- Notifications
You must be signed in to change notification settings - Fork 1
π Let XMD name a coding-agent session, and hand it to the native process#559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -16,22 +16,78 @@ | ||||||
| * Until then `<Session.Launch>` refuses that agent before releasing its ACP | ||||||
| * session, which is the failure the contract asks for rather than a hopeful | ||||||
| * spawn. | ||||||
| * | ||||||
| * Adapters differ in one structural way, and it is discriminated rather than | ||||||
| * inferred: who chooses the provider-native session identity. A | ||||||
| * `provider-returned` adapter can only resume a session something else created | ||||||
| * and named. A `client-allocated` adapter names the session first and hands | ||||||
| * that name to the native process, which is what lets a launch construct a | ||||||
| * conversation instead of merely reattaching to one. | ||||||
| */ | ||||||
| export interface NativeAdapter { | ||||||
| import { randomUUID } from "node:crypto"; | ||||||
| import type { IdentityProvenance } from "@executablemd/core"; | ||||||
| interface AdapterCommands { | ||||||
| /** Stable adapter identity β `claude`, `codex`. Never an executable path. */ | ||||||
| launcher: string; | ||||||
| /** Who chooses this adapter's native session identity. */ | ||||||
| identity: IdentityProvenance; | ||||||
| /** The argv that resumes this exact provider-native session. */ | ||||||
| resume(nativeSessionId: string): string[]; | ||||||
| } | ||||||
| /** | ||||||
| * An adapter whose native UI is handed the session it is to create. | ||||||
| * | ||||||
| * `allocate` is the adapter's because the identity is that provider's dialect: | ||||||
| * what shape one takes and what the provider will accept is knowledge about | ||||||
| * the provider, not about launching in general. The provider decides whether a | ||||||
| * freshly allocated candidate wins publication; it does not decide what one | ||||||
| * looks like. | ||||||
| * | ||||||
| * The instruction layer crosses as a file path and never as text, so nothing | ||||||
| * here takes the instructions themselves. | ||||||
| */ | ||||||
| export interface ClientAllocatedAdapter extends AdapterCommands { | ||||||
| identity: "client-allocated"; | ||||||
| /** A fresh provider-native session identity. */ | ||||||
| allocate(): string; | ||||||
| /** The argv that creates a session under `id` with that instruction layer. */ | ||||||
| create(nativeSessionId: string, instructionFile: string): string[]; | ||||||
| } | ||||||
| export interface ProviderReturnedAdapter extends AdapterCommands { | ||||||
| identity: "provider-returned"; | ||||||
| } | ||||||
| export type NativeAdapter = ProviderReturnedAdapter | ClientAllocatedAdapter; | ||||||
| /** Whether this adapter names its own sessions. */ | ||||||
| export function allocatesIdentity(adapter: NativeAdapter): adapter is ClientAllocatedAdapter { | ||||||
| return adapter.identity === "client-allocated"; | ||||||
| } | ||||||
| const ADAPTERS: Readonly<Record<string, NativeAdapter>> = { | ||||||
| claude: { | ||||||
| launcher: "claude", | ||||||
| // XMD names the session before Claude exists, so the native process is | ||||||
| // told which conversation to make rather than reporting one afterwards. | ||||||
| identity: "client-allocated", | ||||||
| // Claude takes a UUID it has never seen and makes it the session's name. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant comment β restates what the code does.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant comment β restates what the code does.
Suggested change
| ||||||
| allocate: () => randomUUID(), | ||||||
| create: (nativeSessionId, instructionFile) => [ | ||||||
| "claude", | ||||||
| "--session-id", | ||||||
| nativeSessionId, | ||||||
| "--system-prompt-file", | ||||||
| instructionFile, | ||||||
| ], | ||||||
| resume: (nativeSessionId) => ["claude", "--resume", nativeSessionId], | ||||||
| }, | ||||||
| codex: { | ||||||
| launcher: "codex", | ||||||
| identity: "provider-returned", | ||||||
| resume: (nativeSessionId) => ["codex", "resume", nativeSessionId], | ||||||
| }, | ||||||
| }; | ||||||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant comment β restates what the code does.