@leitwerk-dev/process-sdk 0.1.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/LICENSE +13 -0
- package/dist/browser-ui-extension.d.ts +27 -0
- package/dist/browser-ui-extension.d.ts.map +1 -0
- package/dist/browser-ui-extension.js +2 -0
- package/dist/browser-ui-extension.js.map +1 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +7 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/chunk-5RJZ2E7D.js +58 -0
- package/dist/chunk-5RJZ2E7D.js.map +1 -0
- package/dist/chunk-ITPH65G6.js +197 -0
- package/dist/chunk-ITPH65G6.js.map +1 -0
- package/dist/chunk-LIIP7FMU.js +48 -0
- package/dist/chunk-LIIP7FMU.js.map +1 -0
- package/dist/codecs.d.ts +3 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +9 -0
- package/dist/codecs.js.map +1 -0
- package/dist/commit-message.d.ts +7 -0
- package/dist/commit-message.d.ts.map +1 -0
- package/dist/commit-message.js +3 -0
- package/dist/commit-message.js.map +1 -0
- package/dist/core-capabilities.d.ts +393 -0
- package/dist/core-capabilities.d.ts.map +1 -0
- package/dist/core-capabilities.js +6 -0
- package/dist/core-capabilities.js.map +1 -0
- package/dist/define-process.d.ts +269 -0
- package/dist/define-process.d.ts.map +1 -0
- package/dist/define-process.js +1040 -0
- package/dist/define-process.js.map +1 -0
- package/dist/event-bus.d.ts +3 -0
- package/dist/event-bus.d.ts.map +1 -0
- package/dist/event-bus.js +31 -0
- package/dist/event-bus.js.map +1 -0
- package/dist/extension-api-CnlL69Tu.d.ts +1281 -0
- package/dist/extension-api.d.ts +425 -0
- package/dist/extension-api.d.ts.map +1 -0
- package/dist/extension-api.js +5 -0
- package/dist/extension-api.js.map +1 -0
- package/dist/flow.d.ts +456 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +1557 -0
- package/dist/flow.js.map +1 -0
- package/dist/form-contract.d.ts +2 -0
- package/dist/form-contract.d.ts.map +1 -0
- package/dist/form-contract.js +2 -0
- package/dist/form-contract.js.map +1 -0
- package/dist/fs-utils.d.ts +3 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +23 -0
- package/dist/fs-utils.js.map +1 -0
- package/dist/git-binary.d.ts +11 -0
- package/dist/git-binary.d.ts.map +1 -0
- package/dist/git-binary.js +38 -0
- package/dist/git-binary.js.map +1 -0
- package/dist/graph-fragments.d.ts +23 -0
- package/dist/graph-fragments.d.ts.map +1 -0
- package/dist/graph-fragments.js +57 -0
- package/dist/graph-fragments.js.map +1 -0
- package/dist/host-capabilities.d.ts +12 -0
- package/dist/host-capabilities.d.ts.map +1 -0
- package/dist/host-capabilities.js +42 -0
- package/dist/host-capabilities.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/launcher-contract.d.ts +2 -0
- package/dist/launcher-contract.d.ts.map +1 -0
- package/dist/launcher-contract.js +2 -0
- package/dist/launcher-contract.js.map +1 -0
- package/dist/leaf-outcome-renderer.d.ts +48 -0
- package/dist/leaf-outcome-renderer.d.ts.map +1 -0
- package/dist/leaf-outcome-renderer.js +69 -0
- package/dist/leaf-outcome-renderer.js.map +1 -0
- package/dist/leaf-outcomes.d.ts +5 -0
- package/dist/leaf-outcomes.d.ts.map +1 -0
- package/dist/leaf-outcomes.js +52 -0
- package/dist/leaf-outcomes.js.map +1 -0
- package/dist/model-provider.d.ts +210 -0
- package/dist/model-provider.d.ts.map +1 -0
- package/dist/model-provider.js +171 -0
- package/dist/model-provider.js.map +1 -0
- package/dist/pi-config.d.ts +59 -0
- package/dist/pi-config.d.ts.map +1 -0
- package/dist/pi-config.js +182 -0
- package/dist/pi-config.js.map +1 -0
- package/dist/process-definition-internals.d.ts +7 -0
- package/dist/process-definition-internals.d.ts.map +1 -0
- package/dist/process-definition-internals.js +25 -0
- package/dist/process-definition-internals.js.map +1 -0
- package/dist/process-flow-view.d.ts +20 -0
- package/dist/process-flow-view.d.ts.map +1 -0
- package/dist/process-flow-view.js +418 -0
- package/dist/process-flow-view.js.map +1 -0
- package/dist/process-graph.d.ts +45 -0
- package/dist/process-graph.d.ts.map +1 -0
- package/dist/process-graph.js +213 -0
- package/dist/process-graph.js.map +1 -0
- package/dist/process-launcher-builder.d.ts +9 -0
- package/dist/process-launcher-builder.d.ts.map +1 -0
- package/dist/process-launcher-builder.js +43 -0
- package/dist/process-launcher-builder.js.map +1 -0
- package/dist/process-watcher-builder.d.ts +10 -0
- package/dist/process-watcher-builder.d.ts.map +1 -0
- package/dist/process-watcher-builder.js +40 -0
- package/dist/process-watcher-builder.js.map +1 -0
- package/dist/registry-utils.d.ts +8 -0
- package/dist/registry-utils.d.ts.map +1 -0
- package/dist/registry-utils.js +18 -0
- package/dist/registry-utils.js.map +1 -0
- package/dist/repository-git-env.d.ts +8 -0
- package/dist/repository-git-env.d.ts.map +1 -0
- package/dist/repository-git-env.js +26 -0
- package/dist/repository-git-env.js.map +1 -0
- package/dist/review-flow.d.ts +10 -0
- package/dist/review-flow.d.ts.map +1 -0
- package/dist/review-flow.js +44 -0
- package/dist/review-flow.js.map +1 -0
- package/dist/runtime-internals.d.ts +3 -0
- package/dist/runtime-internals.d.ts.map +1 -0
- package/dist/runtime-internals.js +3 -0
- package/dist/runtime-internals.js.map +1 -0
- package/dist/server-events.d.ts +84 -0
- package/dist/server-events.d.ts.map +1 -0
- package/dist/server-events.js +2 -0
- package/dist/server-events.js.map +1 -0
- package/dist/server-process-builder.d.ts +11 -0
- package/dist/server-process-builder.d.ts.map +1 -0
- package/dist/server-process-builder.js +52 -0
- package/dist/server-process-builder.js.map +1 -0
- package/dist/state-helpers.d.ts +9 -0
- package/dist/state-helpers.d.ts.map +1 -0
- package/dist/state-helpers.js +20 -0
- package/dist/state-helpers.js.map +1 -0
- package/dist/subprocess-env.d.ts +12 -0
- package/dist/subprocess-env.d.ts.map +1 -0
- package/dist/subprocess-env.js +34 -0
- package/dist/subprocess-env.js.map +1 -0
- package/dist/tool-renderers.d.ts +10 -0
- package/dist/tool-renderers.d.ts.map +1 -0
- package/dist/tool-renderers.js +63 -0
- package/dist/tool-renderers.js.map +1 -0
- package/dist/turn-semantics.d.ts +22 -0
- package/dist/turn-semantics.d.ts.map +1 -0
- package/dist/turn-semantics.js +339 -0
- package/dist/turn-semantics.js.map +1 -0
- package/dist/types.d.ts +295 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/ui-process-builder.d.ts +9 -0
- package/dist/ui-process-builder.d.ts.map +1 -0
- package/dist/ui-process-builder.js +30 -0
- package/dist/ui-process-builder.js.map +1 -0
- package/dist/worker-process-builder.d.ts +10 -0
- package/dist/worker-process-builder.d.ts.map +1 -0
- package/dist/worker-process-builder.js +22 -0
- package/dist/worker-process-builder.js.map +1 -0
- package/package.json +72 -0
- package/src/browser-ui-extension.ts +32 -0
- package/src/capabilities.ts +16 -0
- package/src/codecs.ts +10 -0
- package/src/commit-message.ts +9 -0
- package/src/core-capabilities.ts +526 -0
- package/src/define-process.ts +1879 -0
- package/src/event-bus.ts +35 -0
- package/src/extension-api.ts +600 -0
- package/src/flow.ts +2268 -0
- package/src/form-contract.ts +11 -0
- package/src/fs-utils.ts +28 -0
- package/src/git-binary.ts +40 -0
- package/src/graph-fragments.ts +110 -0
- package/src/host-capabilities.ts +60 -0
- package/src/index.ts +468 -0
- package/src/launcher-contract.ts +8 -0
- package/src/leaf-outcome-renderer.ts +112 -0
- package/src/leaf-outcomes.ts +74 -0
- package/src/model-provider.ts +461 -0
- package/src/pi-config.ts +268 -0
- package/src/process-definition-internals.ts +46 -0
- package/src/process-flow-view.ts +479 -0
- package/src/process-graph.ts +309 -0
- package/src/process-launcher-builder.ts +59 -0
- package/src/process-watcher-builder.ts +72 -0
- package/src/registry-utils.ts +31 -0
- package/src/repository-git-env.ts +35 -0
- package/src/review-flow.ts +66 -0
- package/src/runtime-internals.ts +7 -0
- package/src/server-events.ts +105 -0
- package/src/server-process-builder.ts +90 -0
- package/src/state-helpers.ts +36 -0
- package/src/subprocess-env.ts +48 -0
- package/src/tool-renderers.ts +92 -0
- package/src/turn-semantics.ts +554 -0
- package/src/types.ts +391 -0
- package/src/ui-process-builder.ts +46 -0
- package/src/worker-process-builder.ts +33 -0
|
@@ -0,0 +1,1281 @@
|
|
|
1
|
+
import { ProcessInstance, ProcessProject, ProcessTurnRecord, WorkerErrorClass, ProcessLeafOutcomeSnapshot, ProcessQuestionRequest, TurnId, ProcessTurnTerminalLifecycleStatus, TurnAcceptanceState as TurnAcceptanceState$1, ProcessTurnRecordPathType, ProcessSemanticEntryRefKey, InputSource, InputKind, ProcessInputTarget, ReviewSubject, ProcessTurnStartSelection, ProcessLifecycleStatus, ProcessCustomizableFields } from '@leitwerk-dev/domain';
|
|
2
|
+
import { ProcessWatcherType } from '@leitwerk-dev/protocol';
|
|
3
|
+
import { ActionFormDefinition } from '@leitwerk-dev/protocol/form-contract';
|
|
4
|
+
import { LauncherCardMetadata, LauncherSchemaDefinition, LauncherFieldOptionDefinition, LauncherValidationError, UiLauncherSummaryBase } from '@leitwerk-dev/protocol/launcher-contract';
|
|
5
|
+
import { ToolCallRendererDefinition } from '@leitwerk-dev/protocol/tool-renderer-contract';
|
|
6
|
+
|
|
7
|
+
type CapabilityCardinality = "single" | "multi";
|
|
8
|
+
interface CapabilityToken<_TValue> {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly cardinality: CapabilityCardinality;
|
|
11
|
+
}
|
|
12
|
+
declare function createCapabilityToken<TValue>(id: string, options?: {
|
|
13
|
+
cardinality?: CapabilityCardinality;
|
|
14
|
+
}): CapabilityToken<TValue>;
|
|
15
|
+
|
|
16
|
+
interface ProcessCreatedEvent {
|
|
17
|
+
instanceId: string;
|
|
18
|
+
process: ProcessInstance;
|
|
19
|
+
projects: readonly ProcessProject[];
|
|
20
|
+
launcherId?: string | null;
|
|
21
|
+
}
|
|
22
|
+
interface ProcessUpdatedEvent {
|
|
23
|
+
instanceId: string;
|
|
24
|
+
process: ProcessInstance;
|
|
25
|
+
changedFields: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
interface TurnStartedEvent {
|
|
28
|
+
instanceId: string;
|
|
29
|
+
turnRecord: ProcessTurnRecord;
|
|
30
|
+
}
|
|
31
|
+
interface TurnFailedEvent {
|
|
32
|
+
instanceId: string;
|
|
33
|
+
turnRecord: ProcessTurnRecord;
|
|
34
|
+
errorSummary: string;
|
|
35
|
+
errorClass?: WorkerErrorClass | null;
|
|
36
|
+
}
|
|
37
|
+
interface LeafOutcomeCapturedEvent {
|
|
38
|
+
instanceId: string;
|
|
39
|
+
snapshot: ProcessLeafOutcomeSnapshot;
|
|
40
|
+
}
|
|
41
|
+
interface ReviewRequestedEvent {
|
|
42
|
+
instanceId: string;
|
|
43
|
+
workerId?: string;
|
|
44
|
+
changedProjects: string[];
|
|
45
|
+
}
|
|
46
|
+
interface QuestionRequestedEvent {
|
|
47
|
+
instanceId: string;
|
|
48
|
+
request: ProcessQuestionRequest;
|
|
49
|
+
}
|
|
50
|
+
interface TurnOutcomeEvent {
|
|
51
|
+
instanceId: string;
|
|
52
|
+
turnRecordId: string;
|
|
53
|
+
turnId: string;
|
|
54
|
+
outcome: string;
|
|
55
|
+
params: Record<string, unknown>;
|
|
56
|
+
turnResultMarkdown?: string | null;
|
|
57
|
+
}
|
|
58
|
+
interface PlanApprovedEvent {
|
|
59
|
+
instanceId: string;
|
|
60
|
+
externalId: string | null;
|
|
61
|
+
planRevision: number;
|
|
62
|
+
}
|
|
63
|
+
interface PlanRevisionRequestedEvent {
|
|
64
|
+
instanceId: string;
|
|
65
|
+
message: string;
|
|
66
|
+
}
|
|
67
|
+
interface PlanSavedEvent {
|
|
68
|
+
instanceId: string;
|
|
69
|
+
planRevision: number;
|
|
70
|
+
summary: string;
|
|
71
|
+
planMarkdown: string;
|
|
72
|
+
acceptanceCriteria: string[];
|
|
73
|
+
}
|
|
74
|
+
interface ReviewCompletedEvent {
|
|
75
|
+
instanceId: string;
|
|
76
|
+
hasIssues: boolean;
|
|
77
|
+
issueCount: number;
|
|
78
|
+
reviewMarkdown?: string;
|
|
79
|
+
}
|
|
80
|
+
interface ServerExtensionEventMap {
|
|
81
|
+
process_created: ProcessCreatedEvent;
|
|
82
|
+
process_updated: ProcessUpdatedEvent;
|
|
83
|
+
turn_started: TurnStartedEvent;
|
|
84
|
+
turn_failed: TurnFailedEvent;
|
|
85
|
+
leaf_outcome_captured: LeafOutcomeCapturedEvent;
|
|
86
|
+
question_requested: QuestionRequestedEvent;
|
|
87
|
+
review_requested: ReviewRequestedEvent;
|
|
88
|
+
turn_outcome: TurnOutcomeEvent;
|
|
89
|
+
plan_approved: PlanApprovedEvent;
|
|
90
|
+
plan_revision_requested: PlanRevisionRequestedEvent;
|
|
91
|
+
plan_saved: PlanSavedEvent;
|
|
92
|
+
review_completed: ReviewCompletedEvent;
|
|
93
|
+
}
|
|
94
|
+
type ServerExtensionEventName = keyof ServerExtensionEventMap;
|
|
95
|
+
type ServerExtensionEventPayloadInputMap = {
|
|
96
|
+
[K in keyof ServerExtensionEventMap]: Omit<ServerExtensionEventMap[K], "instanceId">;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
interface ProcessContext {
|
|
100
|
+
readonly process: ProcessInstance;
|
|
101
|
+
readonly selectedTurnId: TurnId | null;
|
|
102
|
+
readonly isTerminal: boolean;
|
|
103
|
+
readonly projects: readonly ProcessProject[];
|
|
104
|
+
selectTurn(turnId: TurnId | null): void;
|
|
105
|
+
}
|
|
106
|
+
interface TurnOptions {
|
|
107
|
+
reset?: boolean;
|
|
108
|
+
}
|
|
109
|
+
interface TurnResult<T extends string = string> {
|
|
110
|
+
outcome: T;
|
|
111
|
+
params: Record<string, unknown>;
|
|
112
|
+
}
|
|
113
|
+
declare const PI_BUILT_IN_TOOL_NAMES: readonly ["read", "bash", "edit", "write", "grep", "find", "ls"];
|
|
114
|
+
type PiBuiltInToolName = (typeof PI_BUILT_IN_TOOL_NAMES)[number];
|
|
115
|
+
interface ProcessPiConfig {
|
|
116
|
+
/**
|
|
117
|
+
* System prompt template. Rendered with Mustache against runtime context.
|
|
118
|
+
* Use {{variableName}} for escaped values and {{{variableName}}} for raw values.
|
|
119
|
+
* When omitted, Pi's default system prompt is used.
|
|
120
|
+
*/
|
|
121
|
+
systemPromptTemplate?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Additional text appended after the base system prompt/resources. Rendered
|
|
124
|
+
* with Mustache against runtime context.
|
|
125
|
+
*/
|
|
126
|
+
appendSystemPromptTemplate?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Code-defined Pi session working directory template. Rendered with Mustache
|
|
129
|
+
* against runtime context. When omitted, the process workspace root is used.
|
|
130
|
+
*/
|
|
131
|
+
sessionCwdTemplate?: string;
|
|
132
|
+
}
|
|
133
|
+
interface ResolvedProcessPiConfig {
|
|
134
|
+
systemPrompt?: string;
|
|
135
|
+
appendSystemPrompt?: string;
|
|
136
|
+
sessionCwd?: string;
|
|
137
|
+
availableToolNames: string[];
|
|
138
|
+
}
|
|
139
|
+
type OutcomeToolParameterType = "string" | "number" | "array" | "boolean" | "object";
|
|
140
|
+
type OutcomeToolArrayItemType = Exclude<OutcomeToolParameterType, "array">;
|
|
141
|
+
interface OutcomeToolArrayItemSpec {
|
|
142
|
+
type: OutcomeToolArrayItemType;
|
|
143
|
+
description?: string;
|
|
144
|
+
}
|
|
145
|
+
interface OutcomeToolParameterSpec {
|
|
146
|
+
type: OutcomeToolParameterType;
|
|
147
|
+
description: string;
|
|
148
|
+
required?: boolean;
|
|
149
|
+
requiredErrorCode?: string;
|
|
150
|
+
invalidErrorCode?: string;
|
|
151
|
+
minItems?: number;
|
|
152
|
+
minItemsErrorCode?: string;
|
|
153
|
+
minimum?: number;
|
|
154
|
+
minimumErrorCode?: string;
|
|
155
|
+
items?: OutcomeToolArrayItemSpec;
|
|
156
|
+
enum?: readonly string[];
|
|
157
|
+
}
|
|
158
|
+
interface OutcomeToolSpec {
|
|
159
|
+
description: string;
|
|
160
|
+
parameters: Record<string, OutcomeToolParameterSpec>;
|
|
161
|
+
/** Product published from this outcome's turn-result markdown, when selected. */
|
|
162
|
+
publishedProduct?: string;
|
|
163
|
+
/** Outcome parameter whose markdown value is captured as the turn result. */
|
|
164
|
+
turnResultMarkdownParameter?: string;
|
|
165
|
+
}
|
|
166
|
+
interface ProcessToolResult {
|
|
167
|
+
status: string;
|
|
168
|
+
outcome?: string;
|
|
169
|
+
}
|
|
170
|
+
interface PiTreeEntry {
|
|
171
|
+
readonly id: string;
|
|
172
|
+
readonly parentId: string | null;
|
|
173
|
+
readonly type: string;
|
|
174
|
+
readonly timestamp: string;
|
|
175
|
+
readonly message?: {
|
|
176
|
+
readonly role?: string;
|
|
177
|
+
readonly content?: unknown;
|
|
178
|
+
};
|
|
179
|
+
/** Pi custom-message fields. Details are intentionally excluded from model context. */
|
|
180
|
+
readonly customType?: string;
|
|
181
|
+
readonly content?: unknown;
|
|
182
|
+
readonly details?: unknown;
|
|
183
|
+
readonly targetId?: string;
|
|
184
|
+
readonly label?: string;
|
|
185
|
+
}
|
|
186
|
+
interface PiTreeNode {
|
|
187
|
+
readonly entry: PiTreeEntry;
|
|
188
|
+
readonly children: readonly PiTreeNode[];
|
|
189
|
+
readonly label?: string;
|
|
190
|
+
readonly labelTimestamp?: string;
|
|
191
|
+
}
|
|
192
|
+
interface PiTurnExecutionResult {
|
|
193
|
+
startLeafId: string | null;
|
|
194
|
+
endLeafId: string | null;
|
|
195
|
+
createdEntryIds: string[];
|
|
196
|
+
resultEntryId: string;
|
|
197
|
+
/** Final assistant markdown captured from the Pi assistant message for this turn, when available. */
|
|
198
|
+
assistantMarkdown?: string | null;
|
|
199
|
+
}
|
|
200
|
+
type PiEventType = "turn.start" | "turn.end" | "stream.delta" | "tool.call" | "tool.update" | "tool.result" | "toolcall.start" | "toolcall.delta" | "toolcall.end" | "compaction.start" | "compaction.end" | "label.changed" | "error" | "retry.start" | "retry.end" | "usage";
|
|
201
|
+
interface PiEvent {
|
|
202
|
+
type: PiEventType;
|
|
203
|
+
turnId: string;
|
|
204
|
+
data: Record<string, unknown>;
|
|
205
|
+
timestamp: string;
|
|
206
|
+
}
|
|
207
|
+
type PiEventHandler = (event: PiEvent) => void;
|
|
208
|
+
type PiSessionDiagnosticLevel = "debug" | "info" | "warn" | "error";
|
|
209
|
+
interface PiSessionDiagnostic {
|
|
210
|
+
level: PiSessionDiagnosticLevel;
|
|
211
|
+
code: string;
|
|
212
|
+
message: string;
|
|
213
|
+
timestamp: string;
|
|
214
|
+
turnId?: string;
|
|
215
|
+
details?: Record<string, unknown>;
|
|
216
|
+
}
|
|
217
|
+
type PiSessionDiagnosticHandler = (diagnostic: PiSessionDiagnostic) => void;
|
|
218
|
+
interface PiCustomToolExecutionContext {
|
|
219
|
+
/** Pi's identity for this exact invocation; stable across the paused call. */
|
|
220
|
+
toolCallId: string;
|
|
221
|
+
/** Aborted when the active turn is stopped or torn down. */
|
|
222
|
+
signal: AbortSignal;
|
|
223
|
+
/** Pause model-execution budgets while this custom tool awaits durable operator input. */
|
|
224
|
+
suspendPromptGuards?: () => () => void;
|
|
225
|
+
}
|
|
226
|
+
interface PiCustomTool {
|
|
227
|
+
name: string;
|
|
228
|
+
description: string;
|
|
229
|
+
parameters: Record<string, unknown>;
|
|
230
|
+
executionMode?: "sequential" | "parallel";
|
|
231
|
+
execute(args: Record<string, unknown>, context?: PiCustomToolExecutionContext): Promise<unknown>;
|
|
232
|
+
}
|
|
233
|
+
interface PiUsageData {
|
|
234
|
+
input: number;
|
|
235
|
+
output: number;
|
|
236
|
+
/** Provider-reported reasoning/thinking tokens. This is a subset of output tokens. */
|
|
237
|
+
reasoning?: number;
|
|
238
|
+
cacheRead: number;
|
|
239
|
+
cacheWrite: number;
|
|
240
|
+
totalTokens: number;
|
|
241
|
+
cost: {
|
|
242
|
+
input: number;
|
|
243
|
+
output: number;
|
|
244
|
+
cacheRead: number;
|
|
245
|
+
cacheWrite: number;
|
|
246
|
+
total: number;
|
|
247
|
+
};
|
|
248
|
+
cacheHitRate: number;
|
|
249
|
+
}
|
|
250
|
+
interface PiRunDetails {
|
|
251
|
+
loadedAgentsFiles: Array<{
|
|
252
|
+
path: string;
|
|
253
|
+
sizeBytes: number;
|
|
254
|
+
}>;
|
|
255
|
+
loadedSkills: Array<{
|
|
256
|
+
name: string;
|
|
257
|
+
path: string;
|
|
258
|
+
}>;
|
|
259
|
+
availableToolNames: string[];
|
|
260
|
+
}
|
|
261
|
+
type ProcessCustomTool = PiCustomTool;
|
|
262
|
+
interface PiCustomMessageInput {
|
|
263
|
+
content: string;
|
|
264
|
+
details: unknown;
|
|
265
|
+
display?: boolean;
|
|
266
|
+
}
|
|
267
|
+
type PiTerminalAcknowledgementState = "open" | "outcome_accepted" | "acknowledgement_succeeded" | "acknowledgement_failed_ignored";
|
|
268
|
+
interface PiTerminalAcknowledgementControl {
|
|
269
|
+
readonly timeoutMs: number;
|
|
270
|
+
state(): PiTerminalAcknowledgementState;
|
|
271
|
+
isOperatorAbortRequested(): boolean;
|
|
272
|
+
markSucceeded(): void;
|
|
273
|
+
markFailed(reason: string): void;
|
|
274
|
+
}
|
|
275
|
+
interface PiPromptOptions {
|
|
276
|
+
tools?: readonly PiCustomTool[];
|
|
277
|
+
activeTools?: readonly string[];
|
|
278
|
+
/** @internal Runtime-only hook used by the worker Pi adapter before a tool executes. */
|
|
279
|
+
shouldBlockToolCall?: (toolName: string) => string | null;
|
|
280
|
+
/** @internal Guard suspension used by durable interactive tools. */
|
|
281
|
+
suspendPromptGuards?: () => () => void;
|
|
282
|
+
/** @internal Runtime-only terminal outcome acknowledgement state. */
|
|
283
|
+
terminalAcknowledgement?: PiTerminalAcknowledgementControl;
|
|
284
|
+
}
|
|
285
|
+
interface PiTreeHandle {
|
|
286
|
+
readonly sessionId: string;
|
|
287
|
+
readonly treeFile: string;
|
|
288
|
+
readonly isResumed: boolean;
|
|
289
|
+
getRunDetails(): PiRunDetails;
|
|
290
|
+
getLeafId(): string | null;
|
|
291
|
+
getEntry(id: string): PiTreeEntry | undefined;
|
|
292
|
+
getBranch(fromId?: string): PiTreeEntry[];
|
|
293
|
+
getChildren(parentId: string): PiTreeEntry[];
|
|
294
|
+
getTree(): PiTreeNode[];
|
|
295
|
+
branch(entryId: string): void | Promise<void>;
|
|
296
|
+
branchFromRoot(): void | Promise<void>;
|
|
297
|
+
resetLeaf(): void | Promise<void>;
|
|
298
|
+
/**
|
|
299
|
+
* Compact the current Pi context. `details` is persisted with the resulting
|
|
300
|
+
* compaction entry, but deliberately remains outside model context.
|
|
301
|
+
*/
|
|
302
|
+
compact?(customInstructions?: string, details?: unknown): Promise<unknown>;
|
|
303
|
+
prompt(text: string, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;
|
|
304
|
+
promptLiteral(text: string, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;
|
|
305
|
+
promptCustom(input: PiCustomMessageInput, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;
|
|
306
|
+
continueTurn(options?: PiPromptOptions): Promise<PiTurnExecutionResult>;
|
|
307
|
+
appendCustomMessage?(input: PiCustomMessageInput): Promise<string>;
|
|
308
|
+
steer(text: string): Promise<void>;
|
|
309
|
+
abortTurn(): Promise<void>;
|
|
310
|
+
subscribe(handler: PiEventHandler): () => void;
|
|
311
|
+
subscribeDiagnostics?(handler: PiSessionDiagnosticHandler): () => void;
|
|
312
|
+
close(): Promise<void>;
|
|
313
|
+
}
|
|
314
|
+
declare const TURN_CONTEXT_MODES: readonly ["full", "compacted", "fresh", "fresh_seeded"];
|
|
315
|
+
type TurnContextMode = (typeof TURN_CONTEXT_MODES)[number];
|
|
316
|
+
declare const TURN_COMPLETION_MODES: readonly ["turn_end"];
|
|
317
|
+
type TurnCompletionMode = (typeof TURN_COMPLETION_MODES)[number];
|
|
318
|
+
type TurnBranchType = ProcessTurnRecordPathType;
|
|
319
|
+
type TurnSemanticEntryRefKey = ProcessSemanticEntryRefKey;
|
|
320
|
+
interface TurnResultMarkdownNoneBehavior {
|
|
321
|
+
mode: "none";
|
|
322
|
+
}
|
|
323
|
+
interface TurnResultMarkdownAssistantOutputBehavior {
|
|
324
|
+
mode: "assistant_output";
|
|
325
|
+
required?: boolean;
|
|
326
|
+
}
|
|
327
|
+
interface TurnResultMarkdownToolCallBehavior {
|
|
328
|
+
mode: "tool_call";
|
|
329
|
+
toolName: string;
|
|
330
|
+
source?: "arguments" | "result";
|
|
331
|
+
path: string;
|
|
332
|
+
required?: boolean;
|
|
333
|
+
}
|
|
334
|
+
interface TurnResultMarkdownOutcomeToolArgumentBehavior {
|
|
335
|
+
mode: "outcome_tool_argument";
|
|
336
|
+
parameterName: string;
|
|
337
|
+
required?: boolean;
|
|
338
|
+
}
|
|
339
|
+
type TurnResultMarkdownBehavior = TurnResultMarkdownNoneBehavior | TurnResultMarkdownAssistantOutputBehavior | TurnResultMarkdownToolCallBehavior | TurnResultMarkdownOutcomeToolArgumentBehavior;
|
|
340
|
+
type TurnAcceptanceState = TurnAcceptanceState$1;
|
|
341
|
+
interface ProcessActionSchedulingFixedTurnPreview {
|
|
342
|
+
kind: "fixed_turn";
|
|
343
|
+
turnId: TurnId | null;
|
|
344
|
+
}
|
|
345
|
+
interface ProcessActionSchedulingTriggerPreview {
|
|
346
|
+
kind: "trigger";
|
|
347
|
+
trigger: string;
|
|
348
|
+
}
|
|
349
|
+
interface ProcessActionSchedulingTerminalPreview {
|
|
350
|
+
kind: "terminal";
|
|
351
|
+
lifecycleStatus: ProcessTurnTerminalLifecycleStatus;
|
|
352
|
+
}
|
|
353
|
+
type ProcessActionSchedulingPreview = ProcessActionSchedulingFixedTurnPreview | ProcessActionSchedulingTriggerPreview | ProcessActionSchedulingTerminalPreview;
|
|
354
|
+
type ProcessActionPreviewDefinition = ProcessActionSchedulingPreview;
|
|
355
|
+
interface ProcessActionSchedulingDefinition {
|
|
356
|
+
preview: ProcessActionSchedulingPreview;
|
|
357
|
+
}
|
|
358
|
+
interface HumanTurnActionView {
|
|
359
|
+
actionId: string;
|
|
360
|
+
acceptanceState: TurnAcceptanceState;
|
|
361
|
+
label?: string;
|
|
362
|
+
description?: string;
|
|
363
|
+
preview?: ProcessActionPreviewDefinition;
|
|
364
|
+
scheduling?: ProcessActionSchedulingDefinition;
|
|
365
|
+
}
|
|
366
|
+
interface HumanTurnNotesField {
|
|
367
|
+
id: string;
|
|
368
|
+
label: string;
|
|
369
|
+
description?: string;
|
|
370
|
+
placeholder?: string;
|
|
371
|
+
required?: boolean;
|
|
372
|
+
}
|
|
373
|
+
interface HumanTurnExternalTrigger {
|
|
374
|
+
id: string;
|
|
375
|
+
actionId: string;
|
|
376
|
+
label: string;
|
|
377
|
+
description: string;
|
|
378
|
+
}
|
|
379
|
+
interface HumanTurnExternalActionView {
|
|
380
|
+
/** Process-local arming id exposed to providers and UI. */
|
|
381
|
+
id: string;
|
|
382
|
+
externalActionId: string;
|
|
383
|
+
sourceKind: string;
|
|
384
|
+
label: string | null;
|
|
385
|
+
description: string | null;
|
|
386
|
+
}
|
|
387
|
+
interface EventBus<TEventMap extends object = Record<string, unknown>> {
|
|
388
|
+
emit<K extends keyof TEventMap & string>(event: K, data: TEventMap[K]): void;
|
|
389
|
+
on<K extends keyof TEventMap & string>(event: K, handler: (data: TEventMap[K]) => void | Promise<void>): void;
|
|
390
|
+
off<K extends keyof TEventMap & string>(event: K, handler: (data: TEventMap[K]) => void | Promise<void>): void;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
type ProcessEventName = keyof ServerExtensionEventMap & string;
|
|
394
|
+
type ProcessEmittedEvent = {
|
|
395
|
+
type: ProcessEventName;
|
|
396
|
+
data: unknown;
|
|
397
|
+
};
|
|
398
|
+
type ProcessQueuedInput = {
|
|
399
|
+
source: InputSource;
|
|
400
|
+
kind: InputKind;
|
|
401
|
+
bodyMarkdown: string;
|
|
402
|
+
target?: ProcessInputTarget;
|
|
403
|
+
};
|
|
404
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
405
|
+
type StaticRouteTarget = {
|
|
406
|
+
to?: TurnId;
|
|
407
|
+
complete?: boolean;
|
|
408
|
+
lifecycleStatus?: ProcessTurnTerminalLifecycleStatus;
|
|
409
|
+
};
|
|
410
|
+
interface ProcessRuntimeTurnContext<TParams = unknown, TState = unknown> extends WorkerProcessContext<TParams, TState> {
|
|
411
|
+
}
|
|
412
|
+
interface ProcessServerRuntimeContext<TParams = unknown, TState = unknown> {
|
|
413
|
+
readonly process: ServerProcessContext<TParams, TState>["process"];
|
|
414
|
+
readonly projects: ServerProcessContext<TParams, TState>["projects"];
|
|
415
|
+
readonly params: TParams;
|
|
416
|
+
readonly state: TState;
|
|
417
|
+
readSemanticTurnResultMarkdown(ref: ProcessSemanticEntryRefKey): string | null;
|
|
418
|
+
readProductTurnResultMarkdown(productName: string): string | null;
|
|
419
|
+
}
|
|
420
|
+
interface ProcessBroadcastEffect {
|
|
421
|
+
type: string;
|
|
422
|
+
payload: Record<string, unknown>;
|
|
423
|
+
}
|
|
424
|
+
type ProcessPatchEffect = Partial<Pick<ProcessInstance, "planRevision" | "title" | "externalId" | "externalUrl" | "metadata" | "defaultModelProfileId" | "turnConfigsJson">>;
|
|
425
|
+
interface ProcessLifecycleEffects {
|
|
426
|
+
processPatch?: ProcessPatchEffect;
|
|
427
|
+
broadcasts?: readonly ProcessBroadcastEffect[];
|
|
428
|
+
}
|
|
429
|
+
interface ProcessEffectPlan<TState = unknown> extends ProcessLifecycleEffects {
|
|
430
|
+
state?: TState;
|
|
431
|
+
emit?: readonly ProcessEmittedEvent[];
|
|
432
|
+
queueInput?: readonly ProcessQueuedInput[];
|
|
433
|
+
}
|
|
434
|
+
interface SavePlanResultLifecycleIntent<TParams = unknown, TState = unknown> {
|
|
435
|
+
kind: "save_plan_result";
|
|
436
|
+
summaryParam: string;
|
|
437
|
+
acceptanceCriteriaParam: string;
|
|
438
|
+
planMarkdownParam: string;
|
|
439
|
+
emitEventType: ProcessEventName;
|
|
440
|
+
broadcastType: string;
|
|
441
|
+
state?: ProcessOutcomeEffect<TParams, TState>;
|
|
442
|
+
}
|
|
443
|
+
type ProcessOutcomeLifecycleIntent<TParams = unknown, TState = unknown> = SavePlanResultLifecycleIntent<TParams, TState>;
|
|
444
|
+
interface ProcessActionExecution<TParams = unknown, TState = unknown> {
|
|
445
|
+
readonly ctx: ProcessServerRuntimeContext<TParams, TState>;
|
|
446
|
+
readonly input: Record<string, unknown>;
|
|
447
|
+
readonly turnId: TurnId;
|
|
448
|
+
readonly actionId: string;
|
|
449
|
+
readonly selectedBranchId?: string;
|
|
450
|
+
}
|
|
451
|
+
interface ProcessOutcomeExecution<TParams = unknown, TState = unknown> {
|
|
452
|
+
readonly ctx: ProcessServerRuntimeContext<TParams, TState>;
|
|
453
|
+
readonly event: ProcessTurnOutcomeEvent;
|
|
454
|
+
readonly turnId: TurnId;
|
|
455
|
+
readonly outcome: string;
|
|
456
|
+
}
|
|
457
|
+
type ProcessActionEffect<TParams = unknown, TState = unknown> = (input: ProcessActionExecution<TParams, TState>) => MaybePromise<ProcessEffectPlan<TState> | undefined>;
|
|
458
|
+
type ProcessActionBranchSelector<TParams = unknown, TState = unknown> = (input: Omit<ProcessActionExecution<TParams, TState>, "selectedBranchId">) => MaybePromise<string>;
|
|
459
|
+
type ProcessOutcomeEffect<TParams = unknown, TState = unknown> = (input: ProcessOutcomeExecution<TParams, TState>) => MaybePromise<ProcessEffectPlan<TState> | undefined>;
|
|
460
|
+
interface ProcessActionExternalTrigger {
|
|
461
|
+
id: string;
|
|
462
|
+
label: string;
|
|
463
|
+
description: string;
|
|
464
|
+
}
|
|
465
|
+
interface ExternalActionInputPublication {
|
|
466
|
+
productName: string;
|
|
467
|
+
inputField: string;
|
|
468
|
+
}
|
|
469
|
+
interface ProcessHumanTurnExternalActionSpec<TParams = unknown, TState = unknown, TEvent = unknown, TInput extends Record<string, unknown> = Record<string, unknown>> extends StaticRouteTarget {
|
|
470
|
+
id: string;
|
|
471
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
472
|
+
label?: string;
|
|
473
|
+
description?: string;
|
|
474
|
+
publishInput?: ExternalActionInputPublication;
|
|
475
|
+
}
|
|
476
|
+
interface ProcessActionBranchSpec extends StaticRouteTarget {
|
|
477
|
+
trigger?: string;
|
|
478
|
+
}
|
|
479
|
+
type StaticActionRouting = StaticRouteTarget & {
|
|
480
|
+
trigger?: string;
|
|
481
|
+
};
|
|
482
|
+
type BranchingActionRouting<TParams, TState> = {
|
|
483
|
+
branches: Record<string, ProcessActionBranchSpec>;
|
|
484
|
+
choose: ProcessActionBranchSelector<TParams, TState>;
|
|
485
|
+
};
|
|
486
|
+
interface BaseActionSpec<TParams, TState> {
|
|
487
|
+
label: string;
|
|
488
|
+
description?: string;
|
|
489
|
+
form?: ActionFormDefinition;
|
|
490
|
+
preview?: ProcessActionPreviewDefinition;
|
|
491
|
+
schedulable?: boolean;
|
|
492
|
+
effect?: ProcessActionEffect<TParams, TState>;
|
|
493
|
+
}
|
|
494
|
+
type ProcessHumanTurnActionSpec<TParams = unknown, TState = unknown> = BaseActionSpec<TParams, TState> & {
|
|
495
|
+
acceptanceState: TurnAcceptanceState;
|
|
496
|
+
externalTriggers?: readonly ProcessActionExternalTrigger[];
|
|
497
|
+
} & (StaticActionRouting | BranchingActionRouting<TParams, TState>);
|
|
498
|
+
interface ProcessToolOutcomeSpec<TParams = unknown, TState = unknown> extends StaticRouteTarget {
|
|
499
|
+
description: string;
|
|
500
|
+
parameters: Record<string, OutcomeToolParameterSpec>;
|
|
501
|
+
/** Product published from this outcome's turn-result markdown, when this outcome is selected. */
|
|
502
|
+
publishedProduct?: string;
|
|
503
|
+
/** Outcome parameter whose markdown value is captured as the turn result. */
|
|
504
|
+
turnResultMarkdownParameter?: string;
|
|
505
|
+
effect?: ProcessOutcomeEffect<TParams, TState>;
|
|
506
|
+
lifecycleIntent?: ProcessOutcomeLifecycleIntent<TParams, TState>;
|
|
507
|
+
}
|
|
508
|
+
type HumanTurnOperatorAttention = "required" | "passive";
|
|
509
|
+
interface HumanTurnDefinition<TParams = unknown, TState = unknown> {
|
|
510
|
+
kind: "human";
|
|
511
|
+
description: string;
|
|
512
|
+
/** Optional for generic operator-waiting turns; review turns should set it. */
|
|
513
|
+
reviewSubject?: ReviewSubject;
|
|
514
|
+
reviewProduct?: string;
|
|
515
|
+
reviewSemanticRef?: ProcessSemanticEntryRefKey;
|
|
516
|
+
/** Controls whether entering this turn should raise an action-required toast. */
|
|
517
|
+
operatorAttention?: HumanTurnOperatorAttention;
|
|
518
|
+
notesFields?: readonly HumanTurnNotesField[];
|
|
519
|
+
commentary?: string;
|
|
520
|
+
actions: Record<string, ProcessHumanTurnActionSpec<TParams, TState>>;
|
|
521
|
+
externalActions?: Record<string, ProcessHumanTurnExternalActionSpec<TParams, TState>>;
|
|
522
|
+
}
|
|
523
|
+
interface ProcessTurnEndSpec<TParams = unknown, TState = unknown, TOutcome extends string = string> extends StaticRouteTarget {
|
|
524
|
+
outcome: TOutcome;
|
|
525
|
+
params?: Record<string, unknown>;
|
|
526
|
+
effect?: ProcessOutcomeEffect<TParams, TState>;
|
|
527
|
+
}
|
|
528
|
+
type OutcomeRouteSpec<TParams = unknown, TState = unknown> = StaticRouteTarget & Partial<Pick<ProcessToolOutcomeSpec<TParams, TState>, "description" | "parameters" | "effect">>;
|
|
529
|
+
interface OutcomeRouteOptions {
|
|
530
|
+
strict?: boolean;
|
|
531
|
+
}
|
|
532
|
+
type LlmModelPurpose = "process_title_generation";
|
|
533
|
+
interface LlmTurnDefinition<TOutcome extends string = string, TParams = unknown, TState = unknown> {
|
|
534
|
+
kind: "llm";
|
|
535
|
+
description: string;
|
|
536
|
+
/** Code-defined model policy purpose. Purpose selections cannot be overridden per launch/action. */
|
|
537
|
+
modelPurpose?: LlmModelPurpose;
|
|
538
|
+
/** Built-in Pi tools active while this turn runs. */
|
|
539
|
+
availableTools: readonly PiBuiltInToolName[];
|
|
540
|
+
/** Opt in to the durable, operator-facing ask_questions custom tool. */
|
|
541
|
+
askQuestions?: boolean;
|
|
542
|
+
completionMode?: TurnCompletionMode;
|
|
543
|
+
branchType: TurnBranchType;
|
|
544
|
+
context: TurnContextMode;
|
|
545
|
+
startFrom?: ProcessTurnStartSelection;
|
|
546
|
+
restorePrimaryLeafAfterTurn?: boolean;
|
|
547
|
+
prompt(ctx: ProcessRuntimeTurnContext<TParams, TState>): string | Promise<string>;
|
|
548
|
+
outcomes?: Partial<Record<TOutcome, ProcessToolOutcomeSpec<TParams, TState>>>;
|
|
549
|
+
turnEnd?: ProcessTurnEndSpec<TParams, TState, TOutcome>;
|
|
550
|
+
turnResultMarkdown?: TurnResultMarkdownBehavior;
|
|
551
|
+
reviewSubject?: ReviewSubject;
|
|
552
|
+
reviewSemanticRef?: ProcessSemanticEntryRefKey;
|
|
553
|
+
resultSemanticRef?: ProcessSemanticEntryRefKey;
|
|
554
|
+
publishedProduct?: string;
|
|
555
|
+
consumedProducts?: readonly string[];
|
|
556
|
+
optionalConsumedProducts?: readonly string[];
|
|
557
|
+
requiredSemanticMarkdownRefs?: readonly ProcessSemanticEntryRefKey[];
|
|
558
|
+
optionalSemanticMarkdownRefs?: readonly ProcessSemanticEntryRefKey[];
|
|
559
|
+
}
|
|
560
|
+
interface AutomaticTurnDefinition<TOutcome extends string = string, TParams = unknown, TState = unknown> {
|
|
561
|
+
kind: "automatic";
|
|
562
|
+
description: string;
|
|
563
|
+
outcomes?: Partial<Record<TOutcome, ProcessToolOutcomeSpec<TParams, TState>>>;
|
|
564
|
+
turnEnd?: ProcessTurnEndSpec<TParams, TState, TOutcome>;
|
|
565
|
+
reviewSubject?: ReviewSubject;
|
|
566
|
+
reviewSemanticRef?: ProcessSemanticEntryRefKey;
|
|
567
|
+
run(ctx: ProcessRuntimeTurnContext<TParams, TState>): Promise<WorkerCompleteInput<TOutcome>> | WorkerCompleteInput<TOutcome>;
|
|
568
|
+
}
|
|
569
|
+
interface ServerAutomaticTurnRunResult<TOutcome extends string = string, TState = unknown> extends WorkerCompleteInput<TOutcome> {
|
|
570
|
+
state?: TState;
|
|
571
|
+
}
|
|
572
|
+
type ServerAutomaticTurnRestartBehavior = "rerun" | "fail_running";
|
|
573
|
+
interface ServerAutomaticTurnDefinition<TOutcome extends string = string, TParams = unknown, TState = unknown> {
|
|
574
|
+
kind: "server_automatic";
|
|
575
|
+
description: string;
|
|
576
|
+
outcomes?: Partial<Record<TOutcome, ProcessToolOutcomeSpec<TParams, TState>>>;
|
|
577
|
+
turnEnd?: ProcessTurnEndSpec<TParams, TState, TOutcome>;
|
|
578
|
+
reviewSubject?: ReviewSubject;
|
|
579
|
+
reviewSemanticRef?: ProcessSemanticEntryRefKey;
|
|
580
|
+
/**
|
|
581
|
+
* Controls startup/drainer behavior when a durable running turn record already exists.
|
|
582
|
+
* The default reruns the deterministic handler. Use fail_running for non-idempotent
|
|
583
|
+
* host side effects that must not be replayed after a server crash/restart.
|
|
584
|
+
*/
|
|
585
|
+
restartBehavior?: ServerAutomaticTurnRestartBehavior;
|
|
586
|
+
run(ctx: ProcessServerRuntimeContext<TParams, TState>): Promise<ServerAutomaticTurnRunResult<TOutcome, TState>> | ServerAutomaticTurnRunResult<TOutcome, TState>;
|
|
587
|
+
}
|
|
588
|
+
interface ExternalSourceTransition<TParams = unknown, TState = unknown, TEvent = unknown, TInput extends Record<string, unknown> = Record<string, unknown>> extends StaticRouteTarget {
|
|
589
|
+
source: ExternalActionSource<TParams, TState, TEvent, TInput>;
|
|
590
|
+
effect?: ExternalSourceEffect<TParams, TState, TEvent, TInput>;
|
|
591
|
+
}
|
|
592
|
+
interface ExternalTurnDefinition<TParams = unknown, TState = unknown> {
|
|
593
|
+
kind: "external";
|
|
594
|
+
description: string;
|
|
595
|
+
transitions: readonly ExternalSourceTransition<TParams, TState>[];
|
|
596
|
+
reviewSubject?: ReviewSubject;
|
|
597
|
+
reviewSemanticRef?: ProcessSemanticEntryRefKey;
|
|
598
|
+
}
|
|
599
|
+
type TurnDefinition<TParams = unknown, TState = unknown> = LlmTurnDefinition<string, TParams, TState> | AutomaticTurnDefinition<string, TParams, TState> | ServerAutomaticTurnDefinition<string, TParams, TState> | HumanTurnDefinition<TParams, TState> | ExternalTurnDefinition<TParams, TState>;
|
|
600
|
+
type TurnDefinitionRecord<TParams = unknown, TState = unknown> = Record<TurnId, TurnDefinition<TParams, TState>>;
|
|
601
|
+
type ProcessDefinition<TParams = unknown, TState = unknown> = ExtensionProcessDefinition<TParams, TState>;
|
|
602
|
+
interface DefinedProcessInput<TParams = unknown, TState = unknown> {
|
|
603
|
+
id: string;
|
|
604
|
+
displayName: string;
|
|
605
|
+
/** Primary entry used when a launch does not select a start turn explicitly. */
|
|
606
|
+
entry: TurnId;
|
|
607
|
+
/** Additional entry turns that launchers may select explicitly. */
|
|
608
|
+
alternateEntries?: readonly TurnId[];
|
|
609
|
+
happyPath?: readonly TurnId[];
|
|
610
|
+
paramsCodec: Codec<TParams>;
|
|
611
|
+
stateCodec: Codec<TState>;
|
|
612
|
+
initialState(params: TParams): TState;
|
|
613
|
+
repositoryCredentials?(input: {
|
|
614
|
+
params: TParams;
|
|
615
|
+
projects: readonly RepositoryCredentialProject[];
|
|
616
|
+
}): readonly RepositoryCredentialRequirement[];
|
|
617
|
+
piConfig?: ProcessPiConfig;
|
|
618
|
+
turns: TurnDefinitionRecord<TParams, TState>;
|
|
619
|
+
worker?: (api: WorkerProcessAPI<TParams, TState>) => void;
|
|
620
|
+
server?: (api: ServerProcessAPI<TParams, TState>) => void;
|
|
621
|
+
ui?: (api: UiProcessAPI<TParams, TState>) => void;
|
|
622
|
+
launchers?: (api: ProcessLauncherAPI<TParams>) => void;
|
|
623
|
+
watchers?: (api: ProcessWatcherAPI<TParams>) => void;
|
|
624
|
+
}
|
|
625
|
+
declare function getExternalSourceTransitionId(input: {
|
|
626
|
+
turnId: TurnId;
|
|
627
|
+
source: ExternalActionSource;
|
|
628
|
+
index: number;
|
|
629
|
+
}): string;
|
|
630
|
+
declare function getExternalActionArmingId(input: {
|
|
631
|
+
turnId: TurnId;
|
|
632
|
+
externalActionId: string;
|
|
633
|
+
}): string;
|
|
634
|
+
declare function getExternalActionTransitionTrigger(input: {
|
|
635
|
+
externalActionId: string;
|
|
636
|
+
}): string;
|
|
637
|
+
declare function resolveHumanTurnView<TParams, TState>(input: {
|
|
638
|
+
turnId: TurnId;
|
|
639
|
+
turn: HumanTurnDefinition<TParams, TState>;
|
|
640
|
+
}): {
|
|
641
|
+
actions: readonly HumanTurnActionView[];
|
|
642
|
+
externalTriggers: readonly HumanTurnExternalTrigger[];
|
|
643
|
+
externalActions: readonly HumanTurnExternalActionView[];
|
|
644
|
+
};
|
|
645
|
+
declare function defineProcess<TParams = unknown, TState = unknown>(input: DefinedProcessInput<TParams, TState>): ProcessDefinition<TParams, TState>;
|
|
646
|
+
type RoutableTurnDefinition<TOutcome extends string, TParams, TState> = LlmTurnDefinition<TOutcome, TParams, TState> | AutomaticTurnDefinition<TOutcome, TParams, TState> | ServerAutomaticTurnDefinition<TOutcome, TParams, TState>;
|
|
647
|
+
type RoutableOutcome<TTurn> = TTurn extends RoutableTurnDefinition<infer TOutcome, any, any> ? TOutcome : never;
|
|
648
|
+
type RoutableParams<TTurn> = TTurn extends RoutableTurnDefinition<any, infer TParams, any> ? TParams : never;
|
|
649
|
+
type RoutableState<TTurn> = TTurn extends RoutableTurnDefinition<any, any, infer TState> ? TState : never;
|
|
650
|
+
declare function routeTurnOutcomes<TTurn extends RoutableTurnDefinition<string, any, any>>(baseTurn: TTurn, routes: Partial<Record<RoutableOutcome<TTurn>, OutcomeRouteSpec<RoutableParams<TTurn>, RoutableState<TTurn>>>>, options?: OutcomeRouteOptions): TTurn;
|
|
651
|
+
declare function llmTurn<TParams = unknown, TState = unknown, TOutcome extends string = string>(input: Omit<LlmTurnDefinition<TOutcome, TParams, TState>, "kind">): LlmTurnDefinition<TOutcome, TParams, TState>;
|
|
652
|
+
declare function automaticTurn<TParams = unknown, TState = unknown, TOutcome extends string = string>(input: Omit<AutomaticTurnDefinition<TOutcome, TParams, TState>, "kind">): AutomaticTurnDefinition<TOutcome, TParams, TState>;
|
|
653
|
+
declare function serverAutomaticTurn<TParams = unknown, TState = unknown, TOutcome extends string = string>(input: Omit<ServerAutomaticTurnDefinition<TOutcome, TParams, TState>, "kind">): ServerAutomaticTurnDefinition<TOutcome, TParams, TState>;
|
|
654
|
+
declare function humanTurn<TParams = unknown, TState = unknown>(input: Omit<HumanTurnDefinition<TParams, TState>, "kind">): HumanTurnDefinition<TParams, TState>;
|
|
655
|
+
declare function externalTurn<TParams = unknown, TState = unknown>(input: Omit<ExternalTurnDefinition<TParams, TState>, "kind">): ExternalTurnDefinition<TParams, TState>;
|
|
656
|
+
|
|
657
|
+
/** JSON values that may cross the server/worker bootstrap boundary. */
|
|
658
|
+
type ProviderJsonPrimitive = string | number | boolean | null;
|
|
659
|
+
type ProviderJsonValue = ProviderJsonPrimitive | ProviderJsonValue[] | {
|
|
660
|
+
[key: string]: ProviderJsonValue;
|
|
661
|
+
};
|
|
662
|
+
type ProviderJsonObject = {
|
|
663
|
+
[key: string]: ProviderJsonValue;
|
|
664
|
+
};
|
|
665
|
+
interface ConfiguredProviderModel {
|
|
666
|
+
readonly profileId: string;
|
|
667
|
+
readonly modelId: string;
|
|
668
|
+
}
|
|
669
|
+
type ProviderAvailability = "available" | "unavailable" | "stale";
|
|
670
|
+
interface ProviderModelStatus {
|
|
671
|
+
readonly modelId: string;
|
|
672
|
+
readonly availability: ProviderAvailability;
|
|
673
|
+
/** Safe operator-facing reason. It must not contain credential material. */
|
|
674
|
+
readonly safeReason?: string;
|
|
675
|
+
}
|
|
676
|
+
interface ProviderCredentialStatus {
|
|
677
|
+
readonly available: boolean;
|
|
678
|
+
readonly revision: number | null;
|
|
679
|
+
}
|
|
680
|
+
interface ModelProviderModelsContext<TConfig = unknown> {
|
|
681
|
+
readonly config: TConfig;
|
|
682
|
+
readonly configuredModels: readonly ConfiguredProviderModel[];
|
|
683
|
+
readonly credentialStatus: ProviderCredentialStatus;
|
|
684
|
+
}
|
|
685
|
+
interface ProviderOptionChoice {
|
|
686
|
+
readonly value: string;
|
|
687
|
+
readonly label: string;
|
|
688
|
+
}
|
|
689
|
+
interface ProviderOptionChoicesContext<TConfig = unknown> {
|
|
690
|
+
readonly config: TConfig;
|
|
691
|
+
readonly credentialStatus: ProviderCredentialStatus;
|
|
692
|
+
}
|
|
693
|
+
interface ProviderOptionDefaultContext<TConfig = unknown> {
|
|
694
|
+
readonly config: TConfig;
|
|
695
|
+
}
|
|
696
|
+
interface ProviderOptionField<TConfig = unknown> {
|
|
697
|
+
readonly label: string;
|
|
698
|
+
readonly required?: boolean;
|
|
699
|
+
readonly minLength?: number;
|
|
700
|
+
readonly maxLength?: number;
|
|
701
|
+
/**
|
|
702
|
+
* Explicit provider default. Dynamic choices are advisory and are never used
|
|
703
|
+
* as an implicit default.
|
|
704
|
+
*/
|
|
705
|
+
readonly defaultValue?: string | null | ((ctx: ProviderOptionDefaultContext<TConfig>) => string | null | undefined);
|
|
706
|
+
}
|
|
707
|
+
interface ProviderOptionsDefinition<TConfig = unknown> {
|
|
708
|
+
readonly fields: Readonly<Record<string, ProviderOptionField<TConfig>>>;
|
|
709
|
+
choices?(ctx: ProviderOptionChoicesContext<TConfig>): Readonly<Record<string, readonly ProviderOptionChoice[]>> | Promise<Readonly<Record<string, readonly ProviderOptionChoice[]>>>;
|
|
710
|
+
}
|
|
711
|
+
declare function defineProviderOptions<TConfig = unknown>(definition: ProviderOptionsDefinition<TConfig>): ProviderOptionsDefinition<TConfig>;
|
|
712
|
+
interface ProviderOptionsResolutionInput<TConfig = unknown> {
|
|
713
|
+
readonly definition: ProviderOptionsDefinition<TConfig> | null | undefined;
|
|
714
|
+
readonly config: TConfig;
|
|
715
|
+
readonly explicit?: Readonly<Record<string, unknown>> | null;
|
|
716
|
+
readonly profileDefaults?: Readonly<Record<string, unknown>> | null;
|
|
717
|
+
}
|
|
718
|
+
interface ProviderOptionValidationIssue {
|
|
719
|
+
readonly fieldId: string;
|
|
720
|
+
readonly code: "unknown" | "not_string" | "too_short" | "too_long" | "required";
|
|
721
|
+
readonly message: string;
|
|
722
|
+
}
|
|
723
|
+
type ProviderOptionsResolution = {
|
|
724
|
+
readonly ok: true;
|
|
725
|
+
readonly value: Readonly<Record<string, string>>;
|
|
726
|
+
} | {
|
|
727
|
+
readonly ok: false;
|
|
728
|
+
readonly issues: readonly ProviderOptionValidationIssue[];
|
|
729
|
+
};
|
|
730
|
+
/**
|
|
731
|
+
* Resolve explicit values, profile defaults, then declared provider defaults.
|
|
732
|
+
* Dynamic choices deliberately do not participate in validation or fallback.
|
|
733
|
+
*/
|
|
734
|
+
declare function resolveProviderOptions<TConfig = unknown>(input: ProviderOptionsResolutionInput<TConfig>): ProviderOptionsResolution;
|
|
735
|
+
/** Keep only fields declared by a newly selected provider. */
|
|
736
|
+
declare function filterProviderOptionsForDefinition<TConfig = unknown>(definition: ProviderOptionsDefinition<TConfig> | null | undefined, values: Readonly<Record<string, string>>): Readonly<Record<string, string>>;
|
|
737
|
+
/**
|
|
738
|
+
* Runtime-independent schema boundary for non-secret provider worker config.
|
|
739
|
+
* Adapters may wrap Valibot, TypeBox, Zod, or another validator behind parse.
|
|
740
|
+
*/
|
|
741
|
+
interface ProviderWorkerConfigSchema<TValue extends ProviderJsonObject> {
|
|
742
|
+
parse(value: unknown): TValue;
|
|
743
|
+
}
|
|
744
|
+
interface ProviderWorkerConfigContext<TConfig = unknown> {
|
|
745
|
+
readonly config: TConfig;
|
|
746
|
+
readonly options: Readonly<Record<string, string>>;
|
|
747
|
+
}
|
|
748
|
+
interface ProviderWorkerConfigDefinition<TConfig = unknown, TValue extends ProviderJsonObject = ProviderJsonObject> {
|
|
749
|
+
readonly version: number;
|
|
750
|
+
readonly schema: ProviderWorkerConfigSchema<TValue>;
|
|
751
|
+
resolve(ctx: ProviderWorkerConfigContext<TConfig>): TValue;
|
|
752
|
+
}
|
|
753
|
+
declare function defineWorkerConfig<TConfig = unknown, TValue extends ProviderJsonObject = ProviderJsonObject>(definition: ProviderWorkerConfigDefinition<TConfig, TValue>): ProviderWorkerConfigDefinition<TConfig, TValue>;
|
|
754
|
+
interface PiWorkerReference<TConfig = unknown, TValue extends ProviderJsonObject = ProviderJsonObject> {
|
|
755
|
+
readonly kind: "extension_pi_worker";
|
|
756
|
+
readonly config?: ProviderWorkerConfigDefinition<TConfig, TValue>;
|
|
757
|
+
/** Mutable, flat JSON credential files required by this provider's Pi extension. */
|
|
758
|
+
readonly credentialFiles?: readonly string[];
|
|
759
|
+
}
|
|
760
|
+
interface PiServerReference {
|
|
761
|
+
readonly kind: "extension_pi_server";
|
|
762
|
+
}
|
|
763
|
+
interface PiServerGenerateTextInput<TConfig = unknown> {
|
|
764
|
+
readonly providerId: string;
|
|
765
|
+
readonly modelId: string;
|
|
766
|
+
readonly thinkingLevel: string;
|
|
767
|
+
readonly prompt: string;
|
|
768
|
+
readonly systemPrompt: string;
|
|
769
|
+
readonly maxTokens: number;
|
|
770
|
+
readonly config: TConfig;
|
|
771
|
+
readonly options: Readonly<Record<string, string>>;
|
|
772
|
+
readonly secrets: Readonly<Record<string, string>>;
|
|
773
|
+
readonly request: {
|
|
774
|
+
readonly timeoutMs?: number;
|
|
775
|
+
readonly maxRetries?: number;
|
|
776
|
+
readonly maxRetryDelayMs: number;
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
/** Server-only provider boundary for title generation and future cheap LLM consumers. */
|
|
780
|
+
interface PiServerAdapter<TConfig = unknown> {
|
|
781
|
+
generateText(input: PiServerGenerateTextInput<TConfig>): Promise<string>;
|
|
782
|
+
}
|
|
783
|
+
declare function definePiServerAdapter<TConfig = unknown>(adapter: PiServerAdapter<TConfig>): PiServerAdapter<TConfig>;
|
|
784
|
+
interface BuiltinPiProviderReference {
|
|
785
|
+
readonly kind: "builtin_pi_provider";
|
|
786
|
+
readonly providerId: string;
|
|
787
|
+
}
|
|
788
|
+
interface ConfiguredPiProviderReference<TConfig = unknown> {
|
|
789
|
+
readonly kind: "configured_pi_provider";
|
|
790
|
+
readonly providerId: string;
|
|
791
|
+
/** Resolve the credential-blind models.json document pinned into each worker snapshot. */
|
|
792
|
+
resolveModels(ctx: {
|
|
793
|
+
readonly config: TConfig;
|
|
794
|
+
}): ProviderJsonObject;
|
|
795
|
+
}
|
|
796
|
+
declare function piWorker<TConfig = unknown, TValue extends ProviderJsonObject = ProviderJsonObject>(input?: {
|
|
797
|
+
config?: ProviderWorkerConfigDefinition<TConfig, TValue>;
|
|
798
|
+
credentialFiles?: readonly string[];
|
|
799
|
+
}): PiWorkerReference<TConfig, TValue>;
|
|
800
|
+
declare function piServer(): PiServerReference;
|
|
801
|
+
declare function builtinPiProvider(providerId: string): BuiltinPiProviderReference;
|
|
802
|
+
declare function configuredPiProvider<TConfig>(providerId: string, resolveModels: ConfiguredPiProviderReference<TConfig>["resolveModels"]): ConfiguredPiProviderReference<TConfig>;
|
|
803
|
+
type ModelProviderWorker<TConfig = unknown, TValue extends ProviderJsonObject = ProviderJsonObject> = PiWorkerReference<TConfig, TValue> | BuiltinPiProviderReference | ConfiguredPiProviderReference<TConfig>;
|
|
804
|
+
type ModelProviderServer = PiServerReference | BuiltinPiProviderReference;
|
|
805
|
+
interface ModelProviderSecretsContext<TConfig = unknown, TCredential = unknown> {
|
|
806
|
+
readonly config: TConfig;
|
|
807
|
+
readonly credential: TCredential | null;
|
|
808
|
+
readonly options: Readonly<Record<string, string>>;
|
|
809
|
+
}
|
|
810
|
+
interface ParsedModelProviderConfig<TConfig = unknown, TCredential = unknown> {
|
|
811
|
+
/** Restart-scoped, non-secret provider configuration. */
|
|
812
|
+
readonly config: TConfig;
|
|
813
|
+
/** Optional credential used only to initialize an empty durable credential store. */
|
|
814
|
+
readonly credential?: TCredential;
|
|
815
|
+
}
|
|
816
|
+
interface ModelProviderCredentialDefinition<TCredential = unknown> {
|
|
817
|
+
/** Validates configured, durable, and worker-refreshed credential data. */
|
|
818
|
+
parse?(value: unknown): TCredential;
|
|
819
|
+
}
|
|
820
|
+
interface ModelProviderDefinition<TConfig = unknown, TCredential = unknown, TWorkerConfig extends ProviderJsonObject = ProviderJsonObject> {
|
|
821
|
+
readonly id: string;
|
|
822
|
+
parseConfig(raw: unknown): ParsedModelProviderConfig<TConfig, TCredential>;
|
|
823
|
+
readonly worker: ModelProviderWorker<TConfig, TWorkerConfig>;
|
|
824
|
+
readonly server?: ModelProviderServer;
|
|
825
|
+
models(ctx: ModelProviderModelsContext<TConfig>): readonly ProviderModelStatus[] | Promise<readonly ProviderModelStatus[]>;
|
|
826
|
+
readonly options?: ProviderOptionsDefinition<TConfig>;
|
|
827
|
+
secrets(ctx: ModelProviderSecretsContext<TConfig, TCredential>): Readonly<Record<string, string>>;
|
|
828
|
+
readonly credential?: ModelProviderCredentialDefinition<TCredential>;
|
|
829
|
+
}
|
|
830
|
+
declare function defineModelProvider<TConfig = unknown, TCredential = unknown, TWorkerConfig extends ProviderJsonObject = ProviderJsonObject>(definition: ModelProviderDefinition<TConfig, TCredential, TWorkerConfig>): ModelProviderDefinition<TConfig, TCredential, TWorkerConfig>;
|
|
831
|
+
/** Type-erased provider definition used after its typed boundary has been established. */
|
|
832
|
+
type ErasedModelProviderDefinition = ModelProviderDefinition<any, any, any>;
|
|
833
|
+
interface ModelProviderSetEntry {
|
|
834
|
+
readonly definition: ErasedModelProviderDefinition;
|
|
835
|
+
/** Owner-scoped fragment passed to this provider's parseConfig(). */
|
|
836
|
+
readonly rawConfig: unknown;
|
|
837
|
+
}
|
|
838
|
+
/** Resolves every provider owned by one extension from its owner-scoped configuration. */
|
|
839
|
+
type ModelProviderSet = (ownerConfig: unknown) => readonly ModelProviderSetEntry[];
|
|
840
|
+
declare function defineModelProviders(resolve: ModelProviderSet): ModelProviderSet;
|
|
841
|
+
interface PiWorkerSecretBag {
|
|
842
|
+
get(key: string): string | undefined;
|
|
843
|
+
require(key: string): string;
|
|
844
|
+
keys(): readonly string[];
|
|
845
|
+
}
|
|
846
|
+
interface PiWorkerContributionContext {
|
|
847
|
+
readonly model: {
|
|
848
|
+
readonly providerId: string;
|
|
849
|
+
readonly modelId: string;
|
|
850
|
+
};
|
|
851
|
+
readonly options: Readonly<Record<string, string>>;
|
|
852
|
+
readonly workerConfig: ProviderJsonObject | null;
|
|
853
|
+
readonly secrets: PiWorkerSecretBag;
|
|
854
|
+
report(event: Readonly<Record<string, ProviderJsonValue>>): void;
|
|
855
|
+
}
|
|
856
|
+
type PiWorkerContribution = (pi: {
|
|
857
|
+
registerProvider(name: string, config: object): void;
|
|
858
|
+
}, ctx: PiWorkerContributionContext) => void | Promise<void>;
|
|
859
|
+
declare function definePiWorker(contribution: PiWorkerContribution): PiWorkerContribution;
|
|
860
|
+
/**
|
|
861
|
+
* Report each distinct configured model as available or unavailable based solely
|
|
862
|
+
* on credential status. Providers that do not perform runtime model probing can
|
|
863
|
+
* delegate their `models()` callback to this helper.
|
|
864
|
+
*/
|
|
865
|
+
declare function credentialBasedModelStatuses(configuredModels: readonly ConfiguredProviderModel[], credentialStatus: ProviderCredentialStatus, unavailableReason: string): readonly ProviderModelStatus[];
|
|
866
|
+
|
|
867
|
+
interface Codec<T> {
|
|
868
|
+
parse(value: unknown): T;
|
|
869
|
+
serialize(value: T): unknown;
|
|
870
|
+
}
|
|
871
|
+
interface LauncherModelProfileSummary {
|
|
872
|
+
readonly id: string;
|
|
873
|
+
readonly provider: string;
|
|
874
|
+
readonly modelId: string;
|
|
875
|
+
readonly thinkingLevel: string;
|
|
876
|
+
}
|
|
877
|
+
interface LauncherContext {
|
|
878
|
+
readonly process?: ProcessInstance;
|
|
879
|
+
readonly projects?: readonly ProcessProject[];
|
|
880
|
+
/**
|
|
881
|
+
* Effective model profiles available to this launch path.
|
|
882
|
+
* The server may filter this list per process (for example via process allowlists)
|
|
883
|
+
* before invoking UI launcher or process watcher code.
|
|
884
|
+
*/
|
|
885
|
+
readonly modelProfiles?: readonly LauncherModelProfileSummary[];
|
|
886
|
+
}
|
|
887
|
+
type LauncherVisibility = "ui";
|
|
888
|
+
interface ProcessLaunchProjectConfig {
|
|
889
|
+
key: string;
|
|
890
|
+
repoLocator: string;
|
|
891
|
+
baseBranch: string;
|
|
892
|
+
workBranch?: string | null;
|
|
893
|
+
externalId?: string | null;
|
|
894
|
+
externalUrl?: string | null;
|
|
895
|
+
metadata?: Record<string, unknown> | null;
|
|
896
|
+
}
|
|
897
|
+
interface ProcessTitleSourceField {
|
|
898
|
+
/** Short label shown to the title-generation model, e.g. "Prompt" or "Summary". */
|
|
899
|
+
label: string;
|
|
900
|
+
/** Launcher-selected descriptive text to summarize into a short operator-facing title. */
|
|
901
|
+
value: string;
|
|
902
|
+
}
|
|
903
|
+
interface ProcessLaunchConfig<TParams = unknown> {
|
|
904
|
+
processId: string;
|
|
905
|
+
params: TParams;
|
|
906
|
+
startTurnId?: TurnId | null;
|
|
907
|
+
/** Explicit operator-facing title. UI launches may override this with the built-in title input before persistence. */
|
|
908
|
+
title?: string | null;
|
|
909
|
+
/** Explicit launcher-selected fields for optional server-side title generation when title is blank. */
|
|
910
|
+
titleSourceFields?: readonly ProcessTitleSourceField[];
|
|
911
|
+
externalId?: string | null;
|
|
912
|
+
externalUrl?: string | null;
|
|
913
|
+
metadata?: Record<string, unknown> | null;
|
|
914
|
+
defaultModelProfileId?: string | null;
|
|
915
|
+
turnConfigs?: Record<string, {
|
|
916
|
+
modelProfileId?: string | null;
|
|
917
|
+
}>;
|
|
918
|
+
projects?: readonly ProcessLaunchProjectConfig[];
|
|
919
|
+
}
|
|
920
|
+
type UiLauncherConfigResolution<TParams = unknown> = {
|
|
921
|
+
ok: true;
|
|
922
|
+
launchConfig: ProcessLaunchConfig<TParams>;
|
|
923
|
+
} | {
|
|
924
|
+
ok: false;
|
|
925
|
+
errors: readonly LauncherValidationError[];
|
|
926
|
+
};
|
|
927
|
+
interface UiLauncherDefinition<TParams = unknown> {
|
|
928
|
+
card: LauncherCardMetadata;
|
|
929
|
+
launchConfigSchema: LauncherSchemaDefinition;
|
|
930
|
+
resolveDefaults?(ctx: LauncherContext): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
931
|
+
resolveOptions?(input: Record<string, unknown>, ctx: LauncherContext): Record<string, readonly LauncherFieldOptionDefinition[]> | Promise<Record<string, readonly LauncherFieldOptionDefinition[]>>;
|
|
932
|
+
/**
|
|
933
|
+
* Convert persisted operator input into a new-launch draft. The default preserves
|
|
934
|
+
* the complete input. Launchers override this only for values that must be rebuilt.
|
|
935
|
+
*/
|
|
936
|
+
resolveRelaunchInput?(previousInput: Record<string, unknown>, ctx: LauncherContext): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
937
|
+
resolveLaunchConfig(input: Record<string, unknown>, ctx: LauncherContext): UiLauncherConfigResolution<TParams> | Promise<UiLauncherConfigResolution<TParams>>;
|
|
938
|
+
}
|
|
939
|
+
interface ProcessWatcherDefinition<TParams = unknown, TEvent = unknown, TType extends ProcessWatcherType = ProcessWatcherType> {
|
|
940
|
+
id: string;
|
|
941
|
+
label: string;
|
|
942
|
+
description: string;
|
|
943
|
+
type: TType;
|
|
944
|
+
matches?(event: TEvent, ctx: LauncherContext): boolean | Promise<boolean>;
|
|
945
|
+
resolveLaunchConfig(event: TEvent, ctx: LauncherContext): ProcessLaunchConfig<TParams> | Promise<ProcessLaunchConfig<TParams>>;
|
|
946
|
+
}
|
|
947
|
+
interface ProcessLauncherDefinition<TParams = unknown> {
|
|
948
|
+
id: string;
|
|
949
|
+
label: string;
|
|
950
|
+
description: string;
|
|
951
|
+
visibility: LauncherVisibility;
|
|
952
|
+
ui: UiLauncherDefinition<TParams>;
|
|
953
|
+
}
|
|
954
|
+
interface ProcessLaunchPlanProcessInput extends ProcessCustomizableFields {
|
|
955
|
+
processId: string;
|
|
956
|
+
selectedTurnId: string | null;
|
|
957
|
+
lifecycleStatus: ProcessLifecycleStatus;
|
|
958
|
+
paramsJson: string | null;
|
|
959
|
+
stateJson: string | null;
|
|
960
|
+
}
|
|
961
|
+
interface ProcessLaunchPlan {
|
|
962
|
+
launcherId: string;
|
|
963
|
+
processId: string;
|
|
964
|
+
processInput: ProcessLaunchPlanProcessInput;
|
|
965
|
+
/** Optional server-owned idempotency key for cross-process handoffs. */
|
|
966
|
+
handoffDedupKey?: string | null;
|
|
967
|
+
/** Carry-forward launcher-selected fields for optional server-side title generation. */
|
|
968
|
+
titleSourceFields?: readonly ProcessTitleSourceField[];
|
|
969
|
+
projectInputs: readonly ProcessLaunchProjectConfig[];
|
|
970
|
+
startTurnId: TurnId | null;
|
|
971
|
+
}
|
|
972
|
+
interface ResolvedProcessLauncher<TParams = unknown> {
|
|
973
|
+
launcherId: string;
|
|
974
|
+
processId: string;
|
|
975
|
+
displayName: string;
|
|
976
|
+
launchConfig: ProcessLaunchConfig<TParams>;
|
|
977
|
+
launchPlan: ProcessLaunchPlan;
|
|
978
|
+
}
|
|
979
|
+
type UiLauncherResolutionResult<TParams = unknown> = {
|
|
980
|
+
ok: true;
|
|
981
|
+
launcher: ResolvedProcessLauncher<TParams>;
|
|
982
|
+
} | {
|
|
983
|
+
ok: false;
|
|
984
|
+
errors: readonly LauncherValidationError[];
|
|
985
|
+
};
|
|
986
|
+
interface UiLauncherSummary extends UiLauncherSummaryBase {
|
|
987
|
+
}
|
|
988
|
+
interface ProcessLauncherService {
|
|
989
|
+
listUiLaunchers(): readonly UiLauncherSummary[];
|
|
990
|
+
resolveUiDefaults(launcherId: string, ctx?: LauncherContext): Promise<Record<string, unknown>>;
|
|
991
|
+
resolveUiOptions(launcherId: string, input: Record<string, unknown>, ctx?: LauncherContext): Promise<Record<string, readonly LauncherFieldOptionDefinition[]>>;
|
|
992
|
+
resolveUiRelaunchInput(launcherId: string, previousInput: Record<string, unknown>, ctx?: LauncherContext): Promise<Record<string, unknown>>;
|
|
993
|
+
resolveUiLauncher(launcherId: string, input: Record<string, unknown>, ctx?: LauncherContext): Promise<UiLauncherResolutionResult>;
|
|
994
|
+
}
|
|
995
|
+
/** Resolve a UI launcher summary by id, returning `null` when it is unknown. */
|
|
996
|
+
declare function findUiLauncherById(launcherService: Pick<ProcessLauncherService, "listUiLaunchers">, launcherId: string): UiLauncherSummary | null;
|
|
997
|
+
interface ProcessTurnOutcomeEvent {
|
|
998
|
+
turnRecordId: string;
|
|
999
|
+
turnId: string;
|
|
1000
|
+
outcome: string;
|
|
1001
|
+
params: Record<string, unknown>;
|
|
1002
|
+
turnResultMarkdown?: string | null;
|
|
1003
|
+
}
|
|
1004
|
+
type ProcessCleanupReason = "abort";
|
|
1005
|
+
interface ProcessCleanupResult<TState = unknown> extends ProcessLifecycleEffects {
|
|
1006
|
+
state?: TState;
|
|
1007
|
+
}
|
|
1008
|
+
interface ProcessCleanupContext<TParams = unknown, TState = unknown> extends ProcessSnapshotContext<TParams, TState> {
|
|
1009
|
+
readonly reason: ProcessCleanupReason;
|
|
1010
|
+
}
|
|
1011
|
+
type ProcessCleanupHandler<TParams = unknown, TState = unknown> = (ctx: ProcessCleanupContext<TParams, TState>) => undefined | ProcessCleanupResult<TState> | Promise<ProcessCleanupResult<TState> | undefined>;
|
|
1012
|
+
interface LeafOutcomeCaptureContext<TParams = unknown, TState = unknown> extends ProcessSnapshotContext<TParams, TState> {
|
|
1013
|
+
readonly leaf: {
|
|
1014
|
+
entryId: string;
|
|
1015
|
+
turnRecordId: string | null;
|
|
1016
|
+
};
|
|
1017
|
+
readonly turnRecord: ProcessTurnRecord | null;
|
|
1018
|
+
readTreeEntry(entryId: string): PiTreeEntry | null;
|
|
1019
|
+
readLeafEntry(): PiTreeEntry | null;
|
|
1020
|
+
readTurnRecord(turnRecordId: string): ProcessTurnRecord | null;
|
|
1021
|
+
}
|
|
1022
|
+
interface LeafOutcomeCaptureResult {
|
|
1023
|
+
rendererId: string;
|
|
1024
|
+
schemaVersion?: number;
|
|
1025
|
+
props: Record<string, unknown>;
|
|
1026
|
+
fallbackMarkdown?: string | null;
|
|
1027
|
+
}
|
|
1028
|
+
interface ProcessLeafOutcomeDefinition<TParams = unknown, TState = unknown> {
|
|
1029
|
+
rendererId: string;
|
|
1030
|
+
capture(ctx: LeafOutcomeCaptureContext<TParams, TState>): Promise<LeafOutcomeCaptureResult | null> | LeafOutcomeCaptureResult | null;
|
|
1031
|
+
}
|
|
1032
|
+
interface ProcessActionDefinition<TParams = unknown, TState = unknown> {
|
|
1033
|
+
id: string;
|
|
1034
|
+
label: string;
|
|
1035
|
+
form?: ActionFormDefinition;
|
|
1036
|
+
preview?: ProcessActionPreviewDefinition;
|
|
1037
|
+
scheduling?: ProcessActionSchedulingDefinition;
|
|
1038
|
+
/**
|
|
1039
|
+
* Explicitly marks an action as an immediate-only side-effect command. Such
|
|
1040
|
+
* actions must declare execute(...), cannot participate in pure preview or
|
|
1041
|
+
* scheduling flows, and are run only by immediate action execution.
|
|
1042
|
+
*/
|
|
1043
|
+
executionMode?: "side_effect";
|
|
1044
|
+
/**
|
|
1045
|
+
* Optional pure planner used for side-effect-free previews, scheduling validation,
|
|
1046
|
+
* and immediate execution. The shared server runtime collects the declared
|
|
1047
|
+
* transition/input/event plan from this hook without committing side effects
|
|
1048
|
+
* while the hook runs.
|
|
1049
|
+
*/
|
|
1050
|
+
plan?(input: Record<string, unknown>, ctx: ServerProcessContext<TParams, TState>): Promise<void>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Imperative hook for actions with executionMode: "side_effect". Use only for
|
|
1053
|
+
* immediate side effects that cannot be represented as a pure plan(...).
|
|
1054
|
+
*/
|
|
1055
|
+
execute?(input: Record<string, unknown>, ctx: ServerProcessContext<TParams, TState>): Promise<void>;
|
|
1056
|
+
}
|
|
1057
|
+
type ServerTransitionRuntime = "reconcile" | "restart_worker";
|
|
1058
|
+
interface ServerTransitionEffect {
|
|
1059
|
+
/**
|
|
1060
|
+
* Declares how the server runtime should handle the worker context after the
|
|
1061
|
+
* durable transition is committed.
|
|
1062
|
+
*/
|
|
1063
|
+
runtime?: ServerTransitionRuntime;
|
|
1064
|
+
}
|
|
1065
|
+
interface ServerTransitionRequest<TState = unknown> {
|
|
1066
|
+
lifecycleStatus?: ProcessLifecycleStatus;
|
|
1067
|
+
turnId?: TurnId | null;
|
|
1068
|
+
state?: TState;
|
|
1069
|
+
/** State machine trigger for the selected-turn graph. */
|
|
1070
|
+
trigger?: string;
|
|
1071
|
+
effect?: ServerTransitionEffect;
|
|
1072
|
+
}
|
|
1073
|
+
interface ProcessSnapshotContext<TParams = unknown, TState = unknown> {
|
|
1074
|
+
readonly process: ProcessInstance;
|
|
1075
|
+
readonly projects: readonly ProcessProject[];
|
|
1076
|
+
readonly params: TParams;
|
|
1077
|
+
readonly state: TState;
|
|
1078
|
+
}
|
|
1079
|
+
type ExternalSourceInputMode = "none" | "input" | "instruction";
|
|
1080
|
+
interface ExternalSourceResolveContext<TParams = unknown, TState = unknown> extends ProcessSnapshotContext<TParams, TState> {
|
|
1081
|
+
}
|
|
1082
|
+
interface ExternalSourceEffectContext<TParams = unknown, TState = unknown, TEvent = unknown, TInput extends Record<string, unknown> = Record<string, unknown>> extends ProcessSnapshotContext<TParams, TState> {
|
|
1083
|
+
readonly event: TEvent;
|
|
1084
|
+
readonly input: TInput;
|
|
1085
|
+
}
|
|
1086
|
+
type ExternalSourceEffect<TParams = unknown, TState = unknown, TEvent = unknown, TInput extends Record<string, unknown> = Record<string, unknown>> = (ctx: ExternalSourceEffectContext<TParams, TState, TEvent, TInput>) => ProcessEffectPlan<TState> | Promise<ProcessEffectPlan<TState> | undefined> | undefined;
|
|
1087
|
+
interface ExternalActionSource<TParams = unknown, TState = unknown, _TEvent = unknown, _TInput extends Record<string, unknown> = Record<string, unknown>> {
|
|
1088
|
+
kind: string;
|
|
1089
|
+
label?: string;
|
|
1090
|
+
description?: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* Extension-owned opaque config. Core may persist, hash, and display it, but must not
|
|
1093
|
+
* interpret provider-specific fields.
|
|
1094
|
+
*/
|
|
1095
|
+
config: unknown;
|
|
1096
|
+
/** Source-provided input behavior. Provider input is only published when the external action declares publishInput. */
|
|
1097
|
+
inputMode?: ExternalSourceInputMode;
|
|
1098
|
+
/** Optional extension-owned resolver for process-instance-specific matching. */
|
|
1099
|
+
resolve?(ctx: ExternalSourceResolveContext<TParams, TState>): unknown;
|
|
1100
|
+
}
|
|
1101
|
+
interface ServerProcessContext<TParams = unknown, TState = unknown> extends ProcessSnapshotContext<TParams, TState> {
|
|
1102
|
+
transition(next: ServerTransitionRequest<TState>): Promise<void>;
|
|
1103
|
+
emitEvent<K extends keyof ServerExtensionEventMap & string>(eventType: K, data: ServerExtensionEventPayloadInputMap[K]): void;
|
|
1104
|
+
/**
|
|
1105
|
+
* Resolves non-empty turn-result markdown for the current semantic ref.
|
|
1106
|
+
* Returns `null` when the ref is unset or the referenced turn result does not
|
|
1107
|
+
* carry operator-facing markdown. Throws when persisted semantic-ref state is
|
|
1108
|
+
* malformed.
|
|
1109
|
+
*/
|
|
1110
|
+
readSemanticTurnResultMarkdown(ref: ProcessSemanticEntryRefKey): string | null;
|
|
1111
|
+
/**
|
|
1112
|
+
* Resolves non-empty turn-result markdown for a process-defined published product.
|
|
1113
|
+
* Returns `null` when the product ref is unset or the referenced turn result does
|
|
1114
|
+
* not carry operator-facing markdown. Throws when persisted product-ref state is
|
|
1115
|
+
* malformed.
|
|
1116
|
+
*/
|
|
1117
|
+
readProductTurnResultMarkdown(productName: string): string | null;
|
|
1118
|
+
/**
|
|
1119
|
+
* Queue durable process input for worker delivery.
|
|
1120
|
+
* Use `source: "action_prompt"` for action-originated follow-up prompts.
|
|
1121
|
+
* When `target` is set, the worker appends the input on the referenced
|
|
1122
|
+
* semantic or product branch before the next selected LLM turn continues from
|
|
1123
|
+
* that same branch. For `action_prompt` targeted follow-up reruns, that queued
|
|
1124
|
+
* input is the only new instruction: the worker does not replay the original
|
|
1125
|
+
* kickoff prompt.
|
|
1126
|
+
*/
|
|
1127
|
+
queueInput(input: {
|
|
1128
|
+
source: InputSource;
|
|
1129
|
+
kind: InputKind;
|
|
1130
|
+
bodyMarkdown: string;
|
|
1131
|
+
target?: ProcessInputTarget;
|
|
1132
|
+
}): void;
|
|
1133
|
+
/**
|
|
1134
|
+
* Internal SDK lifecycle-effect collector used by high-level process authoring
|
|
1135
|
+
* helpers. Raw process definitions should prefer intent helpers instead of
|
|
1136
|
+
* constructing these effects directly.
|
|
1137
|
+
*/
|
|
1138
|
+
applyLifecycleEffects?(effects: ProcessLifecycleEffects): void;
|
|
1139
|
+
}
|
|
1140
|
+
interface WorkerProcessContext<TParams = unknown, TState = unknown> extends ProcessSnapshotContext<TParams, TState> {
|
|
1141
|
+
readonly turnResultMarkdownBySemanticRef?: Partial<Record<ProcessSemanticEntryRefKey, string>>;
|
|
1142
|
+
readonly turnResultMarkdownByProduct?: Readonly<Record<string, string>>;
|
|
1143
|
+
/** Absolute workspace root for the current process instance, when available. */
|
|
1144
|
+
readonly workspaceRoot?: string;
|
|
1145
|
+
}
|
|
1146
|
+
interface WorkerCompleteInput<TOutcome extends string = string> {
|
|
1147
|
+
outcome: TOutcome;
|
|
1148
|
+
params?: Record<string, unknown>;
|
|
1149
|
+
markdown?: string | null;
|
|
1150
|
+
}
|
|
1151
|
+
interface WorkerRunHandle<TParams = unknown, TState = unknown> {
|
|
1152
|
+
readonly ctx: WorkerProcessContext<TParams, TState>;
|
|
1153
|
+
turn<TOutcome extends string>(def: LlmTurnDefinition<TOutcome, TParams, TState>, options?: TurnOptions): Promise<{
|
|
1154
|
+
outcome: TOutcome;
|
|
1155
|
+
params: Record<string, unknown>;
|
|
1156
|
+
}>;
|
|
1157
|
+
complete<TOutcome extends string>(input: WorkerCompleteInput<TOutcome>): Promise<void>;
|
|
1158
|
+
park(reason?: string): void;
|
|
1159
|
+
}
|
|
1160
|
+
type WorkerTurnHandler<TParams = unknown, TState = unknown> = (run: WorkerRunHandle<TParams, TState>) => Promise<void>;
|
|
1161
|
+
interface ServerProcessAPI<TParams = unknown, TState = unknown> {
|
|
1162
|
+
action(def: ProcessActionDefinition<TParams, TState>): void;
|
|
1163
|
+
onTurnOutcome(turnId: string, handler: (event: ProcessTurnOutcomeEvent, ctx: ServerProcessContext<TParams, TState>) => void | Promise<void>): void;
|
|
1164
|
+
onCleanup(handler: ProcessCleanupHandler<TParams, TState>): void;
|
|
1165
|
+
}
|
|
1166
|
+
interface WorkerProcessAPI<TParams = unknown, TState = unknown> {
|
|
1167
|
+
start(turnId: TurnId): void;
|
|
1168
|
+
turn(turnId: TurnId, handler: WorkerTurnHandler<TParams, TState>): void;
|
|
1169
|
+
}
|
|
1170
|
+
interface UiProcessAPI<TParams = unknown, TState = unknown> {
|
|
1171
|
+
leafOutcome(def: ProcessLeafOutcomeDefinition<TParams, TState>): void;
|
|
1172
|
+
}
|
|
1173
|
+
interface ProcessLauncherAPI<TParams = unknown> {
|
|
1174
|
+
launcher(def: ProcessLauncherDefinition<TParams>): void;
|
|
1175
|
+
}
|
|
1176
|
+
interface ProcessWatcherAPI<TParams = unknown> {
|
|
1177
|
+
watcher<TEvent = unknown, TType extends ProcessWatcherType = ProcessWatcherType>(def: ProcessWatcherDefinition<TParams, TEvent, TType>): void;
|
|
1178
|
+
}
|
|
1179
|
+
interface ProcessTurnBinding<TTurn = TurnDefinition> {
|
|
1180
|
+
definition: TTurn;
|
|
1181
|
+
}
|
|
1182
|
+
type RepositoryCredentialKind = "git_ssh";
|
|
1183
|
+
/** Non-secret, code-defined repository authentication request. */
|
|
1184
|
+
interface RepositoryCredentialRequirement {
|
|
1185
|
+
readonly projectKey: string;
|
|
1186
|
+
readonly kind: RepositoryCredentialKind;
|
|
1187
|
+
readonly credentialRef: string;
|
|
1188
|
+
}
|
|
1189
|
+
/** Project fields available while deriving repository credential requirements. */
|
|
1190
|
+
interface RepositoryCredentialProject {
|
|
1191
|
+
readonly key: string;
|
|
1192
|
+
readonly repoLocator: string;
|
|
1193
|
+
readonly baseBranch: string;
|
|
1194
|
+
readonly workBranch: string | null;
|
|
1195
|
+
}
|
|
1196
|
+
/** Secret material is intentionally restricted to server registration and worker.start. */
|
|
1197
|
+
interface GitSshCredentialMaterial {
|
|
1198
|
+
readonly privateKey: string;
|
|
1199
|
+
readonly knownHosts: string;
|
|
1200
|
+
}
|
|
1201
|
+
interface RepositoryCredentialProvider {
|
|
1202
|
+
readonly kind: RepositoryCredentialKind;
|
|
1203
|
+
resolve(credentialRef: string): GitSshCredentialMaterial | null;
|
|
1204
|
+
}
|
|
1205
|
+
interface RepositoryCredentialRegistrar {
|
|
1206
|
+
register(provider: RepositoryCredentialProvider): void;
|
|
1207
|
+
}
|
|
1208
|
+
interface ExtensionProcessDefinition<TParams = unknown, TState = unknown> {
|
|
1209
|
+
id: string;
|
|
1210
|
+
displayName: string;
|
|
1211
|
+
/** Primary entry used when a launch does not select a start turn explicitly. */
|
|
1212
|
+
entryTurnId: TurnId;
|
|
1213
|
+
/** Additional entry turns that launchers may select explicitly. */
|
|
1214
|
+
alternateEntryTurnIds?: readonly TurnId[];
|
|
1215
|
+
/**
|
|
1216
|
+
* Optional author-declared happy path: the ordered spine of turns a successful
|
|
1217
|
+
* run walks through. Flow diagrams render this as the main line and hang every
|
|
1218
|
+
* other turn off it as a branch. When omitted, consumers fall back to a derived
|
|
1219
|
+
* best-effort spine.
|
|
1220
|
+
*/
|
|
1221
|
+
happyPath?: readonly TurnId[];
|
|
1222
|
+
turns: ReadonlyMap<TurnId, ProcessTurnBinding<TurnDefinition<TParams, TState>>>;
|
|
1223
|
+
paramsCodec: Codec<TParams>;
|
|
1224
|
+
stateCodec: Codec<TState>;
|
|
1225
|
+
initialState(params: TParams): TState;
|
|
1226
|
+
/** Runtime-only requirements; references are non-secret and remain in opaque params JSON. */
|
|
1227
|
+
repositoryCredentials?(input: {
|
|
1228
|
+
params: TParams;
|
|
1229
|
+
projects: readonly RepositoryCredentialProject[];
|
|
1230
|
+
}): readonly RepositoryCredentialRequirement[];
|
|
1231
|
+
piConfig?: ProcessPiConfig;
|
|
1232
|
+
server?: (api: ServerProcessAPI<TParams, TState>) => void;
|
|
1233
|
+
worker?: (api: WorkerProcessAPI<TParams, TState>) => void;
|
|
1234
|
+
ui?: (api: UiProcessAPI<TParams, TState>) => void;
|
|
1235
|
+
launchers?: (api: ProcessLauncherAPI<TParams>) => void;
|
|
1236
|
+
watchers?: (api: ProcessWatcherAPI<TParams>) => void;
|
|
1237
|
+
}
|
|
1238
|
+
interface CatalogExtensionAPI {
|
|
1239
|
+
readonly events: EventBus;
|
|
1240
|
+
registerProcess<TParams = unknown, TState = unknown>(def: ExtensionProcessDefinition<TParams, TState>): void;
|
|
1241
|
+
registerToolRenderer(def: ToolCallRendererDefinition): void;
|
|
1242
|
+
provide<T>(token: CapabilityToken<T>, value: T): void;
|
|
1243
|
+
get<T>(token: CapabilityToken<T>): T | T[] | undefined;
|
|
1244
|
+
require<T>(token: CapabilityToken<T>): T | T[];
|
|
1245
|
+
}
|
|
1246
|
+
type ExtensionLifecycleHook = () => void | Promise<void>;
|
|
1247
|
+
interface ServerExtensionLogger {
|
|
1248
|
+
info?(payload: Record<string, unknown>, message?: string): void;
|
|
1249
|
+
warn?(payload: Record<string, unknown>, message?: string): void;
|
|
1250
|
+
error?(payload: Record<string, unknown>, message?: string): void;
|
|
1251
|
+
}
|
|
1252
|
+
interface ServerExtensionAPI {
|
|
1253
|
+
readonly events: EventBus<ServerExtensionEventMap>;
|
|
1254
|
+
readonly logger?: ServerExtensionLogger;
|
|
1255
|
+
provide<T>(token: CapabilityToken<T>, value: T): void;
|
|
1256
|
+
get<T>(token: CapabilityToken<T>): T | T[] | undefined;
|
|
1257
|
+
require<T>(token: CapabilityToken<T>): T | T[];
|
|
1258
|
+
onStart(handler: ExtensionLifecycleHook): void;
|
|
1259
|
+
onStop(handler: ExtensionLifecycleHook): void;
|
|
1260
|
+
}
|
|
1261
|
+
interface WorkerExtensionAPI {
|
|
1262
|
+
readonly events: EventBus;
|
|
1263
|
+
get<T>(token: CapabilityToken<T>): T | T[] | undefined;
|
|
1264
|
+
require<T>(token: CapabilityToken<T>): T | T[];
|
|
1265
|
+
}
|
|
1266
|
+
interface LeitwerkExtensionManifest {
|
|
1267
|
+
id: string;
|
|
1268
|
+
version: string;
|
|
1269
|
+
requires?: readonly string[];
|
|
1270
|
+
optional?: readonly string[];
|
|
1271
|
+
}
|
|
1272
|
+
interface LeitwerkExtensionModule {
|
|
1273
|
+
manifest: LeitwerkExtensionManifest;
|
|
1274
|
+
/** Resolves every provider owned by this extension before setupServer. */
|
|
1275
|
+
modelProviders?: ModelProviderSet;
|
|
1276
|
+
setupCatalog?(api: CatalogExtensionAPI): void | Promise<void>;
|
|
1277
|
+
setupServer?(api: ServerExtensionAPI, config: unknown): void | Promise<void>;
|
|
1278
|
+
setupWorker?(api: WorkerExtensionAPI, config: unknown): void | Promise<void>;
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
export { type BuiltinPiProviderReference as $, type AutomaticTurnDefinition as A, type PiBuiltInToolName as B, type Codec as C, type ProcessTurnEndSpec as D, type ExternalActionSource as E, type ProcessRuntimeTurnContext as F, type ServerAutomaticTurnRestartBehavior as G, type HumanTurnDefinition as H, type ProcessActionExecution as I, type ProcessActionEffect as J, type LeafOutcomeCaptureResult as K, type LauncherContext as L, type ProcessLeafOutcomeDefinition as M, type ExtensionProcessDefinition as N, type OutcomeToolParameterSpec as O, type ProcessLauncherService as P, type ProcessTurnOutcomeEvent as Q, type RepositoryCredentialRegistrar as R, type ServerAutomaticTurnDefinition as S, type TurnResultMarkdownBehavior as T, type UiProcessAPI as U, type ServerProcessContext as V, type WorkerCompleteInput as W, type ProcessCleanupHandler as X, type TurnBranchType as Y, type WorkerTurnHandler as Z, type WorkerProcessAPI as _, type ProcessLaunchPlan as a, type ProcessActionBranchSelector as a$, type CapabilityCardinality as a0, type CatalogExtensionAPI as a1, type ConfiguredPiProviderReference as a2, type ConfiguredProviderModel as a3, type DefinedProcessInput as a4, type ErasedModelProviderDefinition as a5, type ExtensionLifecycleHook as a6, type ExternalSourceInputMode as a7, type ExternalSourceResolveContext as a8, type ExternalSourceTransition as a9, type PiCustomMessageInput as aA, type PiCustomTool as aB, type PiCustomToolExecutionContext as aC, type PiEvent as aD, type PiEventHandler as aE, type PiEventType as aF, type PiPromptOptions as aG, type PiRunDetails as aH, type PiServerAdapter as aI, type PiServerGenerateTextInput as aJ, type PiServerReference as aK, type PiSessionDiagnostic as aL, type PiSessionDiagnosticHandler as aM, type PiSessionDiagnosticLevel as aN, type PiTerminalAcknowledgementControl as aO, type PiTerminalAcknowledgementState as aP, type PiTreeEntry as aQ, type PiTreeHandle as aR, type PiTreeNode as aS, type PiTurnExecutionResult as aT, type PiUsageData as aU, type PiWorkerContribution as aV, type PiWorkerContributionContext as aW, type PiWorkerReference as aX, type PiWorkerSecretBag as aY, type PlanApprovedEvent as aZ, type PlanRevisionRequestedEvent as a_, type GitSshCredentialMaterial as aa, type HumanTurnActionView as ab, type HumanTurnExternalTrigger as ac, type HumanTurnNotesField as ad, type LauncherModelProfileSummary as ae, type LauncherVisibility as af, type LeafOutcomeCaptureContext as ag, type LeafOutcomeCapturedEvent as ah, type LeitwerkExtensionManifest as ai, type LeitwerkExtensionModule as aj, type ModelProviderCredentialDefinition as ak, type ModelProviderDefinition as al, type ModelProviderModelsContext as am, type ModelProviderSecretsContext as an, type ModelProviderServer as ao, type ModelProviderSet as ap, type ModelProviderSetEntry as aq, type ModelProviderWorker as ar, type OutcomeRouteOptions as as, type OutcomeRouteSpec as at, type OutcomeToolArrayItemSpec as au, type OutcomeToolArrayItemType as av, type OutcomeToolParameterType as aw, type OutcomeToolSpec as ax, PI_BUILT_IN_TOOL_NAMES as ay, type ParsedModelProviderConfig as az, type ProcessLaunchConfig as b, type TurnOutcomeEvent as b$, type ProcessActionBranchSpec as b0, type ProcessActionExternalTrigger as b1, type ProcessActionPreviewDefinition as b2, type ProcessActionSchedulingDefinition as b3, type ProcessActionSchedulingFixedTurnPreview as b4, type ProcessActionSchedulingPreview as b5, type ProcessActionSchedulingTriggerPreview as b6, type ProcessBroadcastEffect as b7, type ProcessContext as b8, type ProcessCreatedEvent as b9, type ProviderWorkerConfigContext as bA, type ProviderWorkerConfigDefinition as bB, type ProviderWorkerConfigSchema as bC, type QuestionRequestedEvent as bD, type RepositoryCredentialKind as bE, type RepositoryCredentialProvider as bF, type ResolvedProcessLauncher as bG, type ResolvedProcessPiConfig as bH, type ReviewCompletedEvent as bI, type ReviewRequestedEvent as bJ, type ServerAutomaticTurnRunResult as bK, type ServerExtensionAPI as bL, type ServerExtensionEventMap as bM, type ServerExtensionEventName as bN, type ServerExtensionEventPayloadInputMap as bO, type ServerExtensionLogger as bP, type ServerTransitionEffect as bQ, type ServerTransitionRequest as bR, type ServerTransitionRuntime as bS, TURN_COMPLETION_MODES as bT, TURN_CONTEXT_MODES as bU, type TurnAcceptanceState as bV, type TurnCompletionMode as bW, type TurnContextMode as bX, type TurnDefinitionRecord as bY, type TurnFailedEvent as bZ, type TurnOptions as b_, type ProcessCustomTool as ba, type ProcessLaunchPlanProcessInput as bb, type ProcessLaunchProjectConfig as bc, type ProcessLifecycleEffects as bd, type ProcessOutcomeEffect as be, type ProcessPatchEffect as bf, type ProcessServerRuntimeContext as bg, type ProcessSnapshotContext as bh, type ProcessTitleSourceField as bi, type ProcessToolResult as bj, type ProcessTurnBinding as bk, type ProcessUpdatedEvent as bl, type ProviderAvailability as bm, type ProviderCredentialStatus as bn, type ProviderJsonObject as bo, type ProviderJsonPrimitive as bp, type ProviderJsonValue as bq, type ProviderModelStatus as br, type ProviderOptionChoice as bs, type ProviderOptionChoicesContext as bt, type ProviderOptionDefaultContext as bu, type ProviderOptionField as bv, type ProviderOptionValidationIssue as bw, type ProviderOptionsDefinition as bx, type ProviderOptionsResolution as by, type ProviderOptionsResolutionInput as bz, type CapabilityToken as c, type TurnResult as c0, type TurnSemanticEntryRefKey as c1, type TurnStartedEvent as c2, type UiLauncherConfigResolution as c3, type UiLauncherDefinition as c4, type UiLauncherResolutionResult as c5, type UiLauncherSummary as c6, type WorkerExtensionAPI as c7, type WorkerProcessContext as c8, type WorkerRunHandle as c9, type PlanSavedEvent as cA, automaticTurn as ca, builtinPiProvider as cb, configuredPiProvider as cc, createCapabilityToken as cd, credentialBasedModelStatuses as ce, defineModelProvider as cf, defineModelProviders as cg, definePiServerAdapter as ch, definePiWorker as ci, defineProcess as cj, defineProviderOptions as ck, defineWorkerConfig as cl, externalTurn as cm, filterProviderOptionsForDefinition as cn, findUiLauncherById as co, getExternalActionArmingId as cp, getExternalActionTransitionTrigger as cq, getExternalSourceTransitionId as cr, humanTurn as cs, llmTurn as ct, piServer as cu, piWorker as cv, resolveHumanTurnView as cw, resolveProviderOptions as cx, routeTurnOutcomes as cy, serverAutomaticTurn as cz, type EventBus as d, type ProcessOutcomeExecution as e, type ProcessEffectPlan as f, type ProcessToolOutcomeSpec as g, type ProcessHumanTurnExternalActionSpec as h, type ExternalTurnDefinition as i, type ExternalSourceEffectContext as j, type ExternalSourceEffect as k, type LlmTurnDefinition as l, type TurnDefinition as m, type ServerProcessAPI as n, type ProcessLauncherAPI as o, type ProcessWatcherAPI as p, type ProcessActionDefinition as q, type ProcessLauncherDefinition as r, type ProcessWatcherDefinition as s, type RepositoryCredentialProject as t, type RepositoryCredentialRequirement as u, type ProcessPiConfig as v, type ProcessDefinition as w, type ProcessHumanTurnActionSpec as x, type HumanTurnOperatorAttention as y, type LlmModelPurpose as z };
|