@anhlp/alp-runtime 0.0.1-beta.7 → 0.0.1-beta.9

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 (52) hide show
  1. package/dist/acp-transport.js +2 -0
  2. package/dist/antigravity-transport.d.ts +10 -2
  3. package/dist/antigravity-transport.js +26 -4
  4. package/dist/assignment-results.d.ts +5 -2
  5. package/dist/assignment-results.js +27 -15
  6. package/dist/catalog.js +2 -1
  7. package/dist/claude-transport.d.ts +33 -2
  8. package/dist/claude-transport.js +48 -9
  9. package/dist/contracts.d.ts +12 -1
  10. package/dist/index.d.ts +4 -3
  11. package/dist/index.js +9 -2
  12. package/dist/language.d.ts +2 -0
  13. package/dist/language.js +6 -0
  14. package/dist/live.d.ts +2 -2
  15. package/dist/live.js +7 -2
  16. package/dist/model-catalog.d.ts +87 -1
  17. package/dist/model-catalog.js +151 -6
  18. package/dist/model-probes.d.ts +1 -1
  19. package/dist/model-probes.js +2 -2
  20. package/dist/recall.d.ts +2 -2
  21. package/dist/recall.js +4 -3
  22. package/dist/resolve.js +4 -4
  23. package/dist/runtime.js +243 -33
  24. package/dist/session-config.d.ts +75 -6
  25. package/dist/session-config.js +9 -5
  26. package/dist/session-state.d.ts +2 -0
  27. package/dist/skill-resources.d.ts +30 -0
  28. package/dist/skill-resources.js +55 -0
  29. package/dist/tools.d.ts +27 -1
  30. package/dist/tools.js +20 -1
  31. package/dist/write-error.d.ts +2 -0
  32. package/dist/write-error.js +10 -0
  33. package/package.json +4 -4
  34. package/src/acp-transport.ts +3 -0
  35. package/src/antigravity-transport.ts +39 -8
  36. package/src/assignment-results.ts +23 -15
  37. package/src/catalog.ts +3 -1
  38. package/src/claude-transport.ts +87 -10
  39. package/src/contracts.ts +12 -0
  40. package/src/index.ts +4 -3
  41. package/src/language.ts +10 -0
  42. package/src/live.ts +7 -3
  43. package/src/model-catalog.ts +156 -6
  44. package/src/model-probes.ts +2 -2
  45. package/src/recall.ts +4 -3
  46. package/src/resolve.ts +9 -5
  47. package/src/runtime.ts +255 -29
  48. package/src/session-config.ts +13 -5
  49. package/src/session-state.ts +2 -0
  50. package/src/skill-resources.ts +73 -0
  51. package/src/tools.ts +22 -1
  52. package/src/write-error.ts +4 -0
@@ -448,6 +448,29 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
448
448
  required: string[];
449
449
  additionalProperties: boolean;
450
450
  };
451
+ } | {
452
+ type: string;
453
+ name: string;
454
+ description: string;
455
+ inputSchema: {
456
+ type: string;
457
+ properties: {
458
+ name: {
459
+ type: string;
460
+ description: string;
461
+ };
462
+ reason: {
463
+ type: string;
464
+ description: string;
465
+ };
466
+ requestId: {
467
+ type: string;
468
+ description: string;
469
+ };
470
+ };
471
+ required: string[];
472
+ additionalProperties: boolean;
473
+ };
451
474
  } | {
452
475
  type: string;
453
476
  name: string;
@@ -663,7 +686,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
663
686
  } | undefined;
664
687
  action: {
665
688
  type: string;
666
- enum: ("close" | "list" | "create" | "link" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
689
+ enum: ("link" | "close" | "list" | "create" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
667
690
  };
668
691
  id: {
669
692
  type: string;
@@ -772,7 +795,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
772
795
  additionalProperties: boolean;
773
796
  };
774
797
  })[];
775
- floor?: "workspace-write" | "read-only" | undefined;
798
+ floor?: "read-only" | "workspace-write" | undefined;
776
799
  permissions?: PermissionProfile | null | undefined;
777
800
  skills?: Array<{
778
801
  name: string;
@@ -1191,6 +1214,29 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1191
1214
  required: string[];
1192
1215
  additionalProperties: boolean;
1193
1216
  };
1217
+ } | {
1218
+ type: string;
1219
+ name: string;
1220
+ description: string;
1221
+ inputSchema: {
1222
+ type: string;
1223
+ properties: {
1224
+ name: {
1225
+ type: string;
1226
+ description: string;
1227
+ };
1228
+ reason: {
1229
+ type: string;
1230
+ description: string;
1231
+ };
1232
+ requestId: {
1233
+ type: string;
1234
+ description: string;
1235
+ };
1236
+ };
1237
+ required: string[];
1238
+ additionalProperties: boolean;
1239
+ };
1194
1240
  } | {
1195
1241
  type: string;
1196
1242
  name: string;
@@ -1406,7 +1452,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1406
1452
  } | undefined;
