@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
|
@@ -13,5 +13,17 @@
|
|
|
13
13
|
* caller falls back to a weaker name source.
|
|
14
14
|
*/
|
|
15
15
|
import { extractWorkflowGraphCached } from "./canvas-cache.js";
|
|
16
|
+
export type ManifestNameInspection = {
|
|
17
|
+
status: "found";
|
|
18
|
+
name: string;
|
|
19
|
+
} | {
|
|
20
|
+
status: "absent" | "failed";
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Inspect the declared manifest name while preserving the difference between
|
|
24
|
+
* a valid unnamed agent and an extraction failure. Inventory uses the richer
|
|
25
|
+
* result to avoid warning for the normal unnamed case.
|
|
26
|
+
*/
|
|
27
|
+
export declare function inspectManifestName(projectDir: string, extract?: typeof extractWorkflowGraphCached): Promise<ManifestNameInspection>;
|
|
16
28
|
export declare function resolveManifestName(projectDir: string, extract?: typeof extractWorkflowGraphCached): Promise<string | null>;
|
|
17
29
|
//# sourceMappingURL=definition-name.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition-name.d.ts","sourceRoot":"","sources":["../../src/core/definition-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAO,0BAAuD,GACtE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"definition-name.d.ts","sourceRoot":"","sources":["../../src/core/definition-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAC9B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAA;CAAE,CAAC;AAEpC;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAO,0BAAuD,GACtE,OAAO,CAAC,sBAAsB,CAAC,CASjC;AAED,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,OAAO,0BAAuD,GACtE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB"}
|
|
@@ -13,16 +13,25 @@
|
|
|
13
13
|
* caller falls back to a weaker name source.
|
|
14
14
|
*/
|
|
15
15
|
import { extractWorkflowGraphCached } from "./canvas-cache.js";
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Inspect the declared manifest name while preserving the difference between
|
|
18
|
+
* a valid unnamed agent and an extraction failure. Inventory uses the richer
|
|
19
|
+
* result to avoid warning for the normal unnamed case.
|
|
20
|
+
*/
|
|
21
|
+
export async function inspectManifestName(projectDir, extract = extractWorkflowGraphCached) {
|
|
17
22
|
try {
|
|
18
23
|
const { result } = await extract(projectDir);
|
|
19
24
|
if (!result.ok)
|
|
20
|
-
return
|
|
21
|
-
|
|
25
|
+
return { status: "failed" };
|
|
26
|
+
const name = result.graph.manifestName.trim();
|
|
27
|
+
return name === "" ? { status: "absent" } : { status: "found", name };
|
|
22
28
|
}
|
|
23
29
|
catch {
|
|
24
|
-
|
|
25
|
-
return null;
|
|
30
|
+
return { status: "failed" };
|
|
26
31
|
}
|
|
27
32
|
}
|
|
33
|
+
export async function resolveManifestName(projectDir, extract = extractWorkflowGraphCached) {
|
|
34
|
+
const inspected = await inspectManifestName(projectDir, extract);
|
|
35
|
+
return inspected.status === "found" ? inspected.name : null;
|
|
36
|
+
}
|
|
28
37
|
//# sourceMappingURL=definition-name.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition-name.js","sourceRoot":"","sources":["../../src/core/definition-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"definition-name.js","sourceRoot":"","sources":["../../src/core/definition-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAM/D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,UAA6C,0BAA0B;IAEvE,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACxE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,UAA6C,0BAA0B;IAEvE,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACjE,OAAO,SAAS,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type AgentKey, type GraphWarning, type WorkspaceKey } from "../shared/system-graph.js";
|
|
2
|
+
import type { WorkflowInfo } from "../shared/types.js";
|
|
3
|
+
import type { ManifestNameInspection } from "./definition-name.js";
|
|
4
|
+
export { workspaceRelativeLocalKey } from "../shared/system-graph.js";
|
|
5
|
+
export interface WorkspaceScope {
|
|
6
|
+
workspaceKey: WorkspaceKey;
|
|
7
|
+
root: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AgentInventoryItem {
|
|
10
|
+
agentKey: AgentKey;
|
|
11
|
+
/** Internal deployment provenance. Never serialize this into SystemGraph. */
|
|
12
|
+
definitionId: number | null;
|
|
13
|
+
definitionSlug: string | null;
|
|
14
|
+
label: string;
|
|
15
|
+
resolutionAliases: string[];
|
|
16
|
+
/** Internal filesystem evidence. Never serialize this into SystemGraph. */
|
|
17
|
+
sourceRoot: string;
|
|
18
|
+
}
|
|
19
|
+
export interface AgentInventoryWarning {
|
|
20
|
+
code: Extract<GraphWarning["code"], "duplicate-agent-key" | "inventory-extraction-failed">;
|
|
21
|
+
agentKey: AgentKey;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentInventoryResult {
|
|
25
|
+
agents: AgentInventoryItem[];
|
|
26
|
+
/** False when a later graph open should retry degraded enrichment. */
|
|
27
|
+
cacheable: boolean;
|
|
28
|
+
warnings: AgentInventoryWarning[];
|
|
29
|
+
}
|
|
30
|
+
/** Read-only boundary between Studio's current registry and graph projection. */
|
|
31
|
+
export interface AgentInventoryProvider {
|
|
32
|
+
listAgents(scope: WorkspaceScope): Promise<AgentInventoryResult>;
|
|
33
|
+
}
|
|
34
|
+
type ManifestNameInspector = (sourceRoot: string) => Promise<ManifestNameInspection>;
|
|
35
|
+
export interface HarnessRegistryInventoryProviderOptions {
|
|
36
|
+
listWorkflows: () => readonly WorkflowInfo[] | Promise<readonly WorkflowInfo[]>;
|
|
37
|
+
inspectManifestName?: ManifestNameInspector;
|
|
38
|
+
/** Test seam; production keeps the default first-open latency budget. */
|
|
39
|
+
manifestInspectionBudgetMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve with the input path's own flavor so mixed Windows separators remain
|
|
43
|
+
* comparable even when the test process (or a future remote host) is POSIX.
|
|
44
|
+
*/
|
|
45
|
+
export declare function canonicalGraphPath(input: string): string;
|
|
46
|
+
export declare function isWithinGraphPath(root: string, candidate: string): boolean;
|
|
47
|
+
/** Canonical registered roots contained by a workspace, safe for symlinked scopes. */
|
|
48
|
+
export declare function graphSourceRootsWithinScope(scopeRoot: string, sourceRoots: readonly string[]): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Attribute exact source edits to the deepest registered project roots.
|
|
51
|
+
* A null path list is the polling/ambiguous-event fallback and dirties every
|
|
52
|
+
* caller in the scope.
|
|
53
|
+
*/
|
|
54
|
+
export declare function dirtyGraphSourceRoots(scopeRoot: string, sourceRoots: readonly string[], sourcePaths: readonly string[] | null): string[];
|
|
55
|
+
/**
|
|
56
|
+
* V0 inventory adapter. WorkflowRegistry's scan/connect flows remain the only
|
|
57
|
+
* writers; this provider receives snapshots and performs no discovery. The
|
|
58
|
+
* injected manifest-name inspection may run cached extraction, so enrichment
|
|
59
|
+
* has both a concurrency cap and a wall-clock budget on a cold graph open.
|
|
60
|
+
*/
|
|
61
|
+
export declare class HarnessRegistryInventoryProvider implements AgentInventoryProvider {
|
|
62
|
+
private readonly options;
|
|
63
|
+
constructor(options: HarnessRegistryInventoryProviderOptions);
|
|
64
|
+
listAgents(scope: WorkspaceScope): Promise<AgentInventoryResult>;
|
|
65
|
+
private prepareAgent;
|
|
66
|
+
private prepareFallbackAgent;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=system-graph-inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-inventory.d.ts","sourceRoot":"","sources":["../../src/core/system-graph-inventory.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oB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B,CAAC,EAAE,MAAM,CAAC;CACrC;AAsDD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6BxD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAU1E;AAED,sFAAsF;AACtF,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,MAAM,EAAE,CAWV;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GACpC,MAAM,EAAE,CAsBV;AAkED;;;;;GAKG;AACH,qBAAa,gCAAiC,YAAW,sBAAsB;IAE3E,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,uCAAuC;IAG7D,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;YAoHxD,YAAY;IA+C1B,OAAO,CAAC,oBAAoB;CAqB7B"}
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { realpathSync } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { workspaceRelativeLocalKey, } from "../shared/system-graph.js";
|
|
4
|
+
export { workspaceRelativeLocalKey } from "../shared/system-graph.js";
|
|
5
|
+
const MANIFEST_INSPECTION_CONCURRENCY = 4;
|
|
6
|
+
// Individual extraction can wait 15 s; inventory must return well before that.
|
|
7
|
+
const MANIFEST_INSPECTION_BUDGET_MS = 5000;
|
|
8
|
+
async function mapWithDeadline(values, concurrency, budgetMs, map) {
|
|
9
|
+
const results = new Array(values.length);
|
|
10
|
+
let nextIndex = 0;
|
|
11
|
+
let deadlineReached = false;
|
|
12
|
+
const worker = async () => {
|
|
13
|
+
while (!deadlineReached && nextIndex < values.length) {
|
|
14
|
+
const index = nextIndex;
|
|
15
|
+
nextIndex += 1;
|
|
16
|
+
try {
|
|
17
|
+
results[index] = await map(values[index]);
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// The caller turns every unfinished/failed item into partial inventory.
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const workers = Promise.all(Array.from({ length: Math.min(concurrency, values.length) }, async () => worker()));
|
|
25
|
+
let timer;
|
|
26
|
+
const deadline = new Promise((resolve) => {
|
|
27
|
+
timer = setTimeout(() => {
|
|
28
|
+
deadlineReached = true;
|
|
29
|
+
resolve();
|
|
30
|
+
}, budgetMs);
|
|
31
|
+
});
|
|
32
|
+
await Promise.race([workers, deadline]);
|
|
33
|
+
if (!deadlineReached && timer)
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
// Already-started production inspections have their own 15 s timeout. Do
|
|
36
|
+
// not await them, and prevent workers from starting any more after the cap.
|
|
37
|
+
void workers;
|
|
38
|
+
return results.slice();
|
|
39
|
+
}
|
|
40
|
+
function isWindowsAbsolute(input) {
|
|
41
|
+
return /^[A-Za-z]:[\\/]/.test(input);
|
|
42
|
+
}
|
|
43
|
+
function pathApi(input) {
|
|
44
|
+
return isWindowsAbsolute(input) ? path.win32 : path.posix;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Resolve with the input path's own flavor so mixed Windows separators remain
|
|
48
|
+
* comparable even when the test process (or a future remote host) is POSIX.
|
|
49
|
+
*/
|
|
50
|
+
export function canonicalGraphPath(input) {
|
|
51
|
+
const windows = isWindowsAbsolute(input);
|
|
52
|
+
const api = pathApi(input);
|
|
53
|
+
const normalizedInput = windows ? input.replace(/\//g, "\\") : input;
|
|
54
|
+
const resolved = api.resolve(normalizedInput);
|
|
55
|
+
const matchesHost = windows === (process.platform === "win32");
|
|
56
|
+
if (!matchesHost)
|
|
57
|
+
return resolved;
|
|
58
|
+
try {
|
|
59
|
+
return realpathSync.native(resolved);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Watchers can report a path after an atomic rename or deletion, so the
|
|
63
|
+
// leaf itself may no longer exist. Resolve the nearest existing ancestor
|
|
64
|
+
// and append the missing tail; otherwise a symlinked workspace would stop
|
|
65
|
+
// matching exactly when targeted invalidation matters most.
|
|
66
|
+
const missingSegments = [];
|
|
67
|
+
let ancestor = resolved;
|
|
68
|
+
let parent = api.dirname(ancestor);
|
|
69
|
+
while (parent !== ancestor) {
|
|
70
|
+
missingSegments.unshift(api.basename(ancestor));
|
|
71
|
+
ancestor = parent;
|
|
72
|
+
try {
|
|
73
|
+
return api.join(realpathSync.native(ancestor), ...missingSegments);
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
// Keep walking toward an existing ancestor.
|
|
77
|
+
}
|
|
78
|
+
parent = api.dirname(ancestor);
|
|
79
|
+
}
|
|
80
|
+
return resolved;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function isWithinGraphPath(root, candidate) {
|
|
84
|
+
if (isWindowsAbsolute(root) !== isWindowsAbsolute(candidate))
|
|
85
|
+
return false;
|
|
86
|
+
const api = pathApi(root);
|
|
87
|
+
const relative = api.relative(root, candidate);
|
|
88
|
+
return (relative === "" ||
|
|
89
|
+
(relative !== ".." &&
|
|
90
|
+
!relative.startsWith(`..${api.sep}`) &&
|
|
91
|
+
!api.isAbsolute(relative)));
|
|
92
|
+
}
|
|
93
|
+
/** Canonical registered roots contained by a workspace, safe for symlinked scopes. */
|
|
94
|
+
export function graphSourceRootsWithinScope(scopeRoot, sourceRoots) {
|
|
95
|
+
const canonicalScopeRoot = canonicalGraphPath(scopeRoot);
|
|
96
|
+
return [
|
|
97
|
+
...new Set(sourceRoots
|
|
98
|
+
.map(canonicalGraphPath)
|
|
99
|
+
.filter((sourceRoot) => isWithinGraphPath(canonicalScopeRoot, sourceRoot))),
|
|
100
|
+
].sort();
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Attribute exact source edits to the deepest registered project roots.
|
|
104
|
+
* A null path list is the polling/ambiguous-event fallback and dirties every
|
|
105
|
+
* caller in the scope.
|
|
106
|
+
*/
|
|
107
|
+
export function dirtyGraphSourceRoots(scopeRoot, sourceRoots, sourcePaths) {
|
|
108
|
+
const roots = graphSourceRootsWithinScope(scopeRoot, sourceRoots);
|
|
109
|
+
if (sourcePaths === null)
|
|
110
|
+
return roots;
|
|
111
|
+
const dirty = new Set();
|
|
112
|
+
for (const sourcePath of sourcePaths) {
|
|
113
|
+
const canonicalSourcePath = canonicalGraphPath(sourcePath);
|
|
114
|
+
const matches = roots.filter((sourceRoot) => isWithinGraphPath(sourceRoot, canonicalSourcePath));
|
|
115
|
+
for (const match of matches) {
|
|
116
|
+
if (!matches.some((candidate) => candidate !== match && isWithinGraphPath(match, candidate))) {
|
|
117
|
+
dirty.add(match);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return [...dirty].sort();
|
|
122
|
+
}
|
|
123
|
+
function normalizedAlias(value) {
|
|
124
|
+
const alias = value?.trim() ?? "";
|
|
125
|
+
if (alias === "" ||
|
|
126
|
+
/[\0\r\n]/.test(alias) ||
|
|
127
|
+
alias.includes("/") ||
|
|
128
|
+
alias.includes("\\") ||
|
|
129
|
+
path.posix.isAbsolute(alias) ||
|
|
130
|
+
path.win32.isAbsolute(alias)) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return alias;
|
|
134
|
+
}
|
|
135
|
+
function safeLabel(value, fallback) {
|
|
136
|
+
const label = value.trim();
|
|
137
|
+
if (label === "" ||
|
|
138
|
+
/[\0\r\n]/.test(label) ||
|
|
139
|
+
path.posix.isAbsolute(label) ||
|
|
140
|
+
path.win32.isAbsolute(label)) {
|
|
141
|
+
return fallback;
|
|
142
|
+
}
|
|
143
|
+
return label;
|
|
144
|
+
}
|
|
145
|
+
function uniqueAliases(values) {
|
|
146
|
+
return [
|
|
147
|
+
...new Set(values.filter((value) => value !== null)),
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
function preparedOrder(left, right) {
|
|
151
|
+
return (left.candidateKey.localeCompare(right.candidateKey) ||
|
|
152
|
+
left.sourceRoot.localeCompare(right.sourceRoot) ||
|
|
153
|
+
left.label.localeCompare(right.label));
|
|
154
|
+
}
|
|
155
|
+
function warningOrder(left, right) {
|
|
156
|
+
return (left.code.localeCompare(right.code) ||
|
|
157
|
+
left.agentKey.localeCompare(right.agentKey) ||
|
|
158
|
+
left.message.localeCompare(right.message));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* V0 inventory adapter. WorkflowRegistry's scan/connect flows remain the only
|
|
162
|
+
* writers; this provider receives snapshots and performs no discovery. The
|
|
163
|
+
* injected manifest-name inspection may run cached extraction, so enrichment
|
|
164
|
+
* has both a concurrency cap and a wall-clock budget on a cold graph open.
|
|
165
|
+
*/
|
|
166
|
+
export class HarnessRegistryInventoryProvider {
|
|
167
|
+
constructor(options) {
|
|
168
|
+
this.options = options;
|
|
169
|
+
}
|
|
170
|
+
async listAgents(scope) {
|
|
171
|
+
// A registry read is the one operation whose failure makes inventory
|
|
172
|
+
// unavailable. Per-agent enrichment failures degrade to local identities.
|
|
173
|
+
const workflows = await this.options.listWorkflows();
|
|
174
|
+
const navigationRoot = scope.root;
|
|
175
|
+
const selectedScope = {
|
|
176
|
+
workspaceKey: scope.workspaceKey,
|
|
177
|
+
root: canonicalGraphPath(scope.root),
|
|
178
|
+
};
|
|
179
|
+
// Project-axis membership is containment in the SELECTED root. An agent can
|
|
180
|
+
// therefore appear in both a parent project's graph and a separately-opened
|
|
181
|
+
// nested project's graph, exactly as it appears under both project rows in
|
|
182
|
+
// the rail. Deepest-scope ownership made the parent row visibly list agents
|
|
183
|
+
// that disappeared when its graph opened.
|
|
184
|
+
const contained = workflows
|
|
185
|
+
.map((workflow) => ({
|
|
186
|
+
workflow,
|
|
187
|
+
sourceRoot: canonicalGraphPath(workflow.path),
|
|
188
|
+
}))
|
|
189
|
+
.filter(({ sourceRoot }) => isWithinGraphPath(selectedScope.root, sourceRoot))
|
|
190
|
+
.map(({ workflow, sourceRoot }) => {
|
|
191
|
+
const fallbackKey = workspaceRelativeLocalKey(navigationRoot, workflow.path) ??
|
|
192
|
+
workspaceRelativeLocalKey(selectedScope.root, sourceRoot);
|
|
193
|
+
if (!fallbackKey) {
|
|
194
|
+
throw new Error("Contained system graph path had no local identity");
|
|
195
|
+
}
|
|
196
|
+
return { workflow, sourceRoot, fallbackKey };
|
|
197
|
+
});
|
|
198
|
+
const inspections = await mapWithDeadline(contained, MANIFEST_INSPECTION_CONCURRENCY, this.options.manifestInspectionBudgetMs ?? MANIFEST_INSPECTION_BUDGET_MS, ({ workflow, sourceRoot, fallbackKey }) => this.prepareAgent(workflow, sourceRoot, fallbackKey));
|
|
199
|
+
const prepared = Array.from({ length: contained.length }, (_, index) => inspections[index] ??
|
|
200
|
+
this.prepareFallbackAgent(contained[index].workflow, contained[index].sourceRoot, contained[index].fallbackKey)).sort(preparedOrder);
|
|
201
|
+
const candidateCounts = new Map();
|
|
202
|
+
for (const agent of prepared) {
|
|
203
|
+
candidateCounts.set(agent.candidateKey, (candidateCounts.get(agent.candidateKey) ?? 0) + 1);
|
|
204
|
+
}
|
|
205
|
+
const used = new Set();
|
|
206
|
+
const assigned = prepared.map((agent) => {
|
|
207
|
+
const duplicate = (candidateCounts.get(agent.candidateKey) ?? 0) > 1;
|
|
208
|
+
let agentKey = duplicate ? agent.fallbackKey : agent.candidateKey;
|
|
209
|
+
if (used.has(agentKey))
|
|
210
|
+
agentKey = agent.fallbackKey;
|
|
211
|
+
let suffix = 2;
|
|
212
|
+
const base = agentKey;
|
|
213
|
+
while (used.has(agentKey)) {
|
|
214
|
+
agentKey = `${base}~${suffix}`;
|
|
215
|
+
suffix += 1;
|
|
216
|
+
}
|
|
217
|
+
used.add(agentKey);
|
|
218
|
+
return { agent, agentKey };
|
|
219
|
+
});
|
|
220
|
+
const warnings = [];
|
|
221
|
+
for (const candidateKey of [...candidateCounts.keys()].sort()) {
|
|
222
|
+
if ((candidateCounts.get(candidateKey) ?? 0) < 2)
|
|
223
|
+
continue;
|
|
224
|
+
warnings.push({
|
|
225
|
+
code: "duplicate-agent-key",
|
|
226
|
+
agentKey: candidateKey,
|
|
227
|
+
message: `Multiple agents use ${candidateKey}; kept each with a local identity.`,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
for (const { agent, agentKey } of assigned) {
|
|
231
|
+
if (!agent.extractionFailed)
|
|
232
|
+
continue;
|
|
233
|
+
warnings.push({
|
|
234
|
+
code: "inventory-extraction-failed",
|
|
235
|
+
agentKey,
|
|
236
|
+
message: `Could not inspect ${agent.label}; using its local identity.`,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
const agents = assigned
|
|
240
|
+
.map(({ agent, agentKey }) => ({
|
|
241
|
+
agentKey,
|
|
242
|
+
definitionId: agent.definitionId,
|
|
243
|
+
definitionSlug: agent.definitionSlug,
|
|
244
|
+
label: agent.label,
|
|
245
|
+
resolutionAliases: agent.resolutionAliases,
|
|
246
|
+
sourceRoot: agent.sourceRoot,
|
|
247
|
+
}))
|
|
248
|
+
.sort((left, right) => left.agentKey.localeCompare(right.agentKey) ||
|
|
249
|
+
left.sourceRoot.localeCompare(right.sourceRoot));
|
|
250
|
+
warnings.sort(warningOrder);
|
|
251
|
+
return {
|
|
252
|
+
agents,
|
|
253
|
+
cacheable: prepared.every((agent) => !agent.extractionFailed),
|
|
254
|
+
warnings,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
async prepareAgent(workflow, sourceRoot, fallbackKey) {
|
|
258
|
+
const definitionSlug = normalizedAlias(workflow.definitionSlug);
|
|
259
|
+
let manifestName = null;
|
|
260
|
+
let extractionFailed = false;
|
|
261
|
+
if (!definitionSlug && this.options.inspectManifestName) {
|
|
262
|
+
try {
|
|
263
|
+
const inspected = await this.options.inspectManifestName(sourceRoot);
|
|
264
|
+
if (inspected.status === "found") {
|
|
265
|
+
manifestName = normalizedAlias(inspected.name);
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
extractionFailed = inspected.status === "failed";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
extractionFailed = true;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const candidateKey = definitionSlug ?? manifestName ?? fallbackKey;
|
|
276
|
+
// Keep the pre-disambiguation candidate as an alias for every copy. When
|
|
277
|
+
// duplicate local fallbacks exist, a caller targeting that candidate must
|
|
278
|
+
// see ambiguity rather than silently resolving to the unsuffixed copy.
|
|
279
|
+
const resolutionAliases = uniqueAliases([
|
|
280
|
+
definitionSlug,
|
|
281
|
+
manifestName,
|
|
282
|
+
candidateKey,
|
|
283
|
+
]);
|
|
284
|
+
return {
|
|
285
|
+
candidateKey,
|
|
286
|
+
fallbackKey,
|
|
287
|
+
definitionId: workflow.definitionId,
|
|
288
|
+
definitionSlug,
|
|
289
|
+
extractionFailed,
|
|
290
|
+
label: safeLabel(workflow.name, definitionSlug ??
|
|
291
|
+
manifestName ??
|
|
292
|
+
(fallbackKey.slice("local:".length) || "Local agent")),
|
|
293
|
+
resolutionAliases,
|
|
294
|
+
sourceRoot,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
prepareFallbackAgent(workflow, sourceRoot, fallbackKey) {
|
|
298
|
+
const definitionSlug = normalizedAlias(workflow.definitionSlug);
|
|
299
|
+
const candidateKey = definitionSlug ?? fallbackKey;
|
|
300
|
+
return {
|
|
301
|
+
candidateKey,
|
|
302
|
+
fallbackKey,
|
|
303
|
+
definitionId: workflow.definitionId,
|
|
304
|
+
definitionSlug,
|
|
305
|
+
extractionFailed: !definitionSlug,
|
|
306
|
+
label: safeLabel(workflow.name, definitionSlug ?? (fallbackKey.slice("local:".length) || "Local agent")),
|
|
307
|
+
resolutionAliases: [candidateKey],
|
|
308
|
+
sourceRoot,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
//# sourceMappingURL=system-graph-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-inventory.js","sourceRoot":"","sources":["../../src/core/system-graph-inventory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,yBAAyB,GAI1B,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAoDtE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAC1C,+EAA+E;AAC/E,MAAM,6BAA6B,GAAG,IAAK,CAAC;AAE5C,KAAK,UAAU,eAAe,CAC5B,MAAwB,EACxB,WAAmB,EACnB,QAAgB,EAChB,GAAsC;IAEtC,MAAM,OAAO,GAAG,IAAI,KAAK,CAAqB,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7D,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,eAAe,GAAG,KAAK,CAAC;IAC5B,MAAM,MAAM,GAAG,KAAK,IAAmB,EAAE;QACvC,OAAO,CAAC,eAAe,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;YACrD,MAAM,KAAK,GAAG,SAAS,CAAC;YACxB,SAAS,IAAI,CAAC,CAAC;YACf,IAAI,CAAC;gBACH,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,KAAK,CAAE,CAAC,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,wEAAwE;YAC1E,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CACzB,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,K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AK,EAAE,SAAS,CACd,QAAQ,CAAC,IAAI,EACb,cAAc,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,CACxE;YACD,iBAAiB,EAAE,CAAC,YAAY,CAAC;YACjC,UAAU;SACX,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type AgentInvocationDetectionWarning, type AgentInvocationMode, type SourceEvidence } from "./canvas-interconnections.js";
|
|
2
|
+
import type { AgentInventoryItem } from "./system-graph-inventory.js";
|
|
3
|
+
export interface AgentRelationshipCandidate {
|
|
4
|
+
/** Inventory key or definition slug to resolve after extraction. */
|
|
5
|
+
target: string;
|
|
6
|
+
mode: AgentInvocationMode;
|
|
7
|
+
/** Internal-only evidence retained across callsite deduplication. */
|
|
8
|
+
evidence: SourceEvidence[];
|
|
9
|
+
}
|
|
10
|
+
export type AgentRelationshipWarning = AgentInvocationDetectionWarning;
|
|
11
|
+
export interface AgentRelationshipProviderResult {
|
|
12
|
+
relationships: AgentRelationshipCandidate[];
|
|
13
|
+
warnings: AgentRelationshipWarning[];
|
|
14
|
+
}
|
|
15
|
+
/** Replaceable per-caller boundary consumed by the workspace graph projector. */
|
|
16
|
+
export interface AgentRelationshipProvider {
|
|
17
|
+
listRelationships(caller: AgentInventoryItem): Promise<AgentRelationshipProviderResult>;
|
|
18
|
+
/** Optional lifecycle hook for providers that retain per-caller state. */
|
|
19
|
+
retainCallers?(callers: readonly AgentInventoryItem[]): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Successful per-caller relationship extraction behind the same cheap source
|
|
23
|
+
* fingerprint used by Canvas. Projection can therefore rebuild against a new
|
|
24
|
+
* inventory without re-walking unchanged caller trees.
|
|
25
|
+
*/
|
|
26
|
+
export declare class CachedAgentRelationshipProvider implements AgentRelationshipProvider {
|
|
27
|
+
private readonly inner;
|
|
28
|
+
private readonly fingerprint;
|
|
29
|
+
private readonly entries;
|
|
30
|
+
constructor(inner?: AgentRelationshipProvider, fingerprint?: (sourceRoot: string) => Promise<string>);
|
|
31
|
+
listRelationships(caller: AgentInventoryItem): Promise<AgentRelationshipProviderResult>;
|
|
32
|
+
invalidateSource(sourceRoot: string): void;
|
|
33
|
+
retainCallers(callers: readonly AgentInventoryItem[]): void;
|
|
34
|
+
clear(): void;
|
|
35
|
+
}
|
|
36
|
+
/** V0 filesystem adapter. It remains syntax-only and has no inventory target
|
|
37
|
+
* resolution, renderer, transport, deployment, or session dependencies. */
|
|
38
|
+
export declare class SourceAgentRelationshipProvider implements AgentRelationshipProvider {
|
|
39
|
+
listRelationships(caller: AgentInventoryItem): Promise<AgentRelationshipProviderResult>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=system-graph-relationships.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-relationships.d.ts","sourceRoot":"","sources":["../../src/core/system-graph-relationships.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,+BAA+B,EACpC,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,WAAW,0BAA0B;IACzC,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,mBAAmB,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,CAAC;AAEvE,MAAM,WAAW,+BAA+B;IAC9C,aAAa,EAAE,0BAA0B,EAAE,CAAC;IAC5C,QAAQ,EAAE,wBAAwB,EAAE,CAAC;CACtC;AAED,iFAAiF;AACjF,MAAM,WAAW,yBAAyB;IACxC,iBAAiB,CACf,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,+BAA+B,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,aAAa,CAAC,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GAAG,IAAI,CAAC;CAC9D;AAOD;;;;GAIG;AACH,qBAAa,+BACX,YAAW,yBAAyB;IAKlC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAJ9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8C;gBAGnD,KAAK,GAAE,yBAAiE,EACxE,WAAW,GAAE,CAC5B,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,MAAM,CAA8B;IAG7C,iBAAiB,CACrB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,+BAA+B,CAAC;IA2B3C,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI1C,aAAa,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,GAAG,IAAI;IAS3D,KAAK,IAAI,IAAI;CAGd;AAeD;2EAC2E;AAC3E,qBAAa,+BAAgC,YAAW,yBAAyB;IACzE,iBAAiB,CACrB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,+BAA+B,CAAC;CAiC5C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
import { detectAgentInvocations, } from "./canvas-interconnections.js";
|
|
3
|
+
import { fingerprintWorkflowSources } from "./canvas-cache.js";
|
|
4
|
+
/**
|
|
5
|
+
* Successful per-caller relationship extraction behind the same cheap source
|
|
6
|
+
* fingerprint used by Canvas. Projection can therefore rebuild against a new
|
|
7
|
+
* inventory without re-walking unchanged caller trees.
|
|
8
|
+
*/
|
|
9
|
+
export class CachedAgentRelationshipProvider {
|
|
10
|
+
constructor(inner = new SourceAgentRelationshipProvider(), fingerprint = fingerprintWorkflowSources) {
|
|
11
|
+
this.inner = inner;
|
|
12
|
+
this.fingerprint = fingerprint;
|
|
13
|
+
this.entries = new Map();
|
|
14
|
+
}
|
|
15
|
+
async listRelationships(caller) {
|
|
16
|
+
const key = path.resolve(caller.sourceRoot);
|
|
17
|
+
let fingerprint;
|
|
18
|
+
try {
|
|
19
|
+
fingerprint = await this.fingerprint(key);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
this.entries.delete(key);
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
const hit = this.entries.get(key);
|
|
26
|
+
if (hit?.fingerprint === fingerprint)
|
|
27
|
+
return hit.result;
|
|
28
|
+
let result;
|
|
29
|
+
try {
|
|
30
|
+
result = Promise.resolve(this.inner.listRelationships(caller));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
result = Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
const entry = { fingerprint, result };
|
|
36
|
+
this.entries.set(key, entry);
|
|
37
|
+
void result.catch(() => {
|
|
38
|
+
if (this.entries.get(key) === entry)
|
|
39
|
+
this.entries.delete(key);
|
|
40
|
+
});
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
invalidateSource(sourceRoot) {
|
|
44
|
+
this.entries.delete(path.resolve(sourceRoot));
|
|
45
|
+
}
|
|
46
|
+
retainCallers(callers) {
|
|
47
|
+
const retained = new Set(callers.map((caller) => path.resolve(caller.sourceRoot)));
|
|
48
|
+
for (const sourceRoot of this.entries.keys()) {
|
|
49
|
+
if (!retained.has(sourceRoot))
|
|
50
|
+
this.entries.delete(sourceRoot);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
clear() {
|
|
54
|
+
this.entries.clear();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function evidenceOrder(left, right) {
|
|
58
|
+
return (left.file.localeCompare(right.file) ||
|
|
59
|
+
left.line - right.line ||
|
|
60
|
+
left.column - right.column);
|
|
61
|
+
}
|
|
62
|
+
const MODE_ORDER = {
|
|
63
|
+
blocking: 0,
|
|
64
|
+
async: 1,
|
|
65
|
+
};
|
|
66
|
+
/** V0 filesystem adapter. It remains syntax-only and has no inventory target
|
|
67
|
+
* resolution, renderer, transport, deployment, or session dependencies. */
|
|
68
|
+
export class SourceAgentRelationshipProvider {
|
|
69
|
+
async listRelationships(caller) {
|
|
70
|
+
const scan = await detectAgentInvocations(caller.sourceRoot, new Set());
|
|
71
|
+
const grouped = new Map();
|
|
72
|
+
for (const invocation of scan.invocations) {
|
|
73
|
+
const key = `${invocation.slug}\0${invocation.mode}`;
|
|
74
|
+
const relationship = grouped.get(key);
|
|
75
|
+
if (relationship) {
|
|
76
|
+
relationship.evidence.push(invocation.evidence);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
grouped.set(key, {
|
|
80
|
+
target: invocation.slug,
|
|
81
|
+
mode: invocation.mode,
|
|
82
|
+
evidence: [invocation.evidence],
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const relationships = [...grouped.values()];
|
|
87
|
+
for (const relationship of relationships) {
|
|
88
|
+
relationship.evidence.sort(evidenceOrder);
|
|
89
|
+
}
|
|
90
|
+
relationships.sort((left, right) => left.evidence[0].file.localeCompare(right.evidence[0].file) ||
|
|
91
|
+
left.evidence[0].line - right.evidence[0].line ||
|
|
92
|
+
left.evidence[0].column - right.evidence[0].column ||
|
|
93
|
+
MODE_ORDER[left.mode] - MODE_ORDER[right.mode] ||
|
|
94
|
+
left.target.localeCompare(right.target));
|
|
95
|
+
return { relationships, warnings: scan.warnings };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=system-graph-relationships.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-graph-relationships.js","sourceRoot":"","sources":["../../src/core/system-graph-relationships.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,sBAAsB,GAIvB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAgC/D;;;;GAIG;AACH,M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