@stigmer/runner 3.12.7 → 3.12.8
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/index.js +21 -0
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/mcp-gate.d.ts +2 -0
- package/dist/activities/execute-deep-agent/mcp-gate.js +2 -1
- package/dist/activities/execute-deep-agent/mcp-gate.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.js +25 -0
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/shared/memory-attachment.d.ts +97 -0
- package/dist/shared/memory-attachment.js +136 -0
- package/dist/shared/memory-attachment.js.map +1 -0
- package/dist/shared/tool-kind.js +9 -0
- package/dist/shared/tool-kind.js.map +1 -1
- package/package.json +2 -2
- package/src/activities/execute-cursor/index.ts +28 -0
- package/src/activities/execute-deep-agent/__tests__/mcp-gate.test.ts +7 -0
- package/src/activities/execute-deep-agent/mcp-gate.ts +4 -1
- package/src/activities/execute-deep-agent/setup.ts +36 -0
- package/src/shared/__tests__/memory-attachment.test.ts +167 -0
- package/src/shared/memory-attachment.ts +167 -0
- package/src/shared/tool-kind.ts +10 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runner-synthesized memory capture attachment (DD-005 D1).
|
|
3
|
+
*
|
|
4
|
+
* When the execution's recall snapshot says memory is on
|
|
5
|
+
* (`spec.recalled_memories.enabled` — the ONE server-owned field that
|
|
6
|
+
* serves both the recall and capture sides, stamped by the create
|
|
7
|
+
* pipeline's compose step), the runner synthesizes ONE MCP attachment
|
|
8
|
+
* serving the `remember` tool. No discovery RPC exists on this path:
|
|
9
|
+
* unlike the channel attachment's registry read, the enablement answer
|
|
10
|
+
* is already on the spec — a free, synchronous read (the
|
|
11
|
+
* conversation-attachment session-label precedent). The enabled bit with
|
|
12
|
+
* ZERO facts is a meaningful state: memory is on, nothing stored yet —
|
|
13
|
+
* the tool is offered so the first fact can be proposed.
|
|
14
|
+
*
|
|
15
|
+
* Two connection shapes, one roster (the channels pattern):
|
|
16
|
+
* - Bridge endpoint configured (cloud): Streamable HTTP against the
|
|
17
|
+
* bridge's /memory route with the execution's own session-scoped
|
|
18
|
+
* credential as the Bearer token, plus the capture context as
|
|
19
|
+
* per-request headers.
|
|
20
|
+
* - No bridge endpoint (OSS/local): a spawned `stigmer mcp-server`
|
|
21
|
+
* stdio child with STIGMER_MCP_ROSTER=memory, plus the capture
|
|
22
|
+
* context as STIGMER_MEMORY_* env.
|
|
23
|
+
*
|
|
24
|
+
* The capture context (org + agent/session/execution ids) is
|
|
25
|
+
* attribution, never authorization (the Stage 3 provenance decision,
|
|
26
|
+
* owner-ratified 2026-08-22): the cloud create handler accepts it only
|
|
27
|
+
* from a session-sandbox credential and overrides session/org with the
|
|
28
|
+
* token's own claims; the OSS server stores it under the local
|
|
29
|
+
* single-user trust model. The subject is never threaded — the server
|
|
30
|
+
* derives it from the credential (DD-005 D2).
|
|
31
|
+
*
|
|
32
|
+
* Approval-free by construction (the synthesized-attachment contract):
|
|
33
|
+
* the tool only ever creates a PROPOSAL the user must confirm through
|
|
34
|
+
* the control plane, so gating the propose call would stack a second
|
|
35
|
+
* consent gate in front of the real one (DD-005 D3: consent is the
|
|
36
|
+
* confirm RPC, not tool approval). Callers inject AFTER resolve +
|
|
37
|
+
* backfill.
|
|
38
|
+
*
|
|
39
|
+
* Failure posture: the attachment is synthesized from values already in
|
|
40
|
+
* hand, so the only failure mode is the create RPC refusing at call
|
|
41
|
+
* time — which the mcp-server's memory error mapper relays honestly.
|
|
42
|
+
* When the snapshot is absent or disabled: no tool, honest absence.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
import type { RecalledMemories } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
|
|
46
|
+
import type { ResolvedMcpServer } from "./mcp-resolver.js";
|
|
47
|
+
import { grpcTarget, type SynthesizedAttachmentOptions } from "./synthesized-attachment.js";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The synthesized attachment's slug. Reserved: a user McpServer with
|
|
51
|
+
* this slug is shadowed by the synthesized attachment, with a warning.
|
|
52
|
+
* Runner-internal (the resolved-server name and shadow key — the
|
|
53
|
+
* mcp-server never sees it); pinned by this module's test. The ROUTE
|
|
54
|
+
* and the context keys below are cross-repo strings, pinned on both
|
|
55
|
+
* sides (the TOOL_CALL_LIMIT precedent).
|
|
56
|
+
*/
|
|
57
|
+
export const MEMORY_ATTACHMENT_SLUG = "stigmer-memory";
|
|
58
|
+
|
|
59
|
+
/** The bridge route serving the memory-only roster (mcp-server twin: MEMORY_ROUTE). */
|
|
60
|
+
export const MEMORY_ROUTE = "/memory";
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The capture-context carriers, mirrored byte-for-byte by the
|
|
64
|
+
* mcp-server's memory domain (domains/memory/context.ts): headers on
|
|
65
|
+
* the bridge's per-request path, env on the stdio child — the same
|
|
66
|
+
* per-request-then-startup split the credential itself uses.
|
|
67
|
+
*/
|
|
68
|
+
export const MEMORY_ORG_HEADER = "x-stigmer-memory-org";
|
|
69
|
+
export const MEMORY_AGENT_ID_HEADER = "x-stigmer-memory-agent-id";
|
|
70
|
+
export const MEMORY_SESSION_ID_HEADER = "x-stigmer-memory-session-id";
|
|
71
|
+
export const MEMORY_EXECUTION_ID_HEADER = "x-stigmer-memory-execution-id";
|
|
72
|
+
|
|
73
|
+
export const MEMORY_ORG_ENV = "STIGMER_MEMORY_ORG";
|
|
74
|
+
export const MEMORY_AGENT_ID_ENV = "STIGMER_MEMORY_AGENT_ID";
|
|
75
|
+
export const MEMORY_SESSION_ID_ENV = "STIGMER_MEMORY_SESSION_ID";
|
|
76
|
+
export const MEMORY_EXECUTION_ID_ENV = "STIGMER_MEMORY_EXECUTION_ID";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Where a proposed memory comes from — threaded to the mcp-server so
|
|
80
|
+
* the create request carries org addressing and provenance. Empty
|
|
81
|
+
* fields are omitted from the carrier (best-effort attribution; the
|
|
82
|
+
* server treats absent as empty).
|
|
83
|
+
*/
|
|
84
|
+
export interface MemoryCaptureContext {
|
|
85
|
+
readonly org: string;
|
|
86
|
+
readonly agentId: string;
|
|
87
|
+
readonly sessionId: string;
|
|
88
|
+
readonly agentExecutionId: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Reports whether the execution's recall snapshot offers the remember
|
|
93
|
+
* tool (DD-005 D1: the snapshot's enabled bit IS the runner's injection
|
|
94
|
+
* signal — one server-owned field, no parallel flag, no discovery
|
|
95
|
+
* round-trip). Exposed for the harnesses' MCP gates, which must open
|
|
96
|
+
* MCP resolution for a memory-only agent.
|
|
97
|
+
*/
|
|
98
|
+
export function memoryCaptureEnabled(recalled: RecalledMemories | undefined): boolean {
|
|
99
|
+
return recalled?.enabled === true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Synthesize the memory capture attachment. Returns undefined when the
|
|
104
|
+
* recall snapshot is absent or disabled — the attachment exists exactly
|
|
105
|
+
* when the server-composed snapshot says memory is on.
|
|
106
|
+
*/
|
|
107
|
+
export function synthesizeMemoryAttachment(
|
|
108
|
+
recalled: RecalledMemories | undefined,
|
|
109
|
+
context: MemoryCaptureContext,
|
|
110
|
+
options: SynthesizedAttachmentOptions,
|
|
111
|
+
): ResolvedMcpServer | undefined {
|
|
112
|
+
if (!memoryCaptureEnabled(recalled)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Approval-free by construction + backfill-proof: see file header.
|
|
117
|
+
const base = {
|
|
118
|
+
slug: MEMORY_ATTACHMENT_SLUG,
|
|
119
|
+
toolApprovals: [],
|
|
120
|
+
pinnedToolApprovals: [],
|
|
121
|
+
toolApprovalOverrides: [],
|
|
122
|
+
discoveredCapabilitiesEmpty: false,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
if (options.bridgeEndpoint !== null && options.bridgeEndpoint !== "") {
|
|
126
|
+
return {
|
|
127
|
+
...base,
|
|
128
|
+
connectionType: "http",
|
|
129
|
+
url: options.bridgeEndpoint.replace(/\/+$/, "") + MEMORY_ROUTE,
|
|
130
|
+
headers: {
|
|
131
|
+
...(options.credential !== null && options.credential !== ""
|
|
132
|
+
? { Authorization: `Bearer ${options.credential}` }
|
|
133
|
+
: undefined),
|
|
134
|
+
...nonEmptyEntries([
|
|
135
|
+
[MEMORY_ORG_HEADER, context.org],
|
|
136
|
+
[MEMORY_AGENT_ID_HEADER, context.agentId],
|
|
137
|
+
[MEMORY_SESSION_ID_HEADER, context.sessionId],
|
|
138
|
+
[MEMORY_EXECUTION_ID_HEADER, context.agentExecutionId],
|
|
139
|
+
]),
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
...base,
|
|
146
|
+
connectionType: "stdio",
|
|
147
|
+
command: "stigmer",
|
|
148
|
+
args: ["mcp-server"],
|
|
149
|
+
env: {
|
|
150
|
+
STIGMER_MCP_ROSTER: "memory",
|
|
151
|
+
STIGMER_SERVER_ADDRESS: grpcTarget(options.backendEndpoint),
|
|
152
|
+
...nonEmptyEntries([
|
|
153
|
+
[MEMORY_ORG_ENV, context.org],
|
|
154
|
+
[MEMORY_AGENT_ID_ENV, context.agentId],
|
|
155
|
+
[MEMORY_SESSION_ID_ENV, context.sessionId],
|
|
156
|
+
[MEMORY_EXECUTION_ID_ENV, context.agentExecutionId],
|
|
157
|
+
]),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The non-empty context fields as carrier entries (absent means empty). */
|
|
163
|
+
function nonEmptyEntries(
|
|
164
|
+
pairs: ReadonlyArray<readonly [string, string]>,
|
|
165
|
+
): Record<string, string> {
|
|
166
|
+
return Object.fromEntries(pairs.filter(([, value]) => value !== ""));
|
|
167
|
+
}
|
package/src/shared/tool-kind.ts
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
import { ToolKind } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
16
16
|
|
|
17
|
+
import { MEMORY_ATTACHMENT_SLUG } from "./memory-attachment.js";
|
|
18
|
+
|
|
17
19
|
// Bare tool name -> ToolKind, covering both harness naming conventions. A name
|
|
18
20
|
// found here is a built-in and wins over a non-empty mcp_server_slug (an MCP
|
|
19
21
|
// server is not expected to shadow a built-in name; matching the legacy resolver).
|
|
@@ -81,6 +83,14 @@ const TOOL_NAME_TO_KIND: ReadonlyMap<string, ToolKind> = new Map([
|
|
|
81
83
|
* back to a name lookup, so this is never worse than no classification).
|
|
82
84
|
*/
|
|
83
85
|
export function classifyTool(name: string, mcpServerSlug?: string): ToolKind {
|
|
86
|
+
// The first-party remember tool (DD-005), slug-scoped on purpose: it is
|
|
87
|
+
// served by the synthesized memory attachment, so only that reserved
|
|
88
|
+
// slug earns the MEMORY kind (and its consent-chip rendering) — a
|
|
89
|
+
// third-party MCP server's coincidental `remember` stays a plain MCP
|
|
90
|
+
// tool, and a bare `remember` with no slug stays unclassified.
|
|
91
|
+
if (name === "remember" && mcpServerSlug === MEMORY_ATTACHMENT_SLUG) {
|
|
92
|
+
return ToolKind.MEMORY;
|
|
93
|
+
}
|
|
84
94
|
const builtin = TOOL_NAME_TO_KIND.get(name);
|
|
85
95
|
if (builtin !== undefined) {
|
|
86
96
|
return builtin;
|