@anhlp/alp-runtime 0.0.1-beta.4 → 0.0.1-beta.6

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 (67) hide show
  1. package/dist/acp-transport.js +5 -36
  2. package/dist/antigravity-transport.d.ts +17 -0
  3. package/dist/antigravity-transport.js +82 -58
  4. package/dist/assignment-results.d.ts +34 -0
  5. package/dist/assignment-results.js +94 -2
  6. package/dist/board-domain.js +2 -2
  7. package/dist/board.d.ts +6 -0
  8. package/dist/board.js +7 -0
  9. package/dist/catalog.d.ts +13 -0
  10. package/dist/catalog.js +9 -1
  11. package/dist/claude-transport.d.ts +7 -0
  12. package/dist/claude-transport.js +71 -10
  13. package/dist/compact.d.ts +29 -0
  14. package/dist/compact.js +49 -0
  15. package/dist/configure.d.ts +1 -1
  16. package/dist/configure.js +2 -2
  17. package/dist/contracts.d.ts +32 -3
  18. package/dist/index.d.ts +10 -2
  19. package/dist/index.js +30 -2
  20. package/dist/input-limits.d.ts +25 -0
  21. package/dist/input-limits.js +48 -0
  22. package/dist/language.d.ts +8 -0
  23. package/dist/language.js +20 -0
  24. package/dist/mcp-tools.d.ts +8 -0
  25. package/dist/mcp-tools.js +26 -0
  26. package/dist/model-catalog.d.ts +76 -0
  27. package/dist/model-catalog.js +193 -0
  28. package/dist/model-probes.d.ts +7 -0
  29. package/dist/model-probes.js +69 -0
  30. package/dist/providers.js +2 -0
  31. package/dist/resolve.d.ts +1 -0
  32. package/dist/resolve.js +3 -1
  33. package/dist/runtime.d.ts +3 -1
  34. package/dist/runtime.js +665 -47
  35. package/dist/session-config.d.ts +174 -0
  36. package/dist/session-config.js +9 -9
  37. package/dist/session-state.d.ts +23 -1
  38. package/dist/tools.d.ts +82 -0
  39. package/dist/tools.js +53 -5
  40. package/dist/transport.js +3 -1
  41. package/dist/workspace.d.ts +31 -5
  42. package/dist/workspace.js +92 -11
  43. package/package.json +3 -3
  44. package/src/acp-transport.ts +7 -37
  45. package/src/antigravity-transport.ts +95 -53
  46. package/src/assignment-results.ts +85 -3
  47. package/src/board-domain.ts +2 -2
  48. package/src/board.ts +7 -0
  49. package/src/catalog.ts +10 -1
  50. package/src/claude-transport.ts +79 -10
  51. package/src/compact.ts +62 -0
  52. package/src/configure.ts +3 -3
  53. package/src/contracts.ts +28 -2
  54. package/src/index.ts +10 -2
  55. package/src/input-limits.ts +65 -0
  56. package/src/language.ts +18 -0
  57. package/src/mcp-tools.ts +33 -0
  58. package/src/model-catalog.ts +166 -0
  59. package/src/model-probes.ts +58 -0
  60. package/src/providers.ts +3 -0
  61. package/src/resolve.ts +4 -2
  62. package/src/runtime.ts +718 -48
  63. package/src/session-config.ts +8 -8
  64. package/src/session-state.ts +15 -1
  65. package/src/tools.ts +53 -5
  66. package/src/transport.ts +3 -1
  67. package/src/workspace.ts +124 -18
@@ -268,7 +268,9 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
268
268
  type: string;
269
269
  items: {
270
270
  type: string;
271
+ maxLength: number;
271
272
  };
273
+ maxItems: number;
272
274
  description: string;
273
275
  };
274
276
  };
@@ -288,6 +290,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
288
290
  type: string;
289
291
  enum: readonly ["claim", "decision", "finding"];
290
292
  };
293
+ maxItems: 3;
291
294
  };
292
295
  limit: {
293
296
  type: string;
@@ -355,6 +358,51 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
355
358
  required: string[];
356
359
  additionalProperties: boolean;
357
360
  };
361
+ } | {
362
+ type: string;
363
+ name: string;
364
+ description: string;
365
+ inputSchema: {
366
+ type: string;
367
+ properties: {
368
+ changes: {
369
+ type: string;
370
+ description: string;
371
+ items: {
372
+ type: string;
373
+ properties: {
374
+ scope: {
375
+ type: string;
376
+ enum: string[];
377
+ };
378
+ remove: {
379
+ type: string;
380
+ items: {
381
+ type: string;
382
+ };
383
+ description: string;
384
+ };
385
+ add: {
386
+ type: string;
387
+ description: string;
388
+ };
389
+ reason: {
390
+ type: string;
391
+ description: string;
392
+ };
393
+ };
394
+ required: string[];
395
+ additionalProperties: boolean;
396
+ };
397
+ };
398
+ requestId: {
399
+ type: string;
400
+ description: string;
401
+ };
402
+ };
403
+ required: string[];
404
+ additionalProperties: boolean;
405
+ };
358
406
  } | {
359
407
  type: string;
360
408
  name: string;
@@ -576,6 +624,15 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
576
624
  type: string;
577
625
  description: string;
578
626
  } | undefined;
