@nylorun/harness 0.11.1-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 +29 -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 -7
- 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 +21 -19
- 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 +5 -5
- package/dist/build/agent.d.ts +0 -18
- package/dist/build/agent.js +0 -37
- package/dist/build/assemble.d.ts +0 -8
- package/dist/build/builder.d.ts +0 -46
- package/dist/build/builder.js +0 -151
- 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 -485
- package/dist/session/seed.d.ts +0 -10
- package/dist/session/session.d.ts +0 -18
- package/dist/session/session.js +0 -103
- 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 -70
- package/dist/turn/plan-runner.js +0 -388
- package/dist/turn/runner.d.ts +0 -69
- package/dist/turn/runner.js +0 -158
- package/dist/types/session.d.ts +0 -227
- package/dist/utils/maps.d.ts +0 -1
- package/dist/utils/maps.js +0 -37
- package/dist/utils/observe.d.ts +0 -8
- package/dist/utils/observe.js +0 -29
- /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
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Agent, AgentBuilder, AgentBuildError, AgentLifecycleError
|
|
1
|
+
export { Agent, AgentBuilder, AgentBuildError, AgentLifecycleError } from "./definition/builder.js";
|
|
2
2
|
export { HarnessError, isHarnessError } from "./errors.js";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
3
|
+
export { middleware, model, tool } from "./definition/helpers.js";
|
|
4
|
+
export { defineSchema } from "./definition/schema.js";
|
|
5
|
+
export { preparedModel } from "./execution/model/prepared.js";
|
|
6
|
+
export { createExecutionState, validateExecutionState } from "./execution/state.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentManifest } from "./manifest.js";
|
|
2
|
+
import type { RunOptions, RunResult } from "./execution.js";
|
|
3
|
+
/** An agent definition built with Agent(...).use(...).build(). */
|
|
4
|
+
export interface BuiltAgent<Info = unknown, Output = string> {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly manifest: AgentManifest;
|
|
8
|
+
run(options: RunOptions<Info>): Promise<RunResult<Output>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ModelAdapter } from "./model.js";
|
|
2
|
+
import type { InputEvent, MessageInput, TranscriptEntry } from "./transcript.js";
|
|
3
|
+
import type { ObserveEvent } from "./observe.js";
|
|
4
|
+
import type { JsonObject, JsonValue, Tripwire } from "./shared.js";
|
|
5
|
+
import type { RequiredInteraction, ToolExecutionResume, ToolOutcome, ToolResult } from "./tool.js";
|
|
6
|
+
export type ExecutionInput = MessageInput | InputEvent | {
|
|
7
|
+
readonly kind: "continue";
|
|
8
|
+
} | {
|
|
9
|
+
readonly kind: "settle";
|
|
10
|
+
readonly invocationId: string;
|
|
11
|
+
readonly outcome: Extract<ToolOutcome, {
|
|
12
|
+
kind: "completed" | "failed" | "denied";
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
/** Portable reference to deployed code. Applications must preserve this value intact. */
|
|
16
|
+
export interface ToolReference {
|
|
17
|
+
readonly capabilityId: string;
|
|
18
|
+
readonly toolName: string;
|
|
19
|
+
readonly descriptor: {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly description?: string;
|
|
22
|
+
readonly inputSchema: JsonObject;
|
|
23
|
+
readonly outputSchema?: JsonObject;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface SavedToolCall {
|
|
27
|
+
readonly callId: string;
|
|
28
|
+
readonly invocationId: string;
|
|
29
|
+
readonly toolName: string;
|
|
30
|
+
readonly args: JsonValue;
|
|
31
|
+
readonly rawArgs: JsonValue;
|
|
32
|
+
readonly reference: ToolReference;
|
|
33
|
+
readonly status: "pending" | "active" | "settled" | "interaction" | "deferred";
|
|
34
|
+
readonly result?: ToolResult;
|
|
35
|
+
readonly interaction?: RequiredInteraction;
|
|
36
|
+
readonly interactionPhase?: "before" | "execute";
|
|
37
|
+
readonly resume?: ToolExecutionResume;
|
|
38
|
+
readonly token?: JsonValue;
|
|
39
|
+
}
|
|
40
|
+
export interface ExecutionPlan {
|
|
41
|
+
readonly turnId: string;
|
|
42
|
+
readonly stepId: string;
|
|
43
|
+
readonly stepNumber: number;
|
|
44
|
+
readonly order: readonly {
|
|
45
|
+
readonly callId: string;
|
|
46
|
+
readonly toolName: string;
|
|
47
|
+
}[];
|
|
48
|
+
readonly immediate: readonly ToolResult[];
|
|
49
|
+
readonly calls: readonly SavedToolCall[];
|
|
50
|
+
}
|
|
51
|
+
/** Versioned continuation data, not a live execution object. */
|
|
52
|
+
export interface ExecutionState {
|
|
53
|
+
readonly version: 1;
|
|
54
|
+
readonly agentId: string;
|
|
55
|
+
readonly executionId: string;
|
|
56
|
+
readonly outputContract?: JsonObject;
|
|
57
|
+
readonly revision: number;
|
|
58
|
+
readonly turnCount: number;
|
|
59
|
+
readonly transcript: readonly TranscriptEntry[];
|
|
60
|
+
readonly status: "ready" | "active" | "completed" | "paused" | "cancelled" | "failed";
|
|
61
|
+
readonly plan?: ExecutionPlan;
|
|
62
|
+
/** Abandoned actions retained for reconciliation, never automatically dispatched. */
|
|
63
|
+
readonly cancelledCalls?: readonly SavedToolCall[];
|
|
64
|
+
}
|
|
65
|
+
export type ExecutionEvent = (ObserveEvent | {
|
|
66
|
+
readonly type: "execution.completed" | "execution.paused" | "execution.cancelled" | "execution.failed" | "observation.failed";
|
|
67
|
+
readonly attributes?: JsonObject;
|
|
68
|
+
}) & {
|
|
69
|
+
readonly executionId: string;
|
|
70
|
+
readonly sequence: number;
|
|
71
|
+
readonly runId: string;
|
|
72
|
+
};
|
|
73
|
+
export interface RunOptions<Info = unknown> {
|
|
74
|
+
readonly state?: ExecutionState;
|
|
75
|
+
readonly input: ExecutionInput;
|
|
76
|
+
readonly onModelCall: ModelAdapter;
|
|
77
|
+
readonly info?: Info;
|
|
78
|
+
readonly signal?: AbortSignal;
|
|
79
|
+
readonly onEvent?: (event: ExecutionEvent) => void | Promise<void>;
|
|
80
|
+
readonly record?: (state: ExecutionState) => void | Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
export type RunResult<Output = string> = {
|
|
83
|
+
readonly status: "completed";
|
|
84
|
+
readonly state: ExecutionState;
|
|
85
|
+
readonly output: Output;
|
|
86
|
+
} | {
|
|
87
|
+
readonly status: "paused";
|
|
88
|
+
readonly state: ExecutionState;
|
|
89
|
+
readonly pending: readonly SavedToolCall[];
|
|
90
|
+
} | {
|
|
91
|
+
readonly status: "cancelled";
|
|
92
|
+
readonly state: ExecutionState;
|
|
93
|
+
} | {
|
|
94
|
+
readonly status: "failed";
|
|
95
|
+
readonly state: ExecutionState;
|
|
96
|
+
readonly error: Tripwire;
|
|
97
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/manifest.d.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
1
|
+
import type { ModelDirective } from "./model.js";
|
|
2
|
+
import type { JsonObject } from "./shared.js";
|
|
3
|
+
export interface ManifestTool {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
readonly inputSchema: JsonObject;
|
|
7
|
+
readonly outputSchema?: JsonObject;
|
|
8
|
+
}
|
|
9
|
+
export interface CapabilityManifest {
|
|
4
10
|
readonly id: string;
|
|
11
|
+
readonly kind: "agent" | "capability" | "middleware";
|
|
12
|
+
readonly hasMiddleware: boolean;
|
|
13
|
+
readonly instructions?: readonly string[];
|
|
14
|
+
readonly tools?: readonly ManifestTool[];
|
|
15
|
+
readonly model?: Pick<ModelDirective, "id" | "controls">;
|
|
5
16
|
}
|
|
6
17
|
export interface AgentManifest {
|
|
7
18
|
readonly id: string;
|
|
8
19
|
readonly name: string;
|
|
9
|
-
readonly
|
|
20
|
+
readonly outputSchema?: JsonObject;
|
|
21
|
+
readonly capabilities: readonly CapabilityManifest[];
|
|
10
22
|
}
|
|
11
|
-
export type BuildResult<Agent> = {
|
|
12
|
-
readonly ok: true;
|
|
13
|
-
readonly agent: Agent;
|
|
14
|
-
readonly manifest: AgentManifest;
|
|
15
|
-
} | {
|
|
16
|
-
readonly ok: false;
|
|
17
|
-
readonly diagnostics: readonly BuildDiagnostic[];
|
|
18
|
-
};
|
|
19
|
-
export type { BoundMiddleware };
|
|
@@ -1,31 +1,14 @@
|
|
|
1
1
|
import type { ContextMutationOptions, ModelCandidate, ModelDirective, ModelToolCall, ModelConfigurationMutationOptions } from "./model.js";
|
|
2
|
-
import type { InputEvent,
|
|
3
|
-
import type { ContextItem,
|
|
2
|
+
import type { InputEvent, TranscriptEntry } from "./transcript.js";
|
|
3
|
+
import type { ContextItem, Tripwire } from "./shared.js";
|
|
4
4
|
import type { Interaction, ToolDefinition, ToolResult } from "./tool.js";
|
|
5
|
-
export interface StepInput {
|
|
6
|
-
readonly sessionId: string;
|
|
7
|
-
readonly turnId: string;
|
|
8
|
-
readonly stepId: string;
|
|
9
|
-
/** One-based position of this turn within the Session. */
|
|
10
|
-
readonly turnNumber: number;
|
|
11
|
-
/** One-based position of this Model Step within the Turn. */
|
|
12
|
-
readonly stepNumber: number;
|
|
13
|
-
readonly session: Readonly<{
|
|
14
|
-
readonly userId?: string;
|
|
15
|
-
readonly context?: JsonObject;
|
|
16
|
-
}>;
|
|
17
|
-
readonly arrivals: readonly InputEvent[];
|
|
18
|
-
readonly toolResults: readonly ToolResult[];
|
|
19
|
-
readonly transcript: readonly TranscriptEntry[];
|
|
20
|
-
}
|
|
21
5
|
interface StepRequestBase {
|
|
22
|
-
/** Opaque identity of the
|
|
23
|
-
readonly
|
|
6
|
+
/** Opaque identity of the execution that owns this Step. */
|
|
7
|
+
readonly executionId: string;
|
|
24
8
|
/** Opaque identity of the Turn that owns this Step. */
|
|
25
9
|
readonly turnId: string;
|
|
26
10
|
/** Opaque identity of this Model Step. */
|
|
27
11
|
readonly stepId: string;
|
|
28
|
-
readonly session: StepInput["session"];
|
|
29
12
|
readonly turnNumber: number;
|
|
30
13
|
readonly stepNumber: number;
|
|
31
14
|
readonly arrivals: readonly InputEvent[];
|
|
@@ -49,9 +32,9 @@ interface StepRequestBase {
|
|
|
49
32
|
};
|
|
50
33
|
tripwire(error: Tripwire): StepResponse;
|
|
51
34
|
}
|
|
52
|
-
export type StepRequest<
|
|
53
|
-
readonly
|
|
54
|
-
}
|
|
35
|
+
export type StepRequest<Info = unknown> = StepRequestBase & {
|
|
36
|
+
readonly info?: Info;
|
|
37
|
+
};
|
|
55
38
|
export interface StepResponse {
|
|
56
39
|
candidate(): Readonly<ModelCandidate> | undefined;
|
|
57
40
|
toolCalls(): readonly ModelToolCall[];
|
|
@@ -60,23 +43,17 @@ export interface StepResponse {
|
|
|
60
43
|
requireInteraction(callId: string, interaction: Interaction): void;
|
|
61
44
|
tripwire(error: Tripwire): StepResponse;
|
|
62
45
|
}
|
|
63
|
-
export type StepMiddleware<
|
|
64
|
-
export interface CapabilityState<State> {
|
|
65
|
-
create(session: SessionIdentity, signal: AbortSignal): State | Promise<State>;
|
|
66
|
-
dispose?(value: State): void | Promise<void>;
|
|
67
|
-
}
|
|
46
|
+
export type StepMiddleware<Info = unknown> = (request: StepRequest<Info>, next: () => Promise<StepResponse>) => Promise<StepResponse>;
|
|
68
47
|
export type CapabilityItems<Item> = readonly Item[] | Readonly<{
|
|
69
48
|
readonly slot: string;
|
|
70
49
|
readonly items: readonly Item[];
|
|
71
50
|
}>;
|
|
72
|
-
|
|
73
|
-
export interface CapabilityDeclaration<State = never> {
|
|
51
|
+
export interface CapabilityDeclaration<Info = unknown> {
|
|
74
52
|
readonly id: string;
|
|
75
|
-
readonly tools?: CapabilityItems<ToolDefinition<
|
|
53
|
+
readonly tools?: CapabilityItems<ToolDefinition<any, Info, any>>;
|
|
76
54
|
readonly instructions?: CapabilityItems<string>;
|
|
77
55
|
readonly model?: ModelDirective;
|
|
78
|
-
readonly
|
|
79
|
-
readonly middleware?: StepMiddleware<State>;
|
|
56
|
+
readonly middleware?: StepMiddleware<Info>;
|
|
80
57
|
}
|
|
81
58
|
export interface MiddlewareContributions {
|
|
82
59
|
readonly instructions?: readonly string[];
|
|
@@ -86,10 +63,4 @@ export interface MiddlewareContributions {
|
|
|
86
63
|
}[];
|
|
87
64
|
readonly model?: Pick<ModelDirective, "id" | "controls">;
|
|
88
65
|
}
|
|
89
|
-
export interface BoundMiddleware {
|
|
90
|
-
readonly id: string;
|
|
91
|
-
readonly handle: StepMiddleware;
|
|
92
|
-
readonly state?: CapabilityState<unknown>;
|
|
93
|
-
readonly contributions?: MiddlewareContributions;
|
|
94
|
-
}
|
|
95
66
|
export {};
|
package/dist/types/model.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ContextItem,
|
|
2
|
-
import type { InputEvent, TranscriptEntry } from "./
|
|
3
|
-
import type {
|
|
1
|
+
import type { ContextItem, JsonObject, JsonValue } from "./shared.js";
|
|
2
|
+
import type { InputEvent, TranscriptEntry } from "./transcript.js";
|
|
3
|
+
import type { ToolDescriptor, ToolResult } from "./tool.js";
|
|
4
4
|
export interface ModelToolCall {
|
|
5
5
|
readonly id: string;
|
|
6
6
|
readonly name: string;
|
|
@@ -81,8 +81,8 @@ export interface ModelConfigurationSnapshot {
|
|
|
81
81
|
readonly version: 1;
|
|
82
82
|
readonly model?: ModelDirective;
|
|
83
83
|
readonly instructions: readonly ModelConfigurationInstruction[];
|
|
84
|
-
/**
|
|
85
|
-
readonly tools: readonly
|
|
84
|
+
/** Data-only descriptions of the selected tools. */
|
|
85
|
+
readonly tools: readonly ToolDescriptor[];
|
|
86
86
|
readonly toolContracts: readonly ModelConfigurationTool[];
|
|
87
87
|
readonly contributors: readonly ModelConfigurationContributor[];
|
|
88
88
|
}
|
|
@@ -103,7 +103,7 @@ export interface ContextSnapshot {
|
|
|
103
103
|
readonly contributors: readonly ContextContributor[];
|
|
104
104
|
}
|
|
105
105
|
export interface ModelRequest {
|
|
106
|
-
readonly
|
|
106
|
+
readonly executionId: string;
|
|
107
107
|
readonly turnId: string;
|
|
108
108
|
readonly stepId: string;
|
|
109
109
|
readonly model?: ModelDirective;
|
|
@@ -114,8 +114,8 @@ export interface ModelRequest {
|
|
|
114
114
|
readonly transcript: readonly TranscriptEntry[];
|
|
115
115
|
readonly arrivals: readonly InputEvent[];
|
|
116
116
|
readonly toolResults: readonly ToolResult[];
|
|
117
|
-
/**
|
|
118
|
-
readonly tools: readonly
|
|
117
|
+
/** Immutable tool descriptions; executable definitions stay inside Harness. */
|
|
118
|
+
readonly tools: readonly ToolDescriptor[];
|
|
119
119
|
/** Optional portable contract for this turn's terminal JSON result. */
|
|
120
120
|
readonly outputSchema?: JsonObject;
|
|
121
121
|
}
|
|
@@ -168,7 +168,7 @@ export interface ModelCall {
|
|
|
168
168
|
readonly tools: readonly ModelCallTool[];
|
|
169
169
|
/** Optional portable contract for this turn's terminal JSON result. */
|
|
170
170
|
readonly outputSchema?: JsonObject;
|
|
171
|
-
readonly
|
|
171
|
+
readonly executionId: string;
|
|
172
172
|
}
|
|
173
173
|
export interface ModelAdapterContext {
|
|
174
174
|
readonly request: ModelRequest;
|
|
@@ -181,4 +181,4 @@ export interface ModelPreparedCall {
|
|
|
181
181
|
readonly adapter: string;
|
|
182
182
|
readonly call: JsonValue;
|
|
183
183
|
}
|
|
184
|
-
export type ModelAdapter = (call: ModelCall, context: ModelAdapterContext) => Promise<ModelCandidate | string
|
|
184
|
+
export type ModelAdapter = (call: ModelCall, context: ModelAdapterContext) => Promise<ModelCandidate | string>;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { ContextSnapshot, ModelCandidate, ModelCall, ModelConfigurationSnapshot } from "./model.js";
|
|
2
|
+
import type { JsonObject, JsonValue } from "./shared.js";
|
|
3
|
+
import type { InputEvent, TranscriptEntry } from "./transcript.js";
|
|
4
|
+
import type { RequiredInteraction, ToolDescriptor, ToolResult } from "./tool.js";
|
|
5
|
+
export type ObserveToolSnapshot = ToolDescriptor;
|
|
6
|
+
/** JSON-only model-configuration view suitable for an observation stream. */
|
|
7
|
+
export interface ObserveModelConfigurationSnapshot extends Omit<ModelConfigurationSnapshot, "tools"> {
|
|
8
|
+
readonly tools: readonly ObserveToolSnapshot[];
|
|
9
|
+
}
|
|
10
|
+
export interface ObserveSealedCall {
|
|
11
|
+
readonly callId: string;
|
|
12
|
+
readonly toolName: string;
|
|
13
|
+
readonly args: JsonValue;
|
|
14
|
+
readonly invocationId: string;
|
|
15
|
+
readonly owner: {
|
|
16
|
+
readonly middlewareId: string;
|
|
17
|
+
readonly slot: string;
|
|
18
|
+
};
|
|
19
|
+
readonly interaction?: RequiredInteraction;
|
|
20
|
+
}
|
|
21
|
+
export interface ObserveModelRequested {
|
|
22
|
+
/** The exact immutable logical input supplied to the ModelAdapter. */
|
|
23
|
+
readonly call: ModelCall;
|
|
24
|
+
/** Canonical configuration facts and attribution. */
|
|
25
|
+
readonly configuration: ObserveModelConfigurationSnapshot;
|
|
26
|
+
/** Current-step runtime context and attribution. */
|
|
27
|
+
readonly context: ContextSnapshot;
|
|
28
|
+
}
|
|
29
|
+
export type ObserveEvent = {
|
|
30
|
+
readonly type: "model.requested";
|
|
31
|
+
readonly invocationId: string;
|
|
32
|
+
readonly turnId: string;
|
|
33
|
+
readonly stepId: string;
|
|
34
|
+
readonly inputId?: string;
|
|
35
|
+
readonly requestedModelId?: string;
|
|
36
|
+
readonly attributes: ObserveModelRequested;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "model.prepared";
|
|
39
|
+
readonly invocationId: string;
|
|
40
|
+
readonly turnId: string;
|
|
41
|
+
readonly stepId: string;
|
|
42
|
+
readonly inputId?: string;
|
|
43
|
+
readonly requestedModelId?: string;
|
|
44
|
+
readonly attributes: {
|
|
45
|
+
readonly adapter: string;
|
|
46
|
+
readonly call: JsonValue;
|
|
47
|
+
};
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "model.completed";
|
|
50
|
+
readonly invocationId?: string;
|
|
51
|
+
readonly turnId: string;
|
|
52
|
+
readonly stepId: string;
|
|
53
|
+
readonly inputId?: string;
|
|
54
|
+
readonly requestedModelId?: string;
|
|
55
|
+
readonly attributes: ModelCandidate;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: "step.started";
|
|
58
|
+
readonly turnId: string;
|
|
59
|
+
readonly stepId: string;
|
|
60
|
+
readonly inputId?: string;
|
|
61
|
+
readonly turnNumber: number;
|
|
62
|
+
readonly stepNumber: number;
|
|
63
|
+
readonly attributes: {
|
|
64
|
+
readonly arrivals: readonly InputEvent[];
|
|
65
|
+
readonly toolResults: readonly ToolResult[];
|
|
66
|
+
readonly transcript: readonly TranscriptEntry[];
|
|
67
|
+
};
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: "middleware.entered" | "middleware.completed";
|
|
70
|
+
readonly turnId: string;
|
|
71
|
+
readonly stepId: string;
|
|
72
|
+
readonly inputId?: string;
|
|
73
|
+
readonly middlewareId: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "middleware.lease-violation";
|
|
76
|
+
readonly turnId: string;
|
|
77
|
+
readonly stepId: string;
|
|
78
|
+
readonly inputId?: string;
|
|
79
|
+
readonly middlewareId: string;
|
|
80
|
+
readonly reason: string;
|
|
81
|
+
} | {
|
|
82
|
+
readonly type: "tool.sealed";
|
|
83
|
+
readonly turnId: string;
|
|
84
|
+
readonly stepId: string;
|
|
85
|
+
readonly inputId?: string;
|
|
86
|
+
readonly attributes: {
|
|
87
|
+
readonly executable: readonly ObserveSealedCall[];
|
|
88
|
+
readonly immediate: readonly ToolResult[];
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
readonly type: "tool.started";
|
|
92
|
+
readonly executionId: string;
|
|
93
|
+
readonly turnId: string;
|
|
94
|
+
readonly stepId: string;
|
|
95
|
+
readonly inputId?: string;
|
|
96
|
+
readonly toolName: string;
|
|
97
|
+
readonly callId: string;
|
|
98
|
+
readonly invocationId: string;
|
|
99
|
+
readonly middlewareId: string;
|
|
100
|
+
readonly slot: string;
|
|
101
|
+
readonly attributes: {
|
|
102
|
+
readonly args: JsonValue;
|
|
103
|
+
};
|
|
104
|
+
} | {
|
|
105
|
+
readonly type: "tool.completed";
|
|
106
|
+
readonly executionId: string;
|
|
107
|
+
readonly turnId: string;
|
|
108
|
+
readonly stepId: string;
|
|
109
|
+
readonly inputId?: string;
|
|
110
|
+
readonly toolName: string;
|
|
111
|
+
readonly callId: string;
|
|
112
|
+
readonly invocationId: string;
|
|
113
|
+
readonly middlewareId: string;
|
|
114
|
+
readonly slot: string;
|
|
115
|
+
readonly outcome: string;
|
|
116
|
+
readonly code?: string;
|
|
117
|
+
readonly attributes?: ToolResult;
|
|
118
|
+
} | {
|
|
119
|
+
readonly type: "tool.deferred";
|
|
120
|
+
readonly executionId: string;
|
|
121
|
+
readonly turnId: string;
|
|
122
|
+
readonly stepId: string;
|
|
123
|
+
readonly inputId?: string;
|
|
124
|
+
readonly toolName: string;
|
|
125
|
+
readonly callId: string;
|
|
126
|
+
readonly invocationId: string;
|
|
127
|
+
readonly middlewareId: string;
|
|
128
|
+
readonly slot: string;
|
|
129
|
+
readonly attributes: {
|
|
130
|
+
readonly token?: JsonValue;
|
|
131
|
+
};
|
|
132
|
+
} | {
|
|
133
|
+
readonly type: "turn.completed";
|
|
134
|
+
readonly turnId: string;
|
|
135
|
+
readonly stepId: string;
|
|
136
|
+
readonly inputId?: string;
|
|
137
|
+
readonly attributes: {
|
|
138
|
+
readonly output: JsonValue;
|
|
139
|
+
};
|
|
140
|
+
} | {
|
|
141
|
+
readonly type: "interaction.required";
|
|
142
|
+
readonly turnId: string;
|
|
143
|
+
readonly stepId: string;
|
|
144
|
+
readonly inputId?: string;
|
|
145
|
+
readonly interactionId: string;
|
|
146
|
+
readonly kind: string;
|
|
147
|
+
readonly callId?: string;
|
|
148
|
+
readonly toolName?: string;
|
|
149
|
+
readonly phase?: "interaction" | "execute";
|
|
150
|
+
readonly attributes: {
|
|
151
|
+
readonly prompt: string;
|
|
152
|
+
readonly metadata?: JsonObject;
|
|
153
|
+
};
|
|
154
|
+
} | {
|
|
155
|
+
readonly type: "tripwire";
|
|
156
|
+
readonly turnId: string;
|
|
157
|
+
readonly stepId?: string;
|
|
158
|
+
readonly inputId?: string;
|
|
159
|
+
readonly code: string;
|
|
160
|
+
readonly scope: string;
|
|
161
|
+
readonly attributes: {
|
|
162
|
+
readonly message: string;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export type Observer = (event: ObserveEvent) => void | Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|