@stigmer/runner 3.11.1-dev.20260812192248 → 3.12.0

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.
Files changed (81) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/activities/execute-cursor/attachment-resolver.d.ts +11 -0
  3. package/dist/activities/execute-cursor/attachment-resolver.js +8 -0
  4. package/dist/activities/execute-cursor/attachment-resolver.js.map +1 -1
  5. package/dist/activities/execute-cursor/blueprint-resolver.d.ts +1 -9
  6. package/dist/activities/execute-cursor/blueprint-resolver.js +0 -1
  7. package/dist/activities/execute-cursor/blueprint-resolver.js.map +1 -1
  8. package/dist/activities/execute-cursor/index.d.ts +6 -2
  9. package/dist/activities/execute-cursor/index.js +16 -32
  10. package/dist/activities/execute-cursor/index.js.map +1 -1
  11. package/dist/activities/execute-cursor/prompt-builder.d.ts +15 -11
  12. package/dist/activities/execute-cursor/prompt-builder.js +20 -10
  13. package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
  14. package/dist/activities/execute-deep-agent/attachment-injector.d.ts +11 -0
  15. package/dist/activities/execute-deep-agent/attachment-injector.js +7 -1
  16. package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -1
  17. package/dist/activities/execute-deep-agent/index.js +0 -15
  18. package/dist/activities/execute-deep-agent/index.js.map +1 -1
  19. package/dist/activities/execute-deep-agent/mcp-gate.d.ts +0 -2
  20. package/dist/activities/execute-deep-agent/mcp-gate.js +0 -1
  21. package/dist/activities/execute-deep-agent/mcp-gate.js.map +1 -1
  22. package/dist/activities/execute-deep-agent/prompt-builder.d.ts +7 -8
  23. package/dist/activities/execute-deep-agent/prompt-builder.js +14 -7
  24. package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
  25. package/dist/activities/execute-deep-agent/setup.d.ts +0 -10
  26. package/dist/activities/execute-deep-agent/setup.js +6 -42
  27. package/dist/activities/execute-deep-agent/setup.js.map +1 -1
  28. package/dist/config.d.ts +6 -5
  29. package/dist/config.js.map +1 -1
  30. package/dist/shared/artifact-storage.d.ts +11 -0
  31. package/dist/shared/artifact-storage.js +2 -0
  32. package/dist/shared/artifact-storage.js.map +1 -1
  33. package/dist/shared/attachment-download-urls.d.ts +62 -0
  34. package/dist/shared/attachment-download-urls.js +79 -0
  35. package/dist/shared/attachment-download-urls.js.map +1 -0
  36. package/dist/shared/channel-attachment.d.ts +1 -1
  37. package/dist/shared/channel-attachment.js +1 -1
  38. package/dist/shared/conversation-attachment.d.ts +2 -3
  39. package/dist/shared/conversation-attachment.js +2 -3
  40. package/dist/shared/conversation-attachment.js.map +1 -1
  41. package/dist/shared/mcp-transport-guard.d.ts +2 -2
  42. package/dist/shared/mcp-transport-guard.js +2 -2
  43. package/dist/shared/synthesized-attachment.d.ts +4 -4
  44. package/dist/shared/synthesized-attachment.js +4 -4
  45. package/package.json +2 -2
  46. package/src/__test-utils__/fake-artifact-storage.ts +10 -1
  47. package/src/activities/execute-cursor/__tests__/attachment-resolver.test.ts +63 -3
  48. package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +62 -29
  49. package/src/activities/execute-cursor/attachment-resolver.ts +24 -0
  50. package/src/activities/execute-cursor/blueprint-resolver.ts +1 -10
  51. package/src/activities/execute-cursor/index.ts +22 -37
  52. package/src/activities/execute-cursor/prompt-builder.ts +38 -22
  53. package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +105 -0
  54. package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +0 -2
  55. package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +0 -1
  56. package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +0 -1
  57. package/src/activities/execute-deep-agent/__tests__/mcp-gate.test.ts +2 -7
  58. package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +71 -0
  59. package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +0 -1
  60. package/src/activities/execute-deep-agent/attachment-injector.ts +20 -1
  61. package/src/activities/execute-deep-agent/index.ts +0 -19
  62. package/src/activities/execute-deep-agent/mcp-gate.ts +0 -3
  63. package/src/activities/execute-deep-agent/prompt-builder.ts +27 -15
  64. package/src/activities/execute-deep-agent/setup.ts +6 -65
  65. package/src/config.ts +6 -5
  66. package/src/shared/__tests__/artifact-storage.test.ts +9 -0
  67. package/src/shared/__tests__/attachment-download-urls.test.ts +70 -0
  68. package/src/shared/__tests__/channel-attachment.test.ts +2 -2
  69. package/src/shared/__tests__/synthesized-attachment.test.ts +19 -41
  70. package/src/shared/artifact-storage.ts +11 -0
  71. package/src/shared/attachment-download-urls.ts +98 -0
  72. package/src/shared/channel-attachment.ts +1 -1
  73. package/src/shared/conversation-attachment.ts +2 -3
  74. package/src/shared/mcp-transport-guard.ts +2 -2
  75. package/src/shared/synthesized-attachment.ts +4 -4
  76. package/dist/shared/datastore-attachment.d.ts +0 -99
  77. package/dist/shared/datastore-attachment.js +0 -184
  78. package/dist/shared/datastore-attachment.js.map +0 -1
  79. package/src/activities/execute-deep-agent/__tests__/datastore-degradation.test.ts +0 -104
  80. package/src/shared/__tests__/datastore-attachment.test.ts +0 -293
  81. package/src/shared/datastore-attachment.ts +0 -209