627
+ options?: {
628
+ type: string;
629
+ items: {
630
+ type: string;
631
+ maxLength: number;
632
+ };
633
+ maxItems: number;
634
+ description: string;
635
+ } | undefined;
579
636
  gate?: {
580
637
  type: string;
581
638
  description: string;
@@ -588,6 +645,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
588
645
  type: string;
589
646
  additionalProperties: {
590
647
  type: string;
648
+ maxLength: number;
591
649
  };
592
650
  description: string;
593
651
  } | undefined;
@@ -953,7 +1011,9 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
953
1011
  type: string;
954
1012
  items: {
955
1013
  type: string;
1014
+ maxLength: number;
956
1015
  };
1016
+ maxItems: number;
957
1017
  description: string;
958
1018
  };
959
1019
  };
@@ -973,6 +1033,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
973
1033
  type: string;
974
1034
  enum: readonly ["claim", "decision", "finding"];
975
1035
  };
1036
+ maxItems: 3;
976
1037
  };
977
1038
  limit: {
978
1039
  type: string;
@@ -1040,6 +1101,51 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1040
1101
  required: string[];
1041
1102
  additionalProperties: boolean;
1042
1103
  };
1104
+ } | {
1105
+ type: string;
1106
+ name: string;
1107
+ description: string;
1108
+ inputSchema: {
1109
+ type: string;
1110
+ properties: {
1111
+ changes: {
1112
+ type: string;
1113
+ description: string;
1114
+ items: {
1115
+ type: string;
1116
+ properties: {
1117
+ scope: {
1118
+ type: string;
1119
+ enum: string[];
1120
+ };
1121
+ remove: {
1122
+ type: string;
1123
+ items: {
1124
+ type: string;
1125
+ };
1126
+ description: string;
1127
+ };
1128
+ add: {
1129
+ type: string;
1130
+ description: string;
1131
+ };
1132
+ reason: {
1133
+ type: string;
1134
+ description: string;
1135
+ };
1136
+ };
1137
+ required: string[];
1138
+ additionalProperties: boolean;
1139
+ };
1140
+ };
1141
+ requestId: {
1142
+ type: string;
1143
+ description: string;
1144
+ };
1145
+ };
1146
+ required: string[];
1147
+ additionalProperties: boolean;
1148
+ };
1043
1149
  } | {
1044
1150
  type: string;
1045
1151
  name: string;
@@ -1261,6 +1367,15 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1261
1367
  type: string;
1262
1368
  description: string;
1263
1369
  } | undefined;
1370
+ options?: {
1371
+ type: string;
1372
+ items: {
1373
+ type: string;
1374
+ maxLength: number;
1375
+ };
1376
+ maxItems: number;
1377
+ description: string;
1378
+ } | undefined;
1264
1379
  gate?: {
1265
1380
  type: string;
1266
1381
  description: string;
@@ -1273,6 +1388,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1273
1388
  type: string;
1274
1389
  additionalProperties: {
1275
1390
  type: string;
1391
+ maxLength: number;
1276
1392
  };
1277
1393
  description: string;
1278
1394
  } | undefined;
@@ -1640,7 +1756,9 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1640
1756
  type: string;
1641
1757
  items: {
1642
1758
  type: string;
1759
+ maxLength: number;
1643
1760
  };
1761
+ maxItems: number;
1644
1762
  description: string;
1645
1763
  };
1646
1764
  };
@@ -1660,6 +1778,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1660
1778
  type: string;
1661
1779
  enum: readonly ["claim", "decision", "finding"];
1662
1780
  };
1781
+ maxItems: 3;
1663
1782
  };
1664
1783
  limit: {
1665
1784
  type: string;
@@ -1727,6 +1846,51 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1727
1846
  required: string[];
1728
1847
  additionalProperties: boolean;
1729
1848
  };
1849
+ } | {
1850
+ type: string;
1851
+ name: string;
1852
+ description: string;
1853
+ inputSchema: {
1854
+ type: string;
1855
+ properties: {
1856
+ changes: {
1857
+ type: string;
1858
+ description: string;
1859
+ items: {
1860
+ type: string;
1861
+ properties: {
1862
+ scope: {
1863
+ type: string;
1864
+ enum: string[];
1865
+ };
1866
+ remove: {
1867
+ type: string;
1868
+ items: {
1869
+ type: string;
1870
+ };
1871
+ description: string;
1872
+ };
1873
+ add: {
1874
+ type: string;
1875
+ description: string;
1876
+ };
1877
+ reason: {
1878
+ type: string;
1879
+ description: string;
1880
+ };
1881
+ };
1882
+ required: string[];
1883
+ additionalProperties: boolean;
1884
+ };
1885
+ };
1886
+ requestId: {
1887
+ type: string;
1888
+ description: string;
1889
+ };
1890
+ };
1891
+ required: string[];
1892
+ additionalProperties: boolean;
1893
+ };
1730
1894
  } | {
1731
1895
  type: string;
1732
1896
  name: string;
@@ -1948,6 +2112,15 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1948
2112
  type: string;
1949
2113
  description: string;
1950
2114
  } | undefined;
