@leitwerk-dev/domain 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.
@@ -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
+ }
@@ -0,0 +1,92 @@
1
+ import type { Actor } from "./domain-model.js";
2
+
3
+ /** One stable subject per named scope type. @public */
4
+ export type SettingsContext = Readonly<Record<string, string>>;
5
+
6
+ /** @public */
7
+ export interface SettingsSubject {
8
+ /** @public */
9
+ id: string;
10
+ /** @public */
11
+ scopeType: string;
12
+ /** @public */
13
+ identity: string;
14
+ /** @public */
15
+ label: string;
16
+ /** Lower scopes supplied by the owning integration, never matched by expression. @public */
17
+ context: SettingsContext;
18
+ /** @public */
19
+ schemaVersion: number;
20
+ /** @public */
21
+ revision: number;
22
+ /** @public */
23
+ createdAt: string;
24
+ /** @public */
25
+ updatedAt: string;
26
+ /** Discovery is attributed to the server system actor. @public */
27
+ actor: Actor;
28
+ }
29
+
30
+ /** A reset retains its revision to prevent delete/recreate races. @internal */
31
+ export interface SettingsOverride {
32
+ /** @internal */
33
+ subjectId: string;
34
+ /** @internal */
35
+ key: string;
36
+ /** @internal */
37
+ value: unknown;
38
+ /** @internal */
39
+ mode: "append" | "replace";
40
+ /** @internal */
41
+ reset: boolean;
42
+ /** @internal */
43
+ schemaVersion: number;
44
+ /** @internal */
45
+ revision: number;
46
+ /** @internal */
47
+ createdAt: string;
48
+ /** @internal */
49
+ updatedAt: string;
50
+ /** @internal */
51
+ actor: Actor;
52
+ }
53
+
54
+ /** @public */
55
+ export interface SettingsSource {
56
+ /** @public */
57
+ subjectId: string | null;
58
+ /** @public */
59
+ scopeType: string;
60
+ /** @public */
61
+ label: string;
62
+ /** @public */
63
+ revision: number;
64
+ /** @public */
65
+ schemaVersion: number;
66
+ /** @public */
67
+ mode: "append" | "replace";
68
+ }
69
+
70
+ /** @public */
71
+ export interface ResolvedSetting<T = unknown> {
72
+ /** @public */
73
+ key: string;
74
+ /** @public */
75
+ value: T;
76
+ /** @public */
77
+ sources: SettingsSource[];
78
+ }
79
+
80
+ /** Immutable, non-secret settings consumed by a prepared turn. @public */
81
+ export interface ScopedSettingsSnapshot {
82
+ /** @public */
83
+ version: 1;
84
+ /** @public */
85
+ purpose: string;
86
+ /** @public */
87
+ context: SettingsContext;
88
+ /** @public */
89
+ values: ResolvedSetting[];
90
+ /** @public */
91
+ explanations: string[];
92
+ }
@@ -7,6 +7,7 @@ export const DEFAULT_CONTINUE_PROMPT = "continue";
7
7
  /** @internal */
8
8
  export const FAILED_TURN_RECOVERY_CODES = [
9
9
  "generic_continue",
10
+ "outcome_rejected",
10
11
  "missing_outcome_tool",
11
12
  "missing_markdown_result",
12
13
  "missing_required_tool_calls",