@akanjs/cli 3.1.0-rc.8 → 3.1.0

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 (92) hide show
  1. package/.build-stamp +1 -1
  2. package/{CodeAgent-rkjyxgec.js → CodeAgent-c53dm40p.js} +2 -2
  3. package/{CodeAgentRpcHost-p7h6n2hp.js → CodeAgentRpcHost-9g27hmer.js} +1 -1
  4. package/{CodeTui-h7pyj6xa.js → CodeTui-xz9jtrn3.js} +47 -4
  5. package/README.ko.md +1 -1
  6. package/README.md +1 -1
  7. package/TunnelShare-59zd4j8n.js +14 -0
  8. package/{agent.command-3qxf4xcj.js → agent.command-qawf7z4s.js} +5 -5
  9. package/akanCode.js +7 -5
  10. package/{application.command-m1kcd7jf.js → application.command-jqrgqk6j.js} +35 -9
  11. package/{applicationBuildRunner-dj0xkrep.js → applicationBuildRunner-grgrey5c.js} +23 -8
  12. package/buildBatch.proc.js +9 -9
  13. package/{cloud.command-3jzym8q7.js → cloud.command-p9067ssj.js} +13 -13
  14. package/cloud.script-f0r4ce7j.js +24 -0
  15. package/{code.command-0ad6gw2a.js → code.command-t6j55sbk.js} +25 -12
  16. package/commandManifest.json +1 -1
  17. package/{context.command-0qx447mb.js → context.command-eqbzbgth.js} +16 -16
  18. package/context.runner-1cs88ags.js +25 -0
  19. package/{guideline.command-cv5bmrx2.js → guideline.command-w905q73w.js} +2 -2
  20. package/guidelines/agentRule/agentRule.instruction.md +25 -10
  21. package/guidelines/conventions/conventions.instruction.md +71 -24
  22. package/guidelines/fieldRule/fieldRule.instruction.md +17 -0
  23. package/guidelines/mcpRule/mcpRule.instruction.md +93 -48
  24. package/guidelines/modelDocument/modelDocument.instruction.md +2 -1
  25. package/guidelines/modelStore/modelStore.instruction.md +7 -0
  26. package/guidelines/pageRule/pageRule.instruction.md +55 -8
  27. package/guidelines/queryRule/queryRule.instruction.md +24 -10
  28. package/guidelines/runtimeRule/runtimeRule.instruction.md +12 -4
  29. package/guidelines/ssrRule/ssrRule.instruction.md +9 -6
  30. package/guidelines/transportRule/transportRule.instruction.md +36 -5
  31. package/guidelines/workspaceOnboarding/workspaceOnboarding.instruction.md +5 -3
  32. package/guidelines/workspaceRecipes/workspaceRecipes.instruction.md +28 -8
  33. package/incrementalBuilder.proc.js +3 -3
  34. package/{index-j4mkhz93.js → index-0dd6z4b9.js} +3 -3
  35. package/{index-h47cf1gg.js → index-1de5f0qq.js} +7 -7
  36. package/{index-6xn2n442.js → index-1enc9rga.js} +4 -4
  37. package/index-25ks6x4k.js +643 -0
  38. package/{index-wa5jbxj1.js → index-2mrn1mrg.js} +1 -0
  39. package/{index-qwa5k1j8.js → index-3aynkpf8.js} +1 -1
  40. package/{index-vk0pa0mn.js → index-3hvmytbs.js} +2 -1
  41. package/{index-w44cy4vs.js → index-45c0mxb6.js} +2 -2
  42. package/{index-fyq1z6kt.js → index-48n4yhm4.js} +3 -3
  43. package/{index-192ha4xh.js → index-64pjry21.js} +1 -1
  44. package/{index-5edzv8fn.js → index-aqwdjn4x.js} +2 -2
  45. package/{index-d2242ksy.js → index-at7bz0xq.js} +3 -0
  46. package/{index-9z426msb.js → index-avjqbtkj.js} +7 -6
  47. package/{index-20bxxyvn.js → index-bs9yr4we.js} +40 -2
  48. package/{index-d72hfmdm.js → index-cgexcnwd.js} +8 -8
  49. package/{index-1xj2t7cb.js → index-dkfadmrx.js} +7 -7
  50. package/{index-35hc95h5.js → index-eabfsarf.js} +1 -1
  51. package/{index-pydbnfez.js → index-er62k6w3.js} +35 -9
  52. package/{index-1p98exm2.js → index-f2gfq0yh.js} +2 -2
  53. package/{index-jw1zm273.js → index-fbw3kmt5.js} +54 -10
  54. package/{index-4mhy6qme.js → index-fnqj2d2w.js} +4 -4
  55. package/{index-awbdfcf2.js → index-hqh4mpgt.js} +4 -4
  56. package/{index-fmzcs8v6.js → index-j4dzazmw.js} +4 -4
  57. package/{index-va06nr10.js → index-n8dsax1f.js} +64 -19
  58. package/{index-g1mbppa9.js → index-nr8m4j21.js} +5 -5
  59. package/{index-86jt2a0e.js → index-qh73jnyb.js} +1 -1
  60. package/{index-8fp3b47h.js → index-vtj332gj.js} +281 -46
  61. package/{index-tamvyvj3.js → index-wt7m1hfc.js} +3 -3
  62. package/{index-cpb3nvma.js → index-yfy3t4kw.js} +2 -2
  63. package/{index-trpasv9q.js → index-yyxy7aff.js} +1 -1
  64. package/{index-d47ypebv.js → index-z5cxrbvv.js} +75 -19
  65. package/index.js +40 -22
  66. package/{library.command-erp2f56n.js → library.command-z1v7zepj.js} +3 -3
  67. package/{localRegistry.command-xxpqgxjw.js → localRegistry.command-48n23bjy.js} +12 -12
  68. package/{module.command-gs2r615e.js → module.command-rv307dk7.js} +5 -5
  69. package/{package.command-7343f74r.js → package.command-7xkzc8m1.js} +3 -3
  70. package/package.json +22 -22
  71. package/{page.command-4h4a8pnh.js → page.command-34hpdt7v.js} +3 -3
  72. package/{pipeline.command-a2nrk26m.js → pipeline.command-ckvhrpyg.js} +2 -2
  73. package/{primitive.command-w6t0asqz.js → primitive.command-em0twr5a.js} +6 -6
  74. package/{projectTypecheck-f534enqj.js → projectTypecheck-fy6hn05y.js} +1 -1
  75. package/{quality.command-77x7vbbx.js → quality.command-c6p2819k.js} +2 -2
  76. package/{repair.command-y6sstev7.js → repair.command-j6czdgrv.js} +5 -5
  77. package/{routeSourceValidator-7ycnfz0e.js → routeSourceValidator-6jd0q6r6.js} +47 -14
  78. package/{scalar.command-20b8cy0k.js → scalar.command-17e20sj2.js} +4 -4
  79. package/skills/akan-code/SKILL.md +4 -0
  80. package/skills/akan-store/SKILL.md +4 -2
  81. package/{subspace.command-92xkc0s0.js → subspace.command-n3j7vv0w.js} +8 -17
  82. package/templates/migration/__migrationId__.ts +23 -0
  83. package/templates/server.ts +8 -1
  84. package/templates/workspaceRoot/.gitignore.template +1 -1
  85. package/templates/workspaceRoot/biome.json.template +1 -1
  86. package/{tunnel.command-2kw8vt9g.js → tunnel.command-cm578f4s.js} +7 -7
  87. package/{workflow.command-2djwmpqf.js → workflow.command-h9vkr6jb.js} +10 -10
  88. package/{workspace.command-5se6spqb.js → workspace.command-tp8ysvjs.js} +30 -28
  89. package/TunnelShare-661cxz5e.js +0 -14
  90. package/cloud.script-r4nskbc6.js +0 -24
  91. package/context.runner-1vsjztjg.js +0 -25
  92. package/index-665zp9rs.js +0 -271