2115
+ options?: {
2116
+ type: string;
2117
+ items: {
2118
+ type: string;
2119
+ maxLength: number;
2120
+ };
2121
+ maxItems: number;
2122
+ description: string;
2123
+ } | undefined;
1951
2124
  gate?: {
1952
2125
  type: string;
1953
2126
  description: string;
@@ -1960,6 +2133,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1960
2133
  type: string;
1961
2134
  additionalProperties: {
1962
2135
  type: string;
2136
+ maxLength: number;
1963
2137
  };
1964
2138
  description: string;
1965
2139
  } | undefined;
@@ -5,9 +5,10 @@ import { anyModel, profileModel } from "@anhlp/alp-core/profiles";
5
5
  import { models, thinkingOptionsFor } from "./catalog.js";
6
6
  import { claudeSandboxAvailable, SKILL_PLUGIN } from "./claude-transport.js";
7
7
  import { languageInstruction } from "./language.js";
8
- import { HANDOFF_TOOL, WAIT_TOOL, SEND_TOOL, MERGE_TOOL, VERIFY_TOOL, DISCARD_TOOL, CANCEL_TOOL, RECALL_TOOL, PIN_TOOL, BOARD_TOOL, UNPIN_TOOL, ASK_TOOL, LESSON_TOOL, SKILL_TOOL, ISSUE_TOOL, SCHEDULE_TOOL, mainOf, taskActions, taskTool } from "./tools.js";
8
+ import { antigravityModeText } from "./antigravity-transport.js";
9
+ import { HANDOFF_TOOL, WAIT_TOOL, SEND_TOOL, MERGE_TOOL, VERIFY_TOOL, DISCARD_TOOL, RESOLVE_TOOL, CANCEL_TOOL, RECALL_TOOL, PIN_TOOL, BOARD_TOOL, UNPIN_TOOL, ASK_TOOL, LESSON_TOOL, LESSON_CURATE_TOOL, SKILL_TOOL, ISSUE_TOOL, SCHEDULE_TOOL, mainOf, taskActions, taskTool } from "./tools.js";
9
10
  import { COMPACT_SHARE } from "./runtime-context.js";
10
- var nativeMode = (mapping) => mapping.runtimeKind === "antigravity" && mapping.mode === "read-only" && mapping.antigravity?.readOnlyMode === "instructions" ? "full-access" : mapping.copy ? "workspace-write" : mapping.mode;
11
+ var nativeMode = (mapping) => mapping.copy ? "workspace-write" : mapping.mode;
11
12
  function claudeFloor(mapping) {
12
13
  if (mapping.runtimeKind !== "claude" || !claudeSandboxAvailable()) return void 0;
13
14
  if (mapping.copy) return "workspace-write";
@@ -28,9 +29,8 @@ function permissionNote(mapping) {
28
29
  // ALPD §46: ALP has no sandbox around an ACP agent; it answers the agent's permission requests.
29
30
  ...mapping.runtimeKind === "acp" ? [`ALP's tools (alp_*) come from the MCP server named alp. ALP answers your permission requests by your ${mapping.mode} mode: ${mapping.mode === "read-only" ? "reading and searching only" : mapping.mode === "workspace-write" ? `reading, running commands, and changing files inside ${mapping.workdir} only` : "everything"}. Ask permission before every tool use that changes something, even where you would not need to.`] : [],
30
31
  ...mapping.runtimeKind === "antigravity" ? [
31
- "ALP's tools (alp_*) come from the MCP server named alp. Antigravity runs natively with full access.",
32
- "External MCP tools supplied by ALP also come from the MCP server named alp. Discover its tools: aliases beginning mcp__ and their descriptions identify the original server and tool. Use those aliases when calling the tools.",
33
- ...mapping.mode === "read-only" ? ["Read-only is emulated by instructions, not enforced by an OS sandbox. Your role is to read, analyze, advise and report only. Do not edit, create, delete or rename files. Do not run commands, builds, tests or native tools that mutate files, repositories, configuration or external state. Report any work that requires changes to your requester. ALP still restricts its own tools according to your read-only role."] : []
32
+ `ALP's tools (alp_*) come from the MCP server named alp. Your mode is ${mapping.mode}: ${antigravityModeText(mapping.mode)}`,
33
+ "External MCP tools supplied by ALP also come from the MCP server named alp. Discover its tools: aliases beginning mcp__ and their descriptions identify the original server and tool. Use those aliases when calling the tools."
34
34
  ] : [],
35
35
  ...mapping.copy ? [`You work in a disposable copy of your requester's tree at ${mapping.workdir}: the same files and git state, uncommitted changes included${mapping.copyOf ? `, mirroring ${mapping.copyOf}` : ""}. Write, build and test there; nothing you change reaches the requester, and the copy is removed when you finish. Where your brief names a path${mapping.copyOf ? ` under ${mapping.copyOf}` : ""}, use the same path in your copy. Never run a command in, or write to, the requester's tree.`] : [],
36
36
  ...floor ? [`Bash runs in an OS sandbox: ${floor === "read-only" ? "it writes nothing but temporary files" : `it writes only ${mapping.workdir} and temporary files`}, and has no network. Run any command you need for your work in it.${profile?.allow.length || profile?.ask.length || profile?.beyondMode === "ask" ? " To run a command outside it (one your profile allows, or one for the user to approve), set dangerouslyDisableSandbox on that Bash call: ALP decides, and asks the user when your profile says so. A sandbox error (Operation not permitted, no network) is not a refusal by the user: run that same command again with dangerouslyDisableSandbox rather than report it refused." : ""}`] : []
@@ -97,7 +97,7 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
97
97
  dynamicTools: [SEND_TOOL, BOARD_TOOL, taskTool(taskActions(mapping, parentAgent, role))]
98
98
  };
99
99
  }
