@leitwerk-dev/process-sdk 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/git-binary.d.ts +4 -3
- package/dist/git-binary.js +25 -33
- package/dist/git-binary.js.map +1 -1
- package/dist/index.d.ts +1066 -35
- package/dist/index.js +4488 -28
- package/dist/index.js.map +1 -1
- package/dist/leaf-outcome-renderer.d.ts +7 -7
- package/dist/leaf-outcome-renderer.js +74 -64
- package/dist/leaf-outcome-renderer.js.map +1 -1
- package/dist/pi-config.d.ts +19 -15
- package/dist/pi-config.js +21 -180
- package/dist/pi-config.js.map +1 -1
- package/dist/review-flow.d.ts +13 -7
- package/dist/review-flow.js +12 -43
- package/dist/review-flow.js.map +1 -1
- package/dist/runtime-internals.d.ts +21 -3
- package/dist/runtime-internals.js +18 -2
- package/dist/runtime-internals.js.map +1 -1
- package/package.json +4 -4
- package/dist/browser-ui-extension.d.ts +0 -27
- package/dist/browser-ui-extension.d.ts.map +0 -1
- package/dist/browser-ui-extension.js +0 -2
- package/dist/browser-ui-extension.js.map +0 -1
- package/dist/capabilities.d.ts +0 -9
- package/dist/capabilities.d.ts.map +0 -1
- package/dist/capabilities.js +0 -7
- package/dist/capabilities.js.map +0 -1
- package/dist/codecs.d.ts +0 -3
- package/dist/codecs.d.ts.map +0 -1
- package/dist/codecs.js +0 -9
- package/dist/codecs.js.map +0 -1
- package/dist/commit-message.d.ts +0 -7
- package/dist/commit-message.d.ts.map +0 -1
- package/dist/commit-message.js +0 -3
- package/dist/commit-message.js.map +0 -1
- package/dist/core-capabilities.d.ts +0 -393
- package/dist/core-capabilities.d.ts.map +0 -1
- package/dist/core-capabilities.js +0 -6
- package/dist/core-capabilities.js.map +0 -1
- package/dist/define-process.d.ts +0 -269
- package/dist/define-process.d.ts.map +0 -1
- package/dist/define-process.js +0 -1040
- package/dist/define-process.js.map +0 -1
- package/dist/event-bus.d.ts +0 -3
- package/dist/event-bus.d.ts.map +0 -1
- package/dist/event-bus.js +0 -31
- package/dist/event-bus.js.map +0 -1
- package/dist/extension-api.d.ts +0 -425
- package/dist/extension-api.d.ts.map +0 -1
- package/dist/extension-api.js +0 -5
- package/dist/extension-api.js.map +0 -1
- package/dist/flow.d.ts +0 -456
- package/dist/flow.d.ts.map +0 -1
- package/dist/flow.js +0 -1557
- package/dist/flow.js.map +0 -1
- package/dist/form-contract.d.ts +0 -2
- package/dist/form-contract.d.ts.map +0 -1
- package/dist/form-contract.js +0 -2
- package/dist/form-contract.js.map +0 -1
- package/dist/fs-utils.d.ts +0 -3
- package/dist/fs-utils.d.ts.map +0 -1
- package/dist/fs-utils.js +0 -23
- package/dist/fs-utils.js.map +0 -1
- package/dist/git-binary.d.ts.map +0 -1
- package/dist/graph-fragments.d.ts +0 -23
- package/dist/graph-fragments.d.ts.map +0 -1
- package/dist/graph-fragments.js +0 -57
- package/dist/graph-fragments.js.map +0 -1
- package/dist/host-capabilities.d.ts +0 -12
- package/dist/host-capabilities.d.ts.map +0 -1
- package/dist/host-capabilities.js +0 -42
- package/dist/host-capabilities.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/launcher-contract.d.ts +0 -2
- package/dist/launcher-contract.d.ts.map +0 -1
- package/dist/launcher-contract.js +0 -2
- package/dist/launcher-contract.js.map +0 -1
- package/dist/leaf-outcome-renderer.d.ts.map +0 -1
- package/dist/leaf-outcomes.d.ts +0 -5
- package/dist/leaf-outcomes.d.ts.map +0 -1
- package/dist/leaf-outcomes.js +0 -52
- package/dist/leaf-outcomes.js.map +0 -1
- package/dist/model-provider.d.ts +0 -210
- package/dist/model-provider.d.ts.map +0 -1
- package/dist/model-provider.js +0 -171
- package/dist/model-provider.js.map +0 -1
- package/dist/pi-config.d.ts.map +0 -1
- package/dist/process-definition-internals.d.ts +0 -7
- package/dist/process-definition-internals.d.ts.map +0 -1
- package/dist/process-definition-internals.js +0 -25
- package/dist/process-definition-internals.js.map +0 -1
- package/dist/process-flow-view.d.ts +0 -20
- package/dist/process-flow-view.d.ts.map +0 -1
- package/dist/process-flow-view.js +0 -418
- package/dist/process-flow-view.js.map +0 -1
- package/dist/process-graph.d.ts +0 -45
- package/dist/process-graph.d.ts.map +0 -1
- package/dist/process-graph.js +0 -213
- package/dist/process-graph.js.map +0 -1
- package/dist/process-launcher-builder.d.ts +0 -9
- package/dist/process-launcher-builder.d.ts.map +0 -1
- package/dist/process-launcher-builder.js +0 -43
- package/dist/process-launcher-builder.js.map +0 -1
- package/dist/process-watcher-builder.d.ts +0 -10
- package/dist/process-watcher-builder.d.ts.map +0 -1
- package/dist/process-watcher-builder.js +0 -40
- package/dist/process-watcher-builder.js.map +0 -1
- package/dist/registry-utils.d.ts +0 -8
- package/dist/registry-utils.d.ts.map +0 -1
- package/dist/registry-utils.js +0 -18
- package/dist/registry-utils.js.map +0 -1
- package/dist/repository-git-env.d.ts +0 -8
- package/dist/repository-git-env.d.ts.map +0 -1
- package/dist/repository-git-env.js +0 -26
- package/dist/repository-git-env.js.map +0 -1
- package/dist/review-flow.d.ts.map +0 -1
- package/dist/runtime-internals.d.ts.map +0 -1
- package/dist/server-events.d.ts +0 -84
- package/dist/server-events.d.ts.map +0 -1
- package/dist/server-events.js +0 -2
- package/dist/server-events.js.map +0 -1
- package/dist/server-process-builder.d.ts +0 -11
- package/dist/server-process-builder.d.ts.map +0 -1
- package/dist/server-process-builder.js +0 -52
- package/dist/server-process-builder.js.map +0 -1
- package/dist/state-helpers.d.ts +0 -9
- package/dist/state-helpers.d.ts.map +0 -1
- package/dist/state-helpers.js +0 -20
- package/dist/state-helpers.js.map +0 -1
- package/dist/subprocess-env.d.ts +0 -12
- package/dist/subprocess-env.d.ts.map +0 -1
- package/dist/subprocess-env.js +0 -34
- package/dist/subprocess-env.js.map +0 -1
- package/dist/tool-renderers.d.ts +0 -10
- package/dist/tool-renderers.d.ts.map +0 -1
- package/dist/tool-renderers.js +0 -63
- package/dist/tool-renderers.js.map +0 -1
- package/dist/turn-semantics.d.ts +0 -22
- package/dist/turn-semantics.d.ts.map +0 -1
- package/dist/turn-semantics.js +0 -339
- package/dist/turn-semantics.js.map +0 -1
- package/dist/types.d.ts +0 -295
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -12
- package/dist/types.js.map +0 -1
- package/dist/ui-process-builder.d.ts +0 -9
- package/dist/ui-process-builder.d.ts.map +0 -1
- package/dist/ui-process-builder.js +0 -30
- package/dist/ui-process-builder.js.map +0 -1
- package/dist/worker-process-builder.d.ts +0 -10
- package/dist/worker-process-builder.d.ts.map +0 -1
- package/dist/worker-process-builder.js +0 -22
- package/dist/worker-process-builder.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface LeafOutcomeRendererMeta {
|
|
2
2
|
instanceId: string;
|
|
3
3
|
snapshotId: string;
|
|
4
4
|
leafEntryId: string;
|
|
@@ -9,7 +9,7 @@ export interface LeafOutcomeRendererMeta {
|
|
|
9
9
|
selectedTurnId?: string | null;
|
|
10
10
|
processUpdatedAt?: string | null;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
interface LeafOutcomeRendererRuntime {
|
|
13
13
|
apiVersion: 1;
|
|
14
14
|
markdown: {
|
|
15
15
|
render(markdown: string): string;
|
|
@@ -20,10 +20,10 @@ export interface LeafOutcomeRendererRuntime {
|
|
|
20
20
|
};
|
|
21
21
|
formatRelativeTime(iso: string): string;
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
declare function escapeLeafOutcomeHtml(value: string): string;
|
|
24
|
+
declare function normalizeLeafOutcomeOptionalText(value: unknown): string | null;
|
|
25
25
|
declare const LeafOutcomeElementBase: typeof HTMLElement;
|
|
26
|
-
|
|
26
|
+
declare abstract class LeafOutcomeCustomElement<TPayload> extends LeafOutcomeElementBase {
|
|
27
27
|
protected readonly shadowRootRef: ShadowRoot;
|
|
28
28
|
private payloadValue;
|
|
29
29
|
private runtimeValue;
|
|
@@ -44,5 +44,5 @@ export declare abstract class LeafOutcomeCustomElement<TPayload> extends LeafOut
|
|
|
44
44
|
protected emitError(code: string, message: string): void;
|
|
45
45
|
protected abstract renderContent(): void;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
|
|
48
|
+
export { LeafOutcomeCustomElement, type LeafOutcomeRendererMeta, type LeafOutcomeRendererRuntime, escapeLeafOutcomeHtml, normalizeLeafOutcomeOptionalText };
|
|
@@ -1,69 +1,79 @@
|
|
|
1
|
+
// src/leaf-outcome-renderer.ts
|
|
1
2
|
import escapeHtml from "escape-html";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
function escapeLeafOutcomeHtml(value) {
|
|
4
|
+
return escapeHtml(value);
|
|
4
5
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function normalizeLeafOutcomeOptionalText(value) {
|
|
7
|
+
if (typeof value !== "string") {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
return trimmed === "" ? null : trimmed;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
13
|
+
var LeafOutcomeElementBase = globalThis.HTMLElement ?? class {
|
|
14
|
+
};
|
|
15
|
+
var LeafOutcomeCustomElement = class extends LeafOutcomeElementBase {
|
|
16
|
+
shadowRootRef;
|
|
17
|
+
payloadValue = null;
|
|
18
|
+
runtimeValue = null;
|
|
19
|
+
metaValue = null;
|
|
20
|
+
signaledReady = false;
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.shadowRootRef = this.attachShadow({ mode: "open" });
|
|
24
|
+
}
|
|
25
|
+
set payload(value) {
|
|
26
|
+
this.payloadValue = value;
|
|
27
|
+
this.renderContent();
|
|
28
|
+
}
|
|
29
|
+
get payload() {
|
|
30
|
+
return this.payloadValue;
|
|
31
|
+
}
|
|
32
|
+
set runtime(value) {
|
|
33
|
+
this.runtimeValue = value;
|
|
34
|
+
this.renderContent();
|
|
35
|
+
}
|
|
36
|
+
get runtime() {
|
|
37
|
+
return this.runtimeValue;
|
|
38
|
+
}
|
|
39
|
+
set meta(value) {
|
|
40
|
+
this.metaValue = value;
|
|
41
|
+
this.renderContent();
|
|
42
|
+
}
|
|
43
|
+
get meta() {
|
|
44
|
+
return this.metaValue;
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
this.renderContent();
|
|
48
|
+
}
|
|
49
|
+
canRender() {
|
|
50
|
+
return this.isConnected && this.runtimeValue !== null;
|
|
51
|
+
}
|
|
52
|
+
emitReady() {
|
|
53
|
+
if (this.signaledReady) {
|
|
54
|
+
return;
|
|
41
55
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
detail: { code, message },
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
56
|
+
this.signaledReady = true;
|
|
57
|
+
this.dispatchEvent(
|
|
58
|
+
new CustomEvent("o2-leaf-outcome-ready", {
|
|
59
|
+
bubbles: true,
|
|
60
|
+
composed: true
|
|
61
|
+
})
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
emitError(code, message) {
|
|
65
|
+
this.dispatchEvent(
|
|
66
|
+
new CustomEvent("o2-leaf-outcome-error", {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
detail: { code, message }
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export {
|
|
75
|
+
LeafOutcomeCustomElement,
|
|
76
|
+
escapeLeafOutcomeHtml,
|
|
77
|
+
normalizeLeafOutcomeOptionalText
|
|
78
|
+
};
|
|
69
79
|
//# sourceMappingURL=leaf-outcome-renderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/leaf-outcome-renderer.ts"],"sourcesContent":["import escapeHtml from \"escape-html\";\n\nexport interface LeafOutcomeRendererMeta {\n\tinstanceId: string;\n\tsnapshotId: string;\n\tleafEntryId: string;\n\tturnRecordId: string | null;\n\tcreatedAt: string;\n\tschemaVersion: number | null;\n\tlifecycleStatus?: string | null;\n\tselectedTurnId?: string | null;\n\tprocessUpdatedAt?: string | null;\n}\n\nexport interface LeafOutcomeRendererRuntime {\n\tapiVersion: 1;\n\tmarkdown: {\n\t\trender(markdown: string): string;\n\t};\n\tserver: {\n\t\tresolveUrl(path: string): string;\n\t\tfetch(path: string, init?: RequestInit): Promise<Response>;\n\t};\n\tformatRelativeTime(iso: string): string;\n}\n\nexport function escapeLeafOutcomeHtml(value: string): string {\n\treturn escapeHtml(value);\n}\n\nexport function normalizeLeafOutcomeOptionalText(value: unknown): string | null {\n\tif (typeof value !== \"string\") {\n\t\treturn null;\n\t}\n\tconst trimmed = value.trim();\n\treturn trimmed === \"\" ? null : trimmed;\n}\n\nconst LeafOutcomeElementBase = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement;\n\nexport abstract class LeafOutcomeCustomElement<TPayload> extends LeafOutcomeElementBase {\n\tprotected readonly shadowRootRef: ShadowRoot;\n\tprivate payloadValue: TPayload | null = null;\n\tprivate runtimeValue: LeafOutcomeRendererRuntime | null = null;\n\tprivate metaValue: LeafOutcomeRendererMeta | null = null;\n\tprivate signaledReady = false;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.shadowRootRef = this.attachShadow({ mode: \"open\" });\n\t}\n\n\tset payload(value: TPayload | null) {\n\t\tthis.payloadValue = value;\n\t\tthis.renderContent();\n\t}\n\n\tget payload(): TPayload | null {\n\t\treturn this.payloadValue;\n\t}\n\n\tset runtime(value: LeafOutcomeRendererRuntime | null) {\n\t\tthis.runtimeValue = value;\n\t\tthis.renderContent();\n\t}\n\n\tget runtime(): LeafOutcomeRendererRuntime | null {\n\t\treturn this.runtimeValue;\n\t}\n\n\tset meta(value: LeafOutcomeRendererMeta | null) {\n\t\tthis.metaValue = value;\n\t\tthis.renderContent();\n\t}\n\n\tget meta(): LeafOutcomeRendererMeta | null {\n\t\treturn this.metaValue;\n\t}\n\n\tconnectedCallback(): void {\n\t\tthis.renderContent();\n\t}\n\n\tprotected canRender(): this is this & { runtime: LeafOutcomeRendererRuntime } {\n\t\treturn this.isConnected && this.runtimeValue !== null;\n\t}\n\n\tprotected emitReady(): void {\n\t\tif (this.signaledReady) {\n\t\t\treturn;\n\t\t}\n\t\tthis.signaledReady = true;\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent(\"o2-leaf-outcome-ready\", {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected emitError(code: string, message: string): void {\n\t\tthis.dispatchEvent(\n\t\t\tnew CustomEvent(\"o2-leaf-outcome-error\", {\n\t\t\t\tbubbles: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tdetail: { code, message },\n\t\t\t}),\n\t\t);\n\t}\n\n\tprotected abstract renderContent(): void;\n}\n"],"mappings":";AAAA,OAAO,gBAAgB;AA0BhB,SAAS,sBAAsB,OAAuB;AAC5D,SAAO,WAAW,KAAK;AACxB;AAEO,SAAS,iCAAiC,OAA+B;AAC/E,MAAI,OAAO,UAAU,UAAU;AAC9B,WAAO;AAAA,EACR;AACA,QAAM,UAAU,MAAM,KAAK;AAC3B,SAAO,YAAY,KAAK,OAAO;AAChC;AAEA,IAAM,yBAA0B,WAAW,eAAe,MAAM;AAAC;AAE1D,IAAe,2BAAf,cAA0D,uBAAuB;AAAA,EACpE;AAAA,EACX,eAAgC;AAAA,EAChC,eAAkD;AAAA,EAClD,YAA4C;AAAA,EAC5C,gBAAgB;AAAA,EAExB,cAAc;AACb,UAAM;AACN,SAAK,gBAAgB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAAA,EACxD;AAAA,EAEA,IAAI,QAAQ,OAAwB;AACnC,SAAK,eAAe;AACpB,SAAK,cAAc;AAAA,EACpB;AAAA,EAEA,IAAI,UAA2B;AAC9B,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,IAAI,QAAQ,OAA0C;AACrD,SAAK,eAAe;AACpB,SAAK,cAAc;AAAA,EACpB;AAAA,EAEA,IAAI,UAA6C;AAChD,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,IAAI,KAAK,OAAuC;AAC/C,SAAK,YAAY;AACjB,SAAK,cAAc;AAAA,EACpB;AAAA,EAEA,IAAI,OAAuC;AAC1C,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,oBAA0B;AACzB,SAAK,cAAc;AAAA,EACpB;AAAA,EAEU,YAAoE;AAC7E,WAAO,KAAK,eAAe,KAAK,iBAAiB;AAAA,EAClD;AAAA,EAEU,YAAkB;AAC3B,QAAI,KAAK,eAAe;AACvB;AAAA,IACD;AACA,SAAK,gBAAgB;AACrB,SAAK;AAAA,MACJ,IAAI,YAAY,yBAAyB;AAAA,QACxC,SAAS;AAAA,QACT,UAAU;AAAA,MACX,CAAC;AAAA,IACF;AAAA,EACD;AAAA,EAEU,UAAU,MAAc,SAAuB;AACxD,SAAK;AAAA,MACJ,IAAI,YAAY,yBAAyB;AAAA,QACxC,SAAS;AAAA,QACT,UAAU;AAAA,QACV,QAAQ,EAAE,MAAM,QAAQ;AAAA,MACzB,CAAC;AAAA,IACF;AAAA,EACD;AAGD;","names":[]}
|
package/dist/pi-config.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { ConfigSnapshot } from '@leitwerk-dev/protocol';
|
|
2
|
+
import { B as PiBuiltInToolName, l as LlmTurnDefinition, v as ProcessPiConfig, bH as ResolvedProcessPiConfig } from './extension-api-CnlL69Tu.js';
|
|
3
|
+
import '@leitwerk-dev/domain';
|
|
4
|
+
import '@leitwerk-dev/protocol/form-contract';
|
|
5
|
+
import '@leitwerk-dev/protocol/launcher-contract';
|
|
6
|
+
import '@leitwerk-dev/protocol/tool-renderer-contract';
|
|
7
|
+
|
|
4
8
|
type TemplateScalar = string | number | boolean;
|
|
5
9
|
type TemplateValue = TemplateScalar | TemplateContext | readonly TemplateValue[] | undefined;
|
|
6
|
-
|
|
10
|
+
interface TemplateContext {
|
|
7
11
|
[key: string]: TemplateValue;
|
|
8
12
|
}
|
|
9
|
-
|
|
13
|
+
declare function createTemplateContext(input: {
|
|
10
14
|
params?: unknown;
|
|
11
15
|
process?: {
|
|
12
16
|
processId?: string | null;
|
|
@@ -21,7 +25,7 @@ export declare function createTemplateContext(input: {
|
|
|
21
25
|
workBranch?: string | null;
|
|
22
26
|
}>;
|
|
23
27
|
}): TemplateContext;
|
|
24
|
-
|
|
28
|
+
declare function interpolateTemplate(template: string, context: TemplateContext): string;
|
|
25
29
|
type TurnToolDefinitionLike = {
|
|
26
30
|
kind: "llm";
|
|
27
31
|
availableTools: readonly PiBuiltInToolName[];
|
|
@@ -32,28 +36,28 @@ type ProcessTurnBindingLike = {
|
|
|
32
36
|
definition: TurnToolDefinitionLike;
|
|
33
37
|
};
|
|
34
38
|
type ProcessToolSource = TurnToolDefinitionLike | ProcessTurnBindingLike;
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
declare function validatePiBuiltInToolArray(toolNames: readonly unknown[], context: string): string[];
|
|
40
|
+
declare function resolveTurnAvailableToolNames(input: {
|
|
37
41
|
turnId: string;
|
|
38
42
|
turnDef: LlmTurnDefinition<string, unknown, unknown>;
|
|
39
43
|
}): string[];
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
declare function collectProcessAvailableToolNames(turns: Iterable<ProcessToolSource> | undefined): string[];
|
|
45
|
+
declare function resolveProcessPiConfig(input: {
|
|
42
46
|
processId: string;
|
|
43
47
|
processPiConfig?: ProcessPiConfig;
|
|
44
48
|
turns?: Iterable<ProcessToolSource>;
|
|
45
49
|
configSnapshot?: ConfigSnapshot;
|
|
46
50
|
templateContext: TemplateContext;
|
|
47
51
|
}): ResolvedProcessPiConfig;
|
|
48
|
-
|
|
52
|
+
declare function resolveTurnActiveToolNames(input: {
|
|
49
53
|
turnId: string;
|
|
50
54
|
turnDef: LlmTurnDefinition<string, unknown, unknown>;
|
|
51
55
|
}): string[];
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
declare function expandPiAgentDir(agentDir: string): string;
|
|
57
|
+
declare function resolvePiAgentDir(options: {
|
|
54
58
|
agentDir?: string | null;
|
|
55
59
|
configSnapshot?: ConfigSnapshot;
|
|
56
60
|
fallbackDir: string;
|
|
57
61
|
}): string;
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
|
|
63
|
+
export { type TemplateContext, collectProcessAvailableToolNames, createTemplateContext, expandPiAgentDir, interpolateTemplate, resolvePiAgentDir, resolveProcessPiConfig, resolveTurnActiveToolNames, resolveTurnAvailableToolNames, validatePiBuiltInToolArray };
|
package/dist/pi-config.js
CHANGED
|
@@ -1,182 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
if (input.process) {
|
|
24
|
-
context.processId = input.process.processId ?? undefined;
|
|
25
|
-
context.externalId = input.process.externalId ?? undefined;
|
|
26
|
-
context.externalUrl = input.process.externalUrl ?? undefined;
|
|
27
|
-
context.selectedTurnId = input.process.selectedTurnId ?? undefined;
|
|
28
|
-
}
|
|
29
|
-
const firstProject = input.projects?.[0];
|
|
30
|
-
if (firstProject) {
|
|
31
|
-
context.projectKey = firstProject.key;
|
|
32
|
-
context.repositoryUrl = firstProject.repoLocator;
|
|
33
|
-
context.baseBranch = firstProject.baseBranch;
|
|
34
|
-
context.workBranch = firstProject.workBranch ?? undefined;
|
|
35
|
-
}
|
|
36
|
-
return context;
|
|
37
|
-
}
|
|
38
|
-
export function interpolateTemplate(template, context) {
|
|
39
|
-
return Mustache.render(template, context);
|
|
40
|
-
}
|
|
41
|
-
function isTurnDefinitionSource(source) {
|
|
42
|
-
return "kind" in source;
|
|
43
|
-
}
|
|
44
|
-
function resolveToolSourceDefinition(source) {
|
|
45
|
-
return isTurnDefinitionSource(source) ? source : source.definition;
|
|
46
|
-
}
|
|
47
|
-
export function validatePiBuiltInToolArray(toolNames, context) {
|
|
48
|
-
const errors = [];
|
|
49
|
-
const seen = new Set();
|
|
50
|
-
for (const rawName of toolNames) {
|
|
51
|
-
if (typeof rawName !== "string") {
|
|
52
|
-
errors.push(`${context} must contain only string tool names`);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const name = rawName.trim();
|
|
56
|
-
if (name === "") {
|
|
57
|
-
errors.push(`${context} must not contain empty tool names`);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
if (name !== rawName) {
|
|
61
|
-
errors.push(`${context} must use canonical Pi tool names without surrounding whitespace`);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (!PI_BUILT_IN_TOOL_NAMES.includes(name)) {
|
|
65
|
-
errors.push(`${context} references unknown Pi tool '${name}'. Expected one of ${PI_BUILT_IN_TOOL_NAMES.join(", ")}`);
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
if (seen.has(name)) {
|
|
69
|
-
errors.push(`${context} must not contain duplicate Pi tool '${name}'`);
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
seen.add(name);
|
|
73
|
-
}
|
|
74
|
-
return errors;
|
|
75
|
-
}
|
|
76
|
-
export function resolveTurnAvailableToolNames(input) {
|
|
77
|
-
const errors = validatePiBuiltInToolArray(input.turnDef.availableTools, `turn '${input.turnId}' availableTools`);
|
|
78
|
-
if (errors.length > 0) {
|
|
79
|
-
throw new Error(errors.join("; "));
|
|
80
|
-
}
|
|
81
|
-
return [...input.turnDef.availableTools];
|
|
82
|
-
}
|
|
83
|
-
export function collectProcessAvailableToolNames(turns) {
|
|
84
|
-
const usedToolNames = new Set();
|
|
85
|
-
for (const source of turns ?? []) {
|
|
86
|
-
const definition = resolveToolSourceDefinition(source);
|
|
87
|
-
if (definition.kind !== "llm" || !("availableTools" in definition)) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
const errors = validatePiBuiltInToolArray(definition.availableTools, "LLM turn availableTools");
|
|
91
|
-
if (errors.length > 0) {
|
|
92
|
-
throw new Error(errors.join("; "));
|
|
93
|
-
}
|
|
94
|
-
for (const toolName of definition.availableTools) {
|
|
95
|
-
usedToolNames.add(toolName);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return PI_BUILT_IN_TOOL_NAMES.filter((toolName) => usedToolNames.has(toolName));
|
|
99
|
-
}
|
|
100
|
-
const DEFAULT_TOOL_DESCRIPTIONS = {
|
|
101
|
-
read: "Read file contents",
|
|
102
|
-
bash: "Execute bash commands (ls, grep, find, etc.)",
|
|
103
|
-
edit: "Make surgical edits to files (find exact text and replace)",
|
|
104
|
-
write: "Create or overwrite files",
|
|
105
|
-
grep: "Search file contents",
|
|
106
|
-
find: "Find files by name/path",
|
|
107
|
-
ls: "List directory contents",
|
|
1
|
+
import {
|
|
2
|
+
collectProcessAvailableToolNames,
|
|
3
|
+
createTemplateContext,
|
|
4
|
+
expandPiAgentDir,
|
|
5
|
+
interpolateTemplate,
|
|
6
|
+
resolvePiAgentDir,
|
|
7
|
+
resolveProcessPiConfig,
|
|
8
|
+
resolveTurnActiveToolNames,
|
|
9
|
+
resolveTurnAvailableToolNames,
|
|
10
|
+
validatePiBuiltInToolArray
|
|
11
|
+
} from "./chunk-ITPH65G6.js";
|
|
12
|
+
export {
|
|
13
|
+
collectProcessAvailableToolNames,
|
|
14
|
+
createTemplateContext,
|
|
15
|
+
expandPiAgentDir,
|
|
16
|
+
interpolateTemplate,
|
|
17
|
+
resolvePiAgentDir,
|
|
18
|
+
resolveProcessPiConfig,
|
|
19
|
+
resolveTurnActiveToolNames,
|
|
20
|
+
resolveTurnAvailableToolNames,
|
|
21
|
+
validatePiBuiltInToolArray
|
|
108
22
|
};
|
|
109
|
-
function buildDefaultSystemPrompt(availableToolNames) {
|
|
110
|
-
const toolList = availableToolNames.length > 0
|
|
111
|
-
? availableToolNames
|
|
112
|
-
.map((toolName) => {
|
|
113
|
-
const description = DEFAULT_TOOL_DESCRIPTIONS[toolName] ?? "Built-in Pi tool";
|
|
114
|
-
return `- ${toolName}: ${description}`;
|
|
115
|
-
})
|
|
116
|
-
.join("\n")
|
|
117
|
-
: "- No built-in tools are available for this process unless a turn registers custom tools.";
|
|
118
|
-
return `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.
|
|
119
|
-
|
|
120
|
-
Available built-in tools for this process:
|
|
121
|
-
${toolList}
|
|
122
|
-
|
|
123
|
-
In addition to the tools above, you may have access to other custom tools depending on the active turn.
|
|
124
|
-
|
|
125
|
-
Guidelines:
|
|
126
|
-
- Use only tools that are available in the active turn.
|
|
127
|
-
- Use read/search tools to examine files before editing.
|
|
128
|
-
- Use edit for precise changes when it is available (old text must match exactly).
|
|
129
|
-
- Use write only for new files or complete rewrites when it is available.
|
|
130
|
-
- When summarizing your actions, output plain text directly - do NOT use cat or bash to display what you did.
|
|
131
|
-
- Be concise in your responses.
|
|
132
|
-
- Show file paths clearly when working with files.`;
|
|
133
|
-
}
|
|
134
|
-
export function resolveProcessPiConfig(input) {
|
|
135
|
-
const processConfig = input.configSnapshot?.process_configs?.[input.processId];
|
|
136
|
-
const processPiOverride = processConfig?.pi;
|
|
137
|
-
const availableToolNames = collectProcessAvailableToolNames(input.turns);
|
|
138
|
-
const configSystemPromptTemplate = input.configSnapshot?.pi?.system_prompt_template;
|
|
139
|
-
const systemPromptTemplate = processPiOverride?.system_prompt_template ??
|
|
140
|
-
input.processPiConfig?.systemPromptTemplate ??
|
|
141
|
-
configSystemPromptTemplate;
|
|
142
|
-
const appendSystemPromptTemplate = processPiOverride?.append_system_prompt_template ??
|
|
143
|
-
input.processPiConfig?.appendSystemPromptTemplate;
|
|
144
|
-
const resolvedSystemPrompt = systemPromptTemplate
|
|
145
|
-
? interpolateTemplate(systemPromptTemplate, input.templateContext)
|
|
146
|
-
: buildDefaultSystemPrompt(availableToolNames);
|
|
147
|
-
const sessionCwd = input.processPiConfig?.sessionCwdTemplate
|
|
148
|
-
? interpolateTemplate(input.processPiConfig.sessionCwdTemplate, input.templateContext).trim()
|
|
149
|
-
: undefined;
|
|
150
|
-
return {
|
|
151
|
-
systemPrompt: resolvedSystemPrompt,
|
|
152
|
-
appendSystemPrompt: appendSystemPromptTemplate
|
|
153
|
-
? interpolateTemplate(appendSystemPromptTemplate, input.templateContext)
|
|
154
|
-
: undefined,
|
|
155
|
-
...(sessionCwd ? { sessionCwd } : {}),
|
|
156
|
-
availableToolNames,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
export function resolveTurnActiveToolNames(input) {
|
|
160
|
-
return resolveTurnAvailableToolNames(input);
|
|
161
|
-
}
|
|
162
|
-
// Mirror Pi's PI_CODING_AGENT_DIR expansion semantics from
|
|
163
|
-
// pi-mono/packages/coding-agent/src/config.ts.
|
|
164
|
-
export function expandPiAgentDir(agentDir) {
|
|
165
|
-
if (agentDir === "~") {
|
|
166
|
-
return homedir();
|
|
167
|
-
}
|
|
168
|
-
if (agentDir.startsWith("~/")) {
|
|
169
|
-
return homedir() + agentDir.slice(1);
|
|
170
|
-
}
|
|
171
|
-
return agentDir;
|
|
172
|
-
}
|
|
173
|
-
export function resolvePiAgentDir(options) {
|
|
174
|
-
const configuredAgentDir = typeof options.agentDir === "string" && options.agentDir.trim() !== ""
|
|
175
|
-
? options.agentDir
|
|
176
|
-
: typeof options.configSnapshot?.pi?.agent_dir === "string" &&
|
|
177
|
-
options.configSnapshot.pi.agent_dir.trim() !== ""
|
|
178
|
-
? options.configSnapshot.pi.agent_dir
|
|
179
|
-
: options.fallbackDir;
|
|
180
|
-
return expandPiAgentDir(configuredAgentDir);
|
|
181
|
-
}
|
|
182
23
|
//# sourceMappingURL=pi-config.js.map
|
package/dist/pi-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/review-flow.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Q as ProcessTurnOutcomeEvent, cA as PlanSavedEvent, bI as ReviewCompletedEvent, bJ as ReviewRequestedEvent } from './extension-api-CnlL69Tu.js';
|
|
2
|
+
import '@leitwerk-dev/domain';
|
|
3
|
+
import '@leitwerk-dev/protocol';
|
|
4
|
+
import '@leitwerk-dev/protocol/form-contract';
|
|
5
|
+
import '@leitwerk-dev/protocol/launcher-contract';
|
|
6
|
+
import '@leitwerk-dev/protocol/tool-renderer-contract';
|
|
7
|
+
|
|
8
|
+
declare function filterStringArray(value: unknown): string[];
|
|
9
|
+
declare function buildPlanSavedEventPayload(input: {
|
|
5
10
|
planRevision: number;
|
|
6
11
|
event: Pick<ProcessTurnOutcomeEvent, "params" | "turnResultMarkdown">;
|
|
7
12
|
}): Omit<PlanSavedEvent, "instanceId">;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
declare function buildReviewRequestedEventPayload(event: Pick<ProcessTurnOutcomeEvent, "params">): Omit<ReviewRequestedEvent, "instanceId">;
|
|
14
|
+
declare function buildReviewCompletedEventPayload(event: Pick<ProcessTurnOutcomeEvent, "outcome" | "params" | "turnResultMarkdown">): Omit<ReviewCompletedEvent, "instanceId">;
|
|
15
|
+
|
|
16
|
+
export { buildPlanSavedEventPayload, buildReviewCompletedEventPayload, buildReviewRequestedEventPayload, filterStringArray };
|
package/dist/review-flow.js
CHANGED
|
@@ -1,44 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const value = event.params[paramKey];
|
|
14
|
-
return typeof value === "string" ? value : undefined;
|
|
15
|
-
}
|
|
16
|
-
export function buildPlanSavedEventPayload(input) {
|
|
17
|
-
return {
|
|
18
|
-
planRevision: input.planRevision,
|
|
19
|
-
summary: normalizeMessage(input.event.params.summary),
|
|
20
|
-
planMarkdown: resolveOutcomeMarkdown(input.event, "planMarkdown") ?? "",
|
|
21
|
-
acceptanceCriteria: filterStringArray(input.event.params.acceptanceCriteria),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function buildReviewRequestedEventPayload(event) {
|
|
25
|
-
return {
|
|
26
|
-
changedProjects: filterStringArray(event.params.changedProjects),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export function buildReviewCompletedEventPayload(event) {
|
|
30
|
-
if (event.outcome === "issues_found") {
|
|
31
|
-
return {
|
|
32
|
-
hasIssues: true,
|
|
33
|
-
issueCount: typeof event.params.issueCount === "number" ? event.params.issueCount : 1,
|
|
34
|
-
...(resolveOutcomeMarkdown(event, "reviewMarkdown")
|
|
35
|
-
? { reviewMarkdown: resolveOutcomeMarkdown(event, "reviewMarkdown") }
|
|
36
|
-
: {}),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
hasIssues: false,
|
|
41
|
-
issueCount: 0,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
buildPlanSavedEventPayload,
|
|
3
|
+
buildReviewCompletedEventPayload,
|
|
4
|
+
buildReviewRequestedEventPayload,
|
|
5
|
+
filterStringArray
|
|
6
|
+
} from "./chunk-LIIP7FMU.js";
|
|
7
|
+
export {
|
|
8
|
+
buildPlanSavedEventPayload,
|
|
9
|
+
buildReviewCompletedEventPayload,
|
|
10
|
+
buildReviewRequestedEventPayload,
|
|
11
|
+
filterStringArray
|
|
12
|
+
};
|
|
44
13
|
//# sourceMappingURL=review-flow.js.map
|
package/dist/review-flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ProcessTurnTransition } from '@leitwerk-dev/domain';
|
|
2
|
+
import { bk as ProcessTurnBinding } from './extension-api-CnlL69Tu.js';
|
|
3
|
+
import '@leitwerk-dev/protocol';
|
|
4
|
+
import '@leitwerk-dev/protocol/form-contract';
|
|
5
|
+
import '@leitwerk-dev/protocol/launcher-contract';
|
|
6
|
+
import '@leitwerk-dev/protocol/tool-renderer-contract';
|
|
7
|
+
|
|
8
|
+
declare function markDefinedProcess(value: object): void;
|
|
9
|
+
declare function isDefinedProcess(value: unknown): boolean;
|
|
10
|
+
declare function setProcessTurnTransitions(binding: object, transitions: readonly ProcessTurnTransition[]): void;
|
|
11
|
+
declare function getProcessTurnTransitions(binding: ProcessTurnBinding<unknown> | undefined): readonly ProcessTurnTransition[];
|
|
12
|
+
|
|
13
|
+
interface UniqueRegistrationOptions<TValue> {
|
|
14
|
+
duplicateMessage: string;
|
|
15
|
+
validate?: (value: TValue) => void;
|
|
16
|
+
}
|
|
17
|
+
declare function registerUnique<TKey, TValue>(registry: Map<TKey, TValue>, key: TKey, value: TValue, options: UniqueRegistrationOptions<TValue>): void;
|
|
18
|
+
declare function cloneMap<TKey, TValue>(registry: ReadonlyMap<TKey, TValue>): Map<TKey, TValue>;
|
|
19
|
+
declare function cloneArrayValueMap<TKey, TValue>(registry: ReadonlyMap<TKey, readonly TValue[]>): Map<TKey, readonly TValue[]>;
|
|
20
|
+
|
|
21
|
+
export { cloneArrayValueMap, cloneMap, getProcessTurnTransitions, isDefinedProcess, markDefinedProcess, registerUnique, setProcessTurnTransitions };
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
cloneArrayValueMap,
|
|
3
|
+
cloneMap,
|
|
4
|
+
getProcessTurnTransitions,
|
|
5
|
+
isDefinedProcess,
|
|
6
|
+
markDefinedProcess,
|
|
7
|
+
registerUnique,
|
|
8
|
+
setProcessTurnTransitions
|
|
9
|
+
} from "./chunk-5RJZ2E7D.js";
|
|
10
|
+
export {
|
|
11
|
+
cloneArrayValueMap,
|
|
12
|
+
cloneMap,
|
|
13
|
+
getProcessTurnTransitions,
|
|
14
|
+
isDefinedProcess,
|
|
15
|
+
markDefinedProcess,
|
|
16
|
+
registerUnique,
|
|
17
|
+
setProcessTurnTransitions
|
|
18
|
+
};
|
|
3
19
|
//# sourceMappingURL=runtime-internals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|