@cavelon/cli 0.2.11 → 0.2.12

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.
@@ -0,0 +1,212 @@
1
+ import { locate } from "./package-files.js";
2
+ import { branches } from "./package-references.js";
3
+ export const UNMANAGED_SET_CODE = "unmanaged_field_set";
4
+ export const MANAGED_SETTING_UNKNOWN_CODE = "managed_setting_unknown";
5
+ export const MANAGED_KINDS_LEFT_OUT_CODE = "managed_kinds_left_out";
6
+ export const MANAGED_KINDS_UNSUPPORTED_CODE = "managed_kinds_unsupported";
7
+ export const NO_MANAGED_FIELDS = { unmanaged: [], kinds: {} };
8
+ const asObject = (v) => (v && typeof v === "object" && !Array.isArray(v) ? v : undefined);
9
+ export function pointerKeys(pointer) {
10
+ return pointer
11
+ .split("/")
12
+ .slice(1)
13
+ .map((k) => k.replace(/~1/g, "/").replace(/~0/g, "~"));
14
+ }
15
+ export function validManagedPointer(pointer) {
16
+ if (!pointer.startsWith("/"))
17
+ return false;
18
+ const keys = pointerKeys(pointer);
19
+ return keys.length >= 2 && keys.every((k) => k.length > 0);
20
+ }
21
+ export function hasManagedFields(managed) {
22
+ return Boolean(managed && (managed.unmanaged.length || Object.keys(managed.kinds).length));
23
+ }
24
+ function parentOf(value, keys) {
25
+ let at = asObject(value);
26
+ for (const key of keys.slice(0, -1)) {
27
+ at = asObject(at?.[key]);
28
+ if (!at)
29
+ return undefined;
30
+ }
31
+ return at;
32
+ }
33
+ function fieldSchema(schema, keys) {
34
+ let node = schema.properties?.[keys[0]];
35
+ for (const key of keys.slice(1)) {
36
+ const holder = branches(schema, node).find((b) => asObject(b.properties)?.[key] !== undefined);
37
+ node = holder ? asObject(holder.properties)[key] : undefined;
38
+ if (node === undefined)
39
+ return undefined;
40
+ }
41
+ return asObject(node);
42
+ }
43
+ function siblingFields(schema, keys) {
44
+ if (keys.length < 2)
45
+ return undefined;
46
+ const holder = keys.length === 2 ? schema.properties?.[keys[0]] : fieldSchema(schema, keys.slice(0, -1));
47
+ const object = branches(schema, holder).find((b) => asObject(b.properties)?.[keys[keys.length - 1]] !== undefined);
48
+ return asObject(object?.properties);
49
+ }
50
+ export function kindedList(schema, pointer) {
51
+ const keys = pointerKeys(pointer);
52
+ const field = fieldSchema(schema, keys);
53
+ if (!field)
54
+ return undefined;
55
+ const items = branches(schema, field).map((b) => b.items).find((i) => i !== undefined);
56
+ if (items === undefined)
57
+ return undefined;
58
+ const itemNode = asObject(items) ?? {};
59
+ const declared = asObject(itemNode.discriminator)?.propertyName;
60
+ const shapes = branches(schema, items).filter((b) => asObject(b.properties));
61
+ const constants = (name) => shapes.map((s) => asObject(asObject(s.properties)[name])).map((p) => (p && "const" in p ? p.const : undefined));
62
+ let discriminator = typeof declared === "string" ? declared : undefined;
63
+ if (!discriminator && shapes.length) {
64
+ discriminator = Object.keys(asObject(shapes[0].properties)).find((name) => constants(name).every((c) => typeof c === "string"));
65
+ }
66
+ const siblings = siblingFields(schema, keys);
67
+ const kindsName = `${keys[keys.length - 1]}_kinds`;
68
+ const kindsNode = siblings?.[kindsName];
69
+ const fromKinds = kindsNode
70
+ ? branches(schema, kindsNode)
71
+ .map((b) => asObject(b.items))
72
+ .flatMap((i) => (i && Array.isArray(i.enum) ? i.enum : []))
73
+ .filter((k) => typeof k === "string")
74
+ : [];
75
+ const fromShapes = discriminator ? constants(discriminator).filter((c) => typeof c === "string") : [];
76
+ const known = fromKinds.length ? fromKinds : fromShapes;
77
+ return { ...(discriminator ? { discriminator } : {}), ...(kindsNode ? { kindsField: kindsName } : {}), ...(known.length ? { known } : {}) };
78
+ }
79
+ const kindOf = (entry, discriminator) => asObject(entry)?.[discriminator];
80
+ const label = (entry) => {
81
+ const id = asObject(entry)?.id;
82
+ return typeof id === "string" ? id : "?";
83
+ };
84
+ export function packageToSend(pkg, managed, schema) {
85
+ const out = structuredClone(pkg);
86
+ const result = { package: out, left_out: [], kinds: [] };
87
+ for (const pointer of managed.unmanaged) {
88
+ const keys = pointerKeys(pointer);
89
+ const parent = parentOf(out, keys);
90
+ const last = keys[keys.length - 1];
91
+ if (parent && last in parent) {
92
+ delete parent[last];
93
+ result.left_out.push(pointer);
94
+ }
95
+ }
96
+ for (const [pointer, kinds] of Object.entries(managed.kinds)) {
97
+ if (managed.unmanaged.includes(pointer))
98
+ continue;
99
+ const keys = pointerKeys(pointer);
100
+ const parent = parentOf(out, keys);
101
+ const last = keys[keys.length - 1];
102
+ const list = parent?.[last];
103
+ if (!parent || !Array.isArray(list))
104
+ continue;
105
+ const shape = schema ? kindedList(schema, pointer) : undefined;
106
+ if (!shape?.kindsField || !shape.discriminator) {
107
+ delete parent[last];
108
+ result.left_out.push(pointer);
109
+ result.kinds.push({
110
+ pointer,
111
+ kinds,
112
+ sent: false,
113
+ other_kinds_left_out: [],
114
+ reason: shape ? `this instance does not take ${last}_kinds, so an import would replace the whole list` : "this instance's package schema has no list here",
115
+ });
116
+ continue;
117
+ }
118
+ const discriminator = shape.discriminator;
119
+ const other = list.filter((entry) => !kinds.includes(String(kindOf(entry, discriminator))));
120
+ parent[last] = list.filter((entry) => kinds.includes(String(kindOf(entry, discriminator))));
121
+ parent[shape.kindsField] = [...kinds];
122
+ result.kinds.push({ pointer, kinds, sent: true, other_kinds_left_out: other.map(label) });
123
+ }
124
+ return result;
125
+ }
126
+ export function packageToWrite(pkg, managed, schema) {
127
+ if (!hasManagedFields(managed))
128
+ return pkg;
129
+ const out = structuredClone(pkg);
130
+ for (const pointer of managed.unmanaged) {
131
+ const keys = pointerKeys(pointer);
132
+ const parent = parentOf(out, keys);
133
+ if (parent)
134
+ delete parent[keys[keys.length - 1]];
135
+ }
136
+ for (const [pointer, kinds] of Object.entries(managed.kinds)) {
137
+ if (managed.unmanaged.includes(pointer))
138
+ continue;
139
+ const keys = pointerKeys(pointer);
140
+ const parent = parentOf(out, keys);
141
+ const last = keys[keys.length - 1];
142
+ const shape = schema ? kindedList(schema, pointer) : undefined;
143
+ if (!parent || !shape)
144
+ continue;
145
+ if (!shape.kindsField || !shape.discriminator) {
146
+ delete parent[last];
147
+ continue;
148
+ }
149
+ const discriminator = shape.discriminator;
150
+ const list = parent[last];
151
+ if (Array.isArray(list))
152
+ parent[last] = list.filter((entry) => kinds.includes(String(kindOf(entry, discriminator))));
153
+ delete parent[shape.kindsField];
154
+ }
155
+ return out;
156
+ }
157
+ export function checkManagedFields(disk, managed, schema) {
158
+ if (!hasManagedFields(managed))
159
+ return [];
160
+ const findings = [];
161
+ const unknown = (pointer, why) => findings.push({ code: MANAGED_SETTING_UNKNOWN_CODE, severity: "warning", file: "cavelon.yaml", path: pointer, message: `cavelon.yaml names ${pointer}, ${why}.` });
162
+ for (const pointer of managed.unmanaged) {
163
+ const keys = pointerKeys(pointer);
164
+ if (!fieldSchema(schema, keys))
165
+ unknown(pointer, "which is no field of this instance's package schema (a field inside a list cannot be named)");
166
+ const parent = parentOf(disk.package, keys);
167
+ if (parent && keys[keys.length - 1] in parent) {
168
+ findings.push({
169
+ code: UNMANAGED_SET_CODE,
170
+ severity: "warning",
171
+ ...locate(disk, pointer),
172
+ message: `cavelon.yaml lists ${pointer} as unmanaged, and the package sets it: apply leaves it out, so the instance keeps its own value.`,
173
+ });
174
+ }
175
+ }
176
+ for (const [pointer, kinds] of Object.entries(managed.kinds)) {
177
+ const shape = kindedList(schema, pointer);
178
+ if (!shape) {
179
+ unknown(pointer, "which is no list of this instance's package schema");
180
+ continue;
181
+ }
182
+ const strange = shape.known ? kinds.filter((k) => !shape.known.includes(k)) : [];
183
+ if (strange.length)
184
+ unknown(pointer, `with the kind${strange.length === 1 ? "" : "s"} ${strange.join(", ")}, which this instance does not know (it knows ${shape.known.join(", ")})`);
185
+ const keys = pointerKeys(pointer);
186
+ const list = parentOf(disk.package, keys)?.[keys[keys.length - 1]];
187
+ if (!Array.isArray(list))
188
+ continue;
189
+ if (!shape.kindsField || !shape.discriminator) {
190
+ findings.push({
191
+ code: MANAGED_KINDS_UNSUPPORTED_CODE,
192
+ severity: "warning",
193
+ ...locate(disk, pointer),
194
+ message: `This instance does not take ${keys[keys.length - 1]}_kinds, so an import of ${pointer} would replace all of the solution's entries, of every kind: apply leaves ${pointer} out.`,
195
+ });
196
+ continue;
197
+ }
198
+ const discriminator = shape.discriminator;
199
+ list.forEach((entry, i) => {
200
+ const kind = kindOf(entry, discriminator);
201
+ if (typeof kind === "string" && !kinds.includes(kind)) {
202
+ findings.push({
203
+ code: MANAGED_KINDS_LEFT_OUT_CODE,
204
+ severity: "warning",
205
+ ...locate(disk, `${pointer}/${i}`),
206
+ message: `"${label(entry)}" is of kind ${kind}, which cavelon.yaml's managed_kinds does not list for ${pointer} (${kinds.join(", ")}): apply leaves it out, and the instance keeps its own entries of that kind.`,
207
+ });
208
+ }
209
+ });
210
+ }
211
+ return findings;
212
+ }
@@ -30941,10 +30941,10 @@ function foldIntersection(json2) {
30941
30941
  if (Object.keys(union2).length !== 1)
30942
30942
  return;
30943
30943
  const rest = allOf.filter((m) => m !== union2);
30944
- const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
30945
- if (branches.some((b) => !b))
30944
+ const branches2 = union2[keyword].map((branch) => foldObjects([...rest, branch]));
30945
+ if (branches2.some((b) => !b))
30946
30946
  return;
30947
- folded = { [keyword]: branches };
30947
+ folded = { [keyword]: branches2 };
30948
30948
  }