100
- const delegationInstruction = targets.length ? `Use alp_delegate to assign bounded work to: ${targets.join(", ")}. Delegation has two finite budgets shared by the entire root session tree: 16 implementation starts (lead/peer) and separately 16 read-only advisor starts (reviewer/oracle). Only a new accepted user prompt in root, including steering, resets both; child turns, mail wakes and approval answers do not. Started assignments count even when they fail. Work runs in the background: by default alp_delegate starts the assignment and returns its assignmentId at once, and its result, questions and stall reports come to you as mail. Pass wait: true only when your very next step cannot go on without the result; it then returns the result, or early with the child's first question. A result carries the child's structured handoff (null if it filed none) and output, its final message. While assignments run, go on with work that does not depend on them; when only their results are left, alp_wait for them (mail from your requester or the user ends the wait early), or end your turn and ALP wakes you with their results and questions. Answer questions with alp_send kind answer and replyTo; use kind steer to change an instruction, note for information. To stop an assignment, for example one parked on a usage limit whose work should go on now, use alp_cancel and delegate the rest, on another runtime (pass a model of claude: or codex:); its changes stay in the checkout or its worktree. At most ${mapping.workflow.maxPeers} peers may run concurrently. Concurrent peers must be read-only or isolated: pass isolation "worktree" to give a writing peer its own git worktree. A worktree result lists its branch and changed files; apply it with alp_merge (uncommitted, conflicts left as markers) or drop it with alp_discard, then verify. Writers in this shared checkout run one at a time. To learn why a finished assignment did something, ask it with alp_recall rather than guessing from its handoff. When the project configures verify commands, ALP runs them before alp_merge applies a change, and after a writer in your checkout finishes; a failed check applies nothing. To fix a failed worktree change, delegate again with continueFrom set to its assignmentId. Do not run shell/file mutations in parallel with delegation. Include scope, constraints, verification, and required handoff in task. Child inherits your mode unless you request read-only. Review its returned evidence before answering. Do not use native spawn tools or shell-launched agents to bypass this route.` : "No delegation targets are authorized. Do not spawn agents or use shell-launched agents. Complete your assigned scope and return evidence.";
100
+ const delegationInstruction = targets.length ? `Use alp_delegate to assign bounded work to: ${targets.join(", ")}. Delegation has two finite budgets shared by the entire root session tree: 16 implementation starts (lead/peer) and separately 16 read-only advisor starts (reviewer/oracle). Only a new accepted user prompt in root, including steering, resets both; child turns, mail wakes and approval answers do not. Started assignments count even when they fail. Work runs in the background: by default alp_delegate starts the assignment and returns its assignmentId at once, and its result, questions and stall reports come to you as mail. Pass wait: true only when your very next step cannot go on without the result; it then returns the result, or early with the child's first question. A result carries the child's structured handoff (null if it filed none) and output, its final message. While assignments run, go on with work that does not depend on them; when only their results are left, alp_wait for them (mail from your requester or the user ends the wait early), or end your turn and ALP wakes you with their results and questions. Answer questions with alp_send kind answer and replyTo; use kind steer to change an instruction, note for information. To stop an assignment, for example one parked on a usage limit whose work should go on now, use alp_cancel and delegate the rest, on another runtime (pass a model of claude: or codex:); its changes stay in the checkout or its worktree. At most ${mapping.workflow.maxPeers} peers may run concurrently. Concurrent peers must be read-only or isolated: pass isolation "worktree" to give a writing peer its own git worktree. A worktree result lists its branch and changed files; apply it with alp_merge (uncommitted, conflicts left as markers) or drop it with alp_discard, then verify. Writers in this shared checkout run one at a time. A writer's change outside a worktree stays a result ALP keeps, and its checkout cannot be removed, until you record with alp_resolve that you applied, discarded or acknowledged it. To learn why a finished assignment did something, ask it with alp_recall rather than guessing from its handoff. When the project configures verify commands, ALP runs them before alp_merge applies a change, and after a writer in your checkout finishes; a failed check applies nothing. To fix a failed worktree change, delegate again with continueFrom set to its assignmentId. Do not run shell/file mutations in parallel with delegation. Include scope, constraints, verification, and required handoff in task. Child inherits your mode unless you request read-only. Review its returned evidence before answering. Do not use native spawn tools or shell-launched agents to bypass this route.` : "No delegation targets are authorized. Do not spawn agents or use shell-launched agents. Complete your assigned scope and return evidence.";
101
101
  return {
102
102
  runtime: runtimeKind,
103
103
  cwd: mapping.workdir,
@@ -117,7 +117,7 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
117
117
  // The team's house rules (ALPD §42); Phở and Cafe's are the text this line held before teams.
118
118
  `Profile: ${mapping.workflow.mode}; fixed for this session.${mapping.houseRules ? ` ${mapping.houseRules}` : ""}`,
119
119
  `Oracle runs on ${mapping.oracleModels.join(" or ")}; pass one as model (effort follows the team's oracle settings, otherwise high). For two independent opinions, start one oracle on each model with wait: false and compare their advice. If the model you need is unavailable, say so rather than choosing another. Usage context is advisory, may be unavailable or stale; never infer quota from token counts. Respect known exhausted limits and report them.`,
120
- ...supervised ? ["A supervisor reviews your process after each turn. Its notes ask about process mistakes: answer them in your reply, then record each lesson with alp_lesson (scope project for this project, user for every project). Do not argue a note away; when it is wrong, say why in one line. When three or more lessons cover one theme, or a lesson recurs, distill them into a skill with alp_skill: a method with steps and checks, listing the lessons it replaces. Scope it to the roles whose work it guides: yourself, lead, peer, oracle, reviewer, supervisor, or a custom agent; a lesson about briefing peers is yours, a lesson about verifying a change belongs to whoever makes it. The user approves it first."] : [],
120
+ ...supervised ? ["A supervisor reviews your process after each turn. Its notes ask about process mistakes: answer them in your reply, then record each lesson with alp_lesson (scope project for this project, user for every project). Do not argue a note away; when it is wrong, say why in one line. When three or more lessons cover one theme, or a lesson recurs, distill them into a skill with alp_skill: a method with steps and checks, listing the lessons it replaces. Scope it to the roles whose work it guides: yourself, lead, peer, oracle, reviewer, supervisor, or a custom agent; a lesson about briefing peers is yours, a lesson about verifying a change belongs to whoever makes it. The user approves it first. To merge, shorten or remove lessons use alp_lesson_curate (the curate skill), never a file edit."] : [],
121
121
  ...!parentAgent && mapping.agent.name === mainOf(mapping) ? ["When you find a problem outside the task that is worth tracking (a bug or gap in this project, or in ALP itself: its process, tools, agent instructions or runtime), search with alp_issue action search, then propose a comment on a matching issue or a new issue. Include facts, reproduction and evidence, never secrets. The user approves every post; never post issues or comments any other way, such as with gh in a shell."] : [],
122
122
  `ALP runtime identity: ${mapping.agent.name}. ${delegationInstruction}`,
123
123
  !parentAgent && mapping.agent.name === mainOf(mapping) ? `Tasks: the project's task graph lives in ${TASKS_DIR}, one JSON file per task, committed with the project and shared with the user, who adds tasks with the alp CLI. Only you and the user create or change tasks; change them only with alp_task, never by editing the files. Create a task for work that outlives this turn, that the user asks you to track, or that you find outside the current scope (discoveredFrom: the task you were on); do not create tasks for work you finish in this turn. Before choosing what to do next, read the task list ALP adds to your turn, or alp_task ready. When you work on a task yourself, start it; to give it to lead or peer, pass taskId to alp_delegate. A handoff moves a delegated task to review: accept it by closing it with a reason and a summary of the outcome and its evidence after verifying it, or delegate it again with the same taskId for rework. Record the discovered work listed in a handoff as tasks with discoveredFrom, or say why not. Model order with blockedBy and grouping with an epic parent.` : `Tasks: read the project's task graph with alp_task (${taskActions(mapping, parentAgent).join(", ")}). Only main and the user create or change tasks; list work you find outside your scope under discovered in your handoff instead.`,
@@ -178,10 +178,10 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
178
178
  }
