@bastani/atomic 0.8.24-alpha.1 → 0.8.24-alpha.2

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.
@@ -1,410 +0,0 @@
1
- /*
2
- * Type-only package authoring surface for standalone workflow packages.
3
- *
4
- * package.json points the root "types" condition here so authors can import
5
- * defineWorkflow and Type without pulling the Atomic runtime/extension graph into
6
- * their TypeScript program. Runtime loading still uses src/index.ts.
7
- */
8
-
9
- import type {
10
- TAny,
11
- TArray,
12
- TArrayOptions,
13
- TBigInt,
14
- TBoolean,
15
- TEnum,
16
- TEnumValue,
17
- TInteger,
18
- TIntersect,
19
- TIntersectOptions,
20
- TLiteral,
21
- TLiteralValue,
22
- TNever,
23
- TNull,
24
- TNumber,
25
- TNumberOptions,
26
- TOmit,
27
- TObject,
28
- TObjectOptions,
29
- TPartial,
30
- TPick,
31
- TRecordAction,
32
- TRequired,
33
- TSchema,
34
- TSchemaOptions,
35
- TString,
36
- TStringOptions,
37
- TTuple,
38
- TTupleOptions,
39
- TUndefined,
40
- TUnion,
41
- TUnknown,
42
- TVoid,
43
- Type as TypeboxType,
44
- TKeysToIndexer,
45
- } from "typebox";
46
-
47
- type PreserveOptions<T extends TSchema, O extends TSchemaOptions> = T & O;
48
- type TypeScriptEnumLike = Record<string, string | number>;
49
- type TypeScriptEnumValues<T extends TypeScriptEnumLike> = Extract<T[keyof T], TEnumValue>[];
50
-
51
- export declare const Type: Omit<
52
- typeof TypeboxType,
53
- | "Any"
54
- | "Array"
55
- | "BigInt"
56
- | "Boolean"
57
- | "Enum"
58
- | "Integer"
59
- | "Intersect"
60
- | "Literal"
61
- | "Never"
62
- | "Null"
63
- | "Number"
64
- | "Omit"
65
- | "Partial"
66
- | "Pick"
67
- | "Object"
68
- | "Record"
69
- | "Required"
70
- | "String"
71
- | "Tuple"
72
- | "Undefined"
73
- | "Union"
74
- | "Unknown"
75
- | "Void"
76
- > & {
77
- Any<const O extends TSchemaOptions>(options: O): PreserveOptions<TAny, O>;
78
- Any(): TAny;
79
- Array<Type extends TSchema, const O extends TArrayOptions>(items: Type, options: O): PreserveOptions<TArray<Type>, O>;
80
- Array<Type extends TSchema>(items: Type): TArray<Type>;
81
- BigInt<const O extends TSchemaOptions>(options: O): PreserveOptions<TBigInt, O>;
82
- BigInt(): TBigInt;
83
- Boolean<const O extends TSchemaOptions>(options: O): PreserveOptions<TBoolean, O>;
84
- Boolean(): TBoolean;
85
- Enum<Values extends TEnumValue[], const O extends TSchemaOptions>(values: readonly [...Values], options: O): PreserveOptions<TEnum<Values>, O>;
86
- Enum<Values extends TEnumValue[]>(values: readonly [...Values]): TEnum<Values>;
87
- Enum<Enum extends TypeScriptEnumLike, const O extends TSchemaOptions>(value: Enum, options: O): PreserveOptions<TEnum<TypeScriptEnumValues<Enum>>, O>;
88
- Enum<Enum extends TypeScriptEnumLike>(value: Enum): TEnum<TypeScriptEnumValues<Enum>>;
89
- Integer<const O extends TNumberOptions>(options: O): PreserveOptions<TInteger, O>;
90
- Integer(): TInteger;
91
- Intersect<Types extends TSchema[], const O extends TIntersectOptions>(types: [...Types], options: O): PreserveOptions<TIntersect<Types>, O>;
92
- Intersect<Types extends TSchema[]>(types: [...Types]): TIntersect<Types>;
93
- Literal<const Value extends TLiteralValue, const O extends TSchemaOptions>(value: Value, options: O): PreserveOptions<TLiteral<Value>, O>;
94
- Literal<const Value extends TLiteralValue>(value: Value): TLiteral<Value>;
95
- Never<const O extends TSchemaOptions>(options: O): PreserveOptions<TNever, O>;
96
- Never(): TNever;
97
- Null<const O extends TSchemaOptions>(options: O): PreserveOptions<TNull, O>;
98
- Null(): TNull;
99
- Number<const O extends TNumberOptions>(options: O): PreserveOptions<TNumber, O>;
100
- Number(): TNumber;
101
- Omit<Type extends TSchema, Indexer extends PropertyKey[], const O extends TSchemaOptions>(type: Type, indexer: readonly [...Indexer], options: O): PreserveOptions<TOmit<Type, TKeysToIndexer<Indexer>>, O>;
102
- Omit<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer]): TOmit<Type, TKeysToIndexer<Indexer>>;
103
- Omit<Type extends TSchema, Indexer extends TSchema, const O extends TSchemaOptions>(type: Type, indexer: Indexer, options: O): PreserveOptions<TOmit<Type, Indexer>, O>;
104
- Omit<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer): TOmit<Type, Indexer>;
105
- Partial<Type extends TSchema, const O extends TSchemaOptions>(type: Type, options: O): PreserveOptions<TPartial<Type>, O>;
106
- Partial<Type extends TSchema>(type: Type): TPartial<Type>;
107
- Pick<Type extends TSchema, Indexer extends PropertyKey[], const O extends TSchemaOptions>(type: Type, indexer: readonly [...Indexer], options: O): PreserveOptions<TPick<Type, TKeysToIndexer<Indexer>>, O>;
108
- Pick<Type extends TSchema, Indexer extends PropertyKey[]>(type: Type, indexer: readonly [...Indexer]): TPick<Type, TKeysToIndexer<Indexer>>;
109
- Pick<Type extends TSchema, Indexer extends TSchema, const O extends TSchemaOptions>(type: Type, indexer: Indexer, options: O): PreserveOptions<TPick<Type, Indexer>, O>;
110
- Pick<Type extends TSchema, Indexer extends TSchema>(type: Type, indexer: Indexer): TPick<Type, Indexer>;
111
- Object<Properties extends Record<PropertyKey, TSchema>, const O extends TObjectOptions>(properties: Properties, options: O): PreserveOptions<TObject<Properties>, O>;
112
- Object<Properties extends Record<PropertyKey, TSchema>>(properties: Properties): TObject<Properties>;
113
- Record<Key extends TSchema, Value extends TSchema, const O extends TObjectOptions>(key: Key, value: Value, options: O): PreserveOptions<TRecordAction<Key, Value>, O>;
114
- Record<Key extends TSchema, Value extends TSchema>(key: Key, value: Value): TRecordAction<Key, Value>;
115
- Required<Type extends TSchema, const O extends TSchemaOptions>(type: Type, options: O): PreserveOptions<TRequired<Type>, O>;
116
- Required<Type extends TSchema>(type: Type): TRequired<Type>;
117
- String<const O extends TStringOptions>(options: O): PreserveOptions<TString, O>;
118
- String(): TString;
119
- Tuple<Types extends TSchema[], const O extends TTupleOptions>(types: [...Types], options: O): PreserveOptions<TTuple<Types>, O>;
120
- Tuple<Types extends TSchema[]>(types: [...Types]): TTuple<Types>;
121
- Undefined<const O extends TSchemaOptions>(options: O): PreserveOptions<TUndefined, O>;
122
- Undefined(): TUndefined;
123
- Union<Types extends TSchema[], const O extends TSchemaOptions>(anyOf: [...Types], options: O): PreserveOptions<TUnion<Types>, O>;
124
- Union<Types extends TSchema[]>(anyOf: [...Types]): TUnion<Types>;
125
- Unknown<const O extends TSchemaOptions>(options: O): PreserveOptions<TUnknown, O>;
126
- Unknown(): TUnknown;
127
- Void<const O extends TSchemaOptions>(options: O): PreserveOptions<TVoid, O>;
128
- Void(): TVoid;
129
- };
130
- export type { Static, TSchema } from "typebox";
131
-
132
- export type {
133
- AgentSessionAdapter,
134
- CompleteAdapter,
135
- CompleteStageOpts,
136
- GitWorktreeSetupOptions,
137
- GitWorktreeSetupResult,
138
- PromptAdapter,
139
- PromptOptions,
140
- ResolvedInputs,
141
- RunResult,
142
- RunStatus,
143
- StageAdapters,
144
- StageStatus,
145
- StageOptions,
146
- StageContext,
147
- StageSnapshot,
148
- StageExecutionMeta,
149
- StageMcpOptions,
150
- StageOutputOptions,
151
- StagePromptOptions,
152
- StageSessionCreateOptions,
153
- StageSessionCreateResult,
154
- StageSessionRuntime,
155
- WorkflowAction,
156
- WorkflowArtifact,
157
- WorkflowChainOptions,
158
- WorkflowChainStep,
159
- WorkflowChildResult,
160
- WorkflowContextMode,
161
- WorkflowControlEvent,
162
- WorkflowCustomToolDefinition,
163
- WorkflowDetails,
164
- WorkflowDetailsMode,
165
- WorkflowDetailsStatus,
166
- WorkflowDirectOptions,
167
- WorkflowDirectTaskItem,
168
- WorkflowExecutionMode,
169
- WorkflowExecutionPolicy,
170
- WorkflowInputBindings,
171
- WorkflowInputSchema,
172
- WorkflowInputSchemaMap,
173
- WorkflowInputValues,
174
- WorkflowIntercomSummary,
175
- WorkflowMaxOutput,
176
- WorkflowMcpPort,
177
- WorkflowModelAttempt,
178
- WorkflowModelCatalogPort,
179
- WorkflowModelFallbackFields,
180
- WorkflowModelInfo,
181
- WorkflowModelUsage,
182
- WorkflowModelValue,
183
- WorkflowOutputMode,
184
- WorkflowOutputSchema,
185
- WorkflowOutputSchemaMap,
186
- WorkflowOutputValues,
187
- WorkflowParallelChainStep,
188
- WorkflowParallelOptions,
189
- WorkflowPersistencePort,
190
- WorkflowProgressSummary,
191
- WorkflowRunChildOptions,
192
- WorkflowRunOutput,
193
- WorkflowRuntimeConfig,
194
- WorkflowSerializableObject,
195
- WorkflowSerializablePrimitive,
196
- WorkflowSerializableValue,
197
- WorkflowSharedTaskDefaults,
198
- WorkflowTaskContext,
199
- WorkflowTaskContextInput,
200
- WorkflowTaskOptions,
201
- WorkflowTaskResult,
202
- WorkflowTaskSessionFields,
203
- WorkflowTaskSessionOptions,
204
- WorkflowTaskStep,
205
- WorkflowThinkingLevel,
206
- WorkflowUIAdapter,
207
- WorkflowUIContext,
208
- WorkflowWorktreeInputBinding,
209
- } from "./shared/authoring-contract.js";
210
-
211
- import type * as AuthoringContract from "./shared/authoring-contract.js";
212
-
213
- import type {
214
- GitWorktreeSetupOptions,
215
- GitWorktreeSetupResult,
216
- ResolvedInputs,
217
- RunResult,
218
- RunStatus,
219
- StageSnapshot,
220
- WorkflowDefinition as WorkflowContractDefinition,
221
- WorkflowDetails,
222
- WorkflowDirectOptions,
223
- WorkflowDirectTaskItem,
224
- WorkflowExecutionPolicy,
225
- WorkflowInputValues,
226
- WorkflowOutputValues,
227
- WorkflowSerializableObject,
228
- WorkflowChainStep,
229
- } from "./shared/authoring-contract.js";
230
-
231
- // Type-only nominal brand for standalone package typings. Runtime discovery uses
232
- // the package-internal WeakSet in define-workflow.ts rather than a symbol field.
233
- declare const workflowDefinitionBrand: unique symbol;
234
- type WorkflowDefinitionBrand = { readonly [workflowDefinitionBrand]: true };
235
-
236
- export interface WorkflowDefinition<
237
- TInputs extends WorkflowInputValues = WorkflowInputValues,
238
- TOutputs extends WorkflowOutputValues = WorkflowOutputValues,
239
- TRunInputs extends WorkflowInputValues = TInputs,
240
- TDefinitionBrand extends object = WorkflowDefinitionBrand,
241
- > extends WorkflowContractDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand>, WorkflowDefinitionBrand {}
242
-
243
- export type WorkflowRunContext<TInputs extends WorkflowInputValues = WorkflowInputValues> = AuthoringContract.WorkflowRunContext<TInputs, WorkflowDefinitionBrand>;
244
- export type WorkflowRunFn<
245
- TInputs extends WorkflowInputValues = WorkflowInputValues,
246
- TOutputs extends WorkflowOutputValues = WorkflowOutputValues,
247
- > = AuthoringContract.WorkflowRunFn<TInputs, TOutputs, WorkflowDefinitionBrand>;
248
-
249
- export type AnyWorkflowDefinition = WorkflowDefinition<WorkflowInputValues, WorkflowOutputValues, WorkflowInputValues>;
250
-
251
- export type WorkflowBuilder<
252
- TInputs extends WorkflowInputValues = {},
253
- TOutputs extends WorkflowOutputValues = {},
254
- TRunInputs extends WorkflowInputValues = TInputs,
255
- > = AuthoringContract.WorkflowBuilder<TInputs, TOutputs, TRunInputs, WorkflowDefinitionBrand, WorkflowDefinition<TInputs, TOutputs, TRunInputs>>;
256
-
257
- export type CompletedWorkflowBuilder<
258
- TInputs extends WorkflowInputValues = {},
259
- TOutputs extends WorkflowOutputValues = {},
260
- TRunInputs extends WorkflowInputValues = TInputs,
261
- > = AuthoringContract.CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, WorkflowDefinitionBrand, WorkflowDefinition<TInputs, TOutputs, TRunInputs>>;
262
-
263
- export type RunContinuationOpts = AuthoringContract.RunContinuationOpts;
264
- export type WorkflowParentRunLink = AuthoringContract.WorkflowParentRunLink;
265
- export type RunOpts = Omit<AuthoringContract.RunOpts, "registry"> & { readonly registry?: WorkflowRegistry };
266
-
267
- export declare const INTERACTIVE_WORKFLOW_POLICY: WorkflowExecutionPolicy;
268
- export declare const NON_INTERACTIVE_WORKFLOW_POLICY: WorkflowExecutionPolicy;
269
- export declare function run<TInputs extends WorkflowInputValues, TOutputs extends WorkflowOutputValues, TRunInputs extends WorkflowInputValues = TInputs>(
270
- definition: WorkflowDefinition<TInputs, TOutputs, TRunInputs>,
271
- inputs: Readonly<NoInfer<TRunInputs>>,
272
- opts?: RunOpts,
273
- ): Promise<RunResult<TOutputs>>;
274
- export declare function runTask(task: WorkflowDirectTaskItem, runOptions?: RunOpts): Promise<WorkflowDetails>;
275
- export declare function runTask(task: WorkflowDirectTaskItem, options?: WorkflowDirectOptions, runOptions?: RunOpts): Promise<WorkflowDetails>;
276
- export declare function runParallel(tasks: readonly WorkflowDirectTaskItem[], options?: WorkflowDirectOptions, runOptions?: RunOpts): Promise<WorkflowDetails>;
277
- export declare function runChain(steps: readonly WorkflowChainStep[], options?: WorkflowDirectOptions, runOptions?: RunOpts): Promise<WorkflowDetails>;
278
- export declare function resolveInputs<TInputs extends WorkflowInputValues>(
279
- schema: Readonly<Record<keyof TInputs & string, TSchema>>,
280
- provided: Partial<TInputs>,
281
- ): ResolvedInputs<TInputs>;
282
- export declare function setupGitWorktree(options: GitWorktreeSetupOptions): GitWorktreeSetupResult;
283
-
284
- export interface WorkflowRegistry {
285
- register<TInputs extends WorkflowInputValues, TOutputs extends WorkflowOutputValues>(
286
- definition: WorkflowDefinition<TInputs, TOutputs>,
287
- ): WorkflowRegistry;
288
- merge(other: WorkflowRegistry): WorkflowRegistry;
289
- get(name: string): AnyWorkflowDefinition | undefined;
290
- has(name: string): boolean;
291
- remove(name: string): WorkflowRegistry;
292
- names(): string[];
293
- all(): AnyWorkflowDefinition[];
294
- }
295
-
296
- /**
297
- * @deprecated Removed imperative workflow API. This runtime value only throws
298
- * a migration error; author workflows with defineWorkflow(...).compile().
299
- */
300
- export declare const runWorkflow: never;
301
- export declare function defineWorkflow(name: string): WorkflowBuilder;
302
- export declare function createRegistry<TDefinitions extends readonly AnyWorkflowDefinition[] = readonly AnyWorkflowDefinition[]>(
303
- initial?: TDefinitions,
304
- ): WorkflowRegistry;
305
- export declare function normalizeWorkflowName(name: string): string;
306
- export declare function workflowNamesEqual(a: string, b: string): boolean;
307
-
308
- export declare class GraphFrontierTracker {
309
- onSpawn(stageId: string, stageName: string): string[];
310
- currentParents(): string[];
311
- replaceParents(stageId: string, parentIds: readonly string[]): void;
312
- onSettle(stageId: string): void;
313
- getNodes(): StageNode[];
314
- getParents(stageId: string): string[];
315
- reset(): void;
316
- }
317
- export interface StageNode extends WorkflowSerializableObject {
318
- readonly id: string;
319
- readonly name: string;
320
- readonly parentIds: readonly string[];
321
- }
322
- export type NoticeLevel = "info" | "warning" | "error";
323
- export type PromptKind = "input" | "confirm" | "select" | "editor";
324
-
325
- export interface PendingPrompt extends WorkflowSerializableObject {
326
- readonly id: string;
327
- readonly kind: PromptKind;
328
- readonly message: string;
329
- readonly choices?: readonly string[];
330
- readonly initial?: string;
331
- readonly createdAt: number;
332
- }
333
-
334
- export interface ToolEvent {
335
- readonly name: string;
336
- readonly input?: Record<string, unknown>;
337
- readonly output?: string;
338
- readonly startedAt?: number;
339
- readonly endedAt?: number;
340
- }
341
-
342
- export interface WorkflowNotice extends WorkflowSerializableObject {
343
- readonly id: string;
344
- readonly runId?: string;
345
- readonly stageId?: string;
346
- readonly level: NoticeLevel;
347
- readonly message: string;
348
- readonly createdAt: number;
349
- readonly requiresAck?: boolean;
350
- readonly ackedAt?: number;
351
- }
352
-
353
- export interface WorkflowOverlayAdapter {
354
- show(notice: WorkflowNotice): void;
355
- hide(): void;
356
- }
357
-
358
- export interface RunSnapshot {
359
- readonly id: string;
360
- readonly name: string;
361
- readonly status: RunStatus;
362
- readonly stages: readonly StageSnapshot[];
363
- readonly startedAt: number;
364
- readonly endedAt?: number;
365
- readonly durationMs?: number;
366
- readonly result?: WorkflowOutputValues;
367
- readonly error?: string;
368
- readonly pendingPrompt?: PendingPrompt;
369
- }
370
-
371
- export interface StoreSnapshot {
372
- readonly runs: readonly RunSnapshot[];
373
- readonly notices: readonly WorkflowNotice[];
374
- readonly version: number;
375
- }
376
-
377
- export interface Store {
378
- runs(): readonly RunSnapshot[];
379
- notices(): readonly WorkflowNotice[];
380
- activeRunId(): string | null;
381
- recordRunStart(run: RunSnapshot): void;
382
- recordStageStart(runId: string, stage: StageSnapshot): void;
383
- recordToolStart(runId: string, stageId: string, evt: ToolEvent): void;
384
- recordToolEnd(runId: string, stageId: string, evt: ToolEvent): void;
385
- recordStageEnd(runId: string, stage: StageSnapshot): void;
386
- recordRunEnd(runId: string, status: RunStatus, result?: WorkflowOutputValues, error?: string): boolean;
387
- removeRun(runId: string): boolean;
388
- recordNotice(notice: WorkflowNotice): void;
389
- ackNotice(id: string): boolean;
390
- }
391
-
392
- export declare function createStore(): Store;
393
- export declare const store: Store;
394
-
395
- export interface ActiveRunEntry {
396
- readonly controller: AbortController;
397
- readonly children: readonly AbortController[];
398
- }
399
-
400
- export interface CancellationRegistry {
401
- register(runId: string, controller: AbortController): void;
402
- registerChild(runId: string, controller: AbortController): void;
403
- abort(runId: string, reason?: unknown): boolean;
404
- abortAll(reason?: unknown): number;
405
- unregister(runId: string): void;
406
- isAborted(runId: string): boolean;
407
- }
408
-
409
- export declare function createCancellationRegistry(): CancellationRegistry;
410
- export declare const cancellationRegistry: CancellationRegistry;