dal-code 0.1.7 → 0.1.8

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 (48) hide show
  1. package/dist/core/house-providers.d.ts +22 -37
  2. package/dist/core/house-providers.d.ts.map +1 -1
  3. package/dist/core/house-providers.js +22 -54
  4. package/dist/core/house-providers.js.map +1 -1
  5. package/dist/core/model-runtime.d.ts.map +1 -1
  6. package/dist/core/model-runtime.js.map +1 -1
  7. package/dist/core/tools/bash.d.ts.map +1 -1
  8. package/dist/core/tools/bash.js +5 -1
  9. package/dist/core/tools/bash.js.map +1 -1
  10. package/dist/dal/builtins.d.ts.map +1 -1
  11. package/dist/dal/builtins.js +19 -2
  12. package/dist/dal/builtins.js.map +1 -1
  13. package/dist/node_modules/@dalcode/dal-bridge/package.json +2 -2
  14. package/dist/node_modules/@dalcode/dal-gateway/package.json +2 -2
  15. package/dist/node_modules/@dalcode/dal-guard/package.json +4 -4
  16. package/dist/node_modules/@dalcode/dal-halo/package.json +1 -1
  17. package/dist/node_modules/@dalcode/dal-lang/package.json +3 -3
  18. package/dist/node_modules/@dalcode/dal-lsp/package.json +3 -3
  19. package/dist/node_modules/@dalcode/dal-lsp/src/client.ts +5 -0
  20. package/dist/node_modules/@dalcode/dal-lsp/src/config.ts +16 -4
  21. package/dist/node_modules/@dalcode/dal-lsp/src/index.ts +1 -1
  22. package/dist/node_modules/@dalcode/dal-mcp/package.json +9 -7
  23. package/dist/node_modules/@dalcode/dal-mcp/src/account-layer.ts +85 -0
  24. package/dist/node_modules/@dalcode/dal-mcp/src/config.ts +21 -2
  25. package/dist/node_modules/@dalcode/dal-mcp/src/index.ts +37 -2
  26. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.d.ts.map +1 -1
  27. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js +3 -0
  28. package/dist/node_modules/@dalcode/dal-pi-kit/dist/i18n.js.map +1 -1
  29. package/dist/node_modules/@dalcode/dal-pi-kit/package.json +1 -1
  30. package/dist/node_modules/@dalcode/dal-pi-kit/src/i18n.ts +4 -0
  31. package/dist/node_modules/@dalcode/dal-skills/package.json +3 -3
  32. package/dist/node_modules/@dalcode/dal-skills/src/index.ts +24 -2
  33. package/dist/node_modules/@dalcode/dal-subagent/package.json +3 -3
  34. package/dist/node_modules/@dalcode/dal-telemetry/package.json +2 -2
  35. package/dist/node_modules/@dalcode/dal-telemetry/src/index.ts +30 -2
  36. package/dist/node_modules/@dalcode/deepailab/package.json +2 -2
  37. package/dist/node_modules/@dalcode/deepailab/src/index.ts +39 -8
  38. package/dist/node_modules/@earendil-works/pi-agent-core/package.json +1 -1
  39. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
  40. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
  41. package/dist/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
  42. package/dist/node_modules/@earendil-works/pi-ai/package.json +1 -1
  43. package/dist/node_modules/@earendil-works/pi-client/package.json +1 -1
  44. package/dist/node_modules/@earendil-works/pi-protocol/package.json +1 -1
  45. package/dist/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
  46. package/dist/node_modules/@earendil-works/pi-tui/package.json +1 -1
  47. package/npm-shrinkwrap.json +2 -2
  48. package/package.json +1 -1
@@ -114,18 +114,39 @@ async function loginDeepAILab(callbacks: OAuthLoginCallbacks): Promise<OAuthCred
114
114
  * A key can be revoked server-side while the OIDC session stays perfectly
115
115
  * valid, and the two failures look nothing alike: inference then dies with
116
116
  * `api_key_not_found` on every call and no amount of re-login fixes it,
117
- * because login preserves a non-empty vk. Cheapest honest probe is /models.
118
- * A network failure is not evidence of revocation, so it reads as still-valid
119
- * and leaves the stored key alone.
117
+ * because login preserves a non-empty vk.
118
+ *
119
+ * This probed /models, which turns out to answer 200 with no key at all
120
+ * (measured 2026-09-11: no key, wrong key, both 200). `status !== 401` was
121
+ * therefore always true and this function had never once detected a
122
+ * revocation — a user whose key was revoked kept the dead key forever and saw
123
+ * `api_key_not_found` on every turn, which is exactly the failure the function
124
+ * exists to prevent.
125
+ *
126
+ * /portal/skills is used instead because it genuinely authenticates: it checks
127
+ * the key against the gateway's own registry, returns a few hundred bytes, and
128
+ * has no side effects and no cost. The one endpoint that also validates —
129
+ * /chat/completions — would bill a completion to answer the question.
120
130
  */
