Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions extensions/connector-claude-code/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export const claudeConnector: Connector = {

const args = ["--dangerously-load-development-channels", CHANNEL_REF];

// Resume a prior conversation into the mesh. `--fork-session` makes claude mint a
// fresh session id from the resumed history, so the original session this id points
// at keeps running untouched (we adopt its context, not its identity).
if (opts.resume) args.push("--resume", opts.resume, "--fork-session");

// An agent file carries identity (read in-session via COTAL_AGENT_FILE) plus
// persona + model, which can only be applied to a `claude` session at launch.
if (opts.configPath) {
Expand Down
4 changes: 3 additions & 1 deletion implementations/cli/src/commands/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function spawn(argv: string[]): Promise<void> {
server: { type: "string" },
agent: { type: "string" },
role: { type: "string" },
resume: { type: "string" },
},
});

Expand All @@ -49,7 +50,7 @@ export async function spawn(argv: string[]): Promise<void> {
const ref = values.config ?? positionals[0] ?? values.name;
if (!ref) {
console.error(
"usage: cotal spawn <name-or-path> | --config <path> | --name <n> [--agent <a>] [--role <r>] [--space <s>] [--server <url>]",
"usage: cotal spawn <name-or-path> | --config <path> | --name <n> [--agent <a>] [--role <r>] [--resume <id>] [--space <s>] [--server <url>]",
);
process.exit(1);
}
Expand Down Expand Up @@ -111,6 +112,7 @@ export async function spawn(argv: string[]): Promise<void> {
creds: credsPath,
servers: server,
configPath: path,
resume: values.resume,
});

console.error(
Expand Down
4 changes: 3 additions & 1 deletion implementations/manager/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function parse(argv: string[]): Values {
agent: { type: "string" },
config: { type: "string" },
creds: { type: "string" },
resume: { type: "string" },
"console-port": { type: "string" },
drive: { type: "boolean" },
},
Expand Down Expand Up @@ -98,6 +99,7 @@ async function start(argv: string[]): Promise<void> {
role: v.role,
agent: v.agent,
config: v.config,
resume: v.resume,
}, v.creds);
failIfNotOk(reply);
const d = reply.data as { name: string; role?: string; agent: string; mode: string };
Expand Down Expand Up @@ -333,7 +335,7 @@ const managerCommands: Command[] = [
name: "start",
group: "Control plane",
summary:
"ask the manager to spawn an agent — --name <n> [--role <r>] [--agent <a>] [--config <file>] (auto-discovers .cotal/agents/<n>.md)",
"ask the manager to spawn an agent — --name <n> [--role <r>] [--agent <a>] [--config <file>] [--resume <id>] (auto-discovers .cotal/agents/<n>.md)",
run: start,
},
{
Expand Down
1 change: 1 addition & 0 deletions implementations/manager/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export class Manager {
creds: credsPath,
servers: this.servers,
configPath,
resume: args.resume ? String(args.resume) : undefined,
});
handle = this.runtime.spawn(name, spec, this.workspaceRoot);
} catch (e) {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export interface LaunchOpts {
* passes it through (`COTAL_AGENT_FILE`) so the joined session reads its own
* card from it, and applies the file's persona/model at launch. */
configPath?: string;
/** Resume a prior session of this agent type instead of starting fresh — the
* connector-specific session id to reattach (claude-code: a `--resume` id,
* forked so the original session isn't hijacked). Connectors that can't resume
* ignore it. */
resume?: string;
}

/** A recipe for starting an agent as a mesh node — command, args, and extra env. */
Expand Down