Dashboard › opencode › Distillation
8675f697-70b1-44c6-9ee8-72f21375d660["lore_tm_v1_wYFBtnowkFKKe8rMi8vIq0dctwZGM2aLKWQPLTLAsro","lore_tm_v1_IRRYyDnOWmbeoUlFAEOB7fBYuEmmb0d5Ra2LqlZ2Lpk","lore_tm_v1_XD3TAyzmVBBqipK4T3qZaZSS_MCHXfrYz8sw7iisf0A"]
Date: Sep 15, 2026
packages/core/src/session.ts lines 352-358 define V2Session.history: it first validates the session with result.get(input.sessionID), then calls EventV2.readAggregate(db, { ...input, aggregateID: input.sessionID, manifest: SessionDurable }).V2Session.prompt in packages/core/src/session.ts lines 360-387 runs inside Effect.uninterruptible, validates the session, resolves input.prompt with resolvePrompt(), defaults messageID to SessionMessage.ID.create(), and defaults delivery to "steer".V2Session.prompt constructs expected = { sessionID: input.sessionID, messageID, prompt, delivery } and calls SessionInput.admit(db, events, { id: messageID, sessionID: input.sessionID, prompt, delivery, requestExecution: input.resume !== false }).SessionInput.LifecycleConflict defect into PromptConflictError({ sessionID: input.sessionID, messageID }); other defects are rethrown with Effect.die(defect).V2Session.prompt checks SessionInput.equivalent(admitted, expected) and returns PromptConflictError if they differ; unless input.resume === false, it calls execution.wake(admitted.sessionID), then returns admitted.V2Session.shell and V2Session.skill in packages/core/src/session.ts are unavailable and each returns OperationUnavailableError, with operations "shell" and "skill" respectively.V2Session.switchAgent validates input.sessionID through result.get() and publishes SessionEvent.AgentSwitched with sessionID, a newly created SessionMessage.ID, timestamp: yield* DateTime.now, and agent: input.agent.packages/core/script/migration.ts is a Bun executable that parses process.argv.slice(2) via parseArgs, supporting boolean --check and string --name; --check runs check() and exits with status 0, otherwise it runs generate().path.resolve(import.meta.dirname, "../../.."): snapshot packages/core/schema.json, TypeScript migration directory packages/core/src/database/migration, registry packages/core/src/database/migration.gen.ts, and generated schema packages/core/src/database/schema.gen.ts.generate() creates a temporary directory prefixed opencode-core-migration-, with incremental and full subdirectories; it creates incremental/baseline, copies packages/core/schema.json to incremental/baseline/snapshot.json, and invokes drizzle(temporary, incremental, args.values.name).Expected one generated migration, found ${generated.length}. otherwise. If generated, it writes packages/core/src/database/migration/${name}.ts using formatTypescript(renderMigration(...migration.sql)), rejects an existing target with Database migration already exists: ${name}, and replaces packages/core/schema.json with the generated snapshot.json.generate() creates a full migration output, invokes drizzle(temporary, full, "schema"), regenerates packages/core/src/database/schema.gen.ts via formatTypescript(renderSchema(await generatedSql(full))), and regenerates packages/core/src/database/migration.gen.ts via formatTypescript(renderRegistry(await typescriptMigrations())).generate() and check() remove their temporary directories in finally using fs.rm(temporary, { recursive: true, force: true }).check() uses a temporary directory prefixed opencode-core-migration-check-, recreates the incremental baseline from packages/core/schema.json, and runs Drizzle without a migration name. If any incremental migration is generated, it throws: Core schema has ungenerated database migrations. Run \bun script/migration.ts` from packages/core.`check() regenerates the full schema with migration name "schema" and compares it byte-for-byte with packages/core/src/database/schema.gen.ts; mismatch throws: Current database schema is stale. Run \bun script/migration.ts` from packages/core.`check() obtains typescriptMigrations(), renders and formats the registry, and compares it byte-for-byte with packages/core/src/database/migration.gen.ts; mismatch throws: Database migration registry is stale. Run \bun script/migration.ts` from packages/core.`drizzle(temporary, output, name?) writes ${path.basename(output)}.config.ts into the temporary directory, imports packages/core/drizzle.config.ts through a pathToFileURL(...).href, overrides its out value, and runs bun drizzle-kit generate --config ${config} with optional ["--name", name] from the repositoryβs packages/core directory.generatedMigrations(directory) scans with new Bun.Glob("*/migration.sql"), using cwd: directory, and maps each match to its first path segment to obtain migration directory names.