@cursor/july 0.1.9 → 0.1.10
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 +9 -0
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +3 -3
- package/dist/docs/assets/{app.Ciosf24M.js → app.CY2buaEE.js} +1 -1
- package/dist/docs/assets/chunks/@localSearchIndexroot.OfDZ5CXg.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.BcRDly7n.js → VPLocalSearchBox.Ix954SFJ.js} +1 -1
- package/dist/docs/assets/chunks/{theme.CMpbjdfx.js → theme.PDwuJbyi.js} +2 -2
- package/dist/docs/assets/{reference_cli.md.D189RBCH.js → reference_cli.md.CjfiV2Q-.js} +2 -1
- package/dist/docs/assets/{reference_connections.md.zaEYCLHT.js → reference_connections.md.FbWupyzW.js} +1 -1
- 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 +3 -3
- package/dist/docs/guides/agent-to-agent.html +3 -3
- package/dist/docs/guides/cloud-runtime.html +3 -3
- package/dist/docs/guides/github.html +3 -3
- package/dist/docs/guides/human-in-the-loop.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 +6 -5
- package/dist/docs/reference/connections.html +5 -5
- 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/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/internal/cli-ax.d.ts.map +1 -1
- package/dist/internal/cli-ax.js +7 -4
- package/dist/internal/persistence-coordinator.d.ts +127 -0
- package/dist/internal/persistence-coordinator.d.ts.map +1 -0
- package/dist/internal/resolved-connections.d.ts +6 -0
- package/dist/internal/resolved-connections.d.ts.map +1 -1
- package/dist/internal/resolved-connections.js +6 -2
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +11 -1
- package/dist/internal/session-engine.d.ts +23 -1
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +71 -11
- package/dist/internal/sessions-client.d.ts +16 -2
- package/dist/internal/sessions-client.d.ts.map +1 -1
- package/dist/internal/sessions-client.js +28 -12
- package/dist/internal/storage-coordinator.d.ts +11 -0
- package/dist/internal/storage-coordinator.d.ts.map +1 -1
- package/dist/internal/storage-coordinator.js +30 -0
- package/dist/persistence.d.ts +184 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/storage-backends/cursor-hosted.d.ts +10 -0
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +14 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/reference/cli.md +2 -0
- package/docs/reference/connections.md +4 -2
- package/package.json +1 -1
- package/src/bin/agent-serve.ts +10 -0
- package/src/internal/cli-ax.ts +10 -4
- package/src/internal/resolved-connections.ts +14 -4
- package/src/internal/server.ts +15 -1
- package/src/internal/session-engine.ts +77 -2
- package/src/internal/sessions-client.ts +49 -14
- package/src/internal/storage-coordinator.ts +36 -0
- package/src/storage-backends/cursor-hosted.ts +21 -0
- package/src/types.ts +16 -0
- package/dist/channels/slack/post-update-delivery.js +0 -318
- package/dist/docs/assets/chunks/@localSearchIndexroot.D154Detj.js +0 -1
- package/dist/internal/json-dir-store.js +0 -100
- package/docs/.vitepress/cache/deps/package.json +0 -3
- /package/dist/docs/assets/{reference_cli.md.D189RBCH.lean.js → reference_cli.md.CjfiV2Q-.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.zaEYCLHT.lean.js → reference_connections.md.FbWupyzW.lean.js} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime for `definePersistence` (`agent/persistence.ts`).
|
|
3
|
+
*
|
|
4
|
+
* The coordinator is the single funnel between the engine's hot paths and
|
|
5
|
+
* the author's key-value sink. The sink is four functions (`put` / `get` /
|
|
6
|
+
* `delete` / `list`); the coordinator owns everything else: it mints every
|
|
7
|
+
* key from the versioned scheme ({@link persistenceKeys}), coalesces
|
|
8
|
+
* session records and batches event chunks per turn (or debounce window),
|
|
9
|
+
* serializes delivery on one bounded queue per agent, and isolates
|
|
10
|
+
* failures — a throwing sink is logged and its write dropped; persistence
|
|
11
|
+
* must never stall or fail a turn.
|
|
12
|
+
*
|
|
13
|
+
* Scaling shape: sessions, evals, and A/Bs all reduce to keyed puts on the
|
|
14
|
+
* same queue, so one author-owned sink covers every domain, and new
|
|
15
|
+
* domains are new key prefixes — not new config surface.
|
|
16
|
+
*/
|
|
17
|
+
import type { ABSamplePersistence } from "../ab.js";
|
|
18
|
+
import type { EvalRunPersistence } from "../evals.js";
|
|
19
|
+
import { type PersistenceContext, type PersistenceDefinition, type ResolvedPersistencePolicy } from "../persistence.js";
|
|
20
|
+
import type { SessionEvent, SessionRecord } from "../types.js";
|
|
21
|
+
import type { ABSnapshot } from "./ab-snapshot.js";
|
|
22
|
+
export interface PersistenceCoordinatorOptions {
|
|
23
|
+
definition: PersistenceDefinition;
|
|
24
|
+
agentName: string;
|
|
25
|
+
projectRoot: string;
|
|
26
|
+
logger: (line: string) => void;
|
|
27
|
+
}
|
|
28
|
+
export declare class PersistenceCoordinator {
|
|
29
|
+
readonly policy: ResolvedPersistencePolicy;
|
|
30
|
+
private readonly definition;
|
|
31
|
+
private readonly agentName;
|
|
32
|
+
private readonly projectRoot;
|
|
33
|
+
private readonly logger;
|
|
34
|
+
/** Per-session pending state (events + coalesced record). */
|
|
35
|
+
private readonly buffers;
|
|
36
|
+
/**
|
|
37
|
+
* Last continuation key written to the sink per session, so a token
|
|
38
|
+
* change emits a delete for the stale index entry alongside the new put.
|
|
39
|
+
*/
|
|
40
|
+
private readonly continuationIndex;
|
|
41
|
+
/** Single delivery chain: writes reach the sink serialized, in order. */
|
|
42
|
+
private queue;
|
|
43
|
+
/** Ops on the queue not yet delivered (bounded by MAX_PENDING_OPS). */
|
|
44
|
+
private pending;
|
|
45
|
+
/** Ops dropped because the queue was full. */
|
|
46
|
+
private dropped;
|
|
47
|
+
private lastAbSnapshotAt;
|
|
48
|
+
private closed;
|
|
49
|
+
constructor(options: PersistenceCoordinatorOptions);
|
|
50
|
+
/** Durable session-record update (engine calls after every store save). */
|
|
51
|
+
sessionRecord(record: SessionRecord): void;
|
|
52
|
+
/** One appended session event (engine calls from its dispatch funnel). */
|
|
53
|
+
event(event: SessionEvent): void;
|
|
54
|
+
/**
|
|
55
|
+
* A boundary event's dispatch settled: channel/hook handlers ran and
|
|
56
|
+
* their record updates (channel state, continuation tokens) are
|
|
57
|
+
* buffered. This — not the append — is the turn-end flush point, so the
|
|
58
|
+
* persisted session record includes the boundary event's own handler
|
|
59
|
+
* mutations. Debounced batching intentionally ignores boundaries.
|
|
60
|
+
*/
|
|
61
|
+
eventDispatched(event: SessionEvent): void;
|
|
62
|
+
/** Flush everything buffered for one session (ordered: events, record). */
|
|
63
|
+
flushSession(sessionId: string, reason?: PersistenceContext["reason"]): void;
|
|
64
|
+
/**
|
|
65
|
+
* Index maintenance for `continuation/{channelId}/{token}` → sessionId:
|
|
66
|
+
* put the current token, delete the previous one when it changed.
|
|
67
|
+
*/
|
|
68
|
+
private continuationOps;
|
|
69
|
+
/** Whether the sink can serve the startup bulk restore (`list`). */
|
|
70
|
+
get canBulkRestore(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Saved session records for this agent (startup restore). Errors are
|
|
73
|
+
* logged and read as "nothing saved" — a broken store must never block
|
|
74
|
+
* serve start.
|
|
75
|
+
*/
|
|
76
|
+
listSessions(): Promise<SessionRecord[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Saved event stream for one session: chunk values concatenated in key
|
|
79
|
+
* order (chunks are keyed by their first event's index, zero-padded, so
|
|
80
|
+
* ascending key order is append order). Errors read as an empty stream.
|
|
81
|
+
*/
|
|
82
|
+
listSessionEvents(sessionId: string): Promise<SessionEvent[]>;
|
|
83
|
+
/**
|
|
84
|
+
* One saved session by channel continuation key (lazy restore). Unlike
|
|
85
|
+
* the startup reads, sink errors **propagate**: a failing store must
|
|
86
|
+
* fail the follow-up (which the caller can retry) rather than read as
|
|
87
|
+
* "unknown token" — that would mint a new session under the same
|
|
88
|
+
* continuation key and permanently shadow the real one on this host.
|
|
89
|
+
* A definitive miss (no index entry, or a write-only sink without
|
|
90
|
+
* `get`) resolves undefined.
|
|
91
|
+
*/
|
|
92
|
+
getSessionByContinuation(channelId: string, continuationKey: string): Promise<SessionRecord | undefined>;
|
|
93
|
+
/**
|
|
94
|
+
* Adapter for {@link EvalRunPersistence} so the playground eval store
|
|
95
|
+
* can fall back to this sink when `evals.config.ts` sets no
|
|
96
|
+
* `persistRuns`.
|
|
97
|
+
*/
|
|
98
|
+
asEvalRunPersistence(): EvalRunPersistence;
|
|
99
|
+
/**
|
|
100
|
+
* Adapter for {@link ABSamplePersistence} so the AB collector can fall
|
|
101
|
+
* back to this sink when `ab.config.ts` sets no `persistSamples`.
|
|
102
|
+
*/
|
|
103
|
+
asABSamplePersistence(): ABSamplePersistence;
|
|
104
|
+
/**
|
|
105
|
+
* Refresh the persisted aggregate A/B snapshot, throttled to once per
|
|
106
|
+
* {@link AB_SNAPSHOT_MIN_INTERVAL_MS} (the playground recomputes the
|
|
107
|
+
* fold on every `GET /v1/abs` poll).
|
|
108
|
+
*/
|
|
109
|
+
abSnapshot(snapshot: ABSnapshot): void;
|
|
110
|
+
/** Latest persisted aggregate A/B snapshot; errors read as absent. */
|
|
111
|
+
getLatestAbSnapshot(): Promise<ABSnapshot | undefined>;
|
|
112
|
+
/**
|
|
113
|
+
* Flush all buffers and drain the queue, giving the sink at most
|
|
114
|
+
* {@link CLOSE_DRAIN_TIMEOUT_MS} — a hung sink must not stall shutdown
|
|
115
|
+
* past the pod grace period. Called from engine close.
|
|
116
|
+
*/
|
|
117
|
+
close(): Promise<void>;
|
|
118
|
+
/** Pending deliveries (exposed for tests and drain instrumentation). */
|
|
119
|
+
whenIdle(): Promise<void>;
|
|
120
|
+
private buffer;
|
|
121
|
+
private armDebounce;
|
|
122
|
+
/** `list` wrapper for the startup reads: missing hook or throw ⇒ empty. */
|
|
123
|
+
private tryList;
|
|
124
|
+
private enqueue;
|
|
125
|
+
private context;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=persistence-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence-coordinator.d.ts","sourceRoot":"","sources":["../../src/internal/persistence-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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ission would expose account connectors. */
|
|
26
26
|
export declare function assertAccountConnectionsNotAnonymous(args: {
|
|
27
27
|
allowAnonymous?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Opt in when every admitted caller is already trusted (e.g. behind an
|
|
30
|
+
* authenticating proxy / hosted alias token). Same trust model as
|
|
31
|
+
* `--allow-anonymous-cursor-github`.
|
|
32
|
+
*/
|
|
33
|
+
allowAnonymousCursorAccountMcp?: boolean;
|
|
28
34
|
hasAccountConnections: boolean;
|
|
29
35
|
}): void;
|
|
30
36
|
export declare function resolveMountConnections(args: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolved-connections.d.ts","sourceRoot":"","sources":["../../src/internal/resolved-connections.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,+EAA+E;AAC/E,wBAAgB,8BAA8B,CAAC,IAAI,EAAE;IACnD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,CAAC,EAAE,0BAA0B,EAAE,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,IAAI,CAuBP;AAED,qEAAqE;AACrE,wBAAgB,wCAAwC,CAAC,IAAI,EAAE;IAC7D,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B,mBAAmB,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAC1D,GAAG,IAAI,CAmBP;AAED,iFAAiF;AACjF,wBAAgB,oCAAoC,CAAC,IAAI,EAAE;IACzD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qB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Aa,CAAC,EAAE,sBAAsB,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAChC,GAAG,wBAAwB,EAAE,CA6C7B"}
|
|
@@ -43,9 +43,13 @@ export function assertCloudCanHonorAccountServersFilters(args) {
|
|
|
43
43
|
}
|
|
44
44
|
/** Fail closed when anonymous HTTP admission would expose account connectors. */
|
|
45
45
|
export function assertAccountConnectionsNotAnonymous(args) {
|
|
46
|
-
if (args.allowAnonymous
|
|
47
|
-
|
|
46
|
+
if (args.allowAnonymous !== true || !args.hasAccountConnections) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (args.allowAnonymousCursorAccountMcp === true) {
|
|
50
|
+
return;
|
|
48
51
|
}
|
|
52
|
+
throw new Error("[agentkit] --allow-anonymous cannot be used with Cursor account MCP connections (defineConnection({ cursorAccount: true })); use --bearer-token, or opt in with --allow-anonymous-cursor-account-mcp behind a trusted boundary.");
|
|
49
53
|
}
|
|
50
54
|
export function resolveMountConnections(args) {
|
|
51
55
|
const agent = args.project.agent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2BH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAoFrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAapE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAYD,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,YAAY,GAAG,0BAA+B,GACtD,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/internal/server.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA2BH,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAOhB,YAAY,EACb,MAAM,aAAa,CAAC;AAoFrB,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAapE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,YAAY,CAAC;CACvB;AAYD,6EAA6E;AAC7E,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,YAAY,GAAG,0BAA+B,GACtD,OAAO,CAAC,gBAAgB,CAAC,CAgnB3B"}
|
package/dist/internal/server.js
CHANGED
|
@@ -179,8 +179,14 @@ export function startServer(mounts_1) {
|
|
|
179
179
|
const accountRefsBySlug = collectCursorAccountConnections(mounts);
|
|
180
180
|
assertAccountConnectionsNotAnonymous({
|
|
181
181
|
allowAnonymous: options.allowAnonymous,
|
|
182
|
+
allowAnonymousCursorAccountMcp: options.allowAnonymousCursorAccountMcp,
|
|
182
183
|
hasAccountConnections: accountRefsBySlug.size > 0,
|
|
183
184
|
});
|
|
185
|
+
if (options.allowAnonymous === true &&
|
|
186
|
+
options.allowAnonymousCursorAccountMcp === true &&
|
|
187
|
+
accountRefsBySlug.size > 0) {
|
|
188
|
+
logger("[agentkit] warning: --allow-anonymous-cursor-account-mcp — every admitted HTTP caller can drive Cursor account MCP connectors; serve this only behind a trusted boundary (e.g. an SSO proxy or hosted alias token)");
|
|
189
|
+
}
|
|
184
190
|
let accountBridge;
|
|
185
191
|
if (accountRefsBySlug.size > 0) {
|
|
186
192
|
if (accountKey === undefined) {
|
|
@@ -696,8 +702,12 @@ function mountAgentRoutes(router, runtime, args) {
|
|
|
696
702
|
(relaxSessionReadAuthBeyondLoopback ||
|
|
697
703
|
(typeof ctx.requestIp === "string" &&
|
|
698
704
|
isLoopbackAddress(ctx.requestIp)));
|
|
705
|
+
const listed = yield engine.listSessionsWithSource(ctx.auth, {
|
|
706
|
+
includeAll,
|
|
707
|
+
});
|
|
699
708
|
return jsonResponse({
|
|
700
|
-
sessions:
|
|
709
|
+
sessions: listed.sessions,
|
|
710
|
+
source: listed.source,
|
|
701
711
|
});
|
|
702
712
|
}),
|
|
703
713
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* event handlers and hooks.
|
|
8
8
|
*/
|
|
9
9
|
import { SlackAskDedupeStore, SlackNudgeStore } from "../channels/slack/nudge-store.js";
|
|
10
|
-
import { type AgentProject, type ApprovalDecision, type AuthContext, type CallToolOptions, type ChannelDefinition, type ChannelSession, type HostContext, type HttpChannelDefinition, type PendingApproval, type ReceiveInput, type SendMessageOptions, type SessionEvent, type SessionInfo, type SessionRecord, type SessionSummary, type ToolCallOutcome, type TurnOutcome } from "../types.js";
|
|
10
|
+
import { type AgentProject, type ApprovalDecision, type AuthContext, type CallToolOptions, type ChannelDefinition, type ChannelSession, type HostContext, type HttpChannelDefinition, type PendingApproval, type ReceiveInput, type SendMessageOptions, type SessionEvent, type SessionInfo, type SessionListSource, type SessionRecord, type SessionSummary, type ToolCallOutcome, type TurnOutcome } from "../types.js";
|
|
11
11
|
import { type ABSnapshot } from "./ab-snapshot.js";
|
|
12
12
|
import { type HostPlatforms } from "./host-platforms.js";
|
|
13
13
|
import type { AgentRunner } from "./sdk-runner.js";
|
|
@@ -300,10 +300,32 @@ export declare class SessionEngine {
|
|
|
300
300
|
* observability surface across every principal (channel-driven runs,
|
|
301
301
|
* schedule/task sessions, other callers). The route auth chain still
|
|
302
302
|
* gates who may call this at all.
|
|
303
|
+
*
|
|
304
|
+
* When the project uses `cursorHostedStorage`, prefers durable Bugbot rows
|
|
305
|
+
* (merged with any newer local records not flushed yet). Falls back to the
|
|
306
|
+
* local `--state-root` store when the sink is unavailable.
|
|
303
307
|
*/
|
|
304
308
|
listSessions(caller: AuthContext | null, options?: {
|
|
305
309
|
includeAll?: boolean;
|
|
306
310
|
}): Promise<SessionSummary[]>;
|
|
311
|
+
/**
|
|
312
|
+
* Same as {@link listSessions}, plus which store answered
|
|
313
|
+
* (`cursor-hosted` = durable DB via the control-plane proxy; `local` =
|
|
314
|
+
* `--state-root`).
|
|
315
|
+
*/
|
|
316
|
+
listSessionsWithSource(caller: AuthContext | null, options?: {
|
|
317
|
+
includeAll?: boolean;
|
|
318
|
+
}): Promise<{
|
|
319
|
+
sessions: SessionSummary[];
|
|
320
|
+
source: SessionListSource;
|
|
321
|
+
}>;
|
|
322
|
+
/**
|
|
323
|
+
* Durable sink rows plus local records (local wins on the same id when
|
|
324
|
+
* newer — covers debounce windows that have not flushed yet). Newest
|
|
325
|
+
* `updatedAt` first.
|
|
326
|
+
*/
|
|
327
|
+
private mergeStoredAndLocalSessions;
|
|
328
|
+
private summarizeSessionRecords;
|
|
307
329
|
/**
|
|
308
330
|
* Fold durable session streams into per-session A/B assignments and
|
|
309
331
|
* aggregate arm metrics (`GET /v1/abs`). Collector-independent: always
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-engine.d.ts","sourceRoot":"","sources":["../../src/internal/session-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EACL,mBAAmB,EACnB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEtB,KAAK,cAAc,EAInB,KAAK,WAAW,EAChB,KAAK,qBAAqB,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AE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GACjC,OAAO,CAAC,UAAU,CAAC,CA6CrB;IAEK,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,UAAU,SAAI,GACb,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAGrC;IAED;;;;OAIG;IACG,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoCzE;IAED,kEAAkE;IAC5D,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,SAAI,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAG3E;IAEK,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;IAED,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CASxC;IAED,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,WAAW,CAc9C;IAED,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,mBAAmB;IAc3B,sEAAsE;IACtE,OAAO,CAAC,YAAY;IA6BpB;;;;;;;;;;;OAWG;IACG,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc3C;YAEa,cAAc;IA4F5B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,4BAA4B;YAqBtB,gCAAgC;IAyB9C;;;;;OAKG;YACW,kBAAkB;IAYhC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAO/C;IAED,yEAAyE;IACnE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3B;CACF"}
|
|
@@ -1361,22 +1361,82 @@ export class SessionEngine {
|
|
|
1361
1361
|
* observability surface across every principal (channel-driven runs,
|
|
1362
1362
|
* schedule/task sessions, other callers). The route auth chain still
|
|
1363
1363
|
* gates who may call this at all.
|
|
1364
|
+
*
|
|
1365
|
+
* When the project uses `cursorHostedStorage`, prefers durable Bugbot rows
|
|
1366
|
+
* (merged with any newer local records not flushed yet). Falls back to the
|
|
1367
|
+
* local `--state-root` store when the sink is unavailable.
|
|
1364
1368
|
*/
|
|
1365
1369
|
listSessions(caller, options) {
|
|
1370
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1371
|
+
return (yield this.listSessionsWithSource(caller, options)).sessions;
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Same as {@link listSessions}, plus which store answered
|
|
1376
|
+
* (`cursor-hosted` = durable DB via the control-plane proxy; `local` =
|
|
1377
|
+
* `--state-root`).
|
|
1378
|
+
*/
|
|
1379
|
+
listSessionsWithSource(caller, options) {
|
|
1366
1380
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1367
1381
|
var _a;
|
|
1368
|
-
|
|
1382
|
+
var _b;
|
|
1383
|
+
const includeAll = (_b = options === null || options === void 0 ? void 0 : options.includeAll) !== null && _b !== void 0 ? _b : false;
|
|
1384
|
+
if (((_a = this.storage) === null || _a === void 0 ? void 0 : _a.isCursorHosted) === true) {
|
|
1385
|
+
try {
|
|
1386
|
+
const records = yield this.mergeStoredAndLocalSessions();
|
|
1387
|
+
return {
|
|
1388
|
+
sessions: this.summarizeSessionRecords(records, caller, includeAll),
|
|
1389
|
+
source: "cursor-hosted",
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
catch (error) {
|
|
1393
|
+
this.logger(`[agentkit] cursor-hosted session list failed; falling back to local: ${describeError(error)}`);
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1369
1396
|
const records = yield this.sessions.list();
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
.
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1397
|
+
// Local store is createdAt-asc; reverse so newest created leads.
|
|
1398
|
+
return {
|
|
1399
|
+
sessions: this.summarizeSessionRecords([...records].reverse(), caller, includeAll),
|
|
1400
|
+
source: "local",
|
|
1401
|
+
};
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Durable sink rows plus local records (local wins on the same id when
|
|
1406
|
+
* newer — covers debounce windows that have not flushed yet). Newest
|
|
1407
|
+
* `updatedAt` first.
|
|
1408
|
+
*/
|
|
1409
|
+
mergeStoredAndLocalSessions() {
|
|
1410
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1411
|
+
const storage = this.storage;
|
|
1412
|
+
if (storage === undefined) {
|
|
1413
|
+
throw new Error("storage is not configured");
|
|
1414
|
+
}
|
|
1415
|
+
const stored = yield storage.listSessionsFromSink();
|
|
1416
|
+
const local = yield this.sessions.list();
|
|
1417
|
+
const byId = new Map();
|
|
1418
|
+
for (const record of stored) {
|
|
1419
|
+
byId.set(record.sessionId, record);
|
|
1420
|
+
}
|
|
1421
|
+
for (const record of local) {
|
|
1422
|
+
const existing = byId.get(record.sessionId);
|
|
1423
|
+
if (existing === undefined ||
|
|
1424
|
+
record.updatedAt.localeCompare(existing.updatedAt) >= 0) {
|
|
1425
|
+
byId.set(record.sessionId, record);
|
|
1426
|
+
}
|
|
1427
|
+
}
|
|
1428
|
+
return [...byId.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
summarizeSessionRecords(records, caller, includeAll) {
|
|
1432
|
+
return records
|
|
1433
|
+
.filter((record) => includeAll || samePrincipal(record.auth, caller))
|
|
1434
|
+
.map((record) => {
|
|
1435
|
+
const externalUrl = externalUrlForSession(record);
|
|
1436
|
+
return Object.assign(Object.assign(Object.assign({ sessionId: record.sessionId, channelId: record.channelId, mode: record.mode }, (record.title === undefined ? {} : { title: record.title })), { turnCount: record.turnCount, running: this.activeTurns.has(record.sessionId) ||
|
|
1437
|
+
this.pendingTurns.has(record.sessionId), createdAt: record.createdAt, updatedAt: record.updatedAt, continuationToken: record.continuationKey === null
|
|
1438
|
+
? null
|
|
1439
|
+
: formatContinuationToken(record.channelId, record.continuationKey) }), (externalUrl === undefined ? {} : { externalUrl }));
|
|
1380
1440
|
});
|
|
1381
1441
|
}
|
|
1382
1442
|
/**
|
|
@@ -3,13 +3,23 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Customer-facing errors never include hosting URLs or infra jargon.
|
|
5
5
|
*/
|
|
6
|
-
import type { SessionEvent, SessionSummary } from "../types.js";
|
|
6
|
+
import type { SessionEvent, SessionListSource, SessionSummary } from "../types.js";
|
|
7
7
|
import { type RequestAuth } from "./request-headers.js";
|
|
8
|
+
export interface ListedSessions {
|
|
9
|
+
sessions: SessionSummary[];
|
|
10
|
+
/** Present when the server reports which store answered. */
|
|
11
|
+
source?: SessionListSource;
|
|
12
|
+
}
|
|
8
13
|
export declare function listSessions(args: {
|
|
9
14
|
baseUrl: string;
|
|
10
15
|
auth?: RequestAuth;
|
|
11
16
|
fetchImpl?: typeof fetch;
|
|
12
17
|
}): Promise<SessionSummary[]>;
|
|
18
|
+
export declare function listSessionsWithSource(args: {
|
|
19
|
+
baseUrl: string;
|
|
20
|
+
auth?: RequestAuth;
|
|
21
|
+
fetchImpl?: typeof fetch;
|
|
22
|
+
}): Promise<ListedSessions>;
|
|
13
23
|
export declare function fetchSessionEvents(args: {
|
|
14
24
|
baseUrl: string;
|
|
15
25
|
sessionId: string;
|
|
@@ -29,6 +39,10 @@ export declare function resolvePreviousSessionId(args: {
|
|
|
29
39
|
auth?: RequestAuth;
|
|
30
40
|
fetchImpl?: typeof fetch;
|
|
31
41
|
}): Promise<string | undefined>;
|
|
42
|
+
/** Human label for {@link SessionListSource} in CLI output. */
|
|
43
|
+
export declare function formatSessionListSource(source: SessionListSource): string;
|
|
32
44
|
/** Format a sessions table (id, channel, mode, turns, running, updated). */
|
|
33
|
-
export declare function formatSessionsTable(sessions: SessionSummary[]
|
|
45
|
+
export declare function formatSessionsTable(sessions: SessionSummary[], options?: {
|
|
46
|
+
source?: SessionListSource;
|
|
47
|
+
}): string;
|
|
34
48
|
//# sourceMappingURL=sessions-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions-client.d.ts","sourceRoot":"","sources":["../../src/internal/sessions-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sessions-client.d.ts","sourceRoot":"","sources":["../../src/internal/sessions-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACf,MAAM,aAAa,CAAC;AAErB,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7E,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC5B;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAE5B;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,GAAG,OAAO,CAAC,cAAc,CAAC,CAiC1B;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAuE1B;AAgCD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAClC,cAAc,GAAG,SAAS,CAU5B;AAED,+DAA+D;AAC/D,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAO9B;AAED,+DAA+D;AAC/D,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAIzE;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,cAAc,EAAE,EAC1B,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAAE,GACvC,MAAM,CAkBR"}
|
|
@@ -15,6 +15,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
15
|
import { sanitizeCustomerError } from "./logs-client.js";
|
|
16
16
|
import { mergeRequestHeaders } from "./request-headers.js";
|
|
17
17
|
export function listSessions(args) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return (yield listSessionsWithSource(args)).sessions;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export function listSessionsWithSource(args) {
|
|
18
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
24
|
var _a;
|
|
20
25
|
const baseUrl = args.baseUrl.replace(/\/$/, "");
|
|
@@ -32,17 +37,19 @@ export function listSessions(args) {
|
|
|
32
37
|
throw new Error(`Could not list sessions (HTTP ${resp.status}).`);
|
|
33
38
|
}
|
|
34
39
|
const body = (yield resp.json());
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
out.push(parsed);
|
|
40
|
+
const sessions = [];
|
|
41
|
+
if (Array.isArray(body.sessions)) {
|
|
42
|
+
for (const row of body.sessions) {
|
|
43
|
+
const parsed = parseSessionSummary(row);
|
|
44
|
+
if (parsed !== undefined) {
|
|
45
|
+
sessions.push(parsed);
|
|
46
|
+
}
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
|
-
|
|
49
|
+
const source = body.source === "cursor-hosted" || body.source === "local"
|
|
50
|
+
? body.source
|
|
51
|
+
: undefined;
|
|
52
|
+
return source === undefined ? { sessions } : { sessions, source };
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
55
|
export function fetchSessionEvents(args) {
|
|
@@ -167,10 +174,19 @@ export function resolvePreviousSessionId(args) {
|
|
|
167
174
|
return (_a = pickPreviousSession(sessions)) === null || _a === void 0 ? void 0 : _a.sessionId;
|
|
168
175
|
});
|
|
169
176
|
}
|
|
177
|
+
/** Human label for {@link SessionListSource} in CLI output. */
|
|
178
|
+
export function formatSessionListSource(source) {
|
|
179
|
+
return source === "cursor-hosted"
|
|
180
|
+
? "Listing from cursor-hosted storage (durable DB)."
|
|
181
|
+
: "Listing from local session store.";
|
|
182
|
+
}
|
|
170
183
|
/** Format a sessions table (id, channel, mode, turns, running, updated). */
|
|
171
|
-
export function formatSessionsTable(sessions) {
|
|
184
|
+
export function formatSessionsTable(sessions, options) {
|
|
185
|
+
const sourceLine = (options === null || options === void 0 ? void 0 : options.source) === undefined
|
|
186
|
+
? ""
|
|
187
|
+
: `${formatSessionListSource(options.source)}\n`;
|
|
172
188
|
if (sessions.length === 0) {
|
|
173
|
-
return
|
|
189
|
+
return `${sourceLine}No sessions.\n`;
|
|
174
190
|
}
|
|
175
191
|
const header = ["SESSION", "CHANNEL", "MODE", "TURNS", "RUNNING", "UPDATED"];
|
|
176
192
|
const rows = sessions.map((s) => [
|
|
@@ -181,7 +197,7 @@ export function formatSessionsTable(sessions) {
|
|
|
181
197
|
s.running ? "yes" : "no",
|
|
182
198
|
s.updatedAt,
|
|
183
199
|
]);
|
|
184
|
-
return `${renderTable(header, rows)}\n`;
|
|
200
|
+
return `${sourceLine}${renderTable(header, rows)}\n`;
|
|
185
201
|
}
|
|
186
202
|
function renderTable(header, rows) {
|
|
187
203
|
const widths = header.map((h, i) => Math.max(h.length, ...rows.map((row) => { var _a; return ((_a = row[i]) !== null && _a !== void 0 ? _a : "").length; })));
|
|
@@ -73,12 +73,23 @@ export declare class StorageCoordinator {
|
|
|
73
73
|
private deleteOp;
|
|
74
74
|
/** Whether the sink can serve the startup bulk restore (`list`). */
|
|
75
75
|
get canBulkRestore(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* True when the authored sink is `cursorHostedStorage` (Bugbot via the
|
|
78
|
+
* control-plane proxy). `GET /v1/sessions` prefers this durable list.
|
|
79
|
+
*/
|
|
80
|
+
get isCursorHosted(): boolean;
|
|
76
81
|
/**
|
|
77
82
|
* Saved session records for this agent (startup restore). Errors are
|
|
78
83
|
* logged and read as "nothing saved" — a broken store must never block
|
|
79
84
|
* serve start.
|
|
80
85
|
*/
|
|
81
86
|
listSessions(): Promise<SessionRecord[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Session records from the sink for the sessions API. Unlike
|
|
89
|
+
* {@link listSessions}, missing `list` or a thrown sink error **propagates**
|
|
90
|
+
* so the caller can fall back to the local session store.
|
|
91
|
+
*/
|
|
92
|
+
listSessionsFromSink(): Promise<SessionRecord[]>;
|
|
82
93
|
/**
|
|
83
94
|
* Saved event stream for one session: chunk values concatenated in key
|
|
84
95
|
* order (chunks are keyed by their first event's index, zero-padded, so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-coordinator.d.ts","sourceRoot":"","sources":["../../src/internal/storage-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK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I,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"}
|
|
@@ -24,6 +24,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
import { resolveStoragePolicy, storageKeys, } from "../storage.js";
|
|
27
|
+
import { isCursorHostedStorage } from "../storage-backends/cursor-hosted.js";
|
|
27
28
|
import { describeError } from "./describe-error.js";
|
|
28
29
|
import { isReminderRecord } from "./reminder-store.js";
|
|
29
30
|
/** Event types that close a unit of work — flush point for turn-end batching. */
|
|
@@ -190,6 +191,13 @@ export class StorageCoordinator {
|
|
|
190
191
|
get canBulkRestore() {
|
|
191
192
|
return this.definition.list !== undefined;
|
|
192
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* True when the authored sink is `cursorHostedStorage` (Bugbot via the
|
|
196
|
+
* control-plane proxy). `GET /v1/sessions` prefers this durable list.
|
|
197
|
+
*/
|
|
198
|
+
get isCursorHosted() {
|
|
199
|
+
return isCursorHostedStorage(this.definition);
|
|
200
|
+
}
|
|
193
201
|
/**
|
|
194
202
|
* Saved session records for this agent (startup restore). Errors are
|
|
195
203
|
* logged and read as "nothing saved" — a broken store must never block
|
|
@@ -203,6 +211,28 @@ export class StorageCoordinator {
|
|
|
203
211
|
.filter((record) => record != null);
|
|
204
212
|
});
|
|
205
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Session records from the sink for the sessions API. Unlike
|
|
216
|
+
* {@link listSessions}, missing `list` or a thrown sink error **propagates**
|
|
217
|
+
* so the caller can fall back to the local session store.
|
|
218
|
+
*/
|
|
219
|
+
listSessionsFromSink() {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const list = this.definition.list;
|
|
222
|
+
if (list === undefined) {
|
|
223
|
+
throw new Error("storage sink has no list");
|
|
224
|
+
}
|
|
225
|
+
const entries = yield list(storageKeys.sessionPrefix(this.agentName), this.context("restore"));
|
|
226
|
+
if (!Array.isArray(entries)) {
|
|
227
|
+
throw new Error("storage list returned a non-array");
|
|
228
|
+
}
|
|
229
|
+
return entries
|
|
230
|
+
.map((entry) => entry.value)
|
|
231
|
+
.filter((record) => record != null &&
|
|
232
|
+
typeof record.sessionId === "string" &&
|
|
233
|
+
record.sessionId !== "");
|
|
234
|
+
});
|
|
235
|
+
}
|
|
206
236
|
/**
|
|
207
237
|
* Saved event stream for one session: chunk values concatenated in key
|
|
208
238
|
* order (chunks are keyed by their first event's index, zero-padded, so
|