aui-agent-builder 0.4.31 → 0.4.32
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/dist/api-client/rag-client.d.ts.map +1 -1
- package/dist/api-client/rag-client.js +9 -4
- package/dist/api-client/rag-client.js.map +1 -1
- package/dist/commands/mockdb.js +2 -2
- package/dist/commands/mockdb.js.map +1 -1
- package/dist/commands/push.js +0 -49
- package/dist/commands/push.js.map +1 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +7 -6
- package/dist/errors/index.js.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/dist/services/integration.service.d.ts.map +1 -1
- package/dist/services/integration.service.js +4 -0
- package/dist/services/integration.service.js.map +1 -1
- package/dist/services/kb-view.service.d.ts.map +1 -1
- package/dist/services/kb-view.service.js +3 -14
- package/dist/services/kb-view.service.js.map +1 -1
- package/dist/services/mock-db.service.d.ts +4 -3
- package/dist/services/mock-db.service.d.ts.map +1 -1
- package/dist/services/mock-db.service.js +20 -19
- package/dist/services/mock-db.service.js.map +1 -1
- package/dist/services/pull-schema.service.d.ts +13 -0
- package/dist/services/pull-schema.service.d.ts.map +1 -1
- package/dist/services/pull-schema.service.js +9 -1
- package/dist/services/pull-schema.service.js.map +1 -1
- package/dist/utils/fetch-with-timeout.d.ts.map +1 -1
- package/dist/utils/fetch-with-timeout.js +24 -1
- package/dist/utils/fetch-with-timeout.js.map +1 -1
- package/package.json +1 -1
- package/dist/services/kb-identity.d.ts +0 -54
- package/dist/services/kb-identity.d.ts.map +0 -1
- package/dist/services/kb-identity.js +0 -152
- package/dist/services/kb-identity.js.map +0 -1
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RAG knowledge-base rename guard.
|
|
3
|
-
*
|
|
4
|
-
* A RAG KB is identified by its name: AS provisions it under
|
|
5
|
-
* to_screaming_snake_case(integration name) and KBM resolves it by that name at
|
|
6
|
-
* runtime. Renaming a provisioned integration between pushes forks that identity
|
|
7
|
-
* — a new empty KB is provisioned (or the old one deleted) while the content
|
|
8
|
-
* stays in the original — so runtime RAG silently returns nothing. The guard
|
|
9
|
-
* anchors on the stable knowledge_base_id the CLI writes into kb.json: if its
|
|
10
|
-
* server KB no longer resolves from the local name, the name was changed.
|
|
11
|
-
*/
|
|
12
|
-
import fs from "fs";
|
|
13
|
-
import path from "path";
|
|
14
|
-
/** Mirror agent-settings-transcoder `to_screaming_snake_case` — keep in sync. */
|
|
15
|
-
function toScreamingSnake(name) {
|
|
16
|
-
if (!name)
|
|
17
|
-
return "";
|
|
18
|
-
let code = name.replace(/-/g, "_").replace(/ /g, "_").toUpperCase();
|
|
19
|
-
code = code.replace(/^[_| ]+/, "");
|
|
20
|
-
code = code.replace(/[^A-Z0-9_]+/g, "");
|
|
21
|
-
code = code.replace(/_+/g, "_");
|
|
22
|
-
return code;
|
|
23
|
-
}
|
|
24
|
-
/** Mirror knowledge-base-manager `name_to_kebab` (the runtime KB-name lookup key). */
|
|
25
|
-
function nameToKebab(name) {
|
|
26
|
-
return name
|
|
27
|
-
.trim()
|
|
28
|
-
.replace(/[\s\-_]+/g, "-")
|
|
29
|
-
.replace(/^-+|-+$/g, "")
|
|
30
|
-
.toLowerCase();
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The key a name resolves a KB to at runtime — provisioning's
|
|
34
|
-
* to_screaming_snake_case composed with KBM's name_to_kebab. Two names share a
|
|
35
|
-
* key IFF they resolve to the same KB, so separator / case / punctuation
|
|
36
|
-
* differences never produce a false-positive rename.
|
|
37
|
-
*/
|
|
38
|
-
export function kbResolutionKey(name) {
|
|
39
|
-
return nameToKebab(toScreamingSnake(name));
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Flag each provisioned local KB whose name no longer resolves to the server KB
|
|
43
|
-
* its id points at. Skips unprovisioned bindings (no id — first push) and ids
|
|
44
|
-
* absent from the server (deleted/foreign — nothing to orphan).
|
|
45
|
-
*/
|
|
46
|
-
export function detectKbRenames(bindings, serverKbNameById) {
|
|
47
|
-
const violations = [];
|
|
48
|
-
for (const b of bindings) {
|
|
49
|
-
if (!b.knowledgeBaseId)
|
|
50
|
-
continue;
|
|
51
|
-
const serverName = serverKbNameById.get(b.knowledgeBaseId);
|
|
52
|
-
if (!serverName)
|
|
53
|
-
continue;
|
|
54
|
-
const bound = kbResolutionKey(serverName);
|
|
55
|
-
// kb.json name drives content upload; integration name drives provisioning
|
|
56
|
-
// + runtime resolution — either renamed away from the bound KB forks it.
|
|
57
|
-
if (kbResolutionKey(b.kbJsonName) !== bound) {
|
|
58
|
-
violations.push({
|
|
59
|
-
dir: b.dir,
|
|
60
|
-
knowledgeBaseId: b.knowledgeBaseId,
|
|
61
|
-
boundName: serverName,
|
|
62
|
-
localName: b.kbJsonName,
|
|
63
|
-
source: "kb.json name",
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
if (b.integrationName !== undefined &&
|
|
67
|
-
kbResolutionKey(b.integrationName) !== bound) {
|
|
68
|
-
violations.push({
|
|
69
|
-
dir: b.dir,
|
|
70
|
-
knowledgeBaseId: b.knowledgeBaseId,
|
|
71
|
-
boundName: serverName,
|
|
72
|
-
localName: b.integrationName,
|
|
73
|
-
source: "integration name",
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return violations;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Scan `knowledge-hubs/<dir>/kb.json` and `integrations.aui.json` (RAG
|
|
81
|
-
* entries) into the bindings the guard checks. Folder name == integration
|
|
82
|
-
* `code`. Returns [] when there are no knowledge-hub folders.
|
|
83
|
-
*/
|
|
84
|
-
export function loadKbBindings(projectRoot) {
|
|
85
|
-
const hubsRoot = path.join(projectRoot, "knowledge-hubs");
|
|
86
|
-
if (!fs.existsSync(hubsRoot))
|
|
87
|
-
return [];
|
|
88
|
-
const ragNameByCode = readRagIntegrationNames(projectRoot);
|
|
89
|
-
const bindings = [];
|
|
90
|
-
for (const dir of fs.readdirSync(hubsRoot)) {
|
|
91
|
-
const kbJsonPath = path.join(hubsRoot, dir, "kb.json");
|
|
92
|
-
if (!fs.existsSync(kbJsonPath))
|
|
93
|
-
continue;
|
|
94
|
-
let raw;
|
|
95
|
-
try {
|
|
96
|
-
raw = JSON.parse(fs.readFileSync(kbJsonPath, "utf-8"));
|
|
97
|
-
}
|
|
98
|
-
catch {
|
|
99
|
-
continue; // unreadable kb.json — readKbFolder surfaces this elsewhere
|
|
100
|
-
}
|
|
101
|
-
if (!raw.name)
|
|
102
|
-
continue;
|
|
103
|
-
bindings.push({
|
|
104
|
-
dir,
|
|
105
|
-
kbJsonName: raw.name,
|
|
106
|
-
knowledgeBaseId: raw.knowledge_base_id,
|
|
107
|
-
integrationName: ragNameByCode.get(dir),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return bindings;
|
|
111
|
-
}
|
|
112
|
-
/** code -> display name for every RAG entry in integrations.aui.json. */
|
|
113
|
-
function readRagIntegrationNames(projectRoot) {
|
|
114
|
-
const out = new Map();
|
|
115
|
-
const integPath = path.join(projectRoot, "integrations.aui.json");
|
|
116
|
-
if (!fs.existsSync(integPath))
|
|
117
|
-
return out;
|
|
118
|
-
try {
|
|
119
|
-
const parsed = JSON.parse(fs.readFileSync(integPath, "utf-8"));
|
|
120
|
-
for (const i of parsed.integrations ?? []) {
|
|
121
|
-
if (i.type === "RAG" && i.code && i.name)
|
|
122
|
-
out.set(i.code, i.name);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
// malformed integrations.aui.json — schema validation surfaces it
|
|
127
|
-
}
|
|
128
|
-
return out;
|
|
129
|
-
}
|
|
130
|
-
/** Build the actionable error shown when a rename is blocked. */
|
|
131
|
-
export function formatRenameLockError(violations) {
|
|
132
|
-
const byDir = new Map();
|
|
133
|
-
for (const v of violations)
|
|
134
|
-
if (!byDir.has(v.dir))
|
|
135
|
-
byDir.set(v.dir, v);
|
|
136
|
-
const lines = [...byDir.values()].map((v) => ` • knowledge-hubs/${v.dir} is bound to knowledge base ${v.boundName} ` +
|
|
137
|
-
`[id ${v.knowledgeBaseId}], but the local ${v.source} "${v.localName}" no longer resolves to it.`);
|
|
138
|
-
return [
|
|
139
|
-
"Knowledge base rename blocked.",
|
|
140
|
-
"",
|
|
141
|
-
"A RAG knowledge base is identified by its name. Renaming it provisions a",
|
|
142
|
-
"new, empty knowledge base and orphans the indexed content — runtime RAG",
|
|
143
|
-
"then returns nothing.",
|
|
144
|
-
"",
|
|
145
|
-
...lines,
|
|
146
|
-
"",
|
|
147
|
-
"To proceed, either:",
|
|
148
|
-
" - revert the name(s) above to match the bound knowledge base, or",
|
|
149
|
-
" - delete this integration and create a new one to start a fresh knowledge base.",
|
|
150
|
-
].join("\n");
|
|
151
|
-
}
|
|
152
|
-
//# sourceMappingURL=kb-identity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kb-identity.js","sourceRoot":"","sources":["../../src/services/kb-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,iFAAiF;AACjF,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACnC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IACxC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChC,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