@cursor/july 0.1.33 → 0.1.34
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/README.md +1 -1
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +0 -5
- package/dist/bin/agent-serve.d.ts +1 -0
- package/dist/bin/agent-serve.d.ts.map +1 -1
- package/dist/bin/agent-serve.js +32 -2
- package/dist/channels/github/types.d.ts +10 -7
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.CgZqLyWL.js → app.FPupl4SP.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.WoYunhnT.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.C4KigoQn.js → VPLocalSearchBox.Cd182Cu0.js} +1 -1
- package/dist/docs/assets/chunks/{theme.C_Ty4yT7.js → theme.BEM3Okcd.js} +2 -2
- package/dist/docs/assets/{example-agents_weather-agent.md.Dmrcphhl.js → example-agents_weather-agent.md.BADkPqxQ.js} +6 -4
- package/dist/docs/assets/example-agents_weather-agent.md.BADkPqxQ.lean.js +1 -0
- package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.js +9 -0
- package/dist/docs/assets/guides_cloud-runtime.md.CDJGvVC4.lean.js +1 -0
- package/dist/docs/building-with-agents.html +3 -3
- package/dist/docs/concepts.html +3 -3
- package/dist/docs/deployment.html +3 -3
- package/dist/docs/evals.html +3 -3
- package/dist/docs/example-agents/approval-buddy.html +3 -3
- package/dist/docs/example-agents/benny.html +3 -3
- package/dist/docs/example-agents/bugbot.html +3 -3
- package/dist/docs/example-agents/codebase-wiki.html +3 -3
- package/dist/docs/example-agents/codeowners-review.html +3 -3
- package/dist/docs/example-agents/concierge.html +3 -3
- package/dist/docs/example-agents/fsd.html +3 -3
- package/dist/docs/example-agents/index.html +3 -3
- package/dist/docs/example-agents/knowledge-base.html +3 -3
- package/dist/docs/example-agents/oncall.html +3 -3
- package/dist/docs/example-agents/security-reviewer.html +3 -3
- package/dist/docs/example-agents/slack-agent.html +3 -3
- package/dist/docs/example-agents/weather-agent.html +10 -8
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +5 -5
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.html +3 -3
- package/dist/docs/guides/mcp-oauth.html +3 -3
- package/dist/docs/guides/slack.html +3 -3
- package/dist/docs/guides/webhooks.html +3 -3
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +3 -3
- package/dist/docs/index.html +3 -3
- package/dist/docs/quickstart.html +3 -3
- package/dist/docs/reference/agent-config.html +3 -3
- package/dist/docs/reference/channels.html +3 -3
- package/dist/docs/reference/cli.html +3 -3
- package/dist/docs/reference/connections.html +3 -3
- package/dist/docs/reference/hooks.html +3 -3
- package/dist/docs/reference/http-api.html +3 -3
- package/dist/docs/reference/instructions.html +3 -3
- package/dist/docs/reference/playground.html +3 -3
- package/dist/docs/reference/project-layout.html +3 -3
- package/dist/docs/reference/prompt.html +3 -3
- package/dist/docs/reference/schedules.html +3 -3
- package/dist/docs/reference/sessions.html +3 -3
- package/dist/docs/reference/skills.html +3 -3
- package/dist/docs/reference/subagents.html +3 -3
- package/dist/docs/reference/tools.html +3 -3
- package/dist/docs/scaffolding-agents.html +3 -3
- package/dist/docs/storage.html +3 -3
- package/dist/docs/troubleshooting.html +3 -3
- package/dist/files-backends/agent-store-presigned-url.d.ts +3 -11
- package/dist/files.d.ts +20 -0
- package/dist/files.d.ts.map +1 -1
- package/dist/files.js +20 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/internal/artifacts-store.d.ts +14 -6
- package/dist/internal/artifacts-store.d.ts.map +1 -1
- package/dist/internal/artifacts-store.js +160 -16
- package/dist/internal/cli-convert-automation.d.ts +39 -0
- package/dist/internal/cli-convert-automation.d.ts.map +1 -0
- package/dist/internal/cli-convert-automation.js +280 -0
- package/dist/internal/cli-deploy.d.ts +2 -0
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +1 -1
- package/dist/internal/cli-mcp-oauth.d.ts +23 -0
- package/dist/internal/cli-mcp-oauth.d.ts.map +1 -1
- package/dist/internal/cli-mcp-oauth.js +57 -33
- package/dist/internal/convert-automation/convert-workflow.d.ts +10 -0
- package/dist/internal/convert-automation/convert-workflow.d.ts.map +1 -0
- package/dist/internal/convert-automation/convert-workflow.js +998 -0
- package/dist/internal/convert-automation/index.d.ts +3 -0
- package/dist/internal/convert-automation/index.d.ts.map +1 -0
- package/dist/internal/convert-automation/index.js +1 -0
- package/dist/internal/convert-automation/slug.d.ts +11 -0
- package/dist/internal/convert-automation/slug.d.ts.map +1 -0
- package/dist/internal/convert-automation/slug.js +36 -0
- package/dist/internal/convert-automation/types.d.ts +191 -0
- package/dist/internal/convert-automation/types.d.ts.map +1 -0
- package/dist/internal/convert-automation/types.js +13 -0
- package/dist/internal/deploy-client.d.ts +31 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +48 -0
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +3 -32
- package/dist/internal/init-project.d.ts +1 -0
- package/dist/internal/init-project.d.ts.map +1 -1
- package/dist/internal/init-project.js +1 -1
- package/dist/internal/mcp-endpoint.d.ts +6 -0
- package/dist/internal/mcp-endpoint.d.ts.map +1 -1
- package/dist/internal/mcp-endpoint.js +168 -0
- package/dist/internal/resolved-connections.d.ts +15 -0
- package/dist/internal/resolved-connections.d.ts.map +1 -1
- package/dist/internal/resolved-connections.js +12 -5
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +75 -7
- package/dist/internal/session-engine.d.ts +56 -3
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +252 -83
- package/dist/internal/storage-coordinator.d.ts +0 -15
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +0 -52
- package/dist/internal/workspace.d.ts +10 -5
- package/dist/internal/workspace.d.ts.map +1 -1
- package/dist/internal/workspace.js +13 -0
- package/dist/memory.d.ts +22 -6
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +100 -8
- package/dist/playground/assets/{index-CVlCAcUx.js → index-CDDWw0YX.js} +46 -46
- package/dist/playground/assets/index-MVuNTd8v.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage.d.ts +0 -4
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +0 -4
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/example-agents/weather-agent.md +29 -11
- package/docs/guides/cloud-runtime.md +6 -4
- package/package.json +3 -1
- package/src/artifacts.ts +0 -6
- package/src/bin/agent-serve.ts +36 -2
- package/src/channels/github/types.ts +10 -7
- package/src/files.ts +27 -0
- package/src/index.ts +6 -1
- package/src/internal/artifacts-store.ts +185 -22
- package/src/internal/cli-convert-automation.ts +352 -0
- package/src/internal/cli-deploy.ts +1 -1
- package/src/internal/cli-mcp-oauth.ts +69 -31
- package/src/internal/convert-automation/convert-workflow.ts +1422 -0
- package/src/internal/convert-automation/index.ts +10 -0
- package/src/internal/convert-automation/slug.ts +38 -0
- package/src/internal/convert-automation/types.ts +199 -0
- package/src/internal/deploy-client.ts +78 -0
- package/src/internal/discovery.ts +3 -37
- package/src/internal/init-project.ts +1 -1
- package/src/internal/mcp-endpoint.ts +243 -0
- package/src/internal/resolved-connections.ts +32 -6
- package/src/internal/server.ts +99 -1
- package/src/internal/session-engine.ts +329 -99
- package/src/internal/storage-coordinator.ts +0 -62
- package/src/internal/workspace.ts +19 -5
- package/src/memory.ts +126 -10
- package/src/storage.ts +0 -6
- package/src/types.ts +15 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.B1uHGxBZ.js +0 -1
- package/dist/docs/assets/example-agents_weather-agent.md.Dmrcphhl.lean.js +0 -1
- package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.js +0 -9
- package/dist/docs/assets/guides_cloud-runtime.md.BZ2GA7Es.lean.js +0 -1
- package/dist/playground/assets/index-BRhBbnd4.css +0 -1
|
@@ -32,6 +32,7 @@ import { mergeABInstructions, resolveABMaxPlaygroundSessions, resolveABSplit, }
|
|
|
32
32
|
import { slackThreadPermalink } from "../channels/slack/links.js";
|
|
33
33
|
import { SlackAskDedupeStore, SlackNudgeStore, } from "../channels/slack/nudge-store.js";
|
|
34
34
|
import { resolveDedicatedSlackHostBinding } from "../channels/slack/slack-channel.js";
|
|
35
|
+
import { isCursorHostedFilesAvailable } from "../files-backends/cursor-hosted.js";
|
|
35
36
|
import { DEFAULT_MODEL, DIRECT_TOOL_CALL_CHANNEL_ID, isHostOauthConnectionTransport, isSymbolicConnectionTransport, } from "../types.js";
|
|
36
37
|
import { ABCollector } from "./ab-collector.js";
|
|
37
38
|
import { foldABStream } from "./ab-fold.js";
|
|
@@ -57,7 +58,7 @@ import { StorageCoordinator } from "./storage-coordinator.js";
|
|
|
57
58
|
import { normalizeToolResult, toolCallErrorMessage } from "./tool-result.js";
|
|
58
59
|
import { estimateTurnCostFromApi, roundCostUsd, } from "./turn-cost.js";
|
|
59
60
|
import { TurnGovernor } from "./turn-governor.js";
|
|
60
|
-
import { buildAgentsMdContent, isNestedInGitRepo, materializeWorkspace, writeWorkspaceFiles, } from "./workspace.js";
|
|
61
|
+
import { buildAgentsMdContent, buildCloudMemorySection, isNestedInGitRepo, materializeWorkspace, writeWorkspaceFiles, } from "./workspace.js";
|
|
61
62
|
export const HTTP_CHANNEL_ID = "http";
|
|
62
63
|
export { SCHEDULE_CHANNEL_PREFIX } from "./prompt-context.js";
|
|
63
64
|
export class SessionBusyError extends Error {
|
|
@@ -124,6 +125,8 @@ export class SessionEngine {
|
|
|
124
125
|
/** Sessions with a turn being admitted (before the run promise exists). */
|
|
125
126
|
this.pendingTurns = new Set();
|
|
126
127
|
this.activeTurns = new Map();
|
|
128
|
+
/** Context used by the cloud turn's HTTP MCP callbacks. */
|
|
129
|
+
this.activeToolContexts = new Map();
|
|
127
130
|
/** Aborts the in-flight turn per session so a follow-up can preempt it. */
|
|
128
131
|
this.turnAborts = new Map();
|
|
129
132
|
/** Serializes turn admission per session (latest follow-up wins). */
|
|
@@ -176,7 +179,7 @@ export class SessionEngine {
|
|
|
176
179
|
});
|
|
177
180
|
this.artifactsStore = new ArtifactsStore({
|
|
178
181
|
stateRoot: options.stateRoot,
|
|
179
|
-
|
|
182
|
+
agentName: options.project.name,
|
|
180
183
|
config: options.project.artifacts,
|
|
181
184
|
});
|
|
182
185
|
this.abCollector = new ABCollector(options.project.abs, this.logger, (sessionId) => __awaiter(this, void 0, void 0, function* () { return (yield this.logs.get(sessionId)).snapshot(0); }),
|
|
@@ -219,6 +222,9 @@ export class SessionEngine {
|
|
|
219
222
|
});
|
|
220
223
|
}
|
|
221
224
|
}
|
|
225
|
+
setCloudServerToolsConnection(connection) {
|
|
226
|
+
this.cloudServerToolsConnection = connection;
|
|
227
|
+
}
|
|
222
228
|
/** Shared host services (MCP / GitHub / Slack / reminders / evals / kv / Slack nudges). */
|
|
223
229
|
get host() {
|
|
224
230
|
return {
|
|
@@ -933,7 +939,13 @@ export class SessionEngine {
|
|
|
933
939
|
yield yieldEventLoop();
|
|
934
940
|
}
|
|
935
941
|
}), signal);
|
|
936
|
-
|
|
942
|
+
this.activeToolContexts.set(sessionId, { record, turnId, emit });
|
|
943
|
+
try {
|
|
944
|
+
outcome = yield this.runner.runTurn(request);
|
|
945
|
+
}
|
|
946
|
+
finally {
|
|
947
|
+
this.activeToolContexts.delete(sessionId);
|
|
948
|
+
}
|
|
937
949
|
}
|
|
938
950
|
catch (error) {
|
|
939
951
|
this.approvals.cancelSession(sessionId, "deny");
|
|
@@ -1032,9 +1044,13 @@ export class SessionEngine {
|
|
|
1032
1044
|
if (isFirstTurn) {
|
|
1033
1045
|
if (runtime === "cloud") {
|
|
1034
1046
|
// Cloud VMs have no materialized workspace: ship the full context,
|
|
1035
|
-
// including agent tool script bodies.
|
|
1047
|
+
// including agent tool script bodies. On hosted deployments the
|
|
1048
|
+
// shared memory journal is on the store mount — say where.
|
|
1036
1049
|
const preamble = buildAgentsMdContent(agent, { includeScripts: true });
|
|
1037
|
-
|
|
1050
|
+
const memorySection = isCursorHostedFilesAvailable()
|
|
1051
|
+
? `\n\n${buildCloudMemorySection(this.project.name)}`
|
|
1052
|
+
: "";
|
|
1053
|
+
turnPrompt = `${preamble}${memorySection}\n\n${turnPrompt}`;
|
|
1038
1054
|
}
|
|
1039
1055
|
else if (instructionsInvisibleToHarness) {
|
|
1040
1056
|
// Local workspace whose AGENTS.md the harness will not load. With a
|
|
@@ -1048,7 +1064,7 @@ export class SessionEngine {
|
|
|
1048
1064
|
}
|
|
1049
1065
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId }, (record.sdkAgentId === undefined
|
|
1050
1066
|
? {}
|
|
1051
|
-
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: ((_c = this.project.agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true, runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (agent.model === undefined ? {} : { model: agent.model })), { runtime }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), { customTools: runtime === "local" ? this.buildCustomTools(record, turnId, emit) : {}, mcpServers: this.buildMcpServers(runtime), subagents: buildRunnerSubagents(agent), onUpdate,
|
|
1067
|
+
: { sdkAgentId: record.sdkAgentId })), { workspaceDir: this.harnessCwd(record), sandbox: ((_c = this.project.agent.local) === null || _c === void 0 ? void 0 : _c.sandbox) === true, runnerStateDir: join(this.stateRoot, "runner"), prompt: turnPrompt, isFirstTurn }), (agent.model === undefined ? {} : { model: agent.model })), { runtime }), (mergedCloud === undefined ? {} : { cloud: mergedCloud })), { customTools: runtime === "local" ? this.buildCustomTools(record, turnId, emit) : {}, mcpServers: this.buildMcpServers(runtime, record.sessionId), subagents: buildRunnerSubagents(agent), onUpdate,
|
|
1052
1068
|
signal,
|
|
1053
1069
|
// Local follow-ups expire any lingering active run so a preempted turn
|
|
1054
1070
|
// (or one orphaned by a crashed process) never blocks this send.
|
|
@@ -1068,17 +1084,85 @@ export class SessionEngine {
|
|
|
1068
1084
|
}) });
|
|
1069
1085
|
}
|
|
1070
1086
|
/**
|
|
1071
|
-
*
|
|
1072
|
-
*
|
|
1087
|
+
* Connection names a cloud turn can only reach through the host connection
|
|
1088
|
+
* bridge on the tool MCP endpoint: filtered account connections without a
|
|
1089
|
+
* public bridge URL, and host-OAuth connections whose tokens live on this
|
|
1090
|
+
* host. `hostOnly` names are never bridged — that flag means the model
|
|
1091
|
+
* must not see the connection at all, on any runtime.
|
|
1092
|
+
*/
|
|
1093
|
+
cloudBridgeableConnectionNames() {
|
|
1094
|
+
const hostOnlyNames = new Set(this.project.agent.connections
|
|
1095
|
+
.filter((connection) => connection.hostOnly === true)
|
|
1096
|
+
.map((connection) => connection.name));
|
|
1097
|
+
const names = [];
|
|
1098
|
+
for (const connection of this.project.agent.connections) {
|
|
1099
|
+
if (!hostOnlyNames.has(connection.name) &&
|
|
1100
|
+
isHostOauthConnectionTransport(connection.transport)) {
|
|
1101
|
+
names.push(connection.name);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
for (const resolved of this.resolvedConnections) {
|
|
1105
|
+
if (!hostOnlyNames.has(resolved.name) &&
|
|
1106
|
+
resolved.accountServersFilter !== undefined &&
|
|
1107
|
+
resolved.cloudUrl === undefined) {
|
|
1108
|
+
names.push(resolved.name);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
return names;
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* True when cloud turns reach `name` through the host connection bridge —
|
|
1115
|
+
* the gate the tool MCP endpoint applies before forwarding a bridge
|
|
1116
|
+
* request to `host.mcp`, so `hostOnly` connections (and arbitrary names)
|
|
1117
|
+
* stay unreachable from a VM.
|
|
1118
|
+
*/
|
|
1119
|
+
isCloudBridgedConnection(name) {
|
|
1120
|
+
if (this.cloudServerToolsConnection === undefined) {
|
|
1121
|
+
return false;
|
|
1122
|
+
}
|
|
1123
|
+
return this.cloudBridgeableConnectionNames().includes(name);
|
|
1124
|
+
}
|
|
1125
|
+
/**
|
|
1126
|
+
* Session-bound transport for one host-bridged connection: the tool MCP
|
|
1127
|
+
* endpoint with the connection named, so `tools/list` / `tools/call`
|
|
1128
|
+
* forward to the host-side client (`host.mcp`) where the credential —
|
|
1129
|
+
* account bridge secret or host OAuth token — actually lives.
|
|
1130
|
+
*/
|
|
1131
|
+
cloudBridgeTransport(sessionId, connectionName) {
|
|
1132
|
+
const connection = this.cloudServerToolsConnection;
|
|
1133
|
+
if (connection === undefined || !("url" in connection)) {
|
|
1134
|
+
return undefined;
|
|
1135
|
+
}
|
|
1136
|
+
const url = new URL(connection.url);
|
|
1137
|
+
url.searchParams.set("agentkitSessionId", sessionId);
|
|
1138
|
+
url.searchParams.set("connection", connectionName);
|
|
1139
|
+
return Object.assign(Object.assign({}, connection), { url: url.toString() });
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Authored + resolved MCP servers for a turn. Skips `hostOnly`. On cloud
|
|
1143
|
+
* turns, connections whose credential lives on this host — filtered
|
|
1144
|
+
* account connections without a public bridge URL, host-OAuth servers —
|
|
1145
|
+
* mount as host connection bridges over the tool MCP endpoint instead of
|
|
1146
|
+
* being omitted or failing the turn closed.
|
|
1073
1147
|
*/
|
|
1074
|
-
buildMcpServers(runtime) {
|
|
1148
|
+
buildMcpServers(runtime, sessionId) {
|
|
1075
1149
|
const hostOnlyNames = new Set(this.project.agent.connections
|
|
1076
1150
|
.filter((connection) => connection.hostOnly === true)
|
|
1077
1151
|
.map((connection) => connection.name));
|
|
1152
|
+
const bridgedNames = new Set(runtime === "cloud" &&
|
|
1153
|
+
sessionId !== undefined &&
|
|
1154
|
+
this.cloudServerToolsConnection !== undefined &&
|
|
1155
|
+
"url" in this.cloudServerToolsConnection
|
|
1156
|
+
? this.cloudBridgeableConnectionNames()
|
|
1157
|
+
: []);
|
|
1078
1158
|
assertCloudCanHonorAccountServersFilters({
|
|
1079
1159
|
runtime,
|
|
1080
1160
|
resolvedConnections: this.resolvedConnections.filter((resolved) => !hostOnlyNames.has(resolved.name)),
|
|
1161
|
+
bridgedNames,
|
|
1081
1162
|
});
|
|
1163
|
+
const bridgeTransport = (name) => sessionId === undefined || !bridgedNames.has(name)
|
|
1164
|
+
? undefined
|
|
1165
|
+
: this.cloudBridgeTransport(sessionId, name);
|
|
1082
1166
|
const servers = {};
|
|
1083
1167
|
for (const connection of this.project.agent.connections) {
|
|
1084
1168
|
if (hostOnlyNames.has(connection.name)) {
|
|
@@ -1089,10 +1173,15 @@ export class SessionEngine {
|
|
|
1089
1173
|
}
|
|
1090
1174
|
// A cloud VM cannot use a credential that lives on this host, and the
|
|
1091
1175
|
// cloud API rejects the `oauth` key outright ("Unrecognized key(s) in
|
|
1092
|
-
// object: 'oauth'"), which fails the whole turn.
|
|
1093
|
-
//
|
|
1176
|
+
// object: 'oauth'"), which fails the whole turn. Mount the host
|
|
1177
|
+
// connection bridge instead when serve has a cloud tools URL; omit
|
|
1178
|
+
// otherwise (host tools via `ctx.host.mcp` still reach the server).
|
|
1094
1179
|
if (runtime === "cloud" &&
|
|
1095
1180
|
isHostOauthConnectionTransport(connection.transport)) {
|
|
1181
|
+
const bridged = bridgeTransport(connection.name);
|
|
1182
|
+
if (bridged !== undefined) {
|
|
1183
|
+
servers[connection.name] = bridged;
|
|
1184
|
+
}
|
|
1096
1185
|
continue;
|
|
1097
1186
|
}
|
|
1098
1187
|
servers[connection.name] = connection.transport;
|
|
@@ -1103,6 +1192,13 @@ export class SessionEngine {
|
|
|
1103
1192
|
}
|
|
1104
1193
|
const url = runtime === "cloud" ? resolved.cloudUrl : resolved.localUrl;
|
|
1105
1194
|
if (url === undefined) {
|
|
1195
|
+
// Filtered account connections bridge through the host so the
|
|
1196
|
+
// `servers` filter is honored; unfiltered ones keep their documented
|
|
1197
|
+
// fallback to the account's native connectors on the VM.
|
|
1198
|
+
const bridged = bridgeTransport(resolved.name);
|
|
1199
|
+
if (bridged !== undefined) {
|
|
1200
|
+
servers[resolved.name] = bridged;
|
|
1201
|
+
}
|
|
1106
1202
|
continue;
|
|
1107
1203
|
}
|
|
1108
1204
|
servers[resolved.name] = {
|
|
@@ -1110,6 +1206,20 @@ export class SessionEngine {
|
|
|
1110
1206
|
headers: resolved.headers,
|
|
1111
1207
|
};
|
|
1112
1208
|
}
|
|
1209
|
+
if (runtime === "cloud" &&
|
|
1210
|
+
sessionId !== undefined &&
|
|
1211
|
+
this.cloudServerToolsConnection !== undefined &&
|
|
1212
|
+
this.project.agent.tools.some((tool) => tool.execution === "server")) {
|
|
1213
|
+
if (servers["agentsdk-tools"] !== undefined) {
|
|
1214
|
+
throw new Error('MCP connection name "agentsdk-tools" is reserved for authored server tools on cloud turns.');
|
|
1215
|
+
}
|
|
1216
|
+
const connection = this.cloudServerToolsConnection;
|
|
1217
|
+
if ("url" in connection) {
|
|
1218
|
+
const url = new URL(connection.url);
|
|
1219
|
+
url.searchParams.set("agentkitSessionId", sessionId);
|
|
1220
|
+
servers["agentsdk-tools"] = Object.assign(Object.assign({}, connection), { url: url.toString() });
|
|
1221
|
+
}
|
|
1222
|
+
}
|
|
1113
1223
|
return servers;
|
|
1114
1224
|
}
|
|
1115
1225
|
buildCustomTools(record, turnId, emit) {
|
|
@@ -1126,81 +1236,105 @@ export class SessionEngine {
|
|
|
1126
1236
|
description: tool.description,
|
|
1127
1237
|
inputSchema: tool.inputSchema,
|
|
1128
1238
|
execute: (args, context) => __awaiter(this, void 0, void 0, function* () {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
},
|
|
1138
|
-
],
|
|
1139
|
-
isError: true,
|
|
1140
|
-
};
|
|
1141
|
-
}
|
|
1142
|
-
const toolCallId = (_a = context.toolCallId) !== null && _a !== void 0 ? _a : newToolCallId(tool.name);
|
|
1143
|
-
const toolCtx = {
|
|
1144
|
-
toolCallId,
|
|
1145
|
-
session: this.sessionInfo(record),
|
|
1146
|
-
workspaceDir: this.harnessCwd(record),
|
|
1147
|
-
stateRoot: this.stateRoot,
|
|
1148
|
-
host: this.hostForSession(record.sessionId),
|
|
1149
|
-
artifacts: this.artifactsApi({
|
|
1150
|
-
sessionId: record.sessionId,
|
|
1151
|
-
turnId,
|
|
1152
|
-
}),
|
|
1153
|
-
send: (channelId, message, sendOptions = {}) => this.send(channelId, message, Object.assign(Object.assign({}, sendOptions), { auth: sendOptions.auth !== undefined
|
|
1154
|
-
? sendOptions.auth
|
|
1155
|
-
: record.auth })),
|
|
1156
|
-
getSession: (channelId, sessionId) => this.getChannelSession(channelId, sessionId),
|
|
1157
|
-
};
|
|
1158
|
-
try {
|
|
1159
|
-
const needsGate = yield evaluateNeedsApproval(tool.definition.needsApproval, validation.value);
|
|
1160
|
-
if (needsGate) {
|
|
1161
|
-
const decision = yield this.parkForApproval({
|
|
1162
|
-
sessionId: record.sessionId,
|
|
1163
|
-
turnId,
|
|
1164
|
-
callId: toolCallId,
|
|
1165
|
-
toolName: tool.name,
|
|
1166
|
-
args: validation.value,
|
|
1167
|
-
emit,
|
|
1168
|
-
});
|
|
1169
|
-
if (decision === "deny") {
|
|
1170
|
-
return {
|
|
1171
|
-
content: [
|
|
1172
|
-
{
|
|
1173
|
-
type: "text",
|
|
1174
|
-
text: `Tool "${tool.name}" was denied by a human approver.`,
|
|
1175
|
-
},
|
|
1176
|
-
],
|
|
1177
|
-
isError: true,
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
const started = Date.now();
|
|
1182
|
-
this.logger(`[session] tool ${tool.name} start`);
|
|
1183
|
-
const result = yield execute(validation.value, toolCtx);
|
|
1184
|
-
this.logger(`[session] tool ${tool.name} done (${Date.now() - started}ms)`);
|
|
1185
|
-
return normalizeToolResult(result);
|
|
1186
|
-
}
|
|
1187
|
-
catch (error) {
|
|
1188
|
-
this.logger(`[session] tool ${tool.name} failed: ${describeError(error)}`);
|
|
1189
|
-
return {
|
|
1190
|
-
content: [
|
|
1191
|
-
{
|
|
1192
|
-
type: "text",
|
|
1193
|
-
text: `Tool "${tool.name}" failed: ${describeError(error)}`,
|
|
1194
|
-
},
|
|
1195
|
-
],
|
|
1196
|
-
isError: true,
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1239
|
+
return this.executeServerTool({
|
|
1240
|
+
tool,
|
|
1241
|
+
input: args,
|
|
1242
|
+
toolCallId: context.toolCallId,
|
|
1243
|
+
record,
|
|
1244
|
+
turnId,
|
|
1245
|
+
emit,
|
|
1246
|
+
});
|
|
1199
1247
|
}),
|
|
1200
1248
|
};
|
|
1201
1249
|
}
|
|
1202
1250
|
return tools;
|
|
1203
1251
|
}
|
|
1252
|
+
/**
|
|
1253
|
+
* True while `sessionId` has a turn in flight. The host connection bridge
|
|
1254
|
+
* applies this before forwarding to `host.mcp` — the same window
|
|
1255
|
+
* {@link callActiveServerTool} enforces for authored server tools — so an
|
|
1256
|
+
* endpoint credential that outlives a turn (e.g. in a VM's MCP config)
|
|
1257
|
+
* cannot reach host-credentialed connectors between turns.
|
|
1258
|
+
*/
|
|
1259
|
+
hasActiveTurn(sessionId) {
|
|
1260
|
+
return this.activeToolContexts.has(sessionId);
|
|
1261
|
+
}
|
|
1262
|
+
callActiveServerTool(sessionId, toolName, input) {
|
|
1263
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1264
|
+
const active = this.activeToolContexts.get(sessionId);
|
|
1265
|
+
if (active === undefined) {
|
|
1266
|
+
return toolErrorResult(`Session ${sessionId} has no active turn for tool "${toolName}".`);
|
|
1267
|
+
}
|
|
1268
|
+
const tool = this.project.agent.tools.find((candidate) => candidate.name === toolName && candidate.execution === "server");
|
|
1269
|
+
if (tool === undefined) {
|
|
1270
|
+
return toolErrorResult(`Unknown server tool "${toolName}".`);
|
|
1271
|
+
}
|
|
1272
|
+
const toolCallId = newToolCallId(toolName);
|
|
1273
|
+
this.logger(`[session] cloud HTTP MCP tool ${toolName} dispatch (${sessionId}, ${toolCallId})`);
|
|
1274
|
+
const result = yield this.executeServerTool({
|
|
1275
|
+
tool,
|
|
1276
|
+
input,
|
|
1277
|
+
toolCallId,
|
|
1278
|
+
record: active.record,
|
|
1279
|
+
turnId: active.turnId,
|
|
1280
|
+
emit: active.emit,
|
|
1281
|
+
});
|
|
1282
|
+
this.logger(`[session] cloud HTTP MCP tool ${toolName} complete (${sessionId}, ${toolCallId}, isError=${isErrorEnvelope(result)})`);
|
|
1283
|
+
return result;
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
executeServerTool(args) {
|
|
1287
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1288
|
+
var _a;
|
|
1289
|
+
const execute = args.tool.definition.execute;
|
|
1290
|
+
if (args.tool.execution !== "server" || typeof execute !== "function") {
|
|
1291
|
+
return toolErrorResult(`Tool "${args.tool.name}" is not a server tool.`);
|
|
1292
|
+
}
|
|
1293
|
+
const validation = validateToolInput(args.tool.definition.inputSchema, args.input);
|
|
1294
|
+
if (!validation.ok) {
|
|
1295
|
+
return toolErrorResult(`Invalid input for tool "${args.tool.name}": ${validation.message}`);
|
|
1296
|
+
}
|
|
1297
|
+
const toolCallId = (_a = args.toolCallId) !== null && _a !== void 0 ? _a : newToolCallId(args.tool.name);
|
|
1298
|
+
const toolCtx = {
|
|
1299
|
+
toolCallId,
|
|
1300
|
+
session: this.sessionInfo(args.record),
|
|
1301
|
+
workspaceDir: this.harnessCwd(args.record),
|
|
1302
|
+
stateRoot: this.stateRoot,
|
|
1303
|
+
host: this.hostForSession(args.record.sessionId),
|
|
1304
|
+
artifacts: this.artifactsApi({
|
|
1305
|
+
sessionId: args.record.sessionId,
|
|
1306
|
+
turnId: args.turnId,
|
|
1307
|
+
}),
|
|
1308
|
+
send: (channelId, message, sendOptions = {}) => { var _a; return this.send(channelId, message, Object.assign(Object.assign({}, sendOptions), { auth: (_a = sendOptions.auth) !== null && _a !== void 0 ? _a : args.record.auth })); },
|
|
1309
|
+
getSession: (channelId, sessionId) => this.getChannelSession(channelId, sessionId),
|
|
1310
|
+
};
|
|
1311
|
+
try {
|
|
1312
|
+
const needsGate = yield evaluateNeedsApproval(args.tool.definition.needsApproval, validation.value);
|
|
1313
|
+
if (needsGate) {
|
|
1314
|
+
const decision = yield this.parkForApproval({
|
|
1315
|
+
sessionId: args.record.sessionId,
|
|
1316
|
+
turnId: args.turnId,
|
|
1317
|
+
callId: toolCallId,
|
|
1318
|
+
toolName: args.tool.name,
|
|
1319
|
+
args: validation.value,
|
|
1320
|
+
emit: args.emit,
|
|
1321
|
+
});
|
|
1322
|
+
if (decision === "deny") {
|
|
1323
|
+
return toolErrorResult(`Tool "${args.tool.name}" was denied by a human approver.`);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
const started = Date.now();
|
|
1327
|
+
this.logger(`[session] tool ${args.tool.name} start`);
|
|
1328
|
+
const result = yield execute(validation.value, toolCtx);
|
|
1329
|
+
this.logger(`[session] tool ${args.tool.name} done (${Date.now() - started}ms)`);
|
|
1330
|
+
return normalizeToolResult(result);
|
|
1331
|
+
}
|
|
1332
|
+
catch (error) {
|
|
1333
|
+
this.logger(`[session] tool ${args.tool.name} failed: ${describeError(error)}`);
|
|
1334
|
+
return toolErrorResult(`Tool "${args.tool.name}" failed: ${describeError(error)}`);
|
|
1335
|
+
}
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1204
1338
|
/**
|
|
1205
1339
|
* Park a server-tool call until a human approves or denies. Emits
|
|
1206
1340
|
* `action.approval_requested` / `action.approval_resolved` on the
|
|
@@ -1616,11 +1750,40 @@ export class SessionEngine {
|
|
|
1616
1750
|
if ((options === null || options === void 0 ? void 0 : options.includeAll) === true) {
|
|
1617
1751
|
return records;
|
|
1618
1752
|
}
|
|
1753
|
+
const owned = yield this.ownedSessionIds(caller);
|
|
1754
|
+
return records.filter((record) => record.sessionId !== undefined && owned.has(record.sessionId));
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* One artifact's file/blob payload for `GET /v1/artifacts/:id/content`.
|
|
1759
|
+
* Same visibility rule as {@link listArtifacts}. Undefined when the
|
|
1760
|
+
* artifact is missing, invisible to the caller, or carries no payload.
|
|
1761
|
+
*/
|
|
1762
|
+
getArtifactContent(caller, id, options) {
|
|
1763
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1764
|
+
const record = yield this.artifactsStore.get(id);
|
|
1765
|
+
if (record === undefined || record.content === undefined) {
|
|
1766
|
+
return undefined;
|
|
1767
|
+
}
|
|
1768
|
+
if ((options === null || options === void 0 ? void 0 : options.includeAll) !== true) {
|
|
1769
|
+
if (record.sessionId === undefined) {
|
|
1770
|
+
return undefined;
|
|
1771
|
+
}
|
|
1772
|
+
const owned = yield this.ownedSessionIds(caller);
|
|
1773
|
+
if (!owned.has(record.sessionId)) {
|
|
1774
|
+
return undefined;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
const body = yield this.artifactsStore.getContent(id);
|
|
1778
|
+
return body === undefined ? undefined : { record, body };
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
ownedSessionIds(caller) {
|
|
1782
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1619
1783
|
const sessions = yield this.sessions.list();
|
|
1620
|
-
|
|
1784
|
+
return new Set(sessions
|
|
1621
1785
|
.filter((record) => samePrincipal(record.auth, caller))
|
|
1622
1786
|
.map((record) => record.sessionId));
|
|
1623
|
-
return records.filter((record) => record.sessionId !== undefined && owned.has(record.sessionId));
|
|
1624
1787
|
});
|
|
1625
1788
|
}
|
|
1626
1789
|
/**
|
|
@@ -2273,6 +2436,12 @@ function buildRunnerSubagents(agent) {
|
|
|
2273
2436
|
function describeError(error) {
|
|
2274
2437
|
return error instanceof Error ? error.message : String(error);
|
|
2275
2438
|
}
|
|
2439
|
+
function toolErrorResult(message) {
|
|
2440
|
+
return {
|
|
2441
|
+
content: [{ type: "text", text: message }],
|
|
2442
|
+
isError: true,
|
|
2443
|
+
};
|
|
2444
|
+
}
|
|
2276
2445
|
function defaultGetCloudUsage(sdkAgentId) {
|
|
2277
2446
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2278
2447
|
try {
|
|
@@ -130,21 +130,6 @@ export declare class StorageCoordinator {
|
|
|
130
130
|
kvPut(authorKey: string, value: JsonValue): Promise<void>;
|
|
131
131
|
/** Awaited author KV delete. No-op when the sink omits `delete`. */
|
|
132
132
|
kvDelete(authorKey: string): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* Whether the sink can serve awaited artifact rows: `get` (upsert
|
|
135
|
-
* read-back), `list` (listing + eviction), and `delete` (`max` cap
|
|
136
|
-
* eviction) are all required — without `delete` the retention cap
|
|
137
|
-
* could never evict, so rows fall back to the filesystem store.
|
|
138
|
-
*/
|
|
139
|
-
get supportsArtifacts(): boolean;
|
|
140
|
-
/** Awaited artifact-row read. Errors propagate (read-after-write). */
|
|
141
|
-
artifactGet(id: string): Promise<JsonValue | undefined>;
|
|
142
|
-
/** Awaited artifact-row write (straight to the sink, like author KV). */
|
|
143
|
-
artifactPut(id: string, value: JsonValue): Promise<void>;
|
|
144
|
-
/** Awaited artifact-row delete. Errors propagate (cap eviction). */
|
|
145
|
-
artifactDelete(id: string): Promise<void>;
|
|
146
|
-
/** All artifact-row values for this agent. Errors propagate. */
|
|
147
|
-
artifactList(): Promise<JsonValue[]>;
|
|
148
133
|
/**
|
|
149
134
|
* Adapter over the sink's dedicated `evals` table for the playground
|
|
150
135
|
* eval-run store. Undefined when the table is not configured — eval
|
|
@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pC;IAMD;;;OAGG;IACH,IAAI,gBAAgB,IAAI,OAAO,CAE9B;IAED;;;OAGG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAQ7D;IAED;;;OAGG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9D;IAED,oEAAoE;IAC9D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/C;IAMD;;;;OAIG;IACH,QAAQ,IAAI,cAAc,GAAG,SAAS,CA2CrC;IAMD,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAcrC;IAED;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,UAAU,GAAG,IAAI,CAerC;IAED,sEAAsE;IAChE,mBAAmB,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAc3D;IAMD;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAqB3B;IAED,wEAAwE;IACxE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAExB;IAED,OAAO,CAAC,MAAM;IASd,OAAO,CAAC,WAAW;IAgBnB,2EAA2E;YAC7D,OAAO;IAkBrB,OAAO,CAAC,OAAO;IA8Bf,OAAO,CAAC,OAAO;CAGhB"}
|
|
@@ -364,58 +364,6 @@ export class StorageCoordinator {
|
|
|
364
364
|
});
|
|
365
365
|
}
|
|
366
366
|
// ==========================================================================
|
|
367
|
-
// Artifacts (`ctx.artifacts`)
|
|
368
|
-
// ==========================================================================
|
|
369
|
-
/**
|
|
370
|
-
* Whether the sink can serve awaited artifact rows: `get` (upsert
|
|
371
|
-
* read-back), `list` (listing + eviction), and `delete` (`max` cap
|
|
372
|
-
* eviction) are all required — without `delete` the retention cap
|
|
373
|
-
* could never evict, so rows fall back to the filesystem store.
|
|
374
|
-
*/
|
|
375
|
-
get supportsArtifacts() {
|
|
376
|
-
return (this.definition.get !== undefined &&
|
|
377
|
-
this.definition.list !== undefined &&
|
|
378
|
-
this.definition.delete !== undefined);
|
|
379
|
-
}
|
|
380
|
-
/** Awaited artifact-row read. Errors propagate (read-after-write). */
|
|
381
|
-
artifactGet(id) {
|
|
382
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
383
|
-
const get = this.definition.get;
|
|
384
|
-
if (get === undefined) {
|
|
385
|
-
throw new Error("storage get is not configured");
|
|
386
|
-
}
|
|
387
|
-
const value = yield get(storageKeys.artifact(this.agentName, id), this.context("restore"));
|
|
388
|
-
return value !== null && value !== void 0 ? value : undefined;
|
|
389
|
-
});
|
|
390
|
-
}
|
|
391
|
-
/** Awaited artifact-row write (straight to the sink, like author KV). */
|
|
392
|
-
artifactPut(id, value) {
|
|
393
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
394
|
-
yield this.definition.put(storageKeys.artifact(this.agentName, id), value, this.context("policy"));
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
/** Awaited artifact-row delete. Errors propagate (cap eviction). */
|
|
398
|
-
artifactDelete(id) {
|
|
399
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
400
|
-
const del = this.definition.delete;
|
|
401
|
-
if (del === undefined) {
|
|
402
|
-
throw new Error("storage delete is not configured");
|
|
403
|
-
}
|
|
404
|
-
yield del(storageKeys.artifact(this.agentName, id), this.context("policy"));
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
/** All artifact-row values for this agent. Errors propagate. */
|
|
408
|
-
artifactList() {
|
|
409
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
410
|
-
const list = this.definition.list;
|
|
411
|
-
if (list === undefined) {
|
|
412
|
-
throw new Error("storage list is not configured");
|
|
413
|
-
}
|
|
414
|
-
const entries = yield list(storageKeys.artifactPrefix(this.agentName), this.context("restore"));
|
|
415
|
-
return Array.isArray(entries) ? entries.map((entry) => entry.value) : [];
|
|
416
|
-
});
|
|
417
|
-
}
|
|
418
|
-
// ==========================================================================
|
|
419
367
|
// Evals (dedicated `evals` table)
|
|
420
368
|
// ==========================================================================
|
|
421
369
|
/**
|
|
@@ -17,14 +17,19 @@ export interface MaterializeWorkspaceOptions {
|
|
|
17
17
|
seed: boolean;
|
|
18
18
|
/**
|
|
19
19
|
* Agent state root. `<stateRoot>/memory/` (the durable cross-session
|
|
20
|
-
* directory the memory hook journals into
|
|
21
|
-
* the
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* directory the memory hook journals into — on hosting a local mirror of
|
|
21
|
+
* the Agent Store journal) is created and symlinked into the workspace as
|
|
22
|
+
* `memory` so the agent reads it with plain file tools. Cloud VMs have no
|
|
23
|
+
* materialized workspace; they read the store mount directly (see
|
|
24
|
+
* {@link buildCloudMemorySection}).
|
|
25
25
|
*/
|
|
26
26
|
stateRoot: string;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* First-turn preamble section for cloud-runtime sessions on hosted
|
|
30
|
+
* deployments: cloud VMs read the memory journal from the store mount.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildCloudMemorySection(agentName: string): string;
|
|
28
33
|
/** Relative path of an agent-side tool script inside the session workspace. */
|
|
29
34
|
export declare function agentToolScriptPath(toolName: string): string;
|
|
30
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/internal/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/internal/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAgBH,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,aAAa,EACd,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,2BAA2B;IAC1C,KAAK,EAAE,aAAa,CAAC;IACrB,YAAY,EAAE,MAAM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
|
|
|
17
17
|
};
|
|
18
18
|
import { chmod, copyFile, lstat, mkdir, readlink, rm, stat, symlink, writeFile, } from "node:fs/promises";
|
|
19
19
|
import { dirname, join, parse, relative, resolve, sep } from "node:path";
|
|
20
|
+
import { agentStoreKeys, DEPLOYMENT_STORE_MOUNT_PATH } from "../files.js";
|
|
20
21
|
import { MEMORY_DIR_NAME } from "../memory.js";
|
|
21
22
|
import { parseFrontmatter, serializeFrontmatter } from "./frontmatter.js";
|
|
22
23
|
import { buildIdentitySection } from "./prompt-context.js";
|
|
24
|
+
/**
|
|
25
|
+
* First-turn preamble section for cloud-runtime sessions on hosted
|
|
26
|
+
* deployments: cloud VMs read the memory journal from the store mount.
|
|
27
|
+
*/
|
|
28
|
+
export function buildCloudMemorySection(agentName) {
|
|
29
|
+
const dir = `${DEPLOYMENT_STORE_MOUNT_PATH}/${agentStoreKeys.memoryDir(agentName)}`;
|
|
30
|
+
return [
|
|
31
|
+
"## Shared session memory",
|
|
32
|
+
"",
|
|
33
|
+
`The cross-session memory journal (the \`memory/\` directory your instructions may reference) lives at \`${dir}\` on this machine — read \`${dir}/journal.jsonl\` with your normal file tools.`,
|
|
34
|
+
].join("\n");
|
|
35
|
+
}
|
|
23
36
|
/** Relative path of an agent-side tool script inside the session workspace. */
|
|
24
37
|
export function agentToolScriptPath(toolName) {
|
|
25
38
|
return `.agent-serve/tools/${toolName}.sh`;
|