@stigmer/cli 3.1.13 → 3.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigmer/cli",
3
- "version": "3.1.13",
3
+ "version": "3.1.15",
4
4
  "description": "Stigmer command-line interface — manage agents, workflows, MCP servers, skills, and executions from the terminal",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -35,10 +35,10 @@
35
35
  "@connectrpc/connect": "^2.0.0",
36
36
  "@connectrpc/connect-node": "^2.1.1",
37
37
  "@modelcontextprotocol/sdk": "^1.26.0",
38
- "@stigmer/ink": "3.1.13",
39
- "@stigmer/mcp-server": "3.1.13",
40
- "@stigmer/protos": "3.1.13",
41
- "@stigmer/sdk": "3.1.13",
38
+ "@stigmer/ink": "3.1.15",
39
+ "@stigmer/mcp-server": "3.1.15",
40
+ "@stigmer/protos": "3.1.15",
41
+ "@stigmer/sdk": "3.1.15",
42
42
  "commander": "^12.1.0",
43
43
  "fflate": "^0.8.3",
44
44
  "ink": "^7.0.0",
@@ -1 +1 @@
1
- {"version":3,"file":"agent-exec.d.ts","sourceRoot":"","sources":["../../../src/resources/run/agent-exec.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2EvF"}
1
+ {"version":3,"file":"agent-exec.d.ts","sourceRoot":"","sources":["../../../src/resources/run/agent-exec.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAChC;AAED,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DvF"}
@@ -1,48 +1,36 @@
1
1
  // The "run a resolved agent" flow (Go's executeResolvedAgent in
2
- // run_agent_exec.go): create the workspace session if needed, create the agent
3
- // execution, then either detach (print header + re-attach hint) or stream and
4
- // optionally download artifacts. Shared by `run` and `draft`.
5
- import { CliExitError, ExitCode } from "../../errors/index.js";
2
+ // run_agent_exec.go): create the agent execution (one call — a workspace rides
3
+ // the embedded session_spec and the backend bootstraps the session), then
4
+ // either detach (print header + re-attach hint) or stream and optionally
5
+ // download artifacts. Shared by `run` and `draft`.
6
6
  import { downloadExecutionArtifacts } from "../download.js";
7
- import { createAgentExecution, createSessionForAgent } from "./create.js";
7
+ import { createAgentExecution } from "./create.js";
8
8
  import { renderSessionHeader, workspaceNames } from "./header.js";
9
9
  import { streamAgentExecution } from "./stream.js";
10
10
  export async function executeResolvedAgent(input) {
11
11
  const { prepared, org, client } = input;
12
12
  const controller = client.controller.bind(client);
13
13
  const progress = stderrProgress();
14
- // Workspaces require a CLI-created session: the backend's auto-create flow has
15
- // no workspace passthrough (Go's createSessionForAgent).
16
- let sessionId = "";
17
- if (prepared.workspaceEntries.length > 0) {
18
- const instanceId = input.agent.status?.defaultInstanceId ?? "";
19
- if (instanceId === "") {
20
- throw new CliExitError("agent has no default instance — cannot create workspace session", ExitCode.General);
21
- }
22
- progress("Creating workspace...");
23
- const session = await createSessionForAgent(controller, {
24
- agentInstanceId: instanceId,
25
- orgId: org,
26
- workspaceEntries: prepared.workspaceEntries,
27
- });
28
- sessionId = session.metadata?.id ?? "";
29
- }
30
14
  progress("Creating execution...");
15
+ // One call: workspace entries ride the embedded session_spec
16
+ // (stigmer/stigmer#249), so the backend bootstraps the session — resolving
17
+ // the agent's default instance server-side (auto-creating it if missing,
18
+ // which a client-side lookup could not) — and dispatches the message.
31
19
  const execution = await createAgentExecution(controller, {
32
20
  agentId: input.agent.metadata?.id,
33
- sessionId: sessionId === "" ? undefined : sessionId,
34
21
  orgId: org,
35
22
  message: prepared.message,
36
23
  runtimeEnv: prepared.runtimeEnv,
37
24
  attachments: prepared.attachments,
38
25
  workspaceFileRefs: prepared.workspaceFileRefs,
26
+ workspaceEntries: prepared.workspaceEntries,
39
27
  model: prepared.model,
40
28
  mode: prepared.mode,
41
29
  autoApproveAll: prepared.autoApproveAll,
42
30
  });
43
- // The backend owns the canonical session id; prefer it over the CLI-created
44
- // one (they agree, but the spec value is authoritative).
45
- sessionId = execution.spec?.sessionId ?? sessionId;
31
+ // The backend owns the canonical session id: it creates the session and
32
+ // records the id on the returned execution spec.
33
+ const sessionId = execution.spec?.sessionId ?? "";
46
34
  const header = {
47
35
  agentName: input.agent.metadata?.name ?? "",
48
36
  sessionId,
@@ -1 +1 @@
1
- {"version":3,"file":"agent-exec.js","sourceRoot":"","sources":["../../../src/resources/run/agent-exec.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,+EAA+E;AAC/E,8EAA8E;AAC9E,8DAA8D;AAI9D,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAA0B,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1F,OAAO,EAAE,oBAAoB,EAAsB,MAAM,aAAa,CAAC;AAYvE,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,KAA6B;IACtE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACxC,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;IAElC,+EAA+E;IAC/E,yDAAyD;IACzD,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,IAAI,QAAQ,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,iBAAiB,IAAI,EAAE,CAAC;QAC/D,IAAI,UAAU,KAAK,EAAE,EAAE,CAAC;YACtB,MAAM,IAAI,YAAY,CAAC,iEAAiE,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9G,CAAC;QACD,QAAQ,CAAC,uBAAuB,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,UAAU,EAAE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,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;AAC1D,CAAC"}
@@ -2,7 +2,6 @@ import type { Client } from "@connectrpc/connect";
2
2
  import { type DescService } from "@bufbuild/protobuf";
3
3
  import { type AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
4
4
  import type { Attachment } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
5
- import { type Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
6
5
  import type { WorkspaceEntry } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
7
6
  import { type WorkflowExecution } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
8
7
  import type { RuntimeEnv } from "./env.js";
@@ -12,6 +11,10 @@ export type ControllerFn = <Desc extends DescService>(service: Desc) => Client<D
12
11
  * Inputs for creating an agent execution. At least one of agentId/sessionId
13
12
  * must be set: agentId-only starts a new backend-managed session, sessionId
14
13
  * threads a follow-up, both pins the agent within an existing session.
14
+ *
15
+ * workspaceEntries ride the one-call bootstrap (spec.session_spec,
16
+ * stigmer/stigmer#249) and shape the auto-created session; they are mutually
17
+ * exclusive with sessionId (a session's workspace is fixed at creation).
15
18
  */
16
19
  export interface CreateAgentExecutionInput {
17
20
  readonly agentId?: string;
@@ -21,25 +24,13 @@ export interface CreateAgentExecutionInput {
21
24
  readonly runtimeEnv: RuntimeEnv;
22
25
  readonly attachments: readonly Attachment[];
23
26
  readonly workspaceFileRefs: readonly string[];
27
+ readonly workspaceEntries: readonly WorkspaceEntry[];
24
28
  readonly model: string;
25
29
  readonly mode: RunMode;
26
30
  readonly autoApproveAll: boolean;
27
31
  }
28
32
  /** Create an agent execution. Mirrors Go's createAgentExecution. */
29
33
  export declare function createAgentExecution(controller: ControllerFn, input: CreateAgentExecutionInput): Promise<AgentExecution>;
30
- /** Inputs for creating a workspace-bearing session. */
31
- export interface CreateSessionInput {
32
- readonly agentInstanceId: string;
33
- readonly orgId: string;
34
- readonly workspaceEntries: readonly WorkspaceEntry[];
35
- }
36
- /**
37
- * Create a session with explicit workspace entries. Mirrors Go's
38
- * createSessionForAgent: the backend's auto-create flow has no workspace
39
- * passthrough, so the CLI creates the session itself. The "Auto-created session"
40
- * subject matches the backend sentinel, so the async title activity replaces it.
41
- */
42
- export declare function createSessionForAgent(controller: ControllerFn, input: CreateSessionInput): Promise<Session>;
43
34
  /** Inputs for creating a workflow execution. */
44
35
  export interface CreateWorkflowExecutionInput {
45
36
  readonly workflowId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/resources/run/create.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,6DAA6D,CAAC;AAGxH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8DAA8D,CAAC;AAO/F,OAAO,EAAE,KAAK,OAAO,EAAiB,MAAM,sDAAsD,CAAC;AAGnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4DAA4D,CAAC;AACjG,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,gEAAgE,CAAC;AAKxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAM5C,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,SAAS,WAAW,EAAE,OAAO,EAAE,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC;AAErF;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B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ACxB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,cAAc,CAAC,CAuBzB;AAED,gDAAgD;AAChD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,YAAY,EACxB,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,iBAAiB,CAAC,CAY5B"}
@@ -1,5 +1,4 @@
1
- // Resource creation for the run path: AgentExecution, the workspace Session it
2
- // may need, and WorkflowExecution.
1
+ // Resource creation for the run path: AgentExecution and WorkflowExecution.
3
2
  //
4
3
  // Ports the Go CLI's run_create.go. We build the full proto messages and drive
5
4
  // the generated command controllers directly — the Wave-2 fidelity rule (see
@@ -11,8 +10,6 @@ import { AgentExecutionSchema } from "@stigmer/protos/ai/stigmer/agentic/agentex
11
10
  import { AgentExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/command_pb";
12
11
  import { InteractionMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
13
12
  import { AgentExecutionSpecSchema, ExecutionConfigSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
14
- import { SessionSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
15
- import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
16
13
  import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
17
14
  import { WorkflowExecutionSchema, } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
18
15
  import { WorkflowExecutionCommandController } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/command_pb";
@@ -34,30 +31,16 @@ export async function createAgentExecution(controller, input) {
34
31
  autoApproveAll: input.autoApproveAll,
35
32
  sessionId: input.sessionId ?? "",
36
33
  agentId: input.agentId ?? "",
34
+ // Subject is left empty: the server defaults its sentinel and the async
35
+ // title activity replaces it, same as any auto-created session.
36
+ sessionSpec: input.workspaceEntries.length > 0
37
+ ? create(SessionSpecSchema, { workspaceEntries: [...input.workspaceEntries] })
38
+ : undefined,
37
39
  executionConfig: buildExecutionConfig(input.model, input.mode),
38
40
  }),
39
41
  });
40
42
  return controller(AgentExecutionCommandController).create(execution);
41
43
  }
42
- /**
43
- * Create a session with explicit workspace entries. Mirrors Go's
44
- * createSessionForAgent: the backend's auto-create flow has no workspace
45
- * passthrough, so the CLI creates the session itself. The "Auto-created session"
46
- * subject matches the backend sentinel, so the async title activity replaces it.
47
- */
48
- export async function createSessionForAgent(controller, input) {
49
- const session = create(SessionSchema, {
50
- apiVersion: API_VERSION,
51
- kind: "Session",
52
- metadata: create(ApiResourceMetadataSchema, { name: `session-${Date.now()}`, org: input.orgId }),
53
- spec: create(SessionSpecSchema, {
54
- agentInstanceId: input.agentInstanceId,
55
- subject: "Auto-created session",
56
- workspaceEntries: [...input.workspaceEntries],
57
- }),
58
- });
59
- return controller(SessionCommandController).create(session);
60
- }
61
44
  /**
62
45
  * Create a workflow execution. Mirrors Go's createWorkflowExecution. The caller
63
46
  * either detaches (prints IDs) or streams the execution live over the canonical
@@ -1 +1 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/resources/run/create.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,mCAAmC;AACnC,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,iFAAiF;AACjF,4EAA4E;AAC5E,kFAAkF;AAGlF,OAAO,EAAE,MAAM,EAAoB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAuB,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACxH,OAAO,EAAE,+BAA+B,EAAE,MAAM,iE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,CAAC"}
@@ -106,18 +106,19 @@ export async function shareAgent(client, ref, org, options) {
106
106
  * slug equals the agent's (the server's default on create), else the
107
107
  * first entry in that org, else null when the agent has never been shared
108
108
  * there. Mirrors the web dialog's selection so both surfaces manage the
109
- * same row. The org filter is what keeps each org on its own channel
109
+ * same row. The org scope is what keeps each org on its own channel
110
110
  * (decision 013): an agent may be shared in N orgs, and toggling here
111
- * must never edit another org's share.
111
+ * must never edit another org's share. The server applies the scope via
112
+ * the request's org field.
112
113
  */
113
114
  async function resolveCanonicalShare(client, agent, shareOrg) {
114
115
  const result = await client.agentShare.getByAgent(create(GetAgentSharesByAgentRequestSchema, {
115
116
  agentId: agent.metadata?.id ?? "",
117
+ org: shareOrg,
116
118
  }));
117
119
  const agentSlug = agent.metadata?.slug ?? "";
118
- const inOrg = result.items.filter((share) => share.metadata?.org === shareOrg);
119
- return (inOrg.find((share) => share.metadata?.slug === agentSlug) ??
120
- inOrg[0] ??
120
+ return (result.items.find((share) => share.metadata?.slug === agentSlug) ??
121
+ result.items[0] ??
121
122
  null);
122
123
  }
123
124
  // Unspecified means public by contract (a share created without an explicit
@@ -1 +1 @@
1
- {"version":3,"file":"share.js","sourceRoot":"","sources":["../../src/resources/share.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,wCAAwC;AACxC,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,8EAA8E;AAC9E,oCAAoC;AACpC,EAAE;AACF,sEAAsE;AACtE,4EAA4E;AAC5E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,EAAE;AACF,+EAA+E;AAC/E,uEAAuE;AACvE,+EAA+E;AAC/E,4EAA4E;AAE5E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,OAAO,EACL,kCAAkC,EAClC,0BAA0B,GAC3B,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,kBAAkB,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AAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,oBAAoB,GAAG,aAAa,CAAC,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;QAC5E,IAAI,OAAO,CAAC,SAAS,KAAK,IAAI,EAAE,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;QAC/E,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC,kFAAkF,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,128 @@
1
+ // Orchestration tests for executeResolvedAgent: the one-call bootstrap
2
+ // contract (stigmer/stigmer#249). A workspace-bearing run must issue exactly
3
+ // one create RPC — the AgentExecution carrying session_spec — instead of the
4
+ // old session.create + agentExecution.create pair, and the flow must read the
5
+ // canonical session id back from the returned execution spec. Runs use
6
+ // detach mode so no streaming machinery is exercised.
7
+
8
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
9
+ import { create } from "@bufbuild/protobuf";
10
+ import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
11
+ import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
12
+ import type { AgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
13
+ import { ApprovalAction } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
14
+ import {
15
+ LocalPathSourceSchema,
16
+ WorkspaceEntrySchema,
17
+ WorkspaceSourceSchema,
18
+ } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
19
+ import type { BackendClient } from "../../client/index.js";
20
+ import { executeResolvedAgent } from "./agent-exec.js";
21
+ import type { PreparedRun } from "./prepare.js";
22
+
23
+ const WORKSPACE_ENTRY = create(WorkspaceEntrySchema, {
24
+ name: "repo",
25
+ source: create(WorkspaceSourceSchema, {
26
+ source: { case: "localPath", value: create(LocalPathSourceSchema, { path: "/home/user/repo" }) },
27
+ }),
28
+ });
29
+
30
+ function makeAgent(): Agent {
31
+ return create(AgentSchema, {
32
+ metadata: { id: "agt_1", name: "helper" },
33
+ });
34
+ }
35
+
36
+ function makePrepared(overrides: Partial<PreparedRun> = {}): PreparedRun {
37
+ return {
38
+ defaultAction: ApprovalAction.UNSPECIFIED,
39
+ workspaceEntries: [],
40
+ runtimeEnv: {},
41
+ attachments: [],
42
+ workspaceFileRefs: [],
43
+ message: "hi",
44
+ detach: true,
45
+ verbose: false,
46
+ model: "",
47
+ autoApproveAll: false,
48
+ mode: "",
49
+ ...overrides,
50
+ };
51
+ }
52
+
53
+ // A BackendClient double whose controller records every create call and
54
+ // emulates the server stamping the bootstrapped session id onto the returned
55
+ // execution spec.
56
+ function fakeBackend(): { client: BackendClient; creates: () => AgentExecution[] } {
57
+ const captured: AgentExecution[] = [];
58
+ const controller = () => ({
59
+ create: async (msg: AgentExecution) => {
60
+ captured.push(msg);
61
+ // Echo with the server-owned session id filled in, like the real backend.
62
+ return {
63
+ ...msg,
64
+ spec: msg.spec === undefined ? undefined : { ...msg.spec, sessionId: "ses_srv" },
65
+ };
66
+ },
67
+ });
68
+ const client = { controller } as unknown as BackendClient;
69
+ return { client, creates: () => captured };
70
+ }
71
+
72
+ // Captured stderr lines (the header + re-attach hint in detach mode).
73
+ let stderrLines: string[];
74
+
75
+ beforeEach(() => {
76
+ stderrLines = [];
77
+ vi.spyOn(process.stderr, "write").mockImplementation((chunk) => {
78
+ stderrLines.push(String(chunk));
79
+ return true;
80
+ });
81
+ });
82
+
83
+ afterEach(() => {
84
+ vi.restoreAllMocks();
85
+ });
86
+
87
+ describe("executeResolvedAgent", () => {
88
+ it("issues exactly one create carrying session_spec for a workspace run", async () => {
89
+ const { client, creates } = fakeBackend();
90
+
91
+ await executeResolvedAgent({
92
+ agent: makeAgent(),
93
+ prepared: makePrepared({ workspaceEntries: [WORKSPACE_ENTRY] }),
94
+ org: "acme",
95
+ downloadDir: "",
96
+ outputMode: "inline",
97
+ client,
98
+ });
99
+
100
+ const sent = creates();
101
+ expect(sent, "a workspace run is a single AgentExecution create").toHaveLength(1);
102
+ expect(sent[0]?.spec?.agentId).toBe("agt_1");
103
+ expect(sent[0]?.spec?.sessionId, "no client-created session id").toBe("");
104
+ expect(sent[0]?.spec?.sessionSpec?.workspaceEntries).toEqual([WORKSPACE_ENTRY]);
105
+
106
+ // The canonical session id comes back on the execution spec and drives the
107
+ // re-attach hint.
108
+ expect(stderrLines.join("")).toContain("stigmer resume ses_srv");
109
+ });
110
+
111
+ it("issues one create with no session_spec when there is no workspace", async () => {
112
+ const { client, creates } = fakeBackend();
113
+
114
+ await executeResolvedAgent({
115
+ agent: makeAgent(),
116
+ prepared: makePrepared(),
117
+ org: "acme",
118
+ downloadDir: "",
119
+ outputMode: "inline",
120
+ client,
121
+ });
122
+
123
+ const sent = creates();
124
+ expect(sent).toHaveLength(1);
125
+ expect(sent[0]?.spec?.sessionSpec).toBeUndefined();
126
+ expect(sent[0]?.spec?.agentId).toBe("agt_1");
127
+ });
128
+ });
@@ -1,13 +1,13 @@
1
1
  // The "run a resolved agent" flow (Go's executeResolvedAgent in
2
- // run_agent_exec.go): create the workspace session if needed, create the agent
3
- // execution, then either detach (print header + re-attach hint) or stream and
4
- // optionally download artifacts. Shared by `run` and `draft`.
2
+ // run_agent_exec.go): create the agent execution (one call — a workspace rides
3
+ // the embedded session_spec and the backend bootstraps the session), then
4
+ // either detach (print header + re-attach hint) or stream and optionally
5
+ // download artifacts. Shared by `run` and `draft`.
5
6
 
6
7
  import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
7
8
  import type { BackendClient } from "../../client/index.js";
8
- import { CliExitError, ExitCode } from "../../errors/index.js";
9
9
  import { downloadExecutionArtifacts } from "../download.js";
10
- import { createAgentExecution, createSessionForAgent } from "./create.js";
10
+ import { createAgentExecution } from "./create.js";
11
11
  import { renderSessionHeader, type SessionHeaderInfo, workspaceNames } from "./header.js";
12
12
  import type { PreparedRun } from "./prepare.js";
13
13
  import { streamAgentExecution, type RunOutputMode } from "./stream.js";
@@ -27,40 +27,27 @@ export async function executeResolvedAgent(input: ResolvedAgentExecInput): Promi
27
27
  const controller = client.controller.bind(client);
28
28
  const progress = stderrProgress();
29
29
 
30
- // Workspaces require a CLI-created session: the backend's auto-create flow has
31
- // no workspace passthrough (Go's createSessionForAgent).
32
- let sessionId = "";
33
- if (prepared.workspaceEntries.length > 0) {
34
- const instanceId = input.agent.status?.defaultInstanceId ?? "";
35
- if (instanceId === "") {
36
- throw new CliExitError("agent has no default instance — cannot create workspace session", ExitCode.General);
37
- }
38
- progress("Creating workspace...");
39
- const session = await createSessionForAgent(controller, {
40
- agentInstanceId: instanceId,
41
- orgId: org,
42
- workspaceEntries: prepared.workspaceEntries,
43
- });
44
- sessionId = session.metadata?.id ?? "";
45
- }
46
-
47
30
  progress("Creating execution...");
31
+ // One call: workspace entries ride the embedded session_spec
32
+ // (stigmer/stigmer#249), so the backend bootstraps the session — resolving
33
+ // the agent's default instance server-side (auto-creating it if missing,
34
+ // which a client-side lookup could not) — and dispatches the message.
48
35
  const execution = await createAgentExecution(controller, {
49
36
  agentId: input.agent.metadata?.id,
50
- sessionId: sessionId === "" ? undefined : sessionId,
51
37
  orgId: org,
52
38
  message: prepared.message,
53
39
  runtimeEnv: prepared.runtimeEnv,
54
40
  attachments: prepared.attachments,
55
41
  workspaceFileRefs: prepared.workspaceFileRefs,
42
+ workspaceEntries: prepared.workspaceEntries,
56
43
  model: prepared.model,
57
44
  mode: prepared.mode,
58
45
  autoApproveAll: prepared.autoApproveAll,
59
46
  });
60
47
 
61
- // The backend owns the canonical session id; prefer it over the CLI-created
62
- // one (they agree, but the spec value is authoritative).
63
- sessionId = execution.spec?.sessionId ?? sessionId;
48
+ // The backend owns the canonical session id: it creates the session and
49
+ // records the id on the returned execution spec.
50
+ const sessionId = execution.spec?.sessionId ?? "";
64
51
 
65
52
  const header: SessionHeaderInfo = {
66
53
  agentName: input.agent.metadata?.name ?? "",
@@ -1,16 +1,17 @@
1
1
  // Unit tests for run-path resource creation: full-proto field mapping, the
2
2
  // message default, ExecutionConfig presence/contents, runtime-env conversion,
3
- // and session/workflow shapes. The controller is faked to capture the exact
4
- // proto sent to the RPC.
3
+ // the one-call session_spec bootstrap, and the workflow shape. The controller
4
+ // is faked to capture the exact proto sent to the RPC.
5
5
 
6
6
  import { describe, expect, it } from "vitest";
7
7
  import { InteractionMode } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
8
+ import { create } from "@bufbuild/protobuf";
8
9
  import {
9
- type ControllerFn,
10
- createAgentExecution,
11
- createSessionForAgent,
12
- createWorkflowExecution,
13
- } from "./create.js";
10
+ LocalPathSourceSchema,
11
+ WorkspaceEntrySchema,
12
+ WorkspaceSourceSchema,
13
+ } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
14
+ import { type ControllerFn, createAgentExecution, createWorkflowExecution } from "./create.js";
14
15
 
15
16
  // Returns a controller whose every RPC echoes the request back, and records the
16
17
  // last message sent. `create` is the only RPC the run path calls.
@@ -36,6 +37,7 @@ describe("createAgentExecution", () => {
36
37
  runtimeEnv: { FOO: { value: "bar", isSecret: false }, TOKEN: { value: "s", isSecret: true } },
37
38
  attachments: [],
38
39
  workspaceFileRefs: ["src/a.ts"],
40
+ workspaceEntries: [],
39
41
  model: "claude",
40
42
  mode: "plan",
41
43
  autoApproveAll: true,
@@ -62,6 +64,7 @@ describe("createAgentExecution", () => {
62
64
  runtimeEnv: {},
63
65
  attachments: [],
64
66
  workspaceFileRefs: [],
67
+ workspaceEntries: [],
65
68
  model: "",
66
69
  mode: "",
67
70
  autoApproveAll: false,
@@ -79,6 +82,7 @@ describe("createAgentExecution", () => {
79
82
  runtimeEnv: {},
80
83
  attachments: [],
81
84
  workspaceFileRefs: [],
85
+ workspaceEntries: [],
82
86
  model: "m",
83
87
  mode: "agent",
84
88
  autoApproveAll: false,
@@ -86,19 +90,51 @@ describe("createAgentExecution", () => {
86
90
  expect(exec.spec?.sessionId).toBe("ses_1");
87
91
  expect(exec.spec?.executionConfig?.interactionMode).toBe(InteractionMode.UNSPECIFIED);
88
92
  });
89
- });
90
93
 
91
- describe("createSessionForAgent", () => {
92
- it("builds a session with the auto-created subject and instance id", async () => {
94
+ it("embeds workspace entries as session_spec (one-call bootstrap) with an empty subject", async () => {
95
+ const entry = create(WorkspaceEntrySchema, {
96
+ name: "repo",
97
+ source: create(WorkspaceSourceSchema, {
98
+ source: { case: "localPath", value: create(LocalPathSourceSchema, { path: "/home/user/repo" }) },
99
+ }),
100
+ });
101
+
102
+ const { fn } = fakeController();
103
+ const exec = await createAgentExecution(fn, {
104
+ agentId: "agt_1",
105
+ orgId: "acme",
106
+ message: "hi",
107
+ runtimeEnv: {},
108
+ attachments: [],
109
+ workspaceFileRefs: [],
110
+ workspaceEntries: [entry],
111
+ model: "",
112
+ mode: "",
113
+ autoApproveAll: false,
114
+ });
115
+
116
+ expect(exec.spec?.sessionId).toBe("");
117
+ expect(exec.spec?.sessionSpec?.workspaceEntries).toEqual([entry]);
118
+ // Subject stays empty so the server defaults its sentinel and the async
119
+ // title activity generates a real one.
120
+ expect(exec.spec?.sessionSpec?.subject).toBe("");
121
+ });
122
+
123
+ it("omits session_spec when there are no workspace entries", async () => {
93
124
  const { fn } = fakeController();
94
- const session = await createSessionForAgent(fn, {
95
- agentInstanceId: "ain_1",
125
+ const exec = await createAgentExecution(fn, {
126
+ agentId: "agt_1",
96
127
  orgId: "acme",
128
+ message: "hi",
129
+ runtimeEnv: {},
130
+ attachments: [],
131
+ workspaceFileRefs: [],
97
132
  workspaceEntries: [],
133
+ model: "",
134
+ mode: "",
135
+ autoApproveAll: false,
98
136
  });
99
- expect(session.kind).toBe("Session");
100
- expect(session.spec?.agentInstanceId).toBe("ain_1");
101
- expect(session.spec?.subject).toBe("Auto-created session");
137
+ expect(exec.spec?.sessionSpec).toBeUndefined();
102
138
  });
103
139
  });
104
140
 
@@ -1,5 +1,4 @@
1
- // Resource creation for the run path: AgentExecution, the workspace Session it
2
- // may need, and WorkflowExecution.
1
+ // Resource creation for the run path: AgentExecution and WorkflowExecution.
3
2
  //
4
3
  // Ports the Go CLI's run_create.go. We build the full proto messages and drive
5
4
  // the generated command controllers directly — the Wave-2 fidelity rule (see
@@ -19,8 +18,6 @@ import {
19
18
  ExecutionConfigSchema,
20
19
  } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
21
20
  import type { ExecutionValue } from "@stigmer/protos/ai/stigmer/agentic/executioncontext/v1/spec_pb";
22
- import { type Session, SessionSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
23
- import { SessionCommandController } from "@stigmer/protos/ai/stigmer/agentic/session/v1/command_pb";
24
21
  import { SessionSpecSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/spec_pb";
25
22
  import type { WorkspaceEntry } from "@stigmer/protos/ai/stigmer/agentic/session/v1/workspace_pb";
26
23
  import {
@@ -44,6 +41,10 @@ export type ControllerFn = <Desc extends DescService>(service: Desc) => Client<D
44
41
  * Inputs for creating an agent execution. At least one of agentId/sessionId
45
42
  * must be set: agentId-only starts a new backend-managed session, sessionId
46
43
  * threads a follow-up, both pins the agent within an existing session.
44
+ *
45
+ * workspaceEntries ride the one-call bootstrap (spec.session_spec,
46
+ * stigmer/stigmer#249) and shape the auto-created session; they are mutually
47
+ * exclusive with sessionId (a session's workspace is fixed at creation).
47
48
  */
48
49
  export interface CreateAgentExecutionInput {
49
50
  readonly agentId?: string;
@@ -53,6 +54,7 @@ export interface CreateAgentExecutionInput {
53
54
  readonly runtimeEnv: RuntimeEnv;
54
55
  readonly attachments: readonly Attachment[];
55
56
  readonly workspaceFileRefs: readonly string[];
57
+ readonly workspaceEntries: readonly WorkspaceEntry[];
56
58
  readonly model: string;
57
59
  readonly mode: RunMode;
58
60
  readonly autoApproveAll: boolean;
@@ -75,39 +77,18 @@ export async function createAgentExecution(
75
77
  autoApproveAll: input.autoApproveAll,
76
78
  sessionId: input.sessionId ?? "",
77
79
  agentId: input.agentId ?? "",
80
+ // Subject is left empty: the server defaults its sentinel and the async
81
+ // title activity replaces it, same as any auto-created session.
82
+ sessionSpec:
83
+ input.workspaceEntries.length > 0
84
+ ? create(SessionSpecSchema, { workspaceEntries: [...input.workspaceEntries] })
85
+ : undefined,
78
86
  executionConfig: buildExecutionConfig(input.model, input.mode),
79
87
  }),
80
88
  });
81
89
  return controller(AgentExecutionCommandController).create(execution);
82
90
  }
83
91
 
84
- /** Inputs for creating a workspace-bearing session. */
85
- export interface CreateSessionInput {
86
- readonly agentInstanceId: string;
87
- readonly orgId: string;
88
- readonly workspaceEntries: readonly WorkspaceEntry[];
89
- }
90
-
91
- /**
92
- * Create a session with explicit workspace entries. Mirrors Go's
93
- * createSessionForAgent: the backend's auto-create flow has no workspace
94
- * passthrough, so the CLI creates the session itself. The "Auto-created session"
95
- * subject matches the backend sentinel, so the async title activity replaces it.
96
- */
97
- export async function createSessionForAgent(controller: ControllerFn, input: CreateSessionInput): Promise<Session> {
98
- const session = create(SessionSchema, {
99
- apiVersion: API_VERSION,
100
- kind: "Session",
101
- metadata: create(ApiResourceMetadataSchema, { name: `session-${Date.now()}`, org: input.orgId }),
102
- spec: create(SessionSpecSchema, {
103
- agentInstanceId: input.agentInstanceId,
104
- subject: "Auto-created session",
105
- workspaceEntries: [...input.workspaceEntries],
106
- }),
107
- });
108
- return controller(SessionCommandController).create(session);
109
- }
110
-
111
92
  /** Inputs for creating a workflow execution. */
112
93
  export interface CreateWorkflowExecutionInput {
113
94
  readonly workflowId: string;
@@ -73,11 +73,16 @@ function fakeClient(
73
73
  },
74
74
  },
75
75
  agentShare: {
76
- async getByAgent() {
77
- return {
78
- totalCount: currentShare ? 1 : 0,
79
- items: currentShare ? [currentShare] : [],
80
- };
76
+ // Mirrors the server's org scope: a non-empty request org returns
77
+ // only that org's shares (the contract resolveCanonicalShare relies
78
+ // on to never surface another org's channel).
79
+ async getByAgent(input: { org?: string }) {
80
+ const items =
81
+ currentShare &&
82
+ (!input.org || currentShare.metadata.org === input.org)
83
+ ? [currentShare]
84
+ : [];
85
+ return { totalCount: items.length, items };
81
86
  },
82
87
  async apply(input: AgentShareInput) {
83
88
  if (opts.failWith) throw opts.failWith;
@@ -179,9 +179,10 @@ export async function shareAgent(
179
179
  * slug equals the agent's (the server's default on create), else the
180
180
  * first entry in that org, else null when the agent has never been shared
181
181
  * there. Mirrors the web dialog's selection so both surfaces manage the
182
- * same row. The org filter is what keeps each org on its own channel
182
+ * same row. The org scope is what keeps each org on its own channel
183
183
  * (decision 013): an agent may be shared in N orgs, and toggling here
184
- * must never edit another org's share.
184
+ * must never edit another org's share. The server applies the scope via
185
+ * the request's org field.
185
186
  */
186
187
  async function resolveCanonicalShare(
187
188
  client: Stigmer,
@@ -191,15 +192,13 @@ async function resolveCanonicalShare(
191
192
  const result = await client.agentShare.getByAgent(
192
193
  create(GetAgentSharesByAgentRequestSchema, {
193
194
  agentId: agent.metadata?.id ?? "",
195
+ org: shareOrg,
194
196
  }),
195
197
  );
196
198
  const agentSlug = agent.metadata?.slug ?? "";
197
- const inOrg = result.items.filter(
198
- (share) => share.metadata?.org === shareOrg,
199
- );
200
199
  return (
201
- inOrg.find((share) => share.metadata?.slug === agentSlug) ??
202
- inOrg[0] ??
200
+ result.items.find((share) => share.metadata?.slug === agentSlug) ??
201
+ result.items[0] ??
203
202
  null
204
203
  );
205
204
  }