@leitwerk-dev/process-sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/{chunk-I7U6HCLN.js → chunk-HT2AXXLH.js} +2 -1
  2. package/dist/chunk-HT2AXXLH.js.map +1 -0
  3. package/dist/core-capabilities.d.ts +57 -1
  4. package/dist/core-capabilities.d.ts.map +1 -1
  5. package/dist/define-process.d.ts +43 -26
  6. package/dist/define-process.d.ts.map +1 -1
  7. package/dist/{extension-api-3Vr3RE8S.d.ts → extension-api-Ljc4UTZ0.d.ts} +440 -49
  8. package/dist/extension-api.d.ts +66 -0
  9. package/dist/extension-api.d.ts.map +1 -1
  10. package/dist/external-source-poll.d.ts +1 -1
  11. package/dist/external-source-poll.d.ts.map +1 -1
  12. package/dist/file-external-source.d.ts +32 -0
  13. package/dist/file-external-source.d.ts.map +1 -0
  14. package/dist/flow-mapped.typecheck.d.ts +2 -0
  15. package/dist/flow-mapped.typecheck.d.ts.map +1 -0
  16. package/dist/flow.d.ts +234 -118
  17. package/dist/flow.d.ts.map +1 -1
  18. package/dist/index.d.ts +15 -7
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +4189 -3534
  21. package/dist/index.js.map +1 -1
  22. package/dist/mapped-turn.d.ts +169 -0
  23. package/dist/mapped-turn.d.ts.map +1 -0
  24. package/dist/outcome-contract.d.ts +19 -0
  25. package/dist/outcome-contract.d.ts.map +1 -0
  26. package/dist/outcome-schema.d.ts +23 -0
  27. package/dist/outcome-schema.d.ts.map +1 -0
  28. package/dist/pi-config-public.js +1 -1
  29. package/dist/pi-config.js +1 -1
  30. package/dist/process-flow-view.d.ts +3 -14
  31. package/dist/process-flow-view.d.ts.map +1 -1
  32. package/dist/process-graph.d.ts +10 -4
  33. package/dist/process-graph.d.ts.map +1 -1
  34. package/dist/scoped-settings.d.ts +87 -0
  35. package/dist/scoped-settings.d.ts.map +1 -0
  36. package/dist/ticket-creation.d.ts +24 -0
  37. package/dist/ticket-creation.d.ts.map +1 -0
  38. package/dist/turn-semantics.d.ts +3 -3
  39. package/dist/turn-semantics.d.ts.map +1 -1
  40. package/dist/turn-wait.d.ts +53 -0
  41. package/dist/turn-wait.d.ts.map +1 -0
  42. package/dist/types.d.ts +45 -24
  43. package/dist/types.d.ts.map +1 -1
  44. package/package.json +6 -6
  45. package/src/core-capabilities.ts +76 -1
  46. package/src/define-process.ts +447 -540
  47. package/src/extension-api.ts +78 -0
  48. package/src/external-source-poll.ts +6 -24
  49. package/src/file-external-source.ts +135 -0
  50. package/src/flow-mapped.typecheck.ts +136 -0
  51. package/src/flow.ts +888 -532
  52. package/src/index.ts +77 -2
  53. package/src/mapped-turn.ts +437 -0
  54. package/src/outcome-contract.ts +126 -0
  55. package/src/outcome-schema.ts +314 -0
  56. package/src/process-flow-view.ts +84 -346
  57. package/src/process-graph.ts +95 -45
  58. package/src/scoped-settings.ts +113 -0
  59. package/src/ticket-creation.ts +113 -0
  60. package/src/turn-semantics.ts +102 -116
  61. package/src/turn-wait.ts +76 -0
  62. package/src/types.ts +44 -22
  63. package/dist/chunk-I7U6HCLN.js.map +0 -1
package/src/types.ts CHANGED
@@ -35,6 +35,7 @@ export type PiBuiltInToolName = (typeof PI_BUILT_IN_TOOL_NAMES)[number];
35
35
 
36
36
  /** Tool names owned by the worker runtime rather than an integration extension. @internal */
