@leitwerk-dev/process-sdk 0.3.0 → 0.4.0
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/{chunk-I7U6HCLN.js → chunk-HT2AXXLH.js} +2 -1
- package/dist/chunk-HT2AXXLH.js.map +1 -0
- package/dist/core-capabilities.d.ts +57 -1
- package/dist/core-capabilities.d.ts.map +1 -1
- package/dist/define-process.d.ts +43 -26
- package/dist/define-process.d.ts.map +1 -1
- package/dist/{extension-api-3Vr3RE8S.d.ts → extension-api-Ljc4UTZ0.d.ts} +440 -49
- package/dist/extension-api.d.ts +66 -0
- package/dist/extension-api.d.ts.map +1 -1
- package/dist/external-source-poll.d.ts +1 -1
- package/dist/external-source-poll.d.ts.map +1 -1
- package/dist/file-external-source.d.ts +32 -0
- package/dist/file-external-source.d.ts.map +1 -0
- package/dist/flow-mapped.typecheck.d.ts +2 -0
- package/dist/flow-mapped.typecheck.d.ts.map +1 -0
- package/dist/flow.d.ts +234 -118
- package/dist/flow.d.ts.map +1 -1
- package/dist/index.d.ts +15 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4189 -3534
- package/dist/index.js.map +1 -1
- package/dist/mapped-turn.d.ts +169 -0
- package/dist/mapped-turn.d.ts.map +1 -0
- package/dist/outcome-contract.d.ts +19 -0
- package/dist/outcome-contract.d.ts.map +1 -0
- package/dist/outcome-schema.d.ts +23 -0
- package/dist/outcome-schema.d.ts.map +1 -0
- package/dist/pi-config-public.js +1 -1
- package/dist/pi-config.js +1 -1
- package/dist/process-flow-view.d.ts +3 -14
- package/dist/process-flow-view.d.ts.map +1 -1
- package/dist/process-graph.d.ts +10 -4
- package/dist/process-graph.d.ts.map +1 -1
- package/dist/scoped-settings.d.ts +87 -0
- package/dist/scoped-settings.d.ts.map +1 -0
- package/dist/ticket-creation.d.ts +24 -0
- package/dist/ticket-creation.d.ts.map +1 -0
- package/dist/turn-semantics.d.ts +3 -3
- package/dist/turn-semantics.d.ts.map +1 -1
- package/dist/turn-wait.d.ts +53 -0
- package/dist/turn-wait.d.ts.map +1 -0
- package/dist/types.d.ts +45 -24
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/core-capabilities.ts +76 -1
- package/src/define-process.ts +447 -540
- package/src/extension-api.ts +78 -0
- package/src/external-source-poll.ts +6 -24
- package/src/file-external-source.ts +135 -0
- package/src/flow-mapped.typecheck.ts +136 -0
- package/src/flow.ts +888 -532
- package/src/index.ts +77 -2
- package/src/mapped-turn.ts +437 -0
- package/src/outcome-contract.ts +126 -0
- package/src/outcome-schema.ts +314 -0
- package/src/process-flow-view.ts +84 -346
- package/src/process-graph.ts +95 -45
- package/src/scoped-settings.ts +113 -0
- package/src/ticket-creation.ts +113 -0
- package/src/turn-semantics.ts +102 -116
- package/src/turn-wait.ts +76 -0
- package/src/types.ts +44 -22
- package/dist/chunk-I7U6HCLN.js.map +0 -1
package/dist/flow.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type ProcessInstance, type ProcessProject, type ProcessTurnStartSelection, type ProcessTurnTerminalLifecycleStatus, type TurnId, type TurnProgressReport } from "@leitwerk-dev/domain";
|
|
2
|
-
import type { AutomaticTurnDefinition, ExternalTurnDefinition, HumanTurnDefinition, HumanTurnOperatorAttention, LlmModelPurpose, LlmTurnDefinition, ProcessEffectPlan, ProcessHumanTurnActionSpec, ProcessHumanTurnExternalActionSpec, ProcessOutcomeEffect, ProcessOutcomeExecution, ProcessRuntimeTurnContext, ProcessToolOutcomeSpec, ProcessTurnEndSpec, TurnDefinition } from "./define-process.js";
|
|
3
|
-
import type { Codec, ExtensionProcessDefinition, ExternalActionSource, ExternalSourceEffect, ExternalSourceEffectContext, FormDefinition, ProcessActionDefinition, ProcessLauncherAPI, ProcessLauncherDefinition, ProcessWatcherAPI, ProcessWatcherDefinition, ServerProcessAPI, UiProcessAPI, WorkerCompleteInput } from "./extension-api.js";
|
|
4
|
-
import type {
|
|
1
|
+
import { type ProcessInstance, type ProcessProject, type ProcessTurnStartSelection, type ProcessTurnTerminalLifecycleStatus, type ScopedSettingsSnapshot, type TurnId, type TurnProgressReport } from "@leitwerk-dev/domain";
|
|
2
|
+
import type { AutomaticTurnDefinition, ExternalTurnDefinition, HumanTurnDefinition, HumanTurnOperatorAttention, LlmModelPurpose, LlmOutcomeSubmission, LlmTurnDefinition, OutcomeParameterContext, ProcessEffectPlan, ProcessHumanTurnActionSpec, ProcessHumanTurnExternalActionSpec, ProcessOutcomeBranchSpec, ProcessOutcomeEffect, ProcessOutcomeExecution, ProcessRuntimeTurnContext, ProcessToolOutcomeSpec, ProcessTurnEndSpec, TurnDefinition } from "./define-process.js";
|
|
3
|
+
import type { Codec, ExtensionProcessDefinition, ExternalActionSource, ExternalSourceEffect, ExternalSourceEffectContext, FormDefinition, ProcessActionDefinition, ProcessLauncherAPI, ProcessLauncherDefinition, ProcessWatcherAPI, ProcessWatcherDefinition, ServerProcessAPI, TurnDiagnosticReport, UiProcessAPI, WorkerCompleteInput } from "./extension-api.js";
|
|
4
|
+
import type { MappedCollect, MappedCollectRouting, MappedItemYield, MappedLlmTurnSpec, MappedTurnItemContext, MappedTurnServerContext } from "./mapped-turn.js";
|
|
5
|
+
import type { TurnWaitPredicate } from "./turn-wait.js";
|
|
6
|
+
import type { OutcomeToolArrayItemSpec, OutcomeToolParameterSpec, PiBuiltInToolName, ProcessPiConfig } from "./types.js";
|
|
5
7
|
/** @public */
|
|
6
8
|
type MaybePromise<T> = T | Promise<T>;
|
|
7
9
|
/** @internal */
|
|
@@ -114,6 +116,8 @@ export type FlowPromptContext<TParams = unknown, TState = unknown, TConsumedProd
|
|
|
114
116
|
});
|
|
115
117
|
/** @public */
|
|
116
118
|
export interface FlowAutomaticRunContext<TParams = unknown, TState = unknown> {
|
|
119
|
+
/** Immutable non-secret settings captured for this turn. @public */
|
|
120
|
+
readonly scopedSettings?: ScopedSettingsSnapshot;
|
|
117
121
|
/** @public */
|
|
118
122
|
process: ProcessInstance;
|
|
119
123
|
/** @public */
|
|
@@ -130,6 +134,13 @@ export interface FlowAutomaticRunContext<TParams = unknown, TState = unknown> {
|
|
|
130
134
|
callIntegrationTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
131
135
|
/** @public */
|
|
132
136
|
reportProgress(report: TurnProgressReport): void;
|
|
137
|
+
/** Append a non-secret worker diagnostic for this turn attempt. @internal */
|
|
138
|
+
reportDiagnostic(report: TurnDiagnosticReport): void;
|
|
139
|
+
}
|
|
140
|
+
/** Worker context for correcting a submission before accepting it. @public */
|
|
141
|
+
export interface FlowOutcomeValidationContext<TParams = unknown, TState = unknown> extends FlowAutomaticRunContext<TParams, TState> {
|
|
142
|
+
/** Preparation captured before prompting. @public */
|
|
143
|
+
prepared?: unknown;
|
|
133
144
|
}
|
|
134
145
|
/** @public */
|
|
135
146
|
export type FlowLlmPreparationContext<TParams = unknown, TState = unknown> = FlowAutomaticRunContext<TParams, TState>;
|
|
@@ -198,40 +209,23 @@ declare class RouteAndEffectBuilder<TParams, TState, TContext> {
|
|
|
198
209
|
/** @public */
|
|
199
210
|
effect(fn: FlowOutcomeEffect<TParams, TState, TContext>): this;
|
|
200
211
|
/** @internal */
|
|
212
|
+
getEffect(): FlowOutcomeEffect<TParams, TState, TContext> | undefined;
|
|
213
|
+
/** @internal */
|
|
201
214
|
hasRoute(): boolean;
|
|
202
215
|
/** @internal */
|
|
203
|
-
|
|
204
|
-
/** @internal */
|
|
205
|
-
to?: TurnId;
|
|
206
|
-
/** @internal */
|
|
207
|
-
complete?: boolean;
|
|
208
|
-
/** @internal */
|
|
209
|
-
lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
|
|
210
|
-
};
|
|
216
|
+
buildRouteTarget(): Pick<ProcessTurnEndSpec, "to" | "complete" | "lifecycleStatus">;
|
|
211
217
|
}
|
|
212
218
|
/** @internal */
|
|
213
219
|
export type FlowTargetSpec = {
|
|
214
220
|
/** @internal */
|
|
215
|
-
|
|
216
|
-
/** @internal */
|
|
217
|
-
turnId: TurnId;
|
|
221
|
+
to: TurnId;
|
|
218
222
|
} | {
|
|
219
223
|
/** @internal */
|
|
220
|
-
|
|
224
|
+
complete: true;
|
|
221
225
|
} | {
|
|
222
226
|
/** @internal */
|
|
223
|
-
|
|
224
|
-
/** @internal */
|
|
225
|
-
status: ProcessTurnTerminalLifecycleStatus;
|
|
227
|
+
lifecycleStatus: ProcessTurnTerminalLifecycleStatus;
|
|
226
228
|
} | null;
|
|
227
|
-
export declare function buildRouteTargetSpec(target: FlowTargetSpec): {
|
|
228
|
-
/** @internal */
|
|
229
|
-
to?: TurnId;
|
|
230
|
-
/** @internal */
|
|
231
|
-
complete?: boolean;
|
|
232
|
-
/** @internal */
|
|
233
|
-
lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
|
|
234
|
-
};
|
|
235
229
|
/** @public */
|
|
236
230
|
interface ParameterOptions extends Partial<Omit<OutcomeToolParameterSpec, "type" | "description">> {
|
|
237
231
|
/** @public */
|
|
@@ -239,9 +233,9 @@ interface ParameterOptions extends Partial<Omit<OutcomeToolParameterSpec, "type"
|
|
|
239
233
|
/** @internal */
|
|
240
234
|
requiredErrorCode?: string;
|
|
241
235
|
}
|
|
242
|
-
/** @
|
|
236
|
+
/** @public */
|
|
243
237
|
interface ArrayParameterOptions extends ParameterOptions {
|
|
244
|
-
/** @
|
|
238
|
+
/** @public */
|
|
245
239
|
items?: OutcomeToolParameterSpec["items"];
|
|
246
240
|
}
|
|
247
241
|
/** @internal */
|
|
@@ -255,52 +249,46 @@ interface MarkdownParameterOptions extends ParameterOptions {
|
|
|
255
249
|
publish?: true;
|
|
256
250
|
}
|
|
257
251
|
/** @public */
|
|
258
|
-
declare class
|
|
252
|
+
declare class OutcomeParametersBuilder<TParams = unknown, TState = unknown> {
|
|
259
253
|
/** @internal */
|
|
260
254
|
protected outcomeDescription: string | null;
|
|
261
255
|
/** @internal */
|
|
262
256
|
protected parameters: Record<string, OutcomeToolParameterSpec>;
|
|
263
257
|
/** @internal */
|
|
264
|
-
protected publishedMarkdownParameter: string | null;
|
|
265
|
-
/** @internal */
|
|
266
258
|
protected summaryParameter: string | null;
|
|
259
|
+
private enforceSchema;
|
|
260
|
+
/** @internal */
|
|
261
|
+
protected parameterResolver?: (ctx: OutcomeParameterContext<TParams, TState>) => Record<string, OutcomeToolParameterSpec>;
|
|
262
|
+
/** Enforce a closed schema with no optional properties at supported providers. @public */
|
|
263
|
+
strictSchema(): this;
|
|
264
|
+
/** Declare alternatives for one argument. @public */
|
|
265
|
+
union(name: string, variants: readonly OutcomeToolArrayItemSpec[], options?: string | ParameterOptions): this;
|
|
267
266
|
/** Optional concise result publication, separate from the full Markdown. @public */
|
|
268
267
|
resultSummary(name?: string): this;
|
|
269
268
|
/** @internal */
|
|
270
|
-
protected
|
|
271
|
-
/** @internal */
|
|
272
|
-
publishedProduct: string;
|
|
273
|
-
/** @internal */
|
|
274
|
-
turnResultMarkdownParameter: string;
|
|
275
|
-
} | {
|
|
276
|
-
/** @internal */
|
|
277
|
-
publishedProduct?: undefined;
|
|
278
|
-
/** @internal */
|
|
279
|
-
turnResultMarkdownParameter?: undefined;
|
|
280
|
-
};
|
|
269
|
+
protected buildParameterSpec(kind: string): Pick<ProcessToolOutcomeSpec, "description" | "parameters" | "resultSummaryParameter">;
|
|
281
270
|
/** @public */
|
|
282
271
|
description(text: string): this;
|
|
283
272
|
/** @internal */
|
|
284
273
|
parameter(name: string, spec: OutcomeToolParameterSpec): this;
|
|
285
274
|
private withRequired;
|
|
286
|
-
private typedParameter;
|
|
287
275
|
/** @internal */
|
|
288
|
-
|
|
276
|
+
protected typedParameter(name: string, type: OutcomeToolParameterSpec["type"], options?: string | ArrayParameterOptions): this;
|
|
289
277
|
/** @public */
|
|
290
|
-
|
|
278
|
+
string(name: string, options?: string | ParameterOptions): this;
|
|
291
279
|
/** @public */
|
|
292
280
|
requiredString(name: string, options?: string | ParameterOptions): this;
|
|
293
281
|
/** @internal */
|
|
294
282
|
number(name: string, options?: string | ParameterOptions): this;
|
|
295
|
-
/** @
|
|
283
|
+
/** @public */
|
|
296
284
|
requiredNumber(name: string, options?: string | ParameterOptions): this;
|
|
297
285
|
/** @internal */
|
|
298
286
|
boolean(name: string, options?: string | ParameterOptions): this;
|
|
299
|
-
/** @
|
|
287
|
+
/** @public */
|
|
300
288
|
requiredBoolean(name: string, options?: string | ParameterOptions): this;
|
|
301
289
|
/** @internal */
|
|
302
290
|
stringArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
303
|
-
/** @
|
|
291
|
+
/** @public */
|
|
304
292
|
requiredStringArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
305
293
|
/** @internal */
|
|
306
294
|
enum(name: string, valuesOrOptions: readonly string[] | EnumParameterOptions): this;
|
|
@@ -308,12 +296,43 @@ declare class ParameterizedOutcomeBuilder<TParams, TState, TContext> extends Rou
|
|
|
308
296
|
object(name: string, options?: string | ParameterOptions): this;
|
|
309
297
|
/** @internal */
|
|
310
298
|
array(name: string, options?: string | ArrayParameterOptions): this;
|
|
299
|
+
/** @public */
|
|
300
|
+
requiredArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
301
|
+
}
|
|
302
|
+
/** @public */
|
|
303
|
+
declare class ParameterizedOutcomeBuilder<TParams, TState, TContext> extends OutcomeParametersBuilder<TParams, TState> {
|
|
304
|
+
private readonly route;
|
|
305
|
+
private publishedMarkdownParameter;
|
|
306
|
+
/** @public */
|
|
307
|
+
to(turnId: TurnId): this;
|
|
308
|
+
/** @public */
|
|
309
|
+
complete(): this;
|
|
310
|
+
/** @public */
|
|
311
|
+
lifecycleStatus(status: ProcessTurnTerminalLifecycleStatus): this;
|
|
312
|
+
/** @internal */
|
|
313
|
+
stay(): this;
|
|
314
|
+
/** @public */
|
|
315
|
+
state(fn: FlowOutcomeStateEffect<TParams, TState, TContext>): this;
|
|
316
|
+
/** @public */
|
|
317
|
+
effect(fn: FlowOutcomeEffect<TParams, TState, TContext>): this;
|
|
318
|
+
/** @internal */
|
|
319
|
+
hasRoute(): boolean;
|
|
320
|
+
/** @internal */
|
|
321
|
+
protected get flowEffect(): FlowOutcomeEffect<TParams, TState, TContext> | undefined;
|
|
322
|
+
/** @internal */
|
|
323
|
+
protected buildRouteTarget(): Pick<ProcessTurnEndSpec<unknown, unknown, string>, "to" | "complete" | "lifecycleStatus">;
|
|
324
|
+
/** @internal */
|
|
325
|
+
protected buildParameterSpec(kind: string): ProcessToolOutcomeSpec<TParams, TState>;
|
|
326
|
+
/** @public */
|
|
327
|
+
markdown(name: string, options?: string | MarkdownParameterOptions): this;
|
|
311
328
|
}
|
|
312
329
|
/** @public */
|
|
313
330
|
export declare class OutcomeToolBuilder<TParams = unknown, TState = unknown> extends ParameterizedOutcomeBuilder<TParams, TState, FlowLlmOutcomeEffectContext<TParams, TState>> {
|
|
331
|
+
/** Pure synchronous resolution at turn-start preparation. @public */
|
|
332
|
+
resolveParameters(fn: (ctx: OutcomeParameterContext<TParams, TState>) => Record<string, OutcomeToolParameterSpec>): this;
|
|
314
333
|
private stateRouting;
|
|
315
334
|
/** @public */
|
|
316
|
-
routeByState(branches: Record<string, TurnId>, choose: (input: FlowOutcomeEffectInput<TParams, TState, FlowLlmOutcomeEffectContext<TParams, TState>>) => MaybePromise<string>): this;
|
|
335
|
+
routeByState(branches: Record<string, TurnId | ProcessOutcomeBranchSpec>, choose: (input: FlowOutcomeEffectInput<TParams, TState, FlowLlmOutcomeEffectContext<TParams, TState>>) => MaybePromise<string>): this;
|
|
317
336
|
/** @internal */
|
|
318
337
|
build(): ProcessToolOutcomeSpec<TParams, TState>;
|
|
319
338
|
}
|
|
@@ -343,11 +362,11 @@ export declare class PlanResultBuilder<TParams = unknown, TState = unknown> exte
|
|
|
343
362
|
buildOutcome(): ProcessToolOutcomeSpec<TParams, TState>;
|
|
344
363
|
}
|
|
345
364
|
/** @public */
|
|
346
|
-
declare
|
|
365
|
+
export declare class LlmTurnEndBuilder<TParams = unknown, TState = unknown> extends RouteAndEffectBuilder<TParams, TState, FlowLlmOutcomeEffectContext<TParams, TState>> implements FlowLlmTurn<TParams, TState, string> {
|
|
347
366
|
private readonly outcomeId;
|
|
348
367
|
private readonly parent?;
|
|
349
368
|
/** @internal */
|
|
350
|
-
protected
|
|
369
|
+
protected readonly builderName: string;
|
|
351
370
|
/** @internal */
|
|
352
371
|
constructor(outcomeId: string, parent?: FlowLlmTurn<TParams, TState, string> | undefined);
|
|
353
372
|
private get turn();
|
|
@@ -356,27 +375,16 @@ declare abstract class TurnEndBuilder<TParams, TState> extends RouteAndEffectBui
|
|
|
356
375
|
/** @internal */
|
|
357
376
|
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
358
377
|
/** @internal */
|
|
359
|
-
|
|
378
|
+
build(): ProcessTurnEndSpec<TParams, TState, string>;
|
|
360
379
|
}
|
|
361
380
|
/** @public */
|
|
362
|
-
export declare class PublishedResultBuilder<TParams = unknown, TState = unknown> extends
|
|
381
|
+
export declare class PublishedResultBuilder<TParams = unknown, TState = unknown> extends LlmTurnEndBuilder<TParams, TState> {
|
|
363
382
|
/** @internal */
|
|
364
383
|
protected readonly builderName = "Published result";
|
|
365
384
|
/** @internal */
|
|
366
385
|
buildTurnEnd(): ProcessTurnEndSpec<TParams, TState, string>;
|
|
367
386
|
}
|
|
368
387
|
/** @public */
|
|
369
|
-
export declare class LlmTurnEndBuilder<TParams = unknown, TState = unknown> extends TurnEndBuilder<TParams, TState> {
|
|
370
|
-
/** @internal */
|
|
371
|
-
protected readonly builderName = "LLM turn end";
|
|
372
|
-
/** @internal */
|
|
373
|
-
constructor(outcomeId: string, parent?: FlowLlmTurn<TParams, TState, string>);
|
|
374
|
-
/** @internal */
|
|
375
|
-
build(): ProcessTurnEndSpec<TParams, TState, string>;
|
|
376
|
-
}
|
|
377
|
-
/** @public */
|
|
378
|
-
type LlmPromptBuilder<TParams, TState, TConsumedProducts extends string, TPrepared> = (ctx: FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared>) => MaybePromise<string>;
|
|
379
|
-
/** @public */
|
|
380
388
|
declare abstract class DescribedTurnBuilder {
|
|
381
389
|
/** @internal */
|
|
382
390
|
protected readonly turnId: TurnId;
|
|
@@ -392,25 +400,52 @@ declare abstract class DescribedTurnBuilder {
|
|
|
392
400
|
description(description: string): this;
|
|
393
401
|
}
|
|
394
402
|
/** @public */
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
private
|
|
399
|
-
|
|
400
|
-
|
|
403
|
+
declare abstract class ExternalActionTurnBuilder<TParams, TState> extends DescribedTurnBuilder {
|
|
404
|
+
/** @internal */
|
|
405
|
+
protected abstract readonly turnKind: "LLM" | "Automatic" | "Human";
|
|
406
|
+
private externalActionBuilders;
|
|
407
|
+
/** @public */
|
|
408
|
+
externalAction<TEvent = unknown, TInput extends Record<string, unknown> = Record<string, unknown>>(externalActionId: string, source: ExternalActionSource<TParams, TState, TEvent, TInput>, configure: (external: ExternalActionBuilder<TParams, TState, TEvent, TInput>) => ExternalActionBuilder<TParams, TState, TEvent, TInput> | undefined): this;
|
|
409
|
+
/** @internal */
|
|
410
|
+
protected buildExternalActions(): Record<string, ProcessHumanTurnExternalActionSpec<TParams, TState>> | undefined;
|
|
411
|
+
}
|
|
412
|
+
/** LLM authoring families used to preserve fluent context and completion types. @public */
|
|
413
|
+
type LlmBuilderFamily = {
|
|
414
|
+
/** @public */
|
|
415
|
+
kind: "ordinary";
|
|
416
|
+
} | {
|
|
417
|
+
/** @public */
|
|
418
|
+
kind: "mapped";
|
|
419
|
+
/** @public */
|
|
420
|
+
item: unknown;
|
|
421
|
+
/** @public */
|
|
422
|
+
result: unknown;
|
|
423
|
+
};
|
|
424
|
+
/** Active-item context supplied by an LLM authoring family. @public */
|
|
425
|
+
type LlmItemContext<TFamily extends LlmBuilderFamily> = TFamily extends {
|
|
426
|
+
kind: "mapped";
|
|
427
|
+
item: infer TItem;
|
|
428
|
+
} ? MappedTurnItemContext<TItem> : Record<never, never>;
|
|
429
|
+
/** Preserve the concrete completion API when preparation or products refine its types. @public */
|
|
430
|
+
type ConfiguredLlmBuilder<TFamily extends LlmBuilderFamily, TParams, TState, TConsumedProducts extends string, TPrepared> = TFamily extends {
|
|
431
|
+
kind: "mapped";
|
|
432
|
+
item: infer TItem;
|
|
433
|
+
result: infer TResult;
|
|
434
|
+
} ? MappedLlmFlowBuilder<TParams, TState, TItem, TResult, TConsumedProducts, TPrepared> : LlmFlowBuilder<TParams, TState, TConsumedProducts, TPrepared>;
|
|
435
|
+
/** @public */
|
|
436
|
+
declare abstract class LlmConfigurationBuilder<TParams, TState, TConsumedProducts extends string, TPrepared, TFamily extends LlmBuilderFamily> extends ExternalActionTurnBuilder<TParams, TState> {
|
|
437
|
+
/** @internal */
|
|
438
|
+
protected readonly turnKind = "LLM";
|
|
439
|
+
private readonly configuration;
|
|
440
|
+
/** Wait on the server before this turn may allocate a worker. @public */
|
|
441
|
+
waitFor(predicate: TurnWaitPredicate<TParams, TState>): this;
|
|
401
442
|
private promptBuilder;
|
|
402
|
-
private branchType;
|
|
403
|
-
private context;
|
|
404
|
-
private questionsEnabled;
|
|
405
|
-
private startFrom;
|
|
406
|
-
private restorePrimaryLeafAfterTurn;
|
|
407
443
|
private readonly consumedProductNames;
|
|
408
444
|
private readonly optionalConsumedProductNames;
|
|
409
|
-
private publishedResult;
|
|
410
|
-
private endResult;
|
|
411
|
-
private outcomeToolBuilders;
|
|
412
445
|
/** @internal */
|
|
413
|
-
|
|
446
|
+
protected abstract itemContext(ctx: ProcessRuntimeTurnContext<TParams, TState>): LlmItemContext<TFamily>;
|
|
447
|
+
/** @public */
|
|
448
|
+
executionPurpose(purpose: string): this;
|
|
414
449
|
/** @internal */
|
|
415
450
|
modelPurpose(purpose: LlmModelPurpose): this;
|
|
416
451
|
/** @public */
|
|
@@ -420,9 +455,11 @@ export declare class LlmFlowBuilder<TParams = unknown, TState = unknown, TConsum
|
|
|
420
455
|
/** @public */
|
|
421
456
|
resolveIntegrationTools(resolver: (params: TParams, state: TState) => readonly string[]): this;
|
|
422
457
|
/** @public */
|
|
423
|
-
prepare<TNextPrepared>(fn: (ctx: FlowLlmPreparationContext<TParams, TState>) => MaybePromise<TNextPrepared>):
|
|
424
|
-
/**
|
|
425
|
-
|
|
458
|
+
prepare<TNextPrepared>(fn: (ctx: FlowLlmPreparationContext<TParams, TState> & LlmItemContext<TFamily>) => MaybePromise<TNextPrepared>): ConfiguredLlmBuilder<TFamily, TParams, TState, TConsumedProducts, TNextPrepared>;
|
|
459
|
+
/** Return correction errors before accepting an outcome. @public */
|
|
460
|
+
validateOutcome(fn: (ctx: FlowOutcomeValidationContext<TParams, TState> & LlmItemContext<TFamily>, outcome: LlmOutcomeSubmission) => MaybePromise<readonly string[]>): this;
|
|
461
|
+
/** Enable durable questions, optionally constrained by captured input. @public */
|
|
462
|
+
askQuestions(when?: (ctx: FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared> & LlmItemContext<TFamily>) => boolean): this;
|
|
426
463
|
/** @public */
|
|
427
464
|
freshPrimary(): this;
|
|
428
465
|
/** @internal */
|
|
@@ -444,33 +481,105 @@ export declare class LlmFlowBuilder<TParams = unknown, TState = unknown, TConsum
|
|
|
444
481
|
/** @internal */
|
|
445
482
|
startFromRoot(): this;
|
|
446
483
|
/** @public */
|
|
447
|
-
consume<TProductName extends string>(productName: TProductName):
|
|
484
|
+
consume<TProductName extends string>(productName: TProductName): ConfiguredLlmBuilder<TFamily, TParams, TState, TConsumedProducts | TProductName, TPrepared>;
|
|
448
485
|
/** @public */
|
|
449
|
-
optionalConsume<TProductName extends string>(productName: TProductName):
|
|
486
|
+
optionalConsume<TProductName extends string>(productName: TProductName): ConfiguredLlmBuilder<TFamily, TParams, TState, TConsumedProducts | TProductName, TPrepared>;
|
|
487
|
+
private refineContext;
|
|
450
488
|
/** @public */
|
|
451
|
-
|
|
489
|
+
buildPrompt(fn: (ctx: FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared> & LlmItemContext<TFamily>) => MaybePromise<string>): this;
|
|
452
490
|
/** @public */
|
|
453
|
-
|
|
491
|
+
prompt(prompt: string | ((ctx: ProcessRuntimeTurnContext<TParams, TState>) => MaybePromise<string>)): this;
|
|
492
|
+
/** @internal */
|
|
493
|
+
protected buildBaseDefinition(): Omit<LlmTurnDefinition<string, TParams, TState>, "outcomes" | "turnEnd" | "forEach">;
|
|
494
|
+
}
|
|
495
|
+
/** @public */
|
|
496
|
+
export declare class LlmFlowBuilder<TParams = unknown, TState = unknown, TConsumedProducts extends string = never, TPrepared = undefined> extends LlmConfigurationBuilder<TParams, TState, TConsumedProducts, TPrepared, {
|
|
497
|
+
kind: "ordinary";
|
|
498
|
+
}> implements FlowLlmTurn<TParams, TState, string> {
|
|
499
|
+
private publishedResult;
|
|
500
|
+
private endResult;
|
|
501
|
+
private outcomeToolBuilders;
|
|
502
|
+
/** @internal */
|
|
503
|
+
protected itemContext(): Record<never, never>;
|
|
454
504
|
/** @public */
|
|
455
|
-
|
|
505
|
+
publish(productName: string): PublishedResultBuilder<TParams, TState>;
|
|
456
506
|
/** @public */
|
|
457
|
-
|
|
507
|
+
end(outcomeId: string): LlmTurnEndBuilder<TParams, TState>;
|
|
458
508
|
/** @public */
|
|
459
509
|
outcomeTool(id: string, configure: (tool: OutcomeToolBuilder<TParams, TState>) => OutcomeToolBuilder<TParams, TState> | undefined): this;
|
|
460
|
-
private buildBaseDefinition;
|
|
461
510
|
/** @internal */
|
|
462
511
|
producesPlan(configure: (plan: PlanResultBuilder<TParams, TState>) => PlanResultBuilder<TParams, TState>): FlowLlmTurn<TParams, TState, typeof DEFAULT_PLAN_RESULT_OUTCOME_ID>;
|
|
463
|
-
|
|
512
|
+
/** @internal */
|
|
513
|
+
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
464
514
|
}
|
|
515
|
+
/** Item selection for `flow.mappedLlm(...)`. @public */
|
|
516
|
+
export type FlowForEachOptions<TParams, TState, TItem, TResult> = Pick<MappedLlmTurnSpec<TParams, TState, TItem, TResult>, "items" | "itemCodec" | "resultCodec" | "key" | "label" | "stateAfterSnapshot">;
|
|
465
517
|
/** @public */
|
|
466
|
-
|
|
518
|
+
export type FlowMappedPromptContext<TParams, TState, TItem, TConsumedProducts extends string, TPrepared> = FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared> & MappedTurnItemContext<TItem>;
|
|
519
|
+
/** @public */
|
|
520
|
+
export type FlowMappedPreparationContext<TParams, TState, TItem> = FlowLlmPreparationContext<TParams, TState> & MappedTurnItemContext<TItem>;
|
|
521
|
+
/**
|
|
522
|
+
* Outcome of one mapped item. It declares parameters and yields the item's
|
|
523
|
+
* result; it cannot route, change process state, or publish products.
|
|
524
|
+
* @public
|
|
525
|
+
*/
|
|
526
|
+
export declare class MappedOutcomeBuilder<TParams = unknown, TState = unknown, TItem = unknown, TResult = unknown> extends OutcomeParametersBuilder<TParams, TState> {
|
|
527
|
+
/** Resolve parameters from captured state and the frozen mapped item. @public */
|
|
528
|
+
resolveParameters(fn: (ctx: OutcomeParameterContext<TParams, TState> & MappedTurnItemContext<TItem>) => Record<string, OutcomeToolParameterSpec>): this;
|
|
529
|
+
private yieldResult;
|
|
530
|
+
/** Map this outcome to the item's typed result. @public */
|
|
531
|
+
yield(fn: MappedItemYield<TParams, TState, TItem, TResult>): this;
|
|
467
532
|
/** @internal */
|
|
468
|
-
|
|
469
|
-
|
|
533
|
+
build(): {
|
|
534
|
+
/** @internal */
|
|
535
|
+
tool: ProcessToolOutcomeSpec<TParams, TState>;
|
|
536
|
+
/** @internal */
|
|
537
|
+
yieldResult: MappedItemYield<TParams, TState, TItem, TResult>;
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
/** Routes a mapped turn once, after all item results are collected. @public */
|
|
541
|
+
export declare class MappedCollectBuilder<TParams = unknown, TState = unknown> implements FlowLlmTurn<TParams, TState, string> {
|
|
542
|
+
private readonly turn;
|
|
543
|
+
private readonly setRouting;
|
|
544
|
+
/** @internal */
|
|
545
|
+
constructor(turn: FlowLlmTurn<TParams, TState, string>, setRouting: (routing: MappedCollectRouting<TParams, TState>) => void);
|
|
546
|
+
/** @internal */
|
|
547
|
+
get id(): TurnId;
|
|
548
|
+
/** @internal */
|
|
549
|
+
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
470
550
|
/** @public */
|
|
471
|
-
|
|
551
|
+
to(turnId: TurnId): this;
|
|
552
|
+
/** @public */
|
|
553
|
+
complete(): this;
|
|
554
|
+
/** @public */
|
|
555
|
+
lifecycleStatus(status: ProcessTurnTerminalLifecycleStatus): this;
|
|
556
|
+
/** Choose the next turn from the collected state. @public */
|
|
557
|
+
routeByState(branches: Record<string, TurnId>, choose: (ctx: MappedTurnServerContext<TParams, TState>) => MaybePromise<string>): this;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* LLM turn that runs once per frozen item. Business state and routing belong
|
|
561
|
+
* to `.collect(...)`.
|
|
562
|
+
* @public
|
|
563
|
+
*/
|
|
564
|
+
export declare class MappedLlmFlowBuilder<TParams = unknown, TState = unknown, TItem = unknown, TResult = unknown, TConsumedProducts extends string = never, TPrepared = undefined> extends LlmConfigurationBuilder<TParams, TState, TConsumedProducts, TPrepared, {
|
|
565
|
+
kind: "mapped";
|
|
566
|
+
item: TItem;
|
|
567
|
+
result: TResult;
|
|
568
|
+
}> implements FlowLlmTurn<TParams, TState, string> {
|
|
569
|
+
private readonly items;
|
|
570
|
+
private readonly outcomes;
|
|
571
|
+
private collection;
|
|
572
|
+
private routing;
|
|
573
|
+
/** @internal */
|
|
574
|
+
constructor(turnId: TurnId, items: FlowForEachOptions<TParams, TState, TItem, TResult>);
|
|
575
|
+
/** @internal */
|
|
576
|
+
protected itemContext(ctx: ProcessRuntimeTurnContext<TParams, TState>): MappedTurnItemContext<TItem>;
|
|
577
|
+
/** @public */
|
|
578
|
+
outcomeTool(id: string, configure: (outcome: MappedOutcomeBuilder<TParams, TState, TItem, TResult>) => MappedOutcomeBuilder<TParams, TState, TItem, TResult> | undefined): this;
|
|
579
|
+
/** Combine ordered item results into process state, once. @public */
|
|
580
|
+
collect(fn: MappedCollect<TParams, TState, TResult>): MappedCollectBuilder<TParams, TState>;
|
|
472
581
|
/** @internal */
|
|
473
|
-
|
|
582
|
+
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
474
583
|
}
|
|
475
584
|
/** @public */
|
|
476
585
|
export declare class AutomaticFlowBuilder<TParams = unknown, TState = unknown> extends ExternalActionTurnBuilder<TParams, TState> implements FlowAutomaticTurn<TParams, TState, string> {
|
|
@@ -479,15 +588,17 @@ export declare class AutomaticFlowBuilder<TParams = unknown, TState = unknown> e
|
|
|
479
588
|
private runFn;
|
|
480
589
|
private outcomeBuilders;
|
|
481
590
|
private availableIntegrationTools;
|
|
482
|
-
|
|
483
|
-
|
|
591
|
+
private waitPredicate;
|
|
592
|
+
/** Wait on the server before this turn may allocate a worker. @public */
|
|
593
|
+
waitFor(predicate: TurnWaitPredicate<TParams, TState>): this;
|
|
484
594
|
/** @public */
|
|
485
595
|
run(fn: (ctx: FlowAutomaticRunContext<TParams, TState>) => MaybePromise<WorkerCompleteInput<string>>): this;
|
|
486
596
|
/** @public */
|
|
487
597
|
integrationTools(...tools: readonly string[]): this;
|
|
488
598
|
/** @public */
|
|
489
599
|
outcome(id: string, configure: (outcome: AutomaticOutcomeBuilder<TParams, TState>) => AutomaticOutcomeBuilder<TParams, TState> | undefined): this;
|
|
490
|
-
|
|
600
|
+
/** @internal */
|
|
601
|
+
get definition(): AutomaticTurnDefinition<string, TParams, TState>;
|
|
491
602
|
}
|
|
492
603
|
/** @public */
|
|
493
604
|
export declare class HumanActionBuilder<TParams = unknown, TState = unknown> {
|
|
@@ -549,11 +660,7 @@ export declare class ExternalActionBuilder<TParams = unknown, TState = unknown,
|
|
|
549
660
|
export declare class HumanFlowBuilder<TParams = unknown, TState = unknown> extends ExternalActionTurnBuilder<TParams, TState> implements FlowHumanTurn<TParams, TState> {
|
|
550
661
|
/** @internal */
|
|
551
662
|
protected readonly turnKind = "Human";
|
|
552
|
-
private
|
|
553
|
-
private reviewSemanticRef;
|
|
554
|
-
private operatorAttentionValue;
|
|
555
|
-
private turnCommentary;
|
|
556
|
-
private notes;
|
|
663
|
+
private readonly metadata;
|
|
557
664
|
private actions;
|
|
558
665
|
/** @public */
|
|
559
666
|
get definition(): HumanTurnDefinition<TParams, TState>;
|
|
@@ -610,11 +717,26 @@ export declare class ExternalRouteBuilder<TParams = unknown, TState = unknown, T
|
|
|
610
717
|
/** @internal */
|
|
611
718
|
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput> | undefined;
|
|
612
719
|
/** @internal */
|
|
613
|
-
|
|
720
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
721
|
+
} | {
|
|
614
722
|
/** @internal */
|
|
615
|
-
|
|
723
|
+
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput> | undefined;
|
|
616
724
|
/** @internal */
|
|
617
|
-
|
|
725
|
+
to: TurnId;
|
|
726
|
+
/** @internal */
|
|
727
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
728
|
+
} | {
|
|
729
|
+
/** @internal */
|
|
730
|
+
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput> | undefined;
|
|
731
|
+
/** @internal */
|
|
732
|
+
complete: true;
|
|
733
|
+
/** @internal */
|
|
734
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
735
|
+
} | {
|
|
736
|
+
/** @internal */
|
|
737
|
+
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput> | undefined;
|
|
738
|
+
/** @internal */
|
|
739
|
+
lifecycleStatus: ProcessTurnTerminalLifecycleStatus;
|
|
618
740
|
/** @internal */
|
|
619
741
|
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
620
742
|
};
|
|
@@ -664,18 +786,8 @@ export declare class FlowFragmentBuilder<TParams = unknown, TState = unknown> ex
|
|
|
664
786
|
/** @public */
|
|
665
787
|
export declare class FlowProcessBuilder<TParams = unknown, TState = unknown> extends FlowComponentBuilder<TParams, TState> {
|
|
666
788
|
private readonly processId;
|
|
667
|
-
private
|
|
668
|
-
private entryTurnId;
|
|
789
|
+
private readonly configuration;
|
|
669
790
|
private readonly alternateEntryTurnIds;
|
|
670
|
-
private happyPathTurnIds;
|
|
671
|
-
private paramsCodec;
|
|
672
|
-
private stateCodec;
|
|
673
|
-
private initialStateFn;
|
|
674
|
-
private repositoryCredentialsFn;
|
|
675
|
-
private storageSizeResolver;
|
|
676
|
-
private processPiConfig;
|
|
677
|
-
private developmentTools;
|
|
678
|
-
private docker;
|
|
679
791
|
/** @internal */
|
|
680
792
|
constructor(processId: string);
|
|
681
793
|
/** @public */
|
|
@@ -712,6 +824,8 @@ export declare class FlowProcessBuilder<TParams = unknown, TState = unknown> ext
|
|
|
712
824
|
developmentTools?: boolean;
|
|
713
825
|
/** @public */
|
|
714
826
|
docker?: boolean;
|
|
827
|
+
/** @internal */
|
|
828
|
+
repositoryCheckout?: "eager" | "on_demand" | "none";
|
|
715
829
|
}): this;
|
|
716
830
|
/** @internal */
|
|
717
831
|
use(fragment: FlowFragmentBuilder<TParams, TState>): this;
|
|
@@ -722,6 +836,8 @@ export declare class FlowProcessBuilder<TParams = unknown, TState = unknown> ext
|
|
|
722
836
|
export declare const flow: {
|
|
723
837
|
/** @public */
|
|
724
838
|
llm<TParams = unknown, TState = unknown>(turnId: TurnId): LlmFlowBuilder<TParams, TState>;
|
|
839
|
+
/** Run an LLM turn sequentially over frozen items, then collect and route once. @public */
|
|
840
|
+
mappedLlm<TParams = unknown, TState = unknown, TItem = unknown, TResult = unknown>(turnId: TurnId, items: FlowForEachOptions<TParams, TState, TItem, TResult>): MappedLlmFlowBuilder<TParams, TState, TItem, TResult>;
|
|
725
841
|
/** @public */
|
|
726
842
|
automatic<TParams = unknown, TState = unknown>(turnId: TurnId): AutomaticFlowBuilder<TParams, TState>;
|
|
727
843
|
/** @public */
|