@anhlp/alp-runtime 0.0.0-stage → 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.
Files changed (127) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +7 -0
  3. package/README.md +6 -2
  4. package/dist/acp-transport.d.ts +130 -0
  5. package/dist/acp-transport.js +482 -0
  6. package/dist/antigravity-transport.d.ts +107 -0
  7. package/dist/antigravity-transport.js +665 -0
  8. package/dist/assignment-results.d.ts +55 -0
  9. package/dist/assignment-results.js +181 -0
  10. package/dist/attachments.d.ts +84 -0
  11. package/dist/attachments.js +213 -0
  12. package/dist/board-domain.d.ts +56 -0
  13. package/dist/board-domain.js +157 -0
  14. package/dist/board.d.ts +27 -0
  15. package/dist/board.js +76 -0
  16. package/dist/catalog.d.ts +44 -0
  17. package/dist/catalog.js +47 -0
  18. package/dist/claude-transport.d.ts +251 -0
  19. package/dist/claude-transport.js +931 -0
  20. package/dist/compact.d.ts +29 -0
  21. package/dist/compact.js +49 -0
  22. package/dist/configure.d.ts +44 -0
  23. package/dist/configure.js +64 -0
  24. package/dist/contracts.d.ts +378 -0
  25. package/dist/contracts.js +16 -0
  26. package/dist/conversation.d.ts +45 -0
  27. package/dist/conversation.js +62 -0
  28. package/dist/events.d.ts +1 -0
  29. package/dist/events.js +0 -0
  30. package/dist/github.d.ts +10 -0
  31. package/dist/github.js +39 -0
  32. package/dist/handoff.d.ts +36 -0
  33. package/dist/handoff.js +73 -0
  34. package/dist/index.d.ts +39 -0
  35. package/dist/index.js +122 -0
  36. package/dist/input-limits.d.ts +25 -0
  37. package/dist/input-limits.js +48 -0
  38. package/dist/language.d.ts +51 -0
  39. package/dist/language.js +94 -0
  40. package/dist/live.d.ts +48 -0
  41. package/dist/live.js +50 -0
  42. package/dist/mailbox.d.ts +26 -0
  43. package/dist/mailbox.js +38 -0
  44. package/dist/mcp-tools.d.ts +123 -0
  45. package/dist/mcp-tools.js +97 -0
  46. package/dist/model-catalog.d.ts +162 -0
  47. package/dist/model-catalog.js +338 -0
  48. package/dist/model-probes.d.ts +7 -0
  49. package/dist/model-probes.js +69 -0
  50. package/dist/permission-path.d.ts +2 -0
  51. package/dist/permission-path.js +44 -0
  52. package/dist/process-info.d.ts +14 -0
  53. package/dist/process-info.js +32 -0
  54. package/dist/providers.d.ts +28 -0
  55. package/dist/providers.js +73 -0
  56. package/dist/recall.d.ts +42 -0
  57. package/dist/recall.js +61 -0
  58. package/dist/resolve.d.ts +123 -0
  59. package/dist/resolve.js +242 -0
  60. package/dist/runtime-context.d.ts +43 -0
  61. package/dist/runtime-context.js +61 -0
  62. package/dist/runtime.d.ts +13 -0
  63. package/dist/runtime.js +4818 -0
  64. package/dist/session-config.d.ts +2345 -0
  65. package/dist/session-config.js +209 -0
  66. package/dist/session-state.d.ts +190 -0
  67. package/dist/session-state.js +0 -0
  68. package/dist/skill-resources.d.ts +30 -0
  69. package/dist/skill-resources.js +55 -0
  70. package/dist/tool-detail.d.ts +81 -0
  71. package/dist/tool-detail.js +332 -0
  72. package/dist/tool-results.d.ts +12 -0
  73. package/dist/tool-results.js +25 -0
  74. package/dist/tools.d.ts +827 -0
  75. package/dist/tools.js +463 -0
  76. package/dist/transport.d.ts +47 -0
  77. package/dist/transport.js +171 -0
  78. package/dist/usage.d.ts +25 -0
  79. package/dist/usage.js +60 -0
  80. package/dist/workspace.d.ts +127 -0
  81. package/dist/workspace.js +340 -0
  82. package/dist/worktree-domain.d.ts +89 -0
  83. package/dist/worktree-domain.js +199 -0
  84. package/dist/write-error.d.ts +2 -0
  85. package/dist/write-error.js +10 -0
  86. package/package.json +262 -4
  87. package/src/acp-transport.ts +481 -0
  88. package/src/antigravity-transport.ts +740 -0
  89. package/src/assignment-results.ts +154 -0
  90. package/src/attachments.ts +254 -0
  91. package/src/board-domain.ts +185 -0
  92. package/src/board.ts +87 -0
  93. package/src/catalog.ts +43 -0
  94. package/src/claude-transport.ts +1097 -0
  95. package/src/compact.ts +62 -0
  96. package/src/configure.ts +93 -0
  97. package/src/contracts.ts +363 -0
  98. package/src/conversation.ts +81 -0
  99. package/src/events.ts +1 -0
  100. package/src/github.ts +37 -0
  101. package/src/handoff.ts +86 -0
  102. package/src/index.ts +41 -0
  103. package/src/input-limits.ts +65 -0
  104. package/src/language.ts +130 -0
  105. package/src/live.ts +90 -0
  106. package/src/mailbox.ts +49 -0
  107. package/src/mcp-tools.ts +106 -0
  108. package/src/model-catalog.ts +316 -0
  109. package/src/model-probes.ts +58 -0
  110. package/src/permission-path.ts +37 -0
  111. package/src/process-info.ts +40 -0
  112. package/src/providers.ts +87 -0
  113. package/src/recall.ts +86 -0
  114. package/src/resolve.ts +238 -0
  115. package/src/runtime-context.ts +49 -0
  116. package/src/runtime.ts +5608 -0
  117. package/src/session-config.ts +312 -0
  118. package/src/session-state.ts +180 -0
  119. package/src/skill-resources.ts +73 -0
  120. package/src/tool-detail.ts +397 -0
  121. package/src/tool-results.ts +26 -0
  122. package/src/tools.ts +466 -0
  123. package/src/transport.ts +118 -0
  124. package/src/usage.ts +79 -0
  125. package/src/workspace.ts +424 -0
  126. package/src/worktree-domain.ts +220 -0
  127. package/src/write-error.ts +4 -0