@@ -3,8 +3,9 @@ import {
3
3
  SubagentPool2,
4
4
  akanCodePaths2,
5
5
  McpServerConfig,
6
- McpSignIn
7
- } from "./index-20bxxyvn.js";
6
+ McpSignIn,
7
+ AkanCodeCompaction2
8
+ } from "./index-bs9yr4we.js";
8
9
  import {
9
10
  stripAnsi
10
11
  } from "./index-7md2g9vw.js";
@@ -254,7 +255,7 @@ class AkanCodeServices2 {
254
255
  enableInstallTelemetry: false,
255
256
  enableAnalytics: false,
256
257
  quietStartup: true,
257
- compaction: { reserveTokens: 32768 }
258
+ compaction: { reserveTokens: AkanCodeCompaction2.reserveFloor }
258
259
  });
259
260
  }
260
261
  static async runtime(workspaceRoot, proxy = null) {
@@ -318,7 +319,7 @@ import {
318
319
  DefaultResourceLoader
319
320
  } from "@earendil-works/pi-coding-agent";
320
321
  import {
321
- codeAgentClip as codeAgentClip5,
322
+ codeAgentClip as codeAgentClip6,
322
323
  codeAgentLabelChars as codeAgentLabelChars2,
323
324
  codeAgentRenderAnswer,
324
325
  codeAgentSessionName as codeAgentSessionName2
@@ -808,7 +809,7 @@ class AkanToolPack2 {
808
809
  return { name: "akan-tools", factory: async (pi) => await this.#register(pi) };
809
810
  }
810
811
  async names() {
811
- const { ContextRunner } = await import("./context.runner-1vsjztjg.js");
812
+ const { ContextRunner } = await import("./context.runner-1cs88ags.js");
812
813
  return [
813
814
  ...new ContextRunner().listMcpTools(this.#options.mode).map((tool) => tool.name),
814
815
  AkanToolPack2.verifyToolName
@@ -816,7 +817,7 @@ class AkanToolPack2 {
816
817
  }
817
818
  static verifyToolName = "akan_verify";
818
819
  async#register(pi) {
819
- const { ContextRunner } = await import("./context.runner-1vsjztjg.js");
820
+ const { ContextRunner } = await import("./context.runner-1cs88ags.js");
820
821
  const runner = new ContextRunner;
821
822
  const guidelineNames = await AkanToolPack2.#guidelineNames();
822
823
  for (const tool of runner.listMcpTools(this.#options.mode, { guidelineNames })) {
@@ -1395,11 +1396,121 @@ class SessionToolPack2 {
1395
1396
  }
1396
1397
 
1397
1398
  // pkgs/@akanjs/devkit/codeAgent/tools/WebToolPack.ts
1398
- import { codeAgentClip as codeAgentClip3, codeAgentOutputChars as codeAgentOutputChars3 } from "akanjs/common";
1399
+ import { lookup } from "dns/promises";
1400
+ import { isIP } from "net";
1401
+ import { codeAgentClip as codeAgentClip4 } from "akanjs/common";
1399
1402
  import { Type as Type6 } from "typebox";
1400
1403
 
1404
+ // pkgs/@akanjs/devkit/codeAgent/tools/DeepSeekWeb.ts
1405
+ import { codeAgentClip as codeAgentClip3 } from "akanjs/common";
1406
+
1407
+ class DeepSeekWeb {
1408
+ static baseUrl = "https://api.deepseek.com/v1/tools";
1409
+ static maxQueryChars = 128;
1410
+ static summaryChars = 600;
1411
+ static #retryable = {
1412
+ search: [408, 429, 500, 502, 503, 504],
1413
+ fetch: [429]
1414
+ };
1415
+ static #attempts = 3;
1416
+ #key;
1417
+ #baseUrl;
1418
+ constructor(key, baseUrl = DeepSeekWeb.baseUrl) {
1419
+ this.#key = key;
1420
+ this.#baseUrl = baseUrl;
1421
+ }
1422
+ static async fromRuntime(runtime, proxied) {
1423
+ if (proxied)
1424
+ return;
1425
+ const key = (await runtime.getAuth("deepseek").catch(() => {
1426
+ return;
1427
+ }))?.auth.apiKey;
1428
+ return key ? new DeepSeekWeb(key) : undefined;
1429
+ }
1430
+ async search(query, count, signal) {
1431
+ if ([...query].length > DeepSeekWeb.maxQueryChars)
1432
+ throw new Error(`DeepSeek search takes at most ${DeepSeekWeb.maxQueryChars} characters; shorten the query.`);
1433
+ const body = await this.#call("search", { query, count }, 20000, signal);
1434
+ const byUrl = new Map;
1435
+ for (const result of body.results ?? []) {
1436
+ const url = DeepSeekWeb.#cleanUrl(result.url);
1437
+ if (!byUrl.has(url))
1438
+ byUrl.set(url, { ...result, url });
1439
+ }
1440
+ return [...byUrl.values()].map((result) => {
1441
+ const date = result.date ? ` \xB7 ${result.date.slice(0, 10)}` : "";
1442
+ const summary = DeepSeekWeb.unescape(result.summary || result.snippet || "").replace(/\s+/g, " ").trim();
1443
+ return `- ${result.title}
1444
+ ${result.url}${date}
1445
+ ${codeAgentClip3(summary, DeepSeekWeb.summaryChars)}`;
1446
+ }).join(`
1447
+ `);
1448
+ }
1449
+ async fetch(url, signal) {
1450
+ const page = await this.#call("fetch", { url }, 30000, signal);
1451
+ return { title: page.title ?? "", content: DeepSeekWeb.unescape(page.content ?? "") };
1452
+ }
1453
+ static unescape(markdown) {
1454
+ const escaped = markdown.match(/\\[!-/:-@[-`{-~]/g)?.length ?? 0;
1455
+ const punctuation = markdown.match(/[!-/:-@[-`{-~]/g)?.length ?? 0;
1456
+ if (!escaped || escaped < (punctuation - escaped) / 2)
1457
+ return markdown;
1458
+ return markdown.replace(/\\([!-/:-@[-`{-~])/g, "$1");
1459
+ }
1460
+ async#call(tool, body, timeoutMs, signal) {
1461
+ for (let attempt = 1;; attempt++) {
1462
+ const response = await fetch(`${this.#baseUrl}/${tool}`, {
1463
+ method: "POST",
1464
+ headers: { authorization: `Bearer ${this.#key}`, "content-type": "application/json" },
1465
+ body: JSON.stringify(body),
1466
+ signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs)
1467
+ });
1468
+ if (response.ok)
1469
+ return await response.json();
1470
+ if (!DeepSeekWeb.#retryable[tool].includes(response.status) || attempt >= DeepSeekWeb.#attempts) {
1471
+ const error = await response.json().catch(() => {
1472
+ return;
1473
+ });
1474
+ throw new Error(`DeepSeek ${tool} answered ${response.status}: ${error?.error?.message ?? response.statusText}`);
1475
+ }
1476
+ await DeepSeekWeb.#wait(DeepSeekWeb.#delayOf(response, attempt), signal);
1477
+ }
1478
+ }
1479
+ static #delayOf(response, attempt) {
1480
+ const retryAfter = Number(response.headers.get("retry-after"));
1481
+ return Number.isFinite(retryAfter) && retryAfter > 0 ? Math.min(retryAfter, 5) * 1000 : 1000 * 2 ** (attempt - 1);
1482
+ }
1483
+ static #wait(ms, signal) {
1484
+ return new Promise((resolve) => {
1485
+ const timer = setTimeout(resolve, ms);
1486
+ signal?.addEventListener("abort", () => {
1487
+ clearTimeout(timer);
1488
+ resolve();
1489
+ }, { once: true });
1490
+ });
1491
+ }
1492
+ static #cleanUrl(url) {
1493
+ try {
1494
+ const parsed = new URL(url);
1495
+ for (const name of [...parsed.searchParams.keys()])
1496
+ if (name.startsWith("utm_"))
1497
+ parsed.searchParams.delete(name);
1498
+ if (/^#\d+$/.test(parsed.hash))
1499
+ parsed.hash = "";
1500
+ return parsed.toString();
1501
+ } catch {
1502
+ return url;
1503
+ }
1504
+ }
1505
+ }
1506
+
1507
+ // pkgs/@akanjs/devkit/codeAgent/tools/WebToolPack.ts
1401
1508
  class WebToolPack2 {
1509
+ static pageChars = 1e4;
1510
+ static maxResults = 10;
1511
+ static #rememberedPages = 16;
1402
1512
  #options;
1513
+ #pages = new Map;
1403
1514
  constructor(options) {
1404
1515
  this.#options = options;
1405
1516
  }
@@ -1438,7 +1549,7 @@ class WebToolPack2 {
1438
1549
  const names = [];
1439
1550
  if (this.#options.profile.tools.web.fetch)
1440
1551
  names.push("web_fetch");
1441
- if (this.#options.profile.tools.web.search && WebToolPack2.#provider())
1552
+ if (this.#options.profile.tools.web.search && this.#searcher())
1442
1553
  names.push("web_search");
1443
1554
  return names;
1444
1555
  }
@@ -1450,58 +1561,146 @@ class WebToolPack2 {
1450
1561
  #register(pi) {
1451
1562
  if (this.#options.profile.tools.web.fetch)
1452
1563
  this.#registerFetch(pi);
1453
- const provider = WebToolPack2.#provider();
1454
- if (this.#options.profile.tools.web.search && provider)
1455
- this.#registerSearch(pi, provider);
1564
+ const searcher = this.#searcher();
1565
+ if (this.#options.profile.tools.web.search && searcher)
1566
+ this.#registerSearch(pi, searcher);
1456
1567
  }
1457
1568
  #registerFetch(pi) {
1458
1569
  const allowHosts = this.#options.profile.network.allowHosts;
1459
1570
  pi.registerTool({
1460
1571
  name: "web_fetch",
1461
1572
  label: "Fetch",
1462
- description: "Fetch a URL and return its readable text. HTML is stripped to text; the result is truncated.",
1573
+ description: `Fetch a URL and return its readable text, ${WebToolPack2.pageChars} characters at a time. A longer page ends with the offset that continues it.`,
1463
1574
  promptSnippet: "web_fetch: fetch a URL and return its readable text",
1464
- parameters: Type6.Object({ url: Type6.String({ description: "Absolute http(s) URL." }) }),
1465
- execute: async (_id, params) => {
1575
+ parameters: Type6.Object({
1576
+ url: Type6.String({ description: "Absolute http(s) URL." }),
1577
+ offset: Type6.Optional(Type6.Number({ description: "Character offset a previous call named, to read on." }))
1578
+ }),
1579
+ execute: async (_id, params, signal) => {
1466
1580
  const refusal = WebToolPack2.#refuseHost(params.url, allowHosts);
1467
1581
  if (refusal)
1468
1582
  return { content: [{ type: "text", text: refusal }], details: undefined, isError: true };
1469
- const response = await fetch(params.url, { signal: AbortSignal.timeout(20000), redirect: "follow" });
1470
- const text = WebToolPack2.#readable(await response.text());
1583
+ const offset = Math.max(0, Math.floor(params.offset ?? 0));
1584
+ const cached = offset ? this.#pages.get(params.url) : undefined;
1585
+ const page = cached ?? await this.#read(params.url, signal);
1586
+ if (page.ok)
1587
+ this.#remember(params.url, page);
1471
1588
  return {
1472
- content: [
1473
- { type: "text", text: `${response.status} ${params.url}
1474
-
1475
- ${codeAgentClip3(text, codeAgentOutputChars3)}` }
1476
- ],
1589
+ content: [{ type: "text", text: WebToolPack2.#window(params.url, page, offset) }],
1477
1590
  details: undefined,
1478
- isError: !response.ok
1591
+ isError: !page.ok
1479
1592
  };
1480
1593
  }
1481
1594
  });
1482
1595
  }
1483
- #registerSearch(pi, provider) {
1596
+ #registerSearch(pi, searcher) {
1597
+ const hint = searcher.name === "deepseek" ? ` Keep the query within ${DeepSeekWeb.maxQueryChars} characters; site:, -site: and quoted phrases work.` : "";
1484
1598
  pi.registerTool({
1485
1599
  name: "web_search",
1486
1600
  label: "Search",
1487
- description: `Search the web (${provider.name}) and return the top results as title, url and snippet.`,
1601
+ description: `Search the web (${searcher.name}) and return the top results as title, url and summary.${hint}`,
1488
1602
  promptSnippet: "web_search: search the web and return titles, urls and snippets",
1489
1603
  parameters: Type6.Object({
1490
1604
  query: Type6.String(),
1491
- count: Type6.Optional(Type6.Number({ description: "How many results, default 5." }))
1605
+ count: Type6.Optional(Type6.Number({ description: `How many results, default 5, at most ${WebToolPack2.maxResults}.` }))
1492
1606
  }),
1493
- execute: async (_id, params) => {
1494
- const key = process.env[provider.envKey] ?? "";
1495
- const results = await provider.search(key, params.query, params.count ?? 5);
1496
- return {
1497
- content: [{ type: "text", text: codeAgentClip3(results || "(no results)", codeAgentOutputChars3) }],
1498
- details: undefined
1499
- };
1607
+ execute: async (_id, params, signal) => {
1608
+ const count = Math.min(Math.max(Math.round(params.count ?? 5), 1), WebToolPack2.maxResults);
1609
+ try {
1610
+ const results = await searcher.search(params.query, count, signal);
1611
+ return {
1612
+ content: [{ type: "text", text: codeAgentClip4(results || "(no results)", WebToolPack2.pageChars) }],
1613
+ details: undefined
1614
+ };
1615
+ } catch (error) {
1616
+ const message = error instanceof Error ? error.message : String(error);
1617
+ return { content: [{ type: "text", text: message }], details: undefined, isError: true };
1618
+ }
1500
1619
  }
1501
1620
  });
1502
1621
  }
1503
- static #provider() {
1504
- return WebToolPack2.providers.find((provider) => !!process.env[provider.envKey]);
1622
+ #searcher() {
1623
+ const provider = WebToolPack2.providers.find((entry) => !!process.env[entry.envKey]);
1624
+ if (provider)
1625
+ return {
1626
+ name: provider.name,
1627
+ search: (query, count) => provider.search(process.env[provider.envKey] ?? "", query, count)
1628
+ };
1629
+ const deepseek = this.#options.deepseek;
1630
+ return deepseek ? { name: "deepseek", search: (query, count, signal) => deepseek.search(query, count, signal) } : undefined;
1631
+ }
1632
+ async#read(url, signal) {
1633
+ const deepseek = this.#options.deepseek;
1634
+ if (deepseek && !await this.#isLocal(new URL(url).hostname)) {
1635
+ try {
1636
+ const page = await deepseek.fetch(url, signal);
1637
+ return { status: 200, ok: true, title: page.title, text: page.content };
1638
+ } catch (error) {
1639
+ if (signal?.aborted)
1640
+ throw error;
1641
+ }
1642
+ }
1643
+ const response = await fetch(url, {
1644
+ signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(20000)]) : AbortSignal.timeout(20000),
1645
+ redirect: "follow"
1646
+ });
1647
+ return { status: response.status, ok: response.ok, title: "", text: WebToolPack2.#readable(await response.text()) };
1648
+ }
1649
+ #remember(url, page) {
1650
+ this.#pages.delete(url);
1651
+ this.#pages.set(url, page);
1652
+ const oldest = this.#pages.keys().next().value;
1653
+ if (this.#pages.size > WebToolPack2.#rememberedPages && oldest)
1654
+ this.#pages.delete(oldest);
1655
+ }
1656
+ static #window(url, page, offset) {
1657
+ const head = [`${page.status} ${url}`, page.title].filter(Boolean).join(`
1658
+ `);
1659
+ const total = page.text.length;
1660
+ if (offset && offset >= total)
1661
+ return `${head}
1662
+
1663
+ Offset ${offset} is past the end; the page has ${total} characters.`;
1664
+ const end = Math.min(offset + WebToolPack2.pageChars, total);
1665
+ const rest = end < total ? `
1666
+
1667
+ [characters ${offset}\u2013${end} of ${total}; offset ${end} reads on]` : "";
1668
+ return `${head}
1669
+
1670
+ ${page.text.slice(offset, end)}${rest}`;
1671
+ }
1672
+ async#isLocal(hostname) {
1673
+ const host = hostname.replace(/^\[|\]$|\.$/g, "").toLowerCase();
1674
+ if (isIP(host))
1675
+ return WebToolPack2.#isLocalAddress(host);
1676
+ if (!host.includes(".") || /\.(localhost|local|internal|lan|home\.arpa)$/.test(host))
1677
+ return true;
1678
+ try {
1679
+ const addresses = await (this.#options.lookup ?? WebToolPack2.#lookup)(host);
1680
+ return !addresses.length || addresses.some((address) => WebToolPack2.#isLocalAddress(address));
1681
+ } catch {
1682
+ return true;
1683
+ }
1684
+ }
1685
+ static async#lookup(host) {
1686
+ return (await lookup(host, { all: true })).map((entry) => entry.address);
1687
+ }
1688
+ static #isLocalAddress(literal) {
1689
+ const address = WebToolPack2.#unmapped(literal);
1690
+ if (isIP(address) === 6)
1691
+ return address === "::" || address === "::1" || /^(f[cd]|fe[89ab])/.test(address);
1692
+ const [a = 0, b = 0] = address.split(".").map(Number);
1693
+ return a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168;
1694
+ }
1695
+ static #unmapped(address) {
1696
+ const mapped = /^::ffff:(?:(\d+\.\d+\.\d+\.\d+)|([0-9a-f]{1,4}):([0-9a-f]{1,4}))$/i.exec(address);
1697
+ if (!mapped)
1698
+ return address;
1699
+ if (mapped[1])
1700
+ return mapped[1];
1701
+ const high = Number.parseInt(mapped[2] ?? "0", 16);
1702
+ const low = Number.parseInt(mapped[3] ?? "0", 16);
1703
+ return [high >> 8, high & 255, low >> 8, low & 255].join(".");
1505
1704
  }
1506
1705
  static #refuseHost(url, allowHosts) {
1507
1706
  let parsed;
@@ -1533,7 +1732,7 @@ class AkanCodePlugins2 {
1533
1732
  });
1534
1733
  const dispose = () => mcp?.close();
1535
1734
  const mcpStatus = mcp?.status ?? [];
1536
- const web = new WebToolPack2({ profile: options.profile });
1735
+ const web = new WebToolPack2({ profile: options.profile, deepseek: options.deepseek });
1537
1736
  const sessions = new SessionToolPack2({
1538
1737
  workspaceRoot: options.workspace.workspaceRoot,
1539
1738
  cwd: options.cwd,
@@ -1668,9 +1867,9 @@ class CodeAgentAsks2 {
1668
1867
 
1669
1868
  // pkgs/@akanjs/devkit/codeAgent/agent/CodeAgentEventMapper.ts
1670
1869
  import {
1671
- codeAgentClip as codeAgentClip4,
1870
+ codeAgentClip as codeAgentClip5,
1672
1871
  codeAgentLabelChars,
1673
- codeAgentOutputChars as codeAgentOutputChars4
1872
+ codeAgentOutputChars as codeAgentOutputChars3
1674
1873
  } from "akanjs/common";
1675
1874
 
1676
1875
  // pkgs/@akanjs/devkit/codeAgent/agent/stringArg.ts
@@ -1730,7 +1929,7 @@ class CodeAgentEventMapper2 {
1730
1929
  type: "tool_progress",
1731
1930
  turnId: this.#turnId,
1732
1931
  toolCallId: event.toolCallId,
1733
- text: codeAgentClip4(CodeAgentEventMapper2.#renderToolText(event.partialResult), codeAgentLabelChars)
1932
+ text: codeAgentClip5(CodeAgentEventMapper2.#renderToolText(event.partialResult), codeAgentLabelChars)
1734
1933
  }
1735
1934
  ];
1736
1935
  case "tool_execution_end":
@@ -1801,8 +2000,8 @@ class CodeAgentEventMapper2 {
1801
2000
  turnId: this.#turnId,
1802
2001
  tool,
1803
2002
  outcome: reason ? "blocked" : event.isError ? "error" : "ok",
1804
- output: codeAgentClip4(full, codeAgentOutputChars4),
1805
- truncated: full.length > codeAgentOutputChars4
2003
+ output: codeAgentClip5(full, codeAgentOutputChars3),
2004
+ truncated: full.length > codeAgentOutputChars3
1806
2005
  };
1807
2006
  }
1808
2007
  noteOutcome(reason) {
@@ -1831,7 +2030,7 @@ class CodeAgentEventMapper2 {
1831
2030
  name,
1832
2031
  op: toolOps[name] ?? "other",
1833
2032
  ...path ? { path } : {},
1834
- title: codeAgentClip4(`${name}${CodeAgentEventMapper2.#renderArgs(args)}`, codeAgentLabelChars)
2033
+ title: codeAgentClip5(`${name}${CodeAgentEventMapper2.#renderArgs(args)}`, codeAgentLabelChars)
1835
2034
  };
1836
2035
  }
1837
2036
  #mapDelta(event) {
@@ -1858,7 +2057,7 @@ class CodeAgentEventMapper2 {
1858
2057
  if (!entries.length)
1859
2058
  return "";
1860
2059
  const rendered = entries.map(([key, value]) => `${key}=${CodeAgentEventMapper2.#renderArgValue(value)}`).join(" ");
1861
- return `(${codeAgentClip4(rendered, 120)})`;
2060
+ return `(${codeAgentClip5(rendered, 120)})`;
1862
2061
  }
1863
2062
  static #renderArgValue(value) {
1864
2063
  if (Array.isArray(value))
@@ -1867,7 +2066,7 @@ class CodeAgentEventMapper2 {
1867
2066
  const keys = Object.keys(value).length;
1868
2067
  return `{${keys} key${keys === 1 ? "" : "s"}}`;
1869
2068
  }
1870
- return codeAgentClip4(String(value), 60);
2069
+ return codeAgentClip5(String(value), 60);
1871
2070
  }
1872
2071
  static #renderContent(content) {
1873
2072
  if (typeof content === "string")
@@ -2308,6 +2507,7 @@ class CodeAgent2 {
2308
2507
  #replay = [];
2309
2508
  #replayFrom = 0;
2310
2509
  #lastContextTokens;
2510
+ #autoCompactAt;
2311
2511
  constructor(profile) {
2312
2512
  this.#profile = profile;
2313
2513
  this.#gate = new CodeAgentGate2(profile);
@@ -2316,8 +2516,10 @@ class CodeAgent2 {
2316
2516
  const workspaceRoot = options.workspace.workspaceRoot;
2317
2517
  const cwd = options.cwd ?? workspaceRoot;
2318
2518
  const agent = new CodeAgent2(options.profile);
2519
+ const autoCompactAt = AkanCodeCompaction2.normalize(options.autoCompactAt);
2319
2520
  const settingsManager = AkanCodeServices2.settings();
2320
- const modelRuntime = await AkanCodeServices2.runtime(workspaceRoot, CodeAgentProxy.fromEnv(options.profile));
2521
+ const proxy = CodeAgentProxy.fromEnv(options.profile);
2522
+ const modelRuntime = await AkanCodeServices2.runtime(workspaceRoot, proxy);
2321
2523
  const model = await akanCodeModel2(modelRuntime, options.model);
2322
2524
  const compaction = settingsManager.getCompactionSettings(model);
2323
2525
  const modelWarnings = akanCodeModelWarnings2(model, compaction.reserveTokens + compaction.keepRecentTokens);
@@ -2327,6 +2529,7 @@ class CodeAgent2 {
2327
2529
  profile: options.profile,
2328
2530
  apps: options.apps ?? [],
2329
2531
  canSeeImages: akanCodeModelSupportsImages2(model),
2532
+ deepseek: await DeepSeekWeb.fromRuntime(modelRuntime, !!proxy),
2330
2533
  depth: options.depth ?? 0,
2331
2534
  ...options.subagentSpend ? { subagentSpend: options.subagentSpend } : {},
2332
2535
  currentSessionId: () => agent.sessionId,
@@ -2365,10 +2568,11 @@ class CodeAgent2 {
2365
2568
  if (options.profile.session.store !== "memory")
2366
2569
  agent.#sessionDir = akanCodePaths2.sessionsDir(workspaceRoot);
2367
2570
  await agent.#attach(session, options.mode ?? "print");
2571
+ const autoCompactWarning = agent.#fitAutoCompact(autoCompactAt);
2368
2572
  agent.#suspended = new CodeAgentSuspended(CodeAgentSuspended.fileOf(agent.#sessionDir, agent.sessionId));
2369
2573
  if (agent.#sessionDir && options.profile.session.store === "file")
2370
2574
  agent.#openMail(akanCodePaths2.mailDir(workspaceRoot), cwd);
2371
- for (const message of modelWarnings)
2575
+ for (const message of [...modelWarnings, ...autoCompactWarning])
2372
2576
  agent.#emit({ type: "notice", level: "warning", message });
2373
2577
  return agent;
2374
2578
  }
@@ -2433,6 +2637,7 @@ ${mail.text}`).catch((error) => this.#emit({ type: "notice", level: "error", mes
2433
2637
  tools: session.getActiveToolNames(),
2434
2638
  contextTokens: model?.contextWindow,
2435
2639
  effort: session.supportsThinking() ? session.thinkingLevel : undefined,
2640
+ autoCompactAt: this.#autoCompactAt,
2436
2641
  name: session.sessionName,
2437
2642
  interaction: this.#profile.interaction
2438
2643
  };
@@ -2581,8 +2786,38 @@ Continue the task.`);
2581
2786
  if (!model)
2582
2787
  throw new Error(`Unknown model: ${ref.provider}/${ref.id}`);
2583
2788
  await session.setModel(model);
2789
+ for (const message of this.#fitAutoCompact(this.#autoCompactAt))
2790
+ this.#emit({ type: "notice", level: "warning", message });
2791
+ this.#emit({ type: "session", info: this.info });
2792
+ }
2793
+ setAutoCompactAt(percent) {
2794
+ const wanted = AkanCodeCompaction2.normalize(percent);
2795
+ const problem = this.#autoCompactProblem(wanted);
2796
+ if (problem)
2797
+ throw new Error(problem);
2798
+ this.#autoCompactAt = wanted;
2799
+ this.#applyAutoCompact();
2584
2800
  this.#emit({ type: "session", info: this.info });
2585
2801
  }
2802
+ #fitAutoCompact(percent) {
2803
+ const problem = this.#autoCompactProblem(percent);
2804
+ this.#autoCompactAt = problem ? undefined : percent;
2805
+ this.#applyAutoCompact();
2806
+ return problem ? [`${problem} Autocompact is back to the default.`] : [];
2807
+ }
2808
+ #autoCompactProblem(percent) {
2809
+ const session = this.#require();
2810
+ const model = session.model;
2811
+ if (!model || !percent)
2812
+ return;
2813
+ const { keepRecentTokens } = session.settingsManager.getCompactionSettings(model);
2814
+ return AkanCodeCompaction2.problemOf(model, percent, keepRecentTokens);
2815
+ }
2816
+ #applyAutoCompact() {
2817
+ const session = this.#require();
2818
+ if (session.model)
2819
+ AkanCodeCompaction2.apply(session.settingsManager, session.model, this.#autoCompactAt);
2820
+ }
2586
2821
  async waitForIdle() {
2587
2822
  await this.#require().waitForIdle();
2588
2823
  }
@@ -2689,7 +2924,7 @@ Continue the task.`);
2689
2924
  approvalId,
2690
2925
  toolCallId,
2691
2926
  name,
2692
- summary: codeAgentClip5(summary, codeAgentLabelChars2),
2927
+ summary: codeAgentClip6(summary, codeAgentLabelChars2),
2693
2928
  policy: this.#profile.approval
2694
2929
  };
2695
2930
  this.#emit({ type: "approval", request });
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  runner,
4
4
  script
5
- } from "./index-jw1zm273.js";
5
+ } from "./index-fbw3kmt5.js";
6
6
  import {
7
7
  AGENT_BLOCK_START,
8
8
  AGENT_BLOCK_END,
@@ -13,14 +13,14 @@ import {
13
13
  CLAUDE_COMMENT_RULE,
14
14
  AppExecutor,
15
15
  LibExecutor
16
- } from "./index-va06nr10.js";
16
+ } from "./index-n8dsax1f.js";
17
17
  import {
18
18
  collectRecipeSources2,
19
19
  scanRecipes2
20
20
  } from "./index-hj6w4ka1.js";
21
21
  import {
22
22
  AkanContextAnalyzer
23
- } from "./index-5edzv8fn.js";
23
+ } from "./index-aqwdjn4x.js";
24
24
  import {
25
25
  Prompter2
26
26
  } from "./index-zzvvc845.js";
@@ -9,10 +9,10 @@ import {
9
9
  NativePublicEnv,
10
10
  UpdatePackFolder,
11
11
  NativeApp
12
- } from "./index-g1mbppa9.js";
12
+ } from "./index-nr8m4j21.js";
13
13
  import {
14
14
  ExitCodeError
15
- } from "./index-jw1zm273.js";
15
+ } from "./index-fbw3kmt5.js";
16
16
  import {
17
17
  ConfigLock
18
18
  } from "./index-bqbf654f.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  AppExecutor,
4
4
  LibExecutor
5
- } from "./index-va06nr10.js";
5
+ } from "./index-n8dsax1f.js";
6
6
 
7
7
  // pkgs/@akanjs/devkit/workflow/artifacts.ts
8
8
  import { capitalize } from "akanjs/common";