1407
1453
  action: {
1408
1454
  type: string;
1409
- enum: ("close" | "list" | "create" | "link" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
1455
+ enum: ("link" | "close" | "list" | "create" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
1410
1456
  };
1411
1457
  id: {
1412
1458
  type: string;
@@ -1515,7 +1561,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1515
1561
  additionalProperties: boolean;
1516
1562
  };
1517
1563
  })[];
1518
- floor?: "workspace-write" | "read-only" | undefined;
1564
+ floor?: "read-only" | "workspace-write" | undefined;
1519
1565
  permissions?: PermissionProfile | null | undefined;
1520
1566
  skills?: Array<{
1521
1567
  name: string;
@@ -1936,6 +1982,29 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
1936
1982
  required: string[];
1937
1983
  additionalProperties: boolean;
1938
1984
  };
1985
+ } | {
1986
+ type: string;
1987
+ name: string;
1988
+ description: string;
1989
+ inputSchema: {
1990
+ type: string;
1991
+ properties: {
1992
+ name: {
1993
+ type: string;
1994
+ description: string;
1995
+ };
1996
+ reason: {
1997
+ type: string;
1998
+ description: string;
1999
+ };
2000
+ requestId: {
2001
+ type: string;
2002
+ description: string;
2003
+ };
2004
+ };
2005
+ required: string[];
2006
+ additionalProperties: boolean;
2007
+ };
1939
2008
  } | {
1940
2009
  type: string;
1941
2010
  name: string;
@@ -2151,7 +2220,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
2151
2220
  } | undefined;
