@cursor/july 0.1.105 → 0.1.107
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/bin/agent-serve.js +1 -8
- package/dist/channels/bitbucket/types.d.ts +2 -4
- package/dist/channels/bitbucket/types.d.ts.map +1 -1
- package/dist/channels/deployments/types.d.ts +5 -8
- package/dist/channels/deployments/types.d.ts.map +1 -1
- package/dist/channels/github/types.d.ts +2 -4
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/gitlab/types.d.ts +2 -5
- package/dist/channels/gitlab/types.d.ts.map +1 -1
- package/dist/channels/origin/types.d.ts +2 -3
- package/dist/channels/origin/types.d.ts.map +1 -1
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +3 -0
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +1 -1
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +48 -11
- package/dist/channels/slack/types.d.ts +4 -3
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +3 -3
- package/dist/docs/ab.html +6 -6
- package/dist/docs/assets/{app.BVwaffdK.js → app.CtuckIiL.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.DXXZxiMv.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.WuWTZ1x8.js → VPLocalSearchBox.Bkkhnu8K.js} +2 -2
- package/dist/docs/assets/chunks/{theme.BYdI_6sF.js → theme.DhpIe0Pa.js} +2 -2
- package/dist/docs/assets/{guides_opentelemetry.md.COh9jFVg.js → guides_opentelemetry.md.SCRMskno.js} +3 -3
- package/dist/docs/assets/{guides_opentelemetry.md.COh9jFVg.lean.js → guides_opentelemetry.md.SCRMskno.lean.js} +1 -1
- package/dist/docs/assets/{reference_channels.md.DBGcaB7m.js → reference_channels.md.D-qTqwcq.js} +2 -2
- package/dist/docs/assets/{reference_channels.md.DBGcaB7m.lean.js → reference_channels.md.D-qTqwcq.lean.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.C6Lo8SEd.js → reference_cli.md.Dm67hd2D.js} +1 -1
- package/dist/docs/assets/{skills_otel.md.CqhobH3B.js → skills_otel.md.B5Ddv1xH.js} +1 -1
- package/dist/docs/assets/{style.BRuM8477.css → style.DCD_zyg3.css} +1 -1
- package/dist/docs/building-with-agents.html +6 -6
- package/dist/docs/concepts.html +5 -5
- package/dist/docs/deployment.html +6 -6
- package/dist/docs/evals.html +6 -6
- package/dist/docs/guides/agent-to-agent.html +6 -6
- package/dist/docs/guides/cloud-agents.html +6 -6
- package/dist/docs/guides/convert-automation.html +6 -6
- package/dist/docs/guides/github.html +6 -6
- package/dist/docs/guides/grokbot-agents.html +6 -6
- package/dist/docs/guides/human-in-the-loop.html +6 -6
- package/dist/docs/guides/mcp-oauth.html +6 -6
- package/dist/docs/guides/opentelemetry.html +8 -8
- package/dist/docs/guides/opentelemetry.md +3 -4
- package/dist/docs/guides/slack.html +6 -6
- package/dist/docs/guides/webhooks.html +6 -6
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +6 -6
- package/dist/docs/index.html +6 -6
- package/dist/docs/llms-full.txt +22 -28
- package/dist/docs/quickstart.html +6 -6
- package/dist/docs/reference/agent-config.html +6 -6
- package/dist/docs/reference/artifacts.html +6 -6
- package/dist/docs/reference/channels.html +7 -7
- package/dist/docs/reference/channels.md +11 -19
- package/dist/docs/reference/cli.html +8 -8
- package/dist/docs/reference/cli.md +5 -2
- package/dist/docs/reference/connections.html +6 -6
- package/dist/docs/reference/extensions.html +6 -6
- package/dist/docs/reference/hooks.html +6 -6
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/instructions.html +6 -6
- package/dist/docs/reference/playground.html +5 -5
- package/dist/docs/reference/project-layout.html +6 -6
- package/dist/docs/reference/prompt.html +6 -6
- package/dist/docs/reference/result.html +6 -6
- package/dist/docs/reference/schedules.html +6 -6
- package/dist/docs/reference/sessions.html +5 -5
- package/dist/docs/reference/skills.html +6 -6
- package/dist/docs/reference/subagents.html +6 -6
- package/dist/docs/reference/tools.html +6 -6
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/skills/ab.html +6 -6
- package/dist/docs/skills/create-agent.html +6 -6
- package/dist/docs/skills/debug.html +5 -5
- package/dist/docs/skills/evals.html +6 -6
- package/dist/docs/skills/framework-map.html +5 -5
- package/dist/docs/skills/github.html +6 -6
- package/dist/docs/skills/hillclimb.html +6 -6
- package/dist/docs/skills/index.html +5 -5
- package/dist/docs/skills/mcp-auth.html +6 -6
- package/dist/docs/skills/otel.html +8 -8
- package/dist/docs/skills/otel.md +3 -3
- package/dist/docs/skills/setup-slack.html +6 -6
- package/dist/docs/storage.html +6 -6
- package/dist/docs/templates/agentic-owners.html +6 -6
- package/dist/docs/templates/agents-md.html +6 -6
- package/dist/docs/templates/code-wiki.html +6 -6
- package/dist/docs/templates/demo.html +6 -6
- package/dist/docs/templates/grokbot-agents.html +6 -6
- package/dist/docs/templates/pr-autofixer.html +6 -6
- package/dist/docs/templates/security-help.html +6 -6
- package/dist/docs/templates/security-reviewer.html +6 -6
- package/dist/docs/templates/triage.html +6 -6
- package/dist/docs/troubleshooting.html +5 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +23 -11
- package/dist/internal/cursor/backend-client.d.ts +25 -0
- package/dist/internal/cursor/backend-client.d.ts.map +1 -1
- package/dist/internal/cursor/backend-client.js +57 -2
- package/dist/internal/deploy-client.d.ts +8 -0
- package/dist/internal/deploy-client.d.ts.map +1 -1
- package/dist/internal/deploy-client.js +14 -0
- package/dist/internal/deploy-manifest.d.ts +3 -0
- package/dist/internal/deploy-manifest.d.ts.map +1 -1
- package/dist/internal/deploy-manifest.js +15 -12
- package/dist/internal/discovery/agent.d.ts.map +1 -1
- package/dist/internal/discovery/agent.js +1 -0
- package/dist/internal/discovery/info.d.ts.map +1 -1
- package/dist/internal/discovery/info.js +7 -3
- package/dist/internal/discovery/modules.d.ts +1 -1
- package/dist/internal/discovery/modules.d.ts.map +1 -1
- package/dist/internal/discovery/modules.js +1 -0
- package/dist/internal/discovery/project.d.ts.map +1 -1
- package/dist/internal/discovery/project.js +3 -0
- package/dist/internal/discovery/reminders.d.ts +7 -0
- package/dist/internal/discovery/reminders.d.ts.map +1 -0
- package/dist/internal/discovery/reminders.js +65 -0
- package/dist/internal/discovery/subagent.js +1 -0
- package/dist/internal/distribution.d.ts +5 -0
- package/dist/internal/distribution.d.ts.map +1 -1
- package/dist/internal/distribution.js +17 -0
- package/dist/internal/framework-storage-selection.d.ts +14 -3
- package/dist/internal/framework-storage-selection.d.ts.map +1 -1
- package/dist/internal/framework-storage-selection.js +36 -6
- package/dist/internal/guest-network.d.ts.map +1 -1
- package/dist/internal/guest-network.js +2 -0
- package/dist/internal/hosted-delivery-protocol.d.ts +48 -0
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +60 -0
- package/dist/internal/hosted-delivery.d.ts +10 -0
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +83 -18
- package/dist/internal/local-control-plane.d.ts +18 -2
- package/dist/internal/local-control-plane.d.ts.map +1 -1
- package/dist/internal/local-control-plane.js +199 -17
- package/dist/internal/reminder-control-plane-protocol.d.ts +187 -0
- package/dist/internal/reminder-control-plane-protocol.d.ts.map +1 -0
- package/dist/internal/reminder-control-plane-protocol.js +244 -0
- package/dist/internal/reminder-runner.d.ts +48 -6
- package/dist/internal/reminder-runner.d.ts.map +1 -1
- package/dist/internal/reminder-runner.js +336 -48
- package/dist/internal/reminder-schedule.d.ts +5 -2
- package/dist/internal/reminder-schedule.d.ts.map +1 -1
- package/dist/internal/reminder-schedule.js +8 -6
- package/dist/internal/reminder-store.d.ts +24 -7
- package/dist/internal/reminder-store.d.ts.map +1 -1
- package/dist/internal/reminder-store.js +6 -5
- package/dist/internal/request-error-status.d.ts +2 -0
- package/dist/internal/request-error-status.d.ts.map +1 -1
- package/dist/internal/request-error-status.js +22 -3
- package/dist/internal/scm/pr-url.d.ts +40 -0
- package/dist/internal/scm/pr-url.d.ts.map +1 -1
- package/dist/internal/scm/pr-url.js +93 -14
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +67 -27
- package/dist/internal/session-engine.d.ts +4 -0
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +5 -0
- package/dist/playground/assets/{index-BaQzjaNK.js → index-Bq2HpEQB.js} +23 -23
- package/dist/playground/assets/index-CZKKNlmb.css +1 -0
- package/dist/playground/index.html +2 -2
- package/dist/reminders.d.ts +24 -5
- package/dist/reminders.d.ts.map +1 -1
- package/dist/reminders.js +28 -5
- package/dist/types.d.ts +89 -20
- package/dist/types.d.ts.map +1 -1
- package/docs/guides/opentelemetry.md +3 -4
- package/docs/reference/channels.md +11 -19
- package/docs/reference/cli.md +5 -2
- package/package.json +3 -3
- package/skills/otel/SKILL.md +3 -3
- package/src/bin/agent-serve.ts +1 -9
- package/src/channels/bitbucket/types.ts +2 -4
- package/src/channels/deployments/types.ts +5 -8
- package/src/channels/github/types.ts +2 -4
- package/src/channels/gitlab/types.ts +2 -5
- package/src/channels/origin/types.ts +2 -3
- package/src/channels/slack/defaults.ts +3 -0
- package/src/channels/slack/dispatch.ts +1 -0
- package/src/channels/slack/live-delivery.ts +53 -12
- package/src/channels/slack/types.ts +4 -3
- package/src/index.ts +6 -3
- package/src/internal/cli-deploy.ts +30 -12
- package/src/internal/cursor/backend-client.ts +90 -2
- package/src/internal/deploy-client.ts +16 -0
- package/src/internal/deploy-manifest.ts +16 -11
- package/src/internal/discovery/agent.ts +1 -0
- package/src/internal/discovery/info.ts +6 -0
- package/src/internal/discovery/modules.ts +2 -4
- package/src/internal/discovery/project.ts +3 -0
- package/src/internal/discovery/reminders.ts +65 -0
- package/src/internal/discovery/subagent.ts +1 -0
- package/src/internal/distribution.ts +20 -0
- package/src/internal/framework-storage-selection.ts +43 -6
- package/src/internal/guest-network.ts +3 -0
- package/src/internal/hosted-delivery-protocol.ts +96 -0
- package/src/internal/hosted-delivery.ts +154 -27
- package/src/internal/local-control-plane.ts +281 -22
- package/src/internal/reminder-control-plane-protocol.ts +499 -0
- package/src/internal/reminder-runner.ts +421 -48
- package/src/internal/reminder-schedule.ts +11 -6
- package/src/internal/reminder-store.ts +27 -7
- package/src/internal/request-error-status.ts +27 -3
- package/src/internal/scm/pr-url.ts +167 -20
- package/src/internal/server.ts +69 -16
- package/src/internal/session-engine.ts +5 -0
- package/src/reminders.ts +35 -4
- package/src/types.ts +95 -20
- package/dist/docs/assets/chunks/@localSearchIndexroot.CJxMklAy.js +0 -1
- package/dist/playground/assets/index-CceqnLTX.css +0 -1
- /package/dist/docs/assets/{reference_cli.md.C6Lo8SEd.lean.js → reference_cli.md.Dm67hd2D.lean.js} +0 -0
- /package/dist/docs/assets/{skills_otel.md.CqhobH3B.lean.js → skills_otel.md.B5Ddv1xH.lean.js} +0 -0
|
@@ -13,7 +13,10 @@
|
|
|
13
13
|
* That selection is a hosting-mode question, not an authoring question.
|
|
14
14
|
* Architecture v2 moves it here: `agent/storage.ts` is rejected at
|
|
15
15
|
* discovery (error diagnostic, so serve and deploy fail early), and the
|
|
16
|
-
* platform picks the default
|
|
16
|
+
* platform picks the default. Architecture v1 with no authored file now
|
|
17
|
+
* uses the same hosted-vs-self-hosted split, so deleting `agent/storage.ts`
|
|
18
|
+
* (required to deploy the same tree onto v2) does not drop the Cursor-hosted
|
|
19
|
+
* session mirror on a still-v1 pod.
|
|
17
20
|
*
|
|
18
21
|
* - **Cursor-managed hosting** (the deployment-generation environment
|
|
19
22
|
* variable is set, same signal that registers `GET /v1/manifest`):
|
|
@@ -33,8 +36,10 @@
|
|
|
33
36
|
* - **Self-hosted**: no mirror. `--state-root` is the durable copy, which
|
|
34
37
|
* is correct when the operator owns the disk.
|
|
35
38
|
*
|
|
36
|
-
* v1
|
|
37
|
-
*
|
|
39
|
+
* v1 still honors an authored `agent/storage.ts` when present. Hosted v1
|
|
40
|
+
* pods with no authored file get the Cursor-hosted lazy mirror (gated on
|
|
41
|
+
* `AGENT_SERVE_DEPLOYMENT_ID`, the same signal the previous authored sinks
|
|
42
|
+
* used). Self-hosted v1 with no authored file stays disk-only.
|
|
38
43
|
*
|
|
39
44
|
* Local disk is not part of this decision. `<stateRoot>/sessions/<id>/`
|
|
40
45
|
* already holds `session.json` and `events.ndjson` unconditionally, through
|
|
@@ -43,10 +48,17 @@
|
|
|
43
48
|
*/
|
|
44
49
|
import { cursorHostedFiles } from "../files-backends/cursor-hosted.js";
|
|
45
50
|
import { defineStorage } from "../storage.js";
|
|
51
|
+
import { AGENT_SERVE_DEPLOYMENT_ID_ENV_VAR, cursorHostedStorage, } from "../storage-backends/cursor-hosted.js";
|
|
46
52
|
import { cursorHostedStorageV2 } from "../storage-backends/cursor-hosted-v2.js";
|
|
47
53
|
import { resolveApiKeySync } from "./cursor/credentials.js";
|
|
48
54
|
import { composeFrameworkStorage, fileSinkStorageCore, frameworkGuardedCas, } from "./framework-file-storage.js";
|
|
49
55
|
import { resolveAgentV2Hosting } from "./v2-hosting.js";
|
|
56
|
+
/**
|
|
57
|
+
* Hosted v2 event-chunk flush debounce. Matches the session view's live poll
|
|
58
|
+
* cadence; a streaming turn still caps each chunk at the coordinator's batch
|
|
59
|
+
* limit, so a long turn writes a few dozen chunks rather than one per event.
|
|
60
|
+
*/
|
|
61
|
+
export const HOSTED_V2_EVENT_FLUSH_DEBOUNCE_MS = 2000;
|
|
50
62
|
/**
|
|
51
63
|
* Pick the backend for framework session state.
|
|
52
64
|
*
|
|
@@ -54,9 +66,19 @@ import { resolveAgentV2Hosting } from "./v2-hosting.js";
|
|
|
54
66
|
* disk is the only copy.
|
|
55
67
|
*/
|
|
56
68
|
export function selectFrameworkStorageDefinition(input) {
|
|
69
|
+
var _a, _b;
|
|
57
70
|
if (input.architecture !== "v2") {
|
|
58
|
-
|
|
59
|
-
|
|
71
|
+
if (input.authored !== undefined) {
|
|
72
|
+
return input.authored;
|
|
73
|
+
}
|
|
74
|
+
const env = (_a = input.env) !== null && _a !== void 0 ? _a : process.env;
|
|
75
|
+
if (((_b = env[AGENT_SERVE_DEPLOYMENT_ID_ENV_VAR]) !== null && _b !== void 0 ? _b : "").trim() !== "") {
|
|
76
|
+
// Hosted v1 pod with no authored sink: keep the Cursor-hosted
|
|
77
|
+
// mirror (lazy restore) so agents can delete `agent/storage.ts`
|
|
78
|
+
// without losing durability while they still run architecture v1.
|
|
79
|
+
return defineStorage(Object.assign({ name: "cursor-hosted (lazy restore)", policy: { restore: "off" } }, cursorHostedStorage()));
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
60
82
|
}
|
|
61
83
|
if (input.authored !== undefined) {
|
|
62
84
|
// Discovery rejects agent/storage.ts on v2 before an engine is built;
|
|
@@ -77,7 +99,15 @@ export function selectFrameworkStorageDefinition(input) {
|
|
|
77
99
|
// backend it is per-key HTTP round trips before the listener even
|
|
78
100
|
// comes up). Follow-ups restore lazily by continuation or session id;
|
|
79
101
|
// GET /v1/sessions lists from the sink either way.
|
|
80
|
-
|
|
102
|
+
//
|
|
103
|
+
// Events flush on a quiet-period debounce rather than only at turn end so
|
|
104
|
+
// the read-only session view and dashboard trace (which have no resident
|
|
105
|
+
// engine to ask) see steps mid-turn. The turn-end record still lands
|
|
106
|
+
// before the execution reply: drainSessionDurability forces the flush.
|
|
107
|
+
const policy = {
|
|
108
|
+
restore: "off",
|
|
109
|
+
debounceMs: HOSTED_V2_EVENT_FLUSH_DEBOUNCE_MS,
|
|
110
|
+
};
|
|
81
111
|
// Full chain (env → bind file → stored login): frozen engines listen
|
|
82
112
|
// unsigned and bind store ids + CURSOR_API_KEY at task time, after this
|
|
83
113
|
// definition is constructed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guest-network.d.ts","sourceRoot":"","sources":["../../src/internal/guest-network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;
|
|
1
|
+
{"version":3,"file":"guest-network.d.ts","sourceRoot":"","sources":["../../src/internal/guest-network.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AACrE,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,sEAAsE;AACtE,eAAO,MAAM,kBAAkB,sBAAsB,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,QAAS,CAAC;AAuB1D,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,OAAO,yBAAyB,CAA6B;IAC5E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,YACE,OAAO,SAAsD,EAC7D,MAAM,GAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAO,EAMzD;CACF;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpE;AAgBD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAQhE;AAED,4EAA4E;AAC5E,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExE;AA+ED,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,OAAQ,CAAC;AAG7C,MAAM,MAAM,uBAAuB,GAAG;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC,CAAC;AA2CF,MAAM,MAAM,uBAAuB,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAE1E,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,uBAAuB,CAAC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,qBAAqB,GAC3B,MAAM,CAER;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAkDjC;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,QAAQ,CAAC,CAuCnB"}
|
|
@@ -27,6 +27,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
27
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
|
+
import { HOSTED_GUEST_RETRY_TRANSIENT } from "./hosted-delivery-protocol.js";
|
|
30
31
|
export const GUEST_NETWORK_UNAVAILABLE = "guest_network_unavailable";
|
|
31
32
|
export const GUEST_CONNECT_STALLED = "guest_connect_stalled";
|
|
32
33
|
/** Control-plane readiness probe. Auth none, same as `/v1/health`. */
|
|
@@ -290,6 +291,7 @@ export function guestNetworkReadinessResponse() {
|
|
|
290
291
|
return new Response(JSON.stringify({
|
|
291
292
|
ok: false,
|
|
292
293
|
error: GUEST_NETWORK_UNAVAILABLE,
|
|
294
|
+
retry: HOSTED_GUEST_RETRY_TRANSIENT,
|
|
293
295
|
message: error.message,
|
|
294
296
|
waitMs: error.waitMs,
|
|
295
297
|
probeAttempts: error.probeAttempts,
|
|
@@ -2,6 +2,28 @@ export declare const HOSTED_DELIVERY_PROTOCOL_VERSION = 2;
|
|
|
2
2
|
export declare const HOSTED_DELIVERY_HEADER = "x-agent-sdk-hosted-delivery";
|
|
3
3
|
export declare const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
|
|
4
4
|
export declare const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
|
|
5
|
+
export declare const HOSTED_GUEST_RETRY_TRANSIENT = "transient";
|
|
6
|
+
export declare const HOSTED_GUEST_RETRY_TERMINAL = "terminal";
|
|
7
|
+
export type HostedGuestRetryDisposition = typeof HOSTED_GUEST_RETRY_TRANSIENT | typeof HOSTED_GUEST_RETRY_TERMINAL;
|
|
8
|
+
export type HostedGuestError = {
|
|
9
|
+
ok: false;
|
|
10
|
+
error: string;
|
|
11
|
+
retry: HostedGuestRetryDisposition;
|
|
12
|
+
message?: string;
|
|
13
|
+
turnStatus?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Hosted delivery is the only HTTP surface whose failures drive Temporal
|
|
17
|
+
* retries. Keep its retry disposition explicit instead of making the shared
|
|
18
|
+
* HTTP error helper guess from a status code.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hostedGuestErrorResponse(input: {
|
|
21
|
+
status: number;
|
|
22
|
+
error: string;
|
|
23
|
+
retry: HostedGuestRetryDisposition;
|
|
24
|
+
message?: string;
|
|
25
|
+
turnStatus?: string;
|
|
26
|
+
}): Response;
|
|
5
27
|
/**
|
|
6
28
|
* Filename under the serve `--state-root` (not the per-slug SessionEngine
|
|
7
29
|
* dir). Hosted freeze uses `/workspace/.agent-serve`; the Temporal host
|
|
@@ -9,6 +31,22 @@ export declare const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
|
|
|
9
31
|
* Must match `AGENT_SERVE_ENGINE_HOSTED_EXECUTION_DIAG_PATH` basename.
|
|
10
32
|
*/
|
|
11
33
|
export declare const HOSTED_EXECUTION_DIAG_FILENAME = "hosted-execution.json";
|
|
34
|
+
/**
|
|
35
|
+
* Reserved hosted-admission `channelKind` for durable reminder fires.
|
|
36
|
+
* Bypasses authored channel admission and invokes ReminderRunner.dispatch.
|
|
37
|
+
* Backend builds envelopes with this constant + {@link HOSTED_REMINDER_EVENT_TYPE}.
|
|
38
|
+
*/
|
|
39
|
+
export declare const HOSTED_REMINDER_CHANNEL_KIND = "agent-sdk:reminder";
|
|
40
|
+
/**
|
|
41
|
+
* Reserved hosted-admission `eventType` for durable reminder fires.
|
|
42
|
+
* Payload is {@link HostedReminderFirePayload}.
|
|
43
|
+
*/
|
|
44
|
+
export declare const HOSTED_REMINDER_EVENT_TYPE = "agent-sdk.reminder/fire";
|
|
45
|
+
/** Compact reminder-fire payload on the reserved hosted-admission path. */
|
|
46
|
+
export type HostedReminderFirePayload = {
|
|
47
|
+
reminderId: string;
|
|
48
|
+
fireCount: number;
|
|
49
|
+
};
|
|
12
50
|
export type HostedAdmissionManagedAutomation = {
|
|
13
51
|
automationUuid: string;
|
|
14
52
|
mcpServerNames: string[];
|
|
@@ -57,5 +95,15 @@ export type HostedExecutionOutcome = {
|
|
|
57
95
|
};
|
|
58
96
|
export declare function parseHostedAdmission(value: unknown): HostedAdmission | undefined;
|
|
59
97
|
export declare function parseHostedExecution(value: unknown): HostedExecution | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* True when the admission envelope is the reserved internal reminder fire
|
|
100
|
+
* path (not an authored channel event).
|
|
101
|
+
*/
|
|
102
|
+
export declare function isHostedReminderAdmission(delivery: HostedAdmission): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Parse `{ reminderId, fireCount }` from a reserved reminder admission
|
|
105
|
+
* payload. Rejects unknown keys and non-integer fireCount.
|
|
106
|
+
*/
|
|
107
|
+
export declare function parseHostedReminderFirePayload(value: unknown): HostedReminderFirePayload | undefined;
|
|
60
108
|
export declare function parseHostedAdmissionOutcome(value: unknown): HostedAdmissionOutcome | undefined;
|
|
61
109
|
//# sourceMappingURL=hosted-delivery-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-delivery-protocol.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAClD,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AACpE,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AACrE,eAAO,MAAM,qBAAqB,kCAAkC,CAAC;AACrE;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,0BAA0B,CAAC;AAEtE,MAAM,MAAM,gCAAgC,GAAG;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,CAAC,CAAC;IACL,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,GAAG,cAAc,CAAC;IACtC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,OAAO,EAAE,OAAO,CA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C;IACjB,iBAAiB,CAAC,EAAE,gCAAgC,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAC9B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC5C;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,CAAC,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,EAAE,CAAC,CAAC;IACL,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,IAAI,CAAC;IACT,CAAC,EAAE,CAAC,CAAC;IACL,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAyEF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,eAAe,GAAG,SAAS,CAuB7B;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,eAAe,GAAG,SAAS,CAe7B;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAK5E;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,yBAAyB,GAAG,SAAS,CAqBvC;AAED,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,OAAO,GACb,sBAAsB,GAAG,SAAS,CAkBpC"}
|
|
@@ -2,6 +2,23 @@ export const HOSTED_DELIVERY_PROTOCOL_VERSION = 2;
|
|
|
2
2
|
export const HOSTED_DELIVERY_HEADER = "x-agent-sdk-hosted-delivery";
|
|
3
3
|
export const HOSTED_ADMISSION_PATH = "/v1/internal/hosted-admission";
|
|
4
4
|
export const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
|
|
5
|
+
export const HOSTED_GUEST_RETRY_TRANSIENT = "transient";
|
|
6
|
+
export const HOSTED_GUEST_RETRY_TERMINAL = "terminal";
|
|
7
|
+
/**
|
|
8
|
+
* Hosted delivery is the only HTTP surface whose failures drive Temporal
|
|
9
|
+
* retries. Keep its retry disposition explicit instead of making the shared
|
|
10
|
+
* HTTP error helper guess from a status code.
|
|
11
|
+
*/
|
|
12
|
+
export function hostedGuestErrorResponse(input) {
|
|
13
|
+
const body = {
|
|
14
|
+
ok: false,
|
|
15
|
+
error: input.error,
|
|
16
|
+
retry: input.retry,
|
|
17
|
+
message: input.message,
|
|
18
|
+
turnStatus: input.turnStatus,
|
|
19
|
+
};
|
|
20
|
+
return Response.json(body, { status: input.status });
|
|
21
|
+
}
|
|
5
22
|
/**
|
|
6
23
|
* Filename under the serve `--state-root` (not the per-slug SessionEngine
|
|
7
24
|
* dir). Hosted freeze uses `/workspace/.agent-serve`; the Temporal host
|
|
@@ -9,6 +26,17 @@ export const HOSTED_EXECUTION_PATH = "/v1/internal/hosted-execution";
|
|
|
9
26
|
* Must match `AGENT_SERVE_ENGINE_HOSTED_EXECUTION_DIAG_PATH` basename.
|
|
10
27
|
*/
|
|
11
28
|
export const HOSTED_EXECUTION_DIAG_FILENAME = "hosted-execution.json";
|
|
29
|
+
/**
|
|
30
|
+
* Reserved hosted-admission `channelKind` for durable reminder fires.
|
|
31
|
+
* Bypasses authored channel admission and invokes ReminderRunner.dispatch.
|
|
32
|
+
* Backend builds envelopes with this constant + {@link HOSTED_REMINDER_EVENT_TYPE}.
|
|
33
|
+
*/
|
|
34
|
+
export const HOSTED_REMINDER_CHANNEL_KIND = "agent-sdk:reminder";
|
|
35
|
+
/**
|
|
36
|
+
* Reserved hosted-admission `eventType` for durable reminder fires.
|
|
37
|
+
* Payload is {@link HostedReminderFirePayload}.
|
|
38
|
+
*/
|
|
39
|
+
export const HOSTED_REMINDER_EVENT_TYPE = "agent-sdk.reminder/fire";
|
|
12
40
|
const DELIVERY_KEYS = new Set([
|
|
13
41
|
"v",
|
|
14
42
|
"channelId",
|
|
@@ -103,6 +131,38 @@ export function parseHostedExecution(value) {
|
|
|
103
131
|
}
|
|
104
132
|
return body;
|
|
105
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* True when the admission envelope is the reserved internal reminder fire
|
|
136
|
+
* path (not an authored channel event).
|
|
137
|
+
*/
|
|
138
|
+
export function isHostedReminderAdmission(delivery) {
|
|
139
|
+
return (delivery.channelKind === HOSTED_REMINDER_CHANNEL_KIND &&
|
|
140
|
+
delivery.eventType === HOSTED_REMINDER_EVENT_TYPE);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parse `{ reminderId, fireCount }` from a reserved reminder admission
|
|
144
|
+
* payload. Rejects unknown keys and non-integer fireCount.
|
|
145
|
+
*/
|
|
146
|
+
export function parseHostedReminderFirePayload(value) {
|
|
147
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
const body = value;
|
|
151
|
+
const keys = Object.keys(body);
|
|
152
|
+
if (keys.length !== 2 ||
|
|
153
|
+
!Object.hasOwn(body, "reminderId") ||
|
|
154
|
+
!Object.hasOwn(body, "fireCount") ||
|
|
155
|
+
!boundedString(body.reminderId, 128) ||
|
|
156
|
+
typeof body.fireCount !== "number" ||
|
|
157
|
+
!Number.isInteger(body.fireCount) ||
|
|
158
|
+
body.fireCount < 0) {
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
reminderId: body.reminderId,
|
|
163
|
+
fireCount: body.fireCount,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
106
166
|
export function parseHostedAdmissionOutcome(value) {
|
|
107
167
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
108
168
|
return undefined;
|
|
@@ -39,6 +39,16 @@ export declare function registerHostedDeliveryRoute(input: {
|
|
|
39
39
|
definition: object;
|
|
40
40
|
}>;
|
|
41
41
|
buildHandlerArgs(channelId: string, sessionPublicId?: string): ChannelHandlerArgs;
|
|
42
|
+
/**
|
|
43
|
+
* Reserved reminder admission: dispatch a hydrated ReminderRunner fire
|
|
44
|
+
* without authored channel admission. Returns the runner's outcome so the
|
|
45
|
+
* route can map fired → task and noop → skip.
|
|
46
|
+
*/
|
|
47
|
+
fireReminder?(reminderId: string, expectedFireCount: number): Promise<{
|
|
48
|
+
reminderId: string;
|
|
49
|
+
outcome: "fired" | "noop";
|
|
50
|
+
reason?: string;
|
|
51
|
+
}>;
|
|
42
52
|
/**
|
|
43
53
|
* Await the session's durable mirror (dispatch chain + storage queue)
|
|
44
54
|
* before the execution reply: the control plane may park the pod the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hosted-delivery.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAKL,KAAK,sBAAsB,EAI5B,MAAM,oBAAoB,CAAC;AAS5B,OAAO,
|
|
1
|
+
{"version":3,"file":"hosted-delivery.d.ts","sourceRoot":"","sources":["../../src/internal/hosted-delivery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAKL,KAAK,sBAAsB,EAI5B,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAOL,KAAK,eAAe,EAOrB,MAAM,+BAA+B,CAAC;AAYvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAOlD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,O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IAAI,CAAC,CAAC;IAC5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,iBAAiB,CAAC,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,8DAA8D;IAC9D,aAAa,CAAC,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,wDAAwD;IACxD,YAAY,CAAC,IAAI,YAAY,EAAE,CAAC;IAChC;;;;;OAKG;IACH,eAAe,CAAC,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C;;;OAGG;IACH,mBAAmB,CAAC,IAAI,OAAO,CAAC,sBAAsB,GAAG,OAAO,CAAC,CAAC;IAClE;;;;OAIG;IACH,mBAAmB,CAAC,IAAI,wBAAwB,CAAC;CAClD,GAAG,IAAI,CAwWP"}
|
|
@@ -14,12 +14,13 @@ import { createDeferredChannelSession, DeferredChannelSessionError, } from "./de
|
|
|
14
14
|
import { formatGuestNetworkServerTiming, GUEST_CONNECT_STALLED, GUEST_NETWORK_UNAVAILABLE, GuestNetworkUnavailableError, isQuietGuestConnectStallMessage, waitForGuestNetworkReady, } from "./guest-network.js";
|
|
15
15
|
import { getHostedAdmissionAdapter, } from "./hosted-admission-adapter.js";
|
|
16
16
|
import { HostedAdmissionLocalSendError, runDuringHostedAdmission, } from "./hosted-admission-context.js";
|
|
17
|
-
import { HOSTED_ADMISSION_PATH, HOSTED_DELIVERY_HEADER, HOSTED_DELIVERY_PROTOCOL_VERSION, HOSTED_EXECUTION_PATH, parseHostedAdmission, parseHostedExecution, } from "./hosted-delivery-protocol.js";
|
|
17
|
+
import { HOSTED_ADMISSION_PATH, HOSTED_DELIVERY_HEADER, HOSTED_DELIVERY_PROTOCOL_VERSION, HOSTED_EXECUTION_PATH, HOSTED_GUEST_RETRY_TERMINAL, HOSTED_GUEST_RETRY_TRANSIENT, hostedGuestErrorResponse, isHostedReminderAdmission, parseHostedAdmission, parseHostedExecution, parseHostedReminderFirePayload, } from "./hosted-delivery-protocol.js";
|
|
18
18
|
import { abortReasonFromTurnStatus, HOSTED_EXECUTION_DIAG_RUNNING_STATUS, hostedExecutionDiagId, } from "./hosted-execution-diag.js";
|
|
19
19
|
import { flushHostedExecutionRecord, } from "./hosted-execution-flush.js";
|
|
20
20
|
import { recordHostedManagedAutomation } from "./hosted-managed-automation.js";
|
|
21
|
-
import {
|
|
21
|
+
import { readJsonObject } from "./http-channel.js";
|
|
22
22
|
import { endActiveHttpSpan } from "./otel/http.js";
|
|
23
|
+
import { ReminderValidationError, UnknownReminderError, } from "./reminder-runner.js";
|
|
23
24
|
import { statusForThrownRequestError } from "./request-error-status.js";
|
|
24
25
|
/**
|
|
25
26
|
* A second `send()` in one delivery is a deterministic authored bug — the
|
|
@@ -44,6 +45,22 @@ function boundedMessage(text) {
|
|
|
44
45
|
? `${text.slice(0, MAX_ERROR_MESSAGE_LENGTH)}…`
|
|
45
46
|
: text;
|
|
46
47
|
}
|
|
48
|
+
function terminalHostedError(status, error, message) {
|
|
49
|
+
return hostedGuestErrorResponse({
|
|
50
|
+
status,
|
|
51
|
+
error,
|
|
52
|
+
retry: HOSTED_GUEST_RETRY_TERMINAL,
|
|
53
|
+
message,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function transientHostedError(status, error, message) {
|
|
57
|
+
return hostedGuestErrorResponse({
|
|
58
|
+
status,
|
|
59
|
+
error,
|
|
60
|
+
retry: HOSTED_GUEST_RETRY_TRANSIENT,
|
|
61
|
+
message,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
47
64
|
/**
|
|
48
65
|
* Classify deterministic authored protocol violations as non-retryable 422
|
|
49
66
|
* admissions. Anything else returns `undefined` so callers fall through to
|
|
@@ -61,7 +78,7 @@ function nonRetryableRejection(error) {
|
|
|
61
78
|
return undefined;
|
|
62
79
|
}
|
|
63
80
|
return {
|
|
64
|
-
response:
|
|
81
|
+
response: terminalHostedError(422, code, boundedMessage(error.message)),
|
|
65
82
|
};
|
|
66
83
|
}
|
|
67
84
|
/**
|
|
@@ -79,7 +96,7 @@ export function dispatchHostedAdmission(input) {
|
|
|
79
96
|
const adapter = getHostedAdmissionAdapter(input.definition);
|
|
80
97
|
if (adapter === undefined || adapter.kind !== input.delivery.channelKind) {
|
|
81
98
|
return {
|
|
82
|
-
response:
|
|
99
|
+
response: terminalHostedError(422, "channel_kind_mismatch"),
|
|
83
100
|
};
|
|
84
101
|
}
|
|
85
102
|
// The admission window marker follows the async graph into task bodies so
|
|
@@ -87,6 +104,41 @@ export function dispatchHostedAdmission(input) {
|
|
|
87
104
|
return runDuringHostedAdmission(() => runAdmission(input, adapter));
|
|
88
105
|
});
|
|
89
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Reserved reminder admission: parse the compact payload and invoke
|
|
109
|
+
* ReminderRunner.dispatch. Returns a standard hosted outcome (`task` /
|
|
110
|
+
* `skip`) and never opens the send-capture / model-session path here —
|
|
111
|
+
* prompt-form fires still follow up inside the runner.
|
|
112
|
+
*/
|
|
113
|
+
function dispatchHostedReminderAdmission(input, delivery) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
if (input.fireReminder === undefined) {
|
|
116
|
+
return transientHostedError(503, "reminder_dispatch_unavailable", "This guest has no reminder runner wired for hosted admission.");
|
|
117
|
+
}
|
|
118
|
+
const payload = parseHostedReminderFirePayload(delivery.payload);
|
|
119
|
+
if (payload === undefined) {
|
|
120
|
+
return terminalHostedError(400, "invalid_reminder_payload", "Expected reminder payload { reminderId, fireCount }.");
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const result = yield input.fireReminder(payload.reminderId, payload.fireCount);
|
|
124
|
+
const outcome = result.outcome === "noop" ? "skip" : "task";
|
|
125
|
+
return Response.json({
|
|
126
|
+
ok: true,
|
|
127
|
+
v: HOSTED_DELIVERY_PROTOCOL_VERSION,
|
|
128
|
+
outcome,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (error instanceof UnknownReminderError) {
|
|
133
|
+
return terminalHostedError(404, "unknown_reminder", boundedMessage(error.message));
|
|
134
|
+
}
|
|
135
|
+
if (error instanceof ReminderValidationError) {
|
|
136
|
+
return terminalHostedError(400, "invalid_reminder", boundedMessage(error.message));
|
|
137
|
+
}
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
90
142
|
function runAdmission(input, adapter) {
|
|
91
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
144
|
var _a;
|
|
@@ -121,7 +173,7 @@ function runAdmission(input, adapter) {
|
|
|
121
173
|
}
|
|
122
174
|
if (!dispatched.ok) {
|
|
123
175
|
return {
|
|
124
|
-
response:
|
|
176
|
+
response: terminalHostedError(dispatched.status >= 400 ? dispatched.status : 502, "channel_dispatch_failed"),
|
|
125
177
|
};
|
|
126
178
|
}
|
|
127
179
|
try {
|
|
@@ -133,7 +185,7 @@ function runAdmission(input, adapter) {
|
|
|
133
185
|
return rejected;
|
|
134
186
|
}
|
|
135
187
|
return {
|
|
136
|
-
response:
|
|
188
|
+
response: terminalHostedError(503, "background_dispatch_failed", boundedMessage(error instanceof Error ? error.message : String(error))),
|
|
137
189
|
};
|
|
138
190
|
}
|
|
139
191
|
if (captured !== undefined) {
|
|
@@ -156,7 +208,7 @@ function runAdmission(input, adapter) {
|
|
|
156
208
|
const outcome = dispatchOutcome(dispatched);
|
|
157
209
|
if (outcome === undefined || outcome === "send") {
|
|
158
210
|
return {
|
|
159
|
-
response:
|
|
211
|
+
response: terminalHostedError(502, "channel_outcome_missing"),
|
|
160
212
|
};
|
|
161
213
|
}
|
|
162
214
|
return {
|
|
@@ -234,7 +286,7 @@ export function registerHostedDeliveryRoute(input) {
|
|
|
234
286
|
const consumed = consumeBoundSecrets();
|
|
235
287
|
return consumed.ok
|
|
236
288
|
? undefined
|
|
237
|
-
:
|
|
289
|
+
: transientHostedError(503, consumed.code, boundedMessage(consumed.message));
|
|
238
290
|
};
|
|
239
291
|
const finishNetworkWait = (phase) => __awaiter(this, void 0, void 0, function* () {
|
|
240
292
|
try {
|
|
@@ -252,7 +304,7 @@ export function registerHostedDeliveryRoute(input) {
|
|
|
252
304
|
: "Guest network is not ready for outbound requests.";
|
|
253
305
|
return {
|
|
254
306
|
timing,
|
|
255
|
-
response:
|
|
307
|
+
response: transientHostedError(503, GUEST_NETWORK_UNAVAILABLE, boundedMessage(message)),
|
|
256
308
|
};
|
|
257
309
|
}
|
|
258
310
|
});
|
|
@@ -298,13 +350,21 @@ export function registerHostedDeliveryRoute(input) {
|
|
|
298
350
|
? Object.keys(rawAdmission)
|
|
299
351
|
: [];
|
|
300
352
|
console.info(`[agent-sdk] hosted admission rejected: envelope failed to parse keys=${JSON.stringify(rawKeys)} hasManagedAutomation=${String(rawKeys.includes("managedAutomation"))}`);
|
|
301
|
-
return finish(
|
|
353
|
+
return finish(terminalHostedError(400, "invalid_hosted_admission", "Expected a supported Agent SDK hosted-admission envelope."));
|
|
302
354
|
}
|
|
303
355
|
console.info(`[agent-sdk] hosted admission received deliveryId=${delivery.deliveryId} channelId=${delivery.channelId} channelKind=${delivery.channelKind} eventType=${delivery.eventType} sessionMode=${delivery.sessionMode} managedAutomation=${delivery.managedAutomation === undefined ? "<absent>" : `automationUuid=${delivery.managedAutomation.automationUuid} mcpServerNames=${String(delivery.managedAutomation.mcpServerNames.length)} slackChannels=${delivery.managedAutomation.slackChannels === undefined ? "<absent>" : JSON.stringify(delivery.managedAutomation.slackChannels)}`}`);
|
|
304
356
|
recordHostedManagedAutomation(delivery);
|
|
357
|
+
if (isHostedReminderAdmission(delivery)) {
|
|
358
|
+
const network = yield finishNetworkWait("admission");
|
|
359
|
+
guestNetwork = network.timing;
|
|
360
|
+
if (network.response !== undefined) {
|
|
361
|
+
return finish(network.response);
|
|
362
|
+
}
|
|
363
|
+
return finish(yield dispatchHostedReminderAdmission(input, delivery));
|
|
364
|
+
}
|
|
305
365
|
const channel = input.channels.find((candidate) => candidate.id === delivery.channelId);
|
|
306
366
|
if (channel === undefined) {
|
|
307
|
-
return finish(
|
|
367
|
+
return finish(terminalHostedError(404, "channel_not_found", `No channel named "${delivery.channelId}" is mounted.`));
|
|
308
368
|
}
|
|
309
369
|
const network = yield finishNetworkWait("admission");
|
|
310
370
|
guestNetwork = network.timing;
|
|
@@ -350,16 +410,16 @@ export function registerHostedDeliveryRoute(input) {
|
|
|
350
410
|
}
|
|
351
411
|
const execution = parseHostedExecution(yield readJsonObject(request));
|
|
352
412
|
if (execution === undefined) {
|
|
353
|
-
return finish(
|
|
413
|
+
return finish(terminalHostedError(400, "invalid_hosted_execution", "Expected a supported Agent SDK hosted-execution envelope."));
|
|
354
414
|
}
|
|
355
415
|
pruneExpired();
|
|
356
416
|
const admitted = pending.get(execution.admissionToken);
|
|
357
417
|
if (admitted === undefined) {
|
|
358
|
-
return finish(
|
|
418
|
+
return finish(transientHostedError(409, "hosted_admission_unavailable", "The hosted admission token is missing or expired."));
|
|
359
419
|
}
|
|
360
420
|
if (admitted.sessionPublicId !== undefined &&
|
|
361
421
|
admitted.sessionPublicId !== execution.sessionPublicId) {
|
|
362
|
-
return finish(
|
|
422
|
+
return finish(transientHostedError(409, "hosted_admission_session_mismatch", "The hosted admission token is already bound to another session."));
|
|
363
423
|
}
|
|
364
424
|
const network = yield finishNetworkWait("execution");
|
|
365
425
|
guestNetwork = network.timing;
|
|
@@ -420,11 +480,13 @@ export function registerHostedDeliveryRoute(input) {
|
|
|
420
480
|
// waitForCompletion resolves (does not throw) on a quiet
|
|
421
481
|
// Connect abort. Map that to guest_connect_stalled so TAS
|
|
422
482
|
// retries the same pod. Real runner failures stay turn_failed.
|
|
483
|
+
const hostedFailure = hostedFailureForUnfinishedTurn(outcome.errorMessage);
|
|
423
484
|
return {
|
|
424
485
|
status: 503,
|
|
425
486
|
body: {
|
|
426
487
|
ok: false,
|
|
427
|
-
error:
|
|
488
|
+
error: hostedFailure.error,
|
|
489
|
+
retry: hostedFailure.retry,
|
|
428
490
|
turnStatus: outcome.status,
|
|
429
491
|
message: outcome.errorMessage,
|
|
430
492
|
},
|
|
@@ -470,12 +532,15 @@ function evictHostedSdkSessions(evict, ...ids) {
|
|
|
470
532
|
evict(id);
|
|
471
533
|
}
|
|
472
534
|
}
|
|
473
|
-
function
|
|
535
|
+
function hostedFailureForUnfinishedTurn(errorMessage) {
|
|
474
536
|
if (errorMessage !== undefined &&
|
|
475
537
|
isQuietGuestConnectStallMessage(errorMessage)) {
|
|
476
|
-
return
|
|
538
|
+
return {
|
|
539
|
+
error: GUEST_CONNECT_STALLED,
|
|
540
|
+
retry: HOSTED_GUEST_RETRY_TRANSIENT,
|
|
541
|
+
};
|
|
477
542
|
}
|
|
478
|
-
return "turn_failed";
|
|
543
|
+
return { error: "turn_failed", retry: HOSTED_GUEST_RETRY_TERMINAL };
|
|
479
544
|
}
|
|
480
545
|
function afterHostedWork(flushOtel, work) {
|
|
481
546
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
* and reminder documents + clocks, then fires into the kit the same way the
|
|
4
4
|
* Cursor backend does over HTTP when `--no-control-plane` is set.
|
|
5
5
|
*
|
|
6
|
+
* Reminder lifecycle (protocol v1): CP assigns id, arms timers, claims a due
|
|
7
|
+
* fire once, invokes a guest executor with an immutable descriptor, and
|
|
8
|
+
* applies the outcome with generation/fireCount CAS. Cancel/rekey racing an
|
|
9
|
+
* in-flight execution bumps generation so a stale outcome cannot resurrect
|
|
10
|
+
* the reminder. Legacy `fireReminder(id, fireCount)` remains for v1 runners.
|
|
11
|
+
*
|
|
6
12
|
* v2 ingest lives here: `routeContinuation` stamps the mailbox (July twin
|
|
7
13
|
* of hosted `routeVerifiedIngressContinuation`), and `attachScmEvents`
|
|
8
14
|
* owns the `/v0/scm-events` long poll. v1 keeps engine-side scm-events.
|
|
@@ -10,7 +16,8 @@
|
|
|
10
16
|
*/
|
|
11
17
|
import { type LocalIngressContinuation, type RouteLocalIngressContinuationInput } from "./local-ingress.js";
|
|
12
18
|
import type { PlatformTimers } from "./platform-timers.js";
|
|
13
|
-
|
|
19
|
+
import { type ReminderControlPlane, type ReminderGuestExecutor } from "./reminder-control-plane-protocol.js";
|
|
20
|
+
export interface LocalControlPlane extends PlatformTimers, ReminderControlPlane {
|
|
14
21
|
/**
|
|
15
22
|
* Stamp a v2 mailbox from the channel selector + live payload. Same
|
|
16
23
|
* contract as hosted verified ingress. `/v1` is a no-op.
|
|
@@ -30,7 +37,16 @@ export interface LocalControlPlane extends PlatformTimers {
|
|
|
30
37
|
}
|
|
31
38
|
export declare function createLocalControlPlane(opts: {
|
|
32
39
|
fireSchedule: (name: string) => Promise<unknown>;
|
|
33
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Legacy v1 path: CP calls this with (id, fireCount) and the runner mutates
|
|
42
|
+
* authoritative state. Prefer {@link executeReminder} for architecture v2.
|
|
43
|
+
*/
|
|
44
|
+
fireReminder?: (id: string, fireCount: number) => Promise<unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Protocol guest executor. When set, due timers claim once, invoke this
|
|
47
|
+
* with an immutable descriptor, and apply the returned outcome via CAS.
|
|
48
|
+
*/
|
|
49
|
+
executeReminder?: ReminderGuestExecutor;
|
|
34
50
|
/**
|
|
35
51
|
* Persist reminder documents under `<stateDir>/reminders`. Local serve
|
|
36
52
|
* passes `<stateRoot>/control-plane`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-control-plane.d.ts","sourceRoot":"","sources":["../../src/internal/local-control-plane.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"local-control-plane.d.ts","sourceRoot":"","sources":["../../src/internal/local-control-plane.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,kCAAkC,EAExC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAKL,KAAK,oBAAoB,EAIzB,KAAK,qBAAqB,EAI3B,MAAM,sCAAsC,CAAC;AAI9C,MAAM,WAAW,iBACf,SAAQ,cAAc,EACpB,oBAAoB;IACtB;;;OAGG;IACH,iBAAiB,CACf,KAAK,EAAE,kCAAkC,GACxC,wBAAwB,CAAC;IAC5B;;;OAGG;IACH,eAAe,CAAC,KAAK,EAAE;QAAE,KAAK,IAAI,IAAI,CAAC;QAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IACvE,yEAAyE;IACzE,WAAW,IAAI,IAAI,CAAC;IACpB,IAAI,IAAI,IAAI,CAAC;CACd;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE;IAClD,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE;;;OAGG;IACH,eAAe,CAAC,EAAE,qBAAqB,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA0X7B"}
|