@thinkingai/ae-cli 6.1.23 → 6.1.25
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 +7 -1
- package/README.zh.md +7 -1
- package/dist/{auth-XZNXFRJS.js → auth-LHM7NQPR.js} +167 -7
- package/dist/{capability-FYTU3X6L.js → capability-SJI5KOCK.js} +11 -6
- package/dist/{chunk-CCS66K4K.js → chunk-2FJM4HRV.js} +3 -3
- package/dist/{chunk-57RRFUEZ.js → chunk-5XRQ3CZR.js} +4 -4
- package/dist/{chunk-EQ255HKO.js → chunk-7WZACOAI.js} +2 -2
- package/dist/{chunk-DX5CDO34.js → chunk-BW7JUDEI.js} +84 -19
- package/dist/{chunk-7XGFSUOM.js → chunk-DU72X2IO.js} +271 -76
- package/dist/{chunk-V2NUHPXF.js → chunk-GK7WDY7E.js} +1 -1
- package/dist/{chunk-7FTTULED.js → chunk-IG3DYEIR.js} +4 -1
- package/dist/{chunk-HBGADCKA.js → chunk-KJDOTPYU.js} +3 -3
- package/dist/{chunk-4NRCTUZJ.js → chunk-KS4DE3MX.js} +4 -4
- package/dist/{chunk-JOCDD4ON.js → chunk-N4BLPJC7.js} +1 -1
- package/dist/{chunk-HFGZGYCG.js → chunk-QYXDJOLA.js} +252 -6
- package/dist/{chunk-DVMLWQD4.js → chunk-SO5LKIWP.js} +2 -2
- package/dist/{chunk-VYXXOKYS.js → chunk-XKIW3QMF.js} +7 -4
- package/dist/{chunk-MAPZ7VB6.js → chunk-YVGXGTD6.js} +13 -0
- package/dist/{community-report-client-CU22W53K.js → community-report-client-6VJDDMJJ.js} +1 -1
- package/dist/{config-XO3LI3SA.js → config-XQWOPDHN.js} +25 -6
- package/dist/{context-IFJI3LIT.js → context-M3HDGEIR.js} +4 -4
- package/dist/{data-integration-HNGUKFIC.js → data-integration-XBTCGXQT.js} +6 -6
- package/dist/index.js +78 -41
- package/dist/{local-data-upload-client-GTRIT64F.js → local-data-upload-client-3P7NIVQ4.js} +1 -1
- package/dist/{memory-QGPSNCQS.js → memory-6APEB2JB.js} +4 -4
- package/dist/{metadata-DI5BMYFU.js → metadata-JRYKNUS5.js} +7 -7
- package/dist/{model-RNPQXIBI.js → model-ZS7HVGKN.js} +4 -4
- package/dist/{personal-semantic-preference-5C3WUXFI.js → personal-semantic-preference-IDE2GE5T.js} +8 -6
- package/dist/project-semantic-36KOCYN7.js +356 -0
- package/dist/{sync-O45NXEQY.js → sync-EQLSTUS7.js} +7 -7
- package/dist/{te-agent-K5MSPNHJ.js → te-agent-Z3HCTKR7.js} +348 -55
- package/dist/{te-analysis-AISWCOOZ.js → te-analysis-5ZZ6YHVH.js} +940 -144
- package/dist/{te-community-4OYU3BDA.js → te-community-Z7JACGF3.js} +3 -3
- package/dist/{te-dataops-NFIPB6FX.js → te-dataops-F7GQOIS6.js} +644 -276
- package/dist/{te-engage-BAM3GBFX.js → te-engage-RNRMYDO3.js} +6 -6
- package/dist/{te-experiment-GUTZXZ5Z.js → te-experiment-BTAC2UNK.js} +6 -6
- package/dist/{te-kb-3TS73NO6.js → te-kb-QJLJEX5K.js} +323 -181
- package/dist/{te-system-STMHLS5J.js → te-system-IXC43QHZ.js} +6 -6
- package/dist/{te-team-3I5AOX3N.js → te-team-BIZIKIHZ.js} +6 -6
- package/dist/{update-RZXLPCRH.js → update-W2SGQNKT.js} +4 -4
- package/package.json +11 -4
- package/skills/ae-agent/SKILL.md +9 -4
- package/skills/ae-agent/references/notification.md +40 -0
- package/skills/ae-analysis/SKILL.md +44 -21
- package/skills/ae-analysis/references/adhoc_export.md +1 -1
- package/skills/ae-analysis/references/adhoc_run.md +1 -1
- package/skills/ae-analysis/references/agent_review_submit_to_page.md +3 -1
- package/skills/ae-analysis/references/ai_models/event.md +6 -1
- package/skills/ae-analysis/references/ai_models/funnel.md +7 -1
- package/skills/ae-analysis/references/ai_models/heat_map.md +23 -0
- package/skills/ae-analysis/references/ai_models/interval.md +24 -0
- package/skills/ae-analysis/references/ai_models/path.md +20 -0
- package/skills/ae-analysis/references/ai_models/prop_analysis.md +2 -0
- package/skills/ae-analysis/references/ai_models/rank_list.md +30 -0
- package/skills/ae-analysis/references/ai_models/retention.md +45 -1
- package/skills/ae-analysis/references/ai_models/revenue.md +20 -2
- package/skills/ae-analysis/references/ai_models/session.md +76 -0
- package/skills/ae-analysis/references/ai_models/tag.md +2 -0
- package/skills/ae-analysis/references/ai_models.md +76 -6
- package/skills/ae-analysis/references/analysis_data_retrieval.md +4 -0
- package/skills/ae-analysis/references/analysis_drilldown_contract.md +4 -1
- package/skills/ae-analysis/references/asset_batch_info_export.md +10 -0
- package/skills/ae-analysis/references/asset_batch_sql_export.md +13 -1
- package/skills/ae-analysis/references/asset_export.md +12 -1
- package/skills/ae-analysis/references/asset_list.md +1 -0
- package/skills/ae-analysis/references/asset_search.md +11 -5
- package/skills/ae-analysis/references/bi_panel_list.md +1 -1
- package/skills/ae-analysis/references/catalog_list.md +1 -1
- package/skills/ae-analysis/references/collaboration.md +48 -0
- package/skills/ae-analysis/references/command_index.md +19 -17
- package/skills/ae-analysis/references/dashboard_list.md +4 -4
- package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
- package/skills/ae-analysis/references/drilldown_session_details_run.md +41 -0
- package/skills/ae-analysis/references/event_export.md +3 -1
- package/skills/ae-analysis/references/governance_recommendation_auto_review.md +77 -0
- package/skills/ae-analysis/references/governance_recommendation_export.md +11 -0
- package/skills/ae-analysis/references/metadata_resolution.md +3 -3
- package/skills/ae-analysis/references/metric_export.md +3 -1
- package/skills/ae-analysis/references/metric_list.md +1 -1
- package/skills/ae-analysis/references/operation_record_export.md +10 -0
- package/skills/ae-analysis/references/personal_semantic_preference_add.md +2 -2
- package/skills/ae-analysis/references/personal_semantic_preference_get.md +4 -4
- package/skills/ae-analysis/references/personal_semantic_preference_list.md +4 -4
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +30 -12
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +59 -0
- package/skills/ae-analysis/references/property_export.md +3 -1
- package/skills/ae-analysis/references/report_create.md +5 -1
- package/skills/ae-analysis/references/report_data_export.md +6 -0
- package/skills/ae-analysis/references/report_get.md +2 -0
- package/skills/ae-analysis/references/report_list.md +5 -5
- package/skills/ae-analysis/references/report_update.md +7 -1
- package/skills/ae-analysis/references/sql_table_columns.md +4 -4
- package/skills/ae-analysis/references/sql_table_list.md +5 -5
- package/skills/ae-analysis/references/user_cluster_models.md +8 -0
- package/skills/ae-analysis/references/user_tag_create.md +7 -1
- package/skills/ae-analysis/references/user_tag_get.md +1 -1
- package/skills/ae-analysis/references/user_tag_models.md +18 -2
- package/skills/ae-analysis/references/user_tag_refresh.md +1 -1
- package/skills/ae-analysis/references/user_tag_update.md +2 -2
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +337 -12
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +8 -3
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +284 -24
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +185 -22
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +46 -2
- package/skills/ae-capability/SKILL.md +63 -1
- package/skills/ae-capability/references/collaboration.md +48 -0
- package/skills/ae-community/SKILL.md +5 -1
- package/skills/ae-community/references/collaboration.md +48 -0
- package/skills/ae-data-integration/SKILL.md +4 -0
- package/skills/ae-data-integration/references/collaboration.md +48 -0
- package/skills/ae-data-integration-helper/references/cpp_server_sdk_faq.md +2 -2
- package/skills/ae-data-integration-helper/references/logbus2_parser_plugin.md +6 -6
- package/skills/ae-data-integration-helper/references/sdk_log_guide.md +4 -4
- package/skills/ae-dataops/SKILL.md +54 -74
- package/skills/ae-dataops/references/collaboration.md +48 -0
- package/skills/ae-dataops/references/dataops-backfill.md +23 -18
- package/skills/ae-dataops/references/dataops-flow-create.md +74 -23
- package/skills/ae-dataops/references/dataops-flow-monitor.md +45 -13
- package/skills/ae-dataops/references/dataops-integration.md +57 -30
- package/skills/ae-dataops/references/dataops-query.md +21 -4
- package/skills/ae-dataops/references/dataops-table.md +143 -11
- package/skills/ae-engage/SKILL.md +21 -6
- package/skills/ae-engage/references/add-channel.md +3 -3
- package/skills/ae-engage/references/channel-mgmt.md +3 -3
- package/skills/ae-engage/references/collaboration.md +48 -0
- package/skills/ae-engage/references/common-metric.md +2 -2
- package/skills/ae-engage/references/save-task.md +2 -2
- package/skills/ae-engage/references/scene-config-channel.md +4 -4
- package/skills/ae-generate-tracking-code/SKILL.md +1 -1
- package/skills/ae-generate-tracking-plan/SKILL.md +4 -0
- package/skills/ae-generate-tracking-plan/references/collaboration.md +48 -0
- package/skills/ae-kb/SKILL.md +9 -1
- package/skills/ae-kb/references/collaboration.md +48 -0
- package/skills/ae-kb/references/schema-import.md +30 -0
- package/skills/ae-kb-discovery/SKILL.md +7 -2
- package/skills/ae-kb-discovery/references/collaboration.md +48 -0
- package/skills/ae-metadata/SKILL.md +20 -12
- package/skills/ae-metadata/references/collaboration.md +48 -0
- package/dist/project-semantic-3LF6Q6JZ.js +0 -1119
- package/skills/ae-project-semantic/SKILL.md +0 -193
- package/skills/ae-project-semantic/references/query-routing-v5.md +0 -165
- package/skills/ae-project-semantic/references/recommendation-quality.md +0 -68
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
assertOutputPathAvailable,
|
|
4
|
+
downloadAnalysisArtifact,
|
|
5
|
+
withAsyncArtifactLifecycle
|
|
6
|
+
} from "./chunk-XKIW3QMF.js";
|
|
7
|
+
import {
|
|
8
|
+
CapabilityGatewayError,
|
|
9
|
+
dryRunCapability,
|
|
10
|
+
executeCapabilityWithEnvelope,
|
|
11
|
+
validateCapability
|
|
12
|
+
} from "./chunk-QYXDJOLA.js";
|
|
13
|
+
import {
|
|
14
|
+
registerCapabilityGatewayRoute,
|
|
15
|
+
resolveGatewayDomain
|
|
16
|
+
} from "./chunk-KPQY44JQ.js";
|
|
17
|
+
import "./chunk-BW7JUDEI.js";
|
|
18
|
+
import "./chunk-Y74WTIKJ.js";
|
|
19
|
+
import "./chunk-DU72X2IO.js";
|
|
20
|
+
import "./chunk-IG3DYEIR.js";
|
|
21
|
+
import "./chunk-YVGXGTD6.js";
|
|
22
|
+
|
|
23
|
+
// src/commands/project-semantic/asset-package/materializer.ts
|
|
24
|
+
import { createHash, randomBytes } from "crypto";
|
|
25
|
+
import { createReadStream } from "fs";
|
|
26
|
+
import {
|
|
27
|
+
appendFile,
|
|
28
|
+
mkdir,
|
|
29
|
+
readFile,
|
|
30
|
+
rename,
|
|
31
|
+
rm,
|
|
32
|
+
stat,
|
|
33
|
+
writeFile
|
|
34
|
+
} from "fs/promises";
|
|
35
|
+
import { createInterface } from "readline";
|
|
36
|
+
import { createGunzip } from "zlib";
|
|
37
|
+
import { basename, dirname, resolve } from "path";
|
|
38
|
+
var MAX_COMPRESSED_BYTES = 64 * 1024 * 1024;
|
|
39
|
+
var MAX_UNCOMPRESSED_BYTES = 512 * 1024 * 1024;
|
|
40
|
+
var MAX_RECORDS = 2e5;
|
|
41
|
+
var SHA256_PATTERN = /^[0-9a-f]{64}$/;
|
|
42
|
+
var SUPPORTED_SCHEMA_VERSIONS = /* @__PURE__ */ new Set(["1.0", "3.0"]);
|
|
43
|
+
var REQUIRED_FILES = [
|
|
44
|
+
"manifest.json",
|
|
45
|
+
"indexes/work-units.jsonl",
|
|
46
|
+
"indexes/asset-directory.jsonl",
|
|
47
|
+
"indexes/coverage-batches.jsonl",
|
|
48
|
+
"indexes/definition-families.jsonl",
|
|
49
|
+
"indexes/governance-coverage.jsonl",
|
|
50
|
+
"catalog/published.jsonl",
|
|
51
|
+
"catalog/active-candidates.jsonl",
|
|
52
|
+
"catalog/rejected-candidates.jsonl"
|
|
53
|
+
];
|
|
54
|
+
async function preflightAssetPackageOutput(args) {
|
|
55
|
+
await assertOutputPathAvailable(args.output, args.force);
|
|
56
|
+
}
|
|
57
|
+
async function materializeProjectSemanticAssetPackage(args) {
|
|
58
|
+
const descriptor = packageDescriptor(args.finalDescriptor);
|
|
59
|
+
const output = resolve(args.output);
|
|
60
|
+
const parent = dirname(output);
|
|
61
|
+
const nonce = `${process.pid}-${randomBytes(6).toString("hex")}`;
|
|
62
|
+
const staging = resolve(parent, `.${basename(output)}.staging-${nonce}`);
|
|
63
|
+
const archive = resolve(parent, `.${basename(output)}.archive-${nonce}.jsonl.gz`);
|
|
64
|
+
const backup = resolve(parent, `.${basename(output)}.backup-${nonce}`);
|
|
65
|
+
let movedExisting = false;
|
|
66
|
+
await assertOutputPathAvailable(output, args.force, {
|
|
67
|
+
run_id: args.runId,
|
|
68
|
+
artifact_id: args.artifactId
|
|
69
|
+
});
|
|
70
|
+
await mkdir(parent, { recursive: true });
|
|
71
|
+
await mkdir(staging, { recursive: false });
|
|
72
|
+
try {
|
|
73
|
+
const download = await downloadAnalysisArtifact(
|
|
74
|
+
args.ctx.host(),
|
|
75
|
+
args.runId,
|
|
76
|
+
args.artifactId,
|
|
77
|
+
archive,
|
|
78
|
+
{ signal: args.signal, ensureReady: false }
|
|
79
|
+
);
|
|
80
|
+
if (download.bytes > MAX_COMPRESSED_BYTES) {
|
|
81
|
+
throw packageError("Asset package archive exceeds 64 MiB.", "ASSET_PACKAGE_ARCHIVE_TOO_LARGE");
|
|
82
|
+
}
|
|
83
|
+
const materialized = await materializeArchive(archive, staging, descriptor);
|
|
84
|
+
if (args.force && await exists(output)) {
|
|
85
|
+
await rename(output, backup);
|
|
86
|
+
movedExisting = true;
|
|
87
|
+
}
|
|
88
|
+
await rename(staging, output);
|
|
89
|
+
if (movedExisting) {
|
|
90
|
+
await rm(backup, { recursive: true, force: true });
|
|
91
|
+
movedExisting = false;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
...args.finalDescriptor,
|
|
95
|
+
output_path: output,
|
|
96
|
+
archive_bytes: download.bytes,
|
|
97
|
+
record_count: materialized.recordCount,
|
|
98
|
+
uncompressed_bytes: materialized.uncompressedBytes
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (movedExisting) {
|
|
102
|
+
await rename(backup, output).catch(() => void 0);
|
|
103
|
+
}
|
|
104
|
+
throw error;
|
|
105
|
+
} finally {
|
|
106
|
+
await rm(archive, { force: true }).catch(() => void 0);
|
|
107
|
+
await rm(staging, { recursive: true, force: true }).catch(() => void 0);
|
|
108
|
+
if (!movedExisting) {
|
|
109
|
+
await rm(backup, { recursive: true, force: true }).catch(() => void 0);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async function materializeArchive(archive, staging, descriptor) {
|
|
114
|
+
const compressed = await stat(archive);
|
|
115
|
+
if (compressed.size > MAX_COMPRESSED_BYTES) {
|
|
116
|
+
throw packageError("Asset package archive exceeds 64 MiB.", "ASSET_PACKAGE_ARCHIVE_TOO_LARGE");
|
|
117
|
+
}
|
|
118
|
+
const digest = createHash("sha256");
|
|
119
|
+
const lines = createInterface({
|
|
120
|
+
input: createReadStream(archive).pipe(createGunzip()),
|
|
121
|
+
crlfDelay: Infinity
|
|
122
|
+
});
|
|
123
|
+
let recordCount = 0;
|
|
124
|
+
let uncompressedBytes = 0;
|
|
125
|
+
let manifest;
|
|
126
|
+
for await (const line of lines) {
|
|
127
|
+
if (!line.trim()) continue;
|
|
128
|
+
uncompressedBytes += Buffer.byteLength(line, "utf8") + 1;
|
|
129
|
+
if (uncompressedBytes > MAX_UNCOMPRESSED_BYTES) {
|
|
130
|
+
throw packageError(
|
|
131
|
+
"Asset package archive exceeds 512 MiB after decompression.",
|
|
132
|
+
"ASSET_PACKAGE_ARCHIVE_TOO_LARGE"
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
recordCount += 1;
|
|
136
|
+
if (recordCount > MAX_RECORDS) {
|
|
137
|
+
throw packageError("Asset package has too many records.", "ASSET_PACKAGE_RECORD_LIMIT_EXCEEDED");
|
|
138
|
+
}
|
|
139
|
+
digest.update(line, "utf8");
|
|
140
|
+
digest.update("\n", "utf8");
|
|
141
|
+
const record = parseRecord(line);
|
|
142
|
+
const target = resolveRecordPath(staging, record.path);
|
|
143
|
+
await mkdir(dirname(target), { recursive: true });
|
|
144
|
+
const content = `${JSON.stringify(record.content)}
|
|
145
|
+
`;
|
|
146
|
+
if (record.append) {
|
|
147
|
+
await appendFile(target, content, "utf8");
|
|
148
|
+
} else {
|
|
149
|
+
await writeFile(target, content, { encoding: "utf8", flag: "wx" });
|
|
150
|
+
}
|
|
151
|
+
if (record.path === "manifest.json") {
|
|
152
|
+
manifest = asObject(record.content);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const actualHash = digest.digest("hex");
|
|
156
|
+
if (actualHash !== descriptor.snapshotHash) {
|
|
157
|
+
throw packageError(
|
|
158
|
+
`Asset package content hash mismatch: expected ${descriptor.snapshotHash}, received ${actualHash}.`,
|
|
159
|
+
"ASSET_PACKAGE_HASH_MISMATCH"
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (!manifest || !Number.isInteger(Number(manifest.project_id))) {
|
|
163
|
+
throw packageError("Asset package manifest is missing project identity.", "ASSET_PACKAGE_MANIFEST_INVALID");
|
|
164
|
+
}
|
|
165
|
+
const schemaVersion = typeof manifest.schema_version === "string" ? manifest.schema_version : "";
|
|
166
|
+
if (!SUPPORTED_SCHEMA_VERSIONS.has(schemaVersion)) {
|
|
167
|
+
throw packageError(
|
|
168
|
+
`Project semantic asset package schema ${[...SUPPORTED_SCHEMA_VERSIONS].join(" or ")} is required.`,
|
|
169
|
+
"ASSET_PACKAGE_VERSION_MISMATCH"
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
for (const required of REQUIRED_FILES) {
|
|
173
|
+
if (!await exists(resolve(staging, required))) {
|
|
174
|
+
throw packageError(`Asset package is missing required file ${required}.`, "ASSET_PACKAGE_MANIFEST_INVALID");
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
await verifyDetailLocators(staging, schemaVersion);
|
|
178
|
+
await writeFile(resolve(staging, ".asset-package.json"), JSON.stringify({
|
|
179
|
+
snapshot_id: descriptor.snapshotId,
|
|
180
|
+
snapshot_hash: descriptor.snapshotHash,
|
|
181
|
+
schema_version: schemaVersion,
|
|
182
|
+
package_kind: typeof manifest.package_kind === "string" ? manifest.package_kind : "project_semantic_asset_package",
|
|
183
|
+
company_id: Number(manifest.company_id),
|
|
184
|
+
project_id: Number(manifest.project_id),
|
|
185
|
+
project_name: typeof manifest.project_name === "string" ? manifest.project_name : void 0,
|
|
186
|
+
record_count: recordCount,
|
|
187
|
+
asset_scope: typeof manifest.asset_scope === "string" ? manifest.asset_scope : "governed",
|
|
188
|
+
exported_asset_count: Number(manifest.exported_asset_count ?? manifest.authenticated_asset_count),
|
|
189
|
+
authenticated_asset_count: Number(manifest.authenticated_asset_count),
|
|
190
|
+
unauthenticated_asset_count: Number(manifest.unauthenticated_asset_count ?? 0),
|
|
191
|
+
truncated: Boolean(manifest.truncated),
|
|
192
|
+
counts: manifest.counts,
|
|
193
|
+
filter_policy: manifest.filter_policy
|
|
194
|
+
}, null, 2), "utf8");
|
|
195
|
+
return { recordCount, uncompressedBytes };
|
|
196
|
+
}
|
|
197
|
+
async function verifyDetailLocators(root, schemaVersion) {
|
|
198
|
+
const directory = await readFile(resolve(root, "indexes/asset-directory.jsonl"), "utf8");
|
|
199
|
+
for (const line of directory.split(/\r?\n/)) {
|
|
200
|
+
if (!line.trim()) continue;
|
|
201
|
+
const row = asObject(JSON.parse(line));
|
|
202
|
+
if (!row || row.record_type === "header") continue;
|
|
203
|
+
const detail = await verifyContentLocator(root, row.detail_locator, "Detail");
|
|
204
|
+
await verifyContentLocator(root, detail.raw_locator, "Raw detail", { skipHash: schemaVersion === "3.0" });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async function verifyContentLocator(root, value, label, options = {}) {
|
|
208
|
+
const locator = asObject(value);
|
|
209
|
+
if (!locator || typeof locator.path !== "string" || typeof locator.content_hash !== "string" || !SHA256_PATTERN.test(locator.content_hash)) {
|
|
210
|
+
throw packageError(
|
|
211
|
+
`Asset package contains an invalid ${label.toLowerCase()} locator.`,
|
|
212
|
+
"ASSET_PACKAGE_MANIFEST_INVALID"
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
const target = resolveRecordPath(root, locator.path);
|
|
216
|
+
if (!await exists(target)) {
|
|
217
|
+
throw packageError(`Asset package is missing ${label.toLowerCase()} file ${locator.path}.`, "ASSET_PACKAGE_MANIFEST_INVALID");
|
|
218
|
+
}
|
|
219
|
+
const content = asObject(JSON.parse(await readFile(target, "utf8")));
|
|
220
|
+
if (!content) {
|
|
221
|
+
throw packageError(`${label} file is not a JSON object: ${locator.path}.`, "ASSET_PACKAGE_MANIFEST_INVALID");
|
|
222
|
+
}
|
|
223
|
+
if (!options.skipHash) {
|
|
224
|
+
const actualHash = createHash("sha256").update(JSON.stringify(content), "utf8").digest("hex");
|
|
225
|
+
if (actualHash !== locator.content_hash) {
|
|
226
|
+
throw packageError(`${label} content hash mismatch for ${locator.path}.`, "ASSET_PACKAGE_HASH_MISMATCH");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return content;
|
|
230
|
+
}
|
|
231
|
+
function parseRecord(line) {
|
|
232
|
+
const value = JSON.parse(line);
|
|
233
|
+
const record = asObject(value);
|
|
234
|
+
if (!record || typeof record.path !== "string") {
|
|
235
|
+
throw packageError("Asset package record is missing path.", "ASSET_PACKAGE_RECORD_INVALID");
|
|
236
|
+
}
|
|
237
|
+
if (!Object.prototype.hasOwnProperty.call(record, "content")) {
|
|
238
|
+
throw packageError("Asset package record is missing content.", "ASSET_PACKAGE_RECORD_INVALID");
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
path: record.path,
|
|
242
|
+
append: Boolean(record.append),
|
|
243
|
+
content: record.content
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function resolveRecordPath(root, path) {
|
|
247
|
+
if (path.startsWith("/") || path.includes("\0")) {
|
|
248
|
+
throw packageError(`Invalid asset package path: ${path}`, "ASSET_PACKAGE_PATH_INVALID");
|
|
249
|
+
}
|
|
250
|
+
const target = resolve(root, path);
|
|
251
|
+
const normalizedRoot = `${resolve(root)}/`;
|
|
252
|
+
if (!target.startsWith(normalizedRoot)) {
|
|
253
|
+
throw packageError(`Invalid asset package path: ${path}`, "ASSET_PACKAGE_PATH_INVALID");
|
|
254
|
+
}
|
|
255
|
+
return target;
|
|
256
|
+
}
|
|
257
|
+
function packageDescriptor(descriptor) {
|
|
258
|
+
const snapshotHash = stringValue(descriptor.snapshot_hash, "snapshot_hash").toLowerCase();
|
|
259
|
+
if (!SHA256_PATTERN.test(snapshotHash)) {
|
|
260
|
+
throw packageError("Asset package export returned invalid snapshot_hash.", "ASSET_PACKAGE_DESCRIPTOR_INVALID");
|
|
261
|
+
}
|
|
262
|
+
return {
|
|
263
|
+
snapshotId: typeof descriptor.snapshot_id === "string" ? descriptor.snapshot_id : void 0,
|
|
264
|
+
snapshotHash
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
function asObject(value) {
|
|
268
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
269
|
+
return value;
|
|
270
|
+
}
|
|
271
|
+
function stringValue(value, label) {
|
|
272
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
273
|
+
throw packageError(`${label} must be a non-empty string.`, "ASSET_PACKAGE_DESCRIPTOR_INVALID");
|
|
274
|
+
}
|
|
275
|
+
return value;
|
|
276
|
+
}
|
|
277
|
+
async function exists(path) {
|
|
278
|
+
try {
|
|
279
|
+
await stat(path);
|
|
280
|
+
return true;
|
|
281
|
+
} catch {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function packageError(message, code) {
|
|
286
|
+
return new CapabilityGatewayError(message, code, 422);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/commands/project-semantic/asset-package/export.ts
|
|
290
|
+
var ASSET_PACKAGE_EXPORT_CAPABILITY = "business_semantics.asset_package.export";
|
|
291
|
+
var ASSET_SCOPES = /* @__PURE__ */ new Set(["governed", "collaborative", "all_visible"]);
|
|
292
|
+
var GATEWAY_DOMAIN = "analysis";
|
|
293
|
+
function assetScope(ctx) {
|
|
294
|
+
const value = ctx.str("asset-scope") || "governed";
|
|
295
|
+
if (!ASSET_SCOPES.has(value)) {
|
|
296
|
+
throw new Error("asset-scope must be one of: governed, collaborative, all_visible");
|
|
297
|
+
}
|
|
298
|
+
return value;
|
|
299
|
+
}
|
|
300
|
+
var assetPackageExportCommand = {
|
|
301
|
+
service: "project-semantic",
|
|
302
|
+
resource: "asset-package",
|
|
303
|
+
command: "export",
|
|
304
|
+
description: "Export and materialize a knowledge-ready project asset package for CLI Agent consumption.",
|
|
305
|
+
helpText: "Requires access to the target project. Explicit asset-package export is independent of automatic knowledge-base discovery.",
|
|
306
|
+
flags: [
|
|
307
|
+
{ name: "project-id", type: "number", required: true, desc: "Numeric project ID.", alias: "p", min: 1 },
|
|
308
|
+
{
|
|
309
|
+
name: "asset-scope",
|
|
310
|
+
type: "string",
|
|
311
|
+
required: false,
|
|
312
|
+
desc: "Asset scope: governed, collaborative, or all_visible. Defaults to governed."
|
|
313
|
+
}
|
|
314
|
+
],
|
|
315
|
+
risk: "read",
|
|
316
|
+
validateInput: (ctx) => validateCapability(
|
|
317
|
+
ctx.host(),
|
|
318
|
+
resolveGatewayDomain(GATEWAY_DOMAIN, GATEWAY_DOMAIN),
|
|
319
|
+
ASSET_PACKAGE_EXPORT_CAPABILITY,
|
|
320
|
+
{ project_id: ctx.num("project-id"), asset_scope: assetScope(ctx) }
|
|
321
|
+
),
|
|
322
|
+
dryRun: (ctx) => dryRunCapability(
|
|
323
|
+
ctx.host(),
|
|
324
|
+
resolveGatewayDomain(GATEWAY_DOMAIN, GATEWAY_DOMAIN),
|
|
325
|
+
ASSET_PACKAGE_EXPORT_CAPABILITY,
|
|
326
|
+
{ project_id: ctx.num("project-id"), asset_scope: assetScope(ctx) }
|
|
327
|
+
),
|
|
328
|
+
execute: async (ctx) => {
|
|
329
|
+
const projectId = ctx.num("project-id");
|
|
330
|
+
const scope = assetScope(ctx);
|
|
331
|
+
const response = await executeCapabilityWithEnvelope(
|
|
332
|
+
ctx.host(),
|
|
333
|
+
resolveGatewayDomain(GATEWAY_DOMAIN, GATEWAY_DOMAIN),
|
|
334
|
+
ASSET_PACKAGE_EXPORT_CAPABILITY,
|
|
335
|
+
{ project_id: projectId, asset_scope: scope }
|
|
336
|
+
);
|
|
337
|
+
return response.data;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
var projectSemanticAssetPackageExport = withAsyncArtifactLifecycle(assetPackageExportCommand, {
|
|
341
|
+
preflightOutput: ({ output, force }) => preflightAssetPackageOutput({ output, force }),
|
|
342
|
+
materialize: materializeProjectSemanticAssetPackage
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// src/commands/project-semantic/index.ts
|
|
346
|
+
registerCapabilityGatewayRoute("project-semantic", {
|
|
347
|
+
gatewayDomain: "analysis",
|
|
348
|
+
capabilityPrefixes: ["business_semantics.asset_package"]
|
|
349
|
+
});
|
|
350
|
+
var commands = [
|
|
351
|
+
projectSemanticAssetPackageExport
|
|
352
|
+
];
|
|
353
|
+
var project_semantic_default = commands;
|
|
354
|
+
export {
|
|
355
|
+
project_semantic_default as default
|
|
356
|
+
};
|
|
@@ -21,8 +21,8 @@ import {
|
|
|
21
21
|
} from "./chunk-T6OSFQZD.js";
|
|
22
22
|
import {
|
|
23
23
|
require_lib
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-SO5LKIWP.js";
|
|
25
|
+
import "./chunk-GK7WDY7E.js";
|
|
26
26
|
import {
|
|
27
27
|
TeAgentApiError,
|
|
28
28
|
TeAgentCredentialsError,
|
|
@@ -30,16 +30,16 @@ import {
|
|
|
30
30
|
postSandboxSyncPull,
|
|
31
31
|
postToMainApp,
|
|
32
32
|
uploadToMainApp
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-KJDOTPYU.js";
|
|
34
34
|
import {
|
|
35
35
|
printError
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-BW7JUDEI.js";
|
|
37
37
|
import "./chunk-Y74WTIKJ.js";
|
|
38
|
-
import "./chunk-
|
|
39
|
-
import "./chunk-
|
|
38
|
+
import "./chunk-DU72X2IO.js";
|
|
39
|
+
import "./chunk-IG3DYEIR.js";
|
|
40
40
|
import {
|
|
41
41
|
__toESM
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-YVGXGTD6.js";
|
|
43
43
|
|
|
44
44
|
// src/commands/sync/index.ts
|
|
45
45
|
var import_jszip = __toESM(require_lib(), 1);
|