179
179
  }
180
180
  ] : [],
181
- ...targets.length ? [WAIT_TOOL, CANCEL_TOOL, MERGE_TOOL, DISCARD_TOOL, VERIFY_TOOL, RECALL_TOOL] : [],
181
+ ...targets.length ? [WAIT_TOOL, CANCEL_TOOL, MERGE_TOOL, DISCARD_TOOL, RESOLVE_TOOL, VERIFY_TOOL, RECALL_TOOL] : [],
182
182
  ...targets.length || parentAgent ? [SEND_TOOL] : [],
183
183
  ...parentAgent ? [HANDOFF_TOOL] : [],
184
- ...supervised ? [LESSON_TOOL, SKILL_TOOL] : [],
184
+ ...supervised ? [LESSON_TOOL, LESSON_CURATE_TOOL, SKILL_TOOL] : [],
185
185
  ...!parentAgent && mapping.agent.name === mainOf(mapping) ? [ISSUE_TOOL, SCHEDULE_TOOL] : [],
186
186
  ASK_TOOL,
187
187
  PIN_TOOL,
@@ -8,7 +8,8 @@ import type { SessionUsage } from './events.js';
8
8
  /** The pause that stopped a turn; a matching resume may arrive before its interruption settles. */
9
9
  export type ParkPause = {
10
10
  scope: RuntimeKind | 'all';
11
- resumed?: boolean;
11
+ resumed?: boolean; /** The pause was alpd's, for a full disk (t-2831). */
12
+ disk?: boolean;
12
13
  };
