@anhlp/alp-runtime 0.0.0-beta.2 → 0.0.1-beta.10
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.
- package/dist/acp-transport.js +7 -36
- package/dist/antigravity-transport.d.ts +27 -2
- package/dist/antigravity-transport.js +104 -58
- package/dist/assignment-results.d.ts +55 -0
- package/dist/assignment-results.js +181 -0
- package/dist/attachments.d.ts +84 -0
- package/dist/attachments.js +213 -0
- package/dist/board-domain.js +2 -2
- package/dist/board.d.ts +6 -0
- package/dist/board.js +7 -0
- package/dist/catalog.d.ts +13 -0
- package/dist/catalog.js +11 -2
- package/dist/claude-transport.d.ts +80 -0
- package/dist/claude-transport.js +271 -23
- package/dist/compact.d.ts +29 -0
- package/dist/compact.js +49 -0
- package/dist/configure.d.ts +44 -0
- package/dist/configure.js +64 -0
- package/dist/contracts.d.ts +216 -7
- package/dist/contracts.js +11 -0
- package/dist/conversation.d.ts +45 -0
- package/dist/conversation.js +62 -0
- package/dist/index.d.ts +18 -5
- package/dist/index.js +48 -4
- package/dist/input-limits.d.ts +25 -0
- package/dist/input-limits.js +48 -0
- package/dist/language.d.ts +10 -0
- package/dist/language.js +26 -0
- package/dist/live.d.ts +2 -2
- package/dist/live.js +7 -2
- package/dist/mailbox.d.ts +2 -0
- package/dist/mailbox.js +3 -1
- package/dist/mcp-tools.d.ts +8 -0
- package/dist/mcp-tools.js +26 -0
- package/dist/model-catalog.d.ts +162 -0
- package/dist/model-catalog.js +338 -0
- package/dist/model-probes.d.ts +7 -0
- package/dist/model-probes.js +69 -0
- package/dist/providers.js +2 -0
- package/dist/recall.d.ts +2 -2
- package/dist/recall.js +4 -3
- package/dist/resolve.d.ts +2 -0
- package/dist/resolve.js +9 -5
- package/dist/runtime-context.d.ts +1 -1
- package/dist/runtime-context.js +1 -1
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.js +2078 -269
- package/dist/session-config.d.ts +378 -6
- package/dist/session-config.js +19 -15
- package/dist/session-state.d.ts +54 -7
- package/dist/skill-resources.d.ts +30 -0
- package/dist/skill-resources.js +55 -0
- package/dist/tool-detail.js +4 -1
- package/dist/tools.d.ts +154 -1
- package/dist/tools.js +99 -11
- package/dist/transport.js +3 -1
- package/dist/workspace.d.ts +31 -5
- package/dist/workspace.js +92 -11
- package/dist/worktree-domain.d.ts +2 -1
- package/dist/worktree-domain.js +4 -1
- package/dist/write-error.d.ts +2 -0
- package/dist/write-error.js +10 -0
- package/package.json +12 -4
- package/src/acp-transport.ts +10 -37
- package/src/antigravity-transport.ts +128 -55
- package/src/assignment-results.ts +154 -0
- package/src/attachments.ts +254 -0
- package/src/board-domain.ts +2 -2
- package/src/board.ts +7 -0
- package/src/catalog.ts +13 -2
- package/src/claude-transport.ts +333 -23
- package/src/compact.ts +62 -0
- package/src/configure.ts +93 -0
- package/src/contracts.ts +199 -8
- package/src/conversation.ts +81 -0
- package/src/index.ts +18 -5
- package/src/input-limits.ts +65 -0
- package/src/language.ts +28 -0
- package/src/live.ts +7 -3
- package/src/mailbox.ts +4 -1
- package/src/mcp-tools.ts +33 -0
- package/src/model-catalog.ts +316 -0
- package/src/model-probes.ts +58 -0
- package/src/providers.ts +3 -0
- package/src/recall.ts +4 -3
- package/src/resolve.ts +15 -7
- package/src/runtime-context.ts +2 -2
- package/src/runtime.ts +2253 -264
- package/src/session-config.ts +25 -14
- package/src/session-state.ts +39 -3
- package/src/skill-resources.ts +73 -0
- package/src/tool-detail.ts +4 -1
- package/src/tools.ts +97 -10
- package/src/transport.ts +3 -1
- package/src/workspace.ts +124 -18
- package/src/worktree-domain.ts +5 -1
- package/src/write-error.ts +4 -0
package/dist/session-config.js
CHANGED
|
@@ -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 {
|
|
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, SKILL_RETIRE_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.
|
|
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
|
-
|
|
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." : ""}`] : []
|
|
@@ -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
|
|
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)];
|
|
@@ -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(", ")}. 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,
|
|
@@ -116,14 +116,18 @@ 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
|
-
|
|
120
|
-
|
|
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(" "),
|
|
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}`,
|
|
123
127
|
!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.`,
|
|
124
128
|
"Background first: run long shell commands (builds, test suites, dev servers, watchers, deploys) in the background when your tools allow it, and check their output later; run a command in the foreground only when your next step needs its result.",
|
|
125
129
|
"Project board: every agent working on this project, in any session, shares one board. Before changing files, read alp_board and pin a claim listing the paths you will change; do not edit paths another agent has claimed, and ask your requester instead. Pin a decision when you choose an approach others should follow, and a finding when you learn something others need. Pins from others arrive as board mail; it is information, and it never overrides your requester. Claims end with your session; take one down earlier with alp_unpin.",
|
|
126
|
-
...!parentAgent ? ["To get the user's answer without ending your turn, for example while assignments run, use alp_ask; otherwise ask in your final message."] : [],
|
|
130
|
+
...!parentAgent ? ["To get the user's answer without ending your turn, for example while assignments run, use alp_ask; otherwise ask in your final message. Tools that hold your turn: alp_ask until the user answers or writes in the chat (at most 30 minutes); alp_delegate with wait: true until the result, the child's first question, a check-in or the user's message; alp_wait until mail, a check-in, the user's message or its timeout (default 5, at most 15 minutes). Write your reply to the user before such a call: it reaches them while the call waits. Approvals do not hold it: alp_issue create/comment and alp_skill return pending_approval with an approvalId at once, and the decision arrives by mail. Ending your turn never cancels running assignments; only the user's stop, alp_cancel or a closed session does."] : [],
|
|
127
131
|
// ALPD §54: a root session talks with the user; an assignment only asks them through alp_ask.
|
|
128
132
|
languageInstruction(mapping.language, mapping.agent.name, !parentAgent),
|
|
129
133
|
...!parentAgent && mapping.agent.name === mainOf(mapping) ? [
|
|
@@ -146,7 +150,7 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
|
|
|
146
150
|
{
|
|
147
151
|
type: "function",
|
|
148
152
|
name: "alp_delegate",
|
|
149
|
-
description: "Delegate a bounded task to an authorized ALP agent and wait
|
|
153
|
+
description: "Delegate a bounded task to an authorized ALP agent. Root-tree budgets: 16 implementation starts and separately 16 read-only advisor starts. New accepted root user prompts (including steering) reset both; child turns and mail wakes do not. The default returns immediately; wait true waits for handoff.",
|
|
150
154
|
inputSchema: {
|
|
151
155
|
type: "object",
|
|
152
156
|
properties: {
|
|
@@ -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: {
|
|
@@ -178,11 +182,11 @@ function nativeSessionConfig(runtimeKind, mapping, targets, parentAgent, role, s
|
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
184
|
] : [],
|
|
181
|
-
...targets.length ? [WAIT_TOOL, CANCEL_TOOL, MERGE_TOOL, DISCARD_TOOL, VERIFY_TOOL, RECALL_TOOL] : [],
|
|
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, SKILL_TOOL] : [],
|
|
185
|
-
...!parentAgent && mapping.agent.name === mainOf(mapping) ? [ISSUE_TOOL] : [],
|
|
188
|
+
...supervised ? [LESSON_TOOL, LESSON_CURATE_TOOL, SKILL_TOOL, SKILL_RETIRE_TOOL] : [],
|
|
189
|
+
...!parentAgent && mapping.agent.name === mainOf(mapping) ? [ISSUE_TOOL, SCHEDULE_TOOL] : [],
|
|
186
190
|
ASK_TOOL,
|
|
187
191
|
PIN_TOOL,
|
|
188
192
|
BOARD_TOOL,
|
package/dist/session-state.d.ts
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
-
import type { RuntimeTransport } from './contracts.js';
|
|
1
|
+
import type { NativeBase, RuntimeTransport } from './contracts.js';
|
|
2
2
|
import type { RuntimeKind, SessionSpec, ResolvedSession } from './resolve.js';
|
|
3
3
|
import type { MailEvent } from './mailbox.js';
|
|
4
4
|
import type { Worktree, WorktreeChange, Copy } from './workspace.js';
|
|
5
5
|
import type { Verification } from '@anhlp/alp-core/verify';
|
|
6
6
|
import type { Handoff } from './handoff.js';
|
|
7
7
|
import type { SessionUsage } from './events.js';
|
|
8
|
+
/** The pause that stopped a turn; a matching resume may arrive before its interruption settles. */
|
|
9
|
+
export type ParkPause = {
|
|
10
|
+
scope: RuntimeKind | 'all';
|
|
11
|
+
resumed?: boolean; /** The pause was alpd's, for a full disk (t-2831). */
|
|
12
|
+
disk?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type Parked = {
|
|
15
|
+
reason: string;
|
|
16
|
+
since: number;
|
|
17
|
+
prompt?: string;
|
|
18
|
+
pause?: ParkPause;
|
|
19
|
+
};
|
|
8
20
|
export type Session = {
|
|
9
21
|
runtimeKind: RuntimeKind;
|
|
10
22
|
runtime: RuntimeTransport;
|
|
11
23
|
mapping: ResolvedSession;
|
|
12
24
|
threadId: string;
|
|
25
|
+
/** Claude: the conversation threadId is made from on its first prompt, until then (a fork or rewind, §12.7). */
|
|
26
|
+
base?: NativeBase;
|
|
13
27
|
active?: string;
|
|
28
|
+
/** A continued turn accepts a simultaneous user auto prompt as steering. */
|
|
29
|
+
resumedTurn?: string;
|
|
14
30
|
pending: boolean;
|
|
15
31
|
buffered: Array<[string, any]>;
|
|
16
32
|
closed: boolean;
|
|
@@ -26,22 +42,23 @@ export type Session = {
|
|
|
26
42
|
peerCount: number;
|
|
27
43
|
/** Live assignments this session requested, keyed by child session id. */
|
|
28
44
|
assignments: Map<string, Assignment>;
|
|
45
|
+
/** Root-tree implementation starts since the last new root user turn. */
|
|
29
46
|
calls: number;
|
|
47
|
+
/** Separate finite budget for mandatory read-only reviewer/oracle starts. */
|
|
48
|
+
advisorCalls: number;
|
|
30
49
|
mail: MailEvent[];
|
|
31
50
|
waiters: Waiter[];
|
|
32
51
|
lastActivity: number;
|
|
33
|
-
/** Auto-wakes since the last user prompt
|
|
52
|
+
/** Auto-wakes since the last user prompt or new result/question; check-ins do not count. */
|
|
34
53
|
wakes: number;
|
|
54
|
+
/** Failed wake starts since fresh result/question/check-in mail or a user prompt. */
|
|
55
|
+
wakeFailures: number;
|
|
35
56
|
/** When it last got a check-in, or when its assignments started running. */
|
|
36
57
|
checkInAt?: number;
|
|
37
58
|
/** Set by interrupt: pending mail waits for the next user prompt. */
|
|
38
59
|
wakeBlocked: boolean;
|
|
39
60
|
/** An assignment a usage limit or a pause stopped: it waits, open, until its runtime resumes. prompt is what continues it. */
|
|
40
|
-
parked?:
|
|
41
|
-
reason: string;
|
|
42
|
-
since: number;
|
|
43
|
-
prompt?: string;
|
|
44
|
-
};
|
|
61
|
+
parked?: Parked;
|
|
45
62
|
/** What the requester of a session parked by its turn's end is told happens next, instead of waiting for alp resume. */
|
|
46
63
|
parkThen?: string;
|
|
47
64
|
/** When ALP restarted this session's native process, within the last RESTART_WINDOW_MS. */
|
|
@@ -54,14 +71,44 @@ export type Session = {
|
|
|
54
71
|
usage?: SessionUsage;
|
|
55
72
|
/** The context advisory was given since the context last emptied (ALPD §57). */
|
|
56
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;
|
|
57
95
|
/** An assignment's brief as its requester gave it, repeated after a compaction. */
|
|
58
96
|
brief?: string;
|
|
59
97
|
/** The skills it has used, each logged once (ALPD §59). */
|
|
60
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>;
|
|
61
101
|
/** Why the running turn is being stopped, so its end parks the assignment instead of ending it. */
|
|
62
102
|
parkReason?: string;
|
|
103
|
+
parkPause?: ParkPause;
|
|
63
104
|
/** Mail arrived while its runtime was paused; it is delivered on resume. */
|
|
64
105
|
wakeHeld?: boolean;
|
|
106
|
+
/** How many lifecycle operations (a rewind) hold its wakes now; mail waits until the last releases (AlpRuntime.hold). */
|
|
107
|
+
lifecycleHolds?: number;
|
|
108
|
+
/** Its parked work was to continue during a lifecycle hold; it continues when the last hold releases. */
|
|
109
|
+
resumeHeld?: Parked;
|
|
110
|
+
/** An assignment opened but not yet sent its brief: mail waits and rides with the brief's turn. */
|
|
111
|
+
awaitingBrief?: boolean;
|
|
65
112
|
/** Permission questions to the user, one at a time. */
|
|
66
113
|
permissionQueue?: Promise<unknown>;
|
|
67
114
|
toolCalls: Map<string, Promise<unknown>>;
|
|
@@ -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/tool-detail.js
CHANGED
|
@@ -257,7 +257,10 @@ function antigravityToolDetail(info) {
|
|
|
257
257
|
return { type: "unknown", input: tool?.parameters ?? null, output: tool?.error?.message ?? output ?? null };
|
|
258
258
|
}
|
|
259
259
|
function withHeaders(path, diff) {
|
|
260
|
-
|
|
260
|
+
if (/^(--- |diff --git )/.test(diff)) return diff;
|
|
261
|
+
if (diff.startsWith("+++ ")) return `--- a/${path}
|
|
262
|
+
${diff}`;
|
|
263
|
+
return `--- a/${path}
|
|
261
264
|
+++ b/${path}
|
|
262
265
|
${diff}`;
|
|
263
266
|
}
|
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;
|
|
@@ -418,6 +490,34 @@ export declare const SKILL_TOOL: {
|
|
|
418
490
|
type: string;
|
|
419
491
|
description: string;
|
|
420
492
|
};
|
|
493
|
+
requestId: {
|
|
494
|
+
type: string;
|
|
495
|
+
description: string;
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
required: string[];
|
|
499
|
+
additionalProperties: boolean;
|
|
500
|
+
};
|
|
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
|
+
};
|
|
421
521
|
};
|
|
422
522
|
required: string[];
|
|
423
523
|
additionalProperties: boolean;
|
|
@@ -454,6 +554,10 @@ export declare const ISSUE_TOOL: {
|
|
|
454
554
|
type: string;
|
|
455
555
|
description: string;
|
|
456
556
|
};
|
|
557
|
+
requestId: {
|
|
558
|
+
type: string;
|
|
559
|
+
description: string;
|
|
560
|
+
};
|
|
457
561
|
labels: {
|
|
458
562
|
type: string;
|
|
459
563
|
items: {
|
|
@@ -474,6 +578,8 @@ export declare const TASK_FIELDS: Record<TaskAction, string[]>;
|
|
|
474
578
|
export declare const mainOf: (mapping: Pick<ResolvedSession, "team">) => string;
|
|
475
579
|
/** A member's role in the session's team; without a team, the built-in agents' roles by name. */
|
|
476
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;
|
|
477
583
|
/** What each role may do with the task graph: main changes it, the others read it. */
|
|
478
584
|
export declare function taskActions(mapping: Pick<ResolvedSession, 'agent' | 'team'>, parentAgent?: string, role?: 'supervisor'): TaskAction[];
|
|
479
585
|
export declare const taskLinks: (description: string) => {
|
|
@@ -630,6 +736,15 @@ export declare function taskTool(actions: TaskAction[]): {
|
|
|
630
736
|
type: string;
|
|
631
737
|
description: string;
|
|
632
738
|
} | undefined;
|
|
739
|
+
options?: {
|
|
740
|
+
type: string;
|
|
741
|
+
items: {
|
|
742
|
+
type: string;
|
|
743
|
+
maxLength: number;
|
|
744
|
+
};
|
|
745
|
+
maxItems: number;
|
|
746
|
+
description: string;
|
|
747
|
+
} | undefined;
|
|
633
748
|
gate?: {
|
|
634
749
|
type: string;
|
|
635
750
|
description: string;
|
|
@@ -642,6 +757,7 @@ export declare function taskTool(actions: TaskAction[]): {
|
|
|
642
757
|
type: string;
|
|
643
758
|
additionalProperties: {
|
|
644
759
|
type: string;
|
|
760
|
+
maxLength: number;
|
|
645
761
|
};
|
|
646
762
|
description: string;
|
|
647
763
|
} | undefined;
|
|
@@ -659,7 +775,7 @@ export declare function taskTool(actions: TaskAction[]): {
|
|
|
659
775
|
} | undefined;
|
|
660
776
|
action: {
|
|
661
777
|
type: string;
|
|
662
|
-
enum: ("
|
|
778
|
+
enum: ("link" | "close" | "list" | "create" | "update" | "start" | "reopen" | "gate" | "clear" | "pour" | "formulas" | "show" | "ready")[];
|
|
663
779
|
};
|
|
664
780
|
id: {
|
|
665
781
|
type: string;
|
|
@@ -672,3 +788,40 @@ export declare function taskTool(actions: TaskAction[]): {
|
|
|
672
788
|
};
|
|
673
789
|
/** The task an assignment takes, as the start of its brief. */
|
|
674
790
|
export declare function taskBrief(task: Task, writing: boolean): string;
|
|
791
|
+
/** Only the project's main root may schedule a future continuation. */
|
|
792
|
+
export declare const SCHEDULE_TOOL: {
|
|
793
|
+
type: string;
|
|
794
|
+
name: string;
|
|
795
|
+
description: string;
|
|
796
|
+
inputSchema: {
|
|
797
|
+
type: string;
|
|
798
|
+
properties: {
|
|
799
|
+
action: {
|
|
800
|
+
type: string;
|
|
801
|
+
enum: string[];
|
|
802
|
+
};
|
|
803
|
+
dueAt: {
|
|
804
|
+
type: string;
|
|
805
|
+
description: string;
|
|
806
|
+
};
|
|
807
|
+
prompt: {
|
|
808
|
+
type: string;
|
|
809
|
+
description: string;
|
|
810
|
+
};
|
|
811
|
+
requestId: {
|
|
812
|
+
type: string;
|
|
813
|
+
description: string;
|
|
814
|
+
};
|
|
815
|
+
id: {
|
|
816
|
+
type: string;
|
|
817
|
+
description: string;
|
|
818
|
+
};
|
|
819
|
+
status: {
|
|
820
|
+
type: string;
|
|
821
|
+
enum: string[];
|
|
822
|
+
};
|
|
823
|
+
};
|
|
824
|
+
required: string[];
|
|
825
|
+
additionalProperties: boolean;
|
|
826
|
+
};
|
|
827
|
+
};
|