@causyne/agent 1.20.121 → 1.20.122

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.
Files changed (256) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/src/acp/agentCatalog.js +81 -26
  4. package/src/acp/agentCatalog.ts +73 -29
  5. package/src/acp/client.js +210 -53
  6. package/src/acp/client.ts +202 -52
  7. package/src/acp/peerProfiles.js +55 -22
  8. package/src/acp/peerProfiles.ts +51 -22
  9. package/src/acp/protocol.js +37 -8
  10. package/src/acp/protocol.ts +30 -8
  11. package/src/acp/server.js +123 -25
  12. package/src/acp/server.ts +124 -24
  13. package/src/agent/errorClassifier.js +6 -2
  14. package/src/agent/errorClassifier.ts +6 -2
  15. package/src/agentLoop.js +11 -5
  16. package/src/agentLoop.ts +11 -5
  17. package/src/approvalGrants.js +19 -7
  18. package/src/approvalGrants.ts +20 -7
  19. package/src/approvalPolicy.js +48 -15
  20. package/src/approvalPolicy.ts +46 -15
  21. package/src/autoUpdate.js +5 -2
  22. package/src/autoUpdate.ts +5 -2
  23. package/src/browser/causyneBrowser.js +3 -2
  24. package/src/browser/causyneBrowser.ts +3 -2
  25. package/src/browser/searchProviders.js +1 -1
  26. package/src/browser/searchProviders.ts +1 -1
  27. package/src/config.js +287 -250
  28. package/src/config.ts +342 -0
  29. package/src/configVault.js +84 -17
  30. package/src/configVault.ts +77 -17
  31. package/src/continuum/compactor.js +2 -1
  32. package/src/continuum/compactor.ts +2 -1
  33. package/src/continuum/sanitizer.js +10 -3
  34. package/src/continuum/sanitizer.ts +9 -3
  35. package/src/continuum/ui/continuumPickerView.js +3 -2
  36. package/src/continuum/ui/continuumPickerView.ts +3 -2
  37. package/src/cortex/vectorDb.js +26 -15
  38. package/src/cortex/vectorDb.ts +26 -16
  39. package/src/creative/liveBridge.js +7 -5
  40. package/src/creative/liveBridge.ts +7 -5
  41. package/src/creative/studioScripts.js +16 -5
  42. package/src/creative/studioScripts.ts +14 -5
  43. package/src/decisionPolicy.js +16 -4
  44. package/src/decisionPolicy.ts +14 -4
  45. package/src/documentEngine/antiSlopAuditor.js +10 -5
  46. package/src/documentEngine/antiSlopAuditor.ts +11 -5
  47. package/src/documentEngine/documentForge.js +47 -15
  48. package/src/documentEngine/documentForge.ts +43 -14
  49. package/src/engines/design.js +2 -1
  50. package/src/engines/design.ts +2 -1
  51. package/src/engines/film.js +4 -4
  52. package/src/engines/film.ts +2 -2
  53. package/src/engines/light.js +2 -1
  54. package/src/engines/light.ts +2 -1
  55. package/src/engines/registry.js +1 -1
  56. package/src/engines/registry.ts +1 -1
  57. package/src/engines/reverseHarness.js +4 -3
  58. package/src/engines/reverseHarness.ts +4 -3
  59. package/src/headlessCli.js +2 -1
  60. package/src/headlessCli.ts +2 -1
  61. package/src/historyPruner.js +3 -2
  62. package/src/historyPruner.ts +3 -2
  63. package/src/hooks.js +3 -0
  64. package/src/hooks.ts +3 -0
  65. package/src/implementationPlan.js +21 -11
  66. package/src/implementationPlan.ts +21 -11
  67. package/src/infra/atomicWriter.js +4 -1
  68. package/src/infra/atomicWriter.ts +4 -1
  69. package/src/launchIntent.js +1 -1
  70. package/src/launchIntent.ts +1 -1
  71. package/src/memory/scopedFacts.js +1 -1
  72. package/src/memory/scopedFacts.ts +1 -1
  73. package/src/memory/symbolFolder.js +1 -1
  74. package/src/memory/symbolFolder.ts +1 -1
  75. package/src/modelRouter.js +1 -1
  76. package/src/modelRouter.ts +1 -1
  77. package/src/observer/evidence.js +10 -4
  78. package/src/observer/evidence.ts +10 -4
  79. package/src/osKeychain.js +62 -8
  80. package/src/osKeychain.ts +50 -8
  81. package/src/perception.js +3 -2
  82. package/src/perception.ts +3 -2
  83. package/src/planCache.js +2 -2
  84. package/src/planCache.ts +2 -2
  85. package/src/pluginsFactory/pluginsFactory.js +19 -11
  86. package/src/pluginsFactory/pluginsFactory.ts +18 -11
  87. package/src/promptMentions.js +2 -2
  88. package/src/promptMentions.ts +2 -2
  89. package/src/providers/acp.js +1 -1
  90. package/src/providers/acp.ts +1 -1
  91. package/src/providers/anthropic.js +327 -401
  92. package/src/providers/anthropic.ts +386 -0
  93. package/src/providers/antigravity.js +10 -4
  94. package/src/providers/antigravity.ts +10 -4
  95. package/src/providers/base.js +221 -319
  96. package/src/providers/base.ts +340 -0
  97. package/src/providers/byokHttp.js +58 -15
  98. package/src/providers/byokHttp.ts +59 -16
  99. package/src/providers/byokStream.js +142 -51
  100. package/src/providers/byokStream.ts +146 -42
  101. package/src/providers/dashscope-byok.js +97 -89
  102. package/src/providers/dashscope-byok.ts +114 -0
  103. package/src/providers/deepseek.js +73 -72
  104. package/src/providers/deepseek.ts +99 -0
  105. package/src/providers/factory.js +35 -28
  106. package/src/providers/factory.ts +40 -0
  107. package/src/providers/gemini.js +227 -278
  108. package/src/providers/gemini.ts +261 -0
  109. package/src/providers/loopGuard.js +9 -5
  110. package/src/providers/loopGuard.ts +10 -5
  111. package/src/providers/moonshot.js +70 -72
  112. package/src/providers/moonshot.ts +93 -0
  113. package/src/providers/muse.js +82 -152
  114. package/src/providers/muse.ts +122 -0
  115. package/src/providers/ollama.js +114 -106
  116. package/src/providers/ollama.ts +135 -0
  117. package/src/providers/openai-compatible.js +113 -96
  118. package/src/providers/openai-compatible.ts +139 -0
  119. package/src/providers/openai.js +22 -15
  120. package/src/providers/openai.ts +30 -0
  121. package/src/providers/openrouter.js +136 -74
  122. package/src/providers/openrouter.ts +133 -72
  123. package/src/providers/pi.js +6 -0
  124. package/src/providers/pi.ts +6 -0
  125. package/src/providers/qwen-byok.js +96 -87
  126. package/src/providers/qwen-byok.ts +113 -0
  127. package/src/providers/toolContracts.js +40 -14
  128. package/src/providers/toolContracts.ts +35 -14
  129. package/src/providers/wireNormalizer.js +78 -11
  130. package/src/providers/wireNormalizer.ts +68 -12
  131. package/src/providers/xai.js +73 -72
  132. package/src/providers/xai.ts +97 -0
  133. package/src/reliability/assetEvidence.js +4 -2
  134. package/src/reliability/assetEvidence.ts +4 -2
  135. package/src/sandbox.js +489 -554
  136. package/src/sandbox.ts +552 -0
  137. package/src/sandboxPolicy.js +95 -16
  138. package/src/sandboxPolicy.ts +97 -16
  139. package/src/sessionJournal.js +8 -3
  140. package/src/sessionJournal.ts +9 -3
  141. package/src/skills/skillResourceSafety.js +19 -8
  142. package/src/skills/skillResourceSafety.ts +16 -7
  143. package/src/skillsManager.js +3 -3
  144. package/src/skillsManager.ts +3 -3
  145. package/src/smartToolsUse.js +28 -4
  146. package/src/smartToolsUse.ts +29 -7
  147. package/src/stallGuard.js +45 -22
  148. package/src/stallGuard.ts +46 -22
  149. package/src/subagentJournal.js +6 -4
  150. package/src/subagentJournal.ts +6 -4
  151. package/src/textDiff.js +6 -1
  152. package/src/textDiff.ts +6 -1
  153. package/src/timeMachine.js +7 -1
  154. package/src/timeMachine.ts +7 -1
  155. package/src/tokenTracker.js +43 -28
  156. package/src/tokenTracker.ts +44 -30
  157. package/src/toolPacks.js +3 -1
  158. package/src/toolPacks.ts +3 -1
  159. package/src/tools/archive.js +245 -35
  160. package/src/tools/archive.ts +244 -35
  161. package/src/tools/computerUse.js +7 -3
  162. package/src/tools/computerUse.ts +7 -3
  163. package/src/tools/creativeApps.js +13 -8
  164. package/src/tools/creativeApps.ts +22 -9
  165. package/src/tools/deferredMcpSearch.js +26 -14
  166. package/src/tools/deferredMcpSearch.ts +26 -14
  167. package/src/tools/desktopOpen.js +69 -10
  168. package/src/tools/desktopOpen.ts +70 -11
  169. package/src/tools/documentForge.js +167 -82
  170. package/src/tools/documentForge.ts +169 -84
  171. package/src/tools/fsEdit.js +101 -30
  172. package/src/tools/fsEdit.ts +105 -32
  173. package/src/tools/fsFind.js +8 -5
  174. package/src/tools/fsFind.ts +7 -4
  175. package/src/tools/fsRead.js +119 -13
  176. package/src/tools/fsRead.ts +124 -13
  177. package/src/tools/fsWrite.js +17 -5
  178. package/src/tools/fsWrite.ts +17 -7
  179. package/src/tools/generateMediaViaApi.js +82 -19
  180. package/src/tools/generateMediaViaApi.ts +80 -19
  181. package/src/tools/memoryRecall.js +62 -11
  182. package/src/tools/memoryRecall.ts +70 -13
  183. package/src/tools/memoryWrite.js +27 -14
  184. package/src/tools/memoryWrite.ts +30 -14
  185. package/src/tools/multiEdit.js +100 -30
  186. package/src/tools/multiEdit.ts +104 -32
  187. package/src/tools/nativeEngine.js +33 -18
  188. package/src/tools/nativeEngine.ts +31 -18
  189. package/src/tools/openSourceToolProvisioner.js +49 -14
  190. package/src/tools/openSourceToolProvisioner.ts +54 -15
  191. package/src/tools/osSandbox.js +54 -14
  192. package/src/tools/osSandbox.ts +48 -14
  193. package/src/tools/payloadSanitizer.js +40 -8
  194. package/src/tools/payloadSanitizer.ts +39 -8
  195. package/src/tools/peerAgent.js +96 -34
  196. package/src/tools/peerAgent.ts +114 -37
  197. package/src/tools/pluginsFactory.js +38 -6
  198. package/src/tools/pluginsFactory.ts +42 -6
  199. package/src/tools/readNativeSkill.js +10 -8
  200. package/src/tools/readNativeSkill.ts +10 -8
  201. package/src/tools/requestDecision.js +10 -3
  202. package/src/tools/requestDecision.ts +10 -3
  203. package/src/tools/resolveAutomator.js +91 -17
  204. package/src/tools/resolveAutomator.ts +102 -17
  205. package/src/tools/reverseEngineering.js +168 -41
  206. package/src/tools/reverseEngineering.ts +161 -41
  207. package/src/tools/sysRun.js +69 -29
  208. package/src/tools/sysRun.ts +66 -24
  209. package/src/tools/toolDispatch.js +24 -1
  210. package/src/tools/toolDispatch.ts +21 -1
  211. package/src/tools/toolOutputStore.js +62 -23
  212. package/src/tools/toolOutputStore.ts +56 -23
  213. package/src/tools/toolScanner.js +13 -10
  214. package/src/tools/toolScanner.ts +13 -10
  215. package/src/tools/toolSelfRepair.js +94 -28
  216. package/src/tools/toolSelfRepair.ts +96 -28
  217. package/src/tools/uiForge.js +71 -6
  218. package/src/tools/uiForge.ts +74 -6
  219. package/src/tools/viewImage.js +62 -17
  220. package/src/tools/viewImage.ts +57 -12
  221. package/src/tools/visionInspector.js +15 -3
  222. package/src/tools/visionInspector.ts +15 -3
  223. package/src/tools/walkerSafety.js +2 -0
  224. package/src/tools/walkerSafety.ts +1 -0
  225. package/src/tools/webFetch.js +105 -10
  226. package/src/tools/webFetch.ts +105 -11
  227. package/src/tui/banner.js +3 -2
  228. package/src/tui/banner.ts +3 -2
  229. package/src/tui/consoleGuard.js +12 -4
  230. package/src/tui/consoleGuard.ts +9 -4
  231. package/src/tui/messageInteraction.js +2 -3
  232. package/src/tui/messageInteraction.ts +2 -3
  233. package/src/tui/modelPicker.js +1 -0
  234. package/src/tui/modelPicker.ts +1 -0
  235. package/src/tui/overlay.js +3 -1
  236. package/src/tui/overlay.ts +3 -1
  237. package/src/tui/sessionPicker.js +3 -2
  238. package/src/tui/sessionPicker.ts +3 -2
  239. package/src/tui/sessionPickerView.js +7 -1
  240. package/src/tui/sessionPickerView.ts +6 -1
  241. package/src/tui/toolOutputNormalizer.js +2 -3
  242. package/src/tui/toolOutputNormalizer.ts +4 -3
  243. package/src/tui/viewport.js +4 -4
  244. package/src/tui/viewport.ts +5 -5
  245. package/src/tui/workspaceIdentity.js +2 -1
  246. package/src/tui/workspaceIdentity.ts +2 -1
  247. package/src/uncertainty.js +8 -3
  248. package/src/uncertainty.ts +8 -3
  249. package/src/utils/paths.js +8 -5
  250. package/src/utils/paths.ts +9 -7
  251. package/src/vfeTracker.js +9 -3
  252. package/src/vfeTracker.ts +9 -3
  253. package/src/config.d.ts +0 -2
  254. package/src/providers/base.d.ts +0 -94
  255. package/src/providers/factory.d.ts +0 -1
  256. package/src/sandbox.d.ts +0 -1
