@leitwerk-dev/domain 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dependency-order.d.ts +3 -0
- package/dist/dependency-order.d.ts.map +1 -0
- package/dist/domain-model.d.ts +34 -4
- package/dist/domain-model.d.ts.map +1 -1
- package/dist/execution-inspection.d.ts +145 -0
- package/dist/execution-inspection.d.ts.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -1
- package/dist/json-pointer.d.ts +3 -0
- package/dist/json-pointer.d.ts.map +1 -0
- package/dist/process-definitions.d.ts +28 -3
- package/dist/process-definitions.d.ts.map +1 -1
- package/dist/process-path.d.ts +4 -0
- package/dist/process-path.d.ts.map +1 -0
- package/dist/scoped-settings.d.ts +87 -0
- package/dist/scoped-settings.d.ts.map +1 -0
- package/dist/turn-recovery.d.ts +1 -1
- package/dist/turn-recovery.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dependency-order.ts +19 -0
- package/src/domain-model.ts +38 -3
- package/src/execution-inspection.ts +182 -0
- package/src/index.ts +15 -0
- package/src/json-pointer.ts +10 -0
- package/src/process-definitions.ts +29 -3
- package/src/process-path.ts +25 -0
- package/src/scoped-settings.ts +92 -0
- package/src/turn-recovery.ts +1 -0
|
@@ -23,7 +23,7 @@ export interface SerializedProcessGraph {
|
|
|
23
23
|
/** @internal */
|
|
24
24
|
turnTransitions: Record<TurnId, ProcessTurnTransition[]>;
|
|
25
25
|
}
|
|
26
|
-
/** Whether a flow node sits on the
|
|
26
|
+
/** Whether a flow node sits on the shortest successful path or a side branch. @internal */
|
|
27
27
|
export type ProcessFlowNodeRole = "spine" | "branch";
|
|
28
28
|
/**
|
|
29
29
|
* Classification of a flow edge relative to the spine:
|
|
@@ -34,6 +34,15 @@ export type ProcessFlowNodeRole = "spine" | "branch";
|
|
|
34
34
|
*/
|
|
35
35
|
/** @internal */
|
|
36
36
|
export type ProcessFlowEdgeKind = "forward" | "loopback" | "branch" | "terminal";
|
|
37
|
+
/** A statically declared LLM tool, without executable code or runtime credentials. @internal */
|
|
38
|
+
export interface ProcessFlowTool {
|
|
39
|
+
/** @internal */
|
|
40
|
+
name: string;
|
|
41
|
+
/** @internal */
|
|
42
|
+
category: "workspace" | "integration" | "question" | "outcome";
|
|
43
|
+
/** Declared description when available; integration registrations are resolved separately. @internal */
|
|
44
|
+
description: string | null;
|
|
45
|
+
}
|
|
37
46
|
/** @internal */
|
|
38
47
|
export interface ProcessFlowNode {
|
|
39
48
|
/** @internal */
|
|
@@ -50,6 +59,16 @@ export interface ProcessFlowNode {
|
|
|
50
59
|
anchorTurnId: TurnId | null;
|
|
51
60
|
/** True when this turn is a launch entry point. @internal */
|
|
52
61
|
isEntry: boolean;
|
|
62
|
+
/** One logical turn applied to frozen items, followed by internal collection. @internal */
|
|
63
|
+
repetition?: "sequential";
|
|
64
|
+
/** Static declarations only; absent on non-LLM turns and older projections. @internal */
|
|
65
|
+
tools?: ProcessFlowTool[];
|
|
66
|
+
/** Additional integration tool names are resolved from process data at turn start. @internal */
|
|
67
|
+
hasDynamicTools?: boolean;
|
|
68
|
+
/** Named product declarations, not execution-time values. @internal */
|
|
69
|
+
inputProducts?: string[];
|
|
70
|
+
/** Named products this turn can publish. @internal */
|
|
71
|
+
outputProducts?: string[];
|
|
53
72
|
}
|
|
54
73
|
/** @internal */
|
|
55
74
|
export interface ProcessFlowEdge {
|
|
@@ -63,6 +82,11 @@ export interface ProcessFlowEdge {
|
|
|
63
82
|
kind: ProcessFlowEdgeKind;
|
|
64
83
|
/** Optional human-facing edge label derived from outcome/trigger metadata. @internal */
|
|
65
84
|
label: string | null;
|
|
85
|
+
/** Declared branch condition; inspecting the graph never evaluates its chooser. @internal */
|
|
86
|
+
condition?: {
|
|
87
|
+
/** @internal */ label: string;
|
|
88
|
+
/** @internal */ description?: string;
|
|
89
|
+
};
|
|
66
90
|
}
|
|
67
91
|
/** @internal */
|
|
68
92
|
export interface ProcessFlowEndState {
|
|
@@ -76,8 +100,9 @@ export interface ProcessFlowEndState {
|
|
|
76
100
|
synthetic: boolean;
|
|
77
101
|
}
|
|
78
102
|
/**
|
|
79
|
-
*
|
|
80
|
-
* The `spine` is the
|
|
103
|
+
* Complete definition projection for operator-facing flow diagrams.
|
|
104
|
+
* The `spine` is the shortest path from the primary entry to completion.
|
|
105
|
+
* Operator decisions remain explicit; collection stays inside a mapped turn.
|
|
81
106
|
*/
|
|
82
107
|
/** @internal */
|
|
83
108
|
export interface ProcessFlowView {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-definitions.d.ts","sourceRoot":"","sources":["../src/process-definitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEzF,cAAc;AACd,MAAM,MAAM,kCAAkC,GAAG,OAAO,CACvD,sBAAsB,EACtB,WAAW,GAAG,SAAS,CACvB,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACrC,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,eAAe,CAAC,EAAE,kCAAkC,CAAC;IACrD,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACtC,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB;IAChB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;CACzD;AAED,
|
|
1
|
+
{"version":3,"file":"process-definitions.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;AACH,gBAAgB;AAChB,MAAM,WAAW,eAAe;IAC/B,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB;IAChB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,gBAAgB;IAChB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,eAAe,EAAE,CAAC;IACzB,gBAAgB;IAChB,SAAS,EAAE,mBAAmB,EAAE,CAAC;CACjC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { TurnId } from "./domain-model.js";
|
|
2
|
+
/** Breadth-first path in declaration order; null marks success. Returns [entry] without success. @internal */
|
|
3
|
+
export declare function shortestSuccessfulTurnPath(entry: TurnId, outgoing: (id: TurnId) => Iterable<TurnId | null>): TurnId[];
|
|
4
|
+
//# sourceMappingURL=process-path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-path.d.ts","sourceRoot":"","sources":["../src/process-path.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,8GAA8G;AAC9G,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,GAC/C,MAAM,EAAE,CAkBV"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { Actor } from "./domain-model.js";
|
|
2
|
+
/** One stable subject per named scope type. @public */
|
|
3
|
+
export type SettingsContext = Readonly<Record<string, string>>;
|
|
4
|
+
/** @public */
|
|
5
|
+
export interface SettingsSubject {
|
|
6
|
+
/** @public */
|
|
7
|
+
id: string;
|
|
8
|
+
/** @public */
|
|
9
|
+
scopeType: string;
|
|
10
|
+
/** @public */
|
|
11
|
+
identity: string;
|
|
12
|
+
/** @public */
|
|
13
|
+
label: string;
|
|
14
|
+
/** Lower scopes supplied by the owning integration, never matched by expression. @public */
|
|
15
|
+
context: SettingsContext;
|
|
16
|
+
/** @public */
|
|
17
|
+
schemaVersion: number;
|
|
18
|
+
/** @public */
|
|
19
|
+
revision: number;
|
|
20
|
+
/** @public */
|
|
21
|
+
createdAt: string;
|
|
22
|
+
/** @public */
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
/** Discovery is attributed to the server system actor. @public */
|
|
25
|
+
actor: Actor;
|
|
26
|
+
}
|
|
27
|
+
/** A reset retains its revision to prevent delete/recreate races. @internal */
|
|
28
|
+
export interface SettingsOverride {
|
|
29
|
+
/** @internal */
|
|
30
|
+
subjectId: string;
|
|
31
|
+
/** @internal */
|
|
32
|
+
key: string;
|
|
33
|
+
/** @internal */
|
|
34
|
+
value: unknown;
|
|
35
|
+
/** @internal */
|
|
36
|
+
mode: "append" | "replace";
|
|
37
|
+
/** @internal */
|
|
38
|
+
reset: boolean;
|
|
39
|
+
/** @internal */
|
|
40
|
+
schemaVersion: number;
|
|
41
|
+
/** @internal */
|
|
42
|
+
revision: number;
|
|
43
|
+
/** @internal */
|
|
44
|
+
createdAt: string;
|
|
45
|
+
/** @internal */
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
/** @internal */
|
|
48
|
+
actor: Actor;
|
|
49
|
+
}
|
|
50
|
+
/** @public */
|
|
51
|
+
export interface SettingsSource {
|
|
52
|
+
/** @public */
|
|
53
|
+
subjectId: string | null;
|
|
54
|
+
/** @public */
|
|
55
|
+
scopeType: string;
|
|
56
|
+
/** @public */
|
|
57
|
+
label: string;
|
|
58
|
+
/** @public */
|
|
59
|
+
revision: number;
|
|
60
|
+
/** @public */
|
|
61
|
+
schemaVersion: number;
|
|
62
|
+
/** @public */
|
|
63
|
+
mode: "append" | "replace";
|
|
64
|
+
}
|
|
65
|
+
/** @public */
|
|
66
|
+
export interface ResolvedSetting<T = unknown> {
|
|
67
|
+
/** @public */
|
|
68
|
+
key: string;
|
|
69
|
+
/** @public */
|
|
70
|
+
value: T;
|
|
71
|
+
/** @public */
|
|
72
|
+
sources: SettingsSource[];
|
|
73
|
+
}
|
|
74
|
+
/** Immutable, non-secret settings consumed by a prepared turn. @public */
|
|
75
|
+
export interface ScopedSettingsSnapshot {
|
|
76
|
+
/** @public */
|
|
77
|
+
version: 1;
|
|
78
|
+
/** @public */
|
|
79
|
+
purpose: string;
|
|
80
|
+
/** @public */
|
|
81
|
+
context: SettingsContext;
|
|
82
|
+
/** @public */
|
|
83
|
+
values: ResolvedSetting[];
|
|
84
|
+
/** @public */
|
|
85
|
+
explanations: string[];
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=scoped-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scoped-settings.d.ts","sourceRoot":"","sources":["../src/scoped-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C,uDAAuD;AACvD,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/D,cAAc;AACd,MAAM,WAAW,eAAe;IAC/B,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,OAAO,EAAE,eAAe,CAAC;IACzB,cAAc;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,KAAK,EAAE,KAAK,CAAC;CACb;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAChC,g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/dist/turn-recovery.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { trimToNull } from "./string-normalize.js";
|
|
|
2
2
|
/** @internal */
|
|
3
3
|
export declare const DEFAULT_CONTINUE_PROMPT = "continue";
|
|
4
4
|
/** @internal */
|
|
5
|
-
export declare const FAILED_TURN_RECOVERY_CODES: readonly ["generic_continue", "missing_outcome_tool", "missing_markdown_result", "missing_required_tool_calls"];
|
|
5
|
+
export declare const FAILED_TURN_RECOVERY_CODES: readonly ["generic_continue", "outcome_rejected", "missing_outcome_tool", "missing_markdown_result", "missing_required_tool_calls"];
|
|
6
6
|
/** @internal */
|
|
7
7
|
export type FailedTurnRecoveryCode = (typeof FAILED_TURN_RECOVERY_CODES)[number];
|
|
8
8
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turn-recovery.d.ts","sourceRoot":"","sources":["../src/turn-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGzE,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAElD,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"turn-recovery.d.ts","sourceRoot":"","sources":["../src/turn-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGzE,gBAAgB;AAChB,eAAO,MAAM,uBAAuB,aAAa,CAAC;AAElD,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,qIAM7B,CAAC;AAEX,gBAAgB;AAChB,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACzC,gBAAgB;IAChB,QAAQ,EAAE,UAAU,CAAC;IACrB,gBAAgB;IAChB,uBAAuB,EAAE,MAAM,CAAC;IAChC,gBAAgB;IAChB,WAAW,EA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,0 +1,19 @@
|
|
|
1
|
+
/** Dependency-first traversal; callers resolve missing and optional dependencies. @internal */
|
|
2
|
+
export function orderDependencies(
|
|
3
|
+
roots: Iterable<string>,
|
|
4
|
+
dependencies: (id: string) => Iterable<string>,
|
|
5
|
+
cycleMessage: (id: string) => string,
|
|
6
|
+
): string[] {
|
|
7
|
+
const visiting = new Set<string>();
|
|
8
|
+
const ordered = new Set<string>();
|
|
9
|
+
function visit(id: string): void {
|
|
10
|
+
if (ordered.has(id)) return;
|
|
11
|
+
if (visiting.has(id)) throw new Error(cycleMessage(id));
|
|
12
|
+
visiting.add(id);
|
|
13
|
+
for (const dependency of dependencies(id)) visit(dependency);
|
|
14
|
+
visiting.delete(id);
|
|
15
|
+
ordered.add(id);
|
|
16
|
+
}
|
|
17
|
+
for (const id of roots) visit(id);
|
|
18
|
+
return [...ordered];
|
|
19
|
+
}
|
package/src/domain-model.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RepoLocatorKind } from "./repo-locator.js";
|
|
2
|
+
import type { ScopedSettingsSnapshot } from "./scoped-settings.js";
|
|
2
3
|
import type { ProcessSemanticEntryRefKey } from "./semantic-entry-refs.js";
|
|
3
4
|
import { trimToNull } from "./string-normalize.js";
|
|
4
5
|
import type { FailedTurnRecoveryContext } from "./turn-recovery.js";
|
|
@@ -451,6 +452,7 @@ export type ProcessSelectedTurnModelSource =
|
|
|
451
452
|
| "instance_turn_config"
|
|
452
453
|
| "process_config_turn"
|
|
453
454
|
| "instance_default"
|
|
455
|
+
| "scoped_purpose_default"
|
|
454
456
|
| "process_config_default"
|
|
455
457
|
| "catalog_default"
|
|
456
458
|
| "legacy_persisted";
|
|
@@ -514,6 +516,10 @@ export type CurrentExecutionRef = {
|
|
|
514
516
|
/** Immutable non-secret inputs resolved for a worker-owned turn start. @internal */
|
|
515
517
|
export type ResolvedTurnStart =
|
|
516
518
|
| {
|
|
519
|
+
/** Resolved non-secret outcome schemas and publication metadata. @internal */
|
|
520
|
+
outcomeContract?: JsonObject;
|
|
521
|
+
/** @internal */
|
|
522
|
+
scopedSettings?: ScopedSettingsSnapshot;
|
|
517
523
|
/** @internal */
|
|
518
524
|
kind: "llm";
|
|
519
525
|
/** @internal */
|
|
@@ -575,7 +581,34 @@ export type TurnStartPreparationFailureCode =
|
|
|
575
581
|
| "provider_preflight_failed";
|
|
576
582
|
|
|
577
583
|
/** @internal */
|
|
578
|
-
export
|
|
584
|
+
export interface StartupRetryState {
|
|
585
|
+
/** First start in this recovery episode. @internal */
|
|
586
|
+
episodeStartRecordId: string;
|
|
587
|
+
/** Includes the initial start; these are not accepted turn attempts. @internal */
|
|
588
|
+
starts: number;
|
|
589
|
+
/** Retained deadline so polling and restarts cannot postpone recovery. @internal */
|
|
590
|
+
nextRetryAt: string | null;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** Safe recovery information shared by automation and the process inspector. @public */
|
|
594
|
+
export interface AutomaticStartupRecoverySummary {
|
|
595
|
+
/** @public */
|
|
596
|
+
status: "blocked" | "waiting" | "ready" | "waiting_for_model" | "exhausted" | "retried";
|
|
597
|
+
/** @public */
|
|
598
|
+
reason: string;
|
|
599
|
+
/** @public */
|
|
600
|
+
starts: number;
|
|
601
|
+
/** @public */
|
|
602
|
+
maxStarts: number;
|
|
603
|
+
/** @public */
|
|
604
|
+
nextRetryAt: string | null;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/** @internal */
|
|
608
|
+
export type TurnStartRecordState = {
|
|
609
|
+
/** @internal */
|
|
610
|
+
automaticRetry?: StartupRetryState;
|
|
611
|
+
} & (
|
|
579
612
|
| {
|
|
580
613
|
/** @internal */
|
|
581
614
|
kind: "preparation_failed";
|
|
@@ -625,7 +658,8 @@ export type TurnStartRecordState =
|
|
|
625
658
|
kind: "superseded";
|
|
626
659
|
/** @internal */
|
|
627
660
|
start: ResolvedTurnStart | null;
|
|
628
|
-
}
|
|
661
|
+
}
|
|
662
|
+
);
|
|
629
663
|
|
|
630
664
|
/** Durable preparation for a single worker-owned selected turn, not an attempt. @internal */
|
|
631
665
|
export interface TurnStartRecord {
|
|
@@ -782,6 +816,7 @@ export const PROCESS_SELECTED_TURN_MODEL_SOURCES = [
|
|
|
782
816
|
"process_config_turn",
|
|
783
817
|
"instance_default",
|
|
784
818
|
"process_config_default",
|
|
819
|
+
"scoped_purpose_default",
|
|
785
820
|
"catalog_default",
|
|
786
821
|
"legacy_persisted",
|
|
787
822
|
] as const satisfies readonly ProcessSelectedTurnModelSource[];
|
|
@@ -1097,7 +1132,7 @@ export interface TurnProgressReport {
|
|
|
1097
1132
|
title: string;
|
|
1098
1133
|
/** Attempt-specific progress or waiting explanation; not an operation receipt. @public */
|
|
1099
1134
|
summary?: string;
|
|
1100
|
-
/** @public */
|
|
1135
|
+
/** Optional checklist; may be empty when summary supplies the activity text. @public */
|
|
1101
1136
|
steps: TurnProgressStep[];
|
|
1102
1137
|
/** @public */
|
|
1103
1138
|
links?: TurnProgressLink[];
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { PreparedTurnStart } from "./domain-model.js";
|
|
2
|
+
|
|
3
|
+
/** Completeness of one historical fact, independent of request/loading state. @internal */
|
|
4
|
+
export type InspectionEvidence<T> =
|
|
5
|
+
| {
|
|
6
|
+
/** @internal */
|
|
7
|
+
state: "recorded" | "redacted";
|
|
8
|
+
/** @internal */
|
|
9
|
+
value: T;
|
|
10
|
+
}
|
|
11
|
+
| {
|
|
12
|
+
/** @internal */
|
|
13
|
+
state: "not_recorded" | "unavailable" | "not_applicable";
|
|
14
|
+
/** @internal */
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Immutable version supplied to a worker, not a declaration of possible consumption. @internal */
|
|
19
|
+
export interface InspectionProduct {
|
|
20
|
+
/** @internal */
|
|
21
|
+
name: string;
|
|
22
|
+
/** @internal */
|
|
23
|
+
producerTurnRecordId: string;
|
|
24
|
+
/** @internal */
|
|
25
|
+
entryId: string;
|
|
26
|
+
/** @internal */
|
|
27
|
+
content: InspectionEvidence<string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Model-facing content only. Renderer details and provider options are deliberately absent. @internal */
|
|
31
|
+
export interface InspectionMessage {
|
|
32
|
+
/** Exact session identity when the conversion is unambiguous. @internal */
|
|
33
|
+
entryId: string | null;
|
|
34
|
+
/** @internal */
|
|
35
|
+
role: string;
|
|
36
|
+
/** @internal */
|
|
37
|
+
toolCallId?: string;
|
|
38
|
+
/** @internal */
|
|
39
|
+
content: InspectionEvidence<unknown>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Captured at the Pi stream function after context conversion and tool assembly. @internal */
|
|
43
|
+
export interface InspectionModelInput {
|
|
44
|
+
/** @internal */
|
|
45
|
+
kind: "model_input";
|
|
46
|
+
/** @internal */
|
|
47
|
+
boundaryEntryId: string | null;
|
|
48
|
+
/** @internal */
|
|
49
|
+
model: {
|
|
50
|
+
/** @internal */
|
|
51
|
+
provider: string;
|
|
52
|
+
/** @internal */
|
|
53
|
+
id: string;
|
|
54
|
+
/** @internal */
|
|
55
|
+
thinkingLevel: string | null;
|
|
56
|
+
};
|
|
57
|
+
/** @internal */
|
|
58
|
+
systemPrompt: InspectionEvidence<string>;
|
|
59
|
+
/** @internal */
|
|
60
|
+
appendedInstructions: InspectionEvidence<string[]>;
|
|
61
|
+
/** @internal */
|
|
62
|
+
contextFiles: InspectionEvidence<
|
|
63
|
+
Array<{
|
|
64
|
+
/** @internal */
|
|
65
|
+
path: string;
|
|
66
|
+
/** @internal */
|
|
67
|
+
content: string;
|
|
68
|
+
}>
|
|
69
|
+
>;
|
|
70
|
+
/** @internal */
|
|
71
|
+
tools: InspectionEvidence<
|
|
72
|
+
Array<{
|
|
73
|
+
/** @internal */
|
|
74
|
+
name: string;
|
|
75
|
+
/** @internal */
|
|
76
|
+
description: string;
|
|
77
|
+
/** @internal */
|
|
78
|
+
parameters: unknown;
|
|
79
|
+
/** @internal */
|
|
80
|
+
strictSchema?: boolean;
|
|
81
|
+
/** @internal */
|
|
82
|
+
schemaEnforcement?: "provider" | "server";
|
|
83
|
+
}>
|
|
84
|
+
>;
|
|
85
|
+
/** Ordered references are retained per call; immutable content is stored once. @internal */
|
|
86
|
+
messages: InspectionMessage[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Versioned worker observation, correlated by the server to an accepted execution and lease. @internal */
|
|
90
|
+
export interface ExecutionInspectionCapture {
|
|
91
|
+
/** Idempotency identity for this observation. @internal */
|
|
92
|
+
id: string;
|
|
93
|
+
/** @internal */
|
|
94
|
+
version: 1;
|
|
95
|
+
/** @internal */
|
|
96
|
+
timestamp: string;
|
|
97
|
+
/** @internal */
|
|
98
|
+
fact:
|
|
99
|
+
| InspectionModelInput
|
|
100
|
+
| {
|
|
101
|
+
/** @internal */
|
|
102
|
+
kind: "supplied_context";
|
|
103
|
+
/** @internal */
|
|
104
|
+
origin: PreparedTurnStart | null;
|
|
105
|
+
/** @internal */
|
|
106
|
+
products: InspectionProduct[];
|
|
107
|
+
}
|
|
108
|
+
| {
|
|
109
|
+
/** @internal */
|
|
110
|
+
kind: "product_consumed";
|
|
111
|
+
/** @internal */
|
|
112
|
+
supplyId: string;
|
|
113
|
+
/** @internal */
|
|
114
|
+
name: string;
|
|
115
|
+
}
|
|
116
|
+
| {
|
|
117
|
+
/** @internal */
|
|
118
|
+
kind: "entry_link";
|
|
119
|
+
/** @internal */
|
|
120
|
+
entryId: string;
|
|
121
|
+
/** @internal */
|
|
122
|
+
piTurnId: string;
|
|
123
|
+
/** @internal */
|
|
124
|
+
role: string;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Compact lineage evidence excludes retained content. @internal */
|
|
129
|
+
export interface InspectionContextObservation {
|
|
130
|
+
/** @internal */
|
|
131
|
+
id: string;
|
|
132
|
+
/** @internal */
|
|
133
|
+
turnRecordId: string;
|
|
134
|
+
/** @internal */
|
|
135
|
+
fact:
|
|
136
|
+
| Exclude<
|
|
137
|
+
ExecutionInspectionCapture["fact"],
|
|
138
|
+
InspectionModelInput | { kind: "supplied_context" }
|
|
139
|
+
>
|
|
140
|
+
| {
|
|
141
|
+
/** @internal */
|
|
142
|
+
kind: "supplied_context";
|
|
143
|
+
/** @internal */
|
|
144
|
+
origin: PreparedTurnStart | null;
|
|
145
|
+
/** @internal */
|
|
146
|
+
products: Omit<InspectionProduct, "content">[];
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Server-owned persisted observation. @internal */
|
|
151
|
+
export interface ExecutionInspectionRecord extends ExecutionInspectionCapture {
|
|
152
|
+
/** @internal */
|
|
153
|
+
sequence: number;
|
|
154
|
+
/** @internal */
|
|
155
|
+
instanceId: string;
|
|
156
|
+
/** @internal */
|
|
157
|
+
turnRecordId: string;
|
|
158
|
+
/** @internal */
|
|
159
|
+
startRecordId: string;
|
|
160
|
+
/** Physical reporter, which can differ from the original accepting lease. @internal */
|
|
161
|
+
workerLeaseId: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Redaction is retained as evidence, not silently presented as a complete capture. @internal */
|
|
165
|
+
export function redactInspectionEvidence<T>(value: T, redact: (text: string) => string): T {
|
|
166
|
+
if (typeof value === "string") return redact(value) as T;
|
|
167
|
+
if (Array.isArray(value)) return value.map((item) => redactInspectionEvidence(item, redact)) as T;
|
|
168
|
+
if (!value || typeof value !== "object") return value;
|
|
169
|
+
const original = value as Record<string, unknown>;
|
|
170
|
+
const safe = Object.fromEntries(
|
|
171
|
+
Object.entries(original).map(([key, item]) => [
|
|
172
|
+
redact(key),
|
|
173
|
+
redactInspectionEvidence(item, redact),
|
|
174
|
+
]),
|
|
175
|
+
);
|
|
176
|
+
if (
|
|
177
|
+
original.state === "recorded" &&
|
|
178
|
+
JSON.stringify(original.value) !== JSON.stringify(safe.value)
|
|
179
|
+
)
|
|
180
|
+
safe.state = "redacted";
|
|
181
|
+
return safe as T;
|
|
182
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,10 @@ export {
|
|
|
4
4
|
SERIALIZED_SYSTEM_ACTOR,
|
|
5
5
|
serializeActor,
|
|
6
6
|
} from "./actor.js";
|
|
7
|
+
export { orderDependencies } from "./dependency-order.js";
|
|
7
8
|
export type {
|
|
8
9
|
Actor,
|
|
10
|
+
AutomaticStartupRecoverySummary,
|
|
9
11
|
CurrentExecutionRef,
|
|
10
12
|
DurableModelSelection,
|
|
11
13
|
ExternalWriteLog,
|
|
@@ -50,6 +52,7 @@ export type {
|
|
|
50
52
|
ProcessTurnType,
|
|
51
53
|
QuestionAnswerDraft,
|
|
52
54
|
ResolvedTurnStart,
|
|
55
|
+
StartupRetryState,
|
|
53
56
|
ToolApprovalStatus,
|
|
54
57
|
TransitionTrigger,
|
|
55
58
|
TurnFailedPayload,
|
|
@@ -87,6 +90,8 @@ export {
|
|
|
87
90
|
SYSTEM_ACTOR,
|
|
88
91
|
WORKER_ERROR_CLASSES,
|
|
89
92
|
} from "./domain-model.js";
|
|
93
|
+
export * from "./execution-inspection.js";
|
|
94
|
+
export { resolveJsonPointer } from "./json-pointer.js";
|
|
90
95
|
export {
|
|
91
96
|
addLauncherRecentValue,
|
|
92
97
|
DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT,
|
|
@@ -104,6 +109,7 @@ export type {
|
|
|
104
109
|
ProcessFlowEdge,
|
|
105
110
|
ProcessFlowEndState,
|
|
106
111
|
ProcessFlowNode,
|
|
112
|
+
ProcessFlowTool,
|
|
107
113
|
ProcessFlowView,
|
|
108
114
|
ProcessTurnTerminalLifecycleStatus,
|
|
109
115
|
ProcessTurnTransition,
|
|
@@ -117,6 +123,7 @@ export {
|
|
|
117
123
|
parseStrictInstanceTurnConfigsJson,
|
|
118
124
|
serializeInstanceTurnConfigs,
|
|
119
125
|
} from "./process-model-config.js";
|
|
126
|
+
export { shortestSuccessfulTurnPath } from "./process-path.js";
|
|
120
127
|
export {
|
|
121
128
|
buildProcessRowSlot,
|
|
122
129
|
type ProcessRowSlot,
|
|
@@ -138,6 +145,14 @@ export {
|
|
|
138
145
|
detectRepoLocatorKind,
|
|
139
146
|
parseRepoLocator,
|
|
140
147
|
} from "./repo-locator.js";
|
|
148
|
+
export type {
|
|
149
|
+
ResolvedSetting,
|
|
150
|
+
ScopedSettingsSnapshot,
|
|
151
|
+
SettingsContext,
|
|
152
|
+
SettingsOverride,
|
|
153
|
+
SettingsSource,
|
|
154
|
+
SettingsSubject,
|
|
155
|
+
} from "./scoped-settings.js";
|
|
141
156
|
export {
|
|
142
157
|
areSemanticEntryRefsEqual,
|
|
143
158
|
assertValidProcessProductName,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Resolve a validated JSON Pointer through own properties only. @internal */
|
|
2
|
+
export function resolveJsonPointer(value: unknown, pointer: string): unknown {
|
|
3
|
+
if (pointer === "") return value;
|
|
4
|
+
for (const token of pointer.slice(1).split("/")) {
|
|
5
|
+
const key = token.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
6
|
+
if (!value || typeof value !== "object" || !Object.hasOwn(value, key)) return undefined;
|
|
7
|
+
value = (value as Record<string, unknown>)[key];
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
@@ -30,7 +30,7 @@ export interface SerializedProcessGraph {
|
|
|
30
30
|
turnTransitions: Record<TurnId, ProcessTurnTransition[]>;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
/** Whether a flow node sits on the
|
|
33
|
+
/** Whether a flow node sits on the shortest successful path or a side branch. @internal */
|
|
34
34
|
export type ProcessFlowNodeRole = "spine" | "branch";
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -43,6 +43,16 @@ export type ProcessFlowNodeRole = "spine" | "branch";
|
|
|
43
43
|
/** @internal */
|
|
44
44
|
export type ProcessFlowEdgeKind = "forward" | "loopback" | "branch" | "terminal";
|
|
45
45
|
|
|
46
|
+
/** A statically declared LLM tool, without executable code or runtime credentials. @internal */
|
|
47
|
+
export interface ProcessFlowTool {
|
|
48
|
+
/** @internal */
|
|
49
|
+
name: string;
|
|
50
|
+
/** @internal */
|
|
51
|
+
category: "workspace" | "integration" | "question" | "outcome";
|
|
52
|
+
/** Declared description when available; integration registrations are resolved separately. @internal */
|
|
53
|
+
description: string | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
/** @internal */
|
|
47
57
|
export interface ProcessFlowNode {
|
|
48
58
|
/** @internal */
|
|
@@ -59,6 +69,16 @@ export interface ProcessFlowNode {
|
|
|
59
69
|
anchorTurnId: TurnId | null;
|
|
60
70
|
/** True when this turn is a launch entry point. @internal */
|
|
61
71
|
isEntry: boolean;
|
|
72
|
+
/** One logical turn applied to frozen items, followed by internal collection. @internal */
|
|
73
|
+
repetition?: "sequential";
|
|
74
|
+
/** Static declarations only; absent on non-LLM turns and older projections. @internal */
|
|
75
|
+
tools?: ProcessFlowTool[];
|
|
76
|
+
/** Additional integration tool names are resolved from process data at turn start. @internal */
|
|
77
|
+
hasDynamicTools?: boolean;
|
|
78
|
+
/** Named product declarations, not execution-time values. @internal */
|
|
79
|
+
inputProducts?: string[];
|
|
80
|
+
/** Named products this turn can publish. @internal */
|
|
81
|
+
outputProducts?: string[];
|
|
62
82
|
}
|
|
63
83
|
|
|
64
84
|
/** @internal */
|
|
@@ -73,6 +93,11 @@ export interface ProcessFlowEdge {
|
|
|
73
93
|
kind: ProcessFlowEdgeKind;
|
|
74
94
|
/** Optional human-facing edge label derived from outcome/trigger metadata. @internal */
|
|
75
95
|
label: string | null;
|
|
96
|
+
/** Declared branch condition; inspecting the graph never evaluates its chooser. @internal */
|
|
97
|
+
condition?: {
|
|
98
|
+
/** @internal */ label: string;
|
|
99
|
+
/** @internal */ description?: string;
|
|
100
|
+
};
|
|
76
101
|
}
|
|
77
102
|
|
|
78
103
|
/** @internal */
|
|
@@ -88,8 +113,9 @@ export interface ProcessFlowEndState {
|
|
|
88
113
|
}
|
|
89
114
|
|
|
90
115
|
/**
|
|
91
|
-
*
|
|
92
|
-
* The `spine` is the
|
|
116
|
+
* Complete definition projection for operator-facing flow diagrams.
|
|
117
|
+
* The `spine` is the shortest path from the primary entry to completion.
|
|
118
|
+
* Operator decisions remain explicit; collection stays inside a mapped turn.
|
|
93
119
|
*/
|
|
94
120
|
/** @internal */
|
|
95
121
|
export interface ProcessFlowView {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TurnId } from "./domain-model.js";
|
|
2
|
+
|
|
3
|
+
/** Breadth-first path in declaration order; null marks success. Returns [entry] without success. @internal */
|
|
4
|
+
export function shortestSuccessfulTurnPath(
|
|
5
|
+
entry: TurnId,
|
|
6
|
+
outgoing: (id: TurnId) => Iterable<TurnId | null>,
|
|
7
|
+
): TurnId[] {
|
|
8
|
+
const parents = new Map<TurnId, TurnId | null>([[entry, null]]);
|
|
9
|
+
for (const id of parents.keys()) {
|
|
10
|
+
for (const next of outgoing(id)) {
|
|
11
|
+
if (next === null) {
|
|
12
|
+
const path: TurnId[] = [];
|
|
13
|
+
let cursor: TurnId | null = id;
|
|
14
|
+
while (cursor !== null) {
|
|
15
|
+
path.push(cursor);
|
|
16
|
+
cursor = parents.get(cursor) ?? null;
|
|
17
|
+
}
|
|
18
|
+
return path.reverse();
|
|
19
|
+
}
|
|
20
|
+
if (parents.has(next)) continue;
|
|
21
|
+
parents.set(next, id);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return [entry];
|
|
25
|
+
}
|