@nylorun/harness 0.12.0-beta → 0.13.0-beta
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 +23 -0
- package/README.md +124 -5
- package/dist/definition/agent-definition.d.ts +11 -0
- package/dist/definition/agent-definition.js +12 -0
- package/dist/definition/assemble.d.ts +22 -0
- package/dist/{build → definition}/assemble.js +6 -4
- package/dist/definition/bind-agent.d.ts +9 -0
- package/dist/definition/bind-agent.js +21 -0
- package/dist/{build → definition}/bind-tool.d.ts +2 -1
- package/dist/{build → definition}/bind-tool.js +1 -0
- package/dist/definition/bound.d.ts +16 -0
- package/dist/definition/builder.d.ts +30 -0
- package/dist/definition/builder.js +94 -0
- package/dist/definition/declaration.d.ts +3 -0
- package/dist/definition/declaration.js +53 -0
- package/dist/{build → definition}/helpers.d.ts +1 -1
- package/dist/{build → definition}/manifest.d.ts +3 -1
- package/dist/definition/manifest.js +45 -0
- package/dist/{session → definition}/output-contract.d.ts +2 -2
- package/dist/{session → definition}/output-contract.js +1 -1
- package/dist/definition/registry.d.ts +10 -0
- package/dist/definition/registry.js +48 -0
- package/dist/{build → definition}/schema.d.ts +4 -4
- package/dist/errors.d.ts +1 -1
- package/dist/execution/dispatch.d.ts +2 -0
- package/dist/execution/dispatch.js +164 -0
- package/dist/execution/initial-state.d.ts +3 -0
- package/dist/execution/initial-state.js +14 -0
- package/dist/execution/invocation.d.ts +21 -0
- package/dist/execution/invocation.js +32 -0
- package/dist/{model → execution/model}/adapters.d.ts +2 -2
- package/dist/{model → execution/model}/adapters.js +2 -2
- package/dist/{model → execution/model}/normalize.d.ts +2 -2
- package/dist/{model → execution/model}/normalize.js +2 -2
- package/dist/{model → execution/model}/prepared.d.ts +3 -3
- package/dist/{step → execution/model}/project.d.ts +1 -1
- package/dist/{step → execution/model}/project.js +2 -10
- package/dist/execution/observe.d.ts +17 -0
- package/dist/execution/observe.js +53 -0
- package/dist/execution/options.d.ts +10 -0
- package/dist/execution/options.js +49 -0
- package/dist/execution/resume.d.ts +4 -0
- package/dist/execution/resume.js +52 -0
- package/dist/execution/run.d.ts +5 -0
- package/dist/execution/run.js +256 -0
- package/dist/execution/state.d.ts +8 -0
- package/dist/execution/state.js +208 -0
- package/dist/{step → execution/step}/canonicalize.d.ts +2 -2
- package/dist/{step → execution/step}/canonicalize.js +2 -2
- package/dist/{step → execution/step}/compose.d.ts +3 -2
- package/dist/{step → execution/step}/compose.js +5 -5
- package/dist/{step → execution/step}/context-draft.d.ts +3 -5
- package/dist/{step → execution/step}/context-draft.js +5 -22
- package/dist/execution/step/describe.d.ts +9 -0
- package/dist/execution/step/describe.js +22 -0
- package/dist/{step → execution/step}/model-configuration.d.ts +4 -3
- package/dist/{step → execution/step}/model-configuration.js +3 -3
- package/dist/execution/step/resolve.d.ts +11 -0
- package/dist/{step → execution/step}/resolve.js +5 -3
- package/dist/execution/step/run.d.ts +29 -0
- package/dist/{step → execution/step}/run.js +19 -53
- package/dist/execution/step/runtime.d.ts +32 -0
- package/dist/execution/step/runtime.js +1 -0
- package/dist/{step → execution/step}/seal.d.ts +13 -8
- package/dist/{step → execution/step}/seal.js +8 -6
- package/dist/{step → execution/step}/slot-assembly.d.ts +4 -4
- package/dist/{step → execution/step}/slot-assembly.js +4 -4
- package/dist/{step → execution/step}/step-context.d.ts +11 -12
- package/dist/{step → execution/step}/step-context.js +5 -27
- package/dist/execution/tool-result.d.ts +4 -0
- package/dist/execution/tool-result.js +30 -0
- package/dist/execution/transcript.d.ts +2 -0
- package/dist/{session/seed.js → execution/transcript.js} +9 -39
- package/dist/index.d.ts +15 -12
- package/dist/index.js +5 -5
- package/dist/types/agent.d.ts +9 -0
- package/dist/types/agent.js +1 -0
- package/dist/types/execution.d.ts +97 -0
- package/dist/types/execution.js +1 -0
- package/dist/types/manifest.d.ts +16 -13
- package/dist/types/middleware.d.ts +11 -40
- package/dist/types/model.d.ts +10 -10
- package/dist/types/observe.d.ts +165 -0
- package/dist/types/observe.js +1 -0
- package/dist/types/shared.d.ts +1 -225
- package/dist/types/tool.d.ts +19 -20
- package/dist/types/transcript.d.ts +65 -0
- package/dist/types/transcript.js +1 -0
- package/dist/utils/canonical.d.ts +1 -0
- package/dist/utils/canonical.js +10 -0
- package/dist/utils/immutable.d.ts +1 -0
- package/dist/utils/immutable.js +8 -0
- package/package.json +3 -3
- package/dist/build/agent.d.ts +0 -17
- package/dist/build/agent.js +0 -32
- package/dist/build/assemble.d.ts +0 -7
- package/dist/build/builder.d.ts +0 -38
- package/dist/build/builder.js +0 -136
- package/dist/build/manifest.js +0 -20
- package/dist/session/capability-state.d.ts +0 -14
- package/dist/session/capability-state.js +0 -67
- package/dist/session/event-log.d.ts +0 -12
- package/dist/session/event-log.js +0 -63
- package/dist/session/input-queue.d.ts +0 -41
- package/dist/session/input-queue.js +0 -94
- package/dist/session/record.d.ts +0 -11
- package/dist/session/record.js +0 -26
- package/dist/session/scheduler.d.ts +0 -62
- package/dist/session/scheduler.js +0 -475
- package/dist/session/seed.d.ts +0 -10
- package/dist/session/session.d.ts +0 -17
- package/dist/session/session.js +0 -101
- package/dist/session/state.d.ts +0 -15
- package/dist/session/state.js +0 -48
- package/dist/session/submission-stream.d.ts +0 -16
- package/dist/session/submission-stream.js +0 -46
- package/dist/step/resolve.d.ts +0 -10
- package/dist/step/run.d.ts +0 -33
- package/dist/turn/plan-runner.d.ts +0 -72
- package/dist/turn/plan-runner.js +0 -389
- package/dist/turn/runner.d.ts +0 -69
- package/dist/turn/runner.js +0 -159
- package/dist/types/session.d.ts +0 -230
- package/dist/utils/maps.d.ts +0 -1
- package/dist/utils/maps.js +0 -37
- package/dist/utils/observe.d.ts +0 -3
- package/dist/utils/observe.js +0 -13
- /package/dist/{types/session.js → definition/bound.js} +0 -0
- /package/dist/{build → definition}/helpers.js +0 -0
- /package/dist/{build → definition}/schema.js +0 -0
- /package/dist/{model → execution/model}/prepared.js +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { BoundMiddleware } from "../types/middleware.js";
|
|
2
|
-
import type { SessionIdentity } from "../types/session.js";
|
|
3
|
-
import type { ObserveEmit } from "../utils/observe.js";
|
|
4
|
-
/** Owns declared, process-local state for exactly one Session. */
|
|
5
|
-
export declare class CapabilityStateRegistry {
|
|
6
|
-
#private;
|
|
7
|
-
private readonly session;
|
|
8
|
-
private readonly observe;
|
|
9
|
-
constructor(middleware: readonly BoundMiddleware[], session: SessionIdentity, observe: ObserveEmit);
|
|
10
|
-
has(id: string): boolean;
|
|
11
|
-
get(id: string): Promise<unknown>;
|
|
12
|
-
abort(reason: unknown): void;
|
|
13
|
-
shutdown(reason: unknown): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { HarnessError } from "../errors.js";
|
|
2
|
-
/** Owns declared, process-local state for exactly one Session. */
|
|
3
|
-
export class CapabilityStateRegistry {
|
|
4
|
-
session;
|
|
5
|
-
observe;
|
|
6
|
-
#entries = new Map();
|
|
7
|
-
#controller = new AbortController();
|
|
8
|
-
#shutdown;
|
|
9
|
-
constructor(middleware, session, observe) {
|
|
10
|
-
this.session = session;
|
|
11
|
-
this.observe = observe;
|
|
12
|
-
for (const middlewareEntry of middleware) {
|
|
13
|
-
if (middlewareEntry.state)
|
|
14
|
-
this.#entries.set(middlewareEntry.id, {
|
|
15
|
-
id: middlewareEntry.id,
|
|
16
|
-
state: middlewareEntry.state,
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
has(id) {
|
|
21
|
-
return this.#entries.has(id);
|
|
22
|
-
}
|
|
23
|
-
get(id) {
|
|
24
|
-
const entry = this.#entries.get(id);
|
|
25
|
-
if (!entry)
|
|
26
|
-
return Promise.reject(new HarnessError("capability.state.undeclared", `Capability '${id}' did not declare session state`));
|
|
27
|
-
if (!entry.promise) {
|
|
28
|
-
entry.promise = Promise.resolve()
|
|
29
|
-
.then(() => entry.state.create(this.session, this.#controller.signal))
|
|
30
|
-
.then((value) => {
|
|
31
|
-
entry.value = value;
|
|
32
|
-
entry.created = true;
|
|
33
|
-
return value;
|
|
34
|
-
}, (cause) => {
|
|
35
|
-
throw new HarnessError("capability.state.create-failed", `Capability '${id}' failed to create session state`, { cause });
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return entry.promise;
|
|
39
|
-
}
|
|
40
|
-
abort(reason) {
|
|
41
|
-
this.#controller.abort(reason);
|
|
42
|
-
}
|
|
43
|
-
shutdown(reason) {
|
|
44
|
-
if (this.#shutdown)
|
|
45
|
-
return this.#shutdown;
|
|
46
|
-
this.abort(reason);
|
|
47
|
-
this.#shutdown = (async () => {
|
|
48
|
-
const created = [...this.#entries.values()].filter((entry) => entry.promise);
|
|
49
|
-
await Promise.allSettled(created.map((entry) => entry.promise));
|
|
50
|
-
for (const entry of [...created].reverse()) {
|
|
51
|
-
if (!entry.created || !entry.state.dispose)
|
|
52
|
-
continue;
|
|
53
|
-
try {
|
|
54
|
-
await entry.state.dispose(entry.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) {
|
|
57
|
-
this.observe({
|
|
58
|
-
type: "capability.state.dispose.failed",
|
|
59
|
-
capabilityId: entry.id,
|
|
60
|
-
attributes: { message: error instanceof Error ? error.message : String(error) },
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})();
|
|
65
|
-
return this.#shutdown;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SessionEvent } from "../types/session.js";
|
|
2
|
-
import type { JsonValue } from "../types/shared.js";
|
|
3
|
-
/** Session-lifetime conversation log. Each stream() call replays from the start. */
|
|
4
|
-
export declare class SessionEventLog implements AsyncIterable<SessionEvent<JsonValue>> {
|
|
5
|
-
private readonly events;
|
|
6
|
-
private readonly subscribers;
|
|
7
|
-
private done;
|
|
8
|
-
emit(event: SessionEvent<JsonValue>): void;
|
|
9
|
-
finish(): void;
|
|
10
|
-
[Symbol.asyncIterator](): AsyncIterator<SessionEvent<JsonValue>>;
|
|
11
|
-
private wake;
|
|
12
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/** Session-lifetime conversation log. Each stream() call replays from the start. */
|
|
2
|
-
export class SessionEventLog {
|
|
3
|
-
events = [];
|
|
4
|
-
subscribers = [];
|
|
5
|
-
done = false;
|
|
6
|
-
emit(event) {
|
|
7
|
-
if (this.done)
|
|
8
|
-
return;
|
|
9
|
-
this.events.push(event);
|
|
10
|
-
this.wake();
|
|
11
|
-
}
|
|
12
|
-
finish() {
|
|
13
|
-
if (this.done)
|
|
14
|
-
return;
|
|
15
|
-
this.done = true;
|
|
16
|
-
this.wake();
|
|
17
|
-
this.subscribers.length = 0;
|
|
18
|
-
}
|
|
19
|
-
[Symbol.asyncIterator]() {
|
|
20
|
-
let index = 0;
|
|
21
|
-
let closed = false;
|
|
22
|
-
const waiting = [];
|
|
23
|
-
this.subscribers.push(waiting);
|
|
24
|
-
const detach = () => {
|
|
25
|
-
const position = this.subscribers.indexOf(waiting);
|
|
26
|
-
if (position !== -1)
|
|
27
|
-
this.subscribers.splice(position, 1);
|
|
28
|
-
};
|
|
29
|
-
const complete = () => {
|
|
30
|
-
closed = true;
|
|
31
|
-
detach();
|
|
32
|
-
return { done: true, value: undefined };
|
|
33
|
-
};
|
|
34
|
-
const pull = () => {
|
|
35
|
-
if (closed)
|
|
36
|
-
return Promise.resolve({ done: true, value: undefined });
|
|
37
|
-
if (index < this.events.length)
|
|
38
|
-
return Promise.resolve({ done: false, value: this.events[index++] });
|
|
39
|
-
if (this.done)
|
|
40
|
-
return Promise.resolve(complete());
|
|
41
|
-
return new Promise((resolve) => {
|
|
42
|
-
waiting.push(() => {
|
|
43
|
-
void pull().then(resolve);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
return {
|
|
48
|
-
next: pull,
|
|
49
|
-
return: () => {
|
|
50
|
-
const result = complete();
|
|
51
|
-
while (waiting.length)
|
|
52
|
-
waiting.shift()();
|
|
53
|
-
return Promise.resolve(result);
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
wake() {
|
|
58
|
-
for (const waiting of this.subscribers) {
|
|
59
|
-
while (waiting.length)
|
|
60
|
-
waiting.shift()();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { InputEvent, InputOptions } from "../types/session.js";
|
|
2
|
-
import type { TurnOutputContract } from "./output-contract.js";
|
|
3
|
-
import { SubmissionStream } from "./submission-stream.js";
|
|
4
|
-
export type WorkEvent = InputEvent | {
|
|
5
|
-
readonly kind: "continue";
|
|
6
|
-
};
|
|
7
|
-
export interface QueuedInput {
|
|
8
|
-
readonly event: WorkEvent;
|
|
9
|
-
readonly options?: InputOptions & {
|
|
10
|
-
readonly output?: TurnOutputContract;
|
|
11
|
-
};
|
|
12
|
-
readonly stream: SubmissionStream;
|
|
13
|
-
cancelled: boolean;
|
|
14
|
-
}
|
|
15
|
-
export type QueuedInterrupt = Omit<QueuedInput, "event"> & {
|
|
16
|
-
readonly event: InputEvent & {
|
|
17
|
-
readonly kind: "interrupt";
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export interface QueueAbortHandlers {
|
|
21
|
-
readonly isActive: () => boolean;
|
|
22
|
-
readonly abortActive: (reason: unknown) => void;
|
|
23
|
-
readonly cancelQueued: () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare function isInteractionReply(event: InputEvent): event is Extract<InputEvent, {
|
|
26
|
-
kind: "approve" | "respond";
|
|
27
|
-
}>;
|
|
28
|
-
export declare function snapshotInput(event: InputEvent): InputEvent;
|
|
29
|
-
export declare function snapshotWork(event: WorkEvent): WorkEvent;
|
|
30
|
-
/** Serializes ordinary input while allowing a matching interaction reply to resume immediately. */
|
|
31
|
-
export declare class InputQueue {
|
|
32
|
-
private readonly values;
|
|
33
|
-
get size(): number;
|
|
34
|
-
add(input: QueuedInput, priority?: boolean): void;
|
|
35
|
-
take(waitingForInteraction: boolean): QueuedInput | undefined;
|
|
36
|
-
takeInterrupts(): QueuedInterrupt[];
|
|
37
|
-
remove(input: QueuedInput): boolean;
|
|
38
|
-
drain(): readonly QueuedInput[];
|
|
39
|
-
}
|
|
40
|
-
/** Binds one caller-provided signal to its queue entry and always removes the listener at completion. */
|
|
41
|
-
export declare function watchInputAbort(input: QueuedInput, handlers: QueueAbortHandlers): void;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { copyJson, copyJsonObject } from "../utils/immutable.js";
|
|
2
|
-
import { SubmissionStream } from "./submission-stream.js";
|
|
3
|
-
export function isInteractionReply(event) {
|
|
4
|
-
return event.kind === "approve" || event.kind === "respond";
|
|
5
|
-
}
|
|
6
|
-
export function snapshotInput(event) {
|
|
7
|
-
switch (event.kind) {
|
|
8
|
-
case "user-message":
|
|
9
|
-
case "interrupt":
|
|
10
|
-
if ("content" in event)
|
|
11
|
-
return Object.freeze({
|
|
12
|
-
kind: event.kind,
|
|
13
|
-
content: Object.freeze(event.content.map((part) => part.type === "text"
|
|
14
|
-
? Object.freeze({ type: "text", text: part.text })
|
|
15
|
-
: Object.freeze({
|
|
16
|
-
type: "media",
|
|
17
|
-
mediaType: part.mediaType,
|
|
18
|
-
reference: copyJson(part.reference),
|
|
19
|
-
}))),
|
|
20
|
-
...(event.metadata ? { metadata: copyJsonObject(event.metadata, "input metadata") } : {}),
|
|
21
|
-
});
|
|
22
|
-
return Object.freeze({
|
|
23
|
-
kind: event.kind,
|
|
24
|
-
text: event.text,
|
|
25
|
-
...(event.metadata ? { metadata: copyJsonObject(event.metadata, "input metadata") } : {}),
|
|
26
|
-
});
|
|
27
|
-
case "approve":
|
|
28
|
-
return Object.freeze({ ...event });
|
|
29
|
-
case "respond":
|
|
30
|
-
return Object.freeze({ ...event, value: copyJson(event.value) });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export function snapshotWork(event) {
|
|
34
|
-
return event.kind === "continue" ? Object.freeze({ kind: "continue" }) : snapshotInput(event);
|
|
35
|
-
}
|
|
36
|
-
/** Serializes ordinary input while allowing a matching interaction reply to resume immediately. */
|
|
37
|
-
export class InputQueue {
|
|
38
|
-
values = [];
|
|
39
|
-
get size() {
|
|
40
|
-
return this.values.length;
|
|
41
|
-
}
|
|
42
|
-
add(input, priority = false) {
|
|
43
|
-
if (priority)
|
|
44
|
-
this.values.unshift(input);
|
|
45
|
-
else
|
|
46
|
-
this.values.push(input);
|
|
47
|
-
}
|
|
48
|
-
take(waitingForInteraction) {
|
|
49
|
-
const next = this.values[0];
|
|
50
|
-
if (!next ||
|
|
51
|
-
(waitingForInteraction && (next.event.kind === "continue" || !isInteractionReply(next.event))))
|
|
52
|
-
return undefined;
|
|
53
|
-
return this.values.shift();
|
|
54
|
-
}
|
|
55
|
-
takeInterrupts() {
|
|
56
|
-
const claimed = [];
|
|
57
|
-
for (let index = 0; index < this.values.length;) {
|
|
58
|
-
const item = this.values[index];
|
|
59
|
-
if (item.event.kind !== "interrupt") {
|
|
60
|
-
index += 1;
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
this.values.splice(index, 1);
|
|
64
|
-
if (!item.cancelled)
|
|
65
|
-
claimed.push(item);
|
|
66
|
-
}
|
|
67
|
-
return claimed;
|
|
68
|
-
}
|
|
69
|
-
remove(input) {
|
|
70
|
-
const index = this.values.indexOf(input);
|
|
71
|
-
if (index < 0)
|
|
72
|
-
return false;
|
|
73
|
-
this.values.splice(index, 1);
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
drain() {
|
|
77
|
-
return this.values.splice(0);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
/** Binds one caller-provided signal to its queue entry and always removes the listener at completion. */
|
|
81
|
-
export function watchInputAbort(input, handlers) {
|
|
82
|
-
const signal = input.options?.signal;
|
|
83
|
-
if (!signal)
|
|
84
|
-
return;
|
|
85
|
-
const onAbort = () => {
|
|
86
|
-
input.cancelled = true;
|
|
87
|
-
if (handlers.isActive())
|
|
88
|
-
handlers.abortActive(signal.reason);
|
|
89
|
-
else
|
|
90
|
-
handlers.cancelQueued();
|
|
91
|
-
};
|
|
92
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
93
|
-
input.stream.onFinish(() => signal.removeEventListener("abort", onAbort));
|
|
94
|
-
}
|
package/dist/session/record.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ActiveExecutionRecord, SessionRecord, SessionSnapshot } from "../types/session.js";
|
|
2
|
-
import type { JsonObject } from "../types/shared.js";
|
|
3
|
-
export declare function sessionRecord(input: {
|
|
4
|
-
readonly state: SessionSnapshot;
|
|
5
|
-
readonly transition: SessionRecord["transition"];
|
|
6
|
-
readonly session: Readonly<{
|
|
7
|
-
readonly userId?: string;
|
|
8
|
-
readonly context?: JsonObject;
|
|
9
|
-
}>;
|
|
10
|
-
readonly active?: ActiveExecutionRecord;
|
|
11
|
-
}): SessionRecord;
|
package/dist/session/record.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { copyJson } from "../utils/immutable.js";
|
|
2
|
-
export function sessionRecord(input) {
|
|
3
|
-
const value = {
|
|
4
|
-
version: 1,
|
|
5
|
-
revision: input.state.revision,
|
|
6
|
-
transition: input.transition,
|
|
7
|
-
session: {
|
|
8
|
-
id: input.state.id,
|
|
9
|
-
...(input.session.userId === undefined ? {} : { userId: input.session.userId }),
|
|
10
|
-
...(input.session.context === undefined ? {} : { context: copyJson(input.session.context) }),
|
|
11
|
-
turnCount: input.state.turnCount,
|
|
12
|
-
status: input.state.status,
|
|
13
|
-
},
|
|
14
|
-
transcript: copyJson(input.state.transcript),
|
|
15
|
-
...(input.active === undefined ? {} : { active: copyJson(input.active) }),
|
|
16
|
-
};
|
|
17
|
-
return deepFreeze(value);
|
|
18
|
-
}
|
|
19
|
-
function deepFreeze(value, seen = new WeakSet()) {
|
|
20
|
-
if (!value || typeof value !== "object" || seen.has(value))
|
|
21
|
-
return value;
|
|
22
|
-
seen.add(value);
|
|
23
|
-
for (const child of Object.values(value))
|
|
24
|
-
deepFreeze(child, seen);
|
|
25
|
-
return Object.freeze(value);
|
|
26
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { InputEvent, InputOptions, SessionRecorder, SessionSnapshot } from "../types/session.js";
|
|
2
|
-
import type { Observer } from "../types/shared.js";
|
|
3
|
-
import { SessionEventLog } from "./event-log.js";
|
|
4
|
-
import { SubmissionStream } from "./submission-stream.js";
|
|
5
|
-
import { type LoopAgent } from "../build/agent.js";
|
|
6
|
-
import type { NormalizedSessionSeed } from "./seed.js";
|
|
7
|
-
/** Coordinates one active turn at a time; TurnRunner owns the turn's internal state machine. */
|
|
8
|
-
export declare class SessionScheduler {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly events: SessionEventLog;
|
|
11
|
-
private snapshotValue;
|
|
12
|
-
private readonly queue;
|
|
13
|
-
private readonly sessionController;
|
|
14
|
-
private activeController?;
|
|
15
|
-
private activeSubmission?;
|
|
16
|
-
private activeWork?;
|
|
17
|
-
private pending?;
|
|
18
|
-
private inFlightPlan?;
|
|
19
|
-
private running;
|
|
20
|
-
private stopping;
|
|
21
|
-
private stopped;
|
|
22
|
-
private suspended;
|
|
23
|
-
private generation;
|
|
24
|
-
private stopPromise?;
|
|
25
|
-
private recordFailure?;
|
|
26
|
-
private readonly turns;
|
|
27
|
-
private readonly states;
|
|
28
|
-
constructor(id: string, agent: LoopAgent, session: Readonly<{
|
|
29
|
-
readonly userId?: string;
|
|
30
|
-
readonly context?: import("../types/shared.js").JsonObject;
|
|
31
|
-
}>, options?: {
|
|
32
|
-
readonly seed?: NormalizedSessionSeed;
|
|
33
|
-
readonly recorder?: SessionRecorder;
|
|
34
|
-
readonly observer?: Observer;
|
|
35
|
-
});
|
|
36
|
-
private readonly session;
|
|
37
|
-
private readonly recorder?;
|
|
38
|
-
private readonly observer?;
|
|
39
|
-
get snapshot(): SessionSnapshot;
|
|
40
|
-
submit(event: InputEvent, options?: InputOptions): SubmissionStream;
|
|
41
|
-
continue(options?: InputOptions): SubmissionStream;
|
|
42
|
-
private submitWork;
|
|
43
|
-
stop(reason?: string): Promise<void>;
|
|
44
|
-
private enqueueReply;
|
|
45
|
-
private enqueueOrdinaryInput;
|
|
46
|
-
private watchAbort;
|
|
47
|
-
private reject;
|
|
48
|
-
private finishCancelled;
|
|
49
|
-
private finishStopped;
|
|
50
|
-
private publish;
|
|
51
|
-
private pump;
|
|
52
|
-
private run;
|
|
53
|
-
private resumeTurn;
|
|
54
|
-
private applyTurnOutcome;
|
|
55
|
-
private emitObserve;
|
|
56
|
-
private commitCancelledPlan;
|
|
57
|
-
private claimInterrupts;
|
|
58
|
-
private commit;
|
|
59
|
-
private assertRecordable;
|
|
60
|
-
private failRecording;
|
|
61
|
-
private assertCurrent;
|
|
62
|
-
}
|