121
- async function isVirtualKeyLive(apiBase: string, vk: string): Promise<boolean> {
131
+ export async function isVirtualKeyLive(apiBase: string, vk: string): Promise<boolean> {
132
+ // Bounded: this sits on the credential-refresh path, which runs before the
133
+ // first turn. An unreachable gateway must delay the session, not hold it.
134
+ const controller = new AbortController();
135
+ const timer = setTimeout(() => controller.abort(), 10_000);
122
136
  try {
123
- const res = await fetch(`${apiBase}/models`, {
137
+ const res = await fetch(`${apiBase}/portal/skills`, {
124
138
  headers: { "x-bf-vk": vk, Accept: "application/json" },
139
+ signal: controller.signal,
125
140
  });
126
- return res.status !== 401;
141
+ // Only an explicit rejection counts as revocation. A 5xx, a 404 from an
142
+ // older gateway, or a timeout all mean "we do not know" — and re-minting
143
+ // on "we do not know" would throw away a perfectly good key every time
144
+ // the service hiccuped.
145
+ return res.status !== 401 && res.status !== 403;
127
146
  } catch {
128
147
  return true;
148
+ } finally {
149
+ clearTimeout(timer);
129
150
  }
130
151
  }
131
152
 
@@ -195,13 +216,18 @@ export default function (pi: ExtensionAPI) {
195
216
  const refreshCatalog = async (ctx: {
196
217
  modelRegistry: { getApiKeyForProvider(id: string): Promise<string | undefined> };
197
218
  ui?: { notify(message: string, level: "info" | "warning" | "error"): void };
219
+ hasUI?: boolean;
198
220
  }) => {
199
221
  // The catalog is the only source of models now that the seed list is gone,
200
222
  // so a failure has to be visible. `ui` is optional because refreshCatalog
201
223
  // also runs in headless (`dal -p`) sessions, where stderr is the channel.
202
224
  const reportFailure = (reason: string): void => {
203
225
  const message = `${t("无法获取模型列表")}:${reason}`;
204
- if (ctx.ui) ctx.ui.notify(message, "error");
226
+ // hasUI, not `ctx.ui`. In a headless run (`dal -p`) `ui` is still a real
227
+ // object — runner.ts hands out a no-op UI — so the truthiness check sent
228
+ // every message into a function that does nothing, and the stderr branch
229
+ // this comment used to promise was never taken.
230
+ if (ctx.hasUI && ctx.ui) ctx.ui.notify(message, "error");
205
231
  else process.stderr.write(`${message}\n`);
206
232
  };
207
233
  // Hoisted so the finally below can clear it: declared inside the try, an
@@ -330,7 +356,12 @@ export default function (pi: ExtensionAPI) {
330
356
  if (event.status < 400 || event.status === lastNotifiedStatus) return;
331
357
  lastNotifiedStatus = event.status;
332
358
  const notice = gatewayStatusNotice(event.status);
333
- if (notice) ctx.ui.notify(notice.message, notice.level);
359
+ if (!notice) return;
360
+ // Headless runs get a real `ui` object whose notify does nothing, so
361
+ // "账户额度已用完" would have been swallowed exactly where it matters most:
362
+ // a `dal -p` in someone's script, failing with a bare 402 blob.
363
+ if (ctx.hasUI) ctx.ui.notify(notice.message, notice.level);
364
+ else process.stderr.write(`${notice.message}\n`);
334
365
  });
335
366
  pi.on("turn_start", () => {
336
367
  lastNotifiedStatus = 0;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-agent-core",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1 +1 @@
1
- {"schemaVersion":3,"generatedAt":"2026-09-11T17:09:36.455Z","structureHash":"6ee4dc65ff0cf34ee63f14f58523e48b73e63f5de1da8ab1d56ff44aa3b5500b","files":{"amazon-bedrock.json":"02de11fa841c07ee8331f5a590dcc48ad24fc8f83b35bfb3fb532797a590e8f3","ant-ling.json":"4979fe79d99ed97382d7ce40170c6132e932e77906de1eb54464c042e7d63633","anthropic.json":"c0e1cfcef8531b5d0852c0e74790290f130dbcb4591b6578bb0d8a4b464231c0","azure-openai-responses.json":"2f42741e47dbebd8491cf40bff1de313fc2221f55e16bc02fd6e5d50b5f8fefe","baseten.json":"d155c434294b5167244cffb6dea6793f9669e91e8ab65b564f9510d81b330e37","cerebras.json":"9eaa554e1b02f3665f8f63e6432d253bf81351af7c72001054dd8108aa528a52","cloudflare-ai-gateway.json":"eb2bf274394a157714072a2726675fbdfd2cc370e359b6665fa6aca409617089","cloudflare-workers-ai.json":"07ef63208ff7517fd1a80962f18143e21de399640423329490b157f459ccf995","deepseek.json":"8cc5e02a8eb3f1ead25da01d6ebac7dbd9aa5134c561026de2076cc990eb3349","fireworks.json":"e7a91f879dae810ebccbc800526ad498ca5189a4a0e6a27489ffbc3f30f02123","github-copilot.json":"5ddbd26a51c3d60975dfc41c685f65ee0964b94352379f9f3dac77715f389004","google-vertex.json":"e1631109172dc1f7d7977570420a5bb86258bdd1088427e244a2c51545c4f24d","google.json":"7619bf03edd2a7acb06a2274a14b13c3a61354288abe029a758401d4de36a8fd","groq.json":"e4728fd72e358cd8f25e9a518e9b49a521ef44523d3debe38a7db9e0663c4077","huggingface.json":"a488b6f175b382277ccf7d487f877ef0c698994576bb55d2410838bf9c8c7c41","kimi-coding.json":"5e28e32e5b16df506a3a1c620ed7870fa7e5e57d8ede4a2aa44dbb24ecf1ba2f","minimax-cn.json":"65d37e55a6d9585855f94b3fb7739308d107fe248ebd9e1001d1c5d4606ad2c4","minimax.json":"c7dc5765995ae77242916430929c7cc9a782589f7e483e13f7e01663190d028e","mistral.json":"e3a109306644bf2f2fa38fece50b2d3ce1dbe3b87b1f1b9e2d70cce7eb5c0ea1","moonshotai-cn.json":"63f77de8782dce6a8d4649b6075ee04c9732863ae85561e0867871220c558bde","moonshotai.json":"2a8dfb97eb905e991c22081dc09bd4a61c05b7fa9ac0d5c72d6930f601f490f1","nvidia.json":"a942cfffa6fc764d603503f7ce2abf4d2bdd1d541b98a65aa6ff53bfe2df4efd","openai-codex.json":"a10bfcfd34db6bcb98d8ee46175e154cab30530a137dbf31ac1434020ed3ffdd","openai.json":"775d3b7d95d14b741d0b287b1153d40f051a9ea03035a82b487889acc7fa69e2","opencode-go.json":"274c4fb1a4e99c286860174700b0b38997df62839efd2b76a8884db1d8dc331a","opencode.json":"7b878f5fb48e9fce68af0c3b507ddafd88a07b5ec7a8c06e9b99cf85b27324ac","openrouter.json":"52fe7682534a7409602334f54f21d8d369518d5e5dfdbcf08f97d97990a56e5d","qwen-token-plan-cn.json":"d24c5318361ae5395866faaaffde5e52341be58e607def0cc219cae49326492a","qwen-token-plan-individual.json":"eb040e78595853e980011308b1bf9caacae6dc8a91abbac5ffebd402515dd2a6","qwen-token-plan.json":"0545c9881decb710a9535f67960174089b04f607c1200335cdad9de4670ec92a","together.json":"6010980c9b0af72c60965ae325dbdb21e67c91844a7f7f6f7d71d363f1325f56","vercel-ai-gateway.json":"e2bef638e33f5eaabd184edc0c3b1eea19af764612febaed7cdb6a44884c8385","xai.json":"037bde3de5ea72814c3f0b79da8b244c89feb708cc0cbf8596cdfac7682477b6","xiaomi-token-plan-ams.json":"a36446cb9e3cb4f7054617676fd711092245a74f703ba89573f21d2673b85fa8","xiaomi-token-plan-cn.json":"c295dadf4097b5d86af15e924fb2a1a6342bae9e0a9a5839c9fca216308c51e5","xiaomi-token-plan-sgp.json":"93d359575c2348c97d79a2b14e1e9437199bd4aee948d58611b3fbab75cd9fb3","xiaomi.json":"f06f1011d606d22311b1f4c50eb36d38b8cd99abf5760faee657d5559e87452b","zai-coding-cn.json":"d3c969020a7ab978497837a3301c7bca364d704082832221cfe61e6596333e56","zai.json":"f42790c77fb4681a656897a9d860b939916c0ddf979a5f16856bce9573cdf64e"}}
1
+ {"schemaVersion":3,"generatedAt":"2026-09-11T20:17:58.930Z","structureHash":"644d340c9f1f5130f44684d6feeff5ad639a5f3db24ba2721e28c75726fde53a","files":{"amazon-bedrock.json":"02de11fa841c07ee8331f5a590dcc48ad24fc8f83b35bfb3fb532797a590e8f3","ant-ling.json":"4979fe79d99ed97382d7ce40170c6132e932e77906de1eb54464c042e7d63633","anthropic.json":"c0e1cfcef8531b5d0852c0e74790290f130dbcb4591b6578bb0d8a4b464231c0","azure-openai-responses.json":"2f42741e47dbebd8491cf40bff1de313fc2221f55e16bc02fd6e5d50b5f8fefe","baseten.json":"d155c434294b5167244cffb6dea6793f9669e91e8ab65b564f9510d81b330e37","cerebras.json":"9eaa554e1b02f3665f8f63e6432d253bf81351af7c72001054dd8108aa528a52","cloudflare-ai-gateway.json":"eb2bf274394a157714072a2726675fbdfd2cc370e359b6665fa6aca409617089","cloudflare-workers-ai.json":"07ef63208ff7517fd1a80962f18143e21de399640423329490b157f459ccf995","deepseek.json":"8cc5e02a8eb3f1ead25da01d6ebac7dbd9aa5134c561026de2076cc990eb3349","fireworks.json":"e7a91f879dae810ebccbc800526ad498ca5189a4a0e6a27489ffbc3f30f02123","github-copilot.json":"5ddbd26a51c3d60975dfc41c685f65ee0964b94352379f9f3dac77715f389004","google-vertex.json":"e1631109172dc1f7d7977570420a5bb86258bdd1088427e244a2c51545c4f24d","google.json":"7619bf03edd2a7acb06a2274a14b13c3a61354288abe029a758401d4de36a8fd","groq.json":"e4728fd72e358cd8f25e9a518e9b49a521ef44523d3debe38a7db9e0663c4077","huggingface.json":"a488b6f175b382277ccf7d487f877ef0c698994576bb55d2410838bf9c8c7c41","kimi-coding.json":"5e28e32e5b16df506a3a1c620ed7870fa7e5e57d8ede4a2aa44dbb24ecf1ba2f","minimax-cn.json":"65d37e55a6d9585855f94b3fb7739308d107fe248ebd9e1001d1c5d4606ad2c4","minimax.json":"c7dc5765995ae77242916430929c7cc9a782589f7e483e13f7e01663190d028e","mistral.json":"e3a109306644bf2f2fa38fece50b2d3ce1dbe3b87b1f1b9e2d70cce7eb5c0ea1","moonshotai-cn.json":"63f77de8782dce6a8d4649b6075ee04c9732863ae85561e0867871220c558bde","moonshotai.json":"2a8dfb97eb905e991c22081dc09bd4a61c05b7fa9ac0d5c72d6930f601f490f1","nvidia.json":"a942cfffa6fc764d603503f7ce2abf4d2bdd1d541b98a65aa6ff53bfe2df4efd","openai-codex.json":"a10bfcfd34db6bcb98d8ee46175e154cab30530a137dbf31ac1434020ed3ffdd","openai.json":"775d3b7d95d14b741d0b287b1153d40f051a9ea03035a82b487889acc7fa69e2","opencode-go.json":"274c4fb1a4e99c286860174700b0b38997df62839efd2b76a8884db1d8dc331a","opencode.json":"7b878f5fb48e9fce68af0c3b507ddafd88a07b5ec7a8c06e9b99cf85b27324ac","openrouter.json":"899d85e437a312cc78d162f5b38a87a10603bf1a4fc0f92870a2e488326b8a58","qwen-token-plan-cn.json":"d24c5318361ae5395866faaaffde5e52341be58e607def0cc219cae49326492a","qwen-token-plan-individual.json":"eb040e78595853e980011308b1bf9caacae6dc8a91abbac5ffebd402515dd2a6","qwen-token-plan.json":"0545c9881decb710a9535f67960174089b04f607c1200335cdad9de4670ec92a","together.json":"6010980c9b0af72c60965ae325dbdb21e67c91844a7f7f6f7d71d363f1325f56","vercel-ai-gateway.json":"7e15afa7dacdce4353bdc0346e1ac322e86f4cb401c7d54262e773e4e5abb98d","xai.json":"037bde3de5ea72814c3f0b79da8b244c89feb708cc0cbf8596cdfac7682477b6","xiaomi-token-plan-ams.json":"a36446cb9e3cb4f7054617676fd711092245a74f703ba89573f21d2673b85fa8","xiaomi-token-plan-cn.json":"c295dadf4097b5d86af15e924fb2a1a6342bae9e0a9a5839c9fca216308c51e5","xiaomi-token-plan-sgp.json":"93d359575c2348c97d79a2b14e1e9437199bd4aee948d58611b3fbab75cd9fb3","xiaomi.json":"f06f1011d606d22311b1f4c50eb36d38b8cd99abf5760faee657d5559e87452b","zai-coding-cn.json":"d3c969020a7ab978497837a3301c7bca364d704082832221cfe61e6596333e56","zai.json":"f42790c77fb4681a656897a9d860b939916c0ddf979a5f16856bce9573cdf64e"}}