13
14
  export type Parked = {
14
15
  reason: string;
@@ -70,6 +71,27 @@ export type Session = {
70
71
  usage?: SessionUsage;
71
72
  /** The context advisory was given since the context last emptied (ALPD §57). */
72
73
  contextLevel?: number;
74
+ /** How full its context last was, 0..1 (t-0e56). */
75
+ contextFill?: number;
76
+ /** The user asked to compact it; done at the next turn boundary (t-0e56). */
77
+ compactRequested?: boolean;
78
+ /** A compaction in progress (t-0e56): main writing its checkpoint, then the runtime compacting. */
79
+ compacting?: {
80
+ phase: 'checkpoint' | 'native' | 'fresh';
81
+ trigger: 'auto' | 'manual';
82
+ checkpoint?: string;
83
+ startedAt: number; /** Its checkpoint turn was started. */
84
+ turn?: boolean; /** The runtime took the native request. */
85
+ requested?: boolean;
86
+ };
87
+ /** Compacted since main's last turn began: usage reported meanwhile may still count the old context. */
88
+ compactCooling?: boolean;
89
+ /** When its last compaction failed: automatic ones wait COMPACT_RETRY_MS after it. */
90
+ compactFailedAt?: number;
91
+ /** The user's prompts held while it compacts, sent after (t-0e56). */
92
+ compactBuffer?: import('./contracts.js').PromptInput[];
93
+ /** The user's last message to it, seeded into a fresh conversation after a compaction (t-0e56). */
94
+ lastUserText?: string;
73
95
  /** An assignment's brief as its requester gave it, repeated after a compaction. */
74
96
  brief?: string;
75
97
  /** The skills it has used, each logged once (ALPD §59). */
package/dist/tools.d.ts CHANGED
@@ -227,6 +227,29 @@ export declare const DISCARD_TOOL: {
227
227
  additionalProperties: boolean;
228
228
  };
229
229
  };
230
+ export declare const RESOLVE_TOOL: {
231
+ type: string;
232
+ name: string;
233
+ description: string;
234
+ inputSchema: {
235
+ type: string;
236
+ properties: {
237
+ assignmentId: {
238
+ type: string;
239
+ };
240
+ outcome: {
241
+ type: string;
242
+ enum: readonly ["applied", "discarded", "acknowledged"];
243
+ };
244
+ note: {
245
+ type: string;
246
+ description: string;
247
+ };
248
+ };
249
+ required: string[];
250
+ additionalProperties: boolean;
251
+ };
252
+ };
230
253
  export declare const CANCEL_TOOL: {
231
254
  type: string;
232
255
  name: string;
@@ -289,7 +312,9 @@ export declare const PIN_TOOL: {
289
312
  type: string;
290
313
  items: {
291
314
  type: string;
315
+ maxLength: number;
292
316
  };
317
+ maxItems: number;
293
318
  description: string;
294
319
  };
295
320
  };
@@ -310,6 +335,7 @@ export declare const BOARD_TOOL: {
310
335
  type: string;
311
336
  enum: readonly ["claim", "decision", "finding"];
312
337
  };
338
+ maxItems: 3;
313
339
  };
314
340
  limit: {
315
341
  type: string;
@@ -381,6 +407,52 @@ export declare const LESSON_TOOL: {
381
407
  additionalProperties: boolean;
382
408
  };
383
409
  };
