@leitwerk-dev/process-sdk 0.3.1 → 0.4.1
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-GVBLXKSR.js → chunk-HT2AXXLH.js} +2 -1
- package/dist/chunk-HT2AXXLH.js.map +1 -0
- package/dist/core-capabilities.d.ts +63 -2
- package/dist/core-capabilities.d.ts.map +1 -1
- package/dist/define-process.d.ts +40 -26
- package/dist/define-process.d.ts.map +1 -1
- package/dist/{extension-api-DM-AvWOW.d.ts → extension-api-Ljc4UTZ0.d.ts} +258 -64
- package/dist/extension-api.d.ts +52 -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 +188 -177
- package/dist/flow.d.ts.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4387 -4313
- package/dist/index.js.map +1 -1
- package/dist/mapped-turn.d.ts +6 -22
- package/dist/mapped-turn.d.ts.map +1 -1
- package/dist/outcome-contract.d.ts +19 -0
- package/dist/outcome-contract.d.ts.map +1 -0
- package/dist/outcome-schema.d.ts +25 -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 +31 -18
- package/dist/types.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/core-capabilities.ts +87 -1
- package/src/define-process.ts +420 -596
- package/src/extension-api.ts +60 -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 +746 -815
- package/src/index.ts +48 -1
- package/src/mapped-turn.ts +74 -23
- package/src/outcome-contract.ts +119 -0
- package/src/outcome-schema.ts +315 -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 +85 -193
- package/src/turn-wait.ts +76 -0
- package/src/types.ts +30 -16
- package/dist/chunk-GVBLXKSR.js.map +0 -1
package/dist/flow.d.ts
CHANGED
|
@@ -1,8 +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";
|
|
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
4
|
import type { MappedCollect, MappedCollectRouting, MappedItemYield, MappedLlmTurnSpec, MappedTurnItemContext, MappedTurnServerContext } from "./mapped-turn.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { TurnWaitPredicate } from "./turn-wait.js";
|
|
6
|
+
import type { OutcomeToolArrayItemSpec, OutcomeToolParameterSpec, PiBuiltInToolName, ProcessPiConfig } from "./types.js";
|
|
6
7
|
/** @public */
|
|
7
8
|
type MaybePromise<T> = T | Promise<T>;
|
|
8
9
|
/** @internal */
|
|
@@ -115,6 +116,8 @@ export type FlowPromptContext<TParams = unknown, TState = unknown, TConsumedProd
|
|
|
115
116
|
});
|
|
116
117
|
/** @public */
|
|
117
118
|
export interface FlowAutomaticRunContext<TParams = unknown, TState = unknown> {
|
|
119
|
+
/** Immutable non-secret settings captured for this turn. @public */
|
|
120
|
+
readonly scopedSettings?: ScopedSettingsSnapshot;
|
|
118
121
|
/** @public */
|
|
119
122
|
process: ProcessInstance;
|
|
120
123
|
/** @public */
|
|
@@ -131,6 +134,13 @@ export interface FlowAutomaticRunContext<TParams = unknown, TState = unknown> {
|
|
|
131
134
|
callIntegrationTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
132
135
|
/** @public */
|
|
133
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;
|
|
134
144
|
}
|
|
135
145
|
/** @public */
|
|
136
146
|
export type FlowLlmPreparationContext<TParams = unknown, TState = unknown> = FlowAutomaticRunContext<TParams, TState>;
|
|
@@ -199,40 +209,23 @@ declare class RouteAndEffectBuilder<TParams, TState, TContext> {
|
|
|
199
209
|
/** @public */
|
|
200
210
|
effect(fn: FlowOutcomeEffect<TParams, TState, TContext>): this;
|
|
201
211
|
/** @internal */
|
|
212
|
+
getEffect(): FlowOutcomeEffect<TParams, TState, TContext> | undefined;
|
|
213
|
+
/** @internal */
|
|
202
214
|
hasRoute(): boolean;
|
|
203
215
|
/** @internal */
|
|
204
|
-
|
|
205
|
-
/** @internal */
|
|
206
|
-
to?: TurnId;
|
|
207
|
-
/** @internal */
|
|
208
|
-
complete?: boolean;
|
|
209
|
-
/** @internal */
|
|
210
|
-
lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
|
|
211
|
-
};
|
|
216
|
+
buildRouteTarget(): Pick<ProcessTurnEndSpec, "to" | "complete" | "lifecycleStatus">;
|
|
212
217
|
}
|
|
213
218
|
/** @internal */
|
|
214
219
|
export type FlowTargetSpec = {
|
|
215
220
|
/** @internal */
|
|
216
|
-
|
|
217
|
-
/** @internal */
|
|
218
|
-
turnId: TurnId;
|
|
221
|
+
to: TurnId;
|
|
219
222
|
} | {
|
|
220
223
|
/** @internal */
|
|
221
|
-
|
|
224
|
+
complete: true;
|
|
222
225
|
} | {
|
|
223
226
|
/** @internal */
|
|
224
|
-
|
|
225
|
-
/** @internal */
|
|
226
|
-
status: ProcessTurnTerminalLifecycleStatus;
|
|
227
|
+
lifecycleStatus: ProcessTurnTerminalLifecycleStatus;
|
|
227
228
|
} | null;
|
|
228
|
-
export declare function buildRouteTargetSpec(target: FlowTargetSpec): {
|
|
229
|
-
/** @internal */
|
|
230
|
-
to?: TurnId;
|
|
231
|
-
/** @internal */
|
|
232
|
-
complete?: boolean;
|
|
233
|
-
/** @internal */
|
|
234
|
-
lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
|
|
235
|
-
};
|
|
236
229
|
/** @public */
|
|
237
230
|
interface ParameterOptions extends Partial<Omit<OutcomeToolParameterSpec, "type" | "description">> {
|
|
238
231
|
/** @public */
|
|
@@ -256,42 +249,46 @@ interface MarkdownParameterOptions extends ParameterOptions {
|
|
|
256
249
|
publish?: true;
|
|
257
250
|
}
|
|
258
251
|
/** @public */
|
|
259
|
-
declare class
|
|
252
|
+
declare class OutcomeParametersBuilder<TParams = unknown, TState = unknown> {
|
|
260
253
|
/** @internal */
|
|
261
254
|
protected outcomeDescription: string | null;
|
|
262
255
|
/** @internal */
|
|
263
256
|
protected parameters: Record<string, OutcomeToolParameterSpec>;
|
|
264
257
|
/** @internal */
|
|
265
|
-
protected publishedMarkdownParameter: string | null;
|
|
266
|
-
/** @internal */
|
|
267
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;
|
|
268
266
|
/** Optional concise result publication, separate from the full Markdown. @public */
|
|
269
267
|
resultSummary(name?: string): this;
|
|
270
268
|
/** @internal */
|
|
271
|
-
protected buildParameterSpec(kind: string): ProcessToolOutcomeSpec
|
|
269
|
+
protected buildParameterSpec(kind: string): Pick<ProcessToolOutcomeSpec, "description" | "parameters" | "resultSummaryParameter">;
|
|
272
270
|
/** @public */
|
|
273
271
|
description(text: string): this;
|
|
274
272
|
/** @internal */
|
|
275
273
|
parameter(name: string, spec: OutcomeToolParameterSpec): this;
|
|
276
274
|
private withRequired;
|
|
277
|
-
private typedParameter;
|
|
278
275
|
/** @internal */
|
|
279
|
-
|
|
276
|
+
protected typedParameter(name: string, type: OutcomeToolParameterSpec["type"], options?: string | ArrayParameterOptions): this;
|
|
280
277
|
/** @public */
|
|
281
|
-
|
|
278
|
+
string(name: string, options?: string | ParameterOptions): this;
|
|
282
279
|
/** @public */
|
|
283
280
|
requiredString(name: string, options?: string | ParameterOptions): this;
|
|
284
281
|
/** @internal */
|
|
285
282
|
number(name: string, options?: string | ParameterOptions): this;
|
|
286
|
-
/** @
|
|
283
|
+
/** @public */
|
|
287
284
|
requiredNumber(name: string, options?: string | ParameterOptions): this;
|
|
288
285
|
/** @internal */
|
|
289
286
|
boolean(name: string, options?: string | ParameterOptions): this;
|
|
290
|
-
/** @
|
|
287
|
+
/** @public */
|
|
291
288
|
requiredBoolean(name: string, options?: string | ParameterOptions): this;
|
|
292
289
|
/** @internal */
|
|
293
290
|
stringArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
294
|
-
/** @
|
|
291
|
+
/** @public */
|
|
295
292
|
requiredStringArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
296
293
|
/** @internal */
|
|
297
294
|
enum(name: string, valuesOrOptions: readonly string[] | EnumParameterOptions): this;
|
|
@@ -303,10 +300,39 @@ declare class ParameterizedOutcomeBuilder<TParams, TState, TContext> extends Rou
|
|
|
303
300
|
requiredArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
304
301
|
}
|
|
305
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;
|
|
328
|
+
}
|
|
329
|
+
/** @public */
|
|
306
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;
|
|
307
333
|
private stateRouting;
|
|
308
334
|
/** @public */
|
|
309
|
-
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;
|
|
310
336
|
/** @internal */
|
|
311
337
|
build(): ProcessToolOutcomeSpec<TParams, TState>;
|
|
312
338
|
}
|
|
@@ -336,11 +362,11 @@ export declare class PlanResultBuilder<TParams = unknown, TState = unknown> exte
|
|
|
336
362
|
buildOutcome(): ProcessToolOutcomeSpec<TParams, TState>;
|
|
337
363
|
}
|
|
338
364
|
/** @public */
|
|
339
|
-
declare
|
|
365
|
+
export declare class LlmTurnEndBuilder<TParams = unknown, TState = unknown> extends RouteAndEffectBuilder<TParams, TState, FlowLlmOutcomeEffectContext<TParams, TState>> implements FlowLlmTurn<TParams, TState, string> {
|
|
340
366
|
private readonly outcomeId;
|
|
341
367
|
private readonly parent?;
|
|
342
368
|
/** @internal */
|
|
343
|
-
protected
|
|
369
|
+
protected readonly builderName: string;
|
|
344
370
|
/** @internal */
|
|
345
371
|
constructor(outcomeId: string, parent?: FlowLlmTurn<TParams, TState, string> | undefined);
|
|
346
372
|
private get turn();
|
|
@@ -349,27 +375,16 @@ declare abstract class TurnEndBuilder<TParams, TState> extends RouteAndEffectBui
|
|
|
349
375
|
/** @internal */
|
|
350
376
|
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
351
377
|
/** @internal */
|
|
352
|
-
|
|
378
|
+
build(): ProcessTurnEndSpec<TParams, TState, string>;
|
|
353
379
|
}
|
|
354
380
|
/** @public */
|
|
355
|
-
export declare class PublishedResultBuilder<TParams = unknown, TState = unknown> extends
|
|
381
|
+
export declare class PublishedResultBuilder<TParams = unknown, TState = unknown> extends LlmTurnEndBuilder<TParams, TState> {
|
|
356
382
|
/** @internal */
|
|
357
383
|
protected readonly builderName = "Published result";
|
|
358
384
|
/** @internal */
|
|
359
385
|
buildTurnEnd(): ProcessTurnEndSpec<TParams, TState, string>;
|
|
360
386
|
}
|
|
361
387
|
/** @public */
|
|
362
|
-
export declare class LlmTurnEndBuilder<TParams = unknown, TState = unknown> extends TurnEndBuilder<TParams, TState> {
|
|
363
|
-
/** @internal */
|
|
364
|
-
protected readonly builderName = "LLM turn end";
|
|
365
|
-
/** @internal */
|
|
366
|
-
constructor(outcomeId: string, parent?: FlowLlmTurn<TParams, TState, string>);
|
|
367
|
-
/** @internal */
|
|
368
|
-
build(): ProcessTurnEndSpec<TParams, TState, string>;
|
|
369
|
-
}
|
|
370
|
-
/** @public */
|
|
371
|
-
type LlmPromptBuilder<TParams, TState, TConsumedProducts extends string, TPrepared> = (ctx: FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared>) => MaybePromise<string>;
|
|
372
|
-
/** @public */
|
|
373
388
|
declare abstract class DescribedTurnBuilder {
|
|
374
389
|
/** @internal */
|
|
375
390
|
protected readonly turnId: TurnId;
|
|
@@ -385,40 +400,52 @@ declare abstract class DescribedTurnBuilder {
|
|
|
385
400
|
description(description: string): this;
|
|
386
401
|
}
|
|
387
402
|
/** @public */
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
private
|
|
392
|
-
|
|
393
|
-
|
|
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;
|
|
394
442
|
private promptBuilder;
|
|
395
|
-
private branchType;
|
|
396
|
-
private context;
|
|
397
|
-
private questionsEnabled;
|
|
398
|
-
private startFrom;
|
|
399
|
-
private restorePrimaryLeafAfterTurn;
|
|
400
443
|
private readonly consumedProductNames;
|
|
401
444
|
private readonly optionalConsumedProductNames;
|
|
402
|
-
private publishedResult;
|
|
403
|
-
private endResult;
|
|
404
|
-
private outcomeToolBuilders;
|
|
405
|
-
private mapped;
|
|
406
|
-
/** @internal */
|
|
407
|
-
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
408
|
-
/**
|
|
409
|
-
* Run this turn once per frozen item. Items run sequentially; each item's
|
|
410
|
-
* outcome yields a typed result, and `collect` updates state and routes once.
|
|
411
|
-
* @public
|
|
412
|
-
*/
|
|
413
|
-
forEach<TItem, TResult>(options: FlowForEachOptions<TParams, TState, TItem, TResult>): MappedLlmFlowBuilder<TParams, TState, TItem, TResult, TConsumedProducts, TPrepared>;
|
|
414
|
-
/** @internal */
|
|
415
|
-
addMappedOutcome(id: string, builder: OutcomeToolBuilder<TParams, TState>, yieldResult: MappedItemYield<TParams, TState, unknown, unknown>): void;
|
|
416
445
|
/** @internal */
|
|
417
|
-
|
|
418
|
-
/** @
|
|
419
|
-
|
|
420
|
-
private mappedItemContext;
|
|
421
|
-
private buildMappedSpec;
|
|
446
|
+
protected abstract itemContext(ctx: ProcessRuntimeTurnContext<TParams, TState>): LlmItemContext<TFamily>;
|
|
447
|
+
/** @public */
|
|
448
|
+
executionPurpose(purpose: string): this;
|
|
422
449
|
/** @internal */
|
|
423
450
|
modelPurpose(purpose: LlmModelPurpose): this;
|
|
424
451
|
/** @public */
|
|
@@ -428,9 +455,11 @@ export declare class LlmFlowBuilder<TParams = unknown, TState = unknown, TConsum
|
|
|
428
455
|
/** @public */
|
|
429
456
|
resolveIntegrationTools(resolver: (params: TParams, state: TState) => readonly string[]): this;
|
|
430
457
|
/** @public */
|
|
431
|
-
prepare<TNextPrepared>(fn: (ctx: FlowLlmPreparationContext<TParams, TState>) => MaybePromise<TNextPrepared>):
|
|
432
|
-
/**
|
|
433
|
-
|
|
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;
|
|
434
463
|
/** @public */
|
|
435
464
|
freshPrimary(): this;
|
|
436
465
|
/** @internal */
|
|
@@ -452,26 +481,38 @@ export declare class LlmFlowBuilder<TParams = unknown, TState = unknown, TConsum
|
|
|
452
481
|
/** @internal */
|
|
453
482
|
startFromRoot(): this;
|
|
454
483
|
/** @public */
|
|
455
|
-
consume<TProductName extends string>(productName: TProductName):
|
|
484
|
+
consume<TProductName extends string>(productName: TProductName): ConfiguredLlmBuilder<TFamily, TParams, TState, TConsumedProducts | TProductName, TPrepared>;
|
|
456
485
|
/** @public */
|
|
457
|
-
optionalConsume<TProductName extends string>(productName: TProductName):
|
|
486
|
+
optionalConsume<TProductName extends string>(productName: TProductName): ConfiguredLlmBuilder<TFamily, TParams, TState, TConsumedProducts | TProductName, TPrepared>;
|
|
487
|
+
private refineContext;
|
|
458
488
|
/** @public */
|
|
459
|
-
|
|
489
|
+
buildPrompt(fn: (ctx: FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared> & LlmItemContext<TFamily>) => MaybePromise<string>): this;
|
|
460
490
|
/** @public */
|
|
461
|
-
|
|
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>;
|
|
462
504
|
/** @public */
|
|
463
|
-
|
|
464
|
-
private assertNotMapped;
|
|
505
|
+
publish(productName: string): PublishedResultBuilder<TParams, TState>;
|
|
465
506
|
/** @public */
|
|
466
|
-
|
|
507
|
+
end(outcomeId: string): LlmTurnEndBuilder<TParams, TState>;
|
|
467
508
|
/** @public */
|
|
468
509
|
outcomeTool(id: string, configure: (tool: OutcomeToolBuilder<TParams, TState>) => OutcomeToolBuilder<TParams, TState> | undefined): this;
|
|
469
|
-
private buildBaseDefinition;
|
|
470
510
|
/** @internal */
|
|
471
511
|
producesPlan(configure: (plan: PlanResultBuilder<TParams, TState>) => PlanResultBuilder<TParams, TState>): FlowLlmTurn<TParams, TState, typeof DEFAULT_PLAN_RESULT_OUTCOME_ID>;
|
|
472
|
-
|
|
512
|
+
/** @internal */
|
|
513
|
+
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
473
514
|
}
|
|
474
|
-
/** Item selection for `flow.
|
|
515
|
+
/** Item selection for `flow.mappedLlm(...)`. @public */
|
|
475
516
|
export type FlowForEachOptions<TParams, TState, TItem, TResult> = Pick<MappedLlmTurnSpec<TParams, TState, TItem, TResult>, "items" | "itemCodec" | "resultCodec" | "key" | "label" | "stateAfterSnapshot">;
|
|
476
517
|
/** @public */
|
|
477
518
|
export type FlowMappedPromptContext<TParams, TState, TItem, TConsumedProducts extends string, TPrepared> = FlowPromptContext<TParams, TState, TConsumedProducts, TPrepared> & MappedTurnItemContext<TItem>;
|
|
@@ -482,55 +523,30 @@ export type FlowMappedPreparationContext<TParams, TState, TItem> = FlowLlmPrepar
|
|
|
482
523
|
* result; it cannot route, change process state, or publish products.
|
|
483
524
|
* @public
|
|
484
525
|
*/
|
|
485
|
-
export declare class MappedOutcomeBuilder<TParams = unknown, TState = unknown, TItem = unknown, TResult = unknown> {
|
|
486
|
-
|
|
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;
|
|
487
529
|
private yieldResult;
|
|
488
|
-
/** @public */
|
|
489
|
-
description(text: string): this;
|
|
490
|
-
/** @public */
|
|
491
|
-
resultSummary(name?: string): this;
|
|
492
|
-
/** @public */
|
|
493
|
-
requiredString(name: string, options?: string | ParameterOptions): this;
|
|
494
|
-
/** @public */
|
|
495
|
-
string(name: string, options?: string | ParameterOptions): this;
|
|
496
|
-
/** @public */
|
|
497
|
-
requiredNumber(name: string, options?: string | ParameterOptions): this;
|
|
498
|
-
/** @public */
|
|
499
|
-
requiredBoolean(name: string, options?: string | ParameterOptions): this;
|
|
500
|
-
/** @public */
|
|
501
|
-
requiredStringArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
502
|
-
/** @public */
|
|
503
|
-
object(name: string, options?: string | ParameterOptions): this;
|
|
504
|
-
/** @public */
|
|
505
|
-
requiredArray(name: string, options?: string | ArrayParameterOptions): this;
|
|
506
530
|
/** Map this outcome to the item's typed result. @public */
|
|
507
531
|
yield(fn: MappedItemYield<TParams, TState, TItem, TResult>): this;
|
|
508
532
|
/** @internal */
|
|
509
533
|
build(): {
|
|
510
534
|
/** @internal */
|
|
511
|
-
tool:
|
|
535
|
+
tool: ProcessToolOutcomeSpec<TParams, TState>;
|
|
512
536
|
/** @internal */
|
|
513
537
|
yieldResult: MappedItemYield<TParams, TState, TItem, TResult>;
|
|
514
538
|
};
|
|
515
539
|
}
|
|
516
|
-
/** @public */
|
|
517
|
-
declare
|
|
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;
|
|
518
544
|
/** @internal */
|
|
519
|
-
|
|
520
|
-
/** @internal */
|
|
521
|
-
constructor(
|
|
522
|
-
/** @internal */
|
|
523
|
-
base: LlmFlowBuilder<TParams, TState, string, unknown>);
|
|
545
|
+
constructor(turn: FlowLlmTurn<TParams, TState, string>, setRouting: (routing: MappedCollectRouting<TParams, TState>) => void);
|
|
524
546
|
/** @internal */
|
|
525
547
|
get id(): TurnId;
|
|
526
548
|
/** @internal */
|
|
527
549
|
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Routes a mapped turn once, after all item results are collected.
|
|
531
|
-
* @public
|
|
532
|
-
*/
|
|
533
|
-
export declare class MappedCollectBuilder<TParams = unknown, TState = unknown> extends MappedTurnFacade<TParams, TState> {
|
|
534
550
|
/** @public */
|
|
535
551
|
to(turnId: TurnId): this;
|
|
536
552
|
/** @public */
|
|
@@ -545,37 +561,25 @@ export declare class MappedCollectBuilder<TParams = unknown, TState = unknown> e
|
|
|
545
561
|
* to `.collect(...)`.
|
|
546
562
|
* @public
|
|
547
563
|
*/
|
|
548
|
-
export declare class MappedLlmFlowBuilder<TParams = unknown, TState = unknown, TItem = unknown, TResult = unknown, TConsumedProducts extends string = never, TPrepared = undefined> extends
|
|
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;
|
|
549
573
|
/** @internal */
|
|
550
|
-
constructor(
|
|
551
|
-
/** @
|
|
552
|
-
|
|
553
|
-
/** @public */
|
|
554
|
-
tools(...tools: readonly PiBuiltInToolName[]): this;
|
|
555
|
-
/** @public */
|
|
556
|
-
integrationTools(...tools: readonly string[]): this;
|
|
557
|
-
/** @public */
|
|
558
|
-
freshPrimary(): this;
|
|
559
|
-
/** @public */
|
|
560
|
-
consume<TProductName extends string>(productName: TProductName): MappedLlmFlowBuilder<TParams, TState, TItem, TResult, TConsumedProducts | TProductName, TPrepared>;
|
|
561
|
-
/** Deterministic worker preparation for the active item. @public */
|
|
562
|
-
prepare<TNextPrepared>(fn: (ctx: FlowMappedPreparationContext<TParams, TState, TItem>) => MaybePromise<TNextPrepared>): MappedLlmFlowBuilder<TParams, TState, TItem, TResult, TConsumedProducts, TNextPrepared>;
|
|
563
|
-
/** Build the prompt for the active item. @public */
|
|
564
|
-
buildPrompt(fn: (ctx: FlowMappedPromptContext<TParams, TState, TItem, TConsumedProducts, TPrepared>) => MaybePromise<string>): this;
|
|
574
|
+
constructor(turnId: TurnId, items: FlowForEachOptions<TParams, TState, TItem, TResult>);
|
|
575
|
+
/** @internal */
|
|
576
|
+
protected itemContext(ctx: ProcessRuntimeTurnContext<TParams, TState>): MappedTurnItemContext<TItem>;
|
|
565
577
|
/** @public */
|
|
566
578
|
outcomeTool(id: string, configure: (outcome: MappedOutcomeBuilder<TParams, TState, TItem, TResult>) => MappedOutcomeBuilder<TParams, TState, TItem, TResult> | undefined): this;
|
|
567
579
|
/** Combine ordered item results into process state, once. @public */
|
|
568
580
|
collect(fn: MappedCollect<TParams, TState, TResult>): MappedCollectBuilder<TParams, TState>;
|
|
569
|
-
}
|
|
570
|
-
/** @public */
|
|
571
|
-
declare abstract class ExternalActionTurnBuilder<TParams, TState> extends DescribedTurnBuilder {
|
|
572
|
-
/** @internal */
|
|
573
|
-
protected abstract readonly turnKind: "Automatic" | "Human";
|
|
574
|
-
private externalActionBuilders;
|
|
575
|
-
/** @public */
|
|
576
|
-
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;
|
|
577
581
|
/** @internal */
|
|
578
|
-
|
|
582
|
+
get definition(): LlmTurnDefinition<string, TParams, TState>;
|
|
579
583
|
}
|
|
580
584
|
/** @public */
|
|
581
585
|
export declare class AutomaticFlowBuilder<TParams = unknown, TState = unknown> extends ExternalActionTurnBuilder<TParams, TState> implements FlowAutomaticTurn<TParams, TState, string> {
|
|
@@ -584,15 +588,17 @@ export declare class AutomaticFlowBuilder<TParams = unknown, TState = unknown> e
|
|
|
584
588
|
private runFn;
|
|
585
589
|
private outcomeBuilders;
|
|
586
590
|
private availableIntegrationTools;
|
|
587
|
-
|
|
588
|
-
|
|
591
|
+
private waitPredicate;
|
|
592
|
+
/** Wait on the server before this turn may allocate a worker. @public */
|
|
593
|
+
waitFor(predicate: TurnWaitPredicate<TParams, TState>): this;
|
|
589
594
|
/** @public */
|
|
590
595
|
run(fn: (ctx: FlowAutomaticRunContext<TParams, TState>) => MaybePromise<WorkerCompleteInput<string>>): this;
|
|
591
596
|
/** @public */
|
|
592
597
|
integrationTools(...tools: readonly string[]): this;
|
|
593
598
|
/** @public */
|
|
594
599
|
outcome(id: string, configure: (outcome: AutomaticOutcomeBuilder<TParams, TState>) => AutomaticOutcomeBuilder<TParams, TState> | undefined): this;
|
|
595
|
-
|
|
600
|
+
/** @internal */
|
|
601
|
+
get definition(): AutomaticTurnDefinition<string, TParams, TState>;
|
|
596
602
|
}
|
|
597
603
|
/** @public */
|
|
598
604
|
export declare class HumanActionBuilder<TParams = unknown, TState = unknown> {
|
|
@@ -654,11 +660,7 @@ export declare class ExternalActionBuilder<TParams = unknown, TState = unknown,
|
|
|
654
660
|
export declare class HumanFlowBuilder<TParams = unknown, TState = unknown> extends ExternalActionTurnBuilder<TParams, TState> implements FlowHumanTurn<TParams, TState> {
|
|
655
661
|
/** @internal */
|
|
656
662
|
protected readonly turnKind = "Human";
|
|
657
|
-
private
|
|
658
|
-
private reviewSemanticRef;
|
|
659
|
-
private operatorAttentionValue;
|
|
660
|
-
private turnCommentary;
|
|
661
|
-
private notes;
|
|
663
|
+
private readonly metadata;
|
|
662
664
|
private actions;
|
|
663
665
|
/** @public */
|
|
664
666
|
get definition(): HumanTurnDefinition<TParams, TState>;
|
|
@@ -715,11 +717,26 @@ export declare class ExternalRouteBuilder<TParams = unknown, TState = unknown, T
|
|
|
715
717
|
/** @internal */
|
|
716
718
|
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput> | undefined;
|
|
717
719
|
/** @internal */
|
|
718
|
-
|
|
720
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
721
|
+
} | {
|
|
719
722
|
/** @internal */
|
|
720
|
-
|
|
723
|
+
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput> | undefined;
|
|
721
724
|
/** @internal */
|
|
722
|
-
|
|
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;
|
|
723
740
|
/** @internal */
|
|
724
741
|
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
725
742
|
};
|
|
@@ -769,18 +786,8 @@ export declare class FlowFragmentBuilder<TParams = unknown, TState = unknown> ex
|
|
|
769
786
|
/** @public */
|
|
770
787
|
export declare class FlowProcessBuilder<TParams = unknown, TState = unknown> extends FlowComponentBuilder<TParams, TState> {
|
|
771
788
|
private readonly processId;
|
|
772
|
-
private
|
|
773
|
-
private entryTurnId;
|
|
789
|
+
private readonly configuration;
|
|
774
790
|
private readonly alternateEntryTurnIds;
|
|
775
|
-
private happyPathTurnIds;
|
|
776
|
-
private paramsCodec;
|
|
777
|
-
private stateCodec;
|
|
778
|
-
private initialStateFn;
|
|
779
|
-
private repositoryCredentialsFn;
|
|
780
|
-
private storageSizeResolver;
|
|
781
|
-
private processPiConfig;
|
|
782
|
-
private developmentTools;
|
|
783
|
-
private docker;
|
|
784
791
|
/** @internal */
|
|
785
792
|
constructor(processId: string);
|
|
786
793
|
/** @public */
|
|
@@ -817,6 +824,8 @@ export declare class FlowProcessBuilder<TParams = unknown, TState = unknown> ext
|
|
|
817
824
|
developmentTools?: boolean;
|
|
818
825
|
/** @public */
|
|
819
826
|
docker?: boolean;
|
|
827
|
+
/** @internal */
|
|
828
|
+
repositoryCheckout?: "eager" | "on_demand" | "none";
|
|
820
829
|
}): this;
|
|
821
830
|
/** @internal */
|
|
822
831
|
use(fragment: FlowFragmentBuilder<TParams, TState>): this;
|
|
@@ -827,6 +836,8 @@ export declare class FlowProcessBuilder<TParams = unknown, TState = unknown> ext
|
|
|
827
836
|
export declare const flow: {
|
|
828
837
|
/** @public */
|
|
829
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>;
|
|
830
841
|
/** @public */
|
|
831
842
|
automatic<TParams = unknown, TState = unknown>(turnId: TurnId): AutomaticFlowBuilder<TParams, TState>;
|
|
832
843
|
/** @public */
|