30949
30949
  if (!folded)
30950
30950
  return;
@@ -31656,11 +31656,11 @@ function stringifyKeyNames(bySchema, json2, visited) {
31656
31656
  return inlined === def ? json2 : inlined;
31657
31657
  }
31658
31658
  for (const keyword of ["anyOf", "oneOf"]) {
31659
- const branches = json2[keyword];
31660
- if (!Array.isArray(branches))
31659
+ const branches2 = json2[keyword];
31660
+ if (!Array.isArray(branches2))
31661
31661
  continue;
31662
- const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
31663
- if (mapped.some((branch, i) => branch !== branches[i]))
31662
+ const mapped = branches2.map((branch) => stringifyKeyNames(bySchema, branch, visited));
31663
+ if (mapped.some((branch, i) => branch !== branches2[i]))
31664
31664
  json2 = { ...json2, [keyword]: mapped };
31665
31665
  }
31666
31666
  const types = Array.isArray(json2.type) ? json2.type : [json2.type];
@@ -38587,6 +38587,14 @@ var current2 = new AsyncLocalStorage();
38587
38587
  var PREVIEW_TOKEN_NAME = "confirm_token of its preview";
38588
38588
  var PREVIEW_TOKEN = `<${PREVIEW_TOKEN_NAME}>`;
