@aopslabs/aops 0.3.31 → 0.3.33
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 +11 -3
- package/aops-assets-release/aops-assets.json.gz +0 -0
- package/aops-assets-release/disciplines/build-review-chat/SKILL.md +33 -0
- package/aops-assets-release/disciplines/coordinator-loop/SKILL.md +33 -0
- package/aops-assets-release/disciplines/design-first-consensus/SKILL.md +30 -0
- package/aops-assets-release/disciplines/solo-pm-loop/SKILL.md +31 -0
- package/aops-assets-release/docs/user-guides/agentspace-user-guide.md +384 -0
- package/aops-assets-release/docs/user-guides/aops-cli-user-guide.md +2067 -0
- package/aops-assets-release/docs/user-guides/chatv3-user-guide.md +500 -0
- package/aops-assets-release/docs/user-guides/docman-user-guide.md +1009 -0
- package/aops-assets-release/docs/user-guides/projectman-user-guide.md +763 -0
- package/aops-assets-release/docs/user-guides/tasker-user-guide.md +244 -0
- package/aops-assets-release/release.json +6 -0
- package/aops-assets-release/roles/coordinator/ROLE.md +28 -0
- package/aops-assets-release/roles/implementer/ROLE.md +27 -0
- package/aops-assets-release/roles/reviewer/ROLE.md +27 -0
- package/aops-assets-release/skills/aops/SKILL.md +112 -0
- package/aops-assets-release/skills/aops-bootstrapper-authoring/SKILL.md +245 -0
- package/aops-assets-release/skills/aops-cli-agentspace/SKILL.md +186 -0
- package/aops-assets-release/skills/aops-cli-board-lifecycle/SKILL.md +64 -0
- package/aops-assets-release/skills/aops-cli-chat/SKILL.md +204 -0
- package/aops-assets-release/skills/aops-cli-collab/SKILL.md +42 -0
- package/aops-assets-release/skills/aops-cli-core/SKILL.md +219 -0
- package/aops-assets-release/skills/aops-cli-discuss/SKILL.md +172 -0
- package/aops-assets-release/skills/aops-cli-docman/SKILL.md +192 -0
- package/aops-assets-release/skills/aops-cli-fileman/SKILL.md +169 -0
- package/aops-assets-release/skills/aops-cli-mission/SKILL.md +128 -0
- package/aops-assets-release/skills/aops-cli-operator-brief/SKILL.md +67 -0
- package/aops-assets-release/skills/aops-cli-projectman/SKILL.md +235 -0
- package/aops-assets-release/skills/aops-cli-sugar-authoring/SKILL.md +188 -0
- package/aops-assets-release/skills/aops-cli-tasker/SKILL.md +108 -0
- package/aops-assets-release/skills/aops-cli-tooling-agent/SKILL.md +112 -0
- package/aops-assets-release/skills/aops-cli-view/SKILL.md +210 -0
- package/aops-assets-release/skills/aops-collaborative-work/SKILL.md +304 -0
- package/aops-assets-release/skills/aops-interactive/SKILL.md +70 -0
- package/aops-assets-release/skills/aops-loop-interactive/SKILL.md +314 -0
- package/aops-assets-release/skills/aops-working-disciplines/SKILL.md +310 -0
- package/aops-assets-release/skills/feature-retirement-flow/SKILL.md +126 -0
- package/assets/skills/aops-install/SKILL.md +18 -17
- package/dist/commands/assets.js +93 -1264
- package/dist/commands/community-server.js +27 -8
- package/dist/commands/community-setup.js +1 -2
- package/dist/commands/discuss.js +1 -1
- package/dist/commands/doc.js +88 -27
- package/dist/commands/docs.js +68 -0
- package/dist/commands/global-update.js +28 -0
- package/dist/commands/init.js +3 -1
- package/dist/commands/loop.js +6379 -0
- package/dist/commands/memory.js +2 -1
- package/dist/commands/pm/index.js +11 -9
- package/dist/commands/pm/projectman.js +33 -2
- package/dist/commands/project.js +6 -6
- package/dist/commands/prompt.js +1 -1
- package/dist/commands/repo-sync.js +92 -27
- package/dist/commands/runner.js +257 -0
- package/dist/commands/skill.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/commands/tasker.js +361 -0
- package/dist/commands/view.js +53 -9
- package/dist/lib/commercial-setup-readiness-adapter.js +0 -1
- package/dist/lib/community-migration-snapshot.js +7 -9
- package/dist/lib/community-native-database-recovery.js +5 -14
- package/dist/lib/community-native-lifecycle.js +13 -0
- package/dist/lib/setup-agent-assets-bridge.js +28 -148
- package/dist/lib/setup-agent-assets-release.js +16 -44
- package/dist/lib/setup-init-orchestrator.js +11 -15
- package/dist/lib/simple-agent-assets.js +447 -0
- package/dist/lib/user-guide-sections.js +488 -0
- package/dist/main.js +10 -2
- package/dist/seeds/agents-md.js +3 -3
- package/dist/utils/agents-md.js +1 -1
- package/dist/utils/guide-paths.js +7 -7
- package/dist/utils/hosted-workspace.js +2 -1
- package/dist/utils/repo-first-storage.js +26 -1
- package/dist/utils/session-state.js +2 -7
- package/launchers/aops-cockpit.sh +0 -0
- package/launchers/aops-server.sh +0 -0
- package/package.json +67 -35
- package/THIRD_PARTY_NOTICES +0 -16169
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/SKILL.md +0 -47
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/agentspace/SKILL.md +0 -72
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/aops-cli-core/SKILL.md +0 -110
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/chatv3/SKILL.md +0 -59
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/collaborative-work/SKILL.md +0 -81
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/discuss/SKILL.md +0 -66
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/docman/SKILL.md +0 -75
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/projectman/SKILL.md +0 -92
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/sys/SKILL.md +0 -36
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/view/SKILL.md +0 -58
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/references/working-disciplines/SKILL.md +0 -66
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/agent-assets.md +0 -81
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/agentspace.md +0 -183
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/aops-cli.md +0 -1108
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/aops-system.md +0 -102
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/chatv3.md +0 -113
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/docman.md +0 -223
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/projectman.md +0 -233
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/sys.md +0 -94
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/files/user-guides/working-disciplines.md +0 -482
- package/agent-assets-release/agent-assets/core/bc42dd7792dbe66040e99a7ef3d80b3bc788c72b369b5a065cf936aef29f53fb/manifest.json +0 -117
- package/agent-assets-release/agent-assets/gateway/aops/SKILL.md +0 -14
- package/agent-assets-release/agent-assets/inventory.json +0 -29
- package/agent-assets-release/agent-assets/projection.json +0 -8
- package/agent-assets-release/agent-assets-release.json +0 -171
- package/agent-assets-release/agent-assets-release.sigstore.json +0 -67
- package/assets/agent-assets/core/SKILL.md +0 -47
- package/assets/agent-assets/core/references/agentspace/SKILL.md +0 -72
- package/assets/agent-assets/core/references/aops-cli-core/SKILL.md +0 -110
- package/assets/agent-assets/core/references/chatv3/SKILL.md +0 -59
- package/assets/agent-assets/core/references/collaborative-work/SKILL.md +0 -81
- package/assets/agent-assets/core/references/discuss/SKILL.md +0 -66
- package/assets/agent-assets/core/references/docman/SKILL.md +0 -75
- package/assets/agent-assets/core/references/projectman/SKILL.md +0 -92
- package/assets/agent-assets/core/references/sys/SKILL.md +0 -36
- package/assets/agent-assets/core/references/view/SKILL.md +0 -58
- package/assets/agent-assets/core/references/working-disciplines/SKILL.md +0 -66
- package/assets/agent-assets/core/user-guides/agent-assets.md +0 -81
- package/assets/agent-assets/core/user-guides/agentspace.md +0 -183
- package/assets/agent-assets/core/user-guides/aops-cli.md +0 -1108
- package/assets/agent-assets/core/user-guides/aops-system.md +0 -102
- package/assets/agent-assets/core/user-guides/chatv3.md +0 -113
- package/assets/agent-assets/core/user-guides/docman.md +0 -223
- package/assets/agent-assets/core/user-guides/projectman.md +0 -233
- package/assets/agent-assets/core/user-guides/sys.md +0 -94
- package/assets/agent-assets/core/user-guides/working-disciplines.md +0 -482
- package/assets/agent-assets/gateway/aops/SKILL.md +0 -14
- package/dist/lib/agent-assets/gateway.js +0 -15
- package/dist/lib/agent-assets/guards.js +0 -23
- package/dist/lib/agent-assets/hosted-discovery.js +0 -148
- package/dist/lib/agent-assets/hosted-package-input.js +0 -154
- package/dist/lib/agent-assets/legacy-pointer-migration.js +0 -677
- package/dist/lib/agent-assets/native-fs.js +0 -589
- package/dist/lib/agent-assets/roots.js +0 -45
- package/dist/lib/agent-assets/runtime-binding-reader.js +0 -545
- package/dist/lib/agent-assets/runtime-targets.js +0 -50
- package/dist/lib/agent-assets/store-reader.js +0 -1212
- package/dist/lib/agent-assets/store-writer.js +0 -1484
- package/native/bin/darwin-arm64/aops-agent-assets-fs +0 -0
- package/native/bin/darwin-x64/aops-agent-assets-fs +0 -0
- package/native/bin/linux-arm64/aops-agent-assets-fs +0 -0
- package/native/bin/linux-x64/aops-agent-assets-fs +0 -0
- package/native/bin/win32-x64/aops-agent-assets-fs.exe +0 -0
- package/native/manifest.json +0 -49
- package/native/qualifications/win32-x64.json +0 -23
- package/native/tui/darwin-arm64/aops-tui +0 -0
- package/native/tui/linux-x64/aops-tui +0 -0
- package/native/tui/win32-x64/aops-tui.exe +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { invokeHostedToolWithApiState, unwrapHostedToolResult } from '../../utils/agent-gateway.js';
|
|
2
|
-
import { createCliApiClientFromOptions } from '../../utils/api.js';
|
|
3
|
-
import { AgentAssetsError } from './envelope.js';
|
|
4
|
-
const MATCH_FIELD = /^(?:name|shortDescription|description|tags|version|entryFile|skillStandard|meta\.[A-Za-z0-9_.-]+)$/;
|
|
5
|
-
const EXACT_REF = /^skill-version:(.+)$/;
|
|
6
|
-
const SHA256_HEX = /^[a-f0-9]{64}$/;
|
|
7
|
-
const FORBIDDEN_BODY_KEYS = new Set([
|
|
8
|
-
'content',
|
|
9
|
-
'files',
|
|
10
|
-
'filesystemPath',
|
|
11
|
-
'materializedPath',
|
|
12
|
-
'outputDir',
|
|
13
|
-
'packagePath',
|
|
14
|
-
'serverPath',
|
|
15
|
-
'sourcePath',
|
|
16
|
-
]);
|
|
17
|
-
function discoveryError(message, details) {
|
|
18
|
-
return new AgentAssetsError('schema_incompatible', message, {
|
|
19
|
-
nextActions: [
|
|
20
|
-
'Inspect `aops-cli agent schema --tool agentspace.skill.search --summary`; do not load skill bodies to compensate.',
|
|
21
|
-
],
|
|
22
|
-
...(details === undefined ? {} : { details }),
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function isRecord(value) {
|
|
26
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
27
|
-
}
|
|
28
|
-
function unwrapData(value) {
|
|
29
|
-
let current = value;
|
|
30
|
-
for (let depth = 0; depth < 3; depth += 1) {
|
|
31
|
-
if (!isRecord(current) || !Object.prototype.hasOwnProperty.call(current, 'data'))
|
|
32
|
-
break;
|
|
33
|
-
current = current.data;
|
|
34
|
-
}
|
|
35
|
-
return current;
|
|
36
|
-
}
|
|
37
|
-
function assertMetadataOnly(value) {
|
|
38
|
-
if (!value || typeof value !== 'object')
|
|
39
|
-
return;
|
|
40
|
-
for (const [key, child] of Object.entries(value)) {
|
|
41
|
-
if (FORBIDDEN_BODY_KEYS.has(key)) {
|
|
42
|
-
throw new AgentAssetsError('untrusted_origin', `Hosted discovery returned forbidden body/path field: ${key}.`, {
|
|
43
|
-
nextActions: ['Use only the raw metadata `agentspace.skill.search` Community projection.'],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
assertMetadataOnly(child);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
function boundedString(record, key, maximum, required = true) {
|
|
50
|
-
const value = record[key];
|
|
51
|
-
if (value === undefined && !required)
|
|
52
|
-
return undefined;
|
|
53
|
-
if (typeof value !== 'string' || value.length < 1 || value.length > maximum) {
|
|
54
|
-
throw discoveryError(`Hosted discovery candidate.${key} is invalid or exceeds its metadata budget.`);
|
|
55
|
-
}
|
|
56
|
-
return value;
|
|
57
|
-
}
|
|
58
|
-
export function validateHostedSkillDiscovery(payload, options) {
|
|
59
|
-
assertMetadataOnly(payload);
|
|
60
|
-
const candidate = unwrapData(payload);
|
|
61
|
-
if (!isRecord(candidate))
|
|
62
|
-
throw discoveryError('Hosted skill search result must be an object.');
|
|
63
|
-
const query = boundedString(candidate, 'query', 256);
|
|
64
|
-
const normalizedQuery = boundedString(candidate, 'normalizedQuery', 256);
|
|
65
|
-
if (!Array.isArray(candidate.candidates) || candidate.candidates.length > options.limit || candidate.candidates.length > 5) {
|
|
66
|
-
throw discoveryError('Hosted skill search exceeded the requested candidate limit.', {
|
|
67
|
-
requestedLimit: options.limit,
|
|
68
|
-
candidateCount: Array.isArray(candidate.candidates) ? candidate.candidates.length : null,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (candidate.count !== candidate.candidates.length) {
|
|
72
|
-
throw discoveryError('Hosted skill search count does not match its candidate array.');
|
|
73
|
-
}
|
|
74
|
-
const candidates = candidate.candidates.map((entry, index) => {
|
|
75
|
-
if (!isRecord(entry))
|
|
76
|
-
throw discoveryError(`Hosted skill search candidate ${index} must be an object.`);
|
|
77
|
-
const versionId = boundedString(entry, 'versionId', 160);
|
|
78
|
-
const exactRef = boundedString(entry, 'exactRef', 180);
|
|
79
|
-
const match = EXACT_REF.exec(exactRef);
|
|
80
|
-
if (!match || match[1] !== versionId) {
|
|
81
|
-
throw discoveryError(`Hosted skill search candidate ${index} has inconsistent exact identity.`);
|
|
82
|
-
}
|
|
83
|
-
if (entry.origin !== 'hosted')
|
|
84
|
-
throw discoveryError(`Hosted skill search candidate ${index} has an invalid origin.`);
|
|
85
|
-
const packageSha256 = boundedString(entry, 'packageSha256', 64);
|
|
86
|
-
const contentSha256 = boundedString(entry, 'contentSha256', 64);
|
|
87
|
-
if (!SHA256_HEX.test(packageSha256) || !SHA256_HEX.test(contentSha256)) {
|
|
88
|
-
throw discoveryError(`Hosted skill search candidate ${index} has invalid immutable digest metadata.`);
|
|
89
|
-
}
|
|
90
|
-
if (entry.computedTrustClass !== 'verified-hosted-package') {
|
|
91
|
-
throw discoveryError(`Hosted skill search candidate ${index} has an invalid computed trust class.`);
|
|
92
|
-
}
|
|
93
|
-
if (!Number.isSafeInteger(entry.score) || entry.score < 1) {
|
|
94
|
-
throw discoveryError(`Hosted skill search candidate ${index} has an invalid score.`);
|
|
95
|
-
}
|
|
96
|
-
if (!Array.isArray(entry.matchedBy)
|
|
97
|
-
|| entry.matchedBy.length < 1
|
|
98
|
-
|| entry.matchedBy.length > 5
|
|
99
|
-
|| entry.matchedBy.some((field) => typeof field !== 'string' || !MATCH_FIELD.test(field))
|
|
100
|
-
|| new Set(entry.matchedBy).size !== entry.matchedBy.length) {
|
|
101
|
-
throw discoveryError(`Hosted skill search candidate ${index} has invalid match metadata.`);
|
|
102
|
-
}
|
|
103
|
-
return Object.freeze({
|
|
104
|
-
name: boundedString(entry, 'name', 80),
|
|
105
|
-
version: boundedString(entry, 'version', 80),
|
|
106
|
-
versionId,
|
|
107
|
-
exactRef,
|
|
108
|
-
packageSha256,
|
|
109
|
-
contentSha256,
|
|
110
|
-
...(entry.shortDescription === undefined
|
|
111
|
-
? {}
|
|
112
|
-
: { shortDescription: boundedString(entry, 'shortDescription', 96, false) }),
|
|
113
|
-
origin: 'hosted-cache',
|
|
114
|
-
computedTrustClass: 'verified-hosted-package',
|
|
115
|
-
score: entry.score,
|
|
116
|
-
matchedBy: Object.freeze([...entry.matchedBy]),
|
|
117
|
-
rationale: boundedString(entry, 'rationale', 160),
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
return Object.freeze({ query, normalizedQuery, candidates: Object.freeze(candidates) });
|
|
121
|
-
}
|
|
122
|
-
export async function discoverHostedSkills(options) {
|
|
123
|
-
let payload;
|
|
124
|
-
try {
|
|
125
|
-
const input = Object.freeze({ query: options.query, limit: options.limit });
|
|
126
|
-
if (options.invoke) {
|
|
127
|
-
payload = await options.invoke('agentspace.skill.search', input);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
const apiState = await createCliApiClientFromOptions({ apiBaseUrl: options.apiBaseUrl });
|
|
131
|
-
const response = await invokeHostedToolWithApiState(apiState, {
|
|
132
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
133
|
-
toolId: 'agentspace.skill.search',
|
|
134
|
-
input,
|
|
135
|
-
});
|
|
136
|
-
payload = unwrapHostedToolResult(response);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
if (error instanceof AgentAssetsError)
|
|
141
|
-
throw error;
|
|
142
|
-
throw new AgentAssetsError('remote_unavailable', 'Hosted skill metadata search failed.', {
|
|
143
|
-
nextActions: ['Retry when the selected AOPS server is reachable, or use `--offline` for the installed core only.'],
|
|
144
|
-
cause: error,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return validateHostedSkillDiscovery(payload, options);
|
|
148
|
-
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { invokeHostedToolWithApiState, unwrapHostedToolResult } from '../../utils/agent-gateway.js';
|
|
4
|
-
import { createCliApiClientFromOptions } from '../../utils/api.js';
|
|
5
|
-
import { AgentAssetsError } from './envelope.js';
|
|
6
|
-
import { validatePortablePackageV1 } from './package-manifest.js';
|
|
7
|
-
import { canonicalJsonV1 } from './store-reader.js';
|
|
8
|
-
const FORBIDDEN_SERVER_PATH_KEYS = new Set([
|
|
9
|
-
'filesystemPath',
|
|
10
|
-
'materializedPath',
|
|
11
|
-
'outputDir',
|
|
12
|
-
'packagePath',
|
|
13
|
-
'serverPath',
|
|
14
|
-
'sourcePath',
|
|
15
|
-
]);
|
|
16
|
-
function packageError(code, message, details) {
|
|
17
|
-
return new AgentAssetsError(code, message, {
|
|
18
|
-
nextActions: [
|
|
19
|
-
'Inspect the exact hosted contract with `aops-cli agent schema --tool agentspace.skill-version.export-skill-package --summary`.',
|
|
20
|
-
],
|
|
21
|
-
...(details === undefined ? {} : { details }),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function isRecord(value) {
|
|
25
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
26
|
-
}
|
|
27
|
-
function unwrapData(value) {
|
|
28
|
-
let current = value;
|
|
29
|
-
for (let depth = 0; depth < 3; depth += 1) {
|
|
30
|
-
if (!isRecord(current) || !Object.prototype.hasOwnProperty.call(current, 'data'))
|
|
31
|
-
break;
|
|
32
|
-
current = current.data;
|
|
33
|
-
}
|
|
34
|
-
return current;
|
|
35
|
-
}
|
|
36
|
-
function assertNoServerFilesystemPointers(value) {
|
|
37
|
-
if (!value || typeof value !== 'object')
|
|
38
|
-
return;
|
|
39
|
-
for (const [key, child] of Object.entries(value)) {
|
|
40
|
-
if (FORBIDDEN_SERVER_PATH_KEYS.has(key) && typeof child === 'string' && child.trim()) {
|
|
41
|
-
throw packageError('untrusted_origin', `Hosted client export leaked a server filesystem field: ${key}.`);
|
|
42
|
-
}
|
|
43
|
-
assertNoServerFilesystemPointers(child);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function nonEmpty(record, key, label) {
|
|
47
|
-
const value = record[key];
|
|
48
|
-
if (typeof value !== 'string' || !value.trim()) {
|
|
49
|
-
throw packageError('schema_incompatible', `${label}.${key} must be a non-empty string.`);
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
function readExpectedManifest(reference, versionId) {
|
|
54
|
-
if (!reference.startsWith('@')) {
|
|
55
|
-
if (reference !== `skill-version:${versionId}`) {
|
|
56
|
-
throw packageError('expected_manifest_required', 'Expected manifest must be @file.json or the exact immutable skill-version ref.', {
|
|
57
|
-
expected: `skill-version:${versionId}`,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
const filePath = path.resolve(reference.slice(1));
|
|
63
|
-
let raw;
|
|
64
|
-
try {
|
|
65
|
-
raw = readFileSync(filePath, 'utf8');
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
throw packageError('expected_manifest_required', 'Expected manifest file could not be read.', {
|
|
69
|
-
cause: error instanceof Error ? error.message : String(error),
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
if (Buffer.byteLength(raw, 'utf8') > 1024 * 1024) {
|
|
73
|
-
throw packageError('schema_incompatible', 'Expected manifest exceeds the 1 MiB input limit.');
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
return JSON.parse(raw);
|
|
77
|
-
}
|
|
78
|
-
catch {
|
|
79
|
-
throw packageError('schema_incompatible', 'Expected manifest is not valid JSON.');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
export function assertExpectedSkillPackageManifestV1(reference, versionId, manifest) {
|
|
83
|
-
if (manifest.assetKind !== 'skill-package' ||
|
|
84
|
-
manifest.versionId !== versionId ||
|
|
85
|
-
manifest.provenance.reference !== `skill-version:${versionId}`) {
|
|
86
|
-
throw packageError('untrusted_origin', 'Package manifest does not identify the exact immutable skill version.');
|
|
87
|
-
}
|
|
88
|
-
const expectedManifest = readExpectedManifest(reference, versionId);
|
|
89
|
-
if (expectedManifest !== null && canonicalJsonV1(expectedManifest) !== canonicalJsonV1(manifest)) {
|
|
90
|
-
throw packageError('hash_mismatch', 'Immutable manifest differs from the caller-pinned expected manifest.');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
export function validateHostedSkillPackageExport(payload, options) {
|
|
94
|
-
assertNoServerFilesystemPointers(payload);
|
|
95
|
-
const candidate = unwrapData(payload);
|
|
96
|
-
if (!isRecord(candidate))
|
|
97
|
-
throw packageError('schema_incompatible', 'Hosted export result must be an object.');
|
|
98
|
-
const skillVersionId = nonEmpty(candidate, 'skillVersionId', 'HostedSkillPackageExport');
|
|
99
|
-
if (skillVersionId !== options.versionId) {
|
|
100
|
-
throw packageError('hash_mismatch', 'Hosted export returned a different immutable skill version.');
|
|
101
|
-
}
|
|
102
|
-
if (!Array.isArray(candidate.files) || candidate.files.length === 0) {
|
|
103
|
-
throw packageError('schema_incompatible', 'Hosted export did not include package files.');
|
|
104
|
-
}
|
|
105
|
-
const transferFiles = candidate.files.map((file, index) => {
|
|
106
|
-
if (!isRecord(file) || typeof file.path !== 'string' || typeof file.content !== 'string') {
|
|
107
|
-
throw packageError('schema_incompatible', `Hosted export file ${index} must contain path and UTF-8 content.`);
|
|
108
|
-
}
|
|
109
|
-
return { path: file.path, bytes: Buffer.from(file.content, 'utf8') };
|
|
110
|
-
});
|
|
111
|
-
const validation = validatePortablePackageV1(candidate.manifest, transferFiles);
|
|
112
|
-
if (!validation.ok) {
|
|
113
|
-
throw packageError('hash_mismatch', 'Hosted package bytes do not match immutable publish-time metadata.', {
|
|
114
|
-
issues: validation.issues,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
const manifest = validation.value.normalizedManifest;
|
|
118
|
-
assertExpectedSkillPackageManifestV1(options.expectedManifest, skillVersionId, manifest);
|
|
119
|
-
return {
|
|
120
|
-
skillVersionId,
|
|
121
|
-
skillId: nonEmpty(candidate, 'skillId', 'HostedSkillPackageExport'),
|
|
122
|
-
skillName: nonEmpty(candidate, 'skillName', 'HostedSkillPackageExport'),
|
|
123
|
-
projectId: nonEmpty(candidate, 'projectId', 'HostedSkillPackageExport'),
|
|
124
|
-
scopeId: nonEmpty(candidate, 'scopeId', 'HostedSkillPackageExport'),
|
|
125
|
-
manifest,
|
|
126
|
-
transferFiles,
|
|
127
|
-
validation: validation.value,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
export async function pullHostedSkillPackage(options) {
|
|
131
|
-
let payload;
|
|
132
|
-
try {
|
|
133
|
-
if (options.invoke) {
|
|
134
|
-
payload = await options.invoke('agentspace.skill-version.export-skill-package', { id: options.versionId });
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
const apiState = await createCliApiClientFromOptions({ apiBaseUrl: options.apiBaseUrl });
|
|
138
|
-
const response = await invokeHostedToolWithApiState(apiState, {
|
|
139
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
140
|
-
toolId: 'agentspace.skill-version.export-skill-package',
|
|
141
|
-
input: { id: options.versionId },
|
|
142
|
-
});
|
|
143
|
-
payload = unwrapHostedToolResult(response);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
if (error instanceof AgentAssetsError)
|
|
148
|
-
throw error;
|
|
149
|
-
throw packageError('remote_unavailable', 'Hosted skill package export failed.', {
|
|
150
|
-
cause: error instanceof Error ? error.message : String(error),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
return validateHostedSkillPackageExport(payload, options);
|
|
154
|
-
}
|