2152
2221
  action: {
2153
2222
  type: string;
2154
- enum: ("close" | "list" | "create" | "link" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
2223
+ enum: ("link" | "close" | "list" | "create" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
2155
2224
  };
2156
2225
  id: {
2157
2226
  type: string;
@@ -2260,7 +2329,7 @@ export declare function nativeSessionConfig(runtimeKind: RuntimeKind, mapping: R
2260
2329
  additionalProperties: boolean;
2261
2330
  };
2262
2331
  })[];
2263
- floor?: "workspace-write" | "read-only" | undefined;
2332
+ floor?: "read-only" | "workspace-write" | undefined;
2264
2333
  permissions?: PermissionProfile | null | undefined;
2265
2334
  skills?: Array<{
2266
2335
  name: string;
@@ -6,7 +6,7 @@ import { models, thinkingOptionsFor } from "./catalog.js";
6
6
  import { claudeSandboxAvailable, SKILL_PLUGIN } from "./claude-transport.js";
7
7
  import { languageInstruction } from "./language.js";
8
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
+ 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, SKILL_RETIRE_TOOL, ISSUE_TOOL, SCHEDULE_TOOL, mainOf, taskActions, taskTool } from "./tools.js";
10
10
  import { COMPACT_SHARE } from "./runtime-context.js";
11
11
  var nativeMode = (mapping) => mapping.copy ? "workspace-write" : mapping.mode;
12
12
  function claudeFloor(mapping) {
@@ -53,7 +53,7 @@ function modelProfileNote(mapping, targets) {
53
53
  return `${id}${about ? `: ${about}` : ""}${efforts.length ? ` Efforts ${efforts.join("|")}` : ""}${effort ? `, usually ${effort}` : ""}`;
54
54
  };
55
55
  const options = (profile) => anyModel(profile) ? `any ${profile.provider} model (the runtime catalog snapshot lists what ${profile.provider} offers when you run on it), such as ${models.filter((model) => model.id.startsWith(`${profile.provider}:`)).map((model) => option(model.id)).join("; ")}` : option(profileModel(profile), profile.effort);
56
- return ["Model profiles of your targets. An agent with one named profile runs on it unless you pass another model. For an agent with several, or with any model of a provider, you choose both for each assignment: weigh the task's difficulty, ambiguity, risk and the autonomy it needs against speed and cost, pass the model with alp_delegate model and the effort with thinking, and say why in modelReason. There is no default, and a model outside its profiles is refused. " + choices.map(([agent, profiles]) => profiles.length === 1 && !anyModel(profiles[0]) ? `${agent}: ${one(profiles[0])}` : `${agent}, choose a model and effort: ${profiles.map(options).join("; ")}`).join(". ") + "."];
56
+ return ["Model profiles of your targets are the models you may pass for them; a model outside them is refused. An agent with one named profile runs on exactly that model: omit model, or pass that one. For an agent with several, or with any model of a provider, you choose both for each assignment: weigh the task's difficulty, ambiguity, risk and the autonomy it needs against speed and cost, pass the model with alp_delegate model and the effort with thinking, and say why in modelReason; there is no default. An effort ALP cannot check for a model is passed on as given, and the answer says so. " + choices.map(([agent, profiles]) => profiles.length === 1 && !anyModel(profiles[0]) ? `${agent}: ${one(profiles[0])}` : `${agent}, choose a model and effort: ${profiles.map(options).join("; ")}`).join(". ") + "."];
57
57
  }
58
58
  function profileEfforts(id) {
59
59
  const [runtime, native] = [id.slice(0, id.indexOf(":")), id.slice(id.indexOf(":") + 1)];
@@ -116,7 +116,11 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
116
116
  ...modelProfileNote(mapping, targets),
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
- `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.`,
119
+ // Only an agent that can delegate to oracle is told how to; two opinions need two oracle models.
120
+ [
121
+ ...targets.includes("oracle") ? [`Oracle runs on ${mapping.oracleModels.join(" or ")}; pass one as model (effort follows the team's oracle settings, otherwise high).` + (mapping.oracleModels.length > 1 ? " 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."] : [],
122
+ "Usage context is advisory, may be unavailable or stale; never infer quota from token counts. Respect known exhausted limits and report them."
123
+ ].join(" "),
120
124
  ...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
125
  ...!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
126
  `ALP runtime identity: ${mapping.agent.name}. ${delegationInstruction}`,
@@ -158,7 +162,7 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
158
162
  type: "string",
159
163
  description: "Complete brief: objective, scope, constraints, verification, handoff."
160
164
  },
161
- model: { type: "string", description: `Explicit runtime-prefixed model ID from the available catalog. Oracle: ${mapping.oracleModels.join(" or ")}.` },
165
+ model: { type: "string", description: `Explicit runtime-prefixed model ID from the available catalog.${targets.includes("oracle") ? ` Oracle: ${mapping.oracleModels.join(" or ")}.` : ""}` },
162
166
  thinking: { type: "string", description: "Effort supported by the selected model." },
163
167
  modelReason: { type: "string", description: "Why this model suits the task." },
164
168
  mode: {
@@ -181,7 +185,7 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
181
185
  ...targets.length ? [WAIT_TOOL, CANCEL_TOOL, MERGE_TOOL, DISCARD_TOOL, RESOLVE_TOOL, VERIFY_TOOL, RECALL_TOOL] : [],
182
186
  ...targets.length || parentAgent ? [SEND_TOOL] : [],
183
187
  ...parentAgent ? [HANDOFF_TOOL] : [],
184
- ...supervised ? [LESSON_TOOL, LESSON_CURATE_TOOL, SKILL_TOOL] : [],
188
+ ...supervised ? [LESSON_TOOL, LESSON_CURATE_TOOL, SKILL_TOOL, SKILL_RETIRE_TOOL] : [],
185
189
  ...!parentAgent && mapping.agent.name === mainOf(mapping) ? [ISSUE_TOOL, SCHEDULE_TOOL] : [],
186
190
  ASK_TOOL,
187
191
  PIN_TOOL,
@@ -96,6 +96,8 @@ export type Session = {
96
96
  brief?: string;
97
97
  /** The skills it has used, each logged once (ALPD §59). */
98
98
  skillsUsed?: Set<string>;
99
+ /** Skill files beyond SKILL.md the session has read or run, as `<read|run>:<skill>/<relative path>` (skill-resource events). */
100
+ skillResourcesUsed?: Set<string>;
99
101
  /** Why the running turn is being stopped, so its end parks the assignment instead of ending it. */
100
102
  parkReason?: string;
101
103
  parkPause?: ParkPause;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Progressive-disclosure evidence (skill system v2): which of an agent's skill resources (files under
3
+ * references/, scripts/, assets/, templates/, data/) a tool call reads or runs. Only what the agent
4
+ * asked for counts, never what a tool printed, and only reading or running: writing a skill file,
5
+ * listing a directory or naming a path in some other command is not "opening it on demand".
6
+ *
7
+ * Every runtime reports a call as a command line (claude-transport, acp-transport, Codex):
8
+ * - a shell command (Bash, Codex, an ACP `execute`), possibly wrapped in `sh -c '…'`;
9
+ * - Claude's other tools as `Name {json input}`;
10
+ * - an ACP agent's other tools as `kind: title`.
11
+ */
12
+ export type ResourceAction = 'read' | 'run';
13
+ export type ResourceUse = {
14
+ skill: string;
15
+ resource: string;
16
+ action: ResourceAction;
17
+ };
18
+ /** Each path a command reads or runs, with what it does to it. */
19
+ export declare function pathActions(command: string): Array<{
20
+ file: string;
21
+ action: ResourceAction;
22
+ }>;
23
+ /**
24
+ * The resources of `skills` a command reads or runs: by the skill's own directory, or by Claude's
25
+ * plugin link to it (`<plugin>/skills/<name>/…`). A path in another skill directory is not this agent's.
26
+ */
27
+ export declare function resourceUses(command: string, skills: Array<{
28
+ name: string;
29
+ path: string;
30
+ }>): ResourceUse[];
@@ -0,0 +1,55 @@
1
+ // packages/runtime/src/skill-resources.ts
2
+ import path from "node:path";
3
+ import { simpleCommands, unwrapShell } from "@anhlp/alp-core/permissions";
4
+ var RESOURCE = "(?:references|scripts|assets|templates|data)/[\\w.@+-]+(?:/[\\w.@+-]+)*";
5
+ var INTERPRETERS = /* @__PURE__ */ new Set(["node", "nodejs", "deno", "bun", "tsx", "ts-node", "python", "python3", "py", "bash", "sh", "zsh", "dash", "ruby", "perl", "pwsh", "powershell"]);
6
+ var READERS = /* @__PURE__ */ new Set(["cat", "bat", "less", "more", "head", "tail", "sed", "awk", "grep", "rg", "egrep", "nl", "wc", "cut", "sort", "jq", "diff", "view", "type", "get-content"]);
7
+ var PREFIXES = /* @__PURE__ */ new Set(["sudo", "env", "exec", "time", "command", "nice", "nohup"]);
8
+ var CLAUDE_READERS = { Read: ["file_path", "path"], NotebookRead: ["notebook_path"], Grep: ["path"] };
9
+ var slash = (value) => value.replace(/\\\\/g, "/").replace(/\\/g, "/");
10
+ var words = (command) => [...command.matchAll(/"((?:[^"\\]|\\.)*)"|'([^']*)'|(\S+)/g)].map((match) => match[1] ?? match[2] ?? match[3]);
11
+ function pathActions(command) {
12
+ const claude = /^([A-Z][A-Za-z]+) (\{[\s\S]*\})$/.exec(command);
13
+ if (claude) {
14
+ const fields = CLAUDE_READERS[claude[1]];
15
+ if (!fields) return [];
16
+ let input = {};
17
+ try {
18
+ input = JSON.parse(claude[2]);
19
+ } catch {
20
+ return [];
21
+ }
22
+ return fields.map((field) => input[field]).filter((value) => typeof value === "string").map((file) => ({ file, action: "read" }));
23
+ }
24
+ const acp = /^(read|search|edit|delete|move|think|fetch|other): ([\s\S]*)$/.exec(command);
25
+ if (acp) return acp[1] === "read" ? words(acp[2]).map((file) => ({ file, action: "read" })) : [];
26
+ const found = [];
27
+ for (const simple of simpleCommands(unwrapShell(command)) ?? [command]) {
28
+ const tokens = words(simple).filter((token) => token !== void 0);
29
+ while (tokens.length && (/^\w+=/.test(tokens[0]) || PREFIXES.has(tokens[0]))) tokens.shift();
30
+ if (!tokens.length) continue;
31
+ const program = path.posix.basename(slash(tokens[0])).toLowerCase().replace(/\.exe$/, "");
32
+ const args = tokens.slice(1).filter((token) => !token.startsWith("-"));
33
+ if (new RegExp(`/${RESOURCE}$`).test(slash(tokens[0]))) found.push({ file: tokens[0], action: "run" });
34
+ else if (INTERPRETERS.has(program)) args.forEach((file, index) => found.push({ file, action: index === 0 ? "run" : "read" }));
35
+ else if (READERS.has(program)) args.forEach((file) => found.push({ file, action: "read" }));
36
+ }
37
+ return found;
38
+ }
39
+ function resourceUses(command, skills) {
40
+ if (!command || !slash(command).includes("/skills/")) return [];
41
+ const escape = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
42
+ const uses = [];
43
+ for (const { file, action } of pathActions(command)) {
44
+ const normal = slash(file);
45
+ for (const skill of skills) {
46
+ const match = new RegExp(`(?:^|/)(?:${escape(slash(path.dirname(skill.path)).replace(/^\//, ""))}|skills/${escape(skill.name)})/(${RESOURCE})$`).exec(normal.replace(/^\//, ""));
47
+ if (match) uses.push({ skill: skill.name, resource: match[1], action });
48
+ }
49
+ }
50
+ return uses;
51
+ }
52
+ export {
53
+ pathActions,
54
+ resourceUses
55
+ };
package/dist/tools.d.ts CHANGED
@@ -499,6 +499,30 @@ export declare const SKILL_TOOL: {
499
499
  additionalProperties: boolean;
500
500
  };
501
501
  };
502
+ export declare const SKILL_RETIRE_TOOL: {
503
+ type: string;
504
+ name: string;
505
+ description: string;
506
+ inputSchema: {
507
+ type: string;
508
+ properties: {
509
+ name: {
510
+ type: string;
511
+ description: string;
512
+ };
513
+ reason: {
514
+ type: string;
515
+ description: string;
516
+ };
517
+ requestId: {
518
+ type: string;
519
+ description: string;
520
+ };
521
+ };
522
+ required: string[];
523
+ additionalProperties: boolean;
524
+ };
525
+ };
502
526
  export declare const ISSUE_TOOL: {
503
527
  type: string;
504
528
  name: string;
@@ -554,6 +578,8 @@ export declare const TASK_FIELDS: Record<TaskAction, string[]>;
554
578
  export declare const mainOf: (mapping: Pick<ResolvedSession, "team">) => string;
555
579
  /** A member's role in the session's team; without a team, the built-in agents' roles by name. */
556
580
  export declare const roleOf: (mapping: Pick<ResolvedSession, "team">, agent: string) => string | undefined;
581
+ /** Whether an agent is read-only in this session's team: a built-in advisor, or a member serving as advisor or reviewer. */
582
+ export declare const readOnlyMember: (mapping: Pick<ResolvedSession, "team">, agent: string) => boolean;
557
583
  /** What each role may do with the task graph: main changes it, the others read it. */
558
584
  export declare function taskActions(mapping: Pick<ResolvedSession, 'agent' | 'team'>, parentAgent?: string, role?: 'supervisor'): TaskAction[];
559
585
  export declare const taskLinks: (description: string) => {
@@ -749,7 +775,7 @@ export declare function taskTool(actions: TaskAction[]): {
749
775
  } | undefined;
750
776
  action: {
751
777
  type: string;
752
- enum: ("close" | "list" | "create" | "link" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
778
+ enum: ("link" | "close" | "list" | "create" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
753
779
  };
754
780
  id: {
755
781
  type: string;
package/dist/tools.js CHANGED
@@ -1,6 +1,7 @@
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 { READ_ONLY_ROLES } from "@anhlp/alp-core/permissions";
4
5
  import { PIN_KINDS, PIN_PATH_CHARS, PIN_PATHS } from "./board.js";
5
6
  import { POUR_VARS } from "./input-limits.js";
6
7
  import { RECALL_KEEP_MS } from "./recall.js";
@@ -286,6 +287,21 @@ var SKILL_TOOL = {
286
287
  additionalProperties: false
287
288
  }
288
289
  };
290
+ var SKILL_RETIRE_TOOL = {
291
+ type: "function",
292
+ name: "alp_skill_retire",
293
+ description: "Propose to retire a skill of the user's skill library that is no longer needed. ALP shows the skill and the roles that lose it to the user, and only when the user approves moves it out of the library into retired-skills (kept, so it can be restored) and removes it from role-skills.json. Nothing changes without that approval. Returns pending_approval with approvalId immediately; the result arrives once by mail. Never delete skill files any other way.",
294
+ inputSchema: {
295
+ type: "object",
296
+ properties: {
297
+ name: { type: "string", description: "The skill directory name in the library." },
298
+ reason: { type: "string", description: "Why it is no longer needed, in one line (at most 300 characters)." },
299
+ requestId: { type: "string", description: "Optional session-scoped idempotency key (1-100 characters)." }
300
+ },
301
+ required: ["name", "reason"],
302
+ additionalProperties: false
303
+ }
304
+ };
289
305
  var ISSUE_TOOL = {
290
306
  type: "function",
291
307
  name: "alp_issue",
@@ -325,10 +341,11 @@ var TASK_FIELDS = {
325
341
  };
326
342
  var mainOf = (mapping) => mapping.team?.main ?? "main";
327
343
  var roleOf = (mapping, agent) => mapping.team ? mapping.team.members[agent]?.role : { lead: "lead", peer: "peer", oracle: "advisor", reviewer: "reviewer" }[agent];
344
+ var readOnlyMember = (mapping, agent) => READ_ONLY_AGENTS.includes(agent) || READ_ONLY_ROLES.includes(roleOf(mapping, agent) ?? "");
328
345
  function taskActions(mapping, parentAgent, role) {
329
346
  if (role === "supervisor") return ["show", "list"];
330
347
  if (!parentAgent && mapping.agent.name === mainOf(mapping)) return [...TASK_ACTIONS];
331
- return READ_ONLY_AGENTS.includes(mapping.agent.name) ? ["show"] : ["show", "ready"];
348
+ return readOnlyMember(mapping, mapping.agent.name) ? ["show"] : ["show", "ready"];
332
349
  }
333
350
  var taskLinks = (description) => ({
334
351
  type: "object",
@@ -427,6 +444,7 @@ export {
427
444
  RESOLVE_TOOL,
428
445
  SCHEDULE_TOOL,
429
446
  SEND_TOOL,
447
+ SKILL_RETIRE_TOOL,
430
448
  SKILL_TOOL,
431
449
  TASK_ACTIONS,
432
450
  TASK_FIELDS,
@@ -436,6 +454,7 @@ export {
436
454
  WAIT_TOOL,
437
455
  handoffList,
438
456
  mainOf,
457
+ readOnlyMember,
439
458
  roleOf,
440
459
  taskActions,
441
460
  taskBrief,
@@ -0,0 +1,2 @@
1
+ /** Tells `onError` of a failed write (t-e80a); what it throws must not change how the write failed. */
2
+ export declare function tell(onError: (error: unknown) => void, error: unknown): void;
@@ -0,0 +1,10 @@
1
+ // packages/runtime/src/write-error.ts
2
+ function tell(onError, error) {
3
+ try {
4
+ onError(error);
5
+ } catch {
6
+ }
7
+ }
8
+ export {
9
+ tell
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anhlp/alp-runtime",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1-beta.9",
4
4
  "type": "module",
5
5
  "description": "ALP runtime module",
6
6
  "files": [
@@ -230,13 +230,13 @@
230
230
  "node": ">=22.12"
231
231
  },
232
232
  "dependencies": {
233
- "@anhlp/alp-core": "0.0.1-beta.7",
234
- "@anhlp/alp-protocol": "0.0.1-beta.7",
233
+ "@anhlp/alp-core": "0.0.1-beta.9",
234
+ "@anhlp/alp-protocol": "0.0.1-beta.9",
235
235
  "@anthropic-ai/claude-agent-sdk": "^0.3.292",
236
236
  "@modelcontextprotocol/sdk": "^1.32.1",
237
237
  "@agentclientprotocol/sdk": "1.7.0",
238
238
  "smol-toml": "1.9.0",
239
- "zod": "4.4.3"
239
+ "zod": "4.6.7"
240
240
  },
241
241
  "scripts": {
242
242
  "build": "node ../../scripts/build-workspace.mjs runtime",
@@ -10,6 +10,7 @@ import { commandDecision, unwrapShell, type PermissionProfile } from '@anhlp/alp
10
10
  import { launchCommand } from '@anhlp/alp-core/providers';
11
11
  import { bridgeCommand } from '@anhlp/alp-core/bridges';
12
12
  import { acpText, acpToolDetail, type AcpCall } from './tool-detail.js';
13
+ import { feedAcpSession } from './model-catalog.js';
13
14
 
14
15
  /**
15
16
  * ACP agents (ALPD §46): a generic transport for any agent that speaks the Agent Client
@@ -197,6 +198,8 @@ export class AcpTransport {
197
198
  } else {
198
199
  const result = await this.call('session/new', { cwd: params.cwd, mcpServers }, 120_000);
199
200
  this.sessionId = result.sessionId;
201
+ // The first real session tells the catalog which models this provider offers (t-d0b0).
202
+ feedAcpSession(this.provider.id, result);
200
203
  await this.chooseModel(result.models, result.configOptions);
201
204
  }
202
205
  return { thread: { id: this.sessionId, turns: [] }, cwd: params.cwd, model: params.model, reasoningEffort: params.thinking };
@@ -22,8 +22,6 @@ export type AntigravityProvider = {
22
22
  models?: Array<{ id: string; label?: string; description?: string }>;
23
23
  additionalModels?: Array<{ id: string; label?: string; description?: string }>;
24
24
  enabled?: boolean;
25
- /** Explicit opt-in: read-only is a prompt constraint, never a native sandbox. */
26
- readOnlyMode?: 'instructions' | 'reject';
27
25
  };
28
26
 
29
27
  type Listener = (method: string, params: any) => void;
@@ -37,8 +35,25 @@ const MODES = ['read-only', 'workspace-write', 'full-access'];
37
35
  * redirection, chaining and substitution itself (checked with agy 1.4.10), so each
38
36
  * entry must have no flag that writes: git is left out (`git log --output`, and
39
37
  * `git status` refreshes the index), as are rg (`--pre`) and find (`-delete`).
38
+ * A prefix rule cannot check a path or a flag, so no command that reads file contents
39
+ * is allowed: cat, head, grep and wc read files outside the workspace, and tail -f or a
40
+ * read of a FIFO hangs the turn. ls is left out too: a prefix rule cannot keep its path
41
+ * argument inside the workspace (`ls /`, `ls ~/.ssh`). agy's own file reading, listing and
42
+ * search tools remain.
40
43
  */
41
- const READ_ONLY_COMMANDS = ['pwd', 'ls', 'cat', 'head', 'tail', 'wc', 'grep'];
44
+ const READ_ONLY_COMMANDS = ['pwd'];
45
+ /** Shell syntax that makes a command line more than one allowed command. */
46
+ const SHELL_SYNTAX = /[;&|<>`$(){}\\\n\r]/;
47
+ /**
48
+ * Whether read-only allows a terminal command line, by ALP's own reading of the allowlist:
49
+ * one allowed command with no shell syntax. Unknown input is refused.
50
+ */
51
+ export function antigravityReadOnlyCommandAllowed(commandLine: unknown): boolean {
52
+ if (typeof commandLine !== 'string' || SHELL_SYNTAX.test(commandLine)) return false;
53
+ const [command] = commandLine.trim().split(/\s+/);
54
+ return READ_ONLY_COMMANDS.includes(command);
55
+ }
56
+ const COMMAND_TOOLS = new Set(['run_command']);
42
57
  /** agy's file-editing tools, which read-only always denies. */
43
58
  const EDIT_TOOLS = new Set(['write_file', 'write_to_file', 'replace_file_content', 'multi_replace_file_content', 'sed_file', 'notebook_edit']);
44
59
  const modeOf = (sandbox: unknown) => sandbox === 'danger-full-access' ? 'full-access' : String(sandbox);
@@ -69,10 +84,16 @@ export function antigravityModeArgs(sandbox: unknown, cwd: string): string[] {
69
84
  return [...(mode === 'workspace-write' ? ['--mode', 'accept-edits'] : []), '--sandbox', '--settings', JSON.stringify(settings)];
70
85
  }
71
86
 
87
+ /** Efforts `agy --effort` takes (agy --help: low|medium|high|xhigh|max); others leave agy's default. */
88
+ export const AGY_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
89
+ export function antigravityEffortArgs(thinking: unknown): string[] {
90
+ return typeof thinking === 'string' && AGY_EFFORTS.includes(thinking) ? ['--effort', thinking] : [];
91
+ }
92
+
72
93
  /** What each mode lets an Antigravity agent do, for its instructions. */
73
94
  export function antigravityModeText(sandbox: unknown): string {
74
95
  const mode = modeOf(sandbox);
75
- if (mode === 'read-only') return 'agy enforces read-only: its own file reading and search tools work, and ALP\'s tools; it allows only the terminal commands pwd, ls, cat, head, tail, wc and grep, with no redirection or chaining, and denies every file edit and other command. A denied tool ends your turn, so do not attempt one: report work that needs changes to your requester.';
96
+ if (mode === 'read-only') return 'agy enforces read-only: its own file reading and search tools work, and ALP\'s tools; it allows only the terminal command pwd, with no redirection or chaining (read files with its own tools), and denies every file edit and other command. A denied tool ends your turn, so do not attempt one: report work that needs changes to your requester.';
76
97
  if (mode === 'workspace-write') return 'agy accepts file edits and runs terminal commands in its sandbox, which writes only inside your workspace; anything outside the workspace or the sandbox is denied, and a denied tool ends your turn. Report work that needs more to your requester.';
77
98
  return 'Antigravity runs with full access: every tool runs without asking.';
78
99
  }
@@ -250,6 +271,7 @@ export class AntigravityTransport {
250
271
  if (params.model) {
251
272
  args.push('--model', params.model);
252
273
  }
274
+ args.push(...antigravityEffortArgs(params.thinking));
253
275
 
254
276
  if (params.threadId) {
255
277
  args.push('--conversation', params.threadId);
@@ -418,10 +440,11 @@ export class AntigravityTransport {
418
440
  },
419
441
  });
420
442
  } else if (step.state === 'DONE' || step.state === 'ERROR') {
421
- // agy 1.4.10 sometimes marks a write_file it denied DONE, with no error and no file written:
422
- // read-only denies every edit, so never report one as done.
423
- if (step.state === 'DONE' && modeOf(this.config?.sandbox) === 'read-only' && (EDIT_TOOLS.has(toolName) || EDIT_TOOLS.has(step.tool_info?.name))) {
424
- step = { ...step, state: 'ERROR', tool_info: { ...step.tool_info, output: undefined, error: { message: `Antigravity denied ${toolName} in read-only mode` } } };
443
+ // agy 1.4.10 sometimes marks a tool step it denied DONE, with no error and nothing run. ALP's own
444
+ // record is authoritative: read-only denies every edit and every command outside its allowlist,
445
+ // so never report one as done, whatever agy says.
446
+ if (step.state === 'DONE' && modeOf(this.config?.sandbox) === 'read-only' && this.readOnlyRefuses(toolName, step.tool_info)) {
447
+ step = { ...step, state: 'ERROR', tool_info: { ...step.tool_info, output: undefined, error: { message: `Antigravity denied ${typed.tool} in read-only mode` } } };
425
448
  }
426
449
  const output = typeof step.tool_info?.output === 'string'
427
450
  ? step.tool_info.output
@@ -444,6 +467,14 @@ export class AntigravityTransport {
444
467
  }
445
468
  }
446
469
 
470
+ /** Whether read-only refuses this tool step: an edit, or a terminal command outside the allowlist. */
471
+ private readOnlyRefuses(toolName: string, info: any): boolean {
472
+ const name = typeof info?.name === 'string' && info.name ? info.name : toolName;
473
+ if (EDIT_TOOLS.has(toolName) || EDIT_TOOLS.has(name)) return true;
474
+ if (COMMAND_TOOLS.has(toolName) || COMMAND_TOOLS.has(name)) return !antigravityReadOnlyCommandAllowed(info?.parameters?.CommandLine);
475
+ return false;
476
+ }
477
+
447
478
  private handleResult(result: any): void {
448
479
  if (!this.activeTurn) return;
449
480
  const turnId = this.activeTurn;
@@ -1,6 +1,7 @@
1
1
  import { readFile, readdir, mkdir, writeFile, open, rm } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { writeAtomic } from '@anhlp/alp-core/atomic';
4
+ import { tell } from './write-error.js';
4
5
 
5
6
  /** What a finished writer outside a worktree left in its checkout, kept until its requester handles it (recall entries expire, this does not). */
6
7
  export type AssignmentResultEvidence = { agent: string; status: string; finishedAt: string; project: string; requesters: string[]; taskId?: string; brief: string; summary: string };
@@ -25,8 +26,11 @@ const valid = (value: any): value is Ledger => value?.version === 1 && Array.isA
25
26
  evidence(entry.result) && handling(entry.handled));
26
27
  const MONTH = /^(\d{4})-(\d{2})\.jsonl$/;
27
28
 
28
- /** Permanent ownership, independent of native-thread recall expiry. Missing initialized data is never recreated. */
29
- export function createAssignmentResults(file?: string) {
29
+ /**
30
+ * Permanent ownership, independent of native-thread recall expiry. Missing initialized data is never recreated.
31
+ * A failed write still fails its caller; `onError` hears of it too, so a full disk is seen at once.
32
+ */
33
+ export function createAssignmentResults(file?: string, onError: (error: unknown) => void = () => {}) {
30
34
  let memory = empty();
31
35
  let archivedInMemory: ArchivedAssignmentResult[] = [];
32
36
  let queue = Promise.resolve();
@@ -51,10 +55,12 @@ export function createAssignmentResults(file?: string) {
51
55
  }
52
56
  async function save(value: Ledger) {
53
57
  if (!file) { memory = value; return; }
54
- await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
55
- await writeAtomic(file, JSON.stringify(value) + '\n');
56
- // The marker survives a lost ledger; registration must never silently reset ownership.
57
- await writeFile(marker!, '1\n', { flag: 'wx', mode: 0o600 }).catch(error => { if (error.code !== 'EEXIST') throw error; });
58
+ try {
59
+ await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
60
+ await writeAtomic(file, JSON.stringify(value) + '\n');
61
+ // The marker survives a lost ledger; registration must never silently reset ownership.
62
+ await writeFile(marker!, '1\n', { flag: 'wx', mode: 0o600 }).catch(error => { if (error.code !== 'EEXIST') throw error; });
63
+ } catch (error) { tell(onError, error); throw error; }
58
64
  }
59
65
  function serialize<T>(run: () => Promise<T>): Promise<T> {
60
66
  const result = queue.then(run);
@@ -64,16 +70,18 @@ export function createAssignmentResults(file?: string) {
64
70
  /** Appends a record and syncs it before its ledger entry may go; a crash in between archives it again, never loses it. */
65
71
  async function append(record: ArchivedAssignmentResult) {
66
72
  if (!archiveDir) { archivedInMemory.push(record); return; }
67
- await mkdir(archiveDir, { recursive: true, mode: 0o700 });
68
- const handle = await open(path.join(archiveDir, `${record.archivedAt.slice(0, 7)}.jsonl`), 'a+', 0o600);
69
73
  try {
70
- const { size } = await handle.stat();
71
- const last = Buffer.alloc(1);
72
- // A line cut short by a crash must not swallow the next record.
73
- const torn = size > 0 && (await handle.read(last, 0, 1, size - 1)).bytesRead === 1 && last[0] !== 0x0a;
74
- await handle.appendFile(`${torn ? '\n' : ''}${JSON.stringify(record)}\n`);
75
- await handle.sync();
76
- } finally { await handle.close(); }
74
+ await mkdir(archiveDir, { recursive: true, mode: 0o700 });
75
+ const handle = await open(path.join(archiveDir, `${record.archivedAt.slice(0, 7)}.jsonl`), 'a+', 0o600);
76
+ try {
77
+ const { size } = await handle.stat();
78
+ const last = Buffer.alloc(1);
79
+ // A line cut short by a crash must not swallow the next record.
80
+ const torn = size > 0 && (await handle.read(last, 0, 1, size - 1)).bytesRead === 1 && last[0] !== 0x0a;
81
+ await handle.appendFile(`${torn ? '\n' : ''}${JSON.stringify(record)}\n`);
82
+ await handle.sync();
83
+ } finally { await handle.close(); }
84
+ } catch (error) { tell(onError, error); throw error; }
77
85
  }
78
86
  async function archived(): Promise<ArchivedAssignmentResult[]> {
79
87
  if (!archiveDir) return archivedInMemory;
package/src/catalog.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Models, modes and thinking options the runtime accepts; viewers render them as-is. */
2
- import { MODELS } from '@anhlp/alp-core/models';
2
+ import { MODELS, useLiveModels } from '@anhlp/alp-core/models';
3
3
 
4
4
  export const DEFAULT_MODEL = 'gpt-5.6-sol';
5
5
  export const DEFAULT_CLAUDE_MODEL = 'sonnet';
@@ -34,6 +34,8 @@ export const models = entries.map(toModel);
34
34
  export function applyCatalog(next: CatalogEntry[]) {
35
35
  entries.splice(0, entries.length, ...next);
36
36
  models.splice(0, models.length, ...next.map(toModel));
37
+ // Core's effort checks and fitting (validation.js, profiles.js) consult the same rows (t-086c).
38
+ useLiveModels(next);
37
39
  }
38
40
 
39
41
  export function thinkingOptionsFor(runtime: 'codex' | 'claude' | 'antigravity', nativeModel: string) {