@gt-fe/eap-sdk 0.1.13 → 0.2.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/README.md +452 -376
- package/dist/lockfile/resolve-dependencies.d.ts +1 -0
- package/dist/lockfile/resolve-dependencies.d.ts.map +1 -1
- package/dist/lockfile/resolve-dependencies.js +3 -0
- package/dist/lockfile/resolve-dependencies.js.map +1 -1
- package/dist/materialization/copy-resource-directory.d.ts +1 -0
- package/dist/materialization/copy-resource-directory.d.ts.map +1 -1
- package/dist/materialization/copy-resource-directory.js +38 -1
- package/dist/materialization/copy-resource-directory.js.map +1 -1
- package/dist/materialization/index.d.ts +1 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/index.js +1 -1
- package/dist/materialization/index.js.map +1 -1
- package/dist/materialization/load-agent-runtime.d.ts +19 -0
- package/dist/materialization/load-agent-runtime.d.ts.map +1 -0
- package/dist/materialization/load-agent-runtime.js +128 -0
- package/dist/materialization/load-agent-runtime.js.map +1 -0
- package/dist/materialization/prepare-agent-runtime.d.ts +6 -0
- package/dist/materialization/prepare-agent-runtime.d.ts.map +1 -1
- package/dist/materialization/prepare-agent-runtime.js +108 -46
- package/dist/materialization/prepare-agent-runtime.js.map +1 -1
- package/dist/materialization/types.d.ts +0 -2
- package/dist/materialization/types.d.ts.map +1 -1
- package/dist/packaging/package-agent-project.d.ts.map +1 -1
- package/dist/packaging/package-agent-project.js +2 -4
- package/dist/packaging/package-agent-project.js.map +1 -1
- package/dist/packaging/read-package.d.ts.map +1 -1
- package/dist/packaging/read-package.js +20 -1
- package/dist/packaging/read-package.js.map +1 -1
- package/dist/platform/client.d.ts.map +1 -1
- package/dist/platform/client.js +13 -2
- package/dist/platform/client.js.map +1 -1
- package/dist/platform/types.d.ts +2 -0
- package/dist/platform/types.d.ts.map +1 -1
- package/dist/project/agent-project.d.ts.map +1 -1
- package/dist/project/agent-project.js +10 -0
- package/dist/project/agent-project.js.map +1 -1
- package/dist/resources/configured-local-resources.d.ts +15 -0
- package/dist/resources/configured-local-resources.d.ts.map +1 -0
- package/dist/resources/configured-local-resources.js +75 -0
- package/dist/resources/configured-local-resources.js.map +1 -0
- package/dist/resources/install-agent-dependencies.d.ts.map +1 -1
- package/dist/resources/install-agent-dependencies.js +7 -2
- package/dist/resources/install-agent-dependencies.js.map +1 -1
- package/dist/schema/agent/manifest.d.ts +832 -197
- package/dist/schema/agent/manifest.d.ts.map +1 -1
- package/dist/schema/graph.d.ts +1295 -403
- package/dist/schema/graph.d.ts.map +1 -1
- package/dist/schema/graph.js +29 -16
- package/dist/schema/graph.js.map +1 -1
- package/dist/schema/lockfile.d.ts +30 -30
- package/dist/schema/project-config.d.ts +6 -0
- package/dist/schema/project-config.d.ts.map +1 -1
- package/dist/schema/project-config.js +4 -0
- package/dist/schema/project-config.js.map +1 -1
- package/dist/service/create-agent.d.ts +8 -0
- package/dist/service/create-agent.d.ts.map +1 -0
- package/dist/service/create-agent.js +338 -0
- package/dist/service/create-agent.js.map +1 -0
- package/dist/service/events.d.ts +14 -45
- package/dist/service/events.d.ts.map +1 -1
- package/dist/service/events.js +46 -1
- package/dist/service/events.js.map +1 -1
- package/dist/service/index.d.ts +5 -2
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/index.js +4 -1
- package/dist/service/index.js.map +1 -1
- package/dist/service/messages.d.ts +13 -0
- package/dist/service/messages.d.ts.map +1 -0
- package/dist/service/messages.js +24 -0
- package/dist/service/messages.js.map +1 -0
- package/dist/service/resources.d.ts +86 -0
- package/dist/service/resources.d.ts.map +1 -0
- package/dist/service/resources.js +26 -0
- package/dist/service/resources.js.map +1 -0
- package/dist/service/runtime-adapter.d.ts.map +1 -1
- package/dist/service/runtime-adapter.js +26 -2
- package/dist/service/runtime-adapter.js.map +1 -1
- package/dist/service/sessions.d.ts +33 -0
- package/dist/service/sessions.d.ts.map +1 -0
- package/dist/service/sessions.js +67 -0
- package/dist/service/sessions.js.map +1 -0
- package/dist/service/types.d.ts +121 -32
- package/dist/service/types.d.ts.map +1 -1
- package/dist/validation/validate-agent-project.d.ts.map +1 -1
- package/dist/validation/validate-agent-project.js +31 -17
- package/dist/validation/validate-agent-project.js.map +1 -1
- package/package.json +4 -4
- package/dist/materialization/sync-author-resources.d.ts +0 -21
- package/dist/materialization/sync-author-resources.d.ts.map +0 -1
- package/dist/materialization/sync-author-resources.js +0 -98
- package/dist/materialization/sync-author-resources.js.map +0 -1
- package/dist/service/create-agent-service.d.ts +0 -12
- package/dist/service/create-agent-service.d.ts.map +0 -1
- package/dist/service/create-agent-service.js +0 -283
- package/dist/service/create-agent-service.js.map +0 -1
- package/dist/service/http-server.d.ts +0 -4
- package/dist/service/http-server.d.ts.map +0 -1
- package/dist/service/http-server.js +0 -89
- package/dist/service/http-server.js.map +0 -1
|
@@ -14,6 +14,7 @@ export declare function resolveLockedResources(options: {
|
|
|
14
14
|
root: string;
|
|
15
15
|
manifest: AgentManifest;
|
|
16
16
|
lock: EapLock;
|
|
17
|
+
availableLocalResources?: Partial<Record<MaterializedResourceKind, ReadonlySet<string>>>;
|
|
17
18
|
}): ResolvedLockedResource[];
|
|
18
19
|
export declare function findUndeclaredLockedResources(manifest: AgentManifest, lock: EapLock): Array<LockResource & {
|
|
19
20
|
kind: MaterializedResourceKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-dependencies.d.ts","sourceRoot":"","sources":["../../src/lockfile/resolve-dependencies.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgC,KAAK,aAAa,EAAE,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvH,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEnF,qBAAa,6BAA8B,SAAQ,KAAK;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAC;QAAC,IAAI,EAAE,MAAM,CA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,CAM1D;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,wBAAwB,GAC7B,MAAM,EAAE,CAQV"}
|
|
@@ -16,6 +16,9 @@ export function resolveLockedResources(options) {
|
|
|
16
16
|
for (const kind of ['tools', 'skills']) {
|
|
17
17
|
for (const code of declaredResourceCodes(options.manifest, kind)) {
|
|
18
18
|
const entries = options.lock.resources[kind].filter((entry) => entry.code === code);
|
|
19
|
+
const availableFromConfig = options.availableLocalResources?.[kind]?.has(code) === true;
|
|
20
|
+
if (availableFromConfig)
|
|
21
|
+
continue;
|
|
19
22
|
if (entries.length === 0 && kind === 'skills' && findLocalSkillEntryFile(resolve(root, 'skills', code))) {
|
|
20
23
|
continue;
|
|
21
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-dependencies.js","sourceRoot":"","sources":["../../src/lockfile/resolve-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,4BAA4B,EAAuD,MAAM,oBAAoB,CAAC;AACvH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IAChB;IAAtC,YAAY,OAAe,EAAW,QAA2D;QAC/F,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,aAAQ,GAAR,QAAQ,CAAmD;QAE/F,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,MAAM,UAAU,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"resolve-dependencies.js","sourceRoot":"","sources":["../../src/lockfile/resolve-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YA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
|
|
1
|
+
{"version":3,"file":"copy-resource-directory.d.ts","sourceRoot":"","sources":["../../src/materialization/copy-resource-directory.ts"],"names":[],"mappings":"AAMA,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAM/E;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQ9D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { copyFileSync, lstatSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
3
|
import { basename, relative, resolve } from 'node:path';
|
|
3
4
|
const EXCLUDED_DIRECTORY_NAMES = new Set(['.git', '.eap', 'node_modules', 'coverage']);
|
|
4
5
|
export function copyResourceDirectory(source, destination) {
|
|
@@ -8,6 +9,15 @@ export function copyResourceDirectory(source, destination) {
|
|
|
8
9
|
}
|
|
9
10
|
copyDirectory(source, destination, source);
|
|
10
11
|
}
|
|
12
|
+
export function resourceDirectoryDigest(source) {
|
|
13
|
+
const sourceStat = lstatSync(source);
|
|
14
|
+
if (!sourceStat.isDirectory() || sourceStat.isSymbolicLink()) {
|
|
15
|
+
throw new Error(`Resource source must be a regular directory: ${source}`);
|
|
16
|
+
}
|
|
17
|
+
const hash = createHash('sha256');
|
|
18
|
+
digestDirectory(source, source, hash);
|
|
19
|
+
return hash.digest('hex');
|
|
20
|
+
}
|
|
11
21
|
function copyDirectory(source, destination, root) {
|
|
12
22
|
const stat = lstatSync(source);
|
|
13
23
|
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
@@ -31,7 +41,34 @@ function copyDirectory(source, destination, root) {
|
|
|
31
41
|
copyFileSync(sourcePath, targetPath);
|
|
32
42
|
}
|
|
33
43
|
}
|
|
44
|
+
function digestDirectory(source, root, hash) {
|
|
45
|
+
const stat = lstatSync(source);
|
|
46
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
47
|
+
throw new Error(`Resource path must be a regular directory: ${source}`);
|
|
48
|
+
}
|
|
49
|
+
const directoryPath = relative(root, source).replace(/\\/g, '/');
|
|
50
|
+
hash.update(`directory:${directoryPath}\0`);
|
|
51
|
+
for (const entry of readdirSync(source, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
52
|
+
if (shouldExclude(entry.name, entry.isDirectory()))
|
|
53
|
+
continue;
|
|
54
|
+
const sourcePath = resolve(source, entry.name);
|
|
55
|
+
assertDescendant(root, sourcePath);
|
|
56
|
+
if (entry.isSymbolicLink())
|
|
57
|
+
throw new Error(`Resource directory must not contain symbolic links: ${sourcePath}`);
|
|
58
|
+
if (entry.isDirectory()) {
|
|
59
|
+
digestDirectory(sourcePath, root, hash);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (!entry.isFile())
|
|
63
|
+
throw new Error(`Resource directory contains an unsupported entry: ${sourcePath}`);
|
|
64
|
+
hash.update(`file:${relative(root, sourcePath).replace(/\\/g, '/')}\0`);
|
|
65
|
+
hash.update(readFileSync(sourcePath));
|
|
66
|
+
hash.update('\0');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
34
69
|
function shouldExclude(name, isDirectory) {
|
|
70
|
+
if (name === '.ready')
|
|
71
|
+
return true;
|
|
35
72
|
if (name === '.env' || name.startsWith('.env.'))
|
|
36
73
|
return true;
|
|
37
74
|
if (name.endsWith('.tmp') || name.startsWith('.tmp'))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-resource-directory.js","sourceRoot":"","sources":["../../src/materialization/copy-resource-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"copy-resource-directory.js","sourceRoot":"","sources":["../../src/materialization/copy-resource-directory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,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,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,WAAoB;IACvD,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC7D,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAClE,OAAO,WAAW,IAAI,wBAAwB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,IAAY;IAClD,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1C,IAAI,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/F,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,EAAE,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/materialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/materialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/materialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/materialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type LoadedProjectRuntimeConfig } from '../config/index.js';
|
|
2
|
+
import { type EapLock } from '../schema/index.js';
|
|
3
|
+
import type { PreparedAgentRuntime } from './types.js';
|
|
4
|
+
export interface LoadAgentRuntimeOptions {
|
|
5
|
+
runtimeRoot?: string;
|
|
6
|
+
agentCode?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface LoadedAgentRuntime extends PreparedAgentRuntime {
|
|
10
|
+
manifestPath: string;
|
|
11
|
+
graphPath: string;
|
|
12
|
+
configPath: string;
|
|
13
|
+
lockPath: string;
|
|
14
|
+
config: LoadedProjectRuntimeConfig['config'];
|
|
15
|
+
lock: EapLock;
|
|
16
|
+
}
|
|
17
|
+
/** Loads and verifies the immutable project inputs in a materialized Runtime tree. */
|
|
18
|
+
export declare function loadAgentRuntime(options?: LoadAgentRuntimeOptions): LoadedAgentRuntime;
|
|
19
|
+
//# sourceMappingURL=load-agent-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-agent-runtime.d.ts","sourceRoot":"","sources":["../../src/materialization/load-agent-runtime.ts"],"names":[],"mappings":"AAGA,OAAO,EAA4B,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAI/F,OAAO,EAIL,KAAK,OAAO,EACb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAcvD,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,0BAA0B,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,EAAE,OAAO,CAAC;CACf;AAED,sFAAsF;AACtF,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,kBAAkB,CA2D1F"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { lstatSync, readFileSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { loadProjectRuntimeConfig } from '../config/index.js';
|
|
4
|
+
import { toSha256Hex } from '../digest.js';
|
|
5
|
+
import { readEapLock } from '../lockfile/index.js';
|
|
6
|
+
import { sha256 } from '../resources/resource-files.js';
|
|
7
|
+
import { AgentManifestSchema, DependenciesLockSchema, GraphSchema, } from '../schema/index.js';
|
|
8
|
+
import { resolveAgentRuntimeRoot } from './prepare-agent-runtime.js';
|
|
9
|
+
const REQUIRED_RUNTIME_ARTIFACTS = [
|
|
10
|
+
'agent.manifest.json',
|
|
11
|
+
'graph.json',
|
|
12
|
+
'eap.config.json',
|
|
13
|
+
'eap.lock.yaml',
|
|
14
|
+
'dependencies.lock',
|
|
15
|
+
];
|
|
16
|
+
/** Loads and verifies the immutable project inputs in a materialized Runtime tree. */
|
|
17
|
+
export function loadAgentRuntime(options = {}) {
|
|
18
|
+
const runtimeRoot = assertRegularDirectory(resolveAgentRuntimeRoot({ runtimeRoot: options.runtimeRoot }), 'Runtime root');
|
|
19
|
+
const agentsRoot = assertRegularDirectory(resolve(runtimeRoot, 'agents'), 'Runtime agents directory');
|
|
20
|
+
const agentCode = options.agentCode ?? selectOnlyDirectory(agentsRoot, 'Agent code');
|
|
21
|
+
assertDirectorySegment(agentCode, 'Agent code');
|
|
22
|
+
const agentRoot = assertRegularDirectory(resolve(agentsRoot, agentCode), `Agent directory ${agentCode}`);
|
|
23
|
+
const version = options.version ?? selectOnlyDirectory(agentRoot, 'Agent version');
|
|
24
|
+
assertDirectorySegment(version, 'Agent version');
|
|
25
|
+
const agentDir = assertRegularDirectory(resolve(agentRoot, version), `Agent version directory ${agentCode}@${version}`);
|
|
26
|
+
const artifactPaths = new Map(REQUIRED_RUNTIME_ARTIFACTS.map((name) => [
|
|
27
|
+
name,
|
|
28
|
+
assertRegularFile(resolve(agentDir, name), `Runtime ${name}`),
|
|
29
|
+
]));
|
|
30
|
+
assertRegularFile(resolve(agentDir, 'snapshot.json'), 'Runtime snapshot');
|
|
31
|
+
assertRegularFile(resolve(agentDir, '.ready'), 'Runtime readiness marker');
|
|
32
|
+
const manifestPath = artifactPaths.get('agent.manifest.json');
|
|
33
|
+
const graphPath = artifactPaths.get('graph.json');
|
|
34
|
+
const configPath = artifactPaths.get('eap.config.json');
|
|
35
|
+
const lockPath = artifactPaths.get('eap.lock.yaml');
|
|
36
|
+
const manifest = AgentManifestSchema.parse(readJson(manifestPath, 'Runtime Agent manifest'));
|
|
37
|
+
if (manifest.code !== agentCode || manifest.version !== version) {
|
|
38
|
+
throw new Error(`Runtime Agent identity does not match ${agentCode}@${version}`);
|
|
39
|
+
}
|
|
40
|
+
GraphSchema.parse(readJson(graphPath, 'Runtime Graph'));
|
|
41
|
+
const dependencies = DependenciesLockSchema.parse(readJson(artifactPaths.get('dependencies.lock'), 'Runtime dependencies lock'));
|
|
42
|
+
if (dependencies.agentCode && dependencies.agentCode !== agentCode) {
|
|
43
|
+
throw new Error(`Runtime dependencies.lock Agent identity does not match ${agentCode}`);
|
|
44
|
+
}
|
|
45
|
+
if (dependencies.agentVersion && dependencies.agentVersion !== version) {
|
|
46
|
+
throw new Error(`Runtime dependencies.lock version does not match ${version}`);
|
|
47
|
+
}
|
|
48
|
+
const loadedConfig = loadProjectRuntimeConfig({ root: agentDir });
|
|
49
|
+
const lock = readEapLock(agentDir);
|
|
50
|
+
if (!lock)
|
|
51
|
+
throw new Error(`Runtime eap.lock.yaml is missing: ${lockPath}`);
|
|
52
|
+
verifySnapshotArtifacts(agentDir, artifactPaths);
|
|
53
|
+
return {
|
|
54
|
+
projectRoot: runtimeRoot,
|
|
55
|
+
runtimeRoot,
|
|
56
|
+
agentDir,
|
|
57
|
+
agentCode,
|
|
58
|
+
version,
|
|
59
|
+
resources: [],
|
|
60
|
+
manifestPath,
|
|
61
|
+
graphPath,
|
|
62
|
+
configPath,
|
|
63
|
+
lockPath,
|
|
64
|
+
config: loadedConfig.config,
|
|
65
|
+
lock,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function verifySnapshotArtifacts(agentDir, artifactPaths) {
|
|
69
|
+
const snapshot = readJson(resolve(agentDir, 'snapshot.json'), 'Runtime snapshot');
|
|
70
|
+
if (!Array.isArray(snapshot.artifacts))
|
|
71
|
+
throw new Error('Runtime snapshot artifacts are invalid');
|
|
72
|
+
const digests = new Map(snapshot.artifacts
|
|
73
|
+
.filter((artifact) => (typeof artifact.path === 'string' && typeof artifact.sha256 === 'string'))
|
|
74
|
+
.map((artifact) => [artifact.path, artifact.sha256]));
|
|
75
|
+
for (const [name, path] of artifactPaths) {
|
|
76
|
+
const expected = toSha256Hex(sha256(readFileSync(path)));
|
|
77
|
+
if (digests.get(name) !== expected) {
|
|
78
|
+
throw new Error(`Runtime snapshot digest does not match ${name}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function selectOnlyDirectory(parent, label) {
|
|
83
|
+
const directories = readdirSync(parent, { withFileTypes: true })
|
|
84
|
+
.filter((entry) => entry.isDirectory())
|
|
85
|
+
.map((entry) => entry.name)
|
|
86
|
+
.sort((left, right) => left.localeCompare(right));
|
|
87
|
+
if (directories.length !== 1)
|
|
88
|
+
throw new Error(`Runtime requires exactly one ${label}; found ${directories.length}`);
|
|
89
|
+
return directories[0];
|
|
90
|
+
}
|
|
91
|
+
function assertRegularDirectory(path, label) {
|
|
92
|
+
let stat;
|
|
93
|
+
try {
|
|
94
|
+
stat = lstatSync(path);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
throw new Error(`${label} is missing: ${path}`);
|
|
98
|
+
}
|
|
99
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
100
|
+
throw new Error(`${label} must be a regular directory: ${path}`);
|
|
101
|
+
return path;
|
|
102
|
+
}
|
|
103
|
+
function assertRegularFile(path, label) {
|
|
104
|
+
let stat;
|
|
105
|
+
try {
|
|
106
|
+
stat = lstatSync(path);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
throw new Error(`${label} is missing: ${path}`);
|
|
110
|
+
}
|
|
111
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
112
|
+
throw new Error(`${label} must be a regular file: ${path}`);
|
|
113
|
+
return path;
|
|
114
|
+
}
|
|
115
|
+
function assertDirectorySegment(value, label) {
|
|
116
|
+
if (!value || value === '.' || value === '..' || /[\\/]/.test(value))
|
|
117
|
+
throw new Error(`${label} is not valid: ${value}`);
|
|
118
|
+
}
|
|
119
|
+
function readJson(path, label) {
|
|
120
|
+
try {
|
|
121
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
125
|
+
throw new Error(`${label} is not valid JSON: ${path} (${reason})`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=load-agent-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-agent-runtime.js","sourceRoot":"","sources":["../../src/materialization/load-agent-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,wBAAwB,EAAmC,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAGrE,MAAM,0BAA0B,GAAG;IACjC,qBAAqB;IACrB,YAAY;IACZ,iBAAiB;IACjB,eAAe;IACf,mBAAmB;CACX,CAAC;AAqBX,sFAAsF;AACtF,MAAM,UAAU,gBAAgB,CAAC,UAAmC,EAAE;IACpE,MAAM,WAAW,GAAG,sBAAsB,CACxC,uBAAuB,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,EAC7D,cAAc,CACf,CAAC;IACF,MAAM,UAAU,GAAG,sBAAsB,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,0BAA0B,CAAC,CAAC;IACtG,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,mBAAmB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IACrF,sBAAsB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAChD,MAA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AAC,CAAC;AAC3H,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,KAAa;IAC3C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,uBAAuB,IAAI,KAAK,MAAM,GAAG,CAAC,CAAC;IACrE,CAAC;AACH,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { PrepareAgentRuntimeOptions, PreparedAgentRuntime } from './types.js';
|
|
2
2
|
export declare function prepareAgentRuntime(options?: PrepareAgentRuntimeOptions): Promise<PreparedAgentRuntime>;
|
|
3
|
+
export declare function resolveAgentRuntimeRoot(options?: {
|
|
4
|
+
root?: string;
|
|
5
|
+
runtimeRoot?: string;
|
|
6
|
+
env?: NodeJS.ProcessEnv;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
}): string;
|
|
3
9
|
//# sourceMappingURL=prepare-agent-runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-agent-runtime.d.ts","sourceRoot":"","sources":["../../src/materialization/prepare-agent-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prepare-agent-runtime.d.ts","sourceRoot":"","sources":["../../src/materialization/prepare-agent-runtime.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAiCnF,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,oBAAoB,CAAC,CA6E/B;AAkGD,wBAAgB,uBAAuB,CAAC,OAAO,GAAE;IAC/C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACT,GAAG,MAAM,CAKd"}
|
|
@@ -2,26 +2,44 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import { copyFileSync, existsSync, lstatSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { dirname, relative, resolve, sep } from 'node:path';
|
|
4
4
|
import { toSha256Hex } from '../digest.js';
|
|
5
|
+
import { loadProjectRuntimeConfig } from '../config/index.js';
|
|
5
6
|
import { resolveAgentProject } from '../discovery/index.js';
|
|
6
7
|
import { readEapLock, resolveLockedResources } from '../lockfile/index.js';
|
|
7
8
|
import { validateAgentProject } from '../validation/index.js';
|
|
8
9
|
import { DependenciesLockSchema } from '../schema/index.js';
|
|
10
|
+
import { configuredLocalResourceCodes, discoverConfiguredLocalResources, } from '../resources/configured-local-resources.js';
|
|
9
11
|
import { ensureGeneratedDirectory, ensureGeneratedDirectoryPath, removeDirectoryChild, sha256, validateDirectoryChild, } from '../resources/resource-files.js';
|
|
10
|
-
import { copyResourceDirectory } from './copy-resource-directory.js';
|
|
12
|
+
import { copyResourceDirectory, resourceDirectoryDigest } from './copy-resource-directory.js';
|
|
13
|
+
const RUNTIME_SOURCE_ARTIFACTS = [
|
|
14
|
+
'agent.manifest.json',
|
|
15
|
+
'graph.json',
|
|
16
|
+
'eap.config.json',
|
|
17
|
+
'eap.lock.yaml',
|
|
18
|
+
];
|
|
11
19
|
export async function prepareAgentRuntime(options = {}) {
|
|
12
20
|
const project = resolveAgentProject(options.root ? { root: options.root } : {});
|
|
13
|
-
const
|
|
14
|
-
const destination = resolveRuntimeDestination(project.root, mode, options.outputRoot);
|
|
21
|
+
const destination = resolveRuntimeDestination(project.root, options.outputRoot);
|
|
15
22
|
const validation = validateAgentProject(project.root);
|
|
16
23
|
if (!validation.valid || !validation.agent) {
|
|
17
24
|
const message = validation.issues.map((issue) => issue.message).join('; ');
|
|
18
25
|
throw new Error(`Cannot prepare Agent Runtime: ${message}. Run eap install to restore missing remote resources.`);
|
|
19
26
|
}
|
|
20
27
|
const lock = readEapLock(project.root);
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
if (!lock) {
|
|
29
|
+
throw new Error('Cannot prepare Agent Runtime: eap.lock.yaml is required. Run eap install to create it.');
|
|
30
|
+
}
|
|
31
|
+
const config = loadProjectRuntimeConfig({ root: project.root }).config;
|
|
32
|
+
const configuredLocalResources = discoverConfiguredLocalResources(project.root, config);
|
|
33
|
+
const resources = resolveLockedResources({
|
|
34
|
+
root: project.root,
|
|
35
|
+
manifest: validation.agent.manifest,
|
|
36
|
+
lock,
|
|
37
|
+
availableLocalResources: configuredLocalResourceCodes(configuredLocalResources),
|
|
38
|
+
});
|
|
39
|
+
const runtimeResources = mergeRuntimeResources(resources, configuredLocalResources, validation.agent.manifest);
|
|
40
|
+
const includeDigests = true;
|
|
23
41
|
// Avoid replacing an unchanged Runtime directory that another Windows process may still hold.
|
|
24
|
-
if (canReuseRuntime(destination.runtimeRoot, project,
|
|
42
|
+
if (canReuseRuntime(destination.runtimeRoot, project, runtimeResources, includeDigests)) {
|
|
25
43
|
const reused = {
|
|
26
44
|
projectRoot: project.root,
|
|
27
45
|
runtimeRoot: destination.runtimeRoot,
|
|
@@ -41,9 +59,10 @@ export async function prepareAgentRuntime(options = {}) {
|
|
|
41
59
|
const temporaryRoot = ensureGeneratedDirectoryPath(destination.runtimeParent, [temporaryName]);
|
|
42
60
|
try {
|
|
43
61
|
const agentDir = ensureGeneratedDirectoryPath(temporaryRoot, ['agents', project.agentCode, project.version]);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
for (const artifact of RUNTIME_SOURCE_ARTIFACTS) {
|
|
63
|
+
copyRegularFile(resolve(project.root, artifact), resolve(agentDir, artifact));
|
|
64
|
+
}
|
|
65
|
+
const snapshot = materializeResources(agentDir, runtimeResources, project.agentCode, project.version, includeDigests);
|
|
47
66
|
writeFileSync(resolve(agentDir, 'snapshot.json'), `${JSON.stringify(snapshot, null, 2)}\n`, 'utf8');
|
|
48
67
|
writeFileSync(resolve(agentDir, '.ready'), '', 'utf8');
|
|
49
68
|
syncAssemblyDocument(project.root, agentDir);
|
|
@@ -76,18 +95,20 @@ function canReuseRuntime(runtimeRoot, project, resources, includeDigests) {
|
|
|
76
95
|
const snapshot = JSON.parse(readFileSync(snapshotPath, 'utf8'));
|
|
77
96
|
if (snapshot.version !== project.version)
|
|
78
97
|
return false;
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
const sourceArtifactDigests = new Map();
|
|
99
|
+
for (const artifact of RUNTIME_SOURCE_ARTIFACTS) {
|
|
100
|
+
const sourceDigest = sha256(readFileSync(resolve(project.root, artifact)));
|
|
101
|
+
sourceArtifactDigests.set(artifact, sourceDigest);
|
|
102
|
+
if (sha256(readFileSync(resolve(agentDir, artifact))) !== sourceDigest)
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
85
105
|
const expectedTools = resources
|
|
86
106
|
.filter((resource) => resource.kind === 'tools')
|
|
87
107
|
.map((resource) => ({
|
|
88
108
|
name: resource.code,
|
|
89
109
|
version: resource.version,
|
|
90
110
|
...(includeDigests ? { sha256: toSha256Hex(sha256(readFileSync(resolve(resource.sourcePath, resource.manifestFile)))) } : {}),
|
|
111
|
+
...(includeDigests ? { contentSha256: resourceDirectoryDigest(resource.sourcePath) } : {}),
|
|
91
112
|
}))
|
|
92
113
|
.sort((left, right) => left.name.localeCompare(right.name) || left.version.localeCompare(right.version));
|
|
93
114
|
const expectedSkills = resources
|
|
@@ -96,6 +117,7 @@ function canReuseRuntime(runtimeRoot, project, resources, includeDigests) {
|
|
|
96
117
|
skillId: resource.code,
|
|
97
118
|
version: resource.version,
|
|
98
119
|
...(includeDigests ? { sha256: toSha256Hex(sha256(readFileSync(resolve(resource.sourcePath, resource.manifestFile)))) } : {}),
|
|
120
|
+
...(includeDigests ? { contentSha256: resourceDirectoryDigest(resource.sourcePath) } : {}),
|
|
99
121
|
}))
|
|
100
122
|
.sort((left, right) => left.skillId.localeCompare(right.skillId) || left.version.localeCompare(right.version));
|
|
101
123
|
if (JSON.stringify(snapshot.tools ?? []) !== JSON.stringify(expectedTools))
|
|
@@ -103,24 +125,33 @@ function canReuseRuntime(runtimeRoot, project, resources, includeDigests) {
|
|
|
103
125
|
if (JSON.stringify(snapshot.skills ?? []) !== JSON.stringify(expectedSkills))
|
|
104
126
|
return false;
|
|
105
127
|
const artifacts = new Map((snapshot.artifacts ?? []).map((artifact) => [artifact.path, artifact.sha256]));
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
128
|
+
for (const artifact of RUNTIME_SOURCE_ARTIFACTS) {
|
|
129
|
+
if (artifacts.get(artifact) !== toSha256Hex(sourceArtifactDigests.get(artifact)))
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
110
132
|
const dependenciesPath = resolve(agentDir, 'dependencies.lock');
|
|
111
133
|
if (!existsSync(dependenciesPath))
|
|
112
134
|
return false;
|
|
113
135
|
if (artifacts.get('dependencies.lock') !== toSha256Hex(sha256(readFileSync(dependenciesPath))))
|
|
114
136
|
return false;
|
|
115
137
|
for (const resource of resources) {
|
|
116
|
-
const
|
|
138
|
+
const materializedDirectory = resolveMaterializedResourceDirectory(agentDir, resource);
|
|
139
|
+
const manifestPath = resolve(materializedDirectory, resource.manifestFile);
|
|
117
140
|
if (!existsSync(manifestPath))
|
|
118
141
|
return false;
|
|
119
142
|
if (includeDigests) {
|
|
120
143
|
const expectedDigest = toSha256Hex(sha256(readFileSync(manifestPath)));
|
|
144
|
+
const sourceContentDigest = resourceDirectoryDigest(resource.sourcePath);
|
|
145
|
+
const materializedContentDigest = resourceDirectoryDigest(materializedDirectory);
|
|
121
146
|
const matches = resource.kind === 'tools'
|
|
122
|
-
? (snapshot.tools ?? []).some((item) => item.name === resource.code
|
|
123
|
-
|
|
147
|
+
? (snapshot.tools ?? []).some((item) => (item.name === resource.code
|
|
148
|
+
&& item.sha256 === expectedDigest
|
|
149
|
+
&& item.contentSha256 === sourceContentDigest
|
|
150
|
+
&& item.contentSha256 === materializedContentDigest))
|
|
151
|
+
: (snapshot.skills ?? []).some((item) => (item.skillId === resource.code
|
|
152
|
+
&& item.sha256 === expectedDigest
|
|
153
|
+
&& item.contentSha256 === sourceContentDigest
|
|
154
|
+
&& item.contentSha256 === materializedContentDigest));
|
|
124
155
|
if (!matches)
|
|
125
156
|
return false;
|
|
126
157
|
}
|
|
@@ -131,20 +162,15 @@ function canReuseRuntime(runtimeRoot, project, resources, includeDigests) {
|
|
|
131
162
|
return false;
|
|
132
163
|
}
|
|
133
164
|
}
|
|
134
|
-
function resolveRuntimeDestination(projectRoot,
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
if (!outputRoot)
|
|
145
|
-
throw new Error('Package Runtime output root is required');
|
|
146
|
-
const stagingRoot = ensureGeneratedDirectoryPath(projectRoot, ['.eap', 'package-staging']);
|
|
147
|
-
return resolveRuntimeDestinationWithin(stagingRoot, resolve(outputRoot), 'Package Runtime output');
|
|
165
|
+
function resolveRuntimeDestination(projectRoot, outputRoot) {
|
|
166
|
+
ensureGeneratedDirectory(projectRoot);
|
|
167
|
+
return resolveRuntimeDestinationWithin(projectRoot, resolveAgentRuntimeRoot({ root: projectRoot, runtimeRoot: outputRoot }), 'Runtime output');
|
|
168
|
+
}
|
|
169
|
+
export function resolveAgentRuntimeRoot(options = {}) {
|
|
170
|
+
const env = options.env ?? process.env;
|
|
171
|
+
const configured = options.runtimeRoot ?? env.EAP_RUNTIME_ROOT;
|
|
172
|
+
const base = options.cwd ?? options.root ?? process.cwd();
|
|
173
|
+
return resolve(base, configured && configured.trim() ? configured : 'dist/.eap/runtime');
|
|
148
174
|
}
|
|
149
175
|
function resolveRuntimeDestinationWithin(allowedRoot, requestedRoot, label) {
|
|
150
176
|
const realAllowedRoot = ensureGeneratedDirectoryPath(allowedRoot, []);
|
|
@@ -211,27 +237,39 @@ function materializeResources(agentDir, resources, agentCode, version, includeDi
|
|
|
211
237
|
throw new Error(`Materialized ${resource.kind.slice(0, -1)} entry file is missing: ${resource.code}`);
|
|
212
238
|
}
|
|
213
239
|
const destinationDigest = includeDigests ? sha256(readFileSync(destinationManifestPath)) : undefined;
|
|
240
|
+
const contentSha256 = includeDigests ? resourceDirectoryDigest(destination) : undefined;
|
|
214
241
|
writeFileSync(resolve(destination, '.ready'), '', 'utf8');
|
|
215
242
|
const digest = destinationDigest ? toSha256Hex(destinationDigest) : undefined;
|
|
216
|
-
if (resource.kind === 'tools')
|
|
217
|
-
tools.push({
|
|
218
|
-
|
|
219
|
-
|
|
243
|
+
if (resource.kind === 'tools') {
|
|
244
|
+
tools.push({
|
|
245
|
+
name: resource.code,
|
|
246
|
+
version: resource.version,
|
|
247
|
+
...(digest ? { sha256: digest } : {}),
|
|
248
|
+
...(contentSha256 ? { contentSha256 } : {}),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
skills.push({
|
|
253
|
+
skillId: resource.code,
|
|
254
|
+
version: resource.version,
|
|
255
|
+
...(digest ? { sha256: digest } : {}),
|
|
256
|
+
...(contentSha256 ? { contentSha256 } : {}),
|
|
257
|
+
});
|
|
258
|
+
}
|
|
220
259
|
}
|
|
221
|
-
const
|
|
222
|
-
const graphPath = resolve(agentDir, 'graph.json');
|
|
260
|
+
const lockableResources = resources.filter((resource) => isDependenciesLockCode(resource.code));
|
|
223
261
|
const dependenciesLock = DependenciesLockSchema.parse({
|
|
224
262
|
lockVersion: 1,
|
|
225
263
|
agentCode,
|
|
226
264
|
agentVersion: version,
|
|
227
|
-
toolRefs:
|
|
265
|
+
toolRefs: lockableResources
|
|
228
266
|
.filter((resource) => resource.kind === 'tools')
|
|
229
267
|
.map((resource) => ({
|
|
230
268
|
code: resource.code,
|
|
231
269
|
version: resource.version,
|
|
232
270
|
...(includeDigests ? { sha256: toSha256Hex(sha256(readFileSync(resolve(resource.sourcePath, resource.manifestFile)))) } : {}),
|
|
233
271
|
})),
|
|
234
|
-
skillRefs:
|
|
272
|
+
skillRefs: lockableResources
|
|
235
273
|
.filter((resource) => resource.kind === 'skills')
|
|
236
274
|
.map((resource) => ({
|
|
237
275
|
code: resource.code,
|
|
@@ -246,8 +284,10 @@ function materializeResources(agentDir, resources, agentCode, version, includeDi
|
|
|
246
284
|
tools: tools.sort((left, right) => left.name.localeCompare(right.name) || left.version.localeCompare(right.version)),
|
|
247
285
|
skills: skills.sort((left, right) => left.skillId.localeCompare(right.skillId) || left.version.localeCompare(right.version)),
|
|
248
286
|
artifacts: [
|
|
249
|
-
|
|
250
|
-
|
|
287
|
+
...RUNTIME_SOURCE_ARTIFACTS.map((path) => ({
|
|
288
|
+
path,
|
|
289
|
+
sha256: toSha256Hex(sha256(readFileSync(resolve(agentDir, path)))),
|
|
290
|
+
})),
|
|
251
291
|
{ path: 'dependencies.lock', sha256: toSha256Hex(sha256(readFileSync(dependenciesPath))) },
|
|
252
292
|
],
|
|
253
293
|
};
|
|
@@ -258,6 +298,28 @@ function resolveMaterializedResourceDirectory(agentDir, resource) {
|
|
|
258
298
|
function materializedResourceDirectorySegments(resource) {
|
|
259
299
|
return ['preinstall', resource.kind, resource.code];
|
|
260
300
|
}
|
|
301
|
+
function mergeRuntimeResources(lockedResources, configuredResources, manifest) {
|
|
302
|
+
const merged = new Map();
|
|
303
|
+
for (const resource of lockedResources) {
|
|
304
|
+
merged.set(`${resource.kind}:${resource.code}`, resource);
|
|
305
|
+
}
|
|
306
|
+
const versions = new Map([
|
|
307
|
+
...manifest.toolRefs.map((ref) => [`tools:${ref.code}`, ref.version]),
|
|
308
|
+
...manifest.skillRefs.map((ref) => [`skills:${ref.code}`, ref.version]),
|
|
309
|
+
]);
|
|
310
|
+
for (const resource of configuredResources) {
|
|
311
|
+
merged.set(`${resource.kind}:${resource.code}`, {
|
|
312
|
+
...resource,
|
|
313
|
+
version: versions.get(`${resource.kind}:${resource.code}`) ?? '1.0.0',
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
return [...merged.values()].sort((left, right) => (left.kind.localeCompare(right.kind)
|
|
317
|
+
|| left.code.localeCompare(right.code)
|
|
318
|
+
|| left.version.localeCompare(right.version)));
|
|
319
|
+
}
|
|
320
|
+
function isDependenciesLockCode(value) {
|
|
321
|
+
return value.length <= 64 && /^[a-z0-9][a-z0-9_-]*$/.test(value);
|
|
322
|
+
}
|
|
261
323
|
function syncAssemblyDocument(projectRoot, agentDir) {
|
|
262
324
|
const source = resolve(projectRoot, 'assembly.json');
|
|
263
325
|
if (!existsSync(source) || !lstatSync(source).isFile())
|