@excitedjs/dreamux-types 0.9.0-beta.179 → 0.9.0-beta.183
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-runtime.d.ts +285 -290
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/channel.d.ts +199 -362
- package/dist/channel.d.ts.map +1 -1
- package/dist/command.d.ts +78 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/index.d.ts +18 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/invoke.d.ts +39 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/json.d.ts +20 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/provider.d.ts +24 -9
- package/dist/provider.d.ts.map +1 -1
- package/dist/team.d.ts +145 -0
- package/dist/team.d.ts.map +1 -0
- package/dist/teammate.d.ts +91 -0
- package/dist/teammate.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/channel-binding.d.ts +0 -80
- package/dist/channel-binding.d.ts.map +0 -1
- package/dist/turn.d.ts +0 -58
- package/dist/turn.d.ts.map +0 -1
package/dist/agent-runtime.d.ts
CHANGED
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent Runtime provider-authoring contracts (declaration-only).
|
|
3
3
|
*
|
|
4
|
-
* The complete, neutral Agent Runtime provider contract
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* host-private types (`DispatcherRow`, `DispatcherStore`,
|
|
10
|
-
* config/state stores, or host path-helper
|
|
11
|
-
* Dreamux core adapts its private objects into these
|
|
4
|
+
* The complete, neutral Agent Runtime provider contract a runtime package
|
|
5
|
+
* implements while importing only `@excitedjs/dreamux-types`. The seam is
|
|
6
|
+
* deliberately minimal: a provider facade for selection, creation, and neutral
|
|
7
|
+
* recent Activity reads; a live handle with only `start`, `submit`, and `stop`;
|
|
8
|
+
* and a Core-owned leased state sink runtime facts are pushed into. It never
|
|
9
|
+
* exposes Dreamux host-private types (`DispatcherRow`, `DispatcherStore`,
|
|
10
|
+
* `DispatcherConfig`, config/state stores, or host path-helper
|
|
11
|
+
* implementations); Dreamux core adapts its private objects into these shapes.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* can be authored against it today.
|
|
13
|
+
* Recovery, session-bound structured output, and recent Activity Records are
|
|
14
|
+
* mandatory provider behavior rather than negotiated capability bits. Live
|
|
15
|
+
* activity emission stays optional because its absence changes only
|
|
16
|
+
* presentation.
|
|
18
17
|
*/
|
|
19
18
|
import type { DreamuxLogger } from './logger.js';
|
|
20
|
-
import type {
|
|
21
|
-
import type {
|
|
19
|
+
import type { JsonSchema, JsonValue } from './json.js';
|
|
20
|
+
import type { DreamuxEnvironment, ProviderBinCheck, ProviderDiagnosticRunner, ProviderDiagnosticScope, ProviderDiagnosticResult, ProviderFactory, ProviderOnboard } from './provider.js';
|
|
21
|
+
/** Runtime-specific alias of the shared public logger contract. */
|
|
22
|
+
export type AgentRuntimeLogger = DreamuxLogger;
|
|
23
|
+
/**
|
|
24
|
+
* One MCP server Core injects into a runtime. Core owns the whole list: a
|
|
25
|
+
* provider launches exactly these entries and never discovers, appends to, or
|
|
26
|
+
* mutates them.
|
|
27
|
+
*/
|
|
22
28
|
export interface AgentRuntimeMcpServer {
|
|
23
|
-
name: string;
|
|
24
|
-
command: string;
|
|
25
|
-
args: string[];
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly command: string;
|
|
31
|
+
readonly args: readonly string[];
|
|
32
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
26
33
|
}
|
|
27
34
|
/**
|
|
28
35
|
* A skill root core hands to a runtime. Core composes required bundled roots
|
|
@@ -38,122 +45,37 @@ export interface AgentRuntimeSkillSource {
|
|
|
38
45
|
path: string;
|
|
39
46
|
source: 'dreamux-core' | string;
|
|
40
47
|
}
|
|
41
|
-
export interface AgentRuntimeResumeCheckpoint {
|
|
42
|
-
/** Runtime-owned checkpoint id persisted by Dreamux and interpreted by the runtime. */
|
|
43
|
-
id: string;
|
|
44
|
-
/**
|
|
45
|
-
* Provider-produced canonical native transcript locator. Dreamux persists
|
|
46
|
-
* this value atomically with {@link id} and never interprets it.
|
|
47
|
-
*/
|
|
48
|
-
transcript_locator?: string | null;
|
|
49
|
-
}
|
|
50
|
-
export interface AgentRuntimeResumeCapability {
|
|
51
|
-
supported: boolean;
|
|
52
|
-
}
|
|
53
|
-
export interface AgentRuntimeStructuredOutputCapability {
|
|
54
|
-
supported: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* How the schema is applied:
|
|
57
|
-
* - `'create-context'`: set once at spawn time (e.g. claude-code `--json-schema`).
|
|
58
|
-
* - `'per-turn'`: set on each turn (e.g. codex `turn/start.outputSchema`).
|
|
59
|
-
* When `supported` is false, `scope` is omitted.
|
|
60
|
-
*/
|
|
61
|
-
scope?: 'create-context' | 'per-turn';
|
|
62
|
-
}
|
|
63
|
-
export interface AgentRuntimeCapabilities {
|
|
64
|
-
/** Whether this runtime can resume a prior checkpoint id from its create context. */
|
|
65
|
-
resume: AgentRuntimeResumeCapability;
|
|
66
|
-
/**
|
|
67
|
-
* Whether this runtime supports structured output (JSON Schema on the final
|
|
68
|
-
* assistant message). Optional: a provider that omits it is treated as
|
|
69
|
-
* unsupported so core can fail-loud before submitting a schema-constrained
|
|
70
|
-
* turn, instead of relying on the runtime to return a specific error.
|
|
71
|
-
*/
|
|
72
|
-
structuredOutput?: AgentRuntimeStructuredOutputCapability;
|
|
73
|
-
}
|
|
74
|
-
export interface AgentRuntimeSystemPrompt {
|
|
75
|
-
/** Full role instructions for runtimes that replace their base prompt. */
|
|
76
|
-
replace?: string;
|
|
77
|
-
/**
|
|
78
|
-
* Ordered role deltas for runtimes that append to an existing native prompt.
|
|
79
|
-
* Runtime adapters preserve order and choose their native isolation mechanic.
|
|
80
|
-
*/
|
|
81
|
-
append?: readonly string[];
|
|
82
|
-
}
|
|
83
|
-
export interface AgentRuntimeTextInput {
|
|
84
|
-
text: string;
|
|
85
|
-
/** Correlation/dedupe metadata; not part of the model-visible text. */
|
|
86
|
-
sourceId?: string;
|
|
87
|
-
/**
|
|
88
|
-
* Optional JSON Schema constraining the model's final assistant message for
|
|
89
|
-
* this turn. Provider-neutral: each runtime maps it to its native structured
|
|
90
|
-
* output mechanism (e.g. codex `turn/start.outputSchema`, claude-code
|
|
91
|
-
* `--json-schema`). Runtimes that do not support structured output MUST
|
|
92
|
-
* return `{ status: 'failed', error }` where `error` is an
|
|
93
|
-
* {@link UnsupportedAgentRuntimeFeatureError} with `feature: 'outputSchema'`
|
|
94
|
-
* when this is set — never silently ignore it, so callers never get
|
|
95
|
-
* unconstrained text when they asked for a schema. When set, the settled
|
|
96
|
-
* result text is expected to be valid JSON conforming to the schema; the
|
|
97
|
-
* caller parses it.
|
|
98
|
-
*/
|
|
99
|
-
outputSchema?: Record<string, unknown>;
|
|
100
|
-
}
|
|
101
48
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
49
|
+
* Provider-static selection metadata. Zero-argument and config-free: Core has
|
|
50
|
+
* no config-resolved consumer, so parsed config would widen the seam without a
|
|
51
|
+
* use case.
|
|
52
|
+
*
|
|
53
|
+
* `publicConfig` is optional, bounded, explicitly projected metadata. Raw
|
|
54
|
+
* provider config, environment variables, paths, credentials, and secrets are
|
|
55
|
+
* forbidden in it.
|
|
108
56
|
*/
|
|
109
|
-
export interface
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
export interface AgentRuntimeContextSnapshot {
|
|
114
|
-
usedTokens: number | null;
|
|
115
|
-
windowTokens: number | null;
|
|
116
|
-
}
|
|
117
|
-
export interface AgentRuntimeTranscriptQuery {
|
|
118
|
-
turns: number;
|
|
119
|
-
cursor?: string;
|
|
120
|
-
includeTools?: boolean;
|
|
121
|
-
}
|
|
122
|
-
export type AgentRuntimeTranscriptBlock = {
|
|
123
|
-
kind: 'message';
|
|
124
|
-
role: 'user' | 'assistant';
|
|
125
|
-
text: string;
|
|
126
|
-
truncated: boolean;
|
|
127
|
-
} | {
|
|
128
|
-
kind: 'tool';
|
|
129
|
-
name: string;
|
|
130
|
-
input: string | null;
|
|
131
|
-
output: string | null;
|
|
132
|
-
status: 'ok' | 'error';
|
|
133
|
-
inputTruncated: boolean;
|
|
134
|
-
outputTruncated: boolean;
|
|
135
|
-
};
|
|
136
|
-
export interface AgentRuntimeTranscriptTurn {
|
|
137
|
-
startedAt: number | null;
|
|
138
|
-
endedAt: number | null;
|
|
139
|
-
blocks: readonly AgentRuntimeTranscriptBlock[];
|
|
57
|
+
export interface AgentRuntimeProviderCapabilities {
|
|
58
|
+
readonly tags: readonly string[];
|
|
59
|
+
readonly publicConfig?: Readonly<Record<string, JsonValue>>;
|
|
140
60
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
checkpoint: AgentRuntimeResumeCheckpoint | null;
|
|
148
|
-
config: TConfig;
|
|
149
|
-
cwd: string;
|
|
150
|
-
injectEnv?: Readonly<Record<string, string>>;
|
|
151
|
-
outputBudgetBytes: 262144;
|
|
152
|
-
logger?: DreamuxLogger;
|
|
61
|
+
/**
|
|
62
|
+
* The shared base of every provider-owned session identity: `id` is the only
|
|
63
|
+
* field Dreamux core validates and the only one it may read.
|
|
64
|
+
*/
|
|
65
|
+
export interface AgentRuntimeSessionRef {
|
|
66
|
+
readonly id: string;
|
|
153
67
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The neutral, Core-supplied identity of one runtime instance.
|
|
70
|
+
*
|
|
71
|
+
* `session` is the provider's own prior session object, or `null` for a fresh
|
|
72
|
+
* start. Core persists the complete JSON object atomically and returns it only
|
|
73
|
+
* to the same provider; it never interprets, indexes, or branches on the
|
|
74
|
+
* provider-specific fields an extended `TSession` adds.
|
|
75
|
+
*/
|
|
76
|
+
export interface AgentRuntimeIdentity<TSession extends AgentRuntimeSessionRef> {
|
|
77
|
+
readonly runtimeId: string;
|
|
78
|
+
readonly session: TSession | null;
|
|
157
79
|
}
|
|
158
80
|
export interface AgentRuntimePathContext {
|
|
159
81
|
/**
|
|
@@ -179,58 +101,64 @@ export interface AgentRuntimePathContext {
|
|
|
179
101
|
*/
|
|
180
102
|
runtimeSocketDirs(): readonly string[];
|
|
181
103
|
}
|
|
182
|
-
export interface AgentRuntimeProviderConfigReadContext {
|
|
183
|
-
providerRef: string;
|
|
184
|
-
/**
|
|
185
|
-
* The `agents[].id` whose config block is being parsed — a config-internal
|
|
186
|
-
* alias, not a dispatcher identity.
|
|
187
|
-
*/
|
|
188
|
-
agentId: string;
|
|
189
|
-
file: string;
|
|
190
|
-
prefix: string;
|
|
191
|
-
}
|
|
192
|
-
/** Runtime-specific alias of the shared provider binary check. */
|
|
193
|
-
export type AgentRuntimeBinCheck = ProviderBinCheck;
|
|
194
|
-
/** Runtime-specific alias of the shared provider diagnostic result. */
|
|
195
|
-
export type AgentRuntimeDiagnosticResult = ProviderDiagnosticResult;
|
|
196
|
-
/** Runtime-specific alias of the shared provider diagnostic runner. */
|
|
197
|
-
export type AgentRuntimeDiagnosticRunner = ProviderDiagnosticRunner;
|
|
198
104
|
/**
|
|
199
105
|
* Neutral runtime status. Mirrors the host's dispatcher lifecycle states without
|
|
200
106
|
* importing the host enum, so a provider can report status without depending on
|
|
201
107
|
* `@excitedjs/dreamux`.
|
|
202
108
|
*/
|
|
203
109
|
export type AgentRuntimeStatus = 'declared' | 'starting' | 'ready' | 'degraded' | 'stopping' | 'stopped';
|
|
110
|
+
/** One authoritative runtime fact pushed into the Core-owned state sink. */
|
|
111
|
+
export type AgentRuntimeStateUpdate<TSession extends AgentRuntimeSessionRef> = {
|
|
112
|
+
readonly kind: 'status';
|
|
113
|
+
readonly status: AgentRuntimeStatus;
|
|
114
|
+
readonly lastError?: string;
|
|
115
|
+
} | {
|
|
116
|
+
readonly kind: 'session';
|
|
117
|
+
readonly session: TSession;
|
|
118
|
+
} | {
|
|
119
|
+
readonly kind: 'session_lost';
|
|
120
|
+
readonly reason: string;
|
|
121
|
+
};
|
|
204
122
|
/**
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
123
|
+
* Push-only state sink, leased to exactly one runtime generation.
|
|
124
|
+
*
|
|
125
|
+
* Core creates a distinct sink per generation; the generation is not a public
|
|
126
|
+
* field and the provider supplies no sequence number. Core serializes updates
|
|
127
|
+
* in call-receipt order and resolves `publish` only after the authoritative
|
|
128
|
+
* state write is durable. There is no pull counterpart: awaiting the provider's
|
|
129
|
+
* own initial `publish` calls is the start fence.
|
|
130
|
+
*
|
|
131
|
+
* After Core revokes the lease (runtime replaced or stopped), `publish` rejects
|
|
132
|
+
* with an {@link AgentRuntimeStateLeaseRevokedError} so the provider terminates
|
|
133
|
+
* the stale writer. A persistence failure is a separate, fatal error.
|
|
208
134
|
*/
|
|
209
|
-
export interface
|
|
210
|
-
|
|
211
|
-
last_error?: string | null;
|
|
212
|
-
last_started_at?: number;
|
|
213
|
-
last_ready_at?: number;
|
|
214
|
-
}): Promise<void>;
|
|
215
|
-
setCheckpoint(checkpoint: AgentRuntimeResumeCheckpoint): Promise<void>;
|
|
216
|
-
recordLostCheckpoint?(lost: AgentRuntimeResumeCheckpoint, replacement: AgentRuntimeResumeCheckpoint, error: string): Promise<void>;
|
|
135
|
+
export interface AgentRuntimeStateSink<TSession extends AgentRuntimeSessionRef> {
|
|
136
|
+
publish(update: AgentRuntimeStateUpdate<TSession>): Promise<void>;
|
|
217
137
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
138
|
+
/**
|
|
139
|
+
* Structural shape of the `Error` {@link AgentRuntimeStateSink.publish} rejects
|
|
140
|
+
* with once Core has revoked that runtime generation's lease. Callers branch on
|
|
141
|
+
* `error.name` rather than `instanceof`, keeping this package declaration-only.
|
|
142
|
+
*/
|
|
143
|
+
export interface AgentRuntimeStateLeaseRevokedError extends Error {
|
|
144
|
+
name: 'AgentRuntimeStateLeaseRevokedError';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* What a tool invocation does, classified by the runtime that owns the tool
|
|
148
|
+
* vocabulary. `null` means the runtime has no such classification for this call.
|
|
149
|
+
*/
|
|
150
|
+
export type RuntimeToolAction = 'read' | 'list_files' | 'search' | 'edit' | 'run';
|
|
221
151
|
/** One accepted provider submission. Its identity never implies folding. */
|
|
222
152
|
export interface RuntimeSubmission {
|
|
223
153
|
readonly settled: Promise<RuntimeSubmissionSettlement>;
|
|
224
154
|
}
|
|
225
|
-
/** A provider-observed native result
|
|
155
|
+
/** A provider-observed native result. */
|
|
226
156
|
export type RuntimeCompletion = {
|
|
227
157
|
readonly status: 'completed';
|
|
228
|
-
readonly displaySubmission: RuntimeSubmission;
|
|
229
158
|
readonly resultText: string | null;
|
|
230
159
|
readonly truncated: boolean;
|
|
231
160
|
} | {
|
|
232
161
|
readonly status: 'failed';
|
|
233
|
-
readonly displaySubmission: RuntimeSubmission;
|
|
234
162
|
readonly error: Error;
|
|
235
163
|
};
|
|
236
164
|
export type RuntimeSubmissionSettlement = {
|
|
@@ -242,11 +170,6 @@ export type RuntimeSubmissionSettlement = {
|
|
|
242
170
|
} | {
|
|
243
171
|
readonly kind: 'stopped';
|
|
244
172
|
};
|
|
245
|
-
/**
|
|
246
|
-
* What a tool invocation does, classified by the runtime that owns the tool
|
|
247
|
-
* vocabulary. `null` means the runtime has no such classification for this call.
|
|
248
|
-
*/
|
|
249
|
-
export type RuntimeToolAction = 'read' | 'list_files' | 'search' | 'edit' | 'run';
|
|
250
173
|
export type RuntimeActivity = {
|
|
251
174
|
readonly kind: 'assistant.message';
|
|
252
175
|
readonly id: string;
|
|
@@ -268,10 +191,31 @@ export interface RuntimeActivityEvent {
|
|
|
268
191
|
readonly activity: RuntimeActivity;
|
|
269
192
|
readonly occurredAt: number;
|
|
270
193
|
}
|
|
271
|
-
/**
|
|
272
|
-
|
|
194
|
+
/**
|
|
195
|
+
* Optional, synchronous, non-backpressuring sink for live native activity. It
|
|
196
|
+
* is transient input to the Core conversation projection, not a progress view:
|
|
197
|
+
* Core drops writes from a revoked generation, and its absence changes only
|
|
198
|
+
* presentation. The stable progress view is
|
|
199
|
+
* {@link AgentRuntimeProvider.readRecentActivity}, which never replays this
|
|
200
|
+
* sink and is never replayed by it.
|
|
201
|
+
*/
|
|
202
|
+
export interface AgentRuntimeActivitySink {
|
|
273
203
|
(event: RuntimeActivityEvent): void;
|
|
274
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* The single input shape a live runtime accepts.
|
|
207
|
+
*
|
|
208
|
+
* Deliberately nothing but text: it is already the complete model-facing
|
|
209
|
+
* message, so the seam carries no discriminator, no source enum, no source
|
|
210
|
+
* identity, and no rendering instruction. Every caller prepares its final text
|
|
211
|
+
* before submitting, so a runtime never renders an envelope and never branches
|
|
212
|
+
* on where a turn came from. Stable source identity, origin, intent, and
|
|
213
|
+
* display correlation stay on Core's own turn/admission state, and Core — not a
|
|
214
|
+
* Provider — deduplicates with them.
|
|
215
|
+
*/
|
|
216
|
+
export interface AgentRuntimeSubmissionInput {
|
|
217
|
+
readonly text: string;
|
|
218
|
+
}
|
|
275
219
|
/**
|
|
276
220
|
* Admission is separate from the eventual outcome of an accepted turn.
|
|
277
221
|
*
|
|
@@ -281,12 +225,17 @@ export interface RuntimeActivitySink {
|
|
|
281
225
|
* boundary. Callers MUST NOT retry an ambiguous admission automatically.
|
|
282
226
|
* A rejected/thrown input promise is likewise admission-ambiguous unless the
|
|
283
227
|
* provider documents and returns the explicit `failed` result instead.
|
|
228
|
+
*
|
|
229
|
+
* `skipped` remains a provider-seam state; the Command boundary — not this
|
|
230
|
+
* seam — normalizes it to the public `stopped`.
|
|
231
|
+
*
|
|
232
|
+
* There is no `duplicate` admission: a Provider has no source identity to
|
|
233
|
+
* deduplicate with. Core's own admission ledger returns the public `duplicate`
|
|
234
|
+
* before it ever calls {@link AgentRuntime.submit}.
|
|
284
235
|
*/
|
|
285
236
|
export type RuntimeAdmission = {
|
|
286
237
|
status: 'submitted';
|
|
287
238
|
submission: RuntimeSubmission;
|
|
288
|
-
} | {
|
|
289
|
-
status: 'duplicate';
|
|
290
239
|
} | {
|
|
291
240
|
status: 'stopped';
|
|
292
241
|
} | {
|
|
@@ -299,125 +248,176 @@ export type RuntimeAdmission = {
|
|
|
299
248
|
error: Error;
|
|
300
249
|
};
|
|
301
250
|
/**
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
* the
|
|
251
|
+
* Neutral system-prompt input. When both forms are present they are alternate
|
|
252
|
+
* representations of the same instructions, and a Provider applies at most one
|
|
253
|
+
* of them — whichever its runtime supports. `append` fragment order is
|
|
254
|
+
* significant. Dreamux re-supplies the reconstructed bundle on every
|
|
255
|
+
* runtime-context creation; a Provider must never become the authority for
|
|
256
|
+
* prompt state.
|
|
306
257
|
*/
|
|
307
|
-
export interface
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* A prior resumable checkpoint the launcher recovered, or null for a fresh
|
|
312
|
-
* start. The runtime interprets both the id and transcript locator.
|
|
313
|
-
*/
|
|
314
|
-
checkpoint: AgentRuntimeResumeCheckpoint | null;
|
|
258
|
+
export interface AgentRuntimeSystemPrompt {
|
|
259
|
+
readonly replace?: string;
|
|
260
|
+
readonly append?: readonly string[];
|
|
315
261
|
}
|
|
316
262
|
/**
|
|
317
|
-
* The neutral
|
|
318
|
-
*
|
|
319
|
-
* content, MCP servers, bundled skill sources, and neutral logger/path/state
|
|
320
|
-
* sinks. It never exposes host dispatcher rows, stores, or config models.
|
|
263
|
+
* The neutral facts required to launch one Dreamux role. Immutable: prior
|
|
264
|
+
* session identity reaches `start` only through this object.
|
|
321
265
|
*/
|
|
322
|
-
export interface AgentRuntimeCreateContext<TConfig
|
|
323
|
-
identity: AgentRuntimeIdentity
|
|
324
|
-
/** Provider-parsed config (the output of the provider's own
|
|
325
|
-
config: TConfig;
|
|
266
|
+
export interface AgentRuntimeCreateContext<TConfig, TSession extends AgentRuntimeSessionRef> {
|
|
267
|
+
readonly identity: AgentRuntimeIdentity<TSession>;
|
|
268
|
+
/** Provider-parsed config (the output of the provider's own config capability). */
|
|
269
|
+
readonly config: TConfig;
|
|
326
270
|
/**
|
|
327
271
|
* The directory the runtime runs in. Always supplied by the launcher; never
|
|
328
272
|
* derived inside the runtime.
|
|
329
273
|
*/
|
|
330
|
-
cwd: string;
|
|
331
|
-
/**
|
|
332
|
-
|
|
333
|
-
* forms; runtime adapters decide which native prompt mechanic to use.
|
|
334
|
-
*/
|
|
335
|
-
systemPrompt?: AgentRuntimeSystemPrompt;
|
|
274
|
+
readonly cwd: string;
|
|
275
|
+
/** Core-supplied role instructions; see {@link AgentRuntimeSystemPrompt}. */
|
|
276
|
+
readonly systemPrompt?: AgentRuntimeSystemPrompt;
|
|
336
277
|
/**
|
|
337
|
-
* MCP servers
|
|
338
|
-
*
|
|
339
|
-
*
|
|
278
|
+
* MCP servers Core injects for this runtime instance. Already fully resolved:
|
|
279
|
+
* an empty array means "no MCP servers", and the provider must launch exactly
|
|
280
|
+
* these — it must not infer, append, or mutate the list.
|
|
340
281
|
*/
|
|
341
|
-
mcpServers: readonly AgentRuntimeMcpServer[];
|
|
282
|
+
readonly mcpServers: readonly AgentRuntimeMcpServer[];
|
|
342
283
|
/**
|
|
343
|
-
* Effective skill sources core selected for this runtime
|
|
344
|
-
*
|
|
284
|
+
* Effective skill sources core selected for this runtime, including required
|
|
285
|
+
* bundled role roots and authorized custom roots.
|
|
345
286
|
*/
|
|
346
|
-
skillSources
|
|
287
|
+
readonly skillSources: readonly AgentRuntimeSkillSource[];
|
|
347
288
|
/**
|
|
348
289
|
* Neutral feature names the host asks this runtime to disable. Core emits
|
|
349
290
|
* only neutral names; each runtime maps the names it understands to its own
|
|
350
291
|
* mechanism and ignores the rest.
|
|
351
292
|
*/
|
|
352
|
-
|
|
293
|
+
readonly disabledFeatures: readonly string[];
|
|
353
294
|
/**
|
|
354
|
-
* Optional JSON Schema constraining the model's final assistant message
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
* `turn/start.outputSchema`) may ignore this create-context field and rely
|
|
360
|
-
* on the per-turn {@link AgentRuntimeTextInput.outputSchema} instead. When
|
|
361
|
-
* set, every settled turn's result text is expected to be valid JSON
|
|
362
|
-
* conforming to the schema; the caller parses it. Omitted/undefined means
|
|
363
|
-
* "no schema constraint" — the common case.
|
|
295
|
+
* Optional JSON Schema constraining the model's final assistant message, bound
|
|
296
|
+
* once to this runtime session. A provider that applies the schema natively
|
|
297
|
+
* per turn stores this fixed value and reapplies it; a later submit can never
|
|
298
|
+
* change it. When set, every settled turn's result text is expected to be
|
|
299
|
+
* valid JSON conforming to the schema; the caller parses it.
|
|
364
300
|
*/
|
|
365
|
-
outputSchema?:
|
|
366
|
-
/** Required live activity sink, installed before the runtime starts. */
|
|
367
|
-
activitySink: RuntimeActivitySink;
|
|
368
|
-
logger?: DreamuxLogger;
|
|
369
|
-
paths?: AgentRuntimePathContext;
|
|
370
|
-
state?: AgentRuntimeStateCallbacks;
|
|
301
|
+
readonly outputSchema?: JsonSchema;
|
|
371
302
|
/**
|
|
372
303
|
* Neutral process-env injection seam. Core merges these entries into the
|
|
373
304
|
* runtime's spawn environment AFTER `process.env` and BEFORE the provider's
|
|
374
305
|
* own `config.extra_env`, i.e. spawn env =
|
|
375
306
|
* `{ ...process.env, ...injectEnv, ...config.extra_env }`. Core owns what (if
|
|
376
307
|
* anything) it injects; `config.extra_env` is the provider's own config and is
|
|
377
|
-
* NOT routed through here.
|
|
378
|
-
* case today.
|
|
308
|
+
* NOT routed through here.
|
|
379
309
|
*/
|
|
380
|
-
injectEnv?: Record<string, string
|
|
310
|
+
readonly injectEnv?: Readonly<Record<string, string>>;
|
|
311
|
+
readonly paths: AgentRuntimePathContext;
|
|
312
|
+
/** Leased, push-only state sink for this runtime generation. */
|
|
313
|
+
readonly state: AgentRuntimeStateSink<TSession>;
|
|
314
|
+
readonly activity?: AgentRuntimeActivitySink;
|
|
315
|
+
readonly logger?: AgentRuntimeLogger;
|
|
316
|
+
}
|
|
317
|
+
/** What `start` restored. Core consumes it before admitting the first submission. */
|
|
318
|
+
export interface AgentRuntimeStartOutcome {
|
|
319
|
+
readonly continuity: 'fresh' | 'resumed';
|
|
381
320
|
}
|
|
382
321
|
/**
|
|
383
|
-
* The live runtime handle
|
|
384
|
-
*
|
|
322
|
+
* The live runtime handle. Nothing is pulled from it: every runtime fact flows
|
|
323
|
+
* out through the leased state and activity sinks.
|
|
385
324
|
*/
|
|
386
325
|
export interface AgentRuntime {
|
|
387
|
-
readonly providerRef: string;
|
|
388
|
-
start(): Promise<void>;
|
|
389
|
-
resume(): Promise<void>;
|
|
390
326
|
/**
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
*
|
|
327
|
+
* Launch or restore the native session. A non-null create-context session MUST
|
|
328
|
+
* restore continuous model context; failure rejects and never silently becomes
|
|
329
|
+
* fresh. The provider durably publishes its session and ready state before
|
|
330
|
+
* this resolves.
|
|
395
331
|
*/
|
|
396
|
-
|
|
332
|
+
start(): Promise<AgentRuntimeStartOutcome>;
|
|
333
|
+
submit(input: AgentRuntimeSubmissionInput): Promise<RuntimeAdmission>;
|
|
397
334
|
/**
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
*
|
|
404
|
-
* not receive channel/XML rendering.
|
|
405
|
-
*/
|
|
406
|
-
completionInput(input: AgentRuntimeTextInput): Promise<RuntimeAdmission>;
|
|
407
|
-
/**
|
|
408
|
-
* Resolve when no turn is in progress. Optional: runtimes that omit it are
|
|
409
|
-
* treated by core as always idle.
|
|
335
|
+
* Fence new input synchronously, terminate the owned runtime, and converge
|
|
336
|
+
* every `submit` call that started before the fence. This promise MUST NOT
|
|
337
|
+
* resolve while an already-started admission can still resolve to a newly
|
|
338
|
+
* accepted {@link RuntimeSubmission}. A stop racing a still-pending start
|
|
339
|
+
* stops the runtime that appears later; a failed start rolls back all partial
|
|
340
|
+
* ownership.
|
|
410
341
|
*/
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
342
|
+
stop(): Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A bounded request for the recent tail of one session's activity. Cursors are
|
|
346
|
+
* opaque and provider-owned; pagination walks a stable recent tail without
|
|
347
|
+
* skipping or duplicating records as native history grows.
|
|
348
|
+
*/
|
|
349
|
+
export interface AgentActivityQuery<TSession extends AgentRuntimeSessionRef> {
|
|
350
|
+
readonly session: TSession;
|
|
351
|
+
readonly cursor?: string;
|
|
352
|
+
readonly limit?: number;
|
|
353
|
+
/** Tools are included by default and can only be hidden as a group. */
|
|
354
|
+
readonly includeTools?: boolean;
|
|
355
|
+
}
|
|
356
|
+
export interface AgentActivityReadContext<TConfig> {
|
|
357
|
+
readonly config: TConfig;
|
|
358
|
+
readonly cwd: string;
|
|
359
|
+
readonly injectEnv?: Readonly<Record<string, string>>;
|
|
360
|
+
readonly logger?: AgentRuntimeLogger;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* One neutral activity fact. Tool arguments, tool results, provider-native
|
|
364
|
+
* lines, Core status, admission, and settlement never appear here.
|
|
365
|
+
*/
|
|
366
|
+
export type AgentActivityRecord = {
|
|
367
|
+
readonly kind: 'assistant_message';
|
|
368
|
+
readonly text: string;
|
|
369
|
+
readonly occurredAt?: string;
|
|
370
|
+
} | {
|
|
371
|
+
readonly kind: 'tool';
|
|
372
|
+
readonly name: string;
|
|
373
|
+
readonly status: 'started' | 'completed' | 'failed';
|
|
374
|
+
readonly occurredAt?: string;
|
|
375
|
+
};
|
|
376
|
+
/** One chronological page of recent Activity Records. */
|
|
377
|
+
export interface AgentActivityPage {
|
|
378
|
+
readonly records: readonly AgentActivityRecord[];
|
|
379
|
+
readonly nextCursor?: string;
|
|
380
|
+
/** Set by the provider when its own native read bounds truncated the page. */
|
|
381
|
+
readonly truncated: boolean;
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Structural shape of the `Error` a provider rejects an Activity read with.
|
|
385
|
+
* Reasons describe neutral states only: never a filesystem path, native history
|
|
386
|
+
* layout, or scan mode. Callers branch on `error.name` rather than
|
|
387
|
+
* `instanceof`, keeping this package declaration-only.
|
|
388
|
+
*/
|
|
389
|
+
export interface AgentActivityError extends Error {
|
|
390
|
+
name: 'AgentActivityError';
|
|
391
|
+
reason: 'session_unavailable' | 'cursor_invalid' | 'activity_corrupt' | 'provider_failure';
|
|
392
|
+
}
|
|
393
|
+
export interface AgentRuntimeProviderConfigReadContext {
|
|
394
|
+
providerRef: string;
|
|
415
395
|
/**
|
|
416
|
-
*
|
|
396
|
+
* The `agents[].id` whose config block is being parsed — a config-internal
|
|
397
|
+
* alias, not a dispatcher identity.
|
|
417
398
|
*/
|
|
418
|
-
|
|
419
|
-
|
|
399
|
+
agentId: string;
|
|
400
|
+
file: string;
|
|
401
|
+
prefix: string;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Optional provider-owned config parsing. A parse/validation failure must throw
|
|
405
|
+
* (the host fails loud), never return a partially-valid config.
|
|
406
|
+
*/
|
|
407
|
+
export interface AgentRuntimeConfigCapability<TConfig> {
|
|
408
|
+
read(rawConfig: Record<string, unknown>, context: AgentRuntimeProviderConfigReadContext): TConfig | Promise<TConfig>;
|
|
420
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* Optional provider-owned onboarding. Core asks only for host envelope fields
|
|
412
|
+
* and delegates provider-specific raw config collection to this capability.
|
|
413
|
+
*/
|
|
414
|
+
export type AgentRuntimeOnboardCapability = ProviderOnboard<Record<string, unknown>>;
|
|
415
|
+
/** Runtime-specific alias of the shared provider binary check. */
|
|
416
|
+
export type AgentRuntimeBinCheck = ProviderBinCheck;
|
|
417
|
+
/** Runtime-specific alias of the shared provider diagnostic result. */
|
|
418
|
+
export type AgentRuntimeDiagnosticResult = ProviderDiagnosticResult;
|
|
419
|
+
/** Runtime-specific alias of the shared provider diagnostic runner. */
|
|
420
|
+
export type AgentRuntimeDiagnosticRunner = ProviderDiagnosticRunner;
|
|
421
421
|
/**
|
|
422
422
|
* Per-runtime diagnostic context. Neutral: it carries the runtime instance id,
|
|
423
423
|
* the provider-parsed config, the resolved env, and the diagnostic `scope`,
|
|
@@ -438,54 +438,49 @@ export interface AgentRuntimeDiagnosticContext<TConfig = unknown> {
|
|
|
438
438
|
paths?: AgentRuntimePathContext;
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
|
-
*
|
|
442
|
-
* core should dedup + execute, and RUNS its own non-bin internal
|
|
443
|
-
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* Optional on {@link AgentRuntimeProvider}: a provider with no diagnostic surface
|
|
447
|
-
* omits it. The host supplies the {@link AgentRuntimeDiagnosticRunner} to
|
|
448
|
-
* `runDiagnostic`; the provider only implements the checks, never the runner.
|
|
441
|
+
* Optional provider-owned diagnostics: the provider DECLARES the bin checks
|
|
442
|
+
* Dreamux core should dedup + execute, and RUNS its own non-bin internal
|
|
443
|
+
* checks. The host supplies the {@link AgentRuntimeDiagnosticRunner}; the
|
|
444
|
+
* provider only implements the checks, never the runner.
|
|
449
445
|
*/
|
|
450
|
-
export interface
|
|
446
|
+
export interface AgentRuntimeDiagnosticCapability<TConfig> {
|
|
451
447
|
binChecks(context: AgentRuntimeDiagnosticContext<TConfig>): AgentRuntimeBinCheck[];
|
|
452
448
|
runDiagnostic(context: AgentRuntimeDiagnosticContext<TConfig>, runner: AgentRuntimeDiagnosticRunner): Promise<AgentRuntimeDiagnosticResult>;
|
|
453
449
|
}
|
|
454
450
|
/**
|
|
455
|
-
* The Agent Runtime provider
|
|
456
|
-
*
|
|
451
|
+
* The Agent Runtime provider facade: selection, neutral recent Activity reads,
|
|
452
|
+
* and runtime creation, plus operational capabilities composed as optional
|
|
453
|
+
* objects rather than fake methods.
|
|
454
|
+
*
|
|
455
|
+
* Registration identity is absent by construction — Core owns the descriptor in
|
|
456
|
+
* its {@link RegisteredProvider} wrapper, so this interface has no `ref` or
|
|
457
|
+
* `descriptor` member and a live {@link AgentRuntime} echoes neither.
|
|
458
|
+
*
|
|
459
|
+
* Every provider defines its own JSON-serializable `TSession`. A provider that
|
|
460
|
+
* resumes from an id alone uses {@link AgentRuntimeSessionRef}; one that needs
|
|
461
|
+
* more native resume coordinates extends it.
|
|
457
462
|
*/
|
|
458
|
-
export interface AgentRuntimeProvider<TConfig =
|
|
459
|
-
|
|
460
|
-
readonly descriptor: AgentRuntimeProviderDescriptor;
|
|
461
|
-
getCapabilities(): AgentRuntimeCapabilities;
|
|
462
|
-
/**
|
|
463
|
-
* Parse + validate this provider's own config block. May return synchronously
|
|
464
|
-
* or as a promise; Dreamux core awaits the result, mirroring
|
|
465
|
-
* `ChannelProvider.readConfig`. A parse/validation failure must throw (the host
|
|
466
|
-
* fails loud), never return a partially-valid config.
|
|
467
|
-
*/
|
|
468
|
-
readConfig?(rawConfig: Record<string, unknown>, context: AgentRuntimeProviderConfigReadContext): TConfig | Promise<TConfig>;
|
|
469
|
-
/**
|
|
470
|
-
* Self-reported diagnostics. Optional: a provider with no diagnostic
|
|
471
|
-
* surface may omit it.
|
|
472
|
-
*/
|
|
473
|
-
diagnostic?: AgentRuntimeDiagnostic<TConfig>;
|
|
463
|
+
export interface AgentRuntimeProvider<TConfig, TSession extends AgentRuntimeSessionRef = AgentRuntimeSessionRef> {
|
|
464
|
+
getCapabilities(): AgentRuntimeProviderCapabilities;
|
|
474
465
|
/**
|
|
475
|
-
*
|
|
476
|
-
*
|
|
466
|
+
* Read the recent tail of one session's activity. Mandatory: it must work
|
|
467
|
+
* against an actively growing session — producing useful records before any
|
|
468
|
+
* completion marker — and against the same session after the live runtime has
|
|
469
|
+
* closed. The provider enforces its own native read bounds and sets
|
|
470
|
+
* {@link AgentActivityPage.truncated}; Core independently validates record
|
|
471
|
+
* count, text size, page size, cursor size, and public errors.
|
|
477
472
|
*/
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
473
|
+
readRecentActivity(query: AgentActivityQuery<TSession>, context: AgentActivityReadContext<TConfig>): Promise<AgentActivityPage>;
|
|
474
|
+
createRuntime(context: AgentRuntimeCreateContext<TConfig, TSession>): Promise<AgentRuntime>;
|
|
475
|
+
readonly config?: AgentRuntimeConfigCapability<TConfig>;
|
|
476
|
+
readonly onboard?: AgentRuntimeOnboardCapability;
|
|
477
|
+
readonly diagnostic?: AgentRuntimeDiagnosticCapability<TConfig>;
|
|
481
478
|
}
|
|
482
479
|
/**
|
|
483
480
|
* The default (or `npm:pkg#export`-selected) factory export an Agent Runtime
|
|
484
|
-
* package ships.
|
|
485
|
-
* {@link AgentRuntimeProviderDescriptor}, so the package assigns
|
|
486
|
-
* `provider.descriptor` from the seed without a cast.
|
|
481
|
+
* package ships.
|
|
487
482
|
*/
|
|
488
|
-
export type AgentRuntimeProviderFactory<TConfig =
|
|
483
|
+
export type AgentRuntimeProviderFactory<TConfig, TSession extends AgentRuntimeSessionRef = AgentRuntimeSessionRef> = ProviderFactory<AgentRuntimeProvider<TConfig, TSession>>;
|
|
489
484
|
/** Re-export so provider packages can take a logger in their own contexts. */
|
|
490
485
|
export type { DreamuxLogger };
|
|
491
486
|
//# sourceMappingURL=agent-runtime.d.ts.map
|