@@ -0,0 +1,62 @@
1
+ // packages/runtime/src/conversation.ts
2
+ import { ConversationError } from "./contracts.js";
3
+ var refuse = (reason, message, outcomeUnknown = false) => new ConversationError(reason, message, { outcomeUnknown });
4
+ function codexForkEnd(request) {
5
+ const { cutoff, turns } = request;
6
+ if (!cutoff) {
7
+ if (!turns.length) throw refuse("empty_prefix", "The conversation has no turn to fork");
8
+ return { last: turns.at(-1), params: {} };
9
+ }
10
+ const id = "beforeTurnId" in cutoff ? cutoff.beforeTurnId : cutoff.throughTurnId;
11
+ const index = turns.indexOf(id);
12
+ if (index < 0) throw refuse("boundary_unmapped", `Turn ${id} is not a turn of this conversation`);
13
+ if ("beforeTurnId" in cutoff) {
14
+ if (index === 0) throw refuse("empty_prefix", "Nothing comes before the first turn");
15
+ return { last: turns[index - 1], params: { beforeTurnId: id } };
16
+ }
17
+ return { last: id, params: { lastTurnId: id } };
18
+ }
19
+ function codexForkRefusal(error) {
20
+ if (error instanceof ConversationError) return error;
21
+ const message = error instanceof Error ? error.message : String(error);
22
+ if (error?.outcomeUnknown) return refuse("native_refused", `Codex did not answer the fork: ${message}`, true);
23
+ if (/^turn not found\b/i.test(message)) return refuse("boundary_unmapped", `Codex does not know that turn: ${message}`);
24
+ if (/identifies an in-progress turn/i.test(message)) return refuse("session_busy", `The turn is still running: ${message}`);
25
+ return refuse("native_refused", `Codex refused the fork: ${message}`);
26
+ }
27
+ function claudeCut(chain, request) {
28
+ const { cutoff, turns } = request;
29
+ const position = new Map(chain.map((entry, index) => [entry.uuid, index]));
30
+ const prompt = (id2) => {
31
+ const index = position.get(id2);
32
+ return index !== void 0 && chain[index].type === "user" && !chain[index].toolResult ? index : void 0;
33
+ };
34
+ if (!cutoff) {
35
+ if (!chain.length) throw refuse("empty_prefix", "The conversation has no turn to fork");
36
+ return chain.at(-1).uuid;
37
+ }
38
+ const id = "beforeTurnId" in cutoff ? cutoff.beforeTurnId : cutoff.throughTurnId;
39
+ const turn = turns.indexOf(id);
40
+ const at = prompt(id);
41
+ if (turn < 0 || at === void 0) throw refuse("boundary_unmapped", `Turn ${id} is not a turn of this conversation's transcript`);
42
+ const found = turns.map(prompt).filter((index) => index !== void 0);
43
+ if (found.some((index, i) => i > 0 && index <= found[i - 1])) throw refuse("boundary_unmapped", "The transcript orders turns differently from ALP");
44
+ if ("beforeTurnId" in cutoff) {
45
+ if (turn === 0 || at === 0) throw refuse("empty_prefix", "Nothing comes before the first turn");
46
+ return chain[at - 1].uuid;
47
+ }
48
+ const next = turns.slice(turn + 1).map(prompt).find((index) => index !== void 0);
49
+ return chain[(next ?? chain.length) - 1].uuid;
50
+ }
51
+ function pendingChain(base, chain) {
52
+ if (!base.at) return chain;
53
+ const index = chain.findIndex((entry) => entry.uuid === base.at);
54
+ if (index < 0) throw refuse("native_refused", `The conversation no longer has the entry ${base.at} it was cut at`);
55
+ return chain.slice(0, index + 1);
56
+ }
57
+ export {
58
+ claudeCut,
59
+ codexForkEnd,
60
+ codexForkRefusal,
61
+ pendingChain
62
+ };
@@ -0,0 +1 @@
1
+ export type * from '@anhlp/alp-protocol/events';
package/dist/events.js ADDED
File without changes
@@ -0,0 +1,10 @@
1
+ /** Where agents send feedback about ALP itself: its process, tools and agent instructions. */
2
+ export declare const ALP_REPO = "phucanh08/alp";
3
+ /** Runs the GitHub CLI with optional standard input and returns its standard output. Tests replace it. */
4
+ export type GitHubRunner = (args: string[], options: {
5
+ cwd: string;
6
+ input?: string;
7
+ }) => Promise<string>;
8
+ export declare const gh: GitHubRunner;
9
+ /** The owner/name of the GitHub repository a project's origin remote points to. */
10
+ export declare function projectRepo(projectRoot: string): Promise<string>;
package/dist/github.js ADDED
@@ -0,0 +1,39 @@
1
+ // packages/runtime/src/github.ts
2
+ import { spawn } from "node:child_process";
3
+ import { gitEnvironment } from "./workspace.js";
4
+ var ALP_REPO = "phucanh08/alp";
5
+ function run(command, args, { cwd, input }) {
6
+ return new Promise((resolve, reject) => {
7
+ const child = spawn(command, args, { cwd, windowsHide: true, stdio: ["pipe", "pipe", "pipe"], env: gitEnvironment() });
8
+ let stdout = "";
9
+ let stderr = "";
10
+ child.stdout.on("data", (chunk) => {
11
+ stdout += chunk;
12
+ });
13
+ child.stderr.on("data", (chunk) => {
14
+ stderr += chunk;
15
+ });
16
+ child.stdin.on("error", () => {
17
+ });
18
+ child.on("error", (error) => reject(error.code === "ENOENT" ? new Error(`${command} is not installed or not on PATH`) : error));
19
+ child.on("close", (code) => code === 0 ? resolve(stdout) : reject(new Error((stderr || stdout).trim() || `${command} exited with ${code}`)));
20
+ child.stdin.end(input ?? "");
21
+ });
22
+ }
23
+ var gh = (args, options) => run(process.env.ALP_GH_BIN ?? "gh", args, options);
24
+ async function projectRepo(projectRoot) {
25
+ let url;
26
+ try {
27
+ url = (await run("git", ["remote", "get-url", "origin"], { cwd: projectRoot })).trim();
28
+ } catch {
29
+ throw new Error('This project has no git remote named origin; use target "alp" for feedback about ALP, or tell the user');
30
+ }
31
+ const match = /github\.com[:/]([\w.-]+)\/([\w.-]+?)(?:\.git)?\/?$/.exec(url);
32
+ if (!match) throw new Error(`The origin remote is not on GitHub (${url}); issues are filed with the GitHub CLI only`);
33
+ return `${match[1]}/${match[2]}`;
34
+ }
35
+ export {
36
+ ALP_REPO,
37
+ gh,
38
+ projectRepo
39
+ };
@@ -0,0 +1,36 @@
1
+ export declare const HANDOFF_OUTCOMES: readonly ["complete", "partial", "blocked", "reconsider"];
2
+ export declare const HANDOFF_LISTS: readonly ["candidate", "scope", "verification", "risks", "discovered"];
3
+ /**
4
+ * A review's verdict (ALPD §38): each criterion judged with its evidence, findings
5
+ * by severity, and one result that follows from them, so requesters, tasks and
6
+ * later a review quorum read every review the same way.
7
+ */
8
+ export declare const VERDICT_RESULTS: readonly ["pass", "pass_with_findings", "fail", "blocked"];
9
+ export declare const CRITERION_RESULTS: readonly ["pass", "fail", "not_checked"];
10
+ export declare const SEVERITIES: readonly ["critical", "high", "medium", "low"];
11
+ export type Verdict = {
12
+ result: typeof VERDICT_RESULTS[number];
13
+ criteria: Array<{
14
+ criterion: string;
15
+ result: typeof CRITERION_RESULTS[number];
16
+ evidence: string;
17
+ }>;
18
+ findings?: Array<{
19
+ severity: typeof SEVERITIES[number];
20
+ where: string;
21
+ problem: string;
22
+ fix?: string;
23
+ }>;
24
+ };
25
+ export type Handoff = {
26
+ outcome: typeof HANDOFF_OUTCOMES[number];
27
+ summary: string;
28
+ ownership?: string;
29
+ verdict?: Verdict;
30
+ } & Partial<Record<typeof HANDOFF_LISTS[number], string[]>>;
31
+ /** Returns the normalized handoff, or an error message for the child. */
32
+ /** Returns the verdict, or what is wrong with it; its result must follow from its criteria and findings. */
33
+ export declare function parseVerdict(value: any): Verdict | string;
34
+ /** A verdict in one line: its result and the criteria counts. */
35
+ export declare function verdictLine(verdict: Verdict): string;
36
+ export declare function parseHandoff(args: any): Handoff | string;
@@ -0,0 +1,73 @@
1
+ // packages/runtime/src/handoff.ts
2
+ var HANDOFF_OUTCOMES = ["complete", "partial", "blocked", "reconsider"];
3
+ var HANDOFF_LISTS = ["candidate", "scope", "verification", "risks", "discovered"];
4
+ var VERDICT_RESULTS = ["pass", "pass_with_findings", "fail", "blocked"];
5
+ var CRITERION_RESULTS = ["pass", "fail", "not_checked"];
6
+ var SEVERITIES = ["critical", "high", "medium", "low"];
7
+ function parseVerdict(value) {
8
+ const text = (item) => typeof item === "string" && !!item.trim();
9
+ const only = (item, keys) => !!item && typeof item === "object" && !Array.isArray(item) && Object.keys(item).every((key) => keys.includes(key));
10
+ if (!only(value, ["result", "criteria", "findings"])) return "verdict must be an object with result, criteria and findings";
11
+ if (!VERDICT_RESULTS.includes(value.result)) return `verdict.result must be one of ${VERDICT_RESULTS.join(", ")}`;
12
+ if (!Array.isArray(value.criteria) || !value.criteria.length || value.criteria.length > 50) return "verdict.criteria must list 1 to 50 criteria";
13
+ for (const item of value.criteria) {
14
+ if (!only(item, ["criterion", "result", "evidence"]) || !text(item.criterion) || !text(item.evidence) || !CRITERION_RESULTS.includes(item.result)) {
15
+ return `each verdict criterion needs criterion, result (${CRITERION_RESULTS.join(", ")}) and evidence`;
16
+ }
17
+ }
18
+ const findings = value.findings ?? [];
19
+ if (!Array.isArray(findings) || findings.length > 100) return "verdict.findings must be a list of at most 100 findings";
20
+ for (const item of findings) {
21
+ if (!only(item, ["severity", "where", "problem", "fix"]) || !SEVERITIES.includes(item.severity) || !text(item.where) || !text(item.problem) || item.fix !== void 0 && !text(item.fix)) {
22
+ return `each verdict finding needs severity (${SEVERITIES.join(", ")}), where and problem, and optionally fix`;
23
+ }
24
+ }
25
+ const failed = value.criteria.filter((item) => item.result === "fail").length;
26
+ const serious = findings.filter((item) => item.severity === "critical" || item.severity === "high").length;
27
+ if (value.result === "fail" && !failed && !serious) return "verdict fail needs a failed criterion or a critical or high finding";
28
+ if ((value.result === "pass" || value.result === "pass_with_findings") && (failed || serious)) {
29
+ return `verdict ${value.result} cannot have ${failed ? "a failed criterion" : "a critical or high finding"}; the result is fail`;
30
+ }
31
+ if (value.result === "pass" && findings.length) return "verdict pass cannot have findings; use pass_with_findings";
32
+ if (value.result === "pass_with_findings" && !findings.length) return "verdict pass_with_findings needs findings";
33
+ return { result: value.result, criteria: value.criteria, ...findings.length ? { findings } : {} };
34
+ }
35
+ function verdictLine(verdict) {
36
+ const count = (result) => verdict.criteria.filter((item) => item.result === result).length;
37
+ const parts = [`${count("pass")} passed`, count("fail") ? `${count("fail")} failed` : "", count("not_checked") ? `${count("not_checked")} not checked` : "", verdict.findings?.length ? `${verdict.findings.length} findings` : ""];
38
+ return `verdict ${verdict.result.toUpperCase()} (${parts.filter(Boolean).join(", ")})`;
39
+ }
40
+ function parseHandoff(args) {
41
+ if (!args || typeof args !== "object" || Array.isArray(args)) return "Handoff must be an object";
42
+ const allowed = ["outcome", "summary", "ownership", "verdict", ...HANDOFF_LISTS];
43
+ if (Object.keys(args).some((key) => !allowed.includes(key))) return "Unknown handoff field";
44
+ if (!HANDOFF_OUTCOMES.includes(args.outcome)) return `outcome must be one of ${HANDOFF_OUTCOMES.join(", ")}`;
45
+ if (typeof args.summary !== "string" || !args.summary.trim()) return "summary is required";
46
+ if (args.ownership !== void 0 && typeof args.ownership !== "string") return "ownership must be a string";
47
+ const handoff = { outcome: args.outcome, summary: args.summary };
48
+ for (const key of HANDOFF_LISTS) {
49
+ if (args[key] === void 0) continue;
50
+ if (!Array.isArray(args[key]) || args[key].length > 100 || !args[key].every((item) => typeof item === "string" && item.trim())) {
51
+ return `${key} must be a list of at most 100 nonempty strings`;
52
+ }
53
+ handoff[key] = args[key];
54
+ }
55
+ if (args.ownership?.trim()) handoff.ownership = args.ownership;
56
+ if (args.verdict !== void 0) {
57
+ const verdict = parseVerdict(args.verdict);
58
+ if (typeof verdict === "string") return verdict;
59
+ handoff.verdict = verdict;
60
+ }
61
+ if (JSON.stringify(handoff).length > 32e3) return "Handoff exceeds 32000 characters; summarize and point to files instead";
62
+ return handoff;
63
+ }
64
+ export {
65
+ CRITERION_RESULTS,
66
+ HANDOFF_LISTS,
67
+ HANDOFF_OUTCOMES,
68
+ SEVERITIES,
69
+ VERDICT_RESULTS,
70
+ parseHandoff,
71
+ parseVerdict,
72
+ verdictLine
73
+ };
@@ -0,0 +1,39 @@
1
+ export { createAlpRuntime, DEFAULT_TEAM, WorkspaceMutationError } from './runtime.js';
2
+ export type { WorkspaceMutationReason, AlpRuntime, RuntimeOptions, OpenOptions, RuntimeTransport, PromptInput, PromptContent, SessionPreview } from './runtime.js';
3
+ export { ConversationError } from './contracts.js';
4
+ export type { RuntimeCommand, BranchRequest, ConversationErrorReason, NativeBase, NativeBinding, ConfigureChanges, ConfigureResult, ConfigurePreview, EffectiveConfig } from './contracts.js';
5
+ export type { AlpEvent, AlpError, Envelope, SessionSnapshot, TimelineItem, TurnOrigin, AssignmentSnapshot, UserQuestion, TreeStatus, SessionState } from './events.js';
6
+ export { resolveSession, InstructionsAdapter, skillDescription } from './resolve.js';
7
+ export { resourceUses, pathActions } from './skill-resources.js';
8
+ export type { SessionSpec, HostMcpServer, ResolvedSession, RuntimeKind } from './resolve.js';
9
+ export { DEFAULT_MODEL, DEFAULT_CLAUDE_MODEL, entries as catalogEntries, models, modes, thinkingOptions, thinkingOptionsFor } from './catalog.js';
10
+ export type { CatalogEntry } from './catalog.js';
11
+ export { ModelCatalog, mergeCatalog, liveFromContext, feedCatalog, feedAcpSession, acpSessionModels, setActiveCatalog, activeCatalog, POLICY as CATALOG_POLICY, REFRESH_MS as CATALOG_REFRESH_MS } from './model-catalog.js';
12
+ export type { CatalogSnapshot, CatalogRuntime, LiveModel, Probe as CatalogProbe, AcpProviderConfig, AcpProbe, AcpRow, AcpState } from './model-catalog.js';
13
+ export { liveProbes, codexProbe, claudeProbe, antigravityProbe, parseAgyModels } from './model-probes.js';
14
+ export { CodexTransport } from './transport.js';
15
+ export { ATTACHMENT_HEADER, ATTACHMENT_ROUTES, attachmentStageDir, createAttachmentStager, stagingExposure } from './attachments.js';
16
+ export type { AttachmentReader, AttachmentRoute } from './attachments.js';
17
+ export { usageAllows } from './runtime-context.js';
18
+ export { AcpTransport, acpDecision, acpEnv, acpPermission } from './acp-transport.js';
19
+ export type { AcpProvider } from './acp-transport.js';
20
+ export { AntigravityTransport } from './antigravity-transport.js';
21
+ export type { AntigravityProvider } from './antigravity-transport.js';
22
+ export { ClaudeTransport, claudePermissions, claudeSandboxAvailable, customClearAliases, nativeCommandRefusal, skillPlugin, SKILL_PLUGIN, toolShapes as claudeToolShapes } from './claude-transport.js';
23
+ export { MAIL_BATCH_CHARS, MAIL_BODY_CHARS, publicEvent, renderMail, takeBatch, USER } from './mailbox.js';
24
+ export type { MailEvent, MailKind } from './mailbox.js';
25
+ export { createCopy, gitEnvironment, reattachWorktree, reclaimCopies, reclaimWorktrees, removeCopy } from './workspace.js';
26
+ export type { LeftWorktree } from './workspace.js';
27
+ export { OWN_START, processStartedAt, sameProcessAlive } from './process-info.js';
28
+ export type { Worktree, WorktreeChange } from './workspace.js';
29
+ export { PIN_KINDS, renderBoard, renderPin } from './board.js';
30
+ export { inputLimitError, TOOL_INPUT, POUR_VARS } from './input-limits.js';
31
+ export type { InputLimits } from './input-limits.js';
32
+ export { CHOICES, isVietnamese, languageInstruction, words } from './language.js';
33
+ export type { Words } from './language.js';
34
+ export type { Pin, PinKind } from './board.js';
35
+ export { ProviderRegistry, createProviderRegistry } from './providers.js';
36
+ export type { ProviderContext, ProviderFactory, ProviderFactories } from './providers.js';
37
+ export { acpToolDetail, antigravityToolDetail, boundDetail, claudeToolDetail, clipText, codexToolCall, stripReadGutter, toolError, DETAIL_FILE_PATHS, DETAIL_TEXT_CHARS, DETAIL_WEB_RESULTS, ERROR_CHARS, TOOL_FAILED } from './tool-detail.js';
38
+ export type { AcpCall, ClaudeResult, CodexToolCall, ToolCallDetail } from './tool-detail.js';
39
+ export { checkpointPrompt, compactDue, compactSettings, contextFill, seedPrompt, COMPACT_DEFAULTS } from './compact.js';
package/dist/index.js ADDED
@@ -0,0 +1,122 @@
1
+ // packages/runtime/src/index.ts
2
+ import { createAlpRuntime, DEFAULT_TEAM, WorkspaceMutationError } from "./runtime.js";
3
+ import { ConversationError } from "./contracts.js";
4
+ import { resolveSession, InstructionsAdapter, skillDescription } from "./resolve.js";
5
+ import { resourceUses, pathActions } from "./skill-resources.js";
6
+ import { DEFAULT_MODEL, DEFAULT_CLAUDE_MODEL, entries, models, modes, thinkingOptions, thinkingOptionsFor } from "./catalog.js";
7
+ import { ModelCatalog, mergeCatalog, liveFromContext, feedCatalog, feedAcpSession, acpSessionModels, setActiveCatalog, activeCatalog, POLICY, REFRESH_MS } from "./model-catalog.js";
8
+ import { liveProbes, codexProbe, claudeProbe, antigravityProbe, parseAgyModels } from "./model-probes.js";
9
+ import { CodexTransport } from "./transport.js";
10
+ import { ATTACHMENT_HEADER, ATTACHMENT_ROUTES, attachmentStageDir, createAttachmentStager, stagingExposure } from "./attachments.js";
11
+ import { usageAllows } from "./runtime-context.js";
12
+ import { AcpTransport, acpDecision, acpEnv, acpPermission } from "./acp-transport.js";
13
+ import { AntigravityTransport } from "./antigravity-transport.js";
14
+ import { ClaudeTransport, claudePermissions, claudeSandboxAvailable, customClearAliases, nativeCommandRefusal, skillPlugin, SKILL_PLUGIN, toolShapes } from "./claude-transport.js";
15
+ import { MAIL_BATCH_CHARS, MAIL_BODY_CHARS, publicEvent, renderMail, takeBatch, USER } from "./mailbox.js";
16
+ import { createCopy, gitEnvironment, reattachWorktree, reclaimCopies, reclaimWorktrees, removeCopy } from "./workspace.js";
17
+ import { OWN_START, processStartedAt, sameProcessAlive } from "./process-info.js";
18
+ import { PIN_KINDS, renderBoard, renderPin } from "./board.js";
19
+ import { inputLimitError, TOOL_INPUT, POUR_VARS } from "./input-limits.js";
20
+ import { CHOICES, isVietnamese, languageInstruction, words } from "./language.js";
21
+ import { ProviderRegistry, createProviderRegistry } from "./providers.js";
22
+ import { acpToolDetail, antigravityToolDetail, boundDetail, claudeToolDetail, clipText, codexToolCall, stripReadGutter, toolError, DETAIL_FILE_PATHS, DETAIL_TEXT_CHARS, DETAIL_WEB_RESULTS, ERROR_CHARS, TOOL_FAILED } from "./tool-detail.js";
23
+ import { checkpointPrompt, compactDue, compactSettings, contextFill, seedPrompt, COMPACT_DEFAULTS } from "./compact.js";
24
+ export {
25
+ ATTACHMENT_HEADER,
26
+ ATTACHMENT_ROUTES,
27
+ AcpTransport,
28
+ AntigravityTransport,
29
+ POLICY as CATALOG_POLICY,
30
+ REFRESH_MS as CATALOG_REFRESH_MS,
31
+ CHOICES,
32
+ COMPACT_DEFAULTS,
33
+ ClaudeTransport,
34
+ CodexTransport,
35
+ ConversationError,
36
+ DEFAULT_CLAUDE_MODEL,
37
+ DEFAULT_MODEL,
38
+ DEFAULT_TEAM,
39
+ DETAIL_FILE_PATHS,
40
+ DETAIL_TEXT_CHARS,
41
+ DETAIL_WEB_RESULTS,
42
+ ERROR_CHARS,
43
+ InstructionsAdapter,
44
+ MAIL_BATCH_CHARS,
45
+ MAIL_BODY_CHARS,
46
+ ModelCatalog,
47
+ OWN_START,
48
+ PIN_KINDS,
49
+ POUR_VARS,
50
+ ProviderRegistry,
51
+ SKILL_PLUGIN,
52
+ TOOL_FAILED,
53
+ TOOL_INPUT,
54
+ USER,
55
+ WorkspaceMutationError,
56
+ acpDecision,
57
+ acpEnv,
58
+ acpPermission,
59
+ acpSessionModels,
60
+ acpToolDetail,
61
+ activeCatalog,
62
+ antigravityProbe,
63
+ antigravityToolDetail,
64
+ attachmentStageDir,
65
+ boundDetail,
66
+ entries as catalogEntries,
67
+ checkpointPrompt,
68
+ claudePermissions,
69
+ claudeProbe,
70
+ claudeSandboxAvailable,
71
+ claudeToolDetail,
72
+ toolShapes as claudeToolShapes,
73
+ clipText,
74
+ codexProbe,
75
+ codexToolCall,
76
+ compactDue,
77
+ compactSettings,
78
+ contextFill,
79
+ createAlpRuntime,
80
+ createAttachmentStager,
81
+ createCopy,
82
+ createProviderRegistry,
83
+ customClearAliases,
84
+ feedAcpSession,
85
+ feedCatalog,
86
+ gitEnvironment,
87
+ inputLimitError,
88
+ isVietnamese,
89
+ languageInstruction,
90
+ liveFromContext,
91
+ liveProbes,
92
+ mergeCatalog,
93
+ models,
94
+ modes,
95
+ nativeCommandRefusal,
96
+ parseAgyModels,
97
+ pathActions,
98
+ processStartedAt,
99
+ publicEvent,
100
+ reattachWorktree,
101
+ reclaimCopies,
102
+ reclaimWorktrees,
103
+ removeCopy,
104
+ renderBoard,
105
+ renderMail,
106
+ renderPin,
107
+ resolveSession,
108
+ resourceUses,
109
+ sameProcessAlive,
110
+ seedPrompt,
111
+ setActiveCatalog,
112
+ skillDescription,
113
+ skillPlugin,
114
+ stagingExposure,
115
+ stripReadGutter,
116
+ takeBatch,
117
+ thinkingOptions,
118
+ thinkingOptionsFor,
119
+ toolError,
120
+ usageAllows,
121
+ words
122
+ };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Size caps for values that reach ALP from a provider or an external MCP server, checked
3
+ * before any schema walks them. Zod before 4.6.6 walks every element of an array before it
4
+ * reports the array's .max(), and a record has no bound at all, so a cap stated only in a
5
+ * schema still costs time and memory in proportion to the input. This walk stops at the first
6
+ * cap the value passes, so its own cost is bounded by the caps, not by the value.
7
+ */
8
+ export type InputLimits = {
9
+ /** UTF-8 bytes of the value as JSON, roughly: strings, keys and separators. */
10
+ bytes: number;
11
+ /** Array elements and object keys, counted over the whole value. */
12
+ items: number;
13
+ /** Arrays and objects inside each other; 1 admits a flat list or object of scalars. */
14
+ depth: number;
15
+ /** Characters in any one string, keys included. */
16
+ string: number;
17
+ };
18
+ /** The arguments of any ALP tool. The longest declared field is alp_delegate's 32,000-character task. */
19
+ export declare const TOOL_INPUT: InputLimits;
20
+ /** alp_task pour's vars: a flat object of text, one value per variable the formula declares. */
21
+ export declare const POUR_VARS: InputLimits;
22
+ /** A formula variable's name, as validateFormula admits it. */
23
+ export declare const VAR_NAME: RegExp;
24
+ /** The first cap `value` passes, as an error that names `what`, or undefined within them. */
25
+ export declare function inputLimitError(value: unknown, limits: InputLimits, what?: string): string | undefined;
@@ -0,0 +1,48 @@
1
+ // packages/runtime/src/input-limits.ts
2
+ var TOOL_INPUT = { bytes: 1024 * 1024, items: 5e3, depth: 8, string: 128 * 1024 };
3
+ var POUR_VARS = { bytes: 128 * 1024, items: 50, depth: 1, string: 2e3 };
4
+ var VAR_NAME = /^[\w-]{1,64}$/;
5
+ function inputLimitError(value, limits, what = "The input") {
6
+ let bytes = 0;
7
+ let items = 0;
8
+ const stack = [[value, 0]];
9
+ const tooLarge = `${what} is too large: over ${limits.bytes} bytes`;
10
+ const text = (string) => {
11
+ if (string.length > limits.string) return `${what} is too large: a text over ${limits.string} characters`;
12
+ bytes += Buffer.byteLength(string) + 2;
13
+ return bytes > limits.bytes ? tooLarge : void 0;
14
+ };
15
+ while (stack.length) {
16
+ const [current, depth] = stack.pop();
17
+ if (typeof current === "string") {
18
+ const error = text(current);
19
+ if (error) return error;
20
+ } else if (current !== null && typeof current === "object") {
21
+ if (depth >= limits.depth) return `${what} is too large: nested over ${limits.depth} levels deep`;
22
+ bytes += 2;
23
+ const list = Array.isArray(current);
24
+ const keys = list ? void 0 : Object.keys(current);
25
+ const size = list ? current.length : keys.length;
26
+ if (items + size > limits.items) return `${what} is too large: over ${limits.items} values`;
27
+ items += size;
28
+ for (let index = 0; index < size; index++) {
29
+ if (keys) {
30
+ const error = text(keys[index]);
31
+ if (error) return error;
32
+ }
33
+ bytes += 1;
34
+ stack.push([list ? current[index] : current[keys[index]], depth + 1]);
35
+ }
36
+ } else {
37
+ bytes += String(current).length;
38
+ }
39
+ if (bytes > limits.bytes) return tooLarge;
40
+ }
41
+ return void 0;
42
+ }
43
+ export {
44
+ POUR_VARS,
45
+ TOOL_INPUT,
46
+ VAR_NAME,
47
+ inputLimitError
48
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * What ALP itself writes for the user, in the user's language (ALPD §54): approvals,
3
+ * permission and trust questions, and notices. Vietnamese and English are written
4
+ * out; any other language gets English from ALP while agents write in it.
5
+ */
6
+ export declare const isVietnamese: (language: string) => boolean;
7
+ declare const en: {
8
+ approve: string;
9
+ reject: string;
10
+ answerLine: (agent: string) => string;
11
+ skill: (agent: string, replacing: boolean, file: string, roles: string, lessons: string[]) => string;
12
+ issue: (agent: string, create: boolean, issue: number | undefined, where: string) => string;
13
+ issueTitle: string;
14
+ skillRetire: (agent: string, name: string, file: string, retired: string, roles: string, users: string, reason: string) => string;
15
+ lessonCurate: (agent: string, changes: string) => string;
16
+ lessonRemove: string;
17
+ lessonAdd: string;
18
+ lessonScope: (scope: string, file: string) => string;
19
+ issueLabels: string;
20
+ trust: (project: string, names: string) => string;
21
+ trustYes: string;
22
+ trustNo: string;
23
+ allowOnce: string;
24
+ alwaysAllow: string;
25
+ deny: string;
26
+ permission: (agent: string, what: string, byRule: boolean, profile: string | undefined, mode: string, always: string | undefined) => string;
27
+ limitReached: (runtime: string, resetsAt: string | undefined, other: string | undefined, autoResume: boolean, kind: string) => string;
28
+ limitLifted: (runtime: string, kind: string) => string;
29
+ compacting: () => string;
30
+ compacted: (native: boolean) => string;
31
+ compactFailed: (reason: string) => string;
32
+ usageWarning: (runtime: string, used: string, resetsAt: string | undefined) => string;
33
+ /** The web app's answer to a Paseo feature ALP has not got yet (ALPD §62). */
34
+ inDevelopment: string;
35
+ resumed: (what: string, by: string, parked: boolean) => string;
36
+ diskFull: (reason: string) => string;
37
+ diskLow: (free: string) => string;
38
+ paused: (what: string, reason: string | undefined, runtime: string | undefined, now: boolean) => string;
39
+ };
40
+ export type Words = typeof en;
41
+ export declare function words(language: string): Words;
42
+ /** Every label a choice may be answered with, in any language ALP writes. */
43
+ export declare const CHOICES: {
44
+ trust: string[];
45
+ allowOnce: string[];
46
+ alwaysAllow: string[];
47
+ deny: string[];
48
+ };
49
+ /** The line every agent reads about the user's language. */
50
+ export declare function languageInstruction(language: string, agent: string, main: boolean): string;
51
+ export {};
@@ -0,0 +1,94 @@
1
+ // packages/runtime/src/language.ts
2
+ var isVietnamese = (language) => /^(vi|vie|vietnamese|tiếng việt|tieng viet)$/i.test(language.trim());
3
+ var en = {
4
+ approve: "Approve",
5
+ reject: "Reject",
6
+ answerLine: (agent) => `Answer Approve or Reject; any other answer goes back to ${agent} as feedback.`,
7
+ skill: (agent, replacing, file, roles, lessons) => `${agent} proposes a skill distilled from its lessons${replacing ? ", replacing the skill of that name" : ""}. Approve to save it as ${file}. Roles that get it: ${roles}.` + (lessons.length ? ` These lessons move into it and leave the lessons files:
8
+ ${lessons.map((lesson) => `- ${lesson}`).join("\n")}` : ""),
9
+ issue: (agent, create, issue, where) => `${agent} wants to ${create ? `open an issue in ${where}` : `comment on issue #${issue} in ${where}`}. It is posted with your GitHub account, and anyone who can see the repository can read it.`,
10
+ issueTitle: "Title",
11
+ skillRetire: (agent, name, file, retired, roles, users, reason) => `${agent} proposes to retire the skill ${name} (${file}): ${reason}
12
+ Approve to move it to ${retired}, where it is kept and can be restored, and remove it from ${roles ? `the roles that have it: ${roles}` : "role-skills.json (no role has it)"}. Nothing else changes.` + (users ? ` It is still named in agent.json by ${users}; it is not retired until they stop naming it.` : ""),
13
+ lessonCurate: (agent, changes) => `${agent} proposes to curate the lessons files. Approve to apply every change below at once; nothing else changes.
14
+
15
+ ${changes}`,
16
+ lessonRemove: "Remove",
17
+ lessonAdd: "Add",
18
+ lessonScope: (scope, file) => `${scope === "user" ? "User lessons" : "Project lessons"} (${file})`,
19
+ issueLabels: "Labels",
20
+ trust: (project, names) => `This project's hooks run shell commands from ${project} on your machine: ${names}. Trust this workspace's hooks? ALP asks once: after you agree, its hooks run without asking, including hooks added or changed later.`,
21
+ trustYes: "Trust this workspace",
22
+ trustNo: "Not now",
23
+ allowOnce: "Allow once",
24
+ alwaysAllow: "Always allow",
25
+ deny: "Deny",
26
+ permission: (agent, what, byRule, profile, mode, always) => `${agent} wants to ${what}. ` + (byRule ? `Its permission profile ${profile} asks you each time.` : `Its ${mode} mode does not allow that.`) + (always ? ` Always allow adds ${always} to profile ${profile}.` : ""),
27
+ limitReached: (runtime, resetsAt, other, autoResume, kind) => `${runtime} usage limit reached${resetsAt ? `; it resets ${resetsAt}` : ""}. ALP paused delegation to ${runtime} agents and parked their assignments${other ? `; ${other} agents keep working` : ""}. ${autoResume ? `ALP asks ${runtime} every minute and resumes it as soon as the limit lifts.` : `ALP asks ${runtime} every minute and tells you when the limit lifts; then run alp resume ${kind}.`}`,
28
+ limitLifted: (runtime, kind) => `${runtime} says its usage limit has lifted. Run alp resume ${kind} to continue its work.`,
29
+ compacting: () => "Compacting main's context: main writes a checkpoint first.",
30
+ compacted: (native) => `Main's context was compacted${native ? "" : " into a fresh conversation"}; it keeps its checkpoint and carries on.`,
31
+ compactFailed: (reason) => `Compacting main's context failed (${reason}); ALP tries again later.`,
32
+ usageWarning: (runtime, used, resetsAt) => `${runtime} has used ${used} of a usage window${resetsAt ? ` that resets ${resetsAt}` : ""}.`,
33
+ /** The web app's answer to a Paseo feature ALP has not got yet (ALPD §62). */
34
+ inDevelopment: "This feature is in development",
35
+ resumed: (what, by, parked) => `${what} resumed by ${by}.${parked ? " Parked assignments continue." : ""}`,
36
+ diskFull: (reason) => `Disk full: ${reason}. ALP paused its work and parked running assignments; it keeps answering. Free some space (alp doctor lists leftover worktrees); ALP checks every minute and continues by itself, or run alp resume.`,
37
+ diskLow: (free) => `Disk space is low: ${free} free. Free some space before it fills (alp doctor lists leftover worktrees); when it is full, ALP pauses its work.`,
38
+ paused: (what, reason, runtime, now) => `${what} paused by the user${reason ? `: ${reason}` : ""}. Delegation${runtime ? ` to ${runtime} agents` : ""} waits${now ? ", and running assignments park where they are" : "; running turns finish"}. alp resume continues.`
39
+ };
40
+ var viWhat = (what) => what.replace(/^run /, "ch\u1EA1y ").replace(/^change files under /, "s\u1EEDa file trong ").replace(/^change files/, "s\u1EEDa file").replace(/^use /, "d\xF9ng ");
41
+ var vi = {
42
+ approve: "Duy\u1EC7t",
43
+ reject: "T\u1EEB ch\u1ED1i",
44
+ answerLine: (agent) => `Ch\u1ECDn Duy\u1EC7t ho\u1EB7c T\u1EEB ch\u1ED1i; c\xE2u tr\u1EA3 l\u1EDDi kh\xE1c s\u1EBD \u0111\u01B0\u1EE3c g\u1EEDi l\u1EA1i cho ${agent} l\xE0m g\xF3p \xFD.`,
45
+ skill: (agent, replacing, file, roles, lessons) => `${agent} \u0111\u1EC1 xu\u1EA5t m\u1ED9t skill \u0111\xFAc k\u1EBFt t\u1EEB c\xE1c b\xE0i h\u1ECDc${replacing ? ", thay cho skill c\xF9ng t\xEAn" : ""}. Duy\u1EC7t \u0111\u1EC3 l\u01B0u th\xE0nh ${file}. C\xE1c vai \u0111\u01B0\u1EE3c d\xF9ng: ${roles}.` + (lessons.length ? ` C\xE1c b\xE0i h\u1ECDc sau chuy\u1EC3n v\xE0o skill v\xE0 r\u1EDDi kh\u1ECFi file b\xE0i h\u1ECDc:
46
+ ${lessons.map((lesson) => `- ${lesson}`).join("\n")}` : ""),
47
+ issue: (agent, create, issue, where) => `${agent} mu\u1ED1n ${create ? `m\u1EDF m\u1ED9t issue trong ${where}` : `b\xECnh lu\u1EADn v\xE0o issue #${issue} trong ${where}`}. N\u1ED9i dung \u0111\u01B0\u1EE3c \u0111\u0103ng b\u1EB1ng t\xE0i kho\u1EA3n GitHub c\u1EE7a b\u1EA1n, ai xem \u0111\u01B0\u1EE3c repository \u0111\u1EC1u \u0111\u1ECDc \u0111\u01B0\u1EE3c.`,
48
+ issueTitle: "Ti\xEAu \u0111\u1EC1",
49
+ skillRetire: (agent, name, file, retired, roles, users, reason) => `${agent} \u0111\u1EC1 xu\u1EA5t cho skill ${name} (${file}) ngh\u1EC9: ${reason}
50
+ Duy\u1EC7t \u0111\u1EC3 chuy\u1EC3n n\xF3 sang ${retired}, n\u01A1i n\xF3 v\u1EABn \u0111\u01B0\u1EE3c gi\u1EEF v\xE0 c\xF3 th\u1EC3 kh\xF4i ph\u1EE5c, v\xE0 b\u1ECF n\xF3 kh\u1ECFi ${roles ? `c\xE1c vai \u0111ang d\xF9ng: ${roles}` : "role-skills.json (kh\xF4ng vai n\xE0o d\xF9ng)"}. Kh\xF4ng thay \u0111\u1ED5i g\xEC kh\xE1c.` + (users ? ` N\xF3 v\u1EABn \u0111\u01B0\u1EE3c n\xEAu trong agent.json c\u1EE7a ${users}; n\xF3 ch\u1EC9 \u0111\u01B0\u1EE3c cho ngh\u1EC9 khi c\xE1c agent \u0111\xF3 th\xF4i n\xEAu n\xF3.` : ""),
51
+ lessonCurate: (agent, changes) => `${agent} \u0111\u1EC1 xu\u1EA5t r\xE0 so\xE1t file b\xE0i h\u1ECDc. Duy\u1EC7t \u0111\u1EC3 \xE1p d\u1EE5ng c\xF9ng l\xFAc m\u1ECDi thay \u0111\u1ED5i d\u01B0\u1EDBi \u0111\xE2y; kh\xF4ng thay \u0111\u1ED5i g\xEC kh\xE1c.
52
+
53
+ ${changes}`,
54
+ lessonRemove: "B\u1ECF",
55
+ lessonAdd: "Th\xEAm",
56
+ lessonScope: (scope, file) => `${scope === "user" ? "B\xE0i h\u1ECDc c\u1EE7a ng\u01B0\u1EDDi d\xF9ng" : "B\xE0i h\u1ECDc c\u1EE7a project"} (${file})`,
57
+ issueLabels: "Nh\xE3n",
58
+ trust: (project, names) => `C\xE1c hook c\u1EE7a project n\xE0y ch\u1EA1y l\u1EC7nh shell t\u1EEB ${project} tr\xEAn m\xE1y c\u1EE7a b\u1EA1n: ${names}. Tin c\u1EADy c\xE1c hook c\u1EE7a workspace n\xE0y? ALP ch\u1EC9 h\u1ECFi m\u1ED9t l\u1EA7n: khi b\u1EA1n \u0111\u1ED3ng \xFD, c\xE1c hook ch\u1EA1y m\xE0 kh\xF4ng h\u1ECFi l\u1EA1i, k\u1EC3 c\u1EA3 hook th\xEAm ho\u1EB7c s\u1EEDa sau n\xE0y.`,
59
+ trustYes: "Tin c\u1EADy workspace n\xE0y",
60
+ trustNo: "\u0110\u1EC3 sau",
61
+ allowOnce: "Cho ph\xE9p l\u1EA7n n\xE0y",
62
+ alwaysAllow: "Lu\xF4n cho ph\xE9p",
63
+ deny: "T\u1EEB ch\u1ED1i",
64
+ permission: (agent, what, byRule, profile, mode, always) => `${agent} mu\u1ED1n ${viWhat(what)}. ` + (byRule ? `H\u1ED3 s\u01A1 quy\u1EC1n ${profile} c\u1EE7a n\xF3 y\xEAu c\u1EA7u h\u1ECFi b\u1EA1n m\u1ED7i l\u1EA7n.` : `Ch\u1EBF \u0111\u1ED9 ${mode} c\u1EE7a n\xF3 kh\xF4ng cho ph\xE9p vi\u1EC7c n\xE0y.`) + (always ? ` Lu\xF4n cho ph\xE9p s\u1EBD th\xEAm ${always} v\xE0o h\u1ED3 s\u01A1 ${profile}.` : ""),
65
+ limitReached: (runtime, resetsAt, other, autoResume, kind) => `${runtime} \u0111\xE3 h\u1EBFt h\u1EA1n m\u1EE9c s\u1EED d\u1EE5ng${resetsAt ? `; h\u1EA1n m\u1EE9c \u0111\u1EB7t l\u1EA1i l\xFAc ${resetsAt}` : ""}. ALP t\u1EA1m d\u1EEBng giao vi\u1EC7c cho c\xE1c agent ${runtime} v\xE0 t\u1EA1m gi\u1EEF vi\u1EC7c c\u1EE7a ch\xFAng${other ? `; c\xE1c agent ${other} v\u1EABn l\xE0m ti\u1EBFp` : ""}. ${autoResume ? `ALP h\u1ECFi ${runtime} m\u1ED7i ph\xFAt v\xE0 t\u1EF1 ch\u1EA1y l\u1EA1i ngay khi c\xF3 h\u1EA1n m\u1EE9c.` : `ALP h\u1ECFi ${runtime} m\u1ED7i ph\xFAt v\xE0 b\xE1o khi c\xF3 h\u1EA1n m\u1EE9c tr\u1EDF l\u1EA1i; khi \u0111\xF3 ch\u1EA1y alp resume ${kind}.`}`,
66
+ limitLifted: (runtime, kind) => `${runtime} b\xE1o \u0111\xE3 c\xF3 h\u1EA1n m\u1EE9c tr\u1EDF l\u1EA1i. Ch\u1EA1y alp resume ${kind} \u0111\u1EC3 l\xE0m ti\u1EBFp vi\u1EC7c c\u1EE7a n\xF3.`,
67
+ compacting: () => "\u0110ang compact context c\u1EE7a main: main vi\u1EBFt checkpoint tr\u01B0\u1EDBc.",
68
+ compacted: (native) => `Context c\u1EE7a main \u0111\xE3 \u0111\u01B0\u1EE3c compact${native ? "" : " sang m\u1ED9t cu\u1ED9c h\u1ED9i tho\u1EA1i m\u1EDBi"}; main gi\u1EEF checkpoint v\xE0 l\xE0m ti\u1EBFp.`,
69
+ compactFailed: (reason) => `Compact context c\u1EE7a main th\u1EA5t b\u1EA1i (${reason}); ALP s\u1EBD th\u1EED l\u1EA1i sau.`,
70
+ usageWarning: (runtime, used, resetsAt) => `${runtime} \u0111\xE3 d\xF9ng ${used} h\u1EA1n m\u1EE9c c\u1EE7a k\u1EF3 n\xE0y${resetsAt ? `, k\u1EF3 \u0111\u1EB7t l\u1EA1i l\xFAc ${resetsAt}` : ""}.`,
71
+ inDevelopment: "T\xEDnh n\u0103ng \u0111ang ph\xE1t tri\u1EC3n",
72
+ resumed: (what, by, parked) => `${what} \u0111\xE3 ch\u1EA1y l\u1EA1i, b\u1EDFi ${by}.${parked ? " C\xE1c vi\u1EC7c \u0111ang t\u1EA1m gi\u1EEF \u0111\u01B0\u1EE3c l\xE0m ti\u1EBFp." : ""}`,
73
+ diskFull: (reason) => `\u0110\u0129a \u0111\u1EA7y: ${reason === "the disk is full" ? "\u0111\u0129a h\u1EBFt dung l\u01B0\u1EE3ng" : reason === "the disk is read-only" ? "\u0111\u0129a ch\u1EC9 \u0111\u1ECDc" : reason}. ALP \u0111\xE3 t\u1EA1m d\u1EEBng c\xF4ng vi\u1EC7c v\xE0 t\u1EA1m gi\u1EEF c\xE1c vi\u1EC7c \u0111ang ch\u1EA1y; ALP v\u1EABn tr\u1EA3 l\u1EDDi. H\xE3y gi\u1EA3i ph\xF3ng dung l\u01B0\u1EE3ng (alp doctor li\u1EC7t k\xEA c\xE1c worktree c\xF2n s\xF3t); ALP ki\u1EC3m tra m\u1ED7i ph\xFAt v\xE0 t\u1EF1 l\xE0m ti\u1EBFp, ho\u1EB7c ch\u1EA1y alp resume.`,
74
+ diskLow: (free) => `\u0110\u0129a s\u1EAFp \u0111\u1EA7y: c\xF2n ${free} tr\u1ED1ng. H\xE3y gi\u1EA3i ph\xF3ng dung l\u01B0\u1EE3ng tr\u01B0\u1EDBc khi \u0111\u1EA7y (alp doctor li\u1EC7t k\xEA c\xE1c worktree c\xF2n s\xF3t); khi \u0111\u0129a \u0111\u1EA7y, ALP s\u1EBD t\u1EA1m d\u1EEBng c\xF4ng vi\u1EC7c.`,
75
+ paused: (what, reason, runtime, now) => `${what} \u0111\xE3 b\u1ECB ng\u01B0\u1EDDi d\xF9ng t\u1EA1m d\u1EEBng${reason ? `: ${reason}` : ""}. Vi\u1EC7c giao${runtime ? ` cho c\xE1c agent ${runtime}` : ""} ph\u1EA3i ch\u1EDD${now ? ", c\xE1c vi\u1EC7c \u0111ang ch\u1EA1y \u0111\u01B0\u1EE3c t\u1EA1m gi\u1EEF t\u1EA1i ch\u1ED7" : "; c\xE1c l\u01B0\u1EE3t \u0111ang ch\u1EA1y v\u1EABn ch\u1EA1y h\u1EBFt"}. Ch\u1EA1y alp resume \u0111\u1EC3 ti\u1EBFp t\u1EE5c.`
76
+ };
77
+ function words(language) {
78
+ return isVietnamese(language) ? vi : en;
79
+ }
80
+ var CHOICES = {
81
+ trust: [en.trustYes, vi.trustYes].map((label) => label.toLowerCase()),
82
+ allowOnce: [en.allowOnce, vi.allowOnce].map((label) => label.toLowerCase()),
83
+ alwaysAllow: [en.alwaysAllow, vi.alwaysAllow].map((label) => label.toLowerCase()),
84
+ deny: [en.deny, vi.deny].map((label) => label.toLowerCase())
85
+ };
86
+ function languageInstruction(language, agent, main) {
87
+ return main ? `The user reads ${language}. Write in ${language} everything the user reads: your replies, questions you ask with alp_ask (and their options), approval requests and what you say about them, gate notes, and the titles and descriptions of tasks you create. Briefs, handoffs and mail between agents may use any language. GitHub issues and comments follow the repository's language; tell the user about them in ${language}.` : agent === "supervisor" ? `The user reads ${language}: main must write everything the user reads in ${language}.` : `The user reads ${language}. A question you put to the user with alp_ask, and its options, must be in ${language}; briefs, handoffs and mail between agents may use any language.`;
88
+ }
89
+ export {
90
+ CHOICES,
91
+ isVietnamese,
92
+ languageInstruction,
93
+ words
94
+ };