38589
38589
 
38590
+ // src/local-state.ts
38591
+ var PREVIEW_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
38592
+
38593
+ // src/package-references.ts
38594
+ var SEARCH_TOOL_KEYS = /* @__PURE__ */ new Set(["search_documents", "search_knowledge_base", "search_kb"]);
38595
+ var KNOWLEDGE_TOOL_KEYS = /* @__PURE__ */ new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
38596
+ var DOCUMENT_TOOL_KEYS = /* @__PURE__ */ new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
38597
+
38590
38598
  // src/paths.ts
38591
38599
  function homeDir(env) {
38592
38600
  return env.HOME || env.USERPROFILE || os.homedir();
@@ -19636,10 +19636,10 @@ function foldIntersection(json) {
19636
19636
  if (Object.keys(union2).length !== 1)
19637
19637
  return;
19638
19638
  const rest = allOf.filter((m) => m !== union2);
19639
- const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
19640
- if (branches.some((b) => !b))
19639
+ const branches2 = union2[keyword].map((branch) => foldObjects([...rest, branch]));
19640
+ if (branches2.some((b) => !b))
19641
19641
  return;
19642
- folded = { [keyword]: branches };
19642
+ folded = { [keyword]: branches2 };
19643
19643
  }
19644
19644
  if (!folded)
19645
19645
  return;
@@ -20228,11 +20228,11 @@ function stringifyKeyNames(bySchema, json, visited) {
20228
20228
  return inlined === def ? json : inlined;
20229
20229
  }
20230
20230
  for (const keyword of ["anyOf", "oneOf"]) {
20231
- const branches = json[keyword];
20232
- if (!Array.isArray(branches))
20231
+ const branches2 = json[keyword];
20232
+ if (!Array.isArray(branches2))
20233
20233
  continue;
20234
- const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
20235
- if (mapped.some((branch, i) => branch !== branches[i]))
20234
+ const mapped = branches2.map((branch) => stringifyKeyNames(bySchema, branch, visited));
20235
+ if (mapped.some((branch, i) => branch !== branches2[i]))
20236
20236
  json = { ...json, [keyword]: mapped };
20237
20237
  }
20238
20238
  const types = Array.isArray(json.type) ? json.type : [json.type];
@@ -25278,6 +25278,14 @@ var current2 = new AsyncLocalStorage();
25278
25278
  var PREVIEW_TOKEN_NAME = "confirm_token of its preview";
25279
25279
  var PREVIEW_TOKEN = `<${PREVIEW_TOKEN_NAME}>`;
25280
25280
 
25281
+ // src/local-state.ts
25282
+ var PREVIEW_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
25283
+
25284
+ // src/package-references.ts
25285
+ var SEARCH_TOOL_KEYS = /* @__PURE__ */ new Set(["search_documents", "search_knowledge_base", "search_kb"]);
25286
+ var KNOWLEDGE_TOOL_KEYS = /* @__PURE__ */ new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
25287
+ var DOCUMENT_TOOL_KEYS = /* @__PURE__ */ new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
25288
+
25281
25289
  // src/paths.ts
25282
25290
  function homeDir(env) {
25283
25291
  return env.HOME || env.USERPROFILE || os.homedir();
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": 1,
3
- "version": "0.2.11",
3
+ "version": "0.2.12",
4
4
  "entries": {
5
5
  "omp": [
6
6
  "omp-extension.mjs"
@@ -25,13 +25,13 @@
25
25
  },
26
26
  {
27
27
  "path": "kilo-server.mjs",
28
- "size": 1496038,
29
- "sha256": "d6db56aea20cce2da0b262227b6079b45655109f82ea7ae61851aff6876514ce"
28
+ "size": 1496469,
29
+ "sha256": "95da367564676b7ba91aaca916646a44a4961ff3f70e3146d6f4336b60fd0cc2"
30
30
  },
31
31
  {
32
32
  "path": "kilo-tui.mjs",
33
- "size": 941608,
34
- "sha256": "21f4d44e1517c29282835b461357e3f20dabc9b834e74d47022e4051407ab0a1"
33
+ "size": 942039,
34
+ "sha256": "04350845fb33cf18e3427c237e1a93a93edef653492ae45dd12abc7c3c7ac316"
35
35
  },
36
36
  {
37
37
  "path": "LICENSE",
@@ -45,23 +45,23 @@
45
45
  },
46
46
  {
47
47
  "path": "omp-extension.mjs",
48
- "size": 1146200,
49
- "sha256": "900767ee9a235c4f32aa4ebb748a617d12dbc4b0d1d4838f454e93ceb183771f"
48
+ "size": 1146631,
49
+ "sha256": "9cbf90d1ca7be16e3125645b84bdc3da9c5d68105d8ac097e98dc04d13bfa577"
50
50
  },
51
51
  {
52
52
  "path": "opencode-server.mjs",
53
- "size": 1495026,
54
- "sha256": "a39a014328c1627070303be6b930f3a5dbb61c3fabbf6a898a9e8f54be31a4f6"
53
+ "size": 1495457,
54
+ "sha256": "d8db9272c893f90d4829ccfd292a023a1ae44dd04c305f0175a37e0a44788e43"
55
55
  },
56
56
  {
57
57
  "path": "opencode-tui.mjs",
58
- "size": 941514,
59
- "sha256": "4b4a75a8c46e3178213c6181359b5c89a634ec9795581ee34aee8b51a6b886b4"
58
+ "size": 941945,
59
+ "sha256": "5ab9edb04a894d77c50e09ca388bfac97a88a0be08cde5982a0a8f1234e65c3a"
60
60
  },
61
61
  {
62
62
  "path": "pi-extension.mjs",
63
- "size": 1146108,
64
- "sha256": "ae85ceedf4cca3a0a08dbd78bc108944295f826836a025ff634d3db6ca907dd3"
63
+ "size": 1146539,
64
+ "sha256": "0586cc60d914c5f9fd089e76389b4be601f2c0cf7d4d2729e728e35a8552f097"
65
65
  },
66
66
  {
67
67
  "path": "THIRD-PARTY-NOTICES",
@@ -23915,10 +23915,10 @@ function foldIntersection(json) {
23915
23915
  if (Object.keys(union2).length !== 1)
23916
23916
  return;
23917
23917
  const rest = allOf.filter((m) => m !== union2);
23918
- const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
23919
- if (branches.some((b) => !b))
23918
+ const branches2 = union2[keyword].map((branch) => foldObjects([...rest, branch]));
23919
+ if (branches2.some((b) => !b))
23920
23920
  return;
23921
- folded = { [keyword]: branches };
23921
+ folded = { [keyword]: branches2 };
23922
23922
  }
23923
23923
  if (!folded)
23924
23924
  return;
@@ -24507,11 +24507,11 @@ function stringifyKeyNames(bySchema, json, visited) {
24507
24507
  return inlined === def ? json : inlined;
24508
24508
  }
24509
24509
  for (const keyword of ["anyOf", "oneOf"]) {
24510
- const branches = json[keyword];
24511
- if (!Array.isArray(branches))
24510
+ const branches2 = json[keyword];
24511
+ if (!Array.isArray(branches2))
24512
24512
  continue;
24513
- const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
24514
- if (mapped.some((branch, i) => branch !== branches[i]))
24513
+ const mapped = branches2.map((branch) => stringifyKeyNames(bySchema, branch, visited));
24514
+ if (mapped.some((branch, i) => branch !== branches2[i]))
24515
24515
  json = { ...json, [keyword]: mapped };
24516
24516
  }
24517
24517
  const types = Array.isArray(json.type) ? json.type : [json.type];
@@ -29451,6 +29451,14 @@ var current2 = new AsyncLocalStorage();
29451
29451
  var PREVIEW_TOKEN_NAME = "confirm_token of its preview";
29452
29452
  var PREVIEW_TOKEN = `<${PREVIEW_TOKEN_NAME}>`;
29453
29453
 
29454
+ // src/local-state.ts
29455
+ var PREVIEW_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
29456
+
29457
+ // src/package-references.ts
29458
+ var SEARCH_TOOL_KEYS = /* @__PURE__ */ new Set(["search_documents", "search_knowledge_base", "search_kb"]);
29459
+ var KNOWLEDGE_TOOL_KEYS = /* @__PURE__ */ new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
29460
+ var DOCUMENT_TOOL_KEYS = /* @__PURE__ */ new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
29461
+
29454
29462
  // src/paths.ts
29455
29463
  function homeDir(env) {
29456
29464
  return env.HOME || env.USERPROFILE || os.homedir();
@@ -30938,10 +30938,10 @@ function foldIntersection(json2) {
30938
30938
  if (Object.keys(union2).length !== 1)
30939
30939
  return;
30940
30940
  const rest = allOf.filter((m) => m !== union2);
30941
- const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
30942
- if (branches.some((b) => !b))
30941
+ const branches2 = union2[keyword].map((branch) => foldObjects([...rest, branch]));
30942
+ if (branches2.some((b) => !b))
30943
30943
  return;
30944
- folded = { [keyword]: branches };
30944
+ folded = { [keyword]: branches2 };
30945
30945
  }
30946
30946
  if (!folded)
30947
30947
  return;
@@ -31653,11 +31653,11 @@ function stringifyKeyNames(bySchema, json2, visited) {
31653
31653
  return inlined === def ? json2 : inlined;
31654
31654
  }
31655
31655
  for (const keyword of ["anyOf", "oneOf"]) {
31656
- const branches = json2[keyword];
31657
- if (!Array.isArray(branches))
31656
+ const branches2 = json2[keyword];
31657
+ if (!Array.isArray(branches2))
31658
31658
  continue;
31659
- const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
31660
- if (mapped.some((branch, i) => branch !== branches[i]))
31659
+ const mapped = branches2.map((branch) => stringifyKeyNames(bySchema, branch, visited));
31660
+ if (mapped.some((branch, i) => branch !== branches2[i]))
31661
31661
  json2 = { ...json2, [keyword]: mapped };
31662
31662
  }
31663
31663
  const types = Array.isArray(json2.type) ? json2.type : [json2.type];
@@ -38587,6 +38587,14 @@ var current2 = new AsyncLocalStorage();
38587
38587
  var PREVIEW_TOKEN_NAME = "confirm_token of its preview";
38588
38588
  var PREVIEW_TOKEN = `<${PREVIEW_TOKEN_NAME}>`;
38589
38589
 
38590
+ // src/local-state.ts
38591
+ var PREVIEW_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
38592
+
38593
+ // src/package-references.ts
38594
+ var SEARCH_TOOL_KEYS = /* @__PURE__ */ new Set(["search_documents", "search_knowledge_base", "search_kb"]);
38595
+ var KNOWLEDGE_TOOL_KEYS = /* @__PURE__ */ new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
38596
+ var DOCUMENT_TOOL_KEYS = /* @__PURE__ */ new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
38597
+
38590
38598
  // src/paths.ts
38591
38599
  function homeDir(env) {
38592
38600
  return env.HOME || env.USERPROFILE || os.homedir();
@@ -19633,10 +19633,10 @@ function foldIntersection(json) {
19633
19633
  if (Object.keys(union2).length !== 1)
19634
19634
  return;
19635
19635
  const rest = allOf.filter((m) => m !== union2);
19636
- const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
19637
- if (branches.some((b) => !b))
19636
+ const branches2 = union2[keyword].map((branch) => foldObjects([...rest, branch]));
19637
+ if (branches2.some((b) => !b))
19638
19638
  return;
19639
- folded = { [keyword]: branches };
19639
+ folded = { [keyword]: branches2 };
19640
19640
  }
19641
19641
  if (!folded)
19642
19642
  return;
@@ -20225,11 +20225,11 @@ function stringifyKeyNames(bySchema, json, visited) {
20225
20225
  return inlined === def ? json : inlined;
20226
20226
  }
20227
20227
  for (const keyword of ["anyOf", "oneOf"]) {
20228
- const branches = json[keyword];
20229
- if (!Array.isArray(branches))
20228
+ const branches2 = json[keyword];
20229
+ if (!Array.isArray(branches2))
20230
20230
  continue;
20231
- const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
20232
- if (mapped.some((branch, i) => branch !== branches[i]))
20231
+ const mapped = branches2.map((branch) => stringifyKeyNames(bySchema, branch, visited));
20232
+ if (mapped.some((branch, i) => branch !== branches2[i]))
20233
20233
  json = { ...json, [keyword]: mapped };
20234
20234
  }
20235
20235
  const types = Array.isArray(json.type) ? json.type : [json.type];
@@ -25278,6 +25278,14 @@ var current2 = new AsyncLocalStorage();
25278
25278
  var PREVIEW_TOKEN_NAME = "confirm_token of its preview";
25279
25279
  var PREVIEW_TOKEN = `<${PREVIEW_TOKEN_NAME}>`;
25280
25280
 
25281
+ // src/local-state.ts
25282
+ var PREVIEW_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
25283
+
25284
+ // src/package-references.ts
25285
+ var SEARCH_TOOL_KEYS = /* @__PURE__ */ new Set(["search_documents", "search_knowledge_base", "search_kb"]);
25286
+ var KNOWLEDGE_TOOL_KEYS = /* @__PURE__ */ new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
25287
+ var DOCUMENT_TOOL_KEYS = /* @__PURE__ */ new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
25288
+
25281
25289
  // src/paths.ts
25282
25290
  function homeDir(env) {
25283
25291
  return env.HOME || env.USERPROFILE || os.homedir();
@@ -23915,10 +23915,10 @@ function foldIntersection(json) {
23915
23915
  if (Object.keys(union2).length !== 1)
23916
23916
  return;
23917
23917
  const rest = allOf.filter((m) => m !== union2);
23918
- const branches = union2[keyword].map((branch) => foldObjects([...rest, branch]));
23919
- if (branches.some((b) => !b))
23918
+ const branches2 = union2[keyword].map((branch) => foldObjects([...rest, branch]));
23919
+ if (branches2.some((b) => !b))
23920
23920
  return;
23921
- folded = { [keyword]: branches };
23921
+ folded = { [keyword]: branches2 };
23922
23922
  }
23923
23923
  if (!folded)
23924
23924
  return;
@@ -24507,11 +24507,11 @@ function stringifyKeyNames(bySchema, json, visited) {
24507
24507
  return inlined === def ? json : inlined;
24508
24508
  }
24509
24509
  for (const keyword of ["anyOf", "oneOf"]) {
24510
- const branches = json[keyword];
24511
- if (!Array.isArray(branches))
24510
+ const branches2 = json[keyword];
24511
+ if (!Array.isArray(branches2))
24512
24512
  continue;
24513
- const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
24514
- if (mapped.some((branch, i) => branch !== branches[i]))
24513
+ const mapped = branches2.map((branch) => stringifyKeyNames(bySchema, branch, visited));
24514
+ if (mapped.some((branch, i) => branch !== branches2[i]))
24515
24515
  json = { ...json, [keyword]: mapped };
24516
24516
  }
24517
24517
  const types = Array.isArray(json.type) ? json.type : [json.type];
@@ -29451,6 +29451,14 @@ var current2 = new AsyncLocalStorage();
29451
29451
  var PREVIEW_TOKEN_NAME = "confirm_token of its preview";
29452
29452
  var PREVIEW_TOKEN = `<${PREVIEW_TOKEN_NAME}>`;
29453
29453
 
29454
+ // src/local-state.ts
29455
+ var PREVIEW_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
29456
+
29457
+ // src/package-references.ts
29458
+ var SEARCH_TOOL_KEYS = /* @__PURE__ */ new Set(["search_documents", "search_knowledge_base", "search_kb"]);
29459
+ var KNOWLEDGE_TOOL_KEYS = /* @__PURE__ */ new Set([...SEARCH_TOOL_KEYS, "list_documents", "list_kb_docs"]);
29460
+ var DOCUMENT_TOOL_KEYS = /* @__PURE__ */ new Set([...KNOWLEDGE_TOOL_KEYS, "read_document", "save_document"]);
29461
+
29454
29462
  // src/paths.ts
29455
29463
  function homeDir(env) {
29456
29464
  return env.HOME || env.USERPROFILE || os.homedir();