@@ -18,6 +18,7 @@ import os from 'node:os';
18
18
  import path from 'node:path';
19
19
  import { isWithinPhysicalPath, physicalPath } from './agent/workspaceBoundary.js';
20
20
  const MAX_SUBSTITUTION_DEPTH = 16;
21
+ const MAX_SUBSTITUTIONS = 64;
21
22
  const SAFE_ENV_TEMPLATE_EXACT = new Set([
22
23
  '.env.example',
23
24
  '.env.sample',
@@ -52,7 +53,12 @@ const CREDENTIAL_EXACT_BASENAMES = new Set([
52
53
  'id_ecdsa',
53
54
  'id_dsa',
54
55
  'credentials.json',
55
- 'application_default_credentials.json'
56
+ 'application_default_credentials.json',
57
+ '.htpasswd',
58
+ 'kubeconfig',
59
+ 'terraform.tfvars',
60
+ 'terraform.tfvars.json',
61
+ '.terraformrc'
56
62
  ]);
57
63
  const SENSITIVE_WRITE_EXACT_BASENAMES = new Set([
58
64
  '.bashrc',
@@ -132,7 +138,17 @@ function isWithinForPlatform(child, parent, platform) {
132
138
  }
133
139
  return isWithinPhysicalPath(child, parent);
134
140
  }
135
- function isBlockedResolvedRoot(candidate, platform) {
141
+ function stripWindowsDevicePrefix(candidate) {
142
+ if (candidate.startsWith('\\\\?\\') || candidate.startsWith('\\\\.\\')) {
143
+ return candidate.slice(4);
144
+ }
145
+ if (candidate.startsWith('//?/') || candidate.startsWith('//./')) {
146
+ return candidate.slice(4);
147
+ }
148
+ return candidate;
149
+ }
150
+ function isBlockedResolvedRoot(rawCandidate, platform) {
151
+ const candidate = platform === 'win32' ? stripWindowsDevicePrefix(rawCandidate) : rawCandidate;
136
152
  const pathApi = platform === 'win32' ? path.win32 : path.posix;
137
153
  const parsedRoot = pathApi.parse(candidate).root;
138
154
  if (parsedRoot && candidate.toLowerCase() === parsedRoot.toLowerCase()) {
@@ -161,7 +177,7 @@ function isBlockedResolvedRoot(candidate, platform) {
161
177
  * Used uniformly by `updateWorkspacePaths()` and `addWorkspacePath()`.
162
178
  */
163
179
  export function isBlockedWorkspaceRoot(targetPath, options) {
164
- if (typeof targetPath !== 'string' || targetPath.trim().length === 0)
180
+ if (typeof targetPath !== 'string' || targetPath.trim().length === 0 || targetPath.includes('\0'))
165
181
  return true;
166
182
  const platform = options?.platform ?? process.platform;
167
183
  const expanded = expandLeadingTilde(targetPath.trim());
@@ -183,7 +199,7 @@ export function isBlockedWorkspaceRoot(targetPath, options) {
183
199
  * `.env.template`, and `.env.dist` templates to prevent developer false positives.
184
200
  */
185
201
  export function isExtendedCredentialPath(targetPath) {
186
- if (typeof targetPath !== 'string' || targetPath.length === 0)
202
+ if (typeof targetPath !== 'string' || targetPath.length === 0 || targetPath.includes('\0'))
187
203
  return false;
188
204
  const normalized = targetPath.replace(/\\/g, '/').trim();
189
205
  if (!normalized)
@@ -204,6 +220,10 @@ export function isExtendedCredentialPath(targetPath) {
204
220
  return true;
205
221
  if (lowerParts[i] === '.docker' && lowerParts[i + 1] === 'config.json')
206
222
  return true;
223
+ if (lowerParts[i] === 'gh' && lowerParts[i + 1] === 'hosts.yml')
224
+ return true;
225
+ if (lowerParts[i] === 'gcloud' && (lowerParts[i + 1] === 'credentials.db' || lowerParts[i + 1] === 'access_tokens.db'))
226
+ return true;
207
227
  }
208
228
  const baseLower = lowerParts[lowerParts.length - 1] ?? '';
209
229
  if (CREDENTIAL_EXACT_BASENAMES.has(baseLower))
@@ -223,6 +243,12 @@ export function isExtendedCredentialPath(targetPath) {
223
243
  baseLower.endsWith('.json')) {
224
244
  return true;
225
245
  }
246
+ const isSafeTemplate = SAFE_ENV_TEMPLATE_SUFFIXES.some(suffix => baseLower.endsWith(suffix));
247
+ if (!isSafeTemplate &&
248
+ !baseLower.endsWith('.pub') &&
249
+ (baseLower.endsWith('.pem') || baseLower.endsWith('.key') || baseLower.endsWith('.p12') || baseLower.endsWith('.pfx'))) {
250
+ return true;
251
+ }
226
252
  return false;
227
253
  }
228
254
  /**
@@ -230,7 +256,7 @@ export function isExtendedCredentialPath(targetPath) {
230
256
  * for shell redirection (`>`, `>>`) or `tee`.
231
257
  */
232
258
  export function isSensitiveWriteTarget(rawTarget) {
233
- if (typeof rawTarget !== 'string' || rawTarget.length === 0)
259
+ if (typeof rawTarget !== 'string' || rawTarget.length === 0 || rawTarget.includes('\0'))
234
260
  return false;
235
261
  let target = rawTarget.trim();
236
262
  if ((target.startsWith('"') && target.endsWith('"') && target.length >= 2) ||
@@ -250,6 +276,12 @@ export function isSensitiveWriteTarget(rawTarget) {
250
276
  const slash = target.indexOf('/');
251
277
  target = `/home/user${target.slice(slash)}`;
252
278
  }
279
+ else if (target.startsWith('$ZDOTDIR/') ||
280
+ target.startsWith('${ZDOTDIR}/') ||
281
+ /^%(?:userprofile|home|appdata)%\//i.test(target)) {
282
+ const slash = target.indexOf('/');
283
+ target = `/home/user${target.slice(slash)}`;
284
+ }
253
285
  const lower = target.toLowerCase();
254
286
  const parts = lower.split('/').filter(Boolean);
255
287
  if (parts.length === 0)
@@ -360,11 +392,18 @@ export function parseMaskAndExtractSubstitutions(input, depth = 0) {
360
392
  masked += ch;
361
393
  i++;
362
394
  }
363
- if (depth < MAX_SUBSTITUTION_DEPTH && substitutions.length > 0) {
395
+ if (substitutions.length > MAX_SUBSTITUTIONS) {
396
+ substitutions.length = MAX_SUBSTITUTIONS;
397
+ }
398
+ if (depth < MAX_SUBSTITUTION_DEPTH && substitutions.length > 0 && substitutions.length < MAX_SUBSTITUTIONS) {
364
399
  const nested = [];
365
400
  for (const sub of substitutions) {
401
+ if (substitutions.length + nested.length >= MAX_SUBSTITUTIONS)
402
+ break;
366
403
  const parsed = parseMaskAndExtractSubstitutions(sub, depth + 1);
367
404
  for (const deeper of parsed.substitutions) {
405
+ if (substitutions.length + nested.length >= MAX_SUBSTITUTIONS)
406
+ break;
368
407
  nested.push(deeper);
369
408
  }
370
409
  }
@@ -666,7 +705,7 @@ export function normalizeExecutableSegment(segment) {
666
705
  idx = scan;
667
706
  continue;
668
707
  }
669
- if (base === 'nohup' || base === 'builtin') {
708
+ if (base === 'nohup' || base === 'builtin' || base === 'setsid') {
670
709
  idx++;
671
710
  if (tokens[idx] === '--')
672
711
  idx++;
@@ -715,7 +754,7 @@ export function normalizeExecutableSegment(segment) {
715
754
  }
716
755
  continue;
717
756
  }
718
- if (base === 'stdbuf') {
757
+ if (base === 'stdbuf' || base === 'ionice' || base === 'taskset') {
719
758
  idx++;
720
759
  while (idx < tokens.length && tokens[idx].startsWith('-')) {
721
760
  const flag = tokens[idx];
@@ -723,7 +762,7 @@ export function normalizeExecutableSegment(segment) {
723
762
  idx++;
724
763
  break;
725
764
  }
726
- if (flag === '-i' || flag === '-o' || flag === '-e') {
765
+ if (flag === '-i' || flag === '-o' || flag === '-e' || flag === '-c' || flag === '-n' || flag === '-p') {
727
766
  idx += 2;
728
767
  continue;
729
768
  }
@@ -963,11 +1002,15 @@ export function extractWriteTargetsFromRaw(rawCommand) {
963
1002
  continue;
964
1003
  }
965
1004
  if (ch === '>') {
966
- // Handle `>>`, `>|`, and ignore descriptor duplications `>&1`, `>&2`, `>&-`
1005
+ // Handle `>>`, `>|`, and `>&`: FD duplications (`2>&1`, `>&2`, `>&-`) are not files,
1006
+ // whereas `>& file` in Bash/Zsh redirects stdout+stderr to `file`.
967
1007
  let next = i + 1;
968
1008
  if (rawCommand[next] === '&') {
969
- // Descriptor duplication (e.g. `2>&1`, `>&2`) is not a file target
970
- i = next + 1;
1009
+ const { word, nextIndex } = readShellWord(next + 1);
1010
+ if (word && !/^(?:\d+-?|-)$/.test(word)) {
1011
+ targets.push(word);
1012
+ }
1013
+ i = nextIndex;
971
1014
  continue;
972
1015
  }
973
1016
  if (rawCommand[next] === '>' || rawCommand[next] === '|') {
@@ -1100,6 +1143,13 @@ export function isExtremeRemovalSegment(seg) {
1100
1143
  target.startsWith('~/') ||
1101
1144
  target.startsWith('~') ||
1102
1145
  target.startsWith('*') ||
1146
+ target === '.' ||
1147
+ target === './' ||
1148
+ target.startsWith('./*') ||
1149
+ target === '..' ||
1150
+ target === '../' ||
1151
+ target.startsWith('../*') ||
1152
+ /^[a-z]:[\\/]?$/.test(target) ||
1103
1153
  target === '$home' ||
1104
1154
  target.startsWith('$home/') ||
1105
1155
  target === '${home}' ||
@@ -1130,11 +1180,29 @@ export function isFetchAndExecPipeline(pipelines) {
1130
1180
  continue;
1131
1181
  if (SHELL_INTERPRETERS.has(stage.executable))
1132
1182
  return true;
1133
- // Handle `curl ... | sudo bash` or `curl ... | sudo -E sh`
1134
- if (stage.executable === 'sudo' || stage.executable === 'su') {
1135
- for (const arg of stage.args) {
1136
- if (arg.startsWith('-'))
1183
+ // Handle `curl ... | sudo|su|doas|pkexec|xargs bash`
1184
+ if (stage.executable === 'sudo' ||
1185
+ stage.executable === 'su' ||
1186
+ stage.executable === 'doas' ||
1187
+ stage.executable === 'pkexec' ||
1188
+ stage.executable === 'xargs') {
1189
+ const valueFlags = new Set([
1190
+ '-u', '-g', '-c', '-d', '-h', '-p', '-r', '-t', '-a', '-s',
1191
+ '--user', '--group', '--prompt', '--chdir', '--shell'
1192
+ ]);
1193
+ for (let i = 0; i < stage.args.length; i++) {
1194
+ const arg = stage.args[i];
1195
+ if (arg === '--') {
1196
+ const next = stage.args[i + 1];
1197
+ if (next && SHELL_INTERPRETERS.has(resolveExecutableBasename(next)))
1198
+ return true;
1199
+ break;
1200
+ }
1201
+ if (arg.startsWith('-')) {
1202
+ if (valueFlags.has(arg))
1203
+ i++;
1137
1204
  continue;
1205
+ }
1138
1206
  if (SHELL_INTERPRETERS.has(resolveExecutableBasename(arg)))
1139
1207
  return true;
1140
1208
  break;
@@ -1149,6 +1217,17 @@ export function isFetchAndExecPipeline(pipelines) {
1149
1217
  * substitutions) into normalized executable segments, pipelines, and write targets.
1150
1218
  */
1151
1219
  export function analyzeShellCommand(rawCommand) {
1220
+ if (typeof rawCommand !== 'string') {
1221
+ return {
1222
+ maskedTopLevel: '',
1223
+ allRawUnits: [],
1224
+ allMaskedUnits: [],
1225
+ normalizedSegments: [],
1226
+ unwrappedRawSegments: [],
1227
+ normalizedPipelines: [],
1228
+ writeTargets: []
1229
+ };
1230
+ }
1152
1231
  const lower = rawCommand.trim().toLowerCase();
1153
1232
  const topParsed = parseMaskAndExtractSubstitutions(lower, 0);
1154
1233
  const allRawUnits = [rawCommand.trim()];
@@ -20,6 +20,7 @@ import path from 'node:path';
20
20
  import { isWithinPhysicalPath, physicalPath } from './agent/workspaceBoundary.js';
21
21
 
22
22
  const MAX_SUBSTITUTION_DEPTH = 16;
23
+ const MAX_SUBSTITUTIONS = 64;
23
24
 
24
25
  const SAFE_ENV_TEMPLATE_EXACT = new Set([
25
26
  '.env.example',
@@ -58,7 +59,12 @@ const CREDENTIAL_EXACT_BASENAMES = new Set([
58
59
  'id_ecdsa',
59
60
  'id_dsa',
60
61
  'credentials.json',
61
- 'application_default_credentials.json'
62
+ 'application_default_credentials.json',
63
+ '.htpasswd',
64
+ 'kubeconfig',
65
+ 'terraform.tfvars',
66
+ 'terraform.tfvars.json',
67
+ '.terraformrc'
62
68
  ]);
63
69
 
64
70
  const SENSITIVE_WRITE_EXACT_BASENAMES = new Set([
@@ -145,7 +151,18 @@ function isWithinForPlatform(child: string, parent: string, platform: NodeJS.Pla
145
151
  return isWithinPhysicalPath(child, parent);
146
152
  }
147
153
 
148
- function isBlockedResolvedRoot(candidate: string, platform: NodeJS.Platform): boolean {
154
+ function stripWindowsDevicePrefix(candidate: string): string {
155
+ if (candidate.startsWith('\\\\?\\') || candidate.startsWith('\\\\.\\')) {
156
+ return candidate.slice(4);
157
+ }
158
+ if (candidate.startsWith('//?/') || candidate.startsWith('//./')) {
159
+ return candidate.slice(4);
160
+ }
161
+ return candidate;
162
+ }
163
+
164
+ function isBlockedResolvedRoot(rawCandidate: string, platform: NodeJS.Platform): boolean {
165
+ const candidate = platform === 'win32' ? stripWindowsDevicePrefix(rawCandidate) : rawCandidate;
149
166
  const pathApi = platform === 'win32' ? path.win32 : path.posix;
150
167
  const parsedRoot = pathApi.parse(candidate).root;
151
168
  if (parsedRoot && candidate.toLowerCase() === parsedRoot.toLowerCase()) {
@@ -181,7 +198,7 @@ export function isBlockedWorkspaceRoot(
181
198
  targetPath: string,
182
199
  options?: { platform?: NodeJS.Platform | undefined }
183
200
  ): boolean {
184
- if (typeof targetPath !== 'string' || targetPath.trim().length === 0) return true;
201
+ if (typeof targetPath !== 'string' || targetPath.trim().length === 0 || targetPath.includes('\0')) return true;
185
202
  const platform = options?.platform ?? process.platform;
186
203
  const expanded = expandLeadingTilde(targetPath.trim());
187
204
  const resolved = platform === 'win32' ? path.win32.resolve(expanded) : path.resolve(expanded);
@@ -203,7 +220,7 @@ export function isBlockedWorkspaceRoot(
203
220
  * `.env.template`, and `.env.dist` templates to prevent developer false positives.
204
221
  */
205
222
  export function isExtendedCredentialPath(targetPath: string): boolean {
206
- if (typeof targetPath !== 'string' || targetPath.length === 0) return false;
223
+ if (typeof targetPath !== 'string' || targetPath.length === 0 || targetPath.includes('\0')) return false;
207
224
  const normalized = targetPath.replace(/\\/g, '/').trim();
208
225
  if (!normalized) return false;
209
226
 
@@ -222,6 +239,8 @@ export function isExtendedCredentialPath(targetPath: string): boolean {
222
239
  for (let i = 0; i < lowerParts.length - 1; i++) {
223
240
  if (lowerParts[i] === 'library' && lowerParts[i + 1] === 'keychains') return true;
224
241
  if (lowerParts[i] === '.docker' && lowerParts[i + 1] === 'config.json') return true;
242
+ if (lowerParts[i] === 'gh' && lowerParts[i + 1] === 'hosts.yml') return true;
243
+ if (lowerParts[i] === 'gcloud' && (lowerParts[i + 1] === 'credentials.db' || lowerParts[i + 1] === 'access_tokens.db')) return true;
225
244
  }
226
245
 
227
246
  const baseLower = lowerParts[lowerParts.length - 1] ?? '';
@@ -243,6 +262,15 @@ export function isExtendedCredentialPath(targetPath: string): boolean {
243
262
  return true;
244
263
  }
245
264
 
265
+ const isSafeTemplate = SAFE_ENV_TEMPLATE_SUFFIXES.some(suffix => baseLower.endsWith(suffix));
266
+ if (
267
+ !isSafeTemplate &&
268
+ !baseLower.endsWith('.pub') &&
269
+ (baseLower.endsWith('.pem') || baseLower.endsWith('.key') || baseLower.endsWith('.p12') || baseLower.endsWith('.pfx'))
270
+ ) {
271
+ return true;
272
+ }
273
+
246
274
  return false;
247
275
  }
248
276
 
@@ -251,7 +279,7 @@ export function isExtendedCredentialPath(targetPath: string): boolean {
251
279
  * for shell redirection (`>`, `>>`) or `tee`.
252
280
  */
253
281
  export function isSensitiveWriteTarget(rawTarget: string): boolean {
254
- if (typeof rawTarget !== 'string' || rawTarget.length === 0) return false;
282
+ if (typeof rawTarget !== 'string' || rawTarget.length === 0 || rawTarget.includes('\0')) return false;
255
283
 
256
284
  let target = rawTarget.trim();
257
285
  if (
@@ -271,6 +299,13 @@ export function isSensitiveWriteTarget(rawTarget: string): boolean {
271
299
  } else if (target.startsWith('$HOME/') || target.startsWith('${HOME}/')) {
272
300
  const slash = target.indexOf('/');
273
301
  target = `/home/user${target.slice(slash)}`;
302
+ } else if (
303
+ target.startsWith('$ZDOTDIR/') ||
304
+ target.startsWith('${ZDOTDIR}/') ||
305
+ /^%(?:userprofile|home|appdata)%\//i.test(target)
306
+ ) {
307
+ const slash = target.indexOf('/');
308
+ target = `/home/user${target.slice(slash)}`;
274
309
  }
275
310
 
276
311
  const lower = target.toLowerCase();
@@ -395,11 +430,16 @@ export function parseMaskAndExtractSubstitutions(
395
430
  i++;
396
431
  }
397
432
 
398
- if (depth < MAX_SUBSTITUTION_DEPTH && substitutions.length > 0) {
433
+ if (substitutions.length > MAX_SUBSTITUTIONS) {
434
+ substitutions.length = MAX_SUBSTITUTIONS;
435
+ }
436
+ if (depth < MAX_SUBSTITUTION_DEPTH && substitutions.length > 0 && substitutions.length < MAX_SUBSTITUTIONS) {
399
437
  const nested: string[] = [];
400
438
  for (const sub of substitutions) {
439
+ if (substitutions.length + nested.length >= MAX_SUBSTITUTIONS) break;
401
440
  const parsed = parseMaskAndExtractSubstitutions(sub, depth + 1);
402
441
  for (const deeper of parsed.substitutions) {
442
+ if (substitutions.length + nested.length >= MAX_SUBSTITUTIONS) break;
403
443
  nested.push(deeper);
404
444
  }
405
445
  }
@@ -737,7 +777,7 @@ export function normalizeExecutableSegment(segment: string): NormalizedSegment {
737
777
  continue;
738
778
  }
739
779
 
740
- if (base === 'nohup' || base === 'builtin') {
780
+ if (base === 'nohup' || base === 'builtin' || base === 'setsid') {
741
781
  idx++;
742
782
  if (tokens[idx] === '--') idx++;
743
783
  continue;
@@ -789,7 +829,7 @@ export function normalizeExecutableSegment(segment: string): NormalizedSegment {
789
829
  continue;
790
830
  }
791
831
 
792
- if (base === 'stdbuf') {
832
+ if (base === 'stdbuf' || base === 'ionice' || base === 'taskset') {
793
833
  idx++;
794
834
  while (idx < tokens.length && tokens[idx]!.startsWith('-')) {
795
835
  const flag = tokens[idx]!;
@@ -797,7 +837,7 @@ export function normalizeExecutableSegment(segment: string): NormalizedSegment {
797
837
  idx++;
798
838
  break;
799
839
  }
800
- if (flag === '-i' || flag === '-o' || flag === '-e') {
840
+ if (flag === '-i' || flag === '-o' || flag === '-e' || flag === '-c' || flag === '-n' || flag === '-p') {
801
841
  idx += 2;
802
842
  continue;
803
843
  }
@@ -1045,11 +1085,15 @@ export function extractWriteTargetsFromRaw(rawCommand: string): string[] {
1045
1085
  }
1046
1086
 
1047
1087
  if (ch === '>') {
1048
- // Handle `>>`, `>|`, and ignore descriptor duplications `>&1`, `>&2`, `>&-`
1088
+ // Handle `>>`, `>|`, and `>&`: FD duplications (`2>&1`, `>&2`, `>&-`) are not files,
1089
+ // whereas `>& file` in Bash/Zsh redirects stdout+stderr to `file`.
1049
1090
  let next = i + 1;
1050
1091
  if (rawCommand[next] === '&') {
1051
- // Descriptor duplication (e.g. `2>&1`, `>&2`) is not a file target
1052
- i = next + 1;
1092
+ const { word, nextIndex } = readShellWord(next + 1);
1093
+ if (word && !/^(?:\d+-?|-)$/.test(word)) {
1094
+ targets.push(word);
1095
+ }
1096
+ i = nextIndex;
1053
1097
  continue;
1054
1098
  }
1055
1099
  if (rawCommand[next] === '>' || rawCommand[next] === '|') {
@@ -1179,6 +1223,13 @@ export function isExtremeRemovalSegment(seg: NormalizedSegment): boolean {
1179
1223
  target.startsWith('~/') ||
1180
1224
  target.startsWith('~') ||
1181
1225
  target.startsWith('*') ||
1226
+ target === '.' ||
1227
+ target === './' ||
1228
+ target.startsWith('./*') ||
1229
+ target === '..' ||
1230
+ target === '../' ||
1231
+ target.startsWith('../*') ||
1232
+ /^[a-z]:[\\/]?$/.test(target) ||
1182
1233
  target === '$home' ||
1183
1234
  target.startsWith('$home/') ||
1184
1235
  target === '${home}' ||
@@ -1208,10 +1259,29 @@ export function isFetchAndExecPipeline(pipelines: readonly (readonly NormalizedS
1208
1259
  }
1209
1260
  if (!sawFetcher) continue;
1210
1261
  if (SHELL_INTERPRETERS.has(stage.executable)) return true;
1211
- // Handle `curl ... | sudo bash` or `curl ... | sudo -E sh`
1212
- if (stage.executable === 'sudo' || stage.executable === 'su') {
1213
- for (const arg of stage.args) {
1214
- if (arg.startsWith('-')) continue;
1262
+ // Handle `curl ... | sudo|su|doas|pkexec|xargs bash`
1263
+ if (
1264
+ stage.executable === 'sudo' ||
1265
+ stage.executable === 'su' ||
1266
+ stage.executable === 'doas' ||
1267
+ stage.executable === 'pkexec' ||
1268
+ stage.executable === 'xargs'
1269
+ ) {
1270
+ const valueFlags = new Set([
1271
+ '-u', '-g', '-c', '-d', '-h', '-p', '-r', '-t', '-a', '-s',
1272
+ '--user', '--group', '--prompt', '--chdir', '--shell'
1273
+ ]);
1274
+ for (let i = 0; i < stage.args.length; i++) {
1275
+ const arg = stage.args[i]!;
1276
+ if (arg === '--') {
1277
+ const next = stage.args[i + 1];
1278
+ if (next && SHELL_INTERPRETERS.has(resolveExecutableBasename(next))) return true;
1279
+ break;
1280
+ }
1281
+ if (arg.startsWith('-')) {
1282
+ if (valueFlags.has(arg)) i++;
1283
+ continue;
1284
+ }
1215
1285
  if (SHELL_INTERPRETERS.has(resolveExecutableBasename(arg))) return true;
1216
1286
  break;
1217
1287
  }
@@ -1236,6 +1306,17 @@ export interface AnalyzedShellCommand {
1236
1306
  * substitutions) into normalized executable segments, pipelines, and write targets.
1237
1307
  */
1238
1308
  export function analyzeShellCommand(rawCommand: string): AnalyzedShellCommand {
1309
+ if (typeof rawCommand !== 'string') {
1310
+ return {
1311
+ maskedTopLevel: '',
1312
+ allRawUnits: [],
1313
+ allMaskedUnits: [],
1314
+ normalizedSegments: [],
1315
+ unwrappedRawSegments: [],
1316
+ normalizedPipelines: [],
1317
+ writeTargets: []
1318
+ };
1319
+ }
1239
1320
  const lower = rawCommand.trim().toLowerCase();
1240
1321
  const topParsed = parseMaskAndExtractSubstitutions(lower, 0);
1241
1322
 
@@ -35,8 +35,11 @@ function validMessage(value) {
35
35
  function validMessages(value) {
36
36
  return Array.isArray(value) && value.every(validMessage);
37
37
  }
38
+ function isValidTimestamp(value) {
39
+ return typeof value === 'number' && Number.isFinite(value) && Math.abs(value) <= 8.64e15;
40
+ }
38
41
  function parseEvent(value) {
39
- if (!isObject(value) || value.version !== 1 || typeof value.type !== 'string' || typeof value.at !== 'number')
42
+ if (!isObject(value) || value.version !== 1 || typeof value.type !== 'string' || !isValidTimestamp(value.at))
40
43
  return null;
41
44
  if (value.type === 'session.created') {
42
45
  const session = value.session;
@@ -45,7 +48,7 @@ function parseEvent(value) {
45
48
  || typeof session.workspace !== 'string'
46
49
  || typeof session.workspaceKey !== 'string'
47
50
  || typeof session.title !== 'string'
48
- || typeof session.createdAt !== 'number')
51
+ || !isValidTimestamp(session.createdAt))
49
52
  return null;
50
53
  return value;
51
54
  }
@@ -237,7 +240,9 @@ function sessionTitle(title, messages, createdAt) {
237
240
  const text = message.content.trim();
238
241
  return text.length > 12 && !NON_TASK_MESSAGE.test(text) && !text.startsWith('[decayed]');
239
242
  });
240
- return prompt ? titleFrom(prompt.content) : `New session - ${new Date(createdAt).toISOString().replace('T', ' ').slice(0, 16)} UTC`;
243
+ const dt = new Date(createdAt);
244
+ const iso = Number.isFinite(dt.getTime()) ? dt.toISOString() : new Date(0).toISOString();
245
+ return prompt ? titleFrom(prompt.content) : `New session - ${iso.replace('T', ' ').slice(0, 16)} UTC`;
241
246
  }
242
247
  export function listSessions() {
243
248
  try {
@@ -93,8 +93,12 @@ function validMessages(value: unknown): value is SessionMessage[] {
93
93
  return Array.isArray(value) && value.every(validMessage);
94
94
  }
95
95
 
96
+ function isValidTimestamp(value: unknown): value is number {
97
+ return typeof value === 'number' && Number.isFinite(value) && Math.abs(value) <= 8.64e15;
98
+ }
99
+
96
100
  function parseEvent(value: unknown): SessionEvent | null {
97
- if (!isObject(value) || value.version !== 1 || typeof value.type !== 'string' || typeof value.at !== 'number') return null;
101
+ if (!isObject(value) || value.version !== 1 || typeof value.type !== 'string' || !isValidTimestamp(value.at)) return null;
98
102
  if (value.type === 'session.created') {
99
103
  const session = value.session;
100
104
  if (!isObject(session)
@@ -102,7 +106,7 @@ function parseEvent(value: unknown): SessionEvent | null {
102
106
  || typeof session.workspace !== 'string'
103
107
  || typeof session.workspaceKey !== 'string'
104
108
  || typeof session.title !== 'string'
105
- || typeof session.createdAt !== 'number') return null;
109
+ || !isValidTimestamp(session.createdAt)) return null;
106
110
  return value as unknown as SessionCreatedEvent;
107
111
  }
108
112
  if (value.type === 'messages.appended') {
@@ -271,7 +275,9 @@ function sessionTitle(title: string, messages: SessionMessage[], createdAt: numb
271
275
  const text = message.content.trim();
272
276
  return text.length > 12 && !NON_TASK_MESSAGE.test(text) && !text.startsWith('[decayed]');
273
277
  });
274
- return prompt ? titleFrom(prompt.content) : `New session - ${new Date(createdAt).toISOString().replace('T', ' ').slice(0, 16)} UTC`;
278
+ const dt = new Date(createdAt);
279
+ const iso = Number.isFinite(dt.getTime()) ? dt.toISOString() : new Date(0).toISOString();
280
+ return prompt ? titleFrom(prompt.content) : `New session - ${iso.replace('T', ' ').slice(0, 16)} UTC`;
275
281
  }
276
282
 
277
283
  export function listSessions(): Array<Omit<SessionRecord, 'messages'> & { messageCount: number }> {
@@ -251,12 +251,18 @@ export function listSkillResourcePaths(root, domain, name, limit = MAX_ADVERTISE
251
251
  if (out.length >= bound || depth > 3)
252
252
  return;
253
253
  const directory = path.join(skillDir, ...relative.split('/'));
254
- if (!inspectDirectory(directory, true))
254
+ let entries;
255
+ try {
256
+ if (!inspectDirectory(directory, true))
257
+ return;
258
+ entries = fs.readdirSync(directory, { withFileTypes: true })
259
+ .filter(item => !item.name.startsWith('.'))
260
+ .sort((a, b) => a.name.localeCompare(b.name))
261
+ .slice(0, 128);
262
+ }
263
+ catch {
255
264
  return;
256
- const entries = fs.readdirSync(directory, { withFileTypes: true })
257
- .filter(item => !item.name.startsWith('.'))
258
- .sort((a, b) => a.name.localeCompare(b.name))
259
- .slice(0, 128);
265
+ }
260
266
  for (const entry of entries) {
261
267
  if (out.length >= bound)
262
268
  break;
@@ -266,9 +272,14 @@ export function listSkillResourcePaths(root, domain, name, limit = MAX_ADVERTISE
266
272
  if (entry.isDirectory())
267
273
  walk(next, depth + 1);
268
274
  else if (entry.isFile() && TEXT_EXTENSIONS.has(path.posix.extname(next).toLowerCase())) {
269
- const stat = fs.lstatSync(path.join(directory, entry.name));
270
- if (stat.size <= MAX_SKILL_RESOURCE_BYTES && !stat.isSymbolicLink())
271
- out.push(next);
275
+ try {
276
+ const stat = fs.lstatSync(path.join(directory, entry.name));
277
+ if (stat.size <= MAX_SKILL_RESOURCE_BYTES && !stat.isSymbolicLink())
278
+ out.push(next);
279
+ }
280
+ catch {
281
+ // Skip vanished or unreadable support file
282
+ }
272
283
  }
273
284
  }
274
285
  };
@@ -266,19 +266,28 @@ export function listSkillResourcePaths(
266
266
  const walk = (relative: string, depth: number): void => {
267
267
  if (out.length >= bound || depth > 3) return;
268
268
  const directory = path.join(skillDir, ...relative.split('/'));
269
- if (!inspectDirectory(directory, true)) return;
270
- const entries = fs.readdirSync(directory, { withFileTypes: true })
271
- .filter(item => !item.name.startsWith('.'))
272
- .sort((a, b) => a.name.localeCompare(b.name))
273
- .slice(0, 128);
269
+ let entries: fs.Dirent[];
270
+ try {
271
+ if (!inspectDirectory(directory, true)) return;
272
+ entries = fs.readdirSync(directory, { withFileTypes: true })
273
+ .filter(item => !item.name.startsWith('.'))
274
+ .sort((a, b) => a.name.localeCompare(b.name))
275
+ .slice(0, 128);
276
+ } catch {
277
+ return;
278
+ }
274
279
  for (const entry of entries) {
275
280
  if (out.length >= bound) break;
276
281
  if (entry.isSymbolicLink()) continue;
277
282
  const next = `${relative}/${entry.name}`;
278
283
  if (entry.isDirectory()) walk(next, depth + 1);
279
284
  else if (entry.isFile() && TEXT_EXTENSIONS.has(path.posix.extname(next).toLowerCase())) {
280
- const stat = fs.lstatSync(path.join(directory, entry.name));
281
- if (stat.size <= MAX_SKILL_RESOURCE_BYTES && !stat.isSymbolicLink()) out.push(next);
285
+ try {
286
+ const stat = fs.lstatSync(path.join(directory, entry.name));
287
+ if (stat.size <= MAX_SKILL_RESOURCE_BYTES && !stat.isSymbolicLink()) out.push(next);
288
+ } catch {
289
+ // Skip vanished or unreadable support file
290
+ }
282
291
  }
283
292
  }
284
293
  };
@@ -144,7 +144,7 @@ export function detectWorkspaceDomains(workspaceRoot) {
144
144
  }
145
145
  export { MAX_INDEXED_SKILLS, UNIVERSAL_DOMAINS };
146
146
  export function ensureSkillRepo(domain) {
147
- if (compiledSkillsCatalog[domain]) {
147
+ if (Object.hasOwn(compiledSkillsCatalog, domain) && compiledSkillsCatalog[domain]) {
148
148
  return true;
149
149
  }
150
150
  return false;
@@ -310,10 +310,10 @@ export function readCompiledSkill(domain, skillId) {
310
310
  .find((skill) => skill.domain === domain && skill.id === skillId);
311
311
  if (pluginSkill)
312
312
  return pluginSkill.content;
313
- const domainSkills = compiledSkillsCatalog[domain];
313
+ const domainSkills = Object.hasOwn(compiledSkillsCatalog, domain) ? compiledSkillsCatalog[domain] : undefined;
314
314
  if (!domainSkills)
315
315
  return `Error: Domain ${domain} not found in compiled skills.`;
316
- const skillData = domainSkills[skillId];
316
+ const skillData = Object.hasOwn(domainSkills, skillId) ? domainSkills[skillId] : undefined;
317
317
  if (!skillData)
318
318
  return `Error: Skill ${skillId} not found in domain ${domain}.`;
319
319
  return skillData.content;
@@ -169,7 +169,7 @@ export function detectWorkspaceDomains(workspaceRoot?: string): string[] {
169
169
  export { MAX_INDEXED_SKILLS, UNIVERSAL_DOMAINS };
170
170
 
171
171
  export function ensureSkillRepo(domain: string): boolean {
172
- if (compiledSkillsCatalog[domain]) {
172
+ if (Object.hasOwn(compiledSkillsCatalog, domain) && compiledSkillsCatalog[domain]) {
173
173
  return true;
174
174
  }
175
175
  return false;
@@ -345,10 +345,10 @@ export function readCompiledSkill(domain: string, skillId: string): string {
345
345
  .find((skill) => skill.domain === domain && skill.id === skillId);
346
346
  if (pluginSkill) return pluginSkill.content;
347
347
 
348
- const domainSkills = compiledSkillsCatalog[domain];
348
+ const domainSkills = Object.hasOwn(compiledSkillsCatalog, domain) ? compiledSkillsCatalog[domain] : undefined;
349
349
  if (!domainSkills) return `Error: Domain ${domain} not found in compiled skills.`;
350
350
 
351
- const skillData = domainSkills[skillId];
351
+ const skillData = Object.hasOwn(domainSkills, skillId) ? domainSkills[skillId] : undefined;
352
352
  if (!skillData) return `Error: Skill ${skillId} not found in domain ${domain}.`;
353
353
 
354
354
  return skillData.content;