37
37
  export const FRAMEWORK_LLM_TOOL_NAMES = [
38
+ "abort_turn",
38
39
  "ask_questions",
39
40
  "markdown_result",
40
41
  "upload_result_images",
@@ -81,23 +82,43 @@ export interface ResolvedProcessPiConfig {
81
82
  availableToolNames: string[];
82
83
  }
83
84
 
84
- /** @internal */
85
+ /** @public */
85
86
  export type OutcomeToolParameterType = "string" | "number" | "array" | "boolean" | "object";
86
- /** @internal */
87
- export type OutcomeToolArrayItemType = Exclude<OutcomeToolParameterType, "array">;
88
87
 
89
- /** @internal */
88
+ /** JSON-schema-compatible value declaration nested below an outcome parameter. @public */
90
89
  export interface OutcomeToolArrayItemSpec {
91
- /** @internal */
92
- type: OutcomeToolArrayItemType;
93
- /** @internal */
90
+ /** @public */
91
+ type?: OutcomeToolParameterType;
92
+ /** Alternatives; declare either type or a nonempty anyOf. @public */
93
+ anyOf?: readonly OutcomeToolArrayItemSpec[];
94
+ /** @public */
94
95
  description?: string;
96
+ /** @public */
97
+ minItems?: number;
98
+ /** @public */
99
+ items?: OutcomeToolArrayItemSpec;
100
+ /** @public */
101
+ properties?: Record<string, OutcomeToolArrayItemSpec>;
102
+ /** @public */
103
+ required?: readonly string[];
104
+ /** @public */
105
+ additionalProperties?: boolean;
106
+ /** @public */
107
+ enum?: readonly string[];
108
+ /** @public */
109
+ minLength?: number;
110
+ /** @public */
111
+ minimum?: number;
95
112
  }
96
113
 
97
114
  /** @public */
98
115
  export interface OutcomeToolParameterSpec {
99
116
  /** @internal */
100
- type: OutcomeToolParameterType;
117
+ type?: OutcomeToolParameterType;
118
+ /** Alternatives for this parameter. @public */
119
+ anyOf?: readonly OutcomeToolArrayItemSpec[];
120
+ /** @public */
121
+ minLength?: number;
101
122
  /** @internal */
102
123
  description: string;
103
124
  /** @internal */
@@ -118,10 +139,18 @@ export interface OutcomeToolParameterSpec {
118
139
  items?: OutcomeToolArrayItemSpec;
119
140
  /** @internal */
120
141
  enum?: readonly string[];
142
+ /** Properties of an object parameter. @public */
143
+ properties?: Record<string, OutcomeToolArrayItemSpec>;
144
+ /** Required keys inside an object; `required` marks the parameter itself. @public */
145
+ requiredProperties?: readonly string[];
146
+ /** Whether an object accepts undeclared keys. @public */
147
+ additionalProperties?: boolean;
121
148
  }
122
149
 
123
150
  /** @internal */
124
151
  export interface OutcomeToolSpec {
152
+ /** Opt in to provider enforcement of the complete schema. @internal */
153
+ strictSchema?: boolean;
125
154
  /** @internal */
126
155
  description: string;
127
156
  /** @internal */
@@ -191,6 +220,7 @@ export interface PiTurnExecutionResult {
191
220
 
192
221
  /** @internal */
193
222
  export type PiEventType =
223
+ | "inspection"
194
224
  | "turn.start"
195
225
  | "turn.end"
196
226
  | "stream.delta"
@@ -257,6 +287,10 @@ export interface PiCustomToolExecutionContext {
257
287
 
258
288
  /** @public */
259
289
  export interface PiCustomTool {
290
+ /** Opt in to provider schema enforcement. @internal */
291
+ strictSchema?: boolean;
292
+ /** Hidden tools remain callable by runtime callbacks. @internal */
293
+ modelVisible?: boolean;
260
294
  /** @public */
261
295
  name: string;
262
296
  /** @internal */
@@ -339,6 +373,8 @@ export interface PiPromptOptions {
339
373
  activeTools?: readonly string[];
340
374
  /** @internal Runtime-only hook used by the worker Pi adapter before a tool executes. */
341
375
  shouldBlockToolCall?: (toolName: string) => string | null;
376
+ /** @internal Return control to the worker after a model response and its tool results. */
377
+ shouldStopAfterTurn?: (toolResults: readonly unknown[]) => boolean;
342
378
  /** @internal Guard suspension used by durable interactive tools. */
343
379
  suspendPromptGuards?: () => () => void;
344
380
  /** @internal Runtime-only terminal outcome acknowledgement state. */
@@ -545,20 +581,6 @@ export interface HumanTurnExternalTrigger {
545
581
  description: string;
546
582
  }
547
583
 
548
- /** @internal */
549
- export interface HumanTurnExternalActionView {
550
- /** Process-local arming id exposed to providers and UI. @internal */
551
- id: string;
552
- /** @internal */
553
- externalActionId: string;
554
- /** @internal */
555
- sourceKind: string;
556
- /** @internal */
557
- label: string | null;
558
- /** @internal */
559
- description: string | null;
560
- }
561
-
562
584
  /** @internal */
563
585
  export interface EventBus<TEventMap extends object = Record<string, unknown>> {
564
586
  /** @internal */
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/pi-config.ts","../src/types.ts"],"sourcesContent":["import { homedir } from \"node:os\";\nimport type { ConfigSnapshot } from \"@leitwerk-dev/protocol\";\nimport Mustache from \"mustache\";\nimport type { LlmTurnDefinition } from \"./define-process.js\";\nimport {\n\tPI_BUILT_IN_TOOL_NAMES,\n\ttype PiBuiltInToolName,\n\ttype ProcessPiConfig,\n\ttype ResolvedProcessPiConfig,\n} from \"./types.js\";\n\n/** @internal */\ntype TemplateScalar = string | number | boolean;\n/** @internal */\ntype TemplateValue = TemplateScalar | TemplateContext | readonly TemplateValue[] | undefined;\n\n/** @internal */\nexport interface TemplateContext {\n\t/** @internal */\n\t[key: string]: TemplateValue;\n}\n\nfunction isScalarValue(value: unknown): value is string | number | boolean {\n\treturn typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\";\n}\n\nfunction toTemplateContextRecord(value: unknown): TemplateContext {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\treturn {};\n\t}\n\tconst context: TemplateContext = {};\n\tfor (const [key, candidate] of Object.entries(value)) {\n\t\tif (isScalarValue(candidate)) {\n\t\t\tcontext[key] = candidate;\n\t\t}\n\t}\n\treturn context;\n}\n\n/** @internal */\nexport function createTemplateContext(input: {\n\t/** @internal */\n\tparams?: unknown;\n\t/** @internal */\n\tprocess?: {\n\t\t/** @internal */\n\t\tprocessId?: string | null;\n\t\t/** @internal */\n\t\texternalId?: string | null;\n\t\t/** @internal */\n\t\texternalUrl?: string | null;\n\t\t/** @internal */\n\t\tselectedTurnId?: string | null;\n\t};\n\t/** @internal */\n\tprojects?: ReadonlyArray<{\n\t\t/** @internal */\n\t\tkey: string;\n\t\t/** @internal */\n\t\trepoLocator: string;\n\t\t/** @internal */\n\t\tbaseBranch: string;\n\t\t/** @internal */\n\t\tworkBranch?: string | null;\n\t}>;\n}): TemplateContext {\n\tconst context: TemplateContext = {\n\t\t...toTemplateContextRecord(input.params),\n\t};\n\tif (input.process) {\n\t\tcontext.processId = input.process.processId ?? undefined;\n\t\tcontext.externalId = input.process.externalId ?? undefined;\n\t\tcontext.externalUrl = input.process.externalUrl ?? undefined;\n\t\tcontext.selectedTurnId = input.process.selectedTurnId ?? undefined;\n\t}\n\tconst firstProject = input.projects?.[0];\n\tif (firstProject) {\n\t\tcontext.projectKey = firstProject.key;\n\t\tcontext.repositoryUrl = firstProject.repoLocator;\n\t\tcontext.baseBranch = firstProject.baseBranch;\n\t\tcontext.workBranch = firstProject.workBranch ?? undefined;\n\t}\n\treturn context;\n}\n\n/** @internal */\nexport function interpolateTemplate(template: string, context: TemplateContext): string {\n\treturn Mustache.render(template, context);\n}\n\n/** @internal */\ntype TurnToolDefinitionLike =\n\t| {\n\t\t\t/** @internal */\n\t\t\tkind: \"llm\";\n\t\t\t/** @internal */\n\t\t\tavailableTools: readonly PiBuiltInToolName[];\n\t }\n\t| {\n\t\t\t/** @internal */\n\t\t\tkind: string;\n\t };\n\n/** @internal */\ntype ProcessTurnBindingLike = {\n\t/** @internal */\n\tdefinition: TurnToolDefinitionLike;\n};\n\n/** @internal */\ntype ProcessToolSource = TurnToolDefinitionLike | ProcessTurnBindingLike;\n\nfunction isTurnDefinitionSource(source: ProcessToolSource): source is TurnToolDefinitionLike {\n\treturn \"kind\" in source;\n}\n\nfunction resolveToolSourceDefinition(source: ProcessToolSource): TurnToolDefinitionLike {\n\treturn isTurnDefinitionSource(source) ? source : source.definition;\n}\n\n/** @internal */\nexport function validatePiBuiltInToolArray(\n\ttoolNames: readonly unknown[],\n\tcontext: string,\n): string[] {\n\tconst errors: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const rawName of toolNames) {\n\t\tif (typeof rawName !== \"string\") {\n\t\t\terrors.push(`${context} must contain only string tool names`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst name = rawName.trim();\n\t\tif (name === \"\") {\n\t\t\terrors.push(`${context} must not contain empty tool names`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (name !== rawName) {\n\t\t\terrors.push(`${context} must use canonical Pi tool names without surrounding whitespace`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (!PI_BUILT_IN_TOOL_NAMES.includes(name as PiBuiltInToolName)) {\n\t\t\terrors.push(\n\t\t\t\t`${context} references unknown Pi tool '${name}'. Expected one of ${PI_BUILT_IN_TOOL_NAMES.join(\", \")}`,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\t\tif (seen.has(name)) {\n\t\t\terrors.push(`${context} must not contain duplicate Pi tool '${name}'`);\n\t\t\tcontinue;\n\t\t}\n\t\tseen.add(name);\n\t}\n\treturn errors;\n}\n\n/** @internal */\nexport function resolveTurnAvailableToolNames(input: {\n\t/** @internal */\n\tturnId: string;\n\t/** @internal */\n\tturnDef: LlmTurnDefinition<string, unknown, unknown>;\n}): string[] {\n\tconst errors = validatePiBuiltInToolArray(\n\t\tinput.turnDef.availableTools,\n\t\t`turn '${input.turnId}' availableTools`,\n\t);\n\tif (errors.length > 0) {\n\t\tthrow new Error(errors.join(\"; \"));\n\t}\n\treturn [...input.turnDef.availableTools];\n}\n\n/** @internal */\nexport function collectProcessAvailableToolNames(\n\tturns: Iterable<ProcessToolSource> | undefined,\n): string[] {\n\tconst usedToolNames = new Set<PiBuiltInToolName>();\n\tfor (const source of turns ?? []) {\n\t\tconst definition = resolveToolSourceDefinition(source);\n\t\tif (definition.kind !== \"llm\" || !(\"availableTools\" in definition)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst errors = validatePiBuiltInToolArray(definition.availableTools, \"LLM turn availableTools\");\n\t\tif (errors.length > 0) {\n\t\t\tthrow new Error(errors.join(\"; \"));\n\t\t}\n\t\tfor (const toolName of definition.availableTools) {\n\t\t\tusedToolNames.add(toolName);\n\t\t}\n\t}\n\treturn PI_BUILT_IN_TOOL_NAMES.filter((toolName) => usedToolNames.has(toolName));\n}\n\nconst DEFAULT_TOOL_DESCRIPTIONS: Record<PiBuiltInToolName, string> = {\n\tread: \"Read file contents\",\n\tbash: \"Execute bash commands (ls, grep, find, etc.)\",\n\tedit: \"Make surgical edits to files (find exact text and replace)\",\n\twrite: \"Create or overwrite files\",\n\tgrep: \"Search file contents\",\n\tfind: \"Find files by name/path\",\n\tls: \"List directory contents\",\n};\n\nfunction buildDefaultSystemPrompt(availableToolNames: readonly string[]): string {\n\tconst toolList =\n\t\tavailableToolNames.length > 0\n\t\t\t? availableToolNames\n\t\t\t\t\t.map((toolName) => {\n\t\t\t\t\t\tconst description =\n\t\t\t\t\t\t\tDEFAULT_TOOL_DESCRIPTIONS[toolName as PiBuiltInToolName] ?? \"Built-in Pi tool\";\n\t\t\t\t\t\treturn `- ${toolName}: ${description}`;\n\t\t\t\t\t})\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t: \"- No built-in tools are available for this process unless a turn registers custom tools.\";\n\treturn `You are an expert coding assistant operating inside pi, a coding agent harness. You help users by using the tools made available for the active turn.\n\nAvailable built-in tools for this process:\n${toolList}\n\nIn addition to the tools above, you may have access to other custom tools depending on the active turn.\n\nGuidelines:\n- Use only tools that are available in the active turn.\n- Use read/search tools to examine files before editing.\n- Use edit for precise changes when it is available (old text must match exactly).\n- Use write only for new files or complete rewrites when it is available.\n- When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did.\n- Be concise in your responses.\n- Show file paths clearly when working with files.`;\n}\n\n/** @internal */\nexport function resolveProcessPiConfig(input: {\n\t/** @internal */\n\tprocessId: string;\n\t/** @internal */\n\tprocessPiConfig?: ProcessPiConfig;\n\t/** @internal */\n\tturns?: Iterable<ProcessToolSource>;\n\t/** @internal */\n\tconfigSnapshot?: ConfigSnapshot;\n\t/** @internal */\n\ttemplateContext: TemplateContext;\n}): ResolvedProcessPiConfig {\n\tconst processConfig = input.configSnapshot?.process_configs?.[input.processId];\n\tconst processPiOverride = processConfig?.pi;\n\tconst availableToolNames = collectProcessAvailableToolNames(input.turns);\n\n\tconst configSystemPromptTemplate = input.configSnapshot?.pi?.system_prompt_template;\n\tconst systemPromptTemplate =\n\t\tprocessPiOverride?.system_prompt_template ??\n\t\tinput.processPiConfig?.systemPromptTemplate ??\n\t\tconfigSystemPromptTemplate;\n\tconst appendSystemPromptTemplate =\n\t\tprocessPiOverride?.append_system_prompt_template ??\n\t\tinput.processPiConfig?.appendSystemPromptTemplate;\n\n\tconst resolvedSystemPrompt = systemPromptTemplate\n\t\t? interpolateTemplate(systemPromptTemplate, input.templateContext)\n\t\t: buildDefaultSystemPrompt(availableToolNames);\n\tconst sessionCwd = input.processPiConfig?.sessionCwdTemplate\n\t\t? interpolateTemplate(input.processPiConfig.sessionCwdTemplate, input.templateContext).trim()\n\t\t: undefined;\n\n\treturn {\n\t\tsystemPrompt: resolvedSystemPrompt,\n\t\tappendSystemPrompt: appendSystemPromptTemplate\n\t\t\t? interpolateTemplate(appendSystemPromptTemplate, input.templateContext)\n\t\t\t: undefined,\n\t\t...(sessionCwd ? { sessionCwd } : {}),\n\t\tavailableToolNames,\n\t};\n}\n\nexport { resolveTurnAvailableToolNames as resolveTurnActiveToolNames };\n\n// Mirror Pi's PI_CODING_AGENT_DIR expansion semantics from\n// pi-mono/packages/coding-agent/src/config.ts.\n/** @internal */\nexport function expandPiAgentDir(agentDir: string): string {\n\tif (agentDir === \"~\") {\n\t\treturn homedir();\n\t}\n\tif (agentDir.startsWith(\"~/\")) {\n\t\treturn homedir() + agentDir.slice(1);\n\t}\n\treturn agentDir;\n}\n\n/** @internal */\nexport function resolvePiAgentDir(options: {\n\t/** @internal */\n\tagentDir?: string | null;\n\t/** @internal */\n\tconfigSnapshot?: ConfigSnapshot;\n\t/** @internal */\n\tfallbackDir: string;\n}): string {\n\tconst configuredAgentDir =\n\t\ttypeof options.agentDir === \"string\" && options.agentDir.trim() !== \"\"\n\t\t\t? options.agentDir\n\t\t\t: typeof options.configSnapshot?.pi?.agent_dir === \"string\" &&\n\t\t\t\t\toptions.configSnapshot.pi.agent_dir.trim() !== \"\"\n\t\t\t\t? options.configSnapshot.pi.agent_dir\n\t\t\t\t: options.fallbackDir;\n\treturn expandPiAgentDir(configuredAgentDir);\n}\n","import type {\n\tTurnAcceptanceState as DomainTurnAcceptanceState,\n\tProcessTurnRecordPathType,\n\tProcessTurnTerminalLifecycleStatus,\n\tTurnId,\n} from \"@leitwerk-dev/domain\";\nimport type { UsageCostSnapshot, UsageTokenCounts } from \"@leitwerk-dev/protocol\";\n\n/** @internal */\nexport interface TurnOptions {\n\t/** @internal */\n\treset?: boolean;\n}\n\n/** @internal */\nexport interface TurnResult<T extends string = string> {\n\t/** @internal */\n\toutcome: T;\n\t/** @internal */\n\tparams: Record<string, unknown>;\n}\n\n/** @public */\nexport const PI_BUILT_IN_TOOL_NAMES = [\n\t\"read\",\n\t\"bash\",\n\t\"edit\",\n\t\"write\",\n\t\"grep\",\n\t\"find\",\n\t\"ls\",\n] as const;\n/** @public */\nexport type PiBuiltInToolName = (typeof PI_BUILT_IN_TOOL_NAMES)[number];\n\n/** Tool names owned by the worker runtime rather than an integration extension. @internal */\nexport const FRAMEWORK_LLM_TOOL_NAMES = [\n\t\"ask_questions\",\n\t\"markdown_result\",\n\t\"upload_result_images\",\n] as const;\n\n/** Names integration tools cannot use because Pi or the worker runtime owns them. @internal */\nexport const RESERVED_INTEGRATION_TOOL_NAMES = [\n\t...PI_BUILT_IN_TOOL_NAMES,\n\t...FRAMEWORK_LLM_TOOL_NAMES,\n] as const;\n\n/** @public */\nexport interface ProcessPiConfig {\n\t/**\n\t * System prompt template. Rendered with Mustache against runtime context.\n\t * Use {{variableName}} for escaped values and {{{variableName}}} for raw values.\n\t * When omitted, Pi's default system prompt is used.\n\t */\n\t/** @internal */\n\tsystemPromptTemplate?: string;\n\t/**\n\t * Additional text appended after the base system prompt/resources. Rendered\n\t * with Mustache against runtime context.\n\t */\n\t/** @public */\n\tappendSystemPromptTemplate?: string;\n\t/**\n\t * Code-defined Pi session working directory template. Rendered with Mustache\n\t * against runtime context. When omitted, the process workspace root is used.\n\t */\n\t/** @public */\n\tsessionCwdTemplate?: string;\n}\n\n/** @internal */\nexport interface ResolvedProcessPiConfig {\n\t/** @internal */\n\tsystemPrompt?: string;\n\t/** @internal */\n\tappendSystemPrompt?: string;\n\t/** @internal */\n\tsessionCwd?: string;\n\t/** @internal */\n\tavailableToolNames: string[];\n}\n\n/** @internal */\nexport type OutcomeToolParameterType = \"string\" | \"number\" | \"array\" | \"boolean\" | \"object\";\n/** @internal */\nexport type OutcomeToolArrayItemType = Exclude<OutcomeToolParameterType, \"array\">;\n\n/** @internal */\nexport interface OutcomeToolArrayItemSpec {\n\t/** @internal */\n\ttype: OutcomeToolArrayItemType;\n\t/** @internal */\n\tdescription?: string;\n}\n\n/** @public */\nexport interface OutcomeToolParameterSpec {\n\t/** @internal */\n\ttype: OutcomeToolParameterType;\n\t/** @internal */\n\tdescription: string;\n\t/** @internal */\n\trequired?: boolean;\n\t/** @internal */\n\trequiredErrorCode?: string;\n\t/** @internal */\n\tinvalidErrorCode?: string;\n\t/** @internal */\n\tminItems?: number;\n\t/** @internal */\n\tminItemsErrorCode?: string;\n\t/** @internal */\n\tminimum?: number;\n\t/** @internal */\n\tminimumErrorCode?: string;\n\t/** @internal */\n\titems?: OutcomeToolArrayItemSpec;\n\t/** @internal */\n\tenum?: readonly string[];\n}\n\n/** @internal */\nexport interface OutcomeToolSpec {\n\t/** @internal */\n\tdescription: string;\n\t/** @internal */\n\tparameters: Record<string, OutcomeToolParameterSpec>;\n\t/** Product published from this outcome's turn-result markdown, when selected. @internal */\n\tpublishedProduct?: string;\n\t/** Outcome parameter whose markdown value is captured as the turn result. @internal */\n\tturnResultMarkdownParameter?: string;\n\t/** Outcome parameter containing a concise operator-facing summary. @internal */\n\tresultSummaryParameter?: string;\n}\n\n/** @public */\nexport interface PiTreeEntry {\n\t/** @internal */\n\treadonly id: string;\n\t/** @internal */\n\treadonly parentId: string | null;\n\t/** @public */\n\treadonly type: string;\n\t/** @internal */\n\treadonly timestamp: string;\n\t/** @public */\n\treadonly message?: {\n\t\t/** @internal */\n\t\treadonly role?: string;\n\t\t/** @public */\n\t\treadonly content?: unknown;\n\t};\n\t/** Pi custom-message fields. Details are intentionally excluded from model context. @internal */\n\treadonly customType?: string;\n\t/** @public */\n\treadonly content?: unknown;\n\t/** @internal */\n\treadonly details?: unknown;\n\t/** @internal */\n\treadonly targetId?: string;\n\t/** @internal */\n\treadonly label?: string;\n}\n\n/** @internal */\nexport interface PiTreeNode {\n\t/** @internal */\n\treadonly entry: PiTreeEntry;\n\t/** @internal */\n\treadonly children: readonly PiTreeNode[];\n\t/** @internal */\n\treadonly label?: string;\n\t/** @internal */\n\treadonly labelTimestamp?: string;\n}\n\n/** @public */\nexport interface PiTurnExecutionResult {\n\t/** @internal */\n\tstartLeafId: string | null;\n\t/** @internal */\n\tendLeafId: string | null;\n\t/** @internal */\n\tcreatedEntryIds: string[];\n\t/** @internal */\n\tresultEntryId: string;\n\t/** Final assistant markdown captured from the Pi assistant message for this turn, when available. @internal */\n\tassistantMarkdown?: string | null;\n}\n\n/** @internal */\nexport type PiEventType =\n\t| \"turn.start\"\n\t| \"turn.end\"\n\t| \"stream.delta\"\n\t| \"tool.call\"\n\t| \"tool.update\"\n\t| \"tool.result\"\n\t| \"toolcall.start\"\n\t| \"toolcall.delta\"\n\t| \"toolcall.end\"\n\t| \"compaction.start\"\n\t| \"compaction.end\"\n\t| \"label.changed\"\n\t| \"error\"\n\t| \"retry.start\"\n\t| \"retry.end\"\n\t| \"usage\";\n\n/** @internal */\nexport interface PiEvent {\n\t/** @internal */\n\ttype: PiEventType;\n\t/** @internal */\n\tturnId: string;\n\t/** @internal */\n\tdata: Record<string, unknown>;\n\t/** @internal */\n\ttimestamp: string;\n}\n\n/** @internal */\nexport type PiEventHandler = (event: PiEvent) => void;\n\n/** @internal */\nexport type PiSessionDiagnosticLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\n/** @internal */\nexport interface PiSessionDiagnostic {\n\t/** @internal */\n\tlevel: PiSessionDiagnosticLevel;\n\t/** @internal */\n\tcode: string;\n\t/** @internal */\n\tmessage: string;\n\t/** @internal */\n\ttimestamp: string;\n\t/** @internal */\n\tturnId?: string;\n\t/** @internal */\n\tdetails?: Record<string, unknown>;\n}\n\n/** @internal */\nexport type PiSessionDiagnosticHandler = (diagnostic: PiSessionDiagnostic) => void;\n\n/** @public */\nexport interface PiCustomToolExecutionContext {\n\t/** Pi's identity for this exact invocation; stable across the paused call. @public */\n\ttoolCallId: string;\n\t/** Aborted when the active turn is stopped or torn down. @public */\n\tsignal: AbortSignal;\n\t/** Pause model-execution budgets while this custom tool awaits durable operator input. @internal */\n\tsuspendPromptGuards?: () => () => void;\n}\n\n/** @public */\nexport interface PiCustomTool {\n\t/** @public */\n\tname: string;\n\t/** @internal */\n\tdescription: string;\n\t/** @internal */\n\tparameters: Record<string, unknown>;\n\t/** @internal */\n\texecutionMode?: \"sequential\" | \"parallel\";\n\t/** @public */\n\texecute(args: Record<string, unknown>, context?: PiCustomToolExecutionContext): Promise<unknown>;\n}\n\n/** @internal */\nexport interface PiUsageData extends UsageTokenCounts {\n\t/** @internal */\n\tcost: UsageCostSnapshot;\n\t/** @internal */\n\tcacheHitRate: number;\n}\n\n/** @internal */\nexport interface PiRunDetails {\n\t/** @internal */\n\tloadedAgentsFiles: Array<{\n\t\t/** @internal */\n\t\tpath: string;\n\t\t/** @internal */\n\t\tsizeBytes: number;\n\t}>;\n\t/** @internal */\n\tloadedSkills: Array<{\n\t\t/** @internal */\n\t\tname: string;\n\t\t/** @internal */\n\t\tpath: string;\n\t}>;\n\t/** @internal */\n\tavailableToolNames: string[];\n}\n\n/** @internal */\nexport type ProcessCustomTool = PiCustomTool;\n\n/** @public */\nexport interface PiCustomMessageInput {\n\t/** @internal */\n\tcontent: string;\n\t/** @internal */\n\tdetails: unknown;\n\t/** @internal */\n\tdisplay?: boolean;\n}\n\n/** @internal */\nexport type PiTerminalAcknowledgementState =\n\t| \"open\"\n\t| \"outcome_accepted\"\n\t| \"acknowledgement_succeeded\"\n\t| \"acknowledgement_failed_ignored\";\n\n/** @internal */\nexport interface PiTerminalAcknowledgementControl {\n\t/** @internal */\n\treadonly timeoutMs: number;\n\t/** @internal */\n\tstate(): PiTerminalAcknowledgementState;\n\t/** @internal */\n\tisOperatorAbortRequested(): boolean;\n\t/** @internal */\n\tmarkSucceeded(): void;\n\t/** @internal */\n\tmarkFailed(reason: string): void;\n}\n\n/** @public */\nexport interface PiPromptOptions {\n\t/** @public */\n\ttools?: readonly PiCustomTool[];\n\t/** @internal */\n\tactiveTools?: readonly string[];\n\t/** @internal Runtime-only hook used by the worker Pi adapter before a tool executes. */\n\tshouldBlockToolCall?: (toolName: string) => string | null;\n\t/** @internal Guard suspension used by durable interactive tools. */\n\tsuspendPromptGuards?: () => () => void;\n\t/** @internal Runtime-only terminal outcome acknowledgement state. */\n\tterminalAcknowledgement?: PiTerminalAcknowledgementControl;\n}\n\n/** @public */\nexport interface PiTreeHandle {\n\t/** @internal */\n\treadonly sessionId: string;\n\t/** @internal */\n\treadonly treeFile: string;\n\t/** @internal */\n\treadonly isResumed: boolean;\n\n\t/** @internal */\n\tgetRunDetails(): PiRunDetails;\n\t/** @internal */\n\tgetLeafId(): string | null;\n\t/** @internal */\n\tgetEntry(id: string): PiTreeEntry | undefined;\n\t/** @internal */\n\tgetBranch(fromId?: string): PiTreeEntry[];\n\t/** @internal */\n\tgetChildren(parentId: string): PiTreeEntry[];\n\t/** @internal */\n\tgetTree(): PiTreeNode[];\n\t/** @internal */\n\tbranch(entryId: string): void | Promise<void>;\n\t/** @internal */\n\tbranchFromRoot(): void | Promise<void>;\n\t/** @internal */\n\tresetLeaf(): void | Promise<void>;\n\t/**\n\t * Compact the current Pi context. `details` is persisted with the resulting\n\t * compaction entry, but deliberately remains outside model context.\n\t */\n\t/** @internal */\n\tcompact?(customInstructions?: string, details?: unknown): Promise<unknown>;\n\t/** @public */\n\tprompt(text: string, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;\n\t/** @public */\n\tpromptLiteral(text: string, options?: PiPromptOptions): Promise<PiTurnExecutionResult>;\n\t/** @public */\n\tpromptCustom(\n\t\tinput: PiCustomMessageInput,\n\t\toptions?: PiPromptOptions,\n\t): Promise<PiTurnExecutionResult>;\n\t/** @public */\n\tcontinueTurn(options?: PiPromptOptions): Promise<PiTurnExecutionResult>;\n\t/** @internal */\n\tappendCustomMessage?(input: PiCustomMessageInput): Promise<string>;\n\t/** @internal */\n\tsteer(text: string): Promise<void>;\n\t/** @internal */\n\tabortTurn(): Promise<void>;\n\t/** @internal */\n\tsubscribe(handler: PiEventHandler): () => void;\n\t/** @internal */\n\tsubscribeDiagnostics?(handler: PiSessionDiagnosticHandler): () => void;\n\t/** @internal */\n\tclose(): Promise<void>;\n}\n\n/** @public */\nexport const TURN_CONTEXT_MODES = [\"full\", \"compacted\", \"fresh\", \"fresh_seeded\"] as const;\n/** @public */\nexport type TurnContextMode = (typeof TURN_CONTEXT_MODES)[number];\n\n/** @public */\nexport const TURN_COMPLETION_MODES = [\"turn_end\"] as const;\n/** @public */\nexport type TurnCompletionMode = (typeof TURN_COMPLETION_MODES)[number];\n\n/** @public */\nexport type TurnBranchType = ProcessTurnRecordPathType;\n\n/** @public */\nexport interface TurnResultMarkdownNoneBehavior {\n\t/** @internal */\n\tmode: \"none\";\n}\n\n/** @public */\nexport interface TurnResultMarkdownAssistantOutputBehavior {\n\t/** @internal */\n\tmode: \"assistant_output\";\n\t/** @internal */\n\trequired?: boolean;\n}\n\n/** @public */\nexport interface TurnResultMarkdownToolCallBehavior {\n\t/** @internal */\n\tmode: \"tool_call\";\n\t/** @internal */\n\ttoolName: string;\n\t/** @internal */\n\tsource?: \"arguments\" | \"result\";\n\t/** @internal */\n\tpath: string;\n\t/** @internal */\n\trequired?: boolean;\n}\n\n/** @public */\nexport interface TurnResultMarkdownOutcomeToolArgumentBehavior {\n\t/** @internal */\n\tmode: \"outcome_tool_argument\";\n\t/** @internal */\n\tparameterName: string;\n\t/** @internal */\n\trequired?: boolean;\n}\n\n/** @public */\nexport type TurnResultMarkdownBehavior =\n\t| TurnResultMarkdownNoneBehavior\n\t| TurnResultMarkdownAssistantOutputBehavior\n\t| TurnResultMarkdownToolCallBehavior\n\t| TurnResultMarkdownOutcomeToolArgumentBehavior;\n\n/** @public */\nexport type TurnAcceptanceState = DomainTurnAcceptanceState;\n\n/** @public */\nexport interface ProcessActionSchedulingFixedTurnPreview {\n\t/** @public */\n\tkind: \"fixed_turn\";\n\t/** @public */\n\tturnId: TurnId | null;\n}\n\n/** @public */\nexport interface ProcessActionSchedulingTriggerPreview {\n\t/** @public */\n\tkind: \"trigger\";\n\t/** @internal */\n\ttrigger: string;\n}\n\n/** @public */\nexport interface ProcessActionSchedulingTerminalPreview {\n\t/** @public */\n\tkind: \"terminal\";\n\t/** @internal */\n\tlifecycleStatus: ProcessTurnTerminalLifecycleStatus;\n}\n\n/** @public */\nexport type ProcessActionSchedulingPreview =\n\t| ProcessActionSchedulingFixedTurnPreview\n\t| ProcessActionSchedulingTriggerPreview\n\t| ProcessActionSchedulingTerminalPreview;\n\n/** @public */\nexport type ProcessActionPreviewDefinition = ProcessActionSchedulingPreview;\n\n/** @internal */\nexport interface ProcessActionSchedulingDefinition {\n\t/** @internal */\n\tpreview: ProcessActionSchedulingPreview;\n}\n\n/** @internal */\nexport interface HumanTurnActionView {\n\t/** @internal */\n\tactionId: string;\n\t/** @internal */\n\tacceptanceState: TurnAcceptanceState;\n\t/** @internal */\n\tlabel?: string;\n\t/** @internal */\n\tdescription?: string;\n\t/** @internal */\n\tpreview?: ProcessActionPreviewDefinition;\n\t/** @internal */\n\tscheduling?: ProcessActionSchedulingDefinition;\n}\n\n/** @internal */\nexport interface HumanTurnNotesField {\n\t/** @internal */\n\tid: string;\n\t/** @internal */\n\tlabel: string;\n\t/** @internal */\n\tdescription?: string;\n\t/** @internal */\n\tplaceholder?: string;\n\t/** @internal */\n\trequired?: boolean;\n}\n\n/** @internal */\nexport interface HumanTurnExternalTrigger {\n\t/** @internal */\n\tid: string;\n\t/** @internal */\n\tactionId: string;\n\t/** @internal */\n\tlabel: string;\n\t/** @internal */\n\tdescription: string;\n}\n\n/** @internal */\nexport interface HumanTurnExternalActionView {\n\t/** Process-local arming id exposed to providers and UI. @internal */\n\tid: string;\n\t/** @internal */\n\texternalActionId: string;\n\t/** @internal */\n\tsourceKind: string;\n\t/** @internal */\n\tlabel: string | null;\n\t/** @internal */\n\tdescription: string | null;\n}\n\n/** @internal */\nexport interface EventBus<TEventMap extends object = Record<string, unknown>> {\n\t/** @internal */\n\temit<K extends keyof TEventMap & string>(event: K, data: TEventMap[K]): void;\n\t/** @internal */\n\ton<K extends keyof TEventMap & string>(\n\t\tevent: K,\n\t\thandler: (data: TEventMap[K]) => void | Promise<void>,\n\t): void;\n\t/** @internal */\n\toff<K extends keyof TEventMap & string>(\n\t\tevent: K,\n\t\thandler: (data: TEventMap[K]) => void | Promise<void>,\n\t): void;\n}\n"],"mappings":";AAAA,SAAS,eAAe;AAExB,OAAO,cAAc;;;ACqBd,IAAM,yBAAyB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAKO,IAAM,2BAA2B;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACD;AAGO,IAAM,kCAAkC;AAAA,EAC9C,GAAG;AAAA,EACH,GAAG;AACJ;;;ADxBA,SAAS,cAAc,OAAoD;AAC1E,SAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU;AACnF;AAEA,SAAS,wBAAwB,OAAiC;AACjE,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,MAAM,QAAQ,KAAK,GAAG;AACxE,WAAO,CAAC;AAAA,EACT;AACA,QAAM,UAA2B,CAAC;AAClC,aAAW,CAAC,KAAK,SAAS,KAAK,OAAO,QAAQ,KAAK,GAAG;AACrD,QAAI,cAAc,SAAS,GAAG;AAC7B,cAAQ,GAAG,IAAI;AAAA,IAChB;AAAA,EACD;AACA,SAAO;AACR;AAGO,SAAS,sBAAsB,OAyBlB;AACnB,QAAM,UAA2B;AAAA,IAChC,GAAG,wBAAwB,MAAM,MAAM;AAAA,EACxC;AACA,MAAI,MAAM,SAAS;AAClB,YAAQ,YAAY,MAAM,QAAQ,aAAa;AAC/C,YAAQ,aAAa,MAAM,QAAQ,cAAc;AACjD,YAAQ,cAAc,MAAM,QAAQ,eAAe;AACnD,YAAQ,iBAAiB,MAAM,QAAQ,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