@sapiom/harness 0.8.9 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/README.md +11 -1
- package/dist/core/agent-project-discovery.d.ts +235 -1
- package/dist/core/agent-project-discovery.d.ts.map +1 -1
- package/dist/core/agent-project-discovery.js +303 -1
- package/dist/core/agent-project-discovery.js.map +1 -1
- package/dist/core/canvas-interconnections.d.ts +31 -0
- package/dist/core/canvas-interconnections.d.ts.map +1 -1
- package/dist/core/canvas-interconnections.js +294 -21
- package/dist/core/canvas-interconnections.js.map +1 -1
- package/dist/core/canvas-render.d.ts +32 -0
- package/dist/core/canvas-render.d.ts.map +1 -1
- package/dist/core/canvas-render.js +50 -41
- package/dist/core/canvas-render.js.map +1 -1
- package/dist/core/definition-name.d.ts +12 -0
- package/dist/core/definition-name.d.ts.map +1 -1
- package/dist/core/definition-name.js +14 -5
- package/dist/core/definition-name.js.map +1 -1
- package/dist/core/system-graph-inventory.d.ts +68 -0
- package/dist/core/system-graph-inventory.d.ts.map +1 -0
- package/dist/core/system-graph-inventory.js +312 -0
- package/dist/core/system-graph-inventory.js.map +1 -0
- package/dist/core/system-graph-relationships.d.ts +41 -0
- package/dist/core/system-graph-relationships.d.ts.map +1 -0
- package/dist/core/system-graph-relationships.js +98 -0
- package/dist/core/system-graph-relationships.js.map +1 -0
- package/dist/core/system-graph-store.d.ts +45 -0
- package/dist/core/system-graph-store.d.ts.map +1 -0
- package/dist/core/system-graph-store.js +222 -0
- package/dist/core/system-graph-store.js.map +1 -0
- package/dist/core/system-graph-watcher.d.ts +51 -0
- package/dist/core/system-graph-watcher.d.ts.map +1 -0
- package/dist/core/system-graph-watcher.js +448 -0
- package/dist/core/system-graph-watcher.js.map +1 -0
- package/dist/core/system-graph.d.ts +43 -0
- package/dist/core/system-graph.d.ts.map +1 -0
- package/dist/core/system-graph.js +321 -0
- package/dist/core/system-graph.js.map +1 -0
- package/dist/core/workflow-registry.d.ts +84 -6
- package/dist/core/workflow-registry.d.ts.map +1 -1
- package/dist/core/workflow-registry.js +191 -91
- package/dist/core/workflow-registry.js.map +1 -1
- package/dist/core/workspace-watcher.d.ts +21 -13
- package/dist/core/workspace-watcher.d.ts.map +1 -1
- package/dist/core/workspace-watcher.js +79 -81
- package/dist/core/workspace-watcher.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server/agent-move.d.ts +134 -0
- package/dist/server/agent-move.d.ts.map +1 -0
- package/dist/server/agent-move.js +343 -0
- package/dist/server/agent-move.js.map +1 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +275 -22
- package/dist/server/index.js.map +1 -1
- package/dist/server/rest.d.ts +3 -0
- package/dist/server/rest.d.ts.map +1 -1
- package/dist/server/rest.js +3 -0
- package/dist/server/rest.js.map +1 -1
- package/dist/server/studio-rail.d.ts +76 -0
- package/dist/server/studio-rail.d.ts.map +1 -0
- package/dist/server/studio-rail.js +234 -0
- package/dist/server/studio-rail.js.map +1 -0
- package/dist/server/system-graph.d.ts +14 -0
- package/dist/server/system-graph.d.ts.map +1 -0
- package/dist/server/system-graph.js +40 -0
- package/dist/server/system-graph.js.map +1 -0
- package/dist/server/workflow-graph.d.ts +43 -0
- package/dist/server/workflow-graph.d.ts.map +1 -0
- package/dist/server/workflow-graph.js +200 -0
- package/dist/server/workflow-graph.js.map +1 -0
- package/dist/shared/system-graph.d.ts +59 -0
- package/dist/shared/system-graph.d.ts.map +1 -0
- package/dist/shared/system-graph.js +76 -0
- package/dist/shared/system-graph.js.map +1 -0
- package/dist/shared/types.d.ts +45 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js.map +1 -1
- package/dist/web/assets/index-2Fab6dzf.js +508 -0
- package/dist/web/assets/index-D0doaFvT.css +32 -0
- package/dist/web/index.html +2 -2
- package/package.json +5 -5
- package/dist/web/assets/index-B18B2y5o.js +0 -494
- package/dist/web/assets/index-jGBbXx9R.css +0 -32
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SystemGraphSnapshot, WorkspaceKey } from "../shared/system-graph.js";
|
|
2
|
+
import type { SystemGraphBuilder, WorkspaceScope } from "./system-graph.js";
|
|
3
|
+
export interface SystemGraphStoreOptions {
|
|
4
|
+
/** Called only for an accepted lifecycle transition. */
|
|
5
|
+
onChange?: (snapshot: SystemGraphSnapshot) => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Process-lifetime, workspace-scoped projection store.
|
|
9
|
+
*
|
|
10
|
+
* Cold reads coalesce behind one build. Later refreshes keep the last usable
|
|
11
|
+
* graph visible as stale, serialize rebuilds, and reject an older generation's
|
|
12
|
+
* result when another edit arrives while it is in flight.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SystemGraphStore {
|
|
15
|
+
private readonly builder;
|
|
16
|
+
private readonly options;
|
|
17
|
+
private readonly entries;
|
|
18
|
+
private readonly revisionFloors;
|
|
19
|
+
constructor(builder: SystemGraphBuilder, options?: SystemGraphStoreOptions);
|
|
20
|
+
get(scope: WorkspaceScope): Promise<SystemGraphSnapshot>;
|
|
21
|
+
/** Marks a workspace dirty and starts (or queues) a background refresh. */
|
|
22
|
+
requestRefresh(scope: WorkspaceScope): SystemGraphSnapshot;
|
|
23
|
+
/** Explicit user recovery: start a fresh projection and await its result. */
|
|
24
|
+
refresh(scope: WorkspaceScope): Promise<SystemGraphSnapshot>;
|
|
25
|
+
peek(workspaceKey: WorkspaceKey): SystemGraphSnapshot | null;
|
|
26
|
+
/** Records a refresh prerequisite failure while preserving visible data. */
|
|
27
|
+
reportRefreshFailure(scope: WorkspaceScope): SystemGraphSnapshot;
|
|
28
|
+
/** Retires projections for workspace scopes Studio no longer exposes. */
|
|
29
|
+
retain(workspaceKeys: ReadonlySet<WorkspaceKey>): void;
|
|
30
|
+
/** Stops retaining a scope that Studio no longer exposes. */
|
|
31
|
+
retire(workspaceKey: WorkspaceKey): void;
|
|
32
|
+
/** Backward-compatible alias for callers that explicitly drop a snapshot. */
|
|
33
|
+
invalidate(workspaceKey: WorkspaceKey): void;
|
|
34
|
+
clear(): void;
|
|
35
|
+
private ensureEntry;
|
|
36
|
+
private queueRefresh;
|
|
37
|
+
private startBuild;
|
|
38
|
+
private finishBuild;
|
|
39
|
+
private finishFailure;
|
|
40
|
+
private canCommit;
|
|
41
|
+
private continueAfterSupersededBuild;
|
|
42
|
+
private retainBuilderWorkspaces;
|
|
43
|
+
private transition;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=system-graph-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-store.d.ts","sourceRoot":"","sources":["../../src/core/system-graph-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,mBAAmB,EACnB,YAAY,EACb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,WAAW,uBAAuB;IACtC,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACpD;AAaD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IACrE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmC;gBAG/C,OAAO,EAAE,kBAAkB,EAC3B,OAAO,GAAE,uBAA4B;IAGxD,GAAG,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAyBxD,2EAA2E;IAC3E,cAAc,CAAC,KAAK,EAAE,cAAc,GAAG,mBAAmB;IAO1D,6EAA6E;IAC7E,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAM5D,IAAI,CAAC,YAAY,EAAE,YAAY,GAAG,mBAAmB,GAAG,IAAI;IAI5D,4EAA4E;IAC5E,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,mBAAmB;IAchE,yEAAyE;IACzE,MAAM,CAAC,aAAa,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,IAAI;IAMtD,6DAA6D;IAC7D,MAAM,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAUxC,6EAA6E;IAC7E,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IAI5C,KAAK,IAAI,IAAI;IAOb,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,UAAU;IA4BlB,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,4BAA4B;IAkBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,UAAU;CA8BnB"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-lifetime, workspace-scoped projection store.
|
|
3
|
+
*
|
|
4
|
+
* Cold reads coalesce behind one build. Later refreshes keep the last usable
|
|
5
|
+
* graph visible as stale, serialize rebuilds, and reject an older generation's
|
|
6
|
+
* result when another edit arrives while it is in flight.
|
|
7
|
+
*/
|
|
8
|
+
export class SystemGraphStore {
|
|
9
|
+
constructor(builder, options = {}) {
|
|
10
|
+
this.builder = builder;
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.entries = new Map();
|
|
13
|
+
this.revisionFloors = new Map();
|
|
14
|
+
}
|
|
15
|
+
get(scope) {
|
|
16
|
+
const entry = this.ensureEntry(scope);
|
|
17
|
+
if (entry.activeBuild) {
|
|
18
|
+
return entry.snapshot.graph === null
|
|
19
|
+
? entry.activeBuild
|
|
20
|
+
: Promise.resolve(entry.snapshot);
|
|
21
|
+
}
|
|
22
|
+
if (entry.snapshot.state === "building" && entry.snapshot.graph === null) {
|
|
23
|
+
return this.startBuild(entry);
|
|
24
|
+
}
|
|
25
|
+
// Non-ready projections are deliberately not healthy cache hits. One
|
|
26
|
+
// later open awaits a recovery build, while a permanent failure cannot
|
|
27
|
+
// charge every collapse/expand forever.
|
|
28
|
+
if ((entry.snapshot.state === "degraded" ||
|
|
29
|
+
entry.snapshot.state === "stale") &&
|
|
30
|
+
!entry.automaticRetryUsed) {
|
|
31
|
+
entry.automaticRetryUsed = true;
|
|
32
|
+
this.queueRefresh(entry, entry.snapshot.state === "degraded");
|
|
33
|
+
}
|
|
34
|
+
return Promise.resolve(entry.snapshot);
|
|
35
|
+
}
|
|
36
|
+
/** Marks a workspace dirty and starts (or queues) a background refresh. */
|
|
37
|
+
requestRefresh(scope) {
|
|
38
|
+
const entry = this.ensureEntry(scope);
|
|
39
|
+
entry.automaticRetryUsed = false;
|
|
40
|
+
this.queueRefresh(entry);
|
|
41
|
+
return entry.snapshot;
|
|
42
|
+
}
|
|
43
|
+
/** Explicit user recovery: start a fresh projection and await its result. */
|
|
44
|
+
refresh(scope) {
|
|
45
|
+
const entry = this.ensureEntry(scope);
|
|
46
|
+
entry.automaticRetryUsed = false;
|
|
47
|
+
return this.queueRefresh(entry) ?? Promise.resolve(entry.snapshot);
|
|
48
|
+
}
|
|
49
|
+
peek(workspaceKey) {
|
|
50
|
+
return this.entries.get(workspaceKey)?.snapshot ?? null;
|
|
51
|
+
}
|
|
52
|
+
/** Records a refresh prerequisite failure while preserving visible data. */
|
|
53
|
+
reportRefreshFailure(scope) {
|
|
54
|
+
const entry = this.ensureEntry(scope);
|
|
55
|
+
entry.generation += 1;
|
|
56
|
+
entry.refreshPending = false;
|
|
57
|
+
// Registry recovery must happen before projection. Do not let a later
|
|
58
|
+
// graph read rebuild from the stale inventory and relabel it ready; the
|
|
59
|
+
// watcher retries the failed inventory callback instead.
|
|
60
|
+
entry.automaticRetryUsed = true;
|
|
61
|
+
const visibleGraph = entry.lastGood ?? entry.snapshot.graph;
|
|
62
|
+
return visibleGraph === null
|
|
63
|
+
? this.transition(entry, "degraded", null)
|
|
64
|
+
: this.transition(entry, "stale", visibleGraph);
|
|
65
|
+
}
|
|
66
|
+
/** Retires projections for workspace scopes Studio no longer exposes. */
|
|
67
|
+
retain(workspaceKeys) {
|
|
68
|
+
for (const workspaceKey of [...this.entries.keys()]) {
|
|
69
|
+
if (!workspaceKeys.has(workspaceKey))
|
|
70
|
+
this.retire(workspaceKey);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Stops retaining a scope that Studio no longer exposes. */
|
|
74
|
+
retire(workspaceKey) {
|
|
75
|
+
const entry = this.entries.get(workspaceKey);
|
|
76
|
+
if (!entry)
|
|
77
|
+
return;
|
|
78
|
+
entry.retired = true;
|
|
79
|
+
entry.generation += 1;
|
|
80
|
+
this.revisionFloors.set(workspaceKey, entry.snapshot.revision);
|
|
81
|
+
this.entries.delete(workspaceKey);
|
|
82
|
+
this.retainBuilderWorkspaces();
|
|
83
|
+
}
|
|
84
|
+
/** Backward-compatible alias for callers that explicitly drop a snapshot. */
|
|
85
|
+
invalidate(workspaceKey) {
|
|
86
|
+
this.retire(workspaceKey);
|
|
87
|
+
}
|
|
88
|
+
clear() {
|
|
89
|
+
for (const workspaceKey of [...this.entries.keys()]) {
|
|
90
|
+
this.retire(workspaceKey);
|
|
91
|
+
}
|
|
92
|
+
this.revisionFloors.clear();
|
|
93
|
+
}
|
|
94
|
+
ensureEntry(scope) {
|
|
95
|
+
const existing = this.entries.get(scope.workspaceKey);
|
|
96
|
+
if (existing) {
|
|
97
|
+
existing.scope = scope;
|
|
98
|
+
return existing;
|
|
99
|
+
}
|
|
100
|
+
const entry = {
|
|
101
|
+
scope,
|
|
102
|
+
snapshot: {
|
|
103
|
+
workspaceKey: scope.workspaceKey,
|
|
104
|
+
revision: this.revisionFloors.get(scope.workspaceKey) ?? 0,
|
|
105
|
+
state: "building",
|
|
106
|
+
graph: null,
|
|
107
|
+
},
|
|
108
|
+
lastGood: null,
|
|
109
|
+
activeBuild: null,
|
|
110
|
+
generation: 0,
|
|
111
|
+
refreshPending: false,
|
|
112
|
+
automaticRetryUsed: false,
|
|
113
|
+
retired: false,
|
|
114
|
+
};
|
|
115
|
+
this.entries.set(scope.workspaceKey, entry);
|
|
116
|
+
return entry;
|
|
117
|
+
}
|
|
118
|
+
queueRefresh(entry, preserveLifecycle = false) {
|
|
119
|
+
if (entry.retired)
|
|
120
|
+
return null;
|
|
121
|
+
entry.generation += 1;
|
|
122
|
+
entry.refreshPending = true;
|
|
123
|
+
const visibleGraph = entry.lastGood ?? entry.snapshot.graph;
|
|
124
|
+
if (!preserveLifecycle) {
|
|
125
|
+
this.transition(entry, visibleGraph === null ? "building" : "stale", visibleGraph);
|
|
126
|
+
}
|
|
127
|
+
if (entry.activeBuild)
|
|
128
|
+
return entry.activeBuild;
|
|
129
|
+
entry.refreshPending = false;
|
|
130
|
+
return this.startBuild(entry);
|
|
131
|
+
}
|
|
132
|
+
startBuild(entry) {
|
|
133
|
+
if (entry.activeBuild)
|
|
134
|
+
return entry.activeBuild;
|
|
135
|
+
const generation = entry.generation;
|
|
136
|
+
entry.refreshPending = false;
|
|
137
|
+
const visibleGraph = entry.lastGood ?? entry.snapshot.graph;
|
|
138
|
+
if (entry.snapshot.state !== "degraded") {
|
|
139
|
+
this.transition(entry, visibleGraph === null ? "building" : "stale", visibleGraph);
|
|
140
|
+
}
|
|
141
|
+
let build;
|
|
142
|
+
try {
|
|
143
|
+
build = Promise.resolve(this.builder.build(entry.scope));
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
build = Promise.reject(error);
|
|
147
|
+
}
|
|
148
|
+
const active = build.then((result) => this.finishBuild(entry, generation, result), () => this.finishFailure(entry, generation));
|
|
149
|
+
entry.activeBuild = active;
|
|
150
|
+
return active;
|
|
151
|
+
}
|
|
152
|
+
finishBuild(entry, generation, result) {
|
|
153
|
+
if (!this.canCommit(entry, generation)) {
|
|
154
|
+
return this.continueAfterSupersededBuild(entry);
|
|
155
|
+
}
|
|
156
|
+
entry.activeBuild = null;
|
|
157
|
+
if (result.cacheable) {
|
|
158
|
+
entry.lastGood = result.graph;
|
|
159
|
+
entry.automaticRetryUsed = false;
|
|
160
|
+
return this.transition(entry, "ready", result.graph);
|
|
161
|
+
}
|
|
162
|
+
return this.transition(entry, "degraded", result.graph);
|
|
163
|
+
}
|
|
164
|
+
finishFailure(entry, generation) {
|
|
165
|
+
if (!this.canCommit(entry, generation)) {
|
|
166
|
+
return this.continueAfterSupersededBuild(entry);
|
|
167
|
+
}
|
|
168
|
+
entry.activeBuild = null;
|
|
169
|
+
const visibleGraph = entry.lastGood ?? entry.snapshot.graph;
|
|
170
|
+
return visibleGraph === null
|
|
171
|
+
? this.transition(entry, "degraded", null)
|
|
172
|
+
: this.transition(entry, "stale", visibleGraph, true);
|
|
173
|
+
}
|
|
174
|
+
canCommit(entry, generation) {
|
|
175
|
+
return (!entry.retired &&
|
|
176
|
+
this.entries.get(entry.scope.workspaceKey) === entry &&
|
|
177
|
+
entry.generation === generation);
|
|
178
|
+
}
|
|
179
|
+
continueAfterSupersededBuild(entry) {
|
|
180
|
+
entry.activeBuild = null;
|
|
181
|
+
if (entry.retired ||
|
|
182
|
+
this.entries.get(entry.scope.workspaceKey) !== entry) {
|
|
183
|
+
this.retainBuilderWorkspaces();
|
|
184
|
+
return entry.snapshot;
|
|
185
|
+
}
|
|
186
|
+
if (entry.refreshPending) {
|
|
187
|
+
entry.refreshPending = false;
|
|
188
|
+
return this.startBuild(entry);
|
|
189
|
+
}
|
|
190
|
+
return entry.snapshot;
|
|
191
|
+
}
|
|
192
|
+
retainBuilderWorkspaces() {
|
|
193
|
+
try {
|
|
194
|
+
this.builder.retainWorkspaces?.(new Set(this.entries.keys()));
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// Cache pruning cannot make graph reads or scope retirement fail.
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
transition(entry, state, graph, forceRevision = false) {
|
|
201
|
+
if (!forceRevision &&
|
|
202
|
+
entry.snapshot.state === state &&
|
|
203
|
+
entry.snapshot.graph === graph) {
|
|
204
|
+
return entry.snapshot;
|
|
205
|
+
}
|
|
206
|
+
entry.snapshot = {
|
|
207
|
+
workspaceKey: entry.scope.workspaceKey,
|
|
208
|
+
revision: entry.snapshot.revision + 1,
|
|
209
|
+
state,
|
|
210
|
+
graph,
|
|
211
|
+
};
|
|
212
|
+
this.revisionFloors.set(entry.scope.workspaceKey, entry.snapshot.revision);
|
|
213
|
+
try {
|
|
214
|
+
this.options.onChange?.(entry.snapshot);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// Observers (the event bus) cannot make graph refreshes fail.
|
|
218
|
+
}
|
|
219
|
+
return entry.snapshot;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=system-graph-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-store.js","sourceRoot":"","sources":["../../src/core/system-graph-store.ts"],"names":[],"mappings":"AAwBA;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAI3B,YACmB,OAA2B,EAC3B,UAAmC,EAAE;QADrC,YAAO,GAAP,OAAO,CAAoB;QAC3B,YAAO,GAAP,OAAO,CAA8B;QALvC,YAAO,GAAG,IAAI,GAAG,EAAkC,CAAC;QACpD,mBAAc,GAAG,IAAI,GAAG,EAAwB,CAAC;IAK/D,CAAC;IAEJ,GAAG,CAAC,KAAqB;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACtC,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC,QAAQ,CAAC,KAAK,KAAK,IAAI;gBAClC,CAAC,CAAC,KAAK,CAAC,WAAW;gBACnB,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAA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AAC;IACH,CAAC;IAEO,UAAU,CAChB,KAAuB,EACvB,KAAgC,EAChC,KAAyB,EACzB,aAAa,GAAG,KAAK;QAErB,IACE,CAAC,aAAa;YACd,KAAK,CAAC,QAAQ,CAAC,KAAK,KAAK,KAAK;YAC9B,KAAK,CAAC,QAAQ,CAAC,KAAK,KAAK,KAAK,EAC9B,CAAC;YACD,OAAO,KAAK,CAAC,QAAQ,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,QAAQ,GAAG;YACf,YAAY,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY;YACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,QAAQ,GAAG,CAAC;YACrC,KAAK;YACL,KAAK;SACN,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,GAAG,CACrB,KAAK,CAAC,KAAK,CAAC,YAAY,EACxB,KAAK,CAAC,QAAQ,CAAC,QAAQ,CACxB,CAAC;QACF,IAAI,CAAC;YACH,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,8DAA8D;QAChE,CAAC;QACD,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { WorkspaceKey } from "../shared/system-graph.js";
|
|
2
|
+
import type { WorkspaceScope } from "./system-graph.js";
|
|
3
|
+
/**
|
|
4
|
+
* Async source fingerprint for the registered agent roots in one workspace.
|
|
5
|
+
*
|
|
6
|
+
* The graph watcher deliberately does not reuse Canvas's synchronous,
|
|
7
|
+
* 400-file project snapshot here: a workspace can contain many agent projects,
|
|
8
|
+
* and polling it on the server event loop would both stutter Studio and miss
|
|
9
|
+
* edits after that project-sized ceiling. Async directory reads yield between
|
|
10
|
+
* entries, while scoping the walk to registry roots keeps the unbounded file
|
|
11
|
+
* count honest without traversing unrelated workspace trees.
|
|
12
|
+
*/
|
|
13
|
+
export declare function snapshotWorkflowSourceRootsAsync(sourceRoots: readonly string[]): Promise<ReadonlyMap<string, string>>;
|
|
14
|
+
export interface SystemGraphWatcherCallbacks {
|
|
15
|
+
/** Current registry roots inside this scope; read lazily on every poll. */
|
|
16
|
+
listSourceRoots: (scope: WorkspaceScope) => readonly string[];
|
|
17
|
+
onSourceChange: (scope: WorkspaceScope,
|
|
18
|
+
/** Null when the platform can only report a workspace-level change. */
|
|
19
|
+
sourcePaths: readonly string[] | null) => void | Promise<void>;
|
|
20
|
+
onInventoryChange: (scope: WorkspaceScope) => void | Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export interface SystemGraphWatchHandle {
|
|
23
|
+
close(): void;
|
|
24
|
+
on(event: "error", listener: (error: Error) => void): SystemGraphWatchHandle;
|
|
25
|
+
}
|
|
26
|
+
export type SystemGraphWatchFactory = (root: string, listener: (event: "rename" | "change", filename: string | null) => void) => SystemGraphWatchHandle;
|
|
27
|
+
export interface SystemGraphWatcherOptions {
|
|
28
|
+
sourceDebounceMs?: number;
|
|
29
|
+
inventoryDebounceMs?: number;
|
|
30
|
+
inventoryRetryBaseMs?: number;
|
|
31
|
+
maxInventoryRetries?: number;
|
|
32
|
+
pollIntervalMs?: number;
|
|
33
|
+
/** Deterministic test seam for the supported polling fallback. */
|
|
34
|
+
forcePolling?: boolean;
|
|
35
|
+
/** Deterministic test seam for native event routing and watcher errors. */
|
|
36
|
+
watchFactory?: SystemGraphWatchFactory;
|
|
37
|
+
}
|
|
38
|
+
/** One watcher per requested workspace, independent of harness sessions. */
|
|
39
|
+
export declare class SystemGraphWatcherManager {
|
|
40
|
+
private readonly callbacks;
|
|
41
|
+
private readonly options;
|
|
42
|
+
private readonly watchers;
|
|
43
|
+
private readonly pendingStarts;
|
|
44
|
+
constructor(callbacks: SystemGraphWatcherCallbacks, options?: SystemGraphWatcherOptions);
|
|
45
|
+
start(scope: WorkspaceScope): Promise<void>;
|
|
46
|
+
retain(workspaceKeys: ReadonlySet<WorkspaceKey>): void;
|
|
47
|
+
stop(workspaceKey: WorkspaceKey): void;
|
|
48
|
+
stopAll(): void;
|
|
49
|
+
get size(): number;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=system-graph-watcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-watcher.d.ts","sourceRoot":"","sources":["../../src/core/system-graph-watcher.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsCxD;;;;;;;;;GASG;AACH,wBAAsB,gCAAgC,CACpD,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwCtC;AAgCD,MAAM,WAAW,2BAA2B;IAC1C,2EAA2E;IAC3E,eAAe,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,MAAM,EAAE,CAAC;IAC9D,cAAc,EAAE,CACd,KAAK,EAAE,cAAc;IACrB,uEAAuE;IACvE,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,KAClC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,iBAAiB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,IAAI,IAAI,CAAC;IACd,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,sBAAsB,CAAC;CAC9E;AAED,MAAM,MAAM,uBAAuB,GAAG,CACpC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IA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