ai-hist 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -22
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +10 -58
- package/dist/cli.js.map +1 -1
- package/dist/delivery-cli.d.ts +1 -16
- package/dist/delivery-cli.d.ts.map +1 -1
- package/dist/delivery-cli.js +1 -7
- package/dist/delivery-cli.js.map +1 -1
- package/dist/delivery-contracts.d.ts +0 -10
- package/dist/delivery-contracts.d.ts.map +1 -1
- package/dist/delivery-plugins.d.ts +1 -12
- package/dist/delivery-plugins.d.ts.map +1 -1
- package/dist/delivery-plugins.js +1 -39
- package/dist/delivery-plugins.js.map +1 -1
- package/dist/delivery.d.ts +2 -44
- package/dist/delivery.d.ts.map +1 -1
- package/dist/delivery.js +1 -14
- package/dist/delivery.js.map +1 -1
- package/dist/handoff.d.ts +64 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +292 -0
- package/dist/handoff.js.map +1 -0
- package/dist/history-export.d.ts +6 -4
- package/dist/history-export.d.ts.map +1 -1
- package/dist/history-export.js +6 -4
- package/dist/history-export.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-server.js +43 -16
- package/dist/mcp-server.js.map +1 -1
- package/dist/native.d.ts +1 -1
- package/dist/native.js +1 -1
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +0 -1
- package/dist/operations.js.map +1 -1
- package/dist/relay-cli.d.ts +1 -2
- package/dist/relay-cli.d.ts.map +1 -1
- package/dist/relay-cli.js +2 -3
- package/dist/relay-cli.js.map +1 -1
- package/package.json +3 -2
|
@@ -4,26 +4,15 @@ import type { HistoryDestination, HistoryPlugin } from './delivery-contracts.js'
|
|
|
4
4
|
export declare class HistoryPluginRegistry {
|
|
5
5
|
private readonly sources;
|
|
6
6
|
private readonly destinations;
|
|
7
|
-
private readonly commands;
|
|
8
|
-
private readonly tools;
|
|
9
7
|
register(plugin: HistoryPlugin): void;
|
|
10
8
|
sourceConnectors(ids?: readonly string[]): HistorySource[];
|
|
11
9
|
destination(id: string, instanceId: string): HistoryDestination | undefined;
|
|
12
|
-
/** Every registered destination instance
|
|
10
|
+
/** Every registered destination instance. */
|
|
13
11
|
registeredDestinations(): Array<{
|
|
14
12
|
destinationId: string;
|
|
15
13
|
instanceId: string;
|
|
16
14
|
destination: HistoryDestination;
|
|
17
15
|
}>;
|
|
18
|
-
command(name: string): {
|
|
19
|
-
name: string;
|
|
20
|
-
run(args: readonly string[]): Promise<unknown>;
|
|
21
|
-
} | undefined;
|
|
22
|
-
registeredTools(): {
|
|
23
|
-
name: string;
|
|
24
|
-
description: string;
|
|
25
|
-
run(input: Record<string, unknown>): Promise<unknown>;
|
|
26
|
-
}[];
|
|
27
16
|
}
|
|
28
17
|
export interface HistoryPluginModule {
|
|
29
18
|
module: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-plugins.d.ts","sourceRoot":"","sources":["../src/delivery-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"delivery-plugins.d.ts","sourceRoot":"","sources":["../src/delivery-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAK3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAQjF,6EAA6E;AAC7E,qBAAa,qBAAqB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAyC;IAEtE,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;IAyBrC,gBAAgB,CAAC,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,EAAE;IAO1D,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAG3E,6CAA6C;IAC7C,sBAAsB,IAAI,KAAK,CAAC;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,kBAAkB,CAAA;KAAE,CAAC;CAMhH;AAED,MAAM,WAAW,mBAAmB;IAAG,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE;AAC1F;+EAC+E;AAC/E,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,EAAE,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAoB1J"}
|
package/dist/delivery-plugins.js
CHANGED
|
@@ -2,8 +2,6 @@ import { pathToFileURL } from 'node:url';
|
|
|
2
2
|
import { resolve } from 'node:path';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { InvalidArgumentError, RelayHistoryError } from './sdk-common.js';
|
|
5
|
-
const CORE_COMMANDS = ['sessions', 'search', 'recent', 'session', 'events', 'resume', 'pack', 'stats', 'sync', 'export', 'delivery', 'plugin'];
|
|
6
|
-
const CORE_TOOLS = ['search_history', 'recent_history', 'list_sessions', 'discover_sessions', 'hydrate_session', 'get_session', 'get_session_events', 'get_session_relationships', 'get_session_tree', 'get_session_tool_calls', 'get_session_file_edits', 'history_stats', 'sync', 'delivery_status', 'delivery_pause', 'delivery_resume', 'delivery_retry'];
|
|
7
5
|
function label(value) {
|
|
8
6
|
if (typeof value !== 'string' || !/^[A-Za-z0-9_.:/@-]{1,200}$/.test(value)) {
|
|
9
7
|
throw new InvalidArgumentError('plugin identifiers must be nonempty non-secret labels', 'INVALID_ARGUMENT');
|
|
@@ -13,13 +11,9 @@ function label(value) {
|
|
|
13
11
|
export class HistoryPluginRegistry {
|
|
14
12
|
sources = new Map();
|
|
15
13
|
destinations = new Map();
|
|
16
|
-
commands = new Map();
|
|
17
|
-
tools = new Map();
|
|
18
14
|
register(plugin) {
|
|
19
15
|
const sources = new Map(this.sources);
|
|
20
16
|
const destinations = new Map(this.destinations);
|
|
21
|
-
const commands = new Map(this.commands);
|
|
22
|
-
const tools = new Map(this.tools);
|
|
23
17
|
for (const source of plugin.sources ?? []) {
|
|
24
18
|
label(source.id);
|
|
25
19
|
label(source.instanceId);
|
|
@@ -43,40 +37,10 @@ export class HistoryPluginRegistry {
|
|
|
43
37
|
}
|
|
44
38
|
destinations.set(key, destination);
|
|
45
39
|
}
|
|
46
|
-
for (const command of plugin.commands ?? []) {
|
|
47
|
-
label(command.name);
|
|
48
|
-
if (CORE_COMMANDS.includes(command.name) || commands.has(command.name))
|
|
49
|
-
throw new InvalidArgumentError(`duplicate command: ${command.name}`, 'INVALID_ARGUMENT');
|
|
50
|
-
commands.set(command.name, { ...command, run: async (args) => {
|
|
51
|
-
try {
|
|
52
|
-
return await command.run(args);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
throw new RelayHistoryError(`plugin command ${command.name} failed`, 'HISTORY_PLUGIN_COMMAND_FAILED');
|
|
56
|
-
}
|
|
57
|
-
} });
|
|
58
|
-
}
|
|
59
|
-
for (const tool of plugin.tools ?? []) {
|
|
60
|
-
label(tool.name);
|
|
61
|
-
if (CORE_TOOLS.includes(tool.name) || tools.has(tool.name))
|
|
62
|
-
throw new InvalidArgumentError(`duplicate tool: ${tool.name}`, 'INVALID_ARGUMENT');
|
|
63
|
-
tools.set(tool.name, { ...tool, run: async (input) => {
|
|
64
|
-
try {
|
|
65
|
-
return await tool.run(input);
|
|
66
|
-
}
|
|
67
|
-
catch {
|
|
68
|
-
throw new RelayHistoryError(`plugin tool ${tool.name} failed`, 'HISTORY_PLUGIN_TOOL_FAILED');
|
|
69
|
-
}
|
|
70
|
-
} });
|
|
71
|
-
}
|
|
72
40
|
for (const [key, value] of sources)
|
|
73
41
|
this.sources.set(key, value);
|
|
74
42
|
for (const [key, value] of destinations)
|
|
75
43
|
this.destinations.set(key, value);
|
|
76
|
-
for (const [key, value] of commands)
|
|
77
|
-
this.commands.set(key, value);
|
|
78
|
-
for (const [key, value] of tools)
|
|
79
|
-
this.tools.set(key, value);
|
|
80
44
|
}
|
|
81
45
|
sourceConnectors(ids) {
|
|
82
46
|
const sources = [...this.sources.values()];
|
|
@@ -92,15 +56,13 @@ export class HistoryPluginRegistry {
|
|
|
92
56
|
destination(id, instanceId) {
|
|
93
57
|
return this.destinations.get(JSON.stringify([id, instanceId]));
|
|
94
58
|
}
|
|
95
|
-
/** Every registered destination instance
|
|
59
|
+
/** Every registered destination instance. */
|
|
96
60
|
registeredDestinations() {
|
|
97
61
|
return [...this.destinations].map(([key, destination]) => {
|
|
98
62
|
const [destinationId, instanceId] = JSON.parse(key);
|
|
99
63
|
return { destinationId, instanceId, destination };
|
|
100
64
|
});
|
|
101
65
|
}
|
|
102
|
-
command(name) { return this.commands.get(name); }
|
|
103
|
-
registeredTools() { return [...this.tools.values()]; }
|
|
104
66
|
}
|
|
105
67
|
/** Resolve only user-listed installed packages/local modules from the config
|
|
106
68
|
* directory. Plugin factories must be inert: loading is not upload consent. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-plugins.js","sourceRoot":"","sources":["../src/delivery-plugins.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,iBAAi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QACD,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7G,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAA2G,CAAC;YAClK,IAAI,OAAO,QAAQ,CAAC,mBAAmB,KAAK,UAAU;gBAAE,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;YAClG,QAAQ,CAAC,QAAQ,CAAC,MAAM,QAAQ,CAAC,mBAAmB,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,oBAAoB;gBAAE,MAAM,KAAK,CAAC;YACvD,wEAAwE;YACxE,MAAM,IAAI,iBAAiB,CAAC,6BAA6B,KAAK,GAAG,CAAC,sBAAsB,EAAE,4BAA4B,CAAC,CAAC;QAC1H,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/delivery.d.ts
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Destination-facing helpers. The destination contract lives in delivery-contracts. */
|
|
2
2
|
import { RelayHistoryError } from './sdk-common.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type { DeliveryFailure, DeliveryJobConfig, DeliveryStatus } from './delivery-contracts.js';
|
|
3
|
+
import type { DeliveryFailure } from './delivery-contracts.js';
|
|
5
4
|
export * from './delivery-contracts.js';
|
|
6
5
|
export * from './delivery-plugins.js';
|
|
7
|
-
export interface HistoryDeliveryOptions {
|
|
8
|
-
dbPath?: string;
|
|
9
|
-
}
|
|
10
|
-
/** @deprecated Use the probe package. No native loading or database mutation occurs. */
|
|
11
|
-
export declare function deliveryRequest<T>(_request: Record<string, unknown>, _options?: HistoryDeliveryOptions): Promise<T>;
|
|
12
|
-
export declare function historyDeliveryRetention(_options?: HistoryDeliveryOptions): Promise<{
|
|
13
|
-
usedBytes: number;
|
|
14
|
-
limitBytes: number;
|
|
15
|
-
}>;
|
|
16
|
-
export declare function compactHistoryDelivery(_options?: HistoryDeliveryOptions): Promise<void>;
|
|
17
|
-
export declare function setHistoryDeliveryRetention(_maxBytes: number, _options?: HistoryDeliveryOptions): Promise<void>;
|
|
18
|
-
export declare function createHistoryDelivery(_config: DeliveryJobConfig, _options?: HistoryDeliveryOptions): Promise<DeliveryStatus>;
|
|
19
|
-
export declare function historyDeliveryStatus(_jobId?: string, _options?: HistoryDeliveryOptions): Promise<DeliveryStatus[]>;
|
|
20
|
-
export declare function controlHistoryDelivery(_jobId: string, _action: 'pause' | 'resume' | 'retry' | 'cancel', _options?: HistoryDeliveryOptions): Promise<DeliveryStatus>;
|
|
21
6
|
/** Safe classification only: arbitrary plugin errors are never persisted/logged. */
|
|
22
7
|
export declare class HistoryDeliveryError extends RelayHistoryError {
|
|
23
8
|
readonly failure: DeliveryFailure;
|
|
@@ -26,31 +11,4 @@ export declare class HistoryDeliveryError extends RelayHistoryError {
|
|
|
26
11
|
}
|
|
27
12
|
/** Translate an HTTP Retry-After header into an absolute retry time. */
|
|
28
13
|
export declare function deliveryRetryAfter(value: string | null, now?: number): number | undefined;
|
|
29
|
-
export interface DeliveryDrainOptions extends HistoryDeliveryOptions {
|
|
30
|
-
jobIds?: readonly string[];
|
|
31
|
-
signal?: AbortSignal;
|
|
32
|
-
workerId?: string;
|
|
33
|
-
maxBatches?: number;
|
|
34
|
-
maxPrepareSteps?: number;
|
|
35
|
-
requestTimeoutMs?: number;
|
|
36
|
-
leaseMs?: number;
|
|
37
|
-
}
|
|
38
|
-
export interface DeliveryDrainResult {
|
|
39
|
-
attempts: number;
|
|
40
|
-
statuses: DeliveryStatus[];
|
|
41
|
-
issues: Array<{
|
|
42
|
-
jobId: string;
|
|
43
|
-
code: 'DESTINATION_NOT_REGISTERED' | 'DELIVERY_STATE_FAILED' | 'DELIVERY_RETENTION_LIMIT';
|
|
44
|
-
detail?: string;
|
|
45
|
-
}>;
|
|
46
|
-
retention: {
|
|
47
|
-
usedBytes: number;
|
|
48
|
-
limitBytes: number;
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export declare function drainHistoryDelivery(_registry: HistoryPluginRegistry, _options?: DeliveryDrainOptions): Promise<DeliveryDrainResult>;
|
|
52
|
-
export declare function runHistoryDelivery(_registry: HistoryPluginRegistry, _options?: DeliveryDrainOptions & {
|
|
53
|
-
pollIntervalMs?: number;
|
|
54
|
-
onProgress?: (result: DeliveryDrainResult) => void | Promise<void>;
|
|
55
|
-
}): Promise<void>;
|
|
56
14
|
//# sourceMappingURL=delivery.d.ts.map
|
package/dist/delivery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,oFAAoF;AACpF,qBAAa,oBAAqB,SAAQ,iBAAiB;IAC7C,QAAQ,CAAC,OAAO,EAAE,eAAe;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM;gBAAxD,OAAO,EAAE,eAAe,EAAW,YAAY,CAAC,EAAE,MAAM,YAAA;CAG9E;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,SAAa,GAAG,MAAM,GAAG,SAAS,CAK7F"}
|
package/dist/delivery.js
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Destination-facing helpers. The destination contract lives in delivery-contracts. */
|
|
2
2
|
import { RelayHistoryError } from './sdk-common.js';
|
|
3
3
|
export * from './delivery-contracts.js';
|
|
4
4
|
export * from './delivery-plugins.js';
|
|
5
|
-
function moved() {
|
|
6
|
-
throw new RelayHistoryError('Upload jobs moved to agent-relay-probe / @relayhistory/capture. Manage existing jobs there; local history and export remain available in ai-hist.', 'HISTORY_DELIVERY_MOVED');
|
|
7
|
-
}
|
|
8
|
-
/** @deprecated Use the probe package. No native loading or database mutation occurs. */
|
|
9
|
-
export async function deliveryRequest(_request, _options = {}) { return moved(); }
|
|
10
|
-
export async function historyDeliveryRetention(_options = {}) { return moved(); }
|
|
11
|
-
export async function compactHistoryDelivery(_options = {}) { return moved(); }
|
|
12
|
-
export async function setHistoryDeliveryRetention(_maxBytes, _options = {}) { return moved(); }
|
|
13
|
-
export async function createHistoryDelivery(_config, _options = {}) { return moved(); }
|
|
14
|
-
export async function historyDeliveryStatus(_jobId, _options = {}) { return moved(); }
|
|
15
|
-
export async function controlHistoryDelivery(_jobId, _action, _options = {}) { return moved(); }
|
|
16
5
|
/** Safe classification only: arbitrary plugin errors are never persisted/logged. */
|
|
17
6
|
export class HistoryDeliveryError extends RelayHistoryError {
|
|
18
7
|
failure;
|
|
@@ -31,6 +20,4 @@ export function deliveryRetryAfter(value, now = Date.now()) {
|
|
|
31
20
|
const parsed = Number.isFinite(seconds) ? now + seconds * 1_000 : Date.parse(value);
|
|
32
21
|
return Number.isSafeInteger(parsed) && parsed >= now ? parsed : undefined;
|
|
33
22
|
}
|
|
34
|
-
export async function drainHistoryDelivery(_registry, _options = {}) { return moved(); }
|
|
35
|
-
export async function runHistoryDelivery(_registry, _options = {}) { return moved(); }
|
|
36
23
|
//# sourceMappingURL=delivery.js.map
|
package/dist/delivery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,oFAAoF;AACpF,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IACpC;IAAmC;IAAxD,YAAqB,OAAwB,EAAW,YAAqB;QAC3E,KAAK,CAAC,gCAAgC,OAAO,EAAE,EAAE,yBAAyB,CAAC,CAAC;QADzD,YAAO,GAAP,OAAO,CAAiB;QAAW,iBAAY,GAAZ,YAAY,CAAS;IAE7E,CAAC;CACF;AAED,wEAAwE;AACxE,MAAM,UAAU,kBAAkB,CAAC,KAAoB,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE;IACvE,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACpF,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { HistoryPluginRegistry } from './delivery-plugins.js';
|
|
2
|
+
import type { CatalogSession, EventCursor, EvidenceCursorInput, HistoryEntry, SessionEvent, SessionFileEdit, SessionToolCall } from './contracts.js';
|
|
3
|
+
import { type CatalogSource } from './sdk-common.js';
|
|
4
|
+
import { hydrateSession } from './operations.js';
|
|
5
|
+
export declare const HANDOFF_CONTRACT_VERSION = 1;
|
|
6
|
+
export declare const MAX_HANDOFF_INTENT_CHARS = 4000;
|
|
7
|
+
/** The exact pointer carried in a Relaycast delivery whose metadata kind is `handoff`. */
|
|
8
|
+
export interface HandoffPointer {
|
|
9
|
+
source: CatalogSource;
|
|
10
|
+
session_id: string;
|
|
11
|
+
intent: string;
|
|
12
|
+
origin_agent: string;
|
|
13
|
+
origin_user: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CreateHandoffOptions {
|
|
16
|
+
dbPath?: string;
|
|
17
|
+
/** Primarily for embedded hosts and deterministic tests. */
|
|
18
|
+
env?: NodeJS.ProcessEnv;
|
|
19
|
+
}
|
|
20
|
+
export interface HandoffPromptCursor {
|
|
21
|
+
timestampMs: number;
|
|
22
|
+
id: number;
|
|
23
|
+
}
|
|
24
|
+
export interface ResumeHandoffCursor {
|
|
25
|
+
prompt?: HandoffPromptCursor;
|
|
26
|
+
events?: EventCursor;
|
|
27
|
+
toolCalls?: EvidenceCursorInput;
|
|
28
|
+
fileEdits?: EvidenceCursorInput;
|
|
29
|
+
}
|
|
30
|
+
export interface ResumeHandoffOptions {
|
|
31
|
+
dbPath?: string;
|
|
32
|
+
plugins?: HistoryPluginRegistry;
|
|
33
|
+
acquisitionTimeoutMs?: number;
|
|
34
|
+
/** Per-evidence-kind page size. Default 200, maximum 1000. */
|
|
35
|
+
limit?: number;
|
|
36
|
+
cursor?: ResumeHandoffCursor;
|
|
37
|
+
}
|
|
38
|
+
export interface ResumeHandoffResult {
|
|
39
|
+
contract_version: typeof HANDOFF_CONTRACT_VERSION;
|
|
40
|
+
source: CatalogSource;
|
|
41
|
+
session_id: string;
|
|
42
|
+
session: CatalogSession | null;
|
|
43
|
+
hydration: Awaited<ReturnType<typeof hydrateSession>>;
|
|
44
|
+
prompts: HistoryEntry[];
|
|
45
|
+
events: SessionEvent[];
|
|
46
|
+
tool_calls: SessionToolCall[];
|
|
47
|
+
file_edits: SessionFileEdit[];
|
|
48
|
+
next_cursor: ResumeHandoffCursor | null;
|
|
49
|
+
}
|
|
50
|
+
interface SessionCandidate {
|
|
51
|
+
source: CatalogSource;
|
|
52
|
+
sessionId: string;
|
|
53
|
+
}
|
|
54
|
+
/** Harness-owned session IDs inherited by an MCP subprocess. Values are never guessed. */
|
|
55
|
+
export declare function currentSessionCandidates(env?: NodeJS.ProcessEnv): SessionCandidate[];
|
|
56
|
+
/** Build a pointer for the invoking harness's own indexed session. */
|
|
57
|
+
export declare function createHandoff(intent: string, options?: CreateHandoffOptions): Promise<HandoffPointer>;
|
|
58
|
+
/**
|
|
59
|
+
* Hydrate a same-workspace session, then compose one bounded continuation page
|
|
60
|
+
* containing every evidence class needed by a coding agent.
|
|
61
|
+
*/
|
|
62
|
+
export declare function resumeHandoff(source: CatalogSource, sessionId: string, options?: ResumeHandoffOptions): Promise<ResumeHandoffResult>;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EACV,cAAc,EAEd,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,eAAe,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAOL,KAAK,aAAa,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAML,cAAc,EAEf,MAAM,iBAAiB,CAAC;AAGzB,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAC1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,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,WAAW,EAAE,mBAAmB,GAAG,IAAI,CAAC;CACzC;AAED,UAAU,gBAAgB;IACxB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAWD,0FAA0F;AAC1F,wBAAgB,wBAAwB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,gBAAgB,EAAE,CAkCjG;AA2CD,sEAAsE;AACtE,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,cAAc,CAAC,CAsDzB;AAqBD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CAoJ9B"}
|
package/dist/handoff.js
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import { CATALOG_SOURCES, ConnectorNotConfiguredError, InvalidArgumentError, RelayHistoryError, SessionNotFoundError, SessionSourceUnavailableError, } from './sdk-common.js';
|
|
2
|
+
import { discoverSessions, getSession, getSessionEventsPage, getSessionFileEditsPage, getSessionToolCallsPage, hydrateSession, listSessionCatalogPage, } from './operations.js';
|
|
3
|
+
import { discoverSourcePlugins } from './source-plugins.js';
|
|
4
|
+
export const HANDOFF_CONTRACT_VERSION = 1;
|
|
5
|
+
export const MAX_HANDOFF_INTENT_CHARS = 4000;
|
|
6
|
+
const HANDOFF_DISCOVERY_ATTEMPTS = 2;
|
|
7
|
+
const HANDOFF_INTENT_TRUNCATION_MARKER = '…';
|
|
8
|
+
function continuationIntent(source, sessionId, originalIntent) {
|
|
9
|
+
const prefix = `Resume this handoff: call resume_handoff(source=${source}, session_id=${sessionId}) via the ai-hist MCP, then continue: `;
|
|
10
|
+
const prefixLength = Array.from(prefix).length;
|
|
11
|
+
if (prefixLength >= MAX_HANDOFF_INTENT_CHARS) {
|
|
12
|
+
throw new InvalidArgumentError(`handoff resume instruction must be shorter than ${MAX_HANDOFF_INTENT_CHARS} characters`, 'INVALID_ARGUMENT');
|
|
13
|
+
}
|
|
14
|
+
const originalCharacters = Array.from(originalIntent);
|
|
15
|
+
const availableCharacters = MAX_HANDOFF_INTENT_CHARS - prefixLength;
|
|
16
|
+
if (originalCharacters.length <= availableCharacters)
|
|
17
|
+
return prefix + originalIntent;
|
|
18
|
+
return prefix + originalCharacters
|
|
19
|
+
.slice(0, availableCharacters - 1)
|
|
20
|
+
.join('') + HANDOFF_INTENT_TRUNCATION_MARKER;
|
|
21
|
+
}
|
|
22
|
+
function nonempty(value) {
|
|
23
|
+
const trimmed = value?.trim();
|
|
24
|
+
return trimmed ? trimmed : undefined;
|
|
25
|
+
}
|
|
26
|
+
function catalogSource(value) {
|
|
27
|
+
return CATALOG_SOURCES.includes(value) ? value : undefined;
|
|
28
|
+
}
|
|
29
|
+
/** Harness-owned session IDs inherited by an MCP subprocess. Values are never guessed. */
|
|
30
|
+
export function currentSessionCandidates(env = process.env) {
|
|
31
|
+
const explicitSource = catalogSource(nonempty(env.AI_HIST_CURRENT_SOURCE));
|
|
32
|
+
const explicitSession = nonempty(env.AI_HIST_CURRENT_SESSION_ID);
|
|
33
|
+
const candidates = [
|
|
34
|
+
explicitSource && explicitSession
|
|
35
|
+
? { source: explicitSource, sessionId: explicitSession }
|
|
36
|
+
: undefined,
|
|
37
|
+
(nonempty(env.CODEX_THREAD_ID) ?? nonempty(env.CODEX_SESSION_ID))
|
|
38
|
+
? { source: 'codex', sessionId: (nonempty(env.CODEX_THREAD_ID) ?? nonempty(env.CODEX_SESSION_ID)) }
|
|
39
|
+
: undefined,
|
|
40
|
+
nonempty(env.CLAUDE_CODE_SESSION_ID)
|
|
41
|
+
? { source: 'claude', sessionId: nonempty(env.CLAUDE_CODE_SESSION_ID) }
|
|
42
|
+
: undefined,
|
|
43
|
+
(nonempty(env.CURSOR_AGENT_SESSION_ID) ?? nonempty(env.CURSOR_SESSION_ID))
|
|
44
|
+
? { source: 'cursor', sessionId: (nonempty(env.CURSOR_AGENT_SESSION_ID) ?? nonempty(env.CURSOR_SESSION_ID)) }
|
|
45
|
+
: undefined,
|
|
46
|
+
nonempty(env.GROK_SESSION_ID)
|
|
47
|
+
? { source: 'grok', sessionId: nonempty(env.GROK_SESSION_ID) }
|
|
48
|
+
: undefined,
|
|
49
|
+
nonempty(env.OPENCODE_SESSION_ID)
|
|
50
|
+
? { source: 'opencode', sessionId: nonempty(env.OPENCODE_SESSION_ID) }
|
|
51
|
+
: undefined,
|
|
52
|
+
(nonempty(env.AGENT_RELAY_SESSION_ID) ?? nonempty(env.RELAY_SESSION_ID))
|
|
53
|
+
? { source: 'relay', sessionId: (nonempty(env.AGENT_RELAY_SESSION_ID) ?? nonempty(env.RELAY_SESSION_ID)) }
|
|
54
|
+
: undefined,
|
|
55
|
+
];
|
|
56
|
+
const seen = new Set();
|
|
57
|
+
return candidates.filter((candidate) => {
|
|
58
|
+
if (!candidate)
|
|
59
|
+
return false;
|
|
60
|
+
const key = `${candidate.source}\0${candidate.sessionId}`;
|
|
61
|
+
if (seen.has(key))
|
|
62
|
+
return false;
|
|
63
|
+
seen.add(key);
|
|
64
|
+
return true;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async function catalogMatches(candidates, dbPath, scope = 'local') {
|
|
68
|
+
if (!candidates.length)
|
|
69
|
+
return [];
|
|
70
|
+
const candidateKeys = new Set(candidates.map((candidate) => `${candidate.source}\0${candidate.sessionId}`));
|
|
71
|
+
const matches = new Map();
|
|
72
|
+
const seenCursors = new Set();
|
|
73
|
+
let after;
|
|
74
|
+
do {
|
|
75
|
+
const page = await listSessionCatalogPage({
|
|
76
|
+
dbPath,
|
|
77
|
+
scope,
|
|
78
|
+
sources: [...new Set(candidates.map((candidate) => candidate.source))],
|
|
79
|
+
limit: 1000,
|
|
80
|
+
after,
|
|
81
|
+
});
|
|
82
|
+
for (const session of page.sessions) {
|
|
83
|
+
const key = `${session.source}\0${session.sessionId}`;
|
|
84
|
+
if (candidateKeys.has(key))
|
|
85
|
+
matches.set(key, session);
|
|
86
|
+
}
|
|
87
|
+
if (matches.size === candidateKeys.size || !page.nextCursor)
|
|
88
|
+
break;
|
|
89
|
+
const cursorKey = JSON.stringify(page.nextCursor);
|
|
90
|
+
if (seenCursors.has(cursorKey)) {
|
|
91
|
+
throw new RelayHistoryError('Session catalog pagination repeated a cursor', 'CATALOG_CURSOR_REPEATED');
|
|
92
|
+
}
|
|
93
|
+
seenCursors.add(cursorKey);
|
|
94
|
+
after = page.nextCursor;
|
|
95
|
+
} while (after);
|
|
96
|
+
return candidates.flatMap((candidate) => {
|
|
97
|
+
const match = matches.get(`${candidate.source}\0${candidate.sessionId}`);
|
|
98
|
+
return match ? [match] : [];
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/** Build a pointer for the invoking harness's own indexed session. */
|
|
102
|
+
export async function createHandoff(intent, options = {}) {
|
|
103
|
+
const normalizedIntent = nonempty(intent);
|
|
104
|
+
if (!normalizedIntent)
|
|
105
|
+
throw new InvalidArgumentError('handoff intent must not be empty', 'INVALID_ARGUMENT');
|
|
106
|
+
if (Array.from(normalizedIntent).length > MAX_HANDOFF_INTENT_CHARS)
|
|
107
|
+
throw new InvalidArgumentError(`handoff intent must not exceed ${MAX_HANDOFF_INTENT_CHARS} characters`, 'INVALID_ARGUMENT');
|
|
108
|
+
const env = options.env ?? process.env;
|
|
109
|
+
const candidates = currentSessionCandidates(env);
|
|
110
|
+
if (!candidates.length) {
|
|
111
|
+
throw new RelayHistoryError('The current harness did not expose a session identity; set AI_HIST_CURRENT_SOURCE and AI_HIST_CURRENT_SESSION_ID', 'CURRENT_SESSION_UNAVAILABLE');
|
|
112
|
+
}
|
|
113
|
+
let matches = await catalogMatches(candidates, options.dbPath);
|
|
114
|
+
if (!matches.length) {
|
|
115
|
+
await discoverSessions({
|
|
116
|
+
dbPath: options.dbPath,
|
|
117
|
+
scope: 'local',
|
|
118
|
+
sources: [...new Set(candidates.map((candidate) => candidate.source))],
|
|
119
|
+
});
|
|
120
|
+
matches = await catalogMatches(candidates, options.dbPath);
|
|
121
|
+
}
|
|
122
|
+
const session = matches[0];
|
|
123
|
+
if (!session) {
|
|
124
|
+
throw new RelayHistoryError('The current harness session was not found in the local session catalog', 'CURRENT_SESSION_NOT_FOUND');
|
|
125
|
+
}
|
|
126
|
+
const intentWithResumeInstruction = continuationIntent(session.source, session.sessionId, normalizedIntent);
|
|
127
|
+
return {
|
|
128
|
+
source: session.source,
|
|
129
|
+
session_id: session.sessionId,
|
|
130
|
+
intent: intentWithResumeInstruction,
|
|
131
|
+
origin_agent: nonempty(env.AI_HIST_ORIGIN_AGENT) ??
|
|
132
|
+
nonempty(env.AGENT_RELAY_AGENT_NAME) ??
|
|
133
|
+
nonempty(session.originator ?? undefined) ??
|
|
134
|
+
session.source,
|
|
135
|
+
origin_user: nonempty(env.AI_HIST_ORIGIN_USER) ??
|
|
136
|
+
nonempty(env.AGENT_RELAY_USER_ID) ??
|
|
137
|
+
nonempty(env.AGENT_RELAY_USER_EMAIL) ??
|
|
138
|
+
nonempty(env.USER ?? env.USERNAME) ??
|
|
139
|
+
'unknown',
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function validateIdentity(source, sessionId) {
|
|
143
|
+
if (!CATALOG_SOURCES.includes(source))
|
|
144
|
+
throw new InvalidArgumentError(`invalid catalog source: ${String(source)}`, 'INVALID_ARGUMENT');
|
|
145
|
+
if (!nonempty(sessionId))
|
|
146
|
+
throw new InvalidArgumentError('sessionId must not be empty', 'INVALID_ARGUMENT');
|
|
147
|
+
}
|
|
148
|
+
function validateLimit(limit) {
|
|
149
|
+
const value = limit ?? 200;
|
|
150
|
+
if (!Number.isInteger(value) || value < 1 || value > 1000)
|
|
151
|
+
throw new InvalidArgumentError('limit must be an integer from 1 to 1000', 'INVALID_ARGUMENT');
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function afterPrompt(entry, cursor) {
|
|
155
|
+
return !cursor || entry.timestampMs > cursor.timestampMs ||
|
|
156
|
+
(entry.timestampMs === cursor.timestampMs && entry.id > cursor.id);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Hydrate a same-workspace session, then compose one bounded continuation page
|
|
160
|
+
* containing every evidence class needed by a coding agent.
|
|
161
|
+
*/
|
|
162
|
+
export async function resumeHandoff(source, sessionId, options = {}) {
|
|
163
|
+
validateIdentity(source, sessionId);
|
|
164
|
+
const limit = validateLimit(options.limit);
|
|
165
|
+
let hydration;
|
|
166
|
+
try {
|
|
167
|
+
const sourceConnectors = ['cloud'];
|
|
168
|
+
if (options.plugins) {
|
|
169
|
+
// Refresh the identity-addressed observation on every resume. A cached
|
|
170
|
+
// observation may belong to the account that was authenticated before a
|
|
171
|
+
// workspace switch, and hydrateSession otherwise reuses it without
|
|
172
|
+
// rediscovery.
|
|
173
|
+
let refreshed = false;
|
|
174
|
+
let discoveryFailure;
|
|
175
|
+
for (let attempt = 0; attempt < HANDOFF_DISCOVERY_ATTEMPTS; attempt += 1) {
|
|
176
|
+
const attemptFailures = [];
|
|
177
|
+
const refresh = await discoverSourcePlugins(options.plugins, {
|
|
178
|
+
dbPath: options.dbPath,
|
|
179
|
+
sourceConnectors,
|
|
180
|
+
sources: [source],
|
|
181
|
+
sessionId,
|
|
182
|
+
acquisitionTimeoutMs: options.acquisitionTimeoutMs,
|
|
183
|
+
onUnavailable: (_connector, error) => { attemptFailures.push(error); },
|
|
184
|
+
});
|
|
185
|
+
refreshed = refresh.some((run) => run.observations.some((observation) => observation.source === source && observation.session_id === sessionId));
|
|
186
|
+
if (refreshed)
|
|
187
|
+
break;
|
|
188
|
+
const terminalFailure = attemptFailures.find((error) => !['CONNECTOR_FAILURE', 'SOURCE_ACQUISITION_TIMEOUT'].includes(error.code));
|
|
189
|
+
if (terminalFailure)
|
|
190
|
+
throw terminalFailure;
|
|
191
|
+
if (!attemptFailures.length) {
|
|
192
|
+
// A complete targeted refresh is authoritative. It also prevents
|
|
193
|
+
// hydrateSession from reusing an observation cached for an older
|
|
194
|
+
// authenticated workspace.
|
|
195
|
+
throw new SessionNotFoundError('Source session was not found in the authenticated workspace', 'SESSION_NOT_FOUND');
|
|
196
|
+
}
|
|
197
|
+
discoveryFailure = attemptFailures[0];
|
|
198
|
+
}
|
|
199
|
+
if (!refreshed) {
|
|
200
|
+
// A partial refresh cannot prove either presence or absence. Do not
|
|
201
|
+
// fall back to cached authorization from a connector that failed;
|
|
202
|
+
// surface a retryable acquisition error instead.
|
|
203
|
+
throw new RelayHistoryError('The authenticated workspace could not be checked for the handoff session', 'HANDOFF_SOURCE_UNAVAILABLE', { cause: discoveryFailure });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
hydration = await hydrateSession({
|
|
207
|
+
source,
|
|
208
|
+
sessionId,
|
|
209
|
+
dbPath: options.dbPath,
|
|
210
|
+
// A handoff is a workspace pointer. Remote acquisition must authorize it;
|
|
211
|
+
// a coincidentally matching local session may never satisfy the load.
|
|
212
|
+
scope: 'remote',
|
|
213
|
+
includeRelated: true,
|
|
214
|
+
plugins: options.plugins,
|
|
215
|
+
// The standard connector is the workspace-scoped RelayHistory source.
|
|
216
|
+
// Other provider connectors represent personal accounts and cannot
|
|
217
|
+
// authorize a teammate handoff.
|
|
218
|
+
sourceConnectors,
|
|
219
|
+
acquisitionTimeoutMs: options.acquisitionTimeoutMs,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error instanceof SessionNotFoundError ||
|
|
224
|
+
error instanceof SessionSourceUnavailableError) {
|
|
225
|
+
throw new RelayHistoryError('The handoff session is unavailable in the authenticated workspace; cross-workspace and cross-organization handoffs are not supported', 'HANDOFF_WORKSPACE_MISMATCH', { cause: error });
|
|
226
|
+
}
|
|
227
|
+
if (error instanceof ConnectorNotConfiguredError) {
|
|
228
|
+
throw new RelayHistoryError('Remote handoff acquisition is not configured; configure the workspace cloud source connector', 'HANDOFF_CONNECTOR_NOT_CONFIGURED', { cause: error });
|
|
229
|
+
}
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
const [allPrompts, eventsPage, toolCallsPage, fileEditsPage, catalogMatchesResult] = await Promise.all([
|
|
233
|
+
getSession(sessionId, { source, dbPath: options.dbPath }),
|
|
234
|
+
getSessionEventsPage(sessionId, {
|
|
235
|
+
source,
|
|
236
|
+
dbPath: options.dbPath,
|
|
237
|
+
limit,
|
|
238
|
+
after: options.cursor?.events,
|
|
239
|
+
}),
|
|
240
|
+
getSessionToolCallsPage(source, sessionId, {
|
|
241
|
+
dbPath: options.dbPath,
|
|
242
|
+
limit,
|
|
243
|
+
after: options.cursor?.toolCalls,
|
|
244
|
+
}),
|
|
245
|
+
getSessionFileEditsPage(source, sessionId, {
|
|
246
|
+
dbPath: options.dbPath,
|
|
247
|
+
limit,
|
|
248
|
+
after: options.cursor?.fileEdits,
|
|
249
|
+
}),
|
|
250
|
+
catalogMatches([{ source, sessionId }], options.dbPath, 'all'),
|
|
251
|
+
]);
|
|
252
|
+
const promptCandidates = allPrompts
|
|
253
|
+
.filter((entry) => afterPrompt(entry, options.cursor?.prompt))
|
|
254
|
+
.sort((left, right) => left.timestampMs - right.timestampMs || left.id - right.id);
|
|
255
|
+
const prompts = promptCandidates.slice(0, limit);
|
|
256
|
+
const lastPrompt = prompts.at(-1);
|
|
257
|
+
const lastEvent = eventsPage.events.at(-1);
|
|
258
|
+
const lastToolCall = toolCallsPage.toolCalls.at(-1);
|
|
259
|
+
const lastFileEdit = fileEditsPage.fileEdits.at(-1);
|
|
260
|
+
const hasMore = promptCandidates.length > prompts.length || eventsPage.nextCursor !== null ||
|
|
261
|
+
toolCallsPage.nextCursor !== null || fileEditsPage.nextCursor !== null;
|
|
262
|
+
const promptCheckpoint = lastPrompt
|
|
263
|
+
? { timestampMs: lastPrompt.timestampMs, id: lastPrompt.id }
|
|
264
|
+
: options.cursor?.prompt;
|
|
265
|
+
const eventCheckpoint = eventsPage.nextCursor ??
|
|
266
|
+
(lastEvent ? { tsMs: lastEvent.tsMs, id: lastEvent.id } : options.cursor?.events);
|
|
267
|
+
const toolCallCheckpoint = toolCallsPage.nextCursor ??
|
|
268
|
+
(lastToolCall ? { tsMs: lastToolCall.tsMs, id: lastToolCall.id } : options.cursor?.toolCalls);
|
|
269
|
+
const fileEditCheckpoint = fileEditsPage.nextCursor ??
|
|
270
|
+
(lastFileEdit ? { tsMs: lastFileEdit.tsMs, id: lastFileEdit.id } : options.cursor?.fileEdits);
|
|
271
|
+
// A composite cursor checkpoints every stream whenever any stream continues;
|
|
272
|
+
// otherwise a shorter stream would restart and duplicate evidence on page 2.
|
|
273
|
+
const nextCursor = hasMore ? {
|
|
274
|
+
...(promptCheckpoint ? { prompt: promptCheckpoint } : {}),
|
|
275
|
+
...(eventCheckpoint ? { events: eventCheckpoint } : {}),
|
|
276
|
+
...(toolCallCheckpoint ? { toolCalls: toolCallCheckpoint } : {}),
|
|
277
|
+
...(fileEditCheckpoint ? { fileEdits: fileEditCheckpoint } : {}),
|
|
278
|
+
} : null;
|
|
279
|
+
return {
|
|
280
|
+
contract_version: HANDOFF_CONTRACT_VERSION,
|
|
281
|
+
source,
|
|
282
|
+
session_id: sessionId,
|
|
283
|
+
session: catalogMatchesResult[0] ?? null,
|
|
284
|
+
hydration,
|
|
285
|
+
prompts,
|
|
286
|
+
events: eventsPage.events,
|
|
287
|
+
tool_calls: toolCallsPage.toolCalls,
|
|
288
|
+
file_edits: fileEditsPage.fileEdits,
|
|
289
|
+
next_cursor: nextCursor,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=handoff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.js","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,EACpB,iBAAiB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