@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.
- package/dist/.build-fingerprint +1 -1
- package/dist/activities/execute-cursor/attachment-resolver.d.ts +11 -0
- package/dist/activities/execute-cursor/attachment-resolver.js +8 -0
- package/dist/activities/execute-cursor/attachment-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/blueprint-resolver.d.ts +1 -9
- package/dist/activities/execute-cursor/blueprint-resolver.js +0 -1
- package/dist/activities/execute-cursor/blueprint-resolver.js.map +1 -1
- package/dist/activities/execute-cursor/index.d.ts +6 -2
- package/dist/activities/execute-cursor/index.js +16 -32
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +15 -11
- package/dist/activities/execute-cursor/prompt-builder.js +20 -10
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/attachment-injector.d.ts +11 -0
- package/dist/activities/execute-deep-agent/attachment-injector.js +7 -1
- package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -1
- package/dist/activities/execute-deep-agent/index.js +0 -15
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/mcp-gate.d.ts +0 -2
- package/dist/activities/execute-deep-agent/mcp-gate.js +0 -1
- package/dist/activities/execute-deep-agent/mcp-gate.js.map +1 -1
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +7 -8
- package/dist/activities/execute-deep-agent/prompt-builder.js +14 -7
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.d.ts +0 -10
- package/dist/activities/execute-deep-agent/setup.js +6 -42
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/config.d.ts +6 -5
- package/dist/config.js.map +1 -1
- package/dist/shared/artifact-storage.d.ts +11 -0
- package/dist/shared/artifact-storage.js +2 -0
- package/dist/shared/artifact-storage.js.map +1 -1
- package/dist/shared/attachment-download-urls.d.ts +62 -0
- package/dist/shared/attachment-download-urls.js +79 -0
- package/dist/shared/attachment-download-urls.js.map +1 -0
- package/dist/shared/channel-attachment.d.ts +1 -1
- package/dist/shared/channel-attachment.js +1 -1
- package/dist/shared/conversation-attachment.d.ts +2 -3
- package/dist/shared/conversation-attachment.js +2 -3
- package/dist/shared/conversation-attachment.js.map +1 -1
- package/dist/shared/mcp-transport-guard.d.ts +2 -2
- package/dist/shared/mcp-transport-guard.js +2 -2
- package/dist/shared/synthesized-attachment.d.ts +4 -4
- package/dist/shared/synthesized-attachment.js +4 -4
- package/package.json +2 -2
- package/src/__test-utils__/fake-artifact-storage.ts +10 -1
- package/src/activities/execute-cursor/__tests__/attachment-resolver.test.ts +63 -3
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +62 -29
- package/src/activities/execute-cursor/attachment-resolver.ts +24 -0
- package/src/activities/execute-cursor/blueprint-resolver.ts +1 -10
- package/src/activities/execute-cursor/index.ts +22 -37
- package/src/activities/execute-cursor/prompt-builder.ts +38 -22
- package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +105 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-reject.test.ts +0 -2
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-approve-all.test.ts +0 -1
- package/src/activities/execute-deep-agent/__tests__/hitl-resume-history.test.ts +0 -1
- package/src/activities/execute-deep-agent/__tests__/mcp-gate.test.ts +2 -7
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +71 -0
- package/src/activities/execute-deep-agent/__tests__/sequential-gate-resume.test.ts +0 -1
- package/src/activities/execute-deep-agent/attachment-injector.ts +20 -1
- package/src/activities/execute-deep-agent/index.ts +0 -19
- package/src/activities/execute-deep-agent/mcp-gate.ts +0 -3
- package/src/activities/execute-deep-agent/prompt-builder.ts +27 -15
- package/src/activities/execute-deep-agent/setup.ts +6 -65
- package/src/config.ts +6 -5
- package/src/shared/__tests__/artifact-storage.test.ts +9 -0
- package/src/shared/__tests__/attachment-download-urls.test.ts +70 -0
- package/src/shared/__tests__/channel-attachment.test.ts +2 -2
- package/src/shared/__tests__/synthesized-attachment.test.ts +19 -41
- package/src/shared/artifact-storage.ts +11 -0
- package/src/shared/attachment-download-urls.ts +98 -0
- package/src/shared/channel-attachment.ts +1 -1
- package/src/shared/conversation-attachment.ts +2 -3
- package/src/shared/mcp-transport-guard.ts +2 -2
- package/src/shared/synthesized-attachment.ts +4 -4
- package/dist/shared/datastore-attachment.d.ts +0 -99
- package/dist/shared/datastore-attachment.js +0 -184
- package/dist/shared/datastore-attachment.js.map +0 -1
- package/src/activities/execute-deep-agent/__tests__/datastore-degradation.test.ts +0 -104
- package/src/shared/__tests__/datastore-attachment.test.ts +0 -293
- 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
|
-
}
|