@excitedjs/dreamux-types 0.2.0-alpha.g0ddd418597ca
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/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/agent-runtime.d.ts +388 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/channel.d.ts +190 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/logger.d.ts +18 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/provider.d.ts +75 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/turn.d.ts +87 -0
- package/dist/turn.d.ts.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 excitedjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @excitedjs/dreamux-types
|
|
2
|
+
|
|
3
|
+
Declaration-only provider-authoring contracts for **Dreamux**.
|
|
4
|
+
|
|
5
|
+
External Agent Runtime and Channel providers compile against this package for
|
|
6
|
+
Dreamux contracts and **must not** import `@excitedjs/dreamux`. The host package
|
|
7
|
+
owns Dispatcher/Team/TeamMate orchestration, provider loading, the Channel MCP
|
|
8
|
+
shim, binding state, routing, and authorization; this package owns only the
|
|
9
|
+
shared structural types.
|
|
10
|
+
|
|
11
|
+
## Guarantees
|
|
12
|
+
|
|
13
|
+
- **Declarations only.** The package emits `.d.ts` files (`emitDeclarationOnly`)
|
|
14
|
+
and publishes a `types`-only `exports` map — there is no runtime JS contract
|
|
15
|
+
surface to import as a value.
|
|
16
|
+
- **No runtime dependencies.** `package.json` declares only dev tooling.
|
|
17
|
+
- **No host-private types.** Provider create contexts here are neutral; Dreamux
|
|
18
|
+
core adapts its private objects (dispatcher rows, stores, identity records)
|
|
19
|
+
into these public shapes rather than exposing them.
|
|
20
|
+
|
|
21
|
+
## What it exports
|
|
22
|
+
|
|
23
|
+
- provider descriptor / ref shapes;
|
|
24
|
+
- the complete Agent Runtime provider contract: `AgentRuntimeProvider`,
|
|
25
|
+
`AgentRuntime`, the neutral `AgentRuntimeCreateContext`, capabilities, role,
|
|
26
|
+
skill sources, completion delivery, resume/last/context, MCP server
|
|
27
|
+
descriptor, neutral state callbacks, and diagnostic helper shapes;
|
|
28
|
+
- Channel provider/session contracts, target shapes, inbound envelope shapes,
|
|
29
|
+
tool descriptor/call shapes, and config/session contexts;
|
|
30
|
+
- a minimal public logger type (`DreamuxLogger`).
|
|
31
|
+
|
|
32
|
+
It does **not** export runtime implementations, default loggers, loader logic,
|
|
33
|
+
provider registry implementations, path helpers, config parsers, or Dreamux host
|
|
34
|
+
state models.
|
|
35
|
+
|
|
36
|
+
A provider implements the full contract against this package only — see
|
|
37
|
+
`tests/fixtures/external-provider.ts` for a complete `AgentRuntimeProvider`
|
|
38
|
+
(`readConfig` + `getCapabilities` + `createRuntime`) and a `ChannelProvider`
|
|
39
|
+
authored with `@excitedjs/dreamux-types` imports alone.
|
|
40
|
+
|
|
41
|
+
> **Core convergence is in progress.** Dreamux core's own launcher still threads
|
|
42
|
+
> a host-coupled create context internally; converging it onto the neutral
|
|
43
|
+
> public `AgentRuntimeCreateContext` (and deleting the host-coupled variant in
|
|
44
|
+
> `packages/dreamux/src/agent-runtime/types.ts`) is the runtime-split slice's job
|
|
45
|
+
> (issue #209 slice 3). The public target published here is already stable for
|
|
46
|
+
> external and built-in runtime/channel packages to author against.
|
|
47
|
+
|
|
48
|
+
## Build / test
|
|
49
|
+
|
|
50
|
+
Built and tested through the monorepo (rush) path — the only supported install
|
|
51
|
+
path (see [the install-model decision](../../.agents/decisions/install-model.md)).
|
|
52
|
+
From the repo root:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
node common/scripts/install-run-rush.js update
|
|
56
|
+
node common/scripts/install-run-rush.js build
|
|
57
|
+
node common/scripts/install-run-rush.js test
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The design record is
|
|
61
|
+
[`.agents/decisions/npm-package-split-and-channel-targets.md`](../../.agents/decisions/npm-package-split-and-channel-targets.md).
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Runtime provider-authoring contracts (declaration-only).
|
|
3
|
+
*
|
|
4
|
+
* The complete, neutral Agent Runtime provider contract an external runtime
|
|
5
|
+
* package (or a future built-in runtime package such as
|
|
6
|
+
* `@excitedjs/agent-runtime-codex`) implements while importing only
|
|
7
|
+
* `@excitedjs/dreamux-types`. The public create context, runtime handle, state
|
|
8
|
+
* callbacks, and status are deliberately neutral: they never expose Dreamux
|
|
9
|
+
* host-private types (`DispatcherRow`, `DispatcherStore`, `DispatcherStatus`,
|
|
10
|
+
* `DispatcherConfig`, config/state stores, or host path-helper implementations).
|
|
11
|
+
* Dreamux core adapts its private objects into these public shapes.
|
|
12
|
+
*
|
|
13
|
+
* Note on sequencing: Dreamux core's own launcher still threads a host-coupled
|
|
14
|
+
* create context internally; converging that launcher onto this neutral context
|
|
15
|
+
* is the runtime-split slice's job (issue #209 slice 3). This package already
|
|
16
|
+
* publishes the stable public target so external and built-in runtime packages
|
|
17
|
+
* can be authored against it today.
|
|
18
|
+
*/
|
|
19
|
+
import type { DreamuxLogger } from './logger.js';
|
|
20
|
+
import type { AgentRuntimeProviderDescriptor, DreamuxEnvironment, ProviderFactory } from './provider.js';
|
|
21
|
+
import type { InboundDeliveryHooks, InboundDeliveryResult, InboundTurnInput, NoticeInjectionResult, TurnSettledSignal } from './turn.js';
|
|
22
|
+
export interface AgentRuntimeMcpServer {
|
|
23
|
+
name: string;
|
|
24
|
+
command: string;
|
|
25
|
+
args: string[];
|
|
26
|
+
}
|
|
27
|
+
/** The role Dreamux core assigns to a runtime instance. */
|
|
28
|
+
export type AgentRuntimeRole = 'dispatcher' | 'team_leader' | 'teammate' | 'team_member';
|
|
29
|
+
/**
|
|
30
|
+
* A bundled skill source core hands to a runtime. Core selects sources by role;
|
|
31
|
+
* the runtime package owns the mechanics of applying them to its engine.
|
|
32
|
+
*/
|
|
33
|
+
export interface AgentRuntimeSkillSource {
|
|
34
|
+
name: string;
|
|
35
|
+
path: string;
|
|
36
|
+
/**
|
|
37
|
+
* How the runtime should mount `path` into its engine. An open string, not a
|
|
38
|
+
* closed union: a new runtime may define its own layout without a types bump.
|
|
39
|
+
* Standard layouts core emits today are `skill-dir` (a single skill directory,
|
|
40
|
+
* e.g. a Codex `skills/extraRoots` entry) and `claude-skills-parent` (the
|
|
41
|
+
* parent of a `.claude/skills` tree, e.g. a Claude `--add-dir` root). A runtime
|
|
42
|
+
* that does not recognize a layout should ignore that source, not fail.
|
|
43
|
+
*/
|
|
44
|
+
layout: string;
|
|
45
|
+
source: 'dreamux-core' | string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* An open, source-agnostic completion delivery shape. Each runtime self-declares
|
|
49
|
+
* its own `kind` string inside its own capabilities; the shared contract never
|
|
50
|
+
* enumerates them.
|
|
51
|
+
*/
|
|
52
|
+
export interface CompletionDeliveryShape {
|
|
53
|
+
kind: string;
|
|
54
|
+
description: string;
|
|
55
|
+
}
|
|
56
|
+
export interface AgentRuntimeResumeCheckpoint {
|
|
57
|
+
/** Runtime-owned checkpoint kind; each runtime self-declares its own. */
|
|
58
|
+
kind: string;
|
|
59
|
+
id: string;
|
|
60
|
+
}
|
|
61
|
+
export type AgentRuntimeResumeCapability = {
|
|
62
|
+
supported: true;
|
|
63
|
+
checkpoint: AgentRuntimeResumeCheckpoint['kind'];
|
|
64
|
+
} | {
|
|
65
|
+
supported: false;
|
|
66
|
+
};
|
|
67
|
+
export interface AgentRuntimeCapabilities {
|
|
68
|
+
/** Whether this runtime can resume a prior checkpoint, and which checkpoint id it expects. */
|
|
69
|
+
resume: AgentRuntimeResumeCapability;
|
|
70
|
+
/**
|
|
71
|
+
* Whether a follow-up turn delivered while a turn is active folds into that
|
|
72
|
+
* turn rather than queueing behind it. Purely behavioral: there is no separate
|
|
73
|
+
* "steer" method — core still delivers through `channelInput`/`systemInput`,
|
|
74
|
+
* and this flag only tells core whether mid-turn delivery is absorbed.
|
|
75
|
+
*/
|
|
76
|
+
steer: {
|
|
77
|
+
supported: boolean;
|
|
78
|
+
};
|
|
79
|
+
/** How runtime events are surfaced to Dreamux. */
|
|
80
|
+
events: {
|
|
81
|
+
kind: 'push' | 'synthesized';
|
|
82
|
+
};
|
|
83
|
+
/** Whether {@link AgentRuntime.getLast} can report the last result. */
|
|
84
|
+
last: {
|
|
85
|
+
supported: boolean;
|
|
86
|
+
};
|
|
87
|
+
/** Whether {@link AgentRuntime.getContext} can report context-window usage. */
|
|
88
|
+
context: {
|
|
89
|
+
supported: boolean;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* How the launcher-supplied role/system prompt content is applied: `replace`
|
|
93
|
+
* swaps the engine's base instructions, `append` adds to them.
|
|
94
|
+
*/
|
|
95
|
+
systemPrompt: {
|
|
96
|
+
mode: 'replace' | 'append';
|
|
97
|
+
};
|
|
98
|
+
/** Upward delivery shapes this runtime supports for teammate completion. */
|
|
99
|
+
teammateCompletion: readonly CompletionDeliveryShape[];
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* A source-agnostic completion delivered upward to a runtime. `teammate` is one
|
|
103
|
+
* source; `id` identifies the completing entity within that source.
|
|
104
|
+
*/
|
|
105
|
+
export interface CompletionEnvelope {
|
|
106
|
+
source: string;
|
|
107
|
+
id: string;
|
|
108
|
+
status: 'completed' | 'failed' | 'stopped';
|
|
109
|
+
result: string;
|
|
110
|
+
}
|
|
111
|
+
export type TeamMateCompletionDeliveryResult = {
|
|
112
|
+
status: 'accepted';
|
|
113
|
+
} | {
|
|
114
|
+
status: 'unsupported';
|
|
115
|
+
reason: string;
|
|
116
|
+
} | {
|
|
117
|
+
status: 'failed';
|
|
118
|
+
error: Error;
|
|
119
|
+
};
|
|
120
|
+
export interface AgentRuntimeSystemInput {
|
|
121
|
+
kind: 'system';
|
|
122
|
+
text: string;
|
|
123
|
+
reason: 'restart-notice' | 'teammate-completion' | 'runtime-control';
|
|
124
|
+
}
|
|
125
|
+
export interface AgentRuntimeResumeInput {
|
|
126
|
+
checkpoint?: AgentRuntimeResumeCheckpoint | null;
|
|
127
|
+
}
|
|
128
|
+
export interface AgentRuntimeLastResult {
|
|
129
|
+
text: string | null;
|
|
130
|
+
}
|
|
131
|
+
export interface AgentRuntimeContextSnapshot {
|
|
132
|
+
usedTokens: number | null;
|
|
133
|
+
windowTokens: number | null;
|
|
134
|
+
}
|
|
135
|
+
export interface AgentRuntimePathContext {
|
|
136
|
+
/**
|
|
137
|
+
* The per-dispatcher root the runtime drops its own state files into.
|
|
138
|
+
* Neutral: the runtime derives its own subpaths from here. Volatile
|
|
139
|
+
* rendezvous sockets do NOT live here.
|
|
140
|
+
*/
|
|
141
|
+
dispatcherDir(id: string): string;
|
|
142
|
+
/**
|
|
143
|
+
* The central logs root. The runtime composes its OWN log subpaths under this
|
|
144
|
+
* directory (e.g. `<logsDir>/<engine>/<id>.log`), so core never has to name a
|
|
145
|
+
* per-runtime log file. Neutral: a runtime that logs differently lays out its
|
|
146
|
+
* own tree here.
|
|
147
|
+
*/
|
|
148
|
+
logsDir(): string;
|
|
149
|
+
/** The owning dispatcher's completion-spill directory in the cache tree. */
|
|
150
|
+
completionSpillDir(id: string): string;
|
|
151
|
+
/**
|
|
152
|
+
* Candidate directories for volatile rendezvous sockets, in host preference
|
|
153
|
+
* order. A runtime that needs a Unix-domain socket allocates a fresh random
|
|
154
|
+
* short name inside the first candidate whose full path fits the platform
|
|
155
|
+
* socket-path budget (see `@excitedjs/dreamux-utils` `unixSocketPathFitsBudget`).
|
|
156
|
+
* Neutral: a runtime that needs no socket (e.g. a stdio engine) ignores it.
|
|
157
|
+
* Sockets are never persisted and never live under {@link dispatcherDir}.
|
|
158
|
+
*/
|
|
159
|
+
runtimeSocketDirs(): readonly string[];
|
|
160
|
+
}
|
|
161
|
+
export interface AgentRuntimeProviderConfigReadContext {
|
|
162
|
+
providerRef: string;
|
|
163
|
+
/**
|
|
164
|
+
* The `agents[].id` whose config block is being parsed — a config-internal
|
|
165
|
+
* alias, not a dispatcher identity.
|
|
166
|
+
*/
|
|
167
|
+
agentId: string;
|
|
168
|
+
file: string;
|
|
169
|
+
prefix: string;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* A neutral runtime-binary launch descriptor a provider declares for doctor.
|
|
173
|
+
* Pure data — the provider never runs it itself.
|
|
174
|
+
*/
|
|
175
|
+
export interface AgentRuntimeBinCheck {
|
|
176
|
+
name: string;
|
|
177
|
+
bin: string;
|
|
178
|
+
args: string[];
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The neutral result of a provider's own (non-bin) diagnostic pass. `detail` is
|
|
182
|
+
* a one-line summary; `errors` are per-problem lines.
|
|
183
|
+
*/
|
|
184
|
+
export interface AgentRuntimeDoctorResult {
|
|
185
|
+
ok: boolean;
|
|
186
|
+
detail: string;
|
|
187
|
+
errors: string[];
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The minimal command runner a provider's diagnostic needs. A structural subset
|
|
191
|
+
* of the CLI's command runner so the provider never imports host CLI modules.
|
|
192
|
+
*/
|
|
193
|
+
export interface AgentRuntimeDiagnosticRunner {
|
|
194
|
+
check(command: string, args: string[], options?: {
|
|
195
|
+
env?: DreamuxEnvironment;
|
|
196
|
+
}): Promise<boolean>;
|
|
197
|
+
capture(command: string, args: string[], options?: {
|
|
198
|
+
env?: DreamuxEnvironment;
|
|
199
|
+
}): Promise<string>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Neutral runtime status. Mirrors the host's dispatcher lifecycle states without
|
|
203
|
+
* importing the host enum, so a provider can report status without depending on
|
|
204
|
+
* `@excitedjs/dreamux`.
|
|
205
|
+
*/
|
|
206
|
+
export type AgentRuntimeStatus = 'declared' | 'starting' | 'ready' | 'degraded' | 'stopping' | 'stopped';
|
|
207
|
+
/**
|
|
208
|
+
* Neutral state sink the runtime writes status/thread transitions to. Dreamux
|
|
209
|
+
* core adapts its own dispatcher store to this shape; the runtime never sees the
|
|
210
|
+
* host store type.
|
|
211
|
+
*/
|
|
212
|
+
export interface AgentRuntimeStateCallbacks {
|
|
213
|
+
setStatus(id: string, status: AgentRuntimeStatus, extras?: {
|
|
214
|
+
last_error?: string | null;
|
|
215
|
+
last_started_at?: number;
|
|
216
|
+
last_ready_at?: number;
|
|
217
|
+
}): Promise<void>;
|
|
218
|
+
setThreadId(id: string, threadId: string): Promise<void>;
|
|
219
|
+
recordLostThread?(id: string, lostThreadId: string, newThreadId: string, error: string): Promise<void>;
|
|
220
|
+
}
|
|
221
|
+
export type AgentRuntimeTurnResult = InboundDeliveryResult | NoticeInjectionResult;
|
|
222
|
+
/**
|
|
223
|
+
* The neutral, launcher-supplied identity of the runtime instance. Replaces the
|
|
224
|
+
* host's `DispatcherRow` in the public create context: a provider reads only the
|
|
225
|
+
* fields it needs (its own id, an optional resumable checkpoint id) and never
|
|
226
|
+
* the host row.
|
|
227
|
+
*/
|
|
228
|
+
export interface AgentRuntimeIdentity {
|
|
229
|
+
/** The runtime instance id (the dispatcher/teammate id the launcher assigns). */
|
|
230
|
+
runtime_id: string;
|
|
231
|
+
/**
|
|
232
|
+
* A prior resumable checkpoint id the launcher recovered, or null for a fresh
|
|
233
|
+
* start. The runtime interprets it per its own `resume` capability.
|
|
234
|
+
*/
|
|
235
|
+
checkpoint_id?: string | null;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The neutral create context a provider's `createRuntime` receives. Carries the
|
|
239
|
+
* runtime identity, role, parsed provider config, cwd, optional system-prompt
|
|
240
|
+
* content, MCP servers, bundled skill sources, and neutral logger/path/state
|
|
241
|
+
* sinks. It never exposes host dispatcher rows, stores, or config models.
|
|
242
|
+
*/
|
|
243
|
+
export interface AgentRuntimeCreateContext<TConfig = unknown> {
|
|
244
|
+
identity: AgentRuntimeIdentity;
|
|
245
|
+
role: AgentRuntimeRole;
|
|
246
|
+
/** Provider-parsed config (the output of the provider's own `readConfig`). */
|
|
247
|
+
config: TConfig;
|
|
248
|
+
/**
|
|
249
|
+
* The directory the runtime runs in. Always supplied by the launcher; never
|
|
250
|
+
* derived inside the runtime.
|
|
251
|
+
*/
|
|
252
|
+
cwd: string;
|
|
253
|
+
/**
|
|
254
|
+
* Launcher-supplied role/system-prompt content, applied per the runtime's
|
|
255
|
+
* `systemPrompt.mode` capability. Optional: teammate launches may omit it.
|
|
256
|
+
*/
|
|
257
|
+
systemPromptContent?: string;
|
|
258
|
+
/**
|
|
259
|
+
* MCP servers the launcher injects for this runtime instance. Already fully
|
|
260
|
+
* resolved by core: an empty array means "no MCP servers", and the provider
|
|
261
|
+
* must launch exactly these — it must not infer, append, or mutate the list.
|
|
262
|
+
*/
|
|
263
|
+
mcpServers: readonly AgentRuntimeMcpServer[];
|
|
264
|
+
/**
|
|
265
|
+
* Bundled skill sources core selected for this role. Empty for roles that
|
|
266
|
+
* receive no bundled Dreamux skills (ordinary teammate/team-member).
|
|
267
|
+
*/
|
|
268
|
+
skillSources?: readonly AgentRuntimeSkillSource[];
|
|
269
|
+
logger?: DreamuxLogger;
|
|
270
|
+
paths?: AgentRuntimePathContext;
|
|
271
|
+
state?: AgentRuntimeStateCallbacks;
|
|
272
|
+
/**
|
|
273
|
+
* Neutral process-env injection seam. Core merges these entries into the
|
|
274
|
+
* runtime's spawn environment AFTER `process.env` and BEFORE the provider's
|
|
275
|
+
* own `config.extra_env`, i.e. spawn env =
|
|
276
|
+
* `{ ...process.env, ...injectEnv, ...config.extra_env }`. Core owns what (if
|
|
277
|
+
* anything) it injects; `config.extra_env` is the provider's own config and is
|
|
278
|
+
* NOT routed through here. Empty/omitted means "inject nothing" — the common
|
|
279
|
+
* case today.
|
|
280
|
+
*/
|
|
281
|
+
injectEnv?: Record<string, string>;
|
|
282
|
+
/**
|
|
283
|
+
* Fired each time a delivered turn reaches a terminal state. Capability-
|
|
284
|
+
* neutral; the launcher opts in.
|
|
285
|
+
*/
|
|
286
|
+
onTurnSettled?: (settled: TurnSettledSignal) => void;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* The live runtime handle a provider's `createRuntime` returns. Neutral: its
|
|
290
|
+
* status type is {@link AgentRuntimeStatus}, not a host enum.
|
|
291
|
+
*/
|
|
292
|
+
export interface AgentRuntime {
|
|
293
|
+
readonly providerRef: string;
|
|
294
|
+
start(): Promise<void>;
|
|
295
|
+
resume(input?: AgentRuntimeResumeInput): Promise<void>;
|
|
296
|
+
stop(): Promise<void>;
|
|
297
|
+
/** Deliver a channel-inbound turn. */
|
|
298
|
+
channelInput(input: InboundTurnInput, hooks?: InboundDeliveryHooks): Promise<AgentRuntimeTurnResult>;
|
|
299
|
+
/** Inject a system-originated notice (e.g. a restart notice). */
|
|
300
|
+
systemInput(notice: AgentRuntimeSystemInput): Promise<AgentRuntimeTurnResult>;
|
|
301
|
+
getStatus(): AgentRuntimeStatus;
|
|
302
|
+
getThreadId(): string | null;
|
|
303
|
+
wasThreadResumed(): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* The last assistant/user-visible result, or `null` when unavailable.
|
|
306
|
+
* A runtime whose `capabilities.last.supported` is false returns `null`
|
|
307
|
+
* rather than throwing or blocking — core treats `null` as "not reported".
|
|
308
|
+
*/
|
|
309
|
+
getLast(): Promise<AgentRuntimeLastResult | null>;
|
|
310
|
+
/**
|
|
311
|
+
* Context-window usage, or `null` when unavailable. A runtime whose
|
|
312
|
+
* `capabilities.context.supported` is false returns `null` rather than
|
|
313
|
+
* throwing or blocking.
|
|
314
|
+
*/
|
|
315
|
+
getContext(): Promise<AgentRuntimeContextSnapshot | null>;
|
|
316
|
+
getCapabilities(): AgentRuntimeCapabilities;
|
|
317
|
+
/**
|
|
318
|
+
* Deliver a teammate-completion envelope upward. Optional, and feature-detected
|
|
319
|
+
* by presence: a runtime that declares no `capabilities.teammateCompletion`
|
|
320
|
+
* shapes should omit this method entirely rather than ship a throwing/no-op
|
|
321
|
+
* stub, since callers test for the method, not the capability array.
|
|
322
|
+
*/
|
|
323
|
+
completionInput?(completion: CompletionEnvelope): Promise<TeamMateCompletionDeliveryResult>;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Per-runtime diagnostic context. Neutral: it carries the runtime instance id,
|
|
327
|
+
* the provider-parsed config, the resolved env, and the doctor pass `scope`,
|
|
328
|
+
* rather than a host `DispatcherConfig`.
|
|
329
|
+
*/
|
|
330
|
+
export interface AgentRuntimeDiagnosticContext<TConfig = unknown> {
|
|
331
|
+
runtime_id: string;
|
|
332
|
+
config: TConfig;
|
|
333
|
+
env: DreamuxEnvironment;
|
|
334
|
+
scope: 'foreground' | 'managedService';
|
|
335
|
+
/**
|
|
336
|
+
* The same neutral path context the create context carries, supplied by
|
|
337
|
+
* doctor so a provider diagnostic can pre-check placement-sensitive paths
|
|
338
|
+
* (e.g. validate that a runtime socket would fit the platform budget via
|
|
339
|
+
* {@link AgentRuntimePathContext.runtimeSocketDirs}). Optional: a provider
|
|
340
|
+
* with no path-dependent checks ignores it.
|
|
341
|
+
*/
|
|
342
|
+
paths?: AgentRuntimePathContext;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* A provider's self-reported diagnostics: it DECLARES the bin checks doctor
|
|
346
|
+
* should dedup + execute, and RUNS its own non-bin internal checks. Doctor
|
|
347
|
+
* iterates providers and calls these instead of branching on a builtin ref.
|
|
348
|
+
*
|
|
349
|
+
* Optional on {@link AgentRuntimeProvider}: a provider with no diagnostic surface
|
|
350
|
+
* omits it. The host supplies the {@link AgentRuntimeDiagnosticRunner} to
|
|
351
|
+
* `runDiagnostic`; the provider only implements the checks, never the runner.
|
|
352
|
+
*/
|
|
353
|
+
export interface AgentRuntimeDiagnostic<TConfig = unknown> {
|
|
354
|
+
binChecks(context: AgentRuntimeDiagnosticContext<TConfig>): AgentRuntimeBinCheck[];
|
|
355
|
+
runDiagnostic(context: AgentRuntimeDiagnosticContext<TConfig>, runner: AgentRuntimeDiagnosticRunner): Promise<AgentRuntimeDoctorResult>;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The Agent Runtime provider contract. An external or built-in runtime package
|
|
359
|
+
* implements this against `@excitedjs/dreamux-types` only.
|
|
360
|
+
*/
|
|
361
|
+
export interface AgentRuntimeProvider<TConfig = unknown> {
|
|
362
|
+
readonly ref: string;
|
|
363
|
+
readonly descriptor: AgentRuntimeProviderDescriptor;
|
|
364
|
+
getCapabilities(): AgentRuntimeCapabilities;
|
|
365
|
+
/**
|
|
366
|
+
* Parse + validate this provider's own config block. May return synchronously
|
|
367
|
+
* or as a promise; Dreamux core awaits the result, mirroring
|
|
368
|
+
* `ChannelProvider.readConfig`. A parse/validation failure must throw (the host
|
|
369
|
+
* fails loud), never return a partially-valid config.
|
|
370
|
+
*/
|
|
371
|
+
readConfig?(rawConfig: Record<string, unknown>, context: AgentRuntimeProviderConfigReadContext): TConfig | Promise<TConfig>;
|
|
372
|
+
/**
|
|
373
|
+
* Self-reported doctor diagnostics. Optional: a provider with no diagnostic
|
|
374
|
+
* surface may omit it.
|
|
375
|
+
*/
|
|
376
|
+
diagnostic?: AgentRuntimeDiagnostic<TConfig>;
|
|
377
|
+
createRuntime(context: AgentRuntimeCreateContext<TConfig>): AgentRuntime;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* The default (or `npm:pkg#export`-selected) factory export an Agent Runtime
|
|
381
|
+
* package ships. Its {@link ProviderFactoryContext} carries the already-narrowed
|
|
382
|
+
* {@link AgentRuntimeProviderDescriptor}, so the package assigns
|
|
383
|
+
* `provider.descriptor` from the seed without a cast.
|
|
384
|
+
*/
|
|
385
|
+
export type AgentRuntimeProviderFactory<TConfig = unknown> = ProviderFactory<AgentRuntimeProvider<TConfig>, AgentRuntimeProviderDescriptor>;
|
|
386
|
+
/** Re-export so provider packages can take a logger in their own contexts. */
|
|
387
|
+
export type { DreamuxLogger };
|
|
388
|
+
//# sourceMappingURL=agent-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runtime.d.ts","sourceRoot":"","sources":["../src/agent-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EACV,8BAA8B,EAC9B,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,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oB,EAAE,CAAC;IACnF,aAAa,CACX,OAAO,EAAE,6BAA6B,CAAC,OAAO,CAAC,EAC/C,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB,CAAC,OAAO,GAAG,OAAO;IACrD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,8BAA8B,CAAC;IACpD,eAAe,IAAI,wBAAwB,CAAC;IAC5C;;;;;OAKG;IACH,UAAU,CAAC,CACT,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClC,OAAO,EAAE,qCAAqC,GAC7C,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B;;;OAGG;IACH,UAAU,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,aAAa,CAAC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC;CAC1E;AAED;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,CAAC,OAAO,GAAG,OAAO,IAAI,eAAe,CAC1E,oBAAoB,CAAC,OAAO,CAAC,EAC7B,8BAA8B,CAC/B,CAAC;AAEF,8EAA8E;AAC9E,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Channel provider-authoring contracts (declaration-only).
|
|
3
|
+
*
|
|
4
|
+
* The neutral Channel provider seam external channel packages author against.
|
|
5
|
+
* Dreamux core owns binding state, routing, and authorization (binding a channel
|
|
6
|
+
* to a Team is a core Team-MCP capability, not a generic Channel MCP); a channel
|
|
7
|
+
* provider owns platform I/O, provider-specific tools, inbound normalization,
|
|
8
|
+
* target resolution, and message ownership facts.
|
|
9
|
+
*
|
|
10
|
+
* These contracts are forward-looking for the channel-provider slices. They live
|
|
11
|
+
* here because external channel packages must compile against
|
|
12
|
+
* `@excitedjs/dreamux-types` only and must not import `@excitedjs/dreamux`.
|
|
13
|
+
*/
|
|
14
|
+
import type { AgentRuntimeMcpServer } from './agent-runtime.js';
|
|
15
|
+
import type { DreamuxLogger } from './logger.js';
|
|
16
|
+
import type { ChannelProviderDescriptor, ProviderFactory } from './provider.js';
|
|
17
|
+
import type { InboundDeliveryHooks, InboundDeliveryResult, InboundTurnInput } from './turn.js';
|
|
18
|
+
export interface ChannelTarget {
|
|
19
|
+
target_type: string;
|
|
20
|
+
target_key: string;
|
|
21
|
+
bindable: boolean;
|
|
22
|
+
display?: string;
|
|
23
|
+
canonical_url?: string;
|
|
24
|
+
meta?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface ChannelToolDescriptor {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Intentionally unrestricted: Dreamux types must not constrain the tool
|
|
31
|
+
* schemas a provider package exposes.
|
|
32
|
+
*/
|
|
33
|
+
inputSchema?: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface ChannelSender {
|
|
36
|
+
id?: string;
|
|
37
|
+
display?: string;
|
|
38
|
+
meta?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface ChannelInboundEnvelope {
|
|
41
|
+
provider: string;
|
|
42
|
+
channel_id: string;
|
|
43
|
+
target: ChannelTarget;
|
|
44
|
+
event_id?: string;
|
|
45
|
+
message_id?: string;
|
|
46
|
+
sender?: ChannelSender;
|
|
47
|
+
metadata?: Record<string, unknown>;
|
|
48
|
+
}
|
|
49
|
+
export interface ChannelConfigContext {
|
|
50
|
+
dispatcher_id: string;
|
|
51
|
+
channel_id: string;
|
|
52
|
+
provider: string;
|
|
53
|
+
}
|
|
54
|
+
export interface ChannelSessionCreateContext<TConfig = unknown> {
|
|
55
|
+
dispatcher_id: string;
|
|
56
|
+
channel_id: string;
|
|
57
|
+
provider: string;
|
|
58
|
+
config: TConfig;
|
|
59
|
+
logger?: DreamuxLogger;
|
|
60
|
+
state_root?: string;
|
|
61
|
+
cache_root?: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ChannelReplyInput {
|
|
64
|
+
target: ChannelTarget;
|
|
65
|
+
text: string;
|
|
66
|
+
meta?: Record<string, unknown>;
|
|
67
|
+
}
|
|
68
|
+
export interface ChannelReactInput {
|
|
69
|
+
target: ChannelTarget;
|
|
70
|
+
message_id: string;
|
|
71
|
+
reaction: string;
|
|
72
|
+
}
|
|
73
|
+
export interface ChannelToolListContext {
|
|
74
|
+
dispatcher_id: string;
|
|
75
|
+
channel_id: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ChannelToolCall {
|
|
78
|
+
name: string;
|
|
79
|
+
arguments: Record<string, unknown>;
|
|
80
|
+
}
|
|
81
|
+
export interface ChannelToolContext {
|
|
82
|
+
dispatcher_id: string;
|
|
83
|
+
channel_id: string;
|
|
84
|
+
logger?: DreamuxLogger;
|
|
85
|
+
}
|
|
86
|
+
export interface ChannelMessageTargetCheck {
|
|
87
|
+
target: ChannelTarget;
|
|
88
|
+
message_id: string;
|
|
89
|
+
meta?: Record<string, unknown>;
|
|
90
|
+
}
|
|
91
|
+
export interface ChannelRoutes {
|
|
92
|
+
/**
|
|
93
|
+
* Deliver a normalized inbound to Dreamux core. The channel session supplies
|
|
94
|
+
* the neutral turn {@link InboundTurnInput} (text/body/attrs/attachments it
|
|
95
|
+
* normalized) plus the routing/identity {@link ChannelInboundEnvelope}; core
|
|
96
|
+
* dedupes (on `input.sourceId`), submits the turn, and returns the neutral
|
|
97
|
+
* {@link InboundDeliveryResult} — the channel session keys its own
|
|
98
|
+
* reaction/ack ledger off the `submitted` turn id. `hooks.onAccepted` (if
|
|
99
|
+
* given) fires after dedupe accepts and before submit, so the channel can mark
|
|
100
|
+
* the message received. A channel inbound never yields `'skipped'` (that is a
|
|
101
|
+
* notice-only state), so the union is exactly the inbound-delivery one.
|
|
102
|
+
*/
|
|
103
|
+
deliver(input: InboundTurnInput, envelope: ChannelInboundEnvelope, hooks?: InboundDeliveryHooks): Promise<InboundDeliveryResult>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The context core passes to {@link ChannelSession.mcpServerDescriptor}. Carries
|
|
107
|
+
* the host bin command + admin-socket path the channel's stdio MCP shim forwards
|
|
108
|
+
* to, plus the caller identity so the descriptor can scope its tool calls. The
|
|
109
|
+
* provider builds its own stdio descriptor from these neutral pieces; core never
|
|
110
|
+
* names the channel's tool transport.
|
|
111
|
+
*/
|
|
112
|
+
export interface ChannelMcpDescriptorContext {
|
|
113
|
+
/** The Dreamux bin command the channel's MCP shim is spawned as. */
|
|
114
|
+
command: string;
|
|
115
|
+
/** The admin Unix-socket path the shim forwards tool calls to. */
|
|
116
|
+
adminSocketPath: string;
|
|
117
|
+
dispatcher_id: string;
|
|
118
|
+
/** Which agent role hosts the MCP server (scopes the shim's admin calls). */
|
|
119
|
+
callerKind?: 'dispatcher' | 'team_leader';
|
|
120
|
+
team_id?: string;
|
|
121
|
+
leader_name?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The context core passes to {@link ChannelProvider.handleSessionlessTool}. A
|
|
125
|
+
* sessionless tool runs without a live {@link ChannelSession} (e.g. listing the
|
|
126
|
+
* bots in a chat before any binding exists), so it gets only neutral host
|
|
127
|
+
* locators, never a session handle.
|
|
128
|
+
*/
|
|
129
|
+
export interface ChannelSessionlessToolContext {
|
|
130
|
+
dispatcher_id: string;
|
|
131
|
+
/** The per-dispatcher state root the provider may read credentials/state from. */
|
|
132
|
+
state_root?: string;
|
|
133
|
+
logger?: DreamuxLogger;
|
|
134
|
+
}
|
|
135
|
+
export interface ChannelSession {
|
|
136
|
+
readonly provider: string;
|
|
137
|
+
readonly channel_id: string;
|
|
138
|
+
start(routes: ChannelRoutes): Promise<void>;
|
|
139
|
+
close(): Promise<void>;
|
|
140
|
+
resolveTarget(meta: unknown): Promise<ChannelTarget>;
|
|
141
|
+
/** Send a reply. Omit entirely if the platform has no outbound reply path. */
|
|
142
|
+
reply?(input: ChannelReplyInput): Promise<unknown>;
|
|
143
|
+
/** Add a reaction. Omit entirely if the platform has no reaction surface. */
|
|
144
|
+
react?(input: ChannelReactInput): Promise<unknown>;
|
|
145
|
+
/** Provider-specific MCP tools. Omit if the provider exposes none. */
|
|
146
|
+
tools?(context: ChannelToolListContext): readonly ChannelToolDescriptor[];
|
|
147
|
+
/**
|
|
148
|
+
* Handle a provider-specific tool call. Omit when `tools` is omitted; the two
|
|
149
|
+
* go together. These optional members are absent, not no-op stubs, when the
|
|
150
|
+
* platform does not support them — core feature-detects by presence.
|
|
151
|
+
*/
|
|
152
|
+
handleTool?(call: ChannelToolCall, context: ChannelToolContext): Promise<unknown>;
|
|
153
|
+
/** Decide message ownership for routing. Omit if the platform cannot. */
|
|
154
|
+
messageBelongsToTarget?(input: ChannelMessageTargetCheck): boolean | Promise<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* Build the stdio MCP server descriptor that backs this channel's
|
|
157
|
+
* provider-specific tools for a runtime. Returns `null` when the channel
|
|
158
|
+
* exposes no MCP surface for the given caller. Omit entirely if the channel
|
|
159
|
+
* never exposes one. The descriptor is an {@link AgentRuntimeMcpServer} so a
|
|
160
|
+
* runtime can launch it through the same neutral MCP-server seam as any other.
|
|
161
|
+
*/
|
|
162
|
+
mcpServerDescriptor?(context: ChannelMcpDescriptorContext): AgentRuntimeMcpServer | null;
|
|
163
|
+
}
|
|
164
|
+
export interface ChannelProvider<TConfig = unknown> {
|
|
165
|
+
readonly ref: string;
|
|
166
|
+
readonly descriptor: ChannelProviderDescriptor;
|
|
167
|
+
readConfig?(raw: unknown, context: ChannelConfigContext): TConfig | Promise<TConfig>;
|
|
168
|
+
createSession(context: ChannelSessionCreateContext<TConfig>): ChannelSession;
|
|
169
|
+
/**
|
|
170
|
+
* Self-report a neutral, opaque channel identity for this config (e.g. the
|
|
171
|
+
* bot app id). Core stores and displays the string but never interprets it,
|
|
172
|
+
* so it never has to name a provider config field. Omit if the channel has no
|
|
173
|
+
* stable identity to report.
|
|
174
|
+
*/
|
|
175
|
+
getIdentity?(config: TConfig): string;
|
|
176
|
+
/**
|
|
177
|
+
* Handle a tool call that has no live {@link ChannelSession} (e.g. a discovery
|
|
178
|
+
* tool used before any binding exists). Omit when the channel exposes no
|
|
179
|
+
* sessionless tools. Feature-detected by presence.
|
|
180
|
+
*/
|
|
181
|
+
handleSessionlessTool?(name: string, args: Record<string, unknown>, context: ChannelSessionlessToolContext): Promise<unknown>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The default (or `npm:pkg#export`-selected) factory export a Channel package
|
|
185
|
+
* ships. Its {@link ProviderFactoryContext} carries the already-narrowed
|
|
186
|
+
* {@link ChannelProviderDescriptor}, so the package assigns `provider.descriptor`
|
|
187
|
+
* from the seed without a cast.
|
|
188
|
+
*/
|
|
189
|
+
export type ChannelProviderFactory<TConfig = unknown> = ProviderFactory<ChannelProvider<TConfig>, ChannelProviderDescriptor>;
|
|
190
|
+
//# sourceMappingURL=channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.d.ts","sourceRoot":"","sources":["../src/channel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EACV,yBAAyB,EACzB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,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,OAAO,CAAC,CAAC;IAC9B,aAAa,CAAC,OAAO,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC;IAC7E;;;;;OAKG;IACH,WAAW,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC;IACtC;;;;OAIG;IACH,qBAAqB,CAAC,CACpB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,CAAC,OAAO,GAAG,OAAO,IAAI,eAAe,CACrE,eAAe,CAAC,OAAO,CAAC,EACxB,yBAAyB,CAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @excitedjs/dreamux-types
|
|
3
|
+
*
|
|
4
|
+
* Declaration-only provider-authoring contracts for Dreamux. External Agent
|
|
5
|
+
* Runtime and Channel providers import Dreamux contracts from this package and
|
|
6
|
+
* must not import `@excitedjs/dreamux`.
|
|
7
|
+
*
|
|
8
|
+
* This package emits declarations only: there is no runtime JS contract surface
|
|
9
|
+
* and no runtime dependencies. See
|
|
10
|
+
* `.agents/decisions/npm-package-split-and-channel-targets.md`.
|
|
11
|
+
*
|
|
12
|
+
* Root-export policy (issue #209): the root aggregates every public contract
|
|
13
|
+
* type so an external provider author can name any of them directly. A type
|
|
14
|
+
* being reached only *contextually* today — through a property of one of these
|
|
15
|
+
* interfaces or an implemented method's parameter — is not a reason to hide it:
|
|
16
|
+
* the package is type-only, so re-exporting a public type costs nothing at
|
|
17
|
+
* runtime and keeps the surface honest (a provider author can name a shape they
|
|
18
|
+
* legitimately depend on). The `exports` map publishes only this root, so this
|
|
19
|
+
* list IS the public API. `tests/root-exports.test.ts` locks the surface to the
|
|
20
|
+
* full set of public types in the source modules so future slices grow it
|
|
21
|
+
* deliberately, not by accident.
|
|
22
|
+
*/
|
|
23
|
+
export type { DreamuxLogger } from './logger.js';
|
|
24
|
+
export type { AgentRuntimeProviderDescriptor, BuiltinProviderRef, ChannelProviderDescriptor, DreamuxEnvironment, NpmProviderRef, ProviderDescriptor, ProviderFactory, ProviderFactoryContext, ProviderKind, ProviderRef, ProviderRefSource, } from './provider.js';
|
|
25
|
+
export type { InboundAttachment, InboundDeliveryHooks, InboundDeliveryResult, InboundTurnInput, NoticeInjectionResult, TurnSettledSignal, } from './turn.js';
|
|
26
|
+
export type { AgentRuntime, AgentRuntimeBinCheck, AgentRuntimeCapabilities, AgentRuntimeContextSnapshot, AgentRuntimeCreateContext, AgentRuntimeDiagnostic, AgentRuntimeDiagnosticContext, AgentRuntimeDiagnosticRunner, AgentRuntimeDoctorResult, AgentRuntimeIdentity, AgentRuntimeLastResult, AgentRuntimeMcpServer, AgentRuntimePathContext, AgentRuntimeProvider, AgentRuntimeProviderConfigReadContext, AgentRuntimeProviderFactory, AgentRuntimeResumeCapability, AgentRuntimeResumeCheckpoint, AgentRuntimeResumeInput, AgentRuntimeRole, AgentRuntimeSkillSource, AgentRuntimeStateCallbacks, AgentRuntimeStatus, AgentRuntimeSystemInput, AgentRuntimeTurnResult, CompletionDeliveryShape, CompletionEnvelope, TeamMateCompletionDeliveryResult, } from './agent-runtime.js';
|
|
27
|
+
export type { ChannelConfigContext, ChannelInboundEnvelope, ChannelMcpDescriptorContext, ChannelMessageTargetCheck, ChannelProvider, ChannelProviderFactory, ChannelReactInput, ChannelReplyInput, ChannelRoutes, ChannelSender, ChannelSession, ChannelSessionCreateContext, ChannelSessionlessToolContext, ChannelTarget, ChannelToolCall, ChannelToolContext, ChannelToolDescriptor, ChannelToolListContext, } from './channel.js';
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EACV,8BAA8B,EAC9B,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,sBAAsB,EACtB,6BAA6B,EAC7B,4BAA4B,EAC5B,wBAAwB,EACxB,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,qCAAqC,EACrC,2BAA2B,EAC3B,4BAA4B,EAC5B,4BAA4B,EAC5B,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,gCAAgC,GACjC,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,2BAA2B,EAC3B,6BAA6B,EAC7B,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,cAAc,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal public logger contract for provider packages.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally smaller than pino: a provider authored against
|
|
5
|
+
* `@excitedjs/dreamux-types` depends only on this shape. Dreamux core adapts
|
|
6
|
+
* its own logger to this contract; provider packages own their minimal console
|
|
7
|
+
* fallback when core passes no logger. That fallback is implementation code and
|
|
8
|
+
* does not belong in this declaration-only package.
|
|
9
|
+
*/
|
|
10
|
+
export interface DreamuxLogger {
|
|
11
|
+
error(message: string, fields?: Record<string, unknown>): void;
|
|
12
|
+
warn(message: string, fields?: Record<string, unknown>): void;
|
|
13
|
+
info(message: string, fields?: Record<string, unknown>): void;
|
|
14
|
+
debug(message: string, fields?: Record<string, unknown>): void;
|
|
15
|
+
trace(message: string, fields?: Record<string, unknown>): void;
|
|
16
|
+
child?(fields: Record<string, unknown>): DreamuxLogger;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC/D,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAAC;CACxD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider reference and descriptor shapes.
|
|
3
|
+
*
|
|
4
|
+
* Declaration-only structural contracts shared between Dreamux core and external
|
|
5
|
+
* provider packages. Parsing, validation, and the in-process registry are
|
|
6
|
+
* runtime concerns owned by `@excitedjs/dreamux`; this package exposes only the
|
|
7
|
+
* shapes so providers can be authored without depending on the host.
|
|
8
|
+
*/
|
|
9
|
+
/** Where a provider's implementation comes from. */
|
|
10
|
+
export type ProviderRefSource = 'builtin' | 'npm';
|
|
11
|
+
/** A bundled, first-party provider selected by id, e.g. `builtin:codex`. */
|
|
12
|
+
export interface BuiltinProviderRef {
|
|
13
|
+
source: 'builtin';
|
|
14
|
+
/** Bundled provider id, e.g. `codex` or `claude-code`. */
|
|
15
|
+
id: string;
|
|
16
|
+
/** The original, canonical string form. */
|
|
17
|
+
raw: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An external provider selected by npm package, optionally narrowed to a named
|
|
21
|
+
* export.
|
|
22
|
+
*/
|
|
23
|
+
export interface NpmProviderRef {
|
|
24
|
+
source: 'npm';
|
|
25
|
+
/** npm package name, e.g. `@example/dreamux-provider` or `some-provider`. */
|
|
26
|
+
package: string;
|
|
27
|
+
/** Named export within the package, or null for the package default. */
|
|
28
|
+
export: string | null;
|
|
29
|
+
/** The original, canonical string form. */
|
|
30
|
+
raw: string;
|
|
31
|
+
}
|
|
32
|
+
export type ProviderRef = BuiltinProviderRef | NpmProviderRef;
|
|
33
|
+
/** Kinds of provider the registry can hold. */
|
|
34
|
+
export type ProviderKind = 'channel' | 'agentRuntime';
|
|
35
|
+
/** A registered provider descriptor. Capabilities live on provider instances. */
|
|
36
|
+
export interface ProviderDescriptor {
|
|
37
|
+
/** Stable registry id; builtin providers use their builtin id. */
|
|
38
|
+
id: string;
|
|
39
|
+
kind: ProviderKind;
|
|
40
|
+
ref: ProviderRef;
|
|
41
|
+
}
|
|
42
|
+
/** A descriptor narrowed to the Agent Runtime kind. */
|
|
43
|
+
export type AgentRuntimeProviderDescriptor = ProviderDescriptor & {
|
|
44
|
+
kind: 'agentRuntime';
|
|
45
|
+
};
|
|
46
|
+
/** A descriptor narrowed to the Channel kind. */
|
|
47
|
+
export type ChannelProviderDescriptor = ProviderDescriptor & {
|
|
48
|
+
kind: 'channel';
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A Dreamux-owned environment map: variable name → value (or `undefined` when
|
|
52
|
+
* unset). Declaration-only and host-neutral so provider packages never reference
|
|
53
|
+
* a Node process-env typings global in their public surface — this is the
|
|
54
|
+
* sanctioned neutral env shape (issue #209 public-types audit, P0).
|
|
55
|
+
*/
|
|
56
|
+
export type DreamuxEnvironment = Record<string, string | undefined>;
|
|
57
|
+
/**
|
|
58
|
+
* The context Dreamux core hands a provider package's factory export. Mirrors the
|
|
59
|
+
* core loader's call exactly — the canonical `ref` and the seed `descriptor` the
|
|
60
|
+
* provider must echo back on its own `descriptor`. `TDescriptor` lets kind-
|
|
61
|
+
* specific factory aliases carry the already-narrowed descriptor kind.
|
|
62
|
+
*/
|
|
63
|
+
export interface ProviderFactoryContext<TDescriptor extends ProviderDescriptor = ProviderDescriptor> {
|
|
64
|
+
/** Canonical provider ref, e.g. `npm:some-pkg#provider` or `builtin:codex`. */
|
|
65
|
+
ref: string;
|
|
66
|
+
/** Seed descriptor the provider must echo back on its own `descriptor`. */
|
|
67
|
+
descriptor: TDescriptor;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A provider package's factory export (default export, or the named export a
|
|
71
|
+
* `npm:pkg#export` ref selects). Dreamux core invokes it with a
|
|
72
|
+
* {@link ProviderFactoryContext} and registers the returned provider.
|
|
73
|
+
*/
|
|
74
|
+
export type ProviderFactory<TProvider, TDescriptor extends ProviderDescriptor = ProviderDescriptor> = (context: ProviderFactoryContext<TDescriptor>) => TProvider | Promise<TProvider>;
|
|
75
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oDAAoD;AACpD,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,KAAK,CAAC;AAElD,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,SAAS,CAAC;IAClB,0DAA0D;IAC1D,EAAE,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,KAAK,CAAC;IACd,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,cAAc,CAAC;AAE9D,+CAA+C;AAC/C,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,cAAc,CAAC;AAEtD,iFAAiF;AACjF,MAAM,WAAW,kBAAkB;IACjC,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,GAAG,EAAE,WAAW,CAAC;CAClB;AAED,uDAAuD;AACvD,MAAM,MAAM,8BAA8B,GAAG,kBAAkB,GAAG;IAChE,IAAI,EAAE,cAAc,CAAC;CACtB,CAAC;AAEF,iDAAiD;AACjD,MAAM,MAAM,yBAAyB,GAAG,kBAAkB,GAAG;IAC3D,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB,CACrC,WAAW,SAAS,kBAAkB,GAAG,kBAAkB;IAE3D,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,UAAU,EAAE,WAAW,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,CACzB,SAAS,EACT,WAAW,SAAS,kBAAkB,GAAG,kBAAkB,IACzD,CACF,OAAO,EAAE,sBAAsB,CAAC,WAAW,CAAC,KACzC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
package/dist/turn.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neutral inbound-turn contract declarations.
|
|
3
|
+
*
|
|
4
|
+
* Declaration-only subset of the core turn contract: the data shapes a provider
|
|
5
|
+
* package needs to author against. The runtime helpers (`renderChannelInput`,
|
|
6
|
+
* the dedupe-window constant) stay in `@excitedjs/dreamux` because they are
|
|
7
|
+
* executable code, not declarations.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A channel-supplied attachment, in a neutral shape (no channel-typed field
|
|
11
|
+
* names). Passed through to the runtime so a runtime can render attachments its
|
|
12
|
+
* own way.
|
|
13
|
+
*/
|
|
14
|
+
export interface InboundAttachment {
|
|
15
|
+
/** Opaque media kind the channel assigns, e.g. `image` | `file`. */
|
|
16
|
+
kind: string;
|
|
17
|
+
/** Display name when the channel knows one. */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Local filesystem path when the channel downloaded the resource; absent otherwise. */
|
|
20
|
+
localPath?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface InboundTurnInput {
|
|
23
|
+
/** The turn text to deliver to the agent (used when no channel body is set). */
|
|
24
|
+
text: string;
|
|
25
|
+
/**
|
|
26
|
+
* Stable dedupe / correlation id for this inbound. An empty string disables
|
|
27
|
+
* dedupe.
|
|
28
|
+
*/
|
|
29
|
+
sourceId: string;
|
|
30
|
+
/**
|
|
31
|
+
* Opaque channel-source label (e.g. `feishu`), rendered as the
|
|
32
|
+
* `<channel source="…">` attribute. Data, not a typed concept.
|
|
33
|
+
*/
|
|
34
|
+
source?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Opaque display attributes rendered verbatim into the runtime's channel
|
|
37
|
+
* block. The runtime MUST NOT interpret or route on them.
|
|
38
|
+
*/
|
|
39
|
+
attrs?: Array<[string, string]>;
|
|
40
|
+
/** Pre-rendered, already-escaped message body the runtime wraps into its channel block. */
|
|
41
|
+
body?: string;
|
|
42
|
+
/** Structured attachments for future per-runtime rendering. */
|
|
43
|
+
attachments?: readonly InboundAttachment[];
|
|
44
|
+
}
|
|
45
|
+
export type InboundDeliveryResult = {
|
|
46
|
+
status: 'duplicate';
|
|
47
|
+
} | {
|
|
48
|
+
status: 'stopped';
|
|
49
|
+
} | {
|
|
50
|
+
status: 'submitted';
|
|
51
|
+
turnId: string;
|
|
52
|
+
} | {
|
|
53
|
+
status: 'failed';
|
|
54
|
+
error: Error;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Result of a best-effort restart-notice injection. `skipped` means a real
|
|
58
|
+
* inbound had already been handed to the runtime.
|
|
59
|
+
*/
|
|
60
|
+
export type NoticeInjectionResult = {
|
|
61
|
+
status: 'stopped';
|
|
62
|
+
} | {
|
|
63
|
+
status: 'skipped';
|
|
64
|
+
} | {
|
|
65
|
+
status: 'submitted';
|
|
66
|
+
turnId: string;
|
|
67
|
+
} | {
|
|
68
|
+
status: 'failed';
|
|
69
|
+
error: Error;
|
|
70
|
+
};
|
|
71
|
+
export interface InboundDeliveryHooks {
|
|
72
|
+
/**
|
|
73
|
+
* Called after process-local dedupe accepts the message and before the turn
|
|
74
|
+
* is submitted.
|
|
75
|
+
*/
|
|
76
|
+
onAccepted?: (input: InboundTurnInput) => void | Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A neutral "turn settled" signal: a delivered turn reached a terminal state.
|
|
80
|
+
* Capability-neutral — carries no channel or runtime specifics.
|
|
81
|
+
*/
|
|
82
|
+
export interface TurnSettledSignal {
|
|
83
|
+
turnId: string | null;
|
|
84
|
+
status: 'completed' | 'failed' | 'stopped';
|
|
85
|
+
error?: Error;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=turn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn.d.ts","sourceRoot":"","sources":["../src/turn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChC,2FAA2F;IAC3F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC5C;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GACvB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACvC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEvC,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@excitedjs/dreamux-types",
|
|
3
|
+
"version": "0.2.0-alpha.g0ddd418597ca",
|
|
4
|
+
"description": "Declaration-only provider-authoring contracts for Dreamux: Agent Runtime and Channel provider types external providers compile against without depending on @excitedjs/dreamux (issue excitedjs/dreamux#209).",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/excitedjs/dreamux.git",
|
|
9
|
+
"directory": "packages/dreamux-types"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=22.7"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.10.0",
|
|
28
|
+
"eslint": "^9.39.0",
|
|
29
|
+
"typescript": "^5.7.0",
|
|
30
|
+
"vitest": "^2.1.0",
|
|
31
|
+
"@excitedjs/eslint-config": "0.0.0"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.json",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
36
|
+
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
|
37
|
+
"lint": "eslint .",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:watch": "vitest",
|
|
40
|
+
"clean": "rm -rf dist"
|
|
41
|
+
}
|
|
42
|
+
}
|