410
+ export declare const LESSON_CURATE_TOOL: {
411
+ type: string;
412
+ name: string;
413
+ description: string;
414
+ inputSchema: {
415
+ type: string;
416
+ properties: {
417
+ changes: {
418
+ type: string;
419
+ description: string;
420
+ items: {
421
+ type: string;
422
+ properties: {
423
+ scope: {
424
+ type: string;
425
+ enum: string[];
426
+ };
427
+ remove: {
428
+ type: string;
429
+ items: {
430
+ type: string;
431
+ };
432
+ description: string;
433
+ };
434
+ add: {
435
+ type: string;
436
+ description: string;
437
+ };
438
+ reason: {
439
+ type: string;
440
+ description: string;
441
+ };
442
+ };
443
+ required: string[];
444
+ additionalProperties: boolean;
445
+ };
446
+ };
447
+ requestId: {
448
+ type: string;
449
+ description: string;
450
+ };
451
+ };
452
+ required: string[];
453
+ additionalProperties: boolean;
454
+ };
455
+ };
384
456
  export declare const SKILL_TOOL: {
385
457
  type: string;
386
458
  name: string;
@@ -638,6 +710,15 @@ export declare function taskTool(actions: TaskAction[]): {
638
710
  type: string;
639
711
  description: string;
640
712
  } | undefined;
713
+ options?: {
714
+ type: string;
715
+ items: {
716
+ type: string;
717
+ maxLength: number;
718
+ };
719
+ maxItems: number;
720
+ description: string;
721
+ } | undefined;
641
722
  gate?: {
642
723
  type: string;
643
724
  description: string;
@@ -650,6 +731,7 @@ export declare function taskTool(actions: TaskAction[]): {
650
731
  type: string;
651
732
  additionalProperties: {
652
733
  type: string;
734
+ maxLength: number;
653
735
  };
654
736
  description: string;
655
737
  } | undefined;
package/dist/tools.js CHANGED
@@ -1,8 +1,10 @@
1
1
  // packages/runtime/src/tools.ts
2
2
  import { CLOSE_REASONS, GATE_KINDS, TASK_STATUSES, TASK_TYPES, TASKS_DIR } from "@anhlp/alp-core/tasks";
3
3
  import { READ_ONLY_AGENTS } from "./resolve.js";
4
- import { PIN_KINDS } from "./board.js";
4
+ import { PIN_KINDS, PIN_PATH_CHARS, PIN_PATHS } from "./board.js";
5
+ import { POUR_VARS } from "./input-limits.js";
5
6
  import { RECALL_KEEP_MS } from "./recall.js";
7
+ import { RESULT_OUTCOMES } from "./assignment-results.js";
6
8
  import { HANDOFF_OUTCOMES, VERDICT_RESULTS, CRITERION_RESULTS, SEVERITIES } from "./handoff.js";
7
9
  var handoffList = (description) => ({ type: "array", items: { type: "string" }, description });
8
10
  var HANDOFF_TOOL = {
@@ -125,6 +127,21 @@ var DISCARD_TOOL = {
125
127
  additionalProperties: false
126
128
  }
127
129
  };
130
+ var RESOLVE_TOOL = {
131
+ type: "function",
132
+ name: "alp_resolve",
133
+ description: "Record how you handled a finished writer's change in your checkout: applied (you kept or committed it), discarded (you reverted it) or acknowledged (you reviewed it; nothing to do). Until then ALP keeps its result and will not let that checkout be removed; then it archives the result.",
134
+ inputSchema: {
135
+ type: "object",
136
+ properties: {
137
+ assignmentId: { type: "string" },
138
+ outcome: { type: "string", enum: RESULT_OUTCOMES },
139
+ note: { type: "string", description: "What you did with it, for the archive and the run log." }
140
+ },
141
+ required: ["assignmentId", "outcome"],
142
+ additionalProperties: false
143
+ }
144
+ };
128
145
  var CANCEL_TOOL = {
129
146
  type: "function",
130
147
  name: "alp_cancel",
@@ -163,7 +180,7 @@ var PIN_TOOL = {
163
180
  properties: {
164
181
  kind: { type: "string", enum: PIN_KINDS },
165
182
  body: { type: "string", description: "For a claim, what you are changing; otherwise the decision or finding itself." },
166
- paths: { type: "array", items: { type: "string" }, description: "Project-relative files or directories. Required for a claim." }
183
+ paths: { type: "array", items: { type: "string", maxLength: PIN_PATH_CHARS }, maxItems: PIN_PATHS, description: `Project-relative files or directories, at most ${PIN_PATHS}. Required for a claim.` }
167
184
  },
168
185
  required: ["kind", "body"],
169
186
  additionalProperties: false
@@ -176,7 +193,7 @@ var BOARD_TOOL = {
176
193
  inputSchema: {
177
194
  type: "object",
178
195
  properties: {
179
- kinds: { type: "array", items: { type: "string", enum: PIN_KINDS } },
196
+ kinds: { type: "array", items: { type: "string", enum: PIN_KINDS }, maxItems: PIN_KINDS.length },
180
197
  limit: { type: "integer", description: "Most recent decisions and findings to return. Default 30." }
181
198
  },
182
199
  additionalProperties: false
@@ -222,6 +239,34 @@ var LESSON_TOOL = {
222
239
  additionalProperties: false
223
240
  }
224
241
  };
242
+ var LESSON_CURATE_TOOL = {
243
+ type: "function",
244
+ name: "alp_lesson_curate",
245
+ description: "Merge, shorten or remove recorded lessons. Each change removes the exact text of lessons from one scope and may add one rule in their place (a merge or a shortening); a change without add removes them. ALP shows every change to the user at once and applies them only when the user approves. Returns pending_approval with approvalId immediately; the result (applied, lessons not found, or the user's feedback) arrives once by mail. Never edit lessons files any other way.",
246
+ inputSchema: {
247
+ type: "object",
248
+ properties: {
249
+ changes: {
250
+ type: "array",
251
+ description: "At most 50 changes.",
252
+ items: {
253
+ type: "object",
254
+ properties: {
255
+ scope: { type: "string", enum: ["project", "user"] },
256
+ remove: { type: "array", items: { type: "string" }, description: "The exact text of each lesson to remove, with or without its date." },
257
+ add: { type: "string", description: "One rule, at most 600 characters, that replaces them." },
258
+ reason: { type: "string", description: "Why, in one line." }
259
+ },
260
+ required: ["scope", "remove"],
261
+ additionalProperties: false
262
+ }
263
+ },
264
+ requestId: { type: "string", description: "Optional session-scoped idempotency key (1-100 characters)." }
265
+ },
266
+ required: ["changes"],
267
+ additionalProperties: false
268
+ }
269
+ };
225
270
  var SKILL_TOOL = {
226
271
  type: "function",
227
272
  name: "alp_skill",
@@ -270,7 +315,7 @@ var TASK_FIELDS = {
270
315
  start: ["id"],
271
316
  close: ["id", "reason", "summary", "unverified"],
272
317
  reopen: ["id", "note"],
273
- gate: ["id", "kind", "note", "until", "ref"],
318
+ gate: ["id", "kind", "note", "until", "ref", "options"],
274
319
  clear: ["id", "gate", "note"],
275
320
  pour: ["formula", "vars", "parent"],
276
321
  formulas: [],
@@ -322,9 +367,10 @@ function taskTool(actions) {
322
367
  kind: { type: "string", enum: GATE_KINDS, description: "For gate: human (the user approves; give the question as note), timer (until), gh:pr (until a pull request merges; ref), gh:run (until a workflow run succeeds; ref)." },
323
368
  until: { type: "string", description: "For a timer gate: an ISO time, or +30m, +2h, +3d." },
324
369
  ref: { type: "string", description: "For a gh:pr or gh:run gate: 123, or owner/repo#123." },
370
+ options: { type: "array", items: { type: "string", maxLength: 200 }, maxItems: 10, description: "For a human gate: up to 10 answers the user picks from, each at most 200 characters; picking any approves it, and you get the choice by mail. Default approve or reject." },
325
371
  gate: { type: "string", description: "For clear: the gate id, such as g1. You cannot clear a human gate; the user does." },
326
372
  formula: { type: "string", description: "For pour: the formula name, from action formulas." },
327
- vars: { type: "object", additionalProperties: { type: "string" }, description: "For pour: values of the formula variables." },
373
+ vars: { type: "object", additionalProperties: { type: "string", maxLength: POUR_VARS.string }, description: `For pour: values of the formula variables (at most ${POUR_VARS.items}), each at most ${POUR_VARS.string} characters.` },
328
374
  summary: { type: "string", description: "For close: the outcome and its evidence." },
329
375
  unverified: { type: "string", description: "For close as done when the task's last verification failed: why it is done anyway. Recorded on the task." },
330
376
  note: { type: "string", description: "For update and reopen: why." }
@@ -373,10 +419,12 @@ export {
373
419
  DISCARD_TOOL,
374
420
  HANDOFF_TOOL,
375
421
  ISSUE_TOOL,
422
+ LESSON_CURATE_TOOL,
376
423
  LESSON_TOOL,
377
424
  MERGE_TOOL,
378
425
  PIN_TOOL,
379
426
  RECALL_TOOL,
427
+ RESOLVE_TOOL,
380
428
  SCHEDULE_TOOL,
381
429
  SEND_TOOL,
382
430
  SKILL_TOOL,
package/dist/transport.js CHANGED
@@ -2,6 +2,7 @@
2
2
  import { optionalRead, codexUsage } from "./runtime-context.js";
3
3
  import { spawn, execFile } from "node:child_process";
4
4
  import { createInterface } from "node:readline";
5
+ import { scriptCommand } from "@anhlp/alp-core/packaged";
5
6
  function unanswered(error) {
6
7
  return Object.assign(new Error(error.message), { outcomeUnknown: true });
7
8
  }
@@ -17,7 +18,8 @@ var CodexTransport = class {
17
18
  constructor(command, cwd, env, args = ["app-server", "--listen", "stdio://"]) {
18
19
  if (/\.(cmd|bat|ps1)$/i.test(command)) throw new Error("Codex executable must be a native binary, not a shell launcher");
19
20
  const script = process.platform === "win32" && /\.[cm]?js$/i.test(command);
20
- this.child = spawn(script ? process.execPath : command, script ? [command, ...args] : args, { cwd, env, windowsHide: true, stdio: ["pipe", "pipe", "pipe"] });
21
+ const run = script ? scriptCommand(command, args) : { command, args, env: void 0 };
22
+ this.child = spawn(run.command, run.args, { cwd, env: run.env ? { ...env, ...run.env } : env, windowsHide: true, stdio: ["pipe", "pipe", "pipe"] });
21
23
  this.exit = new Promise((resolve) => {
22
24
  this.child.once("close", resolve);
23
25
  this.child.once("error", () => resolve());