@@ -1,209 +0,0 @@
1
- /**
2
- * The runner-synthesized datastore records attachment (T05, DD-001 SD-2).
3
- *
4
- * When an agent declares `datastore_usages`, the runner synthesizes ONE
5
- * MCP attachment serving the five record tools (DD-005) — the agent
6
- * builder writes a usage line and gets tools; no McpServer resource, no
7
- * Environment, no credential in any manifest. Harness-agnostic like
8
- * mcp-resolver.ts: both ExecuteCursor and ExecuteDeepAgent inject the
9
- * synthesized entry through their existing ResolvedMcpServer paths.
10
- *
11
- * Two connection shapes, one roster (the bridge's records-only roster,
12
- * T05 R1):
13
- * - Bridge endpoint configured (cloud): Streamable HTTP against the
14
- * bridge's /records route, with the execution's own session-scoped
15
- * credential as the Bearer token — the server's reach chain (DD-006
16
- * Path 1) authorizes from that token; the bridge stays a
17
- * non-validating passthrough.
18
- * - No bridge endpoint (OSS/local): a spawned `stigmer mcp-server`
19
- * stdio child with STIGMER_MCP_ROSTER=records against the local
20
- * backend (zero new distribution — the CLI already embeds the
21
- * bridge). No credential: the local backend is unauthenticated and
22
- * OSS callers resolve as the local principal (T05 R2).
23
- *
24
- * Approval-free by construction (DD-001 SD-3): empty toolApprovals +
25
- * pinnedToolApprovals + toolApprovalOverrides mean mergeApprovalPolicies
26
- * emits no entries for this server — zero classifier involvement, and no
27
- * proto surface can target it (the attachment has no McpServerUsage, and
28
- * since issue #349 an agent's overrides are scoped to their own usage's
29
- * server, so a same-named override elsewhere cannot reach this one).
30
- * `discoveredCapabilitiesEmpty`
31
- * is false and the attachment has no McpServerUsage, so the connect
32
- * backfill (whose destructiveHint tightener would force-gate
33
- * delete_record — silently skipped on channels under UNATTENDED mode)
34
- * is structurally unable to touch it. Callers must still inject AFTER
35
- * resolve + backfill; both harness call sites do.
36
- */
37
-
38
- import type { DatastoreUsage } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/spec_pb";
39
- import type { ResolvedMcpServer } from "./mcp-resolver.js";
40
- import { grpcTarget, type SynthesizedAttachmentOptions } from "./synthesized-attachment.js";
41
-
42
- /**
43
- * The synthesized attachment's slug. Reserved: a user McpServer with
44
- * this slug is shadowed by the synthesized attachment (the record tools
45
- * must exist whenever `datastore_usages` says so), with a warning.
46
- */
47
- export const DATASTORE_ATTACHMENT_SLUG = "stigmer-records";
48
-
49
- /** The bridge route serving the records-only roster (mcp-server T05 R1). */
50
- export const RECORDS_ROUTE = "/records";
51
-
52
- /**
53
- * Synthesize the records attachment for an agent's datastore usages.
54
- * Returns undefined when the agent uses no datastores — the attachment
55
- * exists exactly when the usage edge does.
56
- */
57
- export function synthesizeDatastoreAttachment(
58
- datastoreUsages: DatastoreUsage[],
59
- options: SynthesizedAttachmentOptions,
60
- ): ResolvedMcpServer | undefined {
61
- if (datastoreUsages.length === 0) {
62
- return undefined;
63
- }
64
-
65
- // Approval-free by construction + backfill-proof: see file header.
66
- const base = {
67
- slug: DATASTORE_ATTACHMENT_SLUG,
68
- toolApprovals: [],
69
- pinnedToolApprovals: [],
70
- toolApprovalOverrides: [],
71
- discoveredCapabilitiesEmpty: false,
72
- };
73
-
74
- if (options.bridgeEndpoint !== null && options.bridgeEndpoint !== "") {
75
- return {
76
- ...base,
77
- connectionType: "http",
78
- url: options.bridgeEndpoint.replace(/\/+$/, "") + RECORDS_ROUTE,
79
- headers: options.credential !== null && options.credential !== ""
80
- ? { Authorization: `Bearer ${options.credential}` }
81
- : undefined,
82
- };
83
- }
84
-
85
- return {
86
- ...base,
87
- connectionType: "stdio",
88
- command: "stigmer",
89
- args: ["mcp-server"],
90
- env: {
91
- STIGMER_MCP_ROSTER: "records",
92
- STIGMER_SERVER_ADDRESS: grpcTarget(options.backendEndpoint),
93
- },
94
- };
95
- }
96
-
97
- /**
98
- * The five record tools the records roster always serves (DD-005; the
99
- * mcp-server's records roster registers all five unconditionally for the
100
- * agent audience — only the `org` argument shape varies by audience, see
101
- * mcp-server/src/domains/records/tools.ts). Because the roster never
102
- * legitimately narrows, any of these missing from the connected toolset
103
- * means the store is degraded (issue #325) — the prompt section and the
104
- * reconciliation both derive from this one list so they cannot drift.
105
- */
106
- export const EXPECTED_RECORD_TOOLS = [
107
- "describe_datastore",
108
- "find_records",
109
- "insert_record",
110
- "update_record",
111
- "delete_record",
112
- ] as const;
113
-
114
- /**
115
- * Reconcile the record tools actually connected against the roster
116
- * contract (issue #325). Returns the expected tools absent from
117
- * `actualToolNames` — empty means healthy. Names are bare tool names
118
- * exactly as reported by tools/list (the mcp-enabled-tools identity
119
- * space); extraneous names are ignored.
120
- */
121
- export function missingRecordTools(actualToolNames: Iterable<string>): string[] {
122
- const present = new Set(actualToolNames);
123
- return EXPECTED_RECORD_TOOLS.filter((name) => !present.has(name));
124
- }
125
-
126
- /**
127
- * The operator-facing degradation notice (issue #325): pushed as a
128
- * MESSAGE_SYSTEM row on the execution status so "declared N datastores,
129
- * X/5 record tools connected" is visible without reading a transcript.
130
- * Lives HERE with the rest of the datastore-attachment wording — the
131
- * harness only threads it.
132
- */
133
- export function formatDatastoreDegradationNotice(
134
- declaredCount: number,
135
- missing: readonly string[],
136
- ): string {
137
- const connected = EXPECTED_RECORD_TOOLS.length - missing.length;
138
- return (
139
- `Datastore record tools unavailable this turn: declared ` +
140
- `${declaredCount} datastore(s), ${connected}/${EXPECTED_RECORD_TOOLS.length} ` +
141
- `record tools connected (missing: ${missing.join(", ")}). The agent has ` +
142
- `been instructed to disclose this instead of answering from memory.`
143
- );
144
- }
145
-
146
- /**
147
- * The datastores prompt section (DD-005 SD-5, the skills-section
148
- * precedent). Shared by both harnesses so the section text cannot drift
149
- * (the sender-identity precedent). Two honest renderings (issue #325):
150
- *
151
- * - Healthy (`missingToolNames` empty or omitted — the Cursor harness
152
- * always calls it this way: the Cursor SDK connects MCP itself, so
153
- * that harness can never observe the live roster):
154
- * `<available_datastores>` names the attached datastores, points the
155
- * model at describe_datastore first, and carries a standing
156
- * failure-disclosure instruction — the only mechanism that covers
157
- * tools which connected but fail at call time (the WhatsApp-pilot
158
- * outage shape).
159
- * - Degraded (deep-agent only, from missingRecordTools against the
160
- * connected roster): `<unavailable_datastores>` instead — the section
161
- * must not promise tools the agent does not have. Names the declared
162
- * datastores, states which record tools are missing, and instructs
163
- * plain disclosure over improvisation.
164
- */
165
- export function formatDatastoresSection(
166
- datastoreUsages: DatastoreUsage[],
167
- missingToolNames: readonly string[] = [],
168
- ): string {
169
- const entries = datastoreUsages
170
- .map((u) => u.datastoreRef?.slug)
171
- .filter((s): s is string => !!s)
172
- .map((slug) => `- ${slug}`);
173
-
174
- if (missingToolNames.length > 0) {
175
- return [
176
- "<unavailable_datastores>",
177
- "This agent is configured to use the datastores listed below, but the",
178
- "following record tools failed to connect this turn:",
179
- missingToolNames.join(", ") + ".",
180
- "Treat these datastores as unreachable for any operation that needs a",
181
- "missing tool.",
182
- "",
183
- ...entries,
184
- "",
185
- "When the user's request depends on one of these datastores, tell them",
186
- "plainly that the datastore cannot be reached right now. Never answer",
187
- "from memory, guess, or improvise a substitute for what the datastore",
188
- "would have returned.",
189
- "</unavailable_datastores>",
190
- ].join("\n");
191
- }
192
-
193
- return [
194
- "<available_datastores>",
195
- "You have access to the following datastores through the record tools",
196
- `(${EXPECTED_RECORD_TOOLS.join(", ")}).`,
197
- "Before your first operation against a datastore, call describe_datastore to",
198
- "learn its collections, field encodings, and which operations you are allowed",
199
- "to perform.",
200
- "",
201
- ...entries,
202
- "",
203
- "If any record tool is missing from your toolset or a record tool call",
204
- "fails, the datastore is unreachable: tell the user plainly that you cannot",
205
- "reach it right now, and do not answer from memory, guess, or improvise a",
206
- "substitute for what it would have returned.",
207
- "</available_datastores>",
208
- ].join("\n");
209
- }