@astralyn/pi 1.4.6 → 1.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/bundle/chunks/{chunk-EYKC6ESU.js → chunk-5VIOGR76.js} +1 -1
- package/dist/bundle/chunks/{chunk-KDO6L76C.js → chunk-FODCTZXW.js} +4 -4
- package/dist/bundle/chunks/{chunk-RBTJBQWX.js → chunk-I2COK45I.js} +136 -137
- package/dist/bundle/chunks/{chunk-AXFWZIHH.js → chunk-MG5XDTXV.js} +1 -1
- package/dist/bundle/chunks/{chunk-ALHAFUHP.js → chunk-PU2IWWXV.js} +1 -1
- package/dist/bundle/chunks/{chunk-5M3YJ54Z.js → chunk-RO2VH6UZ.js} +1 -1
- package/dist/bundle/chunks/{cli-FH77R7JR.js → cli-MEL7SGJD.js} +1 -1
- package/dist/bundle/chunks/{execute-5ZQUS52M.js → execute-4CWRNHPO.js} +1 -1
- package/dist/bundle/chunks/{runtime-R5CMHJ5P.js → runtime-R3X67XMR.js} +1 -1
- package/dist/bundle/chunks/{virtual-modules-KCQU7LOC.js → virtual-modules-BBLD7YLS.js} +1 -1
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +0 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +0 -4
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/package-manager.d.ts +3 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +10 -0
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader.d.ts +2 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +17 -4
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -2
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +11 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +7 -0
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +6 -0
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/skill-invocation.d.ts +46 -0
- package/dist/core/skill-invocation.d.ts.map +1 -0
- package/dist/core/skill-invocation.js +128 -0
- package/dist/core/skill-invocation.js.map +1 -0
- package/dist/core/skills.d.ts +10 -0
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +23 -0
- package/dist/core/skills.js.map +1 -1
- package/dist/core/tasks/delivery.d.ts +11 -4
- package/dist/core/tasks/delivery.d.ts.map +1 -1
- package/dist/core/tasks/delivery.js +9 -9
- package/dist/core/tasks/delivery.js.map +1 -1
- package/dist/core/tasks/execution.d.ts +10 -3
- package/dist/core/tasks/execution.d.ts.map +1 -1
- package/dist/core/tasks/execution.js +72 -52
- package/dist/core/tasks/execution.js.map +1 -1
- package/dist/core/tasks/format.d.ts +0 -2
- package/dist/core/tasks/format.d.ts.map +1 -1
- package/dist/core/tasks/format.js +1 -16
- package/dist/core/tasks/format.js.map +1 -1
- package/dist/core/tasks/limits.d.ts +12 -1
- package/dist/core/tasks/limits.d.ts.map +1 -1
- package/dist/core/tasks/limits.js +20 -1
- package/dist/core/tasks/limits.js.map +1 -1
- package/dist/core/tasks/output.d.ts +6 -12
- package/dist/core/tasks/output.d.ts.map +1 -1
- package/dist/core/tasks/output.js +35 -32
- package/dist/core/tasks/output.js.map +1 -1
- package/dist/core/tasks/record.d.ts +45 -0
- package/dist/core/tasks/record.d.ts.map +1 -0
- package/dist/core/tasks/record.js +80 -0
- package/dist/core/tasks/record.js.map +1 -0
- package/dist/core/tasks/runtime.d.ts +14 -14
- package/dist/core/tasks/runtime.d.ts.map +1 -1
- package/dist/core/tasks/runtime.js +111 -93
- package/dist/core/tasks/runtime.js.map +1 -1
- package/dist/core/tasks/session.d.ts +0 -1
- package/dist/core/tasks/session.d.ts.map +1 -1
- package/dist/core/tasks/session.js +7 -8
- package/dist/core/tasks/session.js.map +1 -1
- package/dist/core/tasks/store.d.ts +18 -25
- package/dist/core/tasks/store.d.ts.map +1 -1
- package/dist/core/tasks/store.js +42 -40
- package/dist/core/tasks/store.js.map +1 -1
- package/dist/core/tasks/types.d.ts +96 -17
- package/dist/core/tasks/types.d.ts.map +1 -1
- package/dist/core/tasks/types.js.map +1 -1
- package/dist/core/tools/shell-execution.d.ts +8 -7
- package/dist/core/tools/shell-execution.d.ts.map +1 -1
- package/dist/core/tools/shell-execution.js +18 -26
- package/dist/core/tools/shell-execution.js.map +1 -1
- package/dist/core/tools/shell-tool.d.ts.map +1 -1
- package/dist/core/tools/shell-tool.js +31 -29
- package/dist/core/tools/shell-tool.js.map +1 -1
- package/dist/core/usage-totals.d.ts +3 -0
- package/dist/core/usage-totals.d.ts.map +1 -1
- package/dist/core/usage-totals.js +15 -0
- package/dist/core/usage-totals.js.map +1 -1
- package/dist/extensions/agent/progress.d.ts.map +1 -1
- package/dist/extensions/agent/progress.js +1 -11
- package/dist/extensions/agent/progress.js.map +1 -1
- package/dist/extensions/agent/settings-host.d.ts +33 -0
- package/dist/extensions/agent/settings-host.d.ts.map +1 -0
- package/dist/extensions/agent/settings-host.js +75 -0
- package/dist/extensions/agent/settings-host.js.map +1 -0
- package/dist/extensions/agent/settings.d.ts.map +1 -1
- package/dist/extensions/agent/settings.js +18 -7
- package/dist/extensions/agent/settings.js.map +1 -1
- package/dist/extensions/agent/tool.d.ts.map +1 -1
- package/dist/extensions/agent/tool.js +9 -5
- package/dist/extensions/agent/tool.js.map +1 -1
- package/dist/extensions/agent/worker.d.ts.map +1 -1
- package/dist/extensions/agent/worker.js +3 -5
- package/dist/extensions/agent/worker.js.map +1 -1
- package/dist/extensions/btw/agent.d.ts +1 -1
- package/dist/extensions/btw/agent.d.ts.map +1 -1
- package/dist/extensions/btw/agent.js +3 -20
- package/dist/extensions/btw/agent.js.map +1 -1
- package/dist/extensions/cached-compaction/index.d.ts.map +1 -1
- package/dist/extensions/cached-compaction/index.js +3 -22
- package/dist/extensions/cached-compaction/index.js.map +1 -1
- package/dist/extensions/cached-compaction/render.d.ts +1 -0
- package/dist/extensions/cached-compaction/render.d.ts.map +1 -1
- package/dist/extensions/cached-compaction/render.js +42 -14
- package/dist/extensions/cached-compaction/render.js.map +1 -1
- package/dist/extensions/deepwiki/client.d.ts.map +1 -1
- package/dist/extensions/deepwiki/client.js +6 -78
- package/dist/extensions/deepwiki/client.js.map +1 -1
- package/dist/extensions/deepwiki/transport.d.ts +3 -0
- package/dist/extensions/deepwiki/transport.d.ts.map +1 -0
- package/dist/extensions/deepwiki/transport.js +96 -0
- package/dist/extensions/deepwiki/transport.js.map +1 -0
- package/dist/extensions/provider/ui/builtin-data.d.ts +3 -3
- package/dist/extensions/provider/ui/builtin-data.d.ts.map +1 -1
- package/dist/extensions/provider/ui/builtin-data.js.map +1 -1
- package/dist/extensions/provider/ui/compat.d.ts +3 -3
- package/dist/extensions/provider/ui/compat.d.ts.map +1 -1
- package/dist/extensions/provider/ui/compat.js.map +1 -1
- package/dist/extensions/provider/ui/controls.d.ts +2 -2
- package/dist/extensions/provider/ui/controls.d.ts.map +1 -1
- package/dist/extensions/provider/ui/controls.js.map +1 -1
- package/dist/extensions/provider/ui/dialogs.d.ts +3 -3
- package/dist/extensions/provider/ui/dialogs.d.ts.map +1 -1
- package/dist/extensions/provider/ui/dialogs.js.map +1 -1
- package/dist/extensions/provider/ui/dictionary.d.ts +2 -2
- package/dist/extensions/provider/ui/dictionary.d.ts.map +1 -1
- package/dist/extensions/provider/ui/dictionary.js.map +1 -1
- package/dist/extensions/provider/ui/editor.d.ts.map +1 -1
- package/dist/extensions/provider/ui/editor.js +1 -3
- package/dist/extensions/provider/ui/editor.js.map +1 -1
- package/dist/extensions/provider/ui/fetch-models.d.ts +2 -2
- package/dist/extensions/provider/ui/fetch-models.d.ts.map +1 -1
- package/dist/extensions/provider/ui/fetch-models.js.map +1 -1
- package/dist/extensions/provider/ui/model-fields.d.ts +2 -2
- package/dist/extensions/provider/ui/model-fields.d.ts.map +1 -1
- package/dist/extensions/provider/ui/model-fields.js.map +1 -1
- package/dist/extensions/provider/ui/model-options.d.ts +6 -6
- package/dist/extensions/provider/ui/model-options.d.ts.map +1 -1
- package/dist/extensions/provider/ui/model-options.js.map +1 -1
- package/dist/extensions/provider/ui/pane.d.ts +21 -12
- package/dist/extensions/provider/ui/pane.d.ts.map +1 -1
- package/dist/extensions/provider/ui/pane.js.map +1 -1
- package/dist/extensions/provider/ui/provider-fields.d.ts +3 -3
- package/dist/extensions/provider/ui/provider-fields.d.ts.map +1 -1
- package/dist/extensions/provider/ui/provider-fields.js.map +1 -1
- package/dist/extensions/provider/ui/thinking-map.d.ts +2 -2
- package/dist/extensions/provider/ui/thinking-map.d.ts.map +1 -1
- package/dist/extensions/provider/ui/thinking-map.js.map +1 -1
- package/dist/extensions/run-summary/format.js +1 -1
- package/dist/extensions/run-summary/format.js.map +1 -1
- package/dist/extensions/statusline/usage.d.ts.map +1 -1
- package/dist/extensions/statusline/usage.js +2 -6
- package/dist/extensions/statusline/usage.js.map +1 -1
- package/dist/extensions/tasks/tool/actions.d.ts +1 -1
- package/dist/extensions/tasks/tool/actions.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/actions.js +49 -106
- package/dist/extensions/tasks/tool/actions.js.map +1 -1
- package/dist/extensions/tasks/tool/constants.d.ts +1 -6
- package/dist/extensions/tasks/tool/constants.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/constants.js +1 -6
- package/dist/extensions/tasks/tool/constants.js.map +1 -1
- package/dist/extensions/tasks/tool/schema.d.ts +0 -3
- package/dist/extensions/tasks/tool/schema.d.ts.map +1 -1
- package/dist/extensions/tasks/tool/schema.js +4 -13
- package/dist/extensions/tasks/tool/schema.js.map +1 -1
- package/dist/extensions/tasks/tool.d.ts.map +1 -1
- package/dist/extensions/tasks/tool.js +2 -2
- package/dist/extensions/tasks/tool.js.map +1 -1
- package/dist/extensions/tasks/ui/completion-render.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/completion-render.js +31 -33
- package/dist/extensions/tasks/ui/completion-render.js.map +1 -1
- package/dist/extensions/tasks/ui/layout.d.ts +7 -7
- package/dist/extensions/tasks/ui/layout.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/layout.js +17 -19
- package/dist/extensions/tasks/ui/layout.js.map +1 -1
- package/dist/extensions/tasks/ui/list.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/list.js +2 -3
- package/dist/extensions/tasks/ui/list.js.map +1 -1
- package/dist/extensions/tasks/ui/manager.d.ts +16 -7
- package/dist/extensions/tasks/ui/manager.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/manager.js +163 -131
- package/dist/extensions/tasks/ui/manager.js.map +1 -1
- package/dist/extensions/tasks/ui/model.d.ts +25 -0
- package/dist/extensions/tasks/ui/model.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/model.js +4 -0
- package/dist/extensions/tasks/ui/model.js.map +1 -1
- package/dist/extensions/tasks/ui/render.d.ts +1 -1
- package/dist/extensions/tasks/ui/render.d.ts.map +1 -1
- package/dist/extensions/tasks/ui/render.js +11 -7
- package/dist/extensions/tasks/ui/render.js.map +1 -1
- package/dist/extensions/tasks/ui/status.d.ts +15 -0
- package/dist/extensions/tasks/ui/status.d.ts.map +1 -0
- package/dist/extensions/tasks/ui/status.js +16 -0
- package/dist/extensions/tasks/ui/status.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +17 -2
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +199 -18
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/status-marker.d.ts +2 -1
- package/dist/modes/interactive/components/status-marker.d.ts.map +1 -1
- package/dist/modes/interactive/components/status-marker.js +0 -1
- package/dist/modes/interactive/components/status-marker.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +7 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/duration.d.ts +3 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +17 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/number.d.ts +3 -0
- package/dist/utils/number.d.ts.map +1 -0
- package/dist/utils/number.js +5 -0
- package/dist/utils/number.js.map +1 -0
- package/docs/bundled/extensions/agent.md +3 -3
- package/docs/bundled/extensions/cached-compaction.md +13 -4
- package/docs/bundled/extensions/deepwiki.md +3 -1
- package/docs/extensions.md +5 -5
- package/docs/packages.md +5 -3
- package/docs/sdk.md +1 -1
- package/docs/session-format.md +1 -1
- package/docs/settings.md +11 -0
- package/docs/skills.md +23 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/schemas/settings.schema.json +36 -0
- package/dist/extensions/deepwiki/http.d.ts +0 -13
- package/dist/extensions/deepwiki/http.d.ts.map +0 -1
- package/dist/extensions/deepwiki/http.js +0 -88
- package/dist/extensions/deepwiki/http.js.map +0 -1
- package/dist/extensions/tasks/ui/task-view.d.ts +0 -8
- package/dist/extensions/tasks/ui/task-view.d.ts.map +0 -1
- package/dist/extensions/tasks/ui/task-view.js +0 -13
- package/dist/extensions/tasks/ui/task-view.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { type TaskExecution, type TaskRead, type TaskRuntimeOptions, type TaskSnapshot, type TasksContext, type TaskToolOutcome } from "./types.ts";
|
|
2
|
+
import { type TaskDeliveryLedger, type TaskExecution, type TaskRead, type TaskReadOptions, type TaskRuntimeOptions, type TaskSnapshot, type TasksContext, type TaskToolOutcome, type TaskWaitAnyOptions, type TaskWaitAnyResult, type TaskWaitOptions, type TaskWaitResult } from "./types.ts";
|
|
3
3
|
/** Session-local supervision. Executors own their processes, items and output files. */
|
|
4
|
-
export declare class TaskRuntime implements TasksContext {
|
|
4
|
+
export declare class TaskRuntime implements TasksContext, TaskDeliveryLedger {
|
|
5
5
|
private readonly store;
|
|
6
6
|
private readonly executions;
|
|
7
7
|
private readonly scheduler;
|
|
@@ -13,7 +13,6 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
13
13
|
private readonly options;
|
|
14
14
|
private configuredEnabled;
|
|
15
15
|
private _closed;
|
|
16
|
-
private pauses;
|
|
17
16
|
constructor(options?: TaskRuntimeOptions);
|
|
18
17
|
get closed(): boolean;
|
|
19
18
|
get session(): TaskRuntimeOptions["session"];
|
|
@@ -28,6 +27,7 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
28
27
|
get enabled(): boolean;
|
|
29
28
|
setEnabled(enabled: boolean): void;
|
|
30
29
|
/** Foreground work is bounded by its caller; only background work, queued or running, holds a slot. */
|
|
30
|
+
private activeBackground;
|
|
31
31
|
private backgroundActive;
|
|
32
32
|
private limitError;
|
|
33
33
|
execute<T>(execution: TaskExecution<T>): Promise<TaskToolOutcome<T>>;
|
|
@@ -38,17 +38,18 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
38
38
|
list(): TaskSnapshot[];
|
|
39
39
|
private lookup;
|
|
40
40
|
get(id: string): TaskSnapshot;
|
|
41
|
-
read(id: string, options?:
|
|
42
|
-
mode?: "head" | "tail";
|
|
43
|
-
bytes?: number;
|
|
44
|
-
sinceBytes?: number;
|
|
45
|
-
}): Promise<TaskRead>;
|
|
41
|
+
read(id: string, options?: TaskReadOptions): Promise<TaskRead>;
|
|
46
42
|
private resultText;
|
|
47
43
|
/** One event-driven waiter can observe a whole waitAny cohort without per-task timers. */
|
|
48
44
|
private waitForRecords;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
/**
|
|
46
|
+
* One observation: hold delivery for the observed records, wait, read, then register the
|
|
47
|
+
* receipt with the host, and only then release. Nothing the caller does between those steps
|
|
48
|
+
* can leak a settled result into an automatic notification or lose it.
|
|
49
|
+
*/
|
|
50
|
+
private observe;
|
|
51
|
+
wait(id: string, options?: TaskWaitOptions): Promise<TaskWaitResult>;
|
|
52
|
+
waitAny(options?: TaskWaitAnyOptions): Promise<TaskWaitAnyResult>;
|
|
52
53
|
kill(id: string): boolean;
|
|
53
54
|
private cancel;
|
|
54
55
|
subscribe(listener: () => void): () => void;
|
|
@@ -56,11 +57,10 @@ export declare class TaskRuntime implements TasksContext {
|
|
|
56
57
|
* Retention protects snapshots and logs only. Delivery has its own explicit hold.
|
|
57
58
|
*/
|
|
58
59
|
retain(id: string): () => void;
|
|
60
|
+
private pin;
|
|
59
61
|
holdDelivery(id: string): () => void;
|
|
60
|
-
|
|
62
|
+
private holdRecord;
|
|
61
63
|
pendingNotifications(): TaskSnapshot[];
|
|
62
|
-
/** Only explicit result-delivery holds delay an automatic completion. */
|
|
63
|
-
private candidate;
|
|
64
64
|
claimNotification(id: string): boolean;
|
|
65
65
|
markDelivered(id: string): void;
|
|
66
66
|
releaseNotification(id: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAiBrE,OAAO,EAGN,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAElB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,YA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AAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,YAAY,EAAE;IAOnE;;;OAGG;IACG,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;YAW1D,KAAK;IAgBnB,OAAO,CAAC,IAAI;CAWZ"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { finiteLimit } from "../../utils/number.js";
|
|
3
|
+
import { Execution } from "./execution.js";
|
|
4
|
+
import { boundWaitMs, TASKS_WAIT_DEFAULT_MS } from "./limits.js";
|
|
5
|
+
import { boundFacts, boundInput, boundText, errorText, readOutputSlice, sliceText, TASK_LABEL_BYTES, TASK_TITLE_BYTES, } from "./output.js";
|
|
6
|
+
import { TaskRecord } from "./record.js";
|
|
5
7
|
import { TaskScheduler } from "./scheduler.js";
|
|
6
|
-
import {
|
|
8
|
+
import { TaskStore } from "./store.js";
|
|
7
9
|
import { TASK_BACKGROUND_REJECTION, TASK_KIND_PATTERN, TaskLookupError, } from "./types.js";
|
|
8
10
|
/** Session-local supervision. Executors own their processes, items and output files. */
|
|
9
11
|
export class TaskRuntime {
|
|
@@ -12,7 +14,6 @@ export class TaskRuntime {
|
|
|
12
14
|
this.scheduler = new TaskScheduler();
|
|
13
15
|
this.listeners = new Set();
|
|
14
16
|
this._closed = false;
|
|
15
|
-
this.pauses = 0;
|
|
16
17
|
this.options = options;
|
|
17
18
|
this.configuredEnabled = options.enabled ?? false;
|
|
18
19
|
this.maxBackground = Math.max(1, finiteLimit(options.maxBackground, 8, 128));
|
|
@@ -59,12 +60,11 @@ export class TaskRuntime {
|
|
|
59
60
|
this.emit();
|
|
60
61
|
}
|
|
61
62
|
/** Foreground work is bounded by its caller; only background work, queued or running, holds a slot. */
|
|
63
|
+
activeBackground() {
|
|
64
|
+
return this.store.unsettled().filter((record) => record.task.mode === "background");
|
|
65
|
+
}
|
|
62
66
|
backgroundActive() {
|
|
63
|
-
|
|
64
|
-
for (const record of this.store.records.values())
|
|
65
|
-
if (!record.settled && record.task.mode === "background")
|
|
66
|
-
count++;
|
|
67
|
-
return count;
|
|
67
|
+
return this.activeBackground().length;
|
|
68
68
|
}
|
|
69
69
|
limitError() {
|
|
70
70
|
return new Error(`Background task limit reached (${this.maxBackground}); stop or wait for a background task, or run in the foreground.`);
|
|
@@ -80,7 +80,7 @@ export class TaskRuntime {
|
|
|
80
80
|
throw new Error("Background execution is not available in this host");
|
|
81
81
|
if (this.backgroundActive() >= this.maxBackground)
|
|
82
82
|
throw this.limitError();
|
|
83
|
-
if (this.store.
|
|
83
|
+
if (this.store.retainedCount() >= this.maxRetained) {
|
|
84
84
|
throw new Error("Task history retention limit reached; deliver pending notifications or release pinned or claimed records");
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -108,17 +108,9 @@ export class TaskRuntime {
|
|
|
108
108
|
status: "queued",
|
|
109
109
|
startedAt: Date.now(),
|
|
110
110
|
};
|
|
111
|
-
const record =
|
|
112
|
-
task,
|
|
113
|
-
settled: false,
|
|
114
|
-
visible: true,
|
|
115
|
-
delivery: "none",
|
|
116
|
-
pins: 0,
|
|
117
|
-
deliveryHolds: 0,
|
|
118
|
-
waiters: new Set(),
|
|
119
|
-
};
|
|
111
|
+
const record = new TaskRecord(task);
|
|
120
112
|
const active = new Execution(this.host, record, execution);
|
|
121
|
-
this.store.
|
|
113
|
+
this.store.add(record);
|
|
122
114
|
this.executions.set(task.id, active);
|
|
123
115
|
this.scheduler.schedule(active);
|
|
124
116
|
// Queued background work returns at once; started work hands off after its own accept().
|
|
@@ -133,15 +125,15 @@ export class TaskRuntime {
|
|
|
133
125
|
detachForeground() {
|
|
134
126
|
if (!this.enabled)
|
|
135
127
|
return 0;
|
|
136
|
-
const eligible = [...this.
|
|
137
|
-
.filter((
|
|
128
|
+
const eligible = [...this.executions.values()]
|
|
129
|
+
.filter((execution) => execution.detachable)
|
|
138
130
|
.sort((left, right) => left.task.startedAt - right.task.startedAt);
|
|
139
131
|
if (!eligible.length)
|
|
140
132
|
return 0;
|
|
141
133
|
const free = this.maxBackground - this.backgroundActive();
|
|
142
134
|
if (free <= 0)
|
|
143
135
|
throw this.limitError();
|
|
144
|
-
const executions = eligible.slice(0, free)
|
|
136
|
+
const executions = eligible.slice(0, free);
|
|
145
137
|
for (const execution of executions)
|
|
146
138
|
execution.requestDetach();
|
|
147
139
|
for (const execution of executions)
|
|
@@ -166,26 +158,26 @@ export class TaskRuntime {
|
|
|
166
158
|
return true;
|
|
167
159
|
}
|
|
168
160
|
list() {
|
|
169
|
-
return
|
|
161
|
+
return this.store.visible().map((record) => record.snapshot());
|
|
170
162
|
}
|
|
171
163
|
lookup(id) {
|
|
172
|
-
const exact = this.store.
|
|
164
|
+
const exact = this.store.get(id);
|
|
173
165
|
if (exact)
|
|
174
166
|
return exact;
|
|
175
|
-
const matches =
|
|
167
|
+
const matches = this.store.match(id);
|
|
176
168
|
if (!id || matches.length !== 1) {
|
|
177
|
-
throw new TaskLookupError(matches.length > 1 ? "ambiguous" : "unknown", matches.map(
|
|
169
|
+
throw new TaskLookupError(matches.length > 1 ? "ambiguous" : "unknown", matches.map((record) => record.snapshot()));
|
|
178
170
|
}
|
|
179
171
|
return matches[0];
|
|
180
172
|
}
|
|
181
173
|
get(id) {
|
|
182
|
-
return
|
|
174
|
+
return this.lookup(id).snapshot();
|
|
183
175
|
}
|
|
184
176
|
async read(id, options = {}) {
|
|
185
177
|
const record = this.lookup(id);
|
|
186
178
|
const release = this.retain(record.task.id);
|
|
187
179
|
try {
|
|
188
|
-
const task =
|
|
180
|
+
const task = record.snapshot();
|
|
189
181
|
if (task.outputPath) {
|
|
190
182
|
try {
|
|
191
183
|
return { task, ...(await readOutputSlice(task.outputPath, options)) };
|
|
@@ -238,34 +230,76 @@ export class TaskRuntime {
|
|
|
238
230
|
record.waiters.add(wake);
|
|
239
231
|
signal?.addEventListener("abort", abort, { once: true });
|
|
240
232
|
interruptSignal?.addEventListener("abort", interrupt, { once: true });
|
|
241
|
-
timer = setTimeout(wake,
|
|
233
|
+
timer = setTimeout(wake, boundWaitMs(timeoutMs));
|
|
242
234
|
if (this.closed || interruptSignal?.aborted)
|
|
243
235
|
wake();
|
|
244
236
|
if (signal?.aborted)
|
|
245
237
|
abort();
|
|
246
238
|
});
|
|
247
239
|
}
|
|
248
|
-
/**
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
240
|
+
/**
|
|
241
|
+
* One observation: hold delivery for the observed records, wait, read, then register the
|
|
242
|
+
* receipt with the host, and only then release. Nothing the caller does between those steps
|
|
243
|
+
* can leak a settled result into an automatic notification or lose it.
|
|
244
|
+
*/
|
|
245
|
+
async observe(records, options,
|
|
246
|
+
/** Record to read when none settled; a cohort has none. */
|
|
247
|
+
fallback) {
|
|
248
|
+
const { signal } = options;
|
|
249
|
+
const releases = records.map((record) => this.holdRecord(record));
|
|
250
|
+
try {
|
|
251
|
+
const start = Date.now();
|
|
252
|
+
const interrupt = this.options.waits?.interruptSignal;
|
|
253
|
+
await this.waitForRecords(records, options.timeoutMs ?? TASKS_WAIT_DEFAULT_MS, signal, interrupt);
|
|
254
|
+
const waitedMs = Date.now() - start;
|
|
255
|
+
const settled = records
|
|
256
|
+
.filter((record) => record.settled)
|
|
257
|
+
.sort((left, right) => (left.task.endedAt ?? 0) - (right.task.endedAt ?? 0))[0];
|
|
258
|
+
const outcome = settled
|
|
259
|
+
? "settled"
|
|
260
|
+
: this.closed
|
|
261
|
+
? "closed"
|
|
262
|
+
: interrupt?.aborted
|
|
263
|
+
? "interrupted"
|
|
264
|
+
: "timed_out";
|
|
265
|
+
const running = records
|
|
266
|
+
.filter((record) => record.visible && !record.settled)
|
|
267
|
+
.map((record) => record.snapshot());
|
|
268
|
+
const observed = settled ?? fallback;
|
|
269
|
+
const read = options.read && observed && outcome !== "interrupted"
|
|
270
|
+
? await this.read(observed.task.id, options.read)
|
|
271
|
+
: undefined;
|
|
272
|
+
signal?.throwIfAborted();
|
|
273
|
+
if (settled && settled.task.mode === "background" && options.toolCallId)
|
|
274
|
+
this.options.waits?.bind(options.toolCallId, settled.task.id);
|
|
275
|
+
return { outcome, waitedMs, settled, running, read };
|
|
276
|
+
}
|
|
277
|
+
finally {
|
|
278
|
+
for (const release of releases)
|
|
279
|
+
release();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async wait(id, options = {}) {
|
|
283
|
+
if (options.signal?.aborted)
|
|
284
|
+
throw options.signal.reason ?? new Error("Wait aborted");
|
|
252
285
|
const record = this.lookup(id);
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
286
|
+
const { outcome, waitedMs, read } = await this.observe([record], options, record);
|
|
287
|
+
return { outcome, waitedMs, task: record.snapshot(), ...(read ? { read } : {}) };
|
|
288
|
+
}
|
|
289
|
+
async waitAny(options = {}) {
|
|
290
|
+
if (options.signal?.aborted)
|
|
291
|
+
throw options.signal.reason ?? new Error("Wait aborted");
|
|
292
|
+
const records = this.activeBackground().filter((record) => record.visible);
|
|
293
|
+
if (records.length === 0)
|
|
294
|
+
return { outcome: "no_tasks", waitedMs: 0, running: [] };
|
|
295
|
+
const { outcome, waitedMs, settled, running, read } = await this.observe(records, options);
|
|
296
|
+
return {
|
|
297
|
+
outcome,
|
|
298
|
+
waitedMs,
|
|
299
|
+
running,
|
|
300
|
+
...(settled ? { task: settled.snapshot() } : {}),
|
|
301
|
+
...(read ? { read } : {}),
|
|
302
|
+
};
|
|
269
303
|
}
|
|
270
304
|
kill(id) {
|
|
271
305
|
return this.cancel(this.lookup(id));
|
|
@@ -285,7 +319,9 @@ export class TaskRuntime {
|
|
|
285
319
|
* Retention protects snapshots and logs only. Delivery has its own explicit hold.
|
|
286
320
|
*/
|
|
287
321
|
retain(id) {
|
|
288
|
-
|
|
322
|
+
return this.pin(this.lookup(id));
|
|
323
|
+
}
|
|
324
|
+
pin(record) {
|
|
289
325
|
record.pins++;
|
|
290
326
|
let released = false;
|
|
291
327
|
return () => {
|
|
@@ -294,13 +330,16 @@ export class TaskRuntime {
|
|
|
294
330
|
released = true;
|
|
295
331
|
record.pins--;
|
|
296
332
|
this.store.trim();
|
|
297
|
-
|
|
333
|
+
// Listeners decide whether delivery may proceed; TaskDelivery owns pausing.
|
|
334
|
+
if (!this.closed && record.deliverable)
|
|
298
335
|
this.emit();
|
|
299
336
|
};
|
|
300
337
|
}
|
|
301
338
|
holdDelivery(id) {
|
|
302
|
-
|
|
303
|
-
|
|
339
|
+
return this.holdRecord(this.lookup(id));
|
|
340
|
+
}
|
|
341
|
+
holdRecord(record) {
|
|
342
|
+
const releasePin = this.pin(record);
|
|
304
343
|
record.deliveryHolds++;
|
|
305
344
|
let released = false;
|
|
306
345
|
return () => {
|
|
@@ -308,50 +347,27 @@ export class TaskRuntime {
|
|
|
308
347
|
return;
|
|
309
348
|
released = true;
|
|
310
349
|
record.deliveryHolds--;
|
|
311
|
-
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
pause() {
|
|
315
|
-
this.pauses++;
|
|
316
|
-
let resumed = false;
|
|
317
|
-
return () => {
|
|
318
|
-
if (resumed)
|
|
319
|
-
return;
|
|
320
|
-
resumed = true;
|
|
321
|
-
this.pauses--;
|
|
322
|
-
this.emit();
|
|
350
|
+
releasePin();
|
|
323
351
|
};
|
|
324
352
|
}
|
|
325
353
|
pendingNotifications() {
|
|
326
|
-
if (this.closed
|
|
354
|
+
if (this.closed)
|
|
327
355
|
return [];
|
|
328
|
-
return
|
|
329
|
-
}
|
|
330
|
-
/** Only explicit result-delivery holds delay an automatic completion. */
|
|
331
|
-
candidate(record) {
|
|
332
|
-
return record.visible && record.delivery === "pending" && record.waiters.size === 0 && record.deliveryHolds === 0;
|
|
356
|
+
return this.store.deliverable().map((record) => record.snapshot());
|
|
333
357
|
}
|
|
334
358
|
claimNotification(id) {
|
|
335
|
-
|
|
336
|
-
return false;
|
|
337
|
-
const record = this.store.records.get(id);
|
|
338
|
-
if (!record || !this.candidate(record))
|
|
339
|
-
return false;
|
|
340
|
-
record.delivery = "claimed";
|
|
341
|
-
return true;
|
|
359
|
+
return !this.closed && (this.store.get(id)?.claim() ?? false);
|
|
342
360
|
}
|
|
343
361
|
markDelivered(id) {
|
|
344
|
-
const record = this.store.
|
|
362
|
+
const record = this.store.get(id);
|
|
345
363
|
if (!record)
|
|
346
364
|
return;
|
|
347
|
-
record.
|
|
365
|
+
record.acknowledge();
|
|
348
366
|
this.store.trim();
|
|
349
367
|
}
|
|
350
368
|
releaseNotification(id) {
|
|
351
|
-
|
|
352
|
-
if (!record || record.delivery !== "claimed")
|
|
369
|
+
if (!this.store.get(id)?.unclaim())
|
|
353
370
|
return;
|
|
354
|
-
record.delivery = "pending";
|
|
355
371
|
this.store.trim();
|
|
356
372
|
this.emit();
|
|
357
373
|
}
|
|
@@ -360,7 +376,7 @@ export class TaskRuntime {
|
|
|
360
376
|
return;
|
|
361
377
|
this._closed = true;
|
|
362
378
|
this.listeners.clear();
|
|
363
|
-
for (const record of this.store.
|
|
379
|
+
for (const record of this.store.all()) {
|
|
364
380
|
this.executions.get(record.task.id)?.releaseParent();
|
|
365
381
|
this.cancel(record);
|
|
366
382
|
for (const waiter of [...record.waiters])
|
|
@@ -370,22 +386,24 @@ export class TaskRuntime {
|
|
|
370
386
|
}
|
|
371
387
|
async shutdown(graceMs = 2000) {
|
|
372
388
|
this.close();
|
|
373
|
-
await this.drain(
|
|
389
|
+
await this.drain(this.store.all(), graceMs);
|
|
374
390
|
}
|
|
375
391
|
/** Running tasks whose launch anchor is outside the branch made of `ancestors`. */
|
|
376
392
|
activeOutsideBranch(ancestors) {
|
|
377
|
-
return
|
|
378
|
-
.
|
|
379
|
-
.
|
|
393
|
+
return this.store
|
|
394
|
+
.unsettled()
|
|
395
|
+
.filter((record) => record.task.anchorId !== null && !ancestors.has(record.task.anchorId))
|
|
396
|
+
.map((record) => record.snapshot());
|
|
380
397
|
}
|
|
381
398
|
/**
|
|
382
399
|
* Hidden results stay pending: returning to their branch delivers them again.
|
|
383
400
|
* Restored history is already delivered.
|
|
384
401
|
*/
|
|
385
402
|
async cancelOutsideBranch(ancestors) {
|
|
386
|
-
|
|
403
|
+
const records = this.store.all();
|
|
404
|
+
for (const record of records)
|
|
387
405
|
record.visible = record.task.anchorId === null || ancestors.has(record.task.anchorId);
|
|
388
|
-
const outside =
|
|
406
|
+
const outside = records.filter((record) => !record.visible);
|
|
389
407
|
for (const record of outside)
|
|
390
408
|
this.cancel(record);
|
|
391
409
|
this.store.trim();
|
|
@@ -396,7 +414,7 @@ export class TaskRuntime {
|
|
|
396
414
|
let timer;
|
|
397
415
|
try {
|
|
398
416
|
await Promise.race([
|
|
399
|
-
Promise.all(records.map((record) => this.executions.get(record.task.id)?.done)).then(() =>
|
|
417
|
+
Promise.all(records.map((record) => this.executions.get(record.task.id)?.done)).then(() => this.store.cleanupsDone()),
|
|
400
418
|
new Promise((resolve) => {
|
|
401
419
|
timer = setTimeout(resolve, finiteLimit(graceMs, 2000, 60_000));
|
|
402
420
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAsB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACN,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,gBAAgB,GAChB,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CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CACzF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAChC;gBACD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAC7B,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;gBACjE,CAAC,CAAC;aACF,CAAC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACV,IAAI,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAEO,IAAI;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,MAAM;gBAAE,MAAM;YACvB,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,iDAAiD;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { Execution, type ExecutionHost, errorText } from \"./execution.ts\";\nimport { TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS } from \"./limits.ts\";\nimport {\n\tboundFacts,\n\tboundInput,\n\tboundText,\n\tfiniteLimit,\n\treadOutputSlice,\n\tsliceText,\n\tTASK_LABEL_BYTES,\n\tTASK_TITLE_BYTES,\n} from \"./output.ts\";\nimport { TaskScheduler } from \"./scheduler.ts\";\nimport { snapshotOf, type TaskRecord, TaskStore } from \"./store.ts\";\nimport {\n\tTASK_BACKGROUND_REJECTION,\n\tTASK_KIND_PATTERN,\n\ttype TaskExecution,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskRuntimeOptions,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskToolOutcome,\n} from \"./types.ts\";\n\n/** Session-local supervision. Executors own their processes, items and output files. */\nexport class TaskRuntime implements TasksContext {\n\tprivate readonly store: TaskStore;\n\tprivate readonly executions = new Map<string, Execution<unknown>>();\n\tprivate readonly scheduler = new TaskScheduler();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly host: ExecutionHost;\n\tprivate readonly maxBackground: number;\n\tprivate readonly maxHistory: number;\n\tprivate readonly maxRetained: number;\n\tprivate readonly options: TaskRuntimeOptions;\n\tprivate configuredEnabled: boolean;\n\tprivate _closed = false;\n\tprivate pauses = 0;\n\n\tconstructor(options: TaskRuntimeOptions = {}) {\n\t\tthis.options = options;\n\t\tthis.configuredEnabled = options.enabled ?? false;\n\t\tthis.maxBackground = Math.max(1, finiteLimit(options.maxBackground, 8, 128));\n\t\tthis.maxHistory = finiteLimit(options.maxHistory, 32, 1024);\n\t\t// Separate foreground and background histories, plus the protected-record allowance.\n\t\tthis.maxRetained = this.maxBackground + 2 * Math.max(1, this.maxHistory) + this.maxHistory;\n\t\tthis.store = new TaskStore(this.maxHistory, this.maxRetained, () => this.closed, options.onCleanupError);\n\t\tconst runtime = this;\n\t\tthis.host = {\n\t\t\tget closed() {\n\t\t\t\treturn runtime.closed;\n\t\t\t},\n\t\t\temit: () => this.emit(),\n\t\t\tsettle: (task, usage) => this.options.onSettled?.(task, usage),\n\t\t\treleased: (execution) => {\n\t\t\t\tthis.executions.delete(execution.task.id);\n\t\t\t\tthis.scheduler.release(execution);\n\t\t\t\tthis.store.trim();\n\t\t\t\tthis.emit();\n\t\t\t},\n\t\t};\n\t}\n\n\tget closed(): boolean {\n\t\treturn this._closed;\n\t}\n\n\tget session(): TaskRuntimeOptions[\"session\"] {\n\t\treturn this.options.session;\n\t}\n\n\t/**\n\t * Rehydrate terminal snapshots only, newest endedAt in each history (later input wins\n\t * ties). Existing runtime records win ID collisions. No execution, accounting,\n\t * notification, or deletion ownership is restored. Foreground records take their output\n\t * from the branch's tool results. The host supplies the current branch; closed services\n\t * ignore restoration.\n\t */\n\trestoreHistory(\n\t\trecords: readonly unknown[],\n\t\ttoolResults?: ReadonlyMap<string, AgentToolResult<unknown>[\"content\"]>,\n\t): void {\n\t\tthis.store.restoreHistory(records, toolResults);\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.configuredEnabled && !this.closed && this.options.backgroundAllowed !== false;\n\t}\n\n\tsetEnabled(enabled: boolean): void {\n\t\tthis.configuredEnabled = enabled;\n\t\tthis.emit();\n\t}\n\n\t/** Foreground work is bounded by its caller; only background work, queued or running, holds a slot. */\n\tprivate backgroundActive(): number {\n\t\tlet count = 0;\n\t\tfor (const record of this.store.records.values())\n\t\t\tif (!record.settled && record.task.mode === \"background\") count++;\n\t\treturn count;\n\t}\n\n\tprivate limitError(): Error {\n\t\treturn new Error(\n\t\t\t`Background task limit reached (${this.maxBackground}); stop or wait for a background task, or run in the foreground.`,\n\t\t);\n\t}\n\n\tasync execute<T>(execution: TaskExecution<T>): Promise<TaskToolOutcome<T>> {\n\t\t// Admission and registration happen synchronously, before invoking user code or awaiting anything.\n\t\tif (execution.background && this.options.backgroundAllowed === false) throw new Error(TASK_BACKGROUND_REJECTION);\n\t\tif (this.closed) throw new Error(\"Task service is closed\");\n\t\tif (execution.background) {\n\t\t\tif (!this.enabled) throw new Error(\"Background execution is not available in this host\");\n\t\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\t\tif (this.store.records.size + this.store.cleanups.size >= this.maxRetained) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Task history retention limit reached; deliver pending notifications or release pinned or claimed records\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (execution.signal?.aborted) throw execution.signal.reason ?? new Error(\"Execution aborted\");\n\t\tif (!TASK_KIND_PATTERN.test(execution.kind)) throw new Error(\"Invalid task source\");\n\t\tconst concurrency = execution.concurrency;\n\t\tif (concurrency && (!concurrency.key || !Number.isSafeInteger(concurrency.limit) || concurrency.limit < 1))\n\t\t\tthrow new Error(\"Invalid task concurrency\");\n\t\tconst anchorId = this.options.anchor?.() ?? null;\n\t\tif (anchorId !== null && Buffer.byteLength(anchorId) > 8192) throw new Error(\"Task branch anchor is too large\");\n\t\tconst task: TaskSnapshot = {\n\t\t\tid: `${execution.kind}-${randomUUID()}`,\n\t\t\tkind: execution.kind,\n\t\t\tlabel: boundText(execution.label ?? execution.kind, TASK_LABEL_BYTES),\n\t\t\ttitle: boundText(execution.title, TASK_TITLE_BYTES),\n\t\t\toutput: execution.output ?? \"log\",\n\t\t\t...(execution.input ? { input: boundInput(execution.input) } : {}),\n\t\t\t...(execution.facts?.length ? { facts: boundFacts(execution.facts) } : {}),\n\t\t\ttoolCallId: boundText(execution.toolCallId, 512),\n\t\t\tanchorId,\n\t\t\tmode: execution.background ? \"background\" : \"foreground\",\n\t\t\tstatus: \"queued\",\n\t\t\tstartedAt: Date.now(),\n\t\t};\n\t\tconst record: TaskRecord = {\n\t\t\ttask,\n\t\t\tsettled: false,\n\t\t\tvisible: true,\n\t\t\tdelivery: \"none\",\n\t\t\tpins: 0,\n\t\t\tdeliveryHolds: 0,\n\t\t\twaiters: new Set(),\n\t\t};\n\t\tconst active = new Execution(this.host, record, execution);\n\t\tthis.store.records.set(task.id, record);\n\t\tthis.executions.set(task.id, active as Execution<unknown>);\n\t\tthis.scheduler.schedule(active);\n\t\t// Queued background work returns at once; started work hands off after its own accept().\n\t\tif (active.queued) active.handoff();\n\t\tthis.emit();\n\t\treturn active.caller;\n\t}\n\n\tprivate detachable(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.detachable ?? false;\n\t}\n\n\tdetachForeground(): number {\n\t\tif (!this.enabled) return 0;\n\t\tconst eligible = [...this.store.records.values()]\n\t\t\t.filter((record) => this.detachable(record))\n\t\t\t.sort((left, right) => left.task.startedAt - right.task.startedAt);\n\t\tif (!eligible.length) return 0;\n\t\tconst free = this.maxBackground - this.backgroundActive();\n\t\tif (free <= 0) throw this.limitError();\n\t\tconst executions = eligible.slice(0, free).map((record) => this.executions.get(record.task.id)!);\n\t\tfor (const execution of executions) execution.requestDetach();\n\t\tfor (const execution of executions) execution.completeDetach();\n\t\tthis.emit();\n\t\treturn executions.length;\n\t}\n\n\tcanDetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\treturn this.enabled && this.backgroundActive() < this.maxBackground && this.detachable(record);\n\t}\n\n\tdetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\tif (!this.enabled || !this.detachable(record)) return false;\n\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\tconst execution = this.executions.get(record.task.id)!;\n\t\texecution.requestDetach();\n\t\texecution.completeDetach();\n\t\tthis.emit();\n\t\treturn true;\n\t}\n\n\tlist(): TaskSnapshot[] {\n\t\treturn [...this.store.records.values()].filter((record) => record.visible).map(snapshotOf);\n\t}\n\n\tprivate lookup(id: string): TaskRecord {\n\t\tconst exact = this.store.records.get(id);\n\t\tif (exact) return exact;\n\t\tconst matches = [...this.store.records.values()].filter(\n\t\t\t({ task }) => task.id.startsWith(id) || task.id.slice(task.kind.length + 1).startsWith(id),\n\t\t);\n\t\tif (!id || matches.length !== 1) {\n\t\t\tthrow new TaskLookupError(matches.length > 1 ? \"ambiguous\" : \"unknown\", matches.map(snapshotOf));\n\t\t}\n\t\treturn matches[0]!;\n\t}\n\n\tget(id: string): TaskSnapshot {\n\t\treturn snapshotOf(this.lookup(id));\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\toptions: { mode?: \"head\" | \"tail\"; bytes?: number; sinceBytes?: number } = {},\n\t): Promise<TaskRead> {\n\t\tconst record = this.lookup(id);\n\t\tconst release = this.retain(record.task.id);\n\t\ttry {\n\t\t\tconst task = snapshotOf(record);\n\t\t\tif (task.outputPath) {\n\t\t\t\ttry {\n\t\t\t\t\treturn { task, ...(await readOutputSlice(task.outputPath, options)) };\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttask,\n\t\t\t\t\t\treadError: boundText(`Output could not be read: ${errorText(error)}`, 4096),\n\t\t\t\t\t\t...sliceText(this.resultText(task), options),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { task, readError: record.readError, ...sliceText(this.resultText(task), options) };\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t}\n\n\tprivate resultText(task: TaskSnapshot): string {\n\t\treturn task.result?.text || task.error || \"No output yet.\";\n\t}\n\n\t/** One event-driven waiter can observe a whole waitAny cohort without per-task timers. */\n\tprivate waitForRecords(\n\t\trecords: readonly TaskRecord[],\n\t\ttimeoutMs: number,\n\t\tsignal?: AbortSignal,\n\t\tinterruptSignal?: AbortSignal,\n\t): Promise<void> {\n\t\tif (records.some((record) => record.settled) || interruptSignal?.aborted) return Promise.resolve();\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tlet finished = false;\n\t\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t\tconst complete = (aborted = false) => {\n\t\t\t\tif (finished) return;\n\t\t\t\tfinished = true;\n\t\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\t\tsignal?.removeEventListener(\"abort\", abort);\n\t\t\t\tinterruptSignal?.removeEventListener(\"abort\", interrupt);\n\t\t\t\tfor (const record of records) record.waiters.delete(wake);\n\t\t\t\tif (aborted) reject(signal?.reason ?? new Error(\"Wait aborted\"));\n\t\t\t\telse resolve();\n\t\t\t\tthis.store.trim();\n\t\t\t\tthis.emit();\n\t\t\t};\n\t\t\tconst wake = () => complete();\n\t\t\tconst abort = () => complete(true);\n\t\t\tconst interrupt = () => complete();\n\t\t\tfor (const record of records) record.waiters.add(wake);\n\t\t\tsignal?.addEventListener(\"abort\", abort, { once: true });\n\t\t\tinterruptSignal?.addEventListener(\"abort\", interrupt, { once: true });\n\t\t\ttimer = setTimeout(wake, finiteLimit(timeoutMs, TASKS_WAIT_DEFAULT_MS, TASKS_WAIT_MAX_MS));\n\t\t\tif (this.closed || interruptSignal?.aborted) wake();\n\t\t\tif (signal?.aborted) abort();\n\t\t});\n\t}\n\n\t/** Observe completion without consuming delivery; the host acknowledges only persisted tool results. */\n\tasync wait(\n\t\tid: string,\n\t\ttimeoutMs = TASKS_WAIT_DEFAULT_MS,\n\t\tsignal?: AbortSignal,\n\t\tinterruptSignal?: AbortSignal,\n\t): Promise<TaskSnapshot> {\n\t\tif (signal?.aborted) throw signal.reason ?? new Error(\"Wait aborted\");\n\t\tconst record = this.lookup(id);\n\t\tif (record.settled) return snapshotOf(record);\n\t\tawait this.waitForRecords([record], timeoutMs, signal, interruptSignal);\n\t\treturn snapshotOf(record);\n\t}\n\n\tasync waitAny(\n\t\ttimeoutMs = TASKS_WAIT_DEFAULT_MS,\n\t\tsignal?: AbortSignal,\n\t\tinterruptSignal?: AbortSignal,\n\t): Promise<TaskSnapshot | undefined> {\n\t\tif (signal?.aborted) throw signal.reason ?? new Error(\"Wait aborted\");\n\t\tconst records = [...this.store.records.values()].filter(\n\t\t\t(record) => record.visible && record.task.mode === \"background\" && !record.settled,\n\t\t);\n\t\tif (records.length === 0 || interruptSignal?.aborted) return undefined;\n\t\tawait this.waitForRecords(records, timeoutMs, signal, interruptSignal);\n\t\tconst settled = records\n\t\t\t.filter((record) => record.settled)\n\t\t\t.sort((left, right) => (left.task.endedAt ?? 0) - (right.task.endedAt ?? 0))[0];\n\t\treturn settled ? snapshotOf(settled) : undefined;\n\t}\n\n\tkill(id: string): boolean {\n\t\treturn this.cancel(this.lookup(id));\n\t}\n\n\tprivate cancel(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.cancel() ?? false;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tif (this.closed) return () => {};\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/**\n\t * Retention protects snapshots and logs only. Delivery has its own explicit hold.\n\t */\n\tretain(id: string): () => void {\n\t\tconst record = this.lookup(id);\n\t\trecord.pins++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\trecord.pins--;\n\t\t\tthis.store.trim();\n\t\t\tif (!this.closed && this.pauses === 0 && this.candidate(record)) this.emit();\n\t\t};\n\t}\n\n\tholdDelivery(id: string): () => void {\n\t\tconst record = this.lookup(id);\n\t\tconst releaseRetention = this.retain(id);\n\t\trecord.deliveryHolds++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\trecord.deliveryHolds--;\n\t\t\treleaseRetention();\n\t\t};\n\t}\n\n\tpause(): () => void {\n\t\tthis.pauses++;\n\t\tlet resumed = false;\n\t\treturn () => {\n\t\t\tif (resumed) return;\n\t\t\tresumed = true;\n\t\t\tthis.pauses--;\n\t\t\tthis.emit();\n\t\t};\n\t}\n\n\tpendingNotifications(): TaskSnapshot[] {\n\t\tif (this.closed || this.pauses > 0) return [];\n\t\treturn [...this.store.records.values()].filter((record) => this.candidate(record)).map(snapshotOf);\n\t}\n\n\t/** Only explicit result-delivery holds delay an automatic completion. */\n\tprivate candidate(record: TaskRecord): boolean {\n\t\treturn record.visible && record.delivery === \"pending\" && record.waiters.size === 0 && record.deliveryHolds === 0;\n\t}\n\n\tclaimNotification(id: string): boolean {\n\t\tif (this.closed || this.pauses > 0) return false;\n\t\tconst record = this.store.records.get(id);\n\t\tif (!record || !this.candidate(record)) return false;\n\t\trecord.delivery = \"claimed\";\n\t\treturn true;\n\t}\n\n\tmarkDelivered(id: string): void {\n\t\tconst record = this.store.records.get(id);\n\t\tif (!record) return;\n\t\trecord.delivery = \"delivered\";\n\t\tthis.store.trim();\n\t}\n\n\treleaseNotification(id: string): void {\n\t\tconst record = this.store.records.get(id);\n\t\tif (!record || record.delivery !== \"claimed\") return;\n\t\trecord.delivery = \"pending\";\n\t\tthis.store.trim();\n\t\tthis.emit();\n\t}\n\n\tclose(): void {\n\t\tif (this.closed) return;\n\t\tthis._closed = true;\n\t\tthis.listeners.clear();\n\t\tfor (const record of this.store.records.values()) {\n\t\t\tthis.executions.get(record.task.id)?.releaseParent();\n\t\t\tthis.cancel(record);\n\t\t\tfor (const waiter of [...record.waiters]) waiter();\n\t\t}\n\t\tthis.store.trim();\n\t}\n\n\tasync shutdown(graceMs = 2000): Promise<void> {\n\t\tthis.close();\n\t\tawait this.drain([...this.store.records.values()], graceMs);\n\t}\n\n\t/** Running tasks whose launch anchor is outside the branch made of `ancestors`. */\n\tactiveOutsideBranch(ancestors: ReadonlySet<string>): TaskSnapshot[] {\n\t\treturn [...this.store.records.values()]\n\t\t\t.filter((record) => !record.settled && record.task.anchorId !== null && !ancestors.has(record.task.anchorId))\n\t\t\t.map(snapshotOf);\n\t}\n\n\t/**\n\t * Hidden results stay pending: returning to their branch delivers them again.\n\t * Restored history is already delivered.\n\t */\n\tasync cancelOutsideBranch(ancestors: ReadonlySet<string>): Promise<void> {\n\t\tfor (const record of this.store.records.values())\n\t\t\trecord.visible = record.task.anchorId === null || ancestors.has(record.task.anchorId);\n\t\tconst outside = [...this.store.records.values()].filter((record) => !record.visible);\n\t\tfor (const record of outside) this.cancel(record);\n\t\tthis.store.trim();\n\t\tthis.emit();\n\t\tawait this.drain(outside, 2000);\n\t}\n\n\tprivate async drain(records: TaskRecord[], graceMs: number): Promise<void> {\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tPromise.all(records.map((record) => this.executions.get(record.task.id)?.done)).then(() =>\n\t\t\t\t\tPromise.all(this.store.cleanups),\n\t\t\t\t),\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(resolve, finiteLimit(graceMs, 2000, 60_000));\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t}\n\t}\n\n\tprivate emit(): void {\n\t\tif (this.closed) return;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\tif (this.closed) break;\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t/* Observers do not own execution or delivery. */\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/core/tasks/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAsB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EACN,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACN,yBAAyB,EACzB,iBAAiB,EAGjB,eAAe,GAYf,MAAM,YAAY,CAAC;AAEpB,wFAAwF;AACxF,MAAM,OAAO,WAAW;IAavB,YAAY,UAA8B,EAAE;QAX3B,eAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;QACnD,cAAS,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,cAAS,GAAG,IAAI,GAAG,EAAc,CAAC;QAO3C,YAAO,GAAG,KAAK,CAAC;QAGvB,IAAI,CAAC,OAAO,GAAG,OAAO,CA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,CAAC,IAAI,CAAC,GAAG,EAAE,CACzF,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,CACzB;gBACD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;oBAC7B,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;gBACjE,CAAC,CAAC;aACF,CAAC,CAAC;QACJ,CAAC;gBAAS,CAAC;YACV,IAAI,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAEO,IAAI;QACX,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QACxB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,IAAI,IAAI,CAAC,MAAM;gBAAE,MAAM;YACvB,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,iDAAiD;YAClD,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport { finiteLimit } from \"../../utils/number.ts\";\nimport { Execution, type ExecutionHost } from \"./execution.ts\";\nimport { boundWaitMs, TASKS_WAIT_DEFAULT_MS } from \"./limits.ts\";\nimport {\n\tboundFacts,\n\tboundInput,\n\tboundText,\n\terrorText,\n\treadOutputSlice,\n\tsliceText,\n\tTASK_LABEL_BYTES,\n\tTASK_TITLE_BYTES,\n} from \"./output.ts\";\nimport { TaskRecord } from \"./record.ts\";\nimport { TaskScheduler } from \"./scheduler.ts\";\nimport { TaskStore } from \"./store.ts\";\nimport {\n\tTASK_BACKGROUND_REJECTION,\n\tTASK_KIND_PATTERN,\n\ttype TaskDeliveryLedger,\n\ttype TaskExecution,\n\tTaskLookupError,\n\ttype TaskRead,\n\ttype TaskReadOptions,\n\ttype TaskRuntimeOptions,\n\ttype TaskSnapshot,\n\ttype TasksContext,\n\ttype TaskToolOutcome,\n\ttype TaskWaitAnyOptions,\n\ttype TaskWaitAnyResult,\n\ttype TaskWaitOptions,\n\ttype TaskWaitOutcome,\n\ttype TaskWaitResult,\n} from \"./types.ts\";\n\n/** Session-local supervision. Executors own their processes, items and output files. */\nexport class TaskRuntime implements TasksContext, TaskDeliveryLedger {\n\tprivate readonly store: TaskStore;\n\tprivate readonly executions = new Map<string, Execution<unknown>>();\n\tprivate readonly scheduler = new TaskScheduler();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly host: ExecutionHost;\n\tprivate readonly maxBackground: number;\n\tprivate readonly maxHistory: number;\n\tprivate readonly maxRetained: number;\n\tprivate readonly options: TaskRuntimeOptions;\n\tprivate configuredEnabled: boolean;\n\tprivate _closed = false;\n\n\tconstructor(options: TaskRuntimeOptions = {}) {\n\t\tthis.options = options;\n\t\tthis.configuredEnabled = options.enabled ?? false;\n\t\tthis.maxBackground = Math.max(1, finiteLimit(options.maxBackground, 8, 128));\n\t\tthis.maxHistory = finiteLimit(options.maxHistory, 32, 1024);\n\t\t// Separate foreground and background histories, plus the protected-record allowance.\n\t\tthis.maxRetained = this.maxBackground + 2 * Math.max(1, this.maxHistory) + this.maxHistory;\n\t\tthis.store = new TaskStore(this.maxHistory, this.maxRetained, () => this.closed, options.onCleanupError);\n\t\tconst runtime = this;\n\t\tthis.host = {\n\t\t\tget closed() {\n\t\t\t\treturn runtime.closed;\n\t\t\t},\n\t\t\temit: () => this.emit(),\n\t\t\tsettle: (task, usage) => this.options.onSettled?.(task, usage),\n\t\t\treleased: (execution) => {\n\t\t\t\tthis.executions.delete(execution.task.id);\n\t\t\t\tthis.scheduler.release(execution);\n\t\t\t\tthis.store.trim();\n\t\t\t\tthis.emit();\n\t\t\t},\n\t\t};\n\t}\n\n\tget closed(): boolean {\n\t\treturn this._closed;\n\t}\n\n\tget session(): TaskRuntimeOptions[\"session\"] {\n\t\treturn this.options.session;\n\t}\n\n\t/**\n\t * Rehydrate terminal snapshots only, newest endedAt in each history (later input wins\n\t * ties). Existing runtime records win ID collisions. No execution, accounting,\n\t * notification, or deletion ownership is restored. Foreground records take their output\n\t * from the branch's tool results. The host supplies the current branch; closed services\n\t * ignore restoration.\n\t */\n\trestoreHistory(\n\t\trecords: readonly unknown[],\n\t\ttoolResults?: ReadonlyMap<string, AgentToolResult<unknown>[\"content\"]>,\n\t): void {\n\t\tthis.store.restoreHistory(records, toolResults);\n\t}\n\n\tget enabled(): boolean {\n\t\treturn this.configuredEnabled && !this.closed && this.options.backgroundAllowed !== false;\n\t}\n\n\tsetEnabled(enabled: boolean): void {\n\t\tthis.configuredEnabled = enabled;\n\t\tthis.emit();\n\t}\n\n\t/** Foreground work is bounded by its caller; only background work, queued or running, holds a slot. */\n\tprivate activeBackground(): TaskRecord[] {\n\t\treturn this.store.unsettled().filter((record) => record.task.mode === \"background\");\n\t}\n\n\tprivate backgroundActive(): number {\n\t\treturn this.activeBackground().length;\n\t}\n\n\tprivate limitError(): Error {\n\t\treturn new Error(\n\t\t\t`Background task limit reached (${this.maxBackground}); stop or wait for a background task, or run in the foreground.`,\n\t\t);\n\t}\n\n\tasync execute<T>(execution: TaskExecution<T>): Promise<TaskToolOutcome<T>> {\n\t\t// Admission and registration happen synchronously, before invoking user code or awaiting anything.\n\t\tif (execution.background && this.options.backgroundAllowed === false) throw new Error(TASK_BACKGROUND_REJECTION);\n\t\tif (this.closed) throw new Error(\"Task service is closed\");\n\t\tif (execution.background) {\n\t\t\tif (!this.enabled) throw new Error(\"Background execution is not available in this host\");\n\t\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\t\tif (this.store.retainedCount() >= this.maxRetained) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Task history retention limit reached; deliver pending notifications or release pinned or claimed records\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (execution.signal?.aborted) throw execution.signal.reason ?? new Error(\"Execution aborted\");\n\t\tif (!TASK_KIND_PATTERN.test(execution.kind)) throw new Error(\"Invalid task source\");\n\t\tconst concurrency = execution.concurrency;\n\t\tif (concurrency && (!concurrency.key || !Number.isSafeInteger(concurrency.limit) || concurrency.limit < 1))\n\t\t\tthrow new Error(\"Invalid task concurrency\");\n\t\tconst anchorId = this.options.anchor?.() ?? null;\n\t\tif (anchorId !== null && Buffer.byteLength(anchorId) > 8192) throw new Error(\"Task branch anchor is too large\");\n\t\tconst task: TaskSnapshot = {\n\t\t\tid: `${execution.kind}-${randomUUID()}`,\n\t\t\tkind: execution.kind,\n\t\t\tlabel: boundText(execution.label ?? execution.kind, TASK_LABEL_BYTES),\n\t\t\ttitle: boundText(execution.title, TASK_TITLE_BYTES),\n\t\t\toutput: execution.output ?? \"log\",\n\t\t\t...(execution.input ? { input: boundInput(execution.input) } : {}),\n\t\t\t...(execution.facts?.length ? { facts: boundFacts(execution.facts) } : {}),\n\t\t\ttoolCallId: boundText(execution.toolCallId, 512),\n\t\t\tanchorId,\n\t\t\tmode: execution.background ? \"background\" : \"foreground\",\n\t\t\tstatus: \"queued\",\n\t\t\tstartedAt: Date.now(),\n\t\t};\n\t\tconst record = new TaskRecord(task);\n\t\tconst active = new Execution(this.host, record, execution);\n\t\tthis.store.add(record);\n\t\tthis.executions.set(task.id, active as Execution<unknown>);\n\t\tthis.scheduler.schedule(active);\n\t\t// Queued background work returns at once; started work hands off after its own accept().\n\t\tif (active.queued) active.handoff();\n\t\tthis.emit();\n\t\treturn active.caller;\n\t}\n\n\tprivate detachable(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.detachable ?? false;\n\t}\n\n\tdetachForeground(): number {\n\t\tif (!this.enabled) return 0;\n\t\tconst eligible = [...this.executions.values()]\n\t\t\t.filter((execution) => execution.detachable)\n\t\t\t.sort((left, right) => left.task.startedAt - right.task.startedAt);\n\t\tif (!eligible.length) return 0;\n\t\tconst free = this.maxBackground - this.backgroundActive();\n\t\tif (free <= 0) throw this.limitError();\n\t\tconst executions = eligible.slice(0, free);\n\t\tfor (const execution of executions) execution.requestDetach();\n\t\tfor (const execution of executions) execution.completeDetach();\n\t\tthis.emit();\n\t\treturn executions.length;\n\t}\n\n\tcanDetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\treturn this.enabled && this.backgroundActive() < this.maxBackground && this.detachable(record);\n\t}\n\n\tdetach(id: string): boolean {\n\t\tconst record = this.lookup(id);\n\t\tif (!this.enabled || !this.detachable(record)) return false;\n\t\tif (this.backgroundActive() >= this.maxBackground) throw this.limitError();\n\t\tconst execution = this.executions.get(record.task.id)!;\n\t\texecution.requestDetach();\n\t\texecution.completeDetach();\n\t\tthis.emit();\n\t\treturn true;\n\t}\n\n\tlist(): TaskSnapshot[] {\n\t\treturn this.store.visible().map((record) => record.snapshot());\n\t}\n\n\tprivate lookup(id: string): TaskRecord {\n\t\tconst exact = this.store.get(id);\n\t\tif (exact) return exact;\n\t\tconst matches = this.store.match(id);\n\t\tif (!id || matches.length !== 1) {\n\t\t\tthrow new TaskLookupError(\n\t\t\t\tmatches.length > 1 ? \"ambiguous\" : \"unknown\",\n\t\t\t\tmatches.map((record) => record.snapshot()),\n\t\t\t);\n\t\t}\n\t\treturn matches[0]!;\n\t}\n\n\tget(id: string): TaskSnapshot {\n\t\treturn this.lookup(id).snapshot();\n\t}\n\n\tasync read(id: string, options: TaskReadOptions = {}): Promise<TaskRead> {\n\t\tconst record = this.lookup(id);\n\t\tconst release = this.retain(record.task.id);\n\t\ttry {\n\t\t\tconst task = record.snapshot();\n\t\t\tif (task.outputPath) {\n\t\t\t\ttry {\n\t\t\t\t\treturn { task, ...(await readOutputSlice(task.outputPath, options)) };\n\t\t\t\t} catch (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\ttask,\n\t\t\t\t\t\treadError: boundText(`Output could not be read: ${errorText(error)}`, 4096),\n\t\t\t\t\t\t...sliceText(this.resultText(task), options),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { task, readError: record.readError, ...sliceText(this.resultText(task), options) };\n\t\t} finally {\n\t\t\trelease();\n\t\t}\n\t}\n\n\tprivate resultText(task: TaskSnapshot): string {\n\t\treturn task.result?.text || task.error || \"No output yet.\";\n\t}\n\n\t/** One event-driven waiter can observe a whole waitAny cohort without per-task timers. */\n\tprivate waitForRecords(\n\t\trecords: readonly TaskRecord[],\n\t\ttimeoutMs: number,\n\t\tsignal?: AbortSignal,\n\t\tinterruptSignal?: AbortSignal,\n\t): Promise<void> {\n\t\tif (records.some((record) => record.settled) || interruptSignal?.aborted) return Promise.resolve();\n\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\tlet finished = false;\n\t\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\t\tconst complete = (aborted = false) => {\n\t\t\t\tif (finished) return;\n\t\t\t\tfinished = true;\n\t\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t\t\tsignal?.removeEventListener(\"abort\", abort);\n\t\t\t\tinterruptSignal?.removeEventListener(\"abort\", interrupt);\n\t\t\t\tfor (const record of records) record.waiters.delete(wake);\n\t\t\t\tif (aborted) reject(signal?.reason ?? new Error(\"Wait aborted\"));\n\t\t\t\telse resolve();\n\t\t\t\tthis.store.trim();\n\t\t\t\tthis.emit();\n\t\t\t};\n\t\t\tconst wake = () => complete();\n\t\t\tconst abort = () => complete(true);\n\t\t\tconst interrupt = () => complete();\n\t\t\tfor (const record of records) record.waiters.add(wake);\n\t\t\tsignal?.addEventListener(\"abort\", abort, { once: true });\n\t\t\tinterruptSignal?.addEventListener(\"abort\", interrupt, { once: true });\n\t\t\ttimer = setTimeout(wake, boundWaitMs(timeoutMs));\n\t\t\tif (this.closed || interruptSignal?.aborted) wake();\n\t\t\tif (signal?.aborted) abort();\n\t\t});\n\t}\n\n\t/**\n\t * One observation: hold delivery for the observed records, wait, read, then register the\n\t * receipt with the host, and only then release. Nothing the caller does between those steps\n\t * can leak a settled result into an automatic notification or lose it.\n\t */\n\tprivate async observe(\n\t\trecords: readonly TaskRecord[],\n\t\toptions: TaskWaitOptions,\n\t\t/** Record to read when none settled; a cohort has none. */\n\t\tfallback?: TaskRecord,\n\t): Promise<{\n\t\toutcome: TaskWaitOutcome;\n\t\twaitedMs: number;\n\t\tsettled?: TaskRecord;\n\t\trunning: TaskSnapshot[];\n\t\tread?: TaskRead;\n\t}> {\n\t\tconst { signal } = options;\n\t\tconst releases = records.map((record) => this.holdRecord(record));\n\t\ttry {\n\t\t\tconst start = Date.now();\n\t\t\tconst interrupt = this.options.waits?.interruptSignal;\n\t\t\tawait this.waitForRecords(records, options.timeoutMs ?? TASKS_WAIT_DEFAULT_MS, signal, interrupt);\n\t\t\tconst waitedMs = Date.now() - start;\n\t\t\tconst settled = records\n\t\t\t\t.filter((record) => record.settled)\n\t\t\t\t.sort((left, right) => (left.task.endedAt ?? 0) - (right.task.endedAt ?? 0))[0];\n\t\t\tconst outcome: TaskWaitOutcome = settled\n\t\t\t\t? \"settled\"\n\t\t\t\t: this.closed\n\t\t\t\t\t? \"closed\"\n\t\t\t\t\t: interrupt?.aborted\n\t\t\t\t\t\t? \"interrupted\"\n\t\t\t\t\t\t: \"timed_out\";\n\t\t\tconst running = records\n\t\t\t\t.filter((record) => record.visible && !record.settled)\n\t\t\t\t.map((record) => record.snapshot());\n\t\t\tconst observed = settled ?? fallback;\n\t\t\tconst read =\n\t\t\t\toptions.read && observed && outcome !== \"interrupted\"\n\t\t\t\t\t? await this.read(observed.task.id, options.read)\n\t\t\t\t\t: undefined;\n\t\t\tsignal?.throwIfAborted();\n\t\t\tif (settled && settled.task.mode === \"background\" && options.toolCallId)\n\t\t\t\tthis.options.waits?.bind(options.toolCallId, settled.task.id);\n\t\t\treturn { outcome, waitedMs, settled, running, read };\n\t\t} finally {\n\t\t\tfor (const release of releases) release();\n\t\t}\n\t}\n\n\tasync wait(id: string, options: TaskWaitOptions = {}): Promise<TaskWaitResult> {\n\t\tif (options.signal?.aborted) throw options.signal.reason ?? new Error(\"Wait aborted\");\n\t\tconst record = this.lookup(id);\n\t\tconst { outcome, waitedMs, read } = await this.observe([record], options, record);\n\t\treturn { outcome, waitedMs, task: record.snapshot(), ...(read ? { read } : {}) };\n\t}\n\n\tasync waitAny(options: TaskWaitAnyOptions = {}): Promise<TaskWaitAnyResult> {\n\t\tif (options.signal?.aborted) throw options.signal.reason ?? new Error(\"Wait aborted\");\n\t\tconst records = this.activeBackground().filter((record) => record.visible);\n\t\tif (records.length === 0) return { outcome: \"no_tasks\", waitedMs: 0, running: [] };\n\t\tconst { outcome, waitedMs, settled, running, read } = await this.observe(records, options);\n\t\treturn {\n\t\t\toutcome,\n\t\t\twaitedMs,\n\t\t\trunning,\n\t\t\t...(settled ? { task: settled.snapshot() } : {}),\n\t\t\t...(read ? { read } : {}),\n\t\t};\n\t}\n\n\tkill(id: string): boolean {\n\t\treturn this.cancel(this.lookup(id));\n\t}\n\n\tprivate cancel(record: TaskRecord): boolean {\n\t\treturn this.executions.get(record.task.id)?.cancel() ?? false;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tif (this.closed) return () => {};\n\t\tthis.listeners.add(listener);\n\t\treturn () => {\n\t\t\tthis.listeners.delete(listener);\n\t\t};\n\t}\n\n\t/**\n\t * Retention protects snapshots and logs only. Delivery has its own explicit hold.\n\t */\n\tretain(id: string): () => void {\n\t\treturn this.pin(this.lookup(id));\n\t}\n\n\tprivate pin(record: TaskRecord): () => void {\n\t\trecord.pins++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\trecord.pins--;\n\t\t\tthis.store.trim();\n\t\t\t// Listeners decide whether delivery may proceed; TaskDelivery owns pausing.\n\t\t\tif (!this.closed && record.deliverable) this.emit();\n\t\t};\n\t}\n\n\tholdDelivery(id: string): () => void {\n\t\treturn this.holdRecord(this.lookup(id));\n\t}\n\n\tprivate holdRecord(record: TaskRecord): () => void {\n\t\tconst releasePin = this.pin(record);\n\t\trecord.deliveryHolds++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\trecord.deliveryHolds--;\n\t\t\treleasePin();\n\t\t};\n\t}\n\n\tpendingNotifications(): TaskSnapshot[] {\n\t\tif (this.closed) return [];\n\t\treturn this.store.deliverable().map((record) => record.snapshot());\n\t}\n\n\tclaimNotification(id: string): boolean {\n\t\treturn !this.closed && (this.store.get(id)?.claim() ?? false);\n\t}\n\n\tmarkDelivered(id: string): void {\n\t\tconst record = this.store.get(id);\n\t\tif (!record) return;\n\t\trecord.acknowledge();\n\t\tthis.store.trim();\n\t}\n\n\treleaseNotification(id: string): void {\n\t\tif (!this.store.get(id)?.unclaim()) return;\n\t\tthis.store.trim();\n\t\tthis.emit();\n\t}\n\n\tclose(): void {\n\t\tif (this.closed) return;\n\t\tthis._closed = true;\n\t\tthis.listeners.clear();\n\t\tfor (const record of this.store.all()) {\n\t\t\tthis.executions.get(record.task.id)?.releaseParent();\n\t\t\tthis.cancel(record);\n\t\t\tfor (const waiter of [...record.waiters]) waiter();\n\t\t}\n\t\tthis.store.trim();\n\t}\n\n\tasync shutdown(graceMs = 2000): Promise<void> {\n\t\tthis.close();\n\t\tawait this.drain(this.store.all(), graceMs);\n\t}\n\n\t/** Running tasks whose launch anchor is outside the branch made of `ancestors`. */\n\tactiveOutsideBranch(ancestors: ReadonlySet<string>): TaskSnapshot[] {\n\t\treturn this.store\n\t\t\t.unsettled()\n\t\t\t.filter((record) => record.task.anchorId !== null && !ancestors.has(record.task.anchorId))\n\t\t\t.map((record) => record.snapshot());\n\t}\n\n\t/**\n\t * Hidden results stay pending: returning to their branch delivers them again.\n\t * Restored history is already delivered.\n\t */\n\tasync cancelOutsideBranch(ancestors: ReadonlySet<string>): Promise<void> {\n\t\tconst records = this.store.all();\n\t\tfor (const record of records)\n\t\t\trecord.visible = record.task.anchorId === null || ancestors.has(record.task.anchorId);\n\t\tconst outside = records.filter((record) => !record.visible);\n\t\tfor (const record of outside) this.cancel(record);\n\t\tthis.store.trim();\n\t\tthis.emit();\n\t\tawait this.drain(outside, 2000);\n\t}\n\n\tprivate async drain(records: TaskRecord[], graceMs: number): Promise<void> {\n\t\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\t\ttry {\n\t\t\tawait Promise.race([\n\t\t\t\tPromise.all(records.map((record) => this.executions.get(record.task.id)?.done)).then(() =>\n\t\t\t\t\tthis.store.cleanupsDone(),\n\t\t\t\t),\n\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(resolve, finiteLimit(graceMs, 2000, 60_000));\n\t\t\t\t}),\n\t\t\t]);\n\t\t} finally {\n\t\t\tif (timer !== undefined) clearTimeout(timer);\n\t\t}\n\t}\n\n\tprivate emit(): void {\n\t\tif (this.closed) return;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\tif (this.closed) break;\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t/* Observers do not own execution or delivery. */\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
@@ -37,7 +37,6 @@ export declare class TaskSession {
|
|
|
37
37
|
private readonly quarantine;
|
|
38
38
|
constructor(options: TaskSessionOptions);
|
|
39
39
|
get service(): TaskRuntime;
|
|
40
|
-
get waitInterruptSignal(): AbortSignal;
|
|
41
40
|
/** End only current task waits; the next wait observes a fresh signal. */
|
|
42
41
|
interruptWaits(): void;
|
|
43
42
|
noteCompaction(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/core/tasks/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAmB,MAAM,+BAA+B,CAAC;AACnF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,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