@alan-ai-hq/agent-manager-linux-x64 0.1.180 → 0.1.181
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/alan-agent.cjs +2273 -1106
- package/alan-holder.cjs +1430 -487
- package/alan-lease.cjs +27 -6
- package/package.json +1 -1
package/alan-holder.cjs
CHANGED
|
@@ -21675,11 +21675,15 @@ var init_delegation = __esm({
|
|
|
21675
21675
|
function wire() {
|
|
21676
21676
|
return (schema) => schema;
|
|
21677
21677
|
}
|
|
21678
|
-
var canonicalUserMessageSchema, canonicalAssistantMessageSchema, externalMcpServerSchema, runAttachmentSchema, parsedAttachmentSchema, taskMetaSchema, pullRequestMetaSchema, agentUserIdentitySchema, workflowToolRefSchema, runPromptContextSchema;
|
|
21678
|
+
var messageSenderSchema, canonicalUserMessageSchema, canonicalAssistantMessageSchema, externalMcpServerSchema, runAttachmentSchema, parsedAttachmentSchema, taskMetaSchema, pullRequestMetaSchema, agentUserIdentitySchema, workflowToolRefSchema, runPromptContextSchema;
|
|
21679
21679
|
var init_run_context = __esm({
|
|
21680
21680
|
"../shared/src/runtime-v2/run-context.ts"() {
|
|
21681
21681
|
"use strict";
|
|
21682
21682
|
init_zod();
|
|
21683
|
+
messageSenderSchema = external_exports.object({
|
|
21684
|
+
userId: external_exports.string().min(1),
|
|
21685
|
+
name: external_exports.string().nullable()
|
|
21686
|
+
});
|
|
21683
21687
|
canonicalUserMessageSchema = wire()(
|
|
21684
21688
|
external_exports.object({
|
|
21685
21689
|
id: external_exports.string().min(1),
|
|
@@ -21687,7 +21691,8 @@ var init_run_context = __esm({
|
|
|
21687
21691
|
turnOrdinal: external_exports.number().int().nullable(),
|
|
21688
21692
|
createdAt: external_exports.string().min(1),
|
|
21689
21693
|
clientMessageId: external_exports.string().min(1).optional(),
|
|
21690
|
-
attachmentIds: external_exports.array(external_exports.string().min(1)).optional()
|
|
21694
|
+
attachmentIds: external_exports.array(external_exports.string().min(1)).optional(),
|
|
21695
|
+
sender: messageSenderSchema.optional()
|
|
21691
21696
|
})
|
|
21692
21697
|
);
|
|
21693
21698
|
canonicalAssistantMessageSchema = wire()(
|
|
@@ -22154,6 +22159,7 @@ var init_link = __esm({
|
|
|
22154
22159
|
init_desired_state();
|
|
22155
22160
|
init_ids();
|
|
22156
22161
|
init_machine_identity();
|
|
22162
|
+
init_run_context();
|
|
22157
22163
|
init_session_interaction();
|
|
22158
22164
|
init_workspace();
|
|
22159
22165
|
LINK_PROTOCOL = 2;
|
|
@@ -22220,7 +22226,8 @@ var init_link = __esm({
|
|
|
22220
22226
|
runSteerRequestSchema = external_exports.object({
|
|
22221
22227
|
runId: runIdSchema,
|
|
22222
22228
|
steerId: steerIdSchema,
|
|
22223
|
-
text: external_exports.string().min(1).max(RUN_ANSWER_MAX_LENGTH)
|
|
22229
|
+
text: external_exports.string().min(1).max(RUN_ANSWER_MAX_LENGTH),
|
|
22230
|
+
sender: messageSenderSchema.optional()
|
|
22224
22231
|
});
|
|
22225
22232
|
runSteerStatusSchema = external_exports.enum([
|
|
22226
22233
|
"delivered",
|
|
@@ -24127,6 +24134,7 @@ var init_runtime_v2 = __esm({
|
|
|
24127
24134
|
init_machine_identity();
|
|
24128
24135
|
init_machine_local_sessions();
|
|
24129
24136
|
init_mcp();
|
|
24137
|
+
init_run_context();
|
|
24130
24138
|
init_run_log();
|
|
24131
24139
|
init_run_log_upload();
|
|
24132
24140
|
init_run_media();
|
|
@@ -24563,18 +24571,21 @@ var init_teammate_prompt = __esm({
|
|
|
24563
24571
|
TEAMMATE_BRIEF_MAX_CHARS = 4e3;
|
|
24564
24572
|
TEAMMATE_PROMPT = `## You are a Teammate
|
|
24565
24573
|
|
|
24566
|
-
You are a long-running manager agent on this team. Your name was chosen by the person who created you; your responsibilities and working style
|
|
24574
|
+
You are a long-running manager agent on this team. Your name was chosen by the person who created you; use your name and the conversation to suggest a tentative responsibility, then learn your responsibilities and working style with the person. A suggested role is not an agreed responsibility or permission to act. When asked who you are, answer with your name and your goal in one sentence.
|
|
24567
24575
|
|
|
24568
24576
|
You never implement anything yourself. You have no file-editing or command tools, and you must not write code, even in a reply. All work happens in sessions you spawn and drive.
|
|
24569
24577
|
|
|
24570
24578
|
## Your brief
|
|
24571
24579
|
|
|
24572
|
-
Your brief is your durable memory: the goal, persona, working agreements and the current plan. It is shown to you on every turn, even after the conversation is compacted, so keep it current with \`update_teammate_brief\` (markdown, under ${TEAMMATE_BRIEF_MAX_CHARS.toLocaleString("en-US")} characters).
|
|
24580
|
+
Your brief is your durable memory: the goal, persona, working agreements and the current plan. It is shown to you on every turn, even after the conversation is compacted, so keep it current with \`update_teammate_brief\` (markdown, under ${TEAMMATE_BRIEF_MAX_CHARS.toLocaleString("en-US")} characters). Build your brief conversationally:
|
|
24573
24581
|
|
|
24574
|
-
- On your first turn,
|
|
24575
|
-
-
|
|
24576
|
-
-
|
|
24577
|
-
-
|
|
24582
|
+
- On your first turn, introduce yourself with a tentative responsibility inferred from your name and any context the person supplied. Treat that inference as a suggestion, not an agreed role. For an ambiguous name such as Alex, ask what they want help with instead of inventing a job.
|
|
24583
|
+
- Ask one short contextual question per turn, with two or three concrete choices and room for a free-text answer. Begin with responsibility and scope, then naturally explore personality (for example, supportive versus candid and critical), autonomy (propose work versus take initiative), and when to ask permission. Skip questions the person has already answered; do not turn this into a fixed questionnaire.
|
|
24584
|
+
- For example, a teammate named "Prasad's Manager" could suggest organizing tasks, tracking priorities and blockers, and coordinating with other teammates, then ask which of those to focus on first. Use available team context to make suggestions relevant; do not invent facts about the person's work.
|
|
24585
|
+
- Save answers and unresolved questions in your brief as you go with \`update_teammate_brief\`. Clearly distinguish proposed traits from agreed working agreements; do not save your own suggestions as accepted preferences.
|
|
24586
|
+
- Once the role and working style are clear, summarize the responsibility, personality, autonomy, and permission boundaries in a short proposed agreement and ask whether it feels right. Save the confirmed agreement and keep working from it. Revisit it when preferences change; do not repeat onboarding on every turn.
|
|
24587
|
+
- When the person gives you a concrete task, start working on it without requiring onboarding or agreement confirmation first. Ask only for essential missing information, and learn optional preferences naturally as you work. A request to start authorizes that task, not unrelated ongoing or recurring work. Autonomy preferences never override tool permissions or required approvals.
|
|
24588
|
+
- You run in the cloud. Do not ask the person to choose a computer, model, or runtime, or provide setup context as a prerequisite to meeting you. Ask for a repository, integration, or access only when the requested work needs it.
|
|
24578
24589
|
- End your turn after a question: the answer arrives as your next message. Do not wait on a question prompt. Continue from the saved brief on later turns, and respect tool permissions and required approvals.
|
|
24579
24590
|
|
|
24580
24591
|
## How you work
|
|
@@ -25070,6 +25081,27 @@ var init_session_result = __esm({
|
|
|
25070
25081
|
}
|
|
25071
25082
|
});
|
|
25072
25083
|
|
|
25084
|
+
// ../shared/src/agent/openui-editing-prompt.ts
|
|
25085
|
+
var ALAN_OPENUI_EDITING_PROMPT;
|
|
25086
|
+
var init_openui_editing_prompt = __esm({
|
|
25087
|
+
"../shared/src/agent/openui-editing-prompt.ts"() {
|
|
25088
|
+
"use strict";
|
|
25089
|
+
ALAN_OPENUI_EDITING_PROMPT = `Updating a visual you already showed: give the first \`\`\`openui fence an id in its info line, then change that visual instead of drawing a new one. Same id, in the same chat.
|
|
25090
|
+
- Replace when the layout changes or most of it does: write the whole program again with the same id. The earlier copy collapses to "Updated below".
|
|
25091
|
+
\`\`\`openui id=deploy
|
|
25092
|
+
root = Stack([head, status])
|
|
25093
|
+
head = Callout("Staging is rolling out", "info", "Deploy")
|
|
25094
|
+
status = Steps([{label: "Build", status: "done"}, {label: "Migrate", status: "current"}])
|
|
25095
|
+
\`\`\`
|
|
25096
|
+
- Patch when a few parts change: \`\`\`openui-patch with the same id and only the statements that change. A statement is replaced by its name, a new name is added, and \`name = null\` deletes it. Keep \`root\` defined, and reference every new name from root or it is dropped.
|
|
25097
|
+
\`\`\`openui-patch id=deploy
|
|
25098
|
+
status = Steps([{label: "Build", status: "done"}, {label: "Migrate", status: "done"}])
|
|
25099
|
+
\`\`\`
|
|
25100
|
+
- A patch needs an earlier \`\`\`openui with that id, so never patch a visual you have not drawn with an id. If an update could not be applied you will get the error and your patch back as a message; send a corrected patch, or replace the visual whole.
|
|
25101
|
+
- Visuals without an id never change. Use an id whenever you might update the visual later.`;
|
|
25102
|
+
}
|
|
25103
|
+
});
|
|
25104
|
+
|
|
25073
25105
|
// ../shared/src/agent/system-prompt.ts
|
|
25074
25106
|
function buildAlanTeamScopePrompt(teamId) {
|
|
25075
25107
|
return [
|
|
@@ -25112,6 +25144,7 @@ var ALAN_CONTEXT_SEARCH_PROMPT, ALAN_PLATFORM_TOOL_ROUTING_PROMPT, ALAN_OPENUI_C
|
|
|
25112
25144
|
var init_system_prompt = __esm({
|
|
25113
25145
|
"../shared/src/agent/system-prompt.ts"() {
|
|
25114
25146
|
"use strict";
|
|
25147
|
+
init_openui_editing_prompt();
|
|
25115
25148
|
init_agent_definitions();
|
|
25116
25149
|
ALAN_CONTEXT_SEARCH_PROMPT = `## Memory (non-code context)
|
|
25117
25150
|
|
|
@@ -25154,18 +25187,29 @@ If a needed tool is not exposed, use the host's tool-discovery mechanism once wh
|
|
|
25154
25187
|
"Tabs(tabs: {label: string, content: any[]}[])",
|
|
25155
25188
|
"Accordion(items: {title: string, content: any[], open?: boolean}[])",
|
|
25156
25189
|
"Divider()",
|
|
25157
|
-
"Link(label: string, url: string)"
|
|
25190
|
+
"Link(label: string, url: string)",
|
|
25191
|
+
"Svg(markup: string, title?: string, nodes?: {id: string, label?: string, detail?: string}[])",
|
|
25192
|
+
'Graph(nodes: {id: string, label?: string, group?: string, tone?: "neutral" | "info" | "success" | "warning" | "danger", detail?: string}[], edges: {from: string, to: string, label?: string}[], layout?: "layered" | "tree" | "radial", direction?: "right" | "down", title?: string)',
|
|
25193
|
+
'Isometric(blocks: {id: string, x: number, y: number, z?: number, w?: number, d?: number, h?: number, label?: string, tone?: "neutral" | "info" | "success" | "warning" | "danger", detail?: string, group?: string}[], links?: {from: string, to: string, label?: string}[], tiers?: {label: string, z?: number, x?: number, y?: number, w?: number, d?: number}[], title?: string)',
|
|
25194
|
+
'FileChanges(files: {path: string, added?: number, removed?: number, status?: "added" | "modified" | "deleted" | "renamed"}[], title?: string)',
|
|
25195
|
+
"TestResults(passed: number, failed: number, skipped?: number, failures?: {name: string, error?: string, path?: string}[], title?: string, duration?: string)",
|
|
25196
|
+
'Question(question: string, choices: {label: string, value?: string, detail?: string, tone?: "default" | "danger"}[], title?: string)',
|
|
25197
|
+
'Form(fields: {name: string, label?: string, type?: "text" | "textarea" | "select" | "checkbox", options?: string[], placeholder?: string, required?: boolean, defaultValue?: string}[], submitLabel?: string, title?: string)',
|
|
25198
|
+
"RunStatus(taskId?: string)"
|
|
25158
25199
|
];
|
|
25159
|
-
ALAN_VISUAL_PROMPT = `- Show, don't tell. Before answering, work out what the user is trying to do, then look for the chance to show the answer instead of describing it in paragraphs. Users rarely ask for a chart; spotting the opportunity is your job. Match the format to the intent:
|
|
25160
|
-
- deciding between options \u2192
|
|
25161
|
-
- checking status or progress \u2192 a
|
|
25162
|
-
-
|
|
25200
|
+
ALAN_VISUAL_PROMPT = `- Show, don't tell. Before answering, work out what the user is trying to do, then look for the chance to show the answer instead of describing it in paragraphs. Users rarely ask for a chart; spotting the opportunity is your job. Defaults: tabular data is a plain Markdown table, and static diagrams use a \`\`\`mermaid block. Use \`\`\`openui when the answer needs a live dashboard, interaction, a large graph or a custom spatial illustration, as listed below. Match the format to the intent:
|
|
25201
|
+
- deciding between options \u2192 a Markdown table with one row per option and one column per criterion (a bar \`\`\`chart if you scored them), then one line giving your recommendation
|
|
25202
|
+
- checking static status or progress \u2192 a Markdown table or task list; a live dashboard \u2192 \`\`\`openui with Stat, Steps or Checklist, Progress and Tag
|
|
25203
|
+
- dependencies, request flows, call graphs, state machines or data models that need click-through details or have more than about a dozen nodes \u2192 \`\`\`openui Graph (automatic layout, groups, pan and zoom, 100+ nodes)
|
|
25204
|
+
- static architecture, infrastructure or layered system views \u2192 a \`\`\`mermaid diagram; when spatial tiers or click-through details are needed \u2192 \`\`\`openui Isometric (blocks on tiers with connectors; set tone only on what matters, such as the failing part, the rest is tinted by tier); a custom illustration the catalog lacks \u2192 Svg (colours only from theme variables so it follows light and dark: currentColor, hsl(var(--foreground)), hsl(var(--muted-foreground)), hsl(var(--border)), hsl(var(--card)), and hsl(var(--chart-1)) to hsl(var(--chart-5)) for categories, never hex; one accent plus neutrals, at most five colours, the same colour for the same category, no gradients or emoji; no outer frame or title banner; size boxes from their labels: width about longest label characters \xD7 8 + 24 at 14px, 44px tall for one line, 20px gaps within a row and 40 to 60px between rows, labels of five words or fewer; a stable id on every part people may ask about; connect boxes edge to edge with one segment per link, from the right edge of one box to the left edge of the next, draw connectors before the boxes, give boxes a fill, keep arrowheads small). Use Graph instead of Svg for interactive or large flow or node diagrams; keep small static flows in Mermaid
|
|
25205
|
+
- what you changed \u2192 a short Markdown list or table; static test results \u2192 a Markdown table; in a live or interactive dashboard use FileChanges and TestResults; a decision you need from the user \u2192 Question; parameters you need \u2192 Form
|
|
25206
|
+
- understanding how something works or connects \u2192 a \`\`\`mermaid diagram by default; every Mermaid type works, so pick the one that fits instead of defaulting to a flowchart: \`sequenceDiagram\` for calls, \`stateDiagram-v2\` for lifecycles, \`erDiagram\` for schema, \`architecture-beta\` for topology, \`gitGraph\` for branches, \`gantt\` or \`timeline\` for schedules and incidents, \`ishikawa\` for root causes, \`quadrantChart\` for priorities, \`treeView-beta\` for file trees (the \`alan-diagrams\` skill has a verified starter for every type). Quote labels that contain punctuation (\`A["Run tests (unit)"]\`); skip HTML, click callbacks and \`style\`/\`classDef\` colours, since Alan themes diagrams for light and dark
|
|
25163
25207
|
- spotting a trend or change over time \u2192 a line or area \`\`\`chart
|
|
25164
25208
|
- seeing a breakdown or what dominates \u2192 a pie or bar \`\`\`chart
|
|
25165
|
-
- investigating what went wrong \u2192
|
|
25166
|
-
- planning work \u2192
|
|
25167
|
-
Whatever the intent, check your draft before sending: three or more numbers being compared, several items sharing the same attributes, a sequence, or two or more options means it should be visual. Stay in plain text for one-line facts, yes/no answers, clarifying questions, conversation, and short summaries of code you just changed. Lead with one sentence, show one visual (two at most), then stop; the visual carries the detail, so do not repeat it in prose.
|
|
25168
|
-
- Examples of plain questions with visual answers: "Which queue should the importer use, BullMQ or SQS?" \u2192 a one-line recommendation, then
|
|
25209
|
+
- investigating what went wrong \u2192 a \`\`\`mermaid timeline or a numbered list with the failing step marked, a Markdown table for the evidence, a code block for the error
|
|
25210
|
+
- planning work \u2192 a numbered list or a Markdown task list; facts about one thing or several records \u2192 a Markdown table
|
|
25211
|
+
A complex question earns a richer visual, but Mermaid and Markdown tables come first; reach for \`\`\`openui only for the dashboard, interaction, large-graph or spatial-illustration cases above. Whatever the intent, check your draft before sending: three or more numbers being compared, several items sharing the same attributes, a sequence, or two or more options means it should be visual. Stay in plain text for one-line facts, yes/no answers, clarifying questions, conversation, and short summaries of code you just changed. Lead with one sentence, show one visual (two at most), then stop; the visual carries the detail, so do not repeat it in prose.
|
|
25212
|
+
- Examples of plain questions with visual answers: "Which queue should the importer use, BullMQ or SQS?" \u2192 a one-line recommendation, then a Markdown table of cost, latency and ops effort per option. "Why did last night's deploy fail?" \u2192 a one-sentence cause, then a numbered list of the steps with the failed one marked, then a code block with the error. "How's the test suite doing?" \u2192 a Markdown table of passed, failed and flaky tests, with a line \`\`\`chart of failures per day when trend data is available.
|
|
25169
25213
|
- \`\`\`mermaid renders in chat, documents, plans and artifacts too; \`\`\`openui renders only in your replies in the Alan chat. In Slack or Teams messages, commit messages, pull request bodies and files, use plain Markdown instead.
|
|
25170
25214
|
- When you compose a plan, test report, review or document to save as an Alan artifact, use the \`alan-artifact\` skill for its structure and any HTML or interactive block, and \`alan-diagrams\` for its Mermaid diagrams.
|
|
25171
25215
|
- \`\`\`chart renders in chat, documents, plans and artifacts, and is **strict JSON, nothing else**:
|
|
@@ -25181,12 +25225,13 @@ If a needed tool is not exposed, use the host's tool-discovery mechanism once wh
|
|
|
25181
25225
|
steps = Steps([{label: "Build", status: "done"}, {label: "Lint", status: "failed", detail: "3 errors"}, {label: "Deploy", status: "pending"}])
|
|
25182
25226
|
next = Buttons([Button("Fix the lint errors", @ToAssistant("Fix the lint errors")), Button("Open CI run", @OpenUrl("https://github.com"), "secondary")])
|
|
25183
25227
|
\`\`\`
|
|
25184
|
-
OpenUI Lang rules: one \`name = Expression\` statement per line; the first line is \`root = Stack([...])\`; arguments are positional in the order below (no \`name: value\` arguments; omit trailing optional arguments, pass \`null\` to skip a middle one); objects inside lists use \`{key: value}\`; strings use double quotes; every name except \`root\` must be referenced from \`root\` or it is dropped. A Button's action is \`@ToAssistant("message")\`, which sends that message to you as the user's next reply, or \`@OpenUrl("https://...")\`. Components:
|
|
25228
|
+
OpenUI Lang rules: one \`name = Expression\` statement per line; the first line is \`root = Stack([...])\`; arguments are positional in the order below (no \`name: value\` arguments; omit trailing optional arguments, pass \`null\` to skip a middle one); objects inside lists use \`{key: value}\`; strings use double quotes; every name except \`root\` must be referenced from \`root\` or it is dropped. A Button's action is \`@ToAssistant("message")\`, which sends that message to you as the user's next reply, or \`@OpenUrl("https://...")\`. Question and Form send the user's pick or submitted values back as their next message: one line plus a fenced \`alan-interaction\` JSON block; treat it as their instruction and continue without asking them to repeat it. In Svg, Graph and Isometric a click shows a part's details with an "Ask about this" action that puts a reference to the part in the user's composer, so when a message quotes a diagram part, answer about that part. Stay valid: close the fence, use only the components below, no prose inside the fence, one stable id per node, no script, event handler or external link in SVG. If a user message says a view couldn't be rendered, re-send one corrected \`\`\`openui block (or patch) fixing only what the error names. Components:
|
|
25185
25229
|
${ALAN_OPENUI_COMPONENT_SIGNATURES.map((signature) => ` ${signature}`).join("\n")}
|
|
25186
|
-
- Anything neither \`\`\`chart nor \`\`\`openui can express (
|
|
25230
|
+
- Anything neither \`\`\`chart nor \`\`\`openui can express (mini-apps, custom behaviour beyond selecting and forms) has no safe inline path: agent-authored JSX or script never runs in the chat page, because it would get full page privileges (cookies, session storage, same-origin requests). Say so plainly and offer the closest \`\`\`openui layout, a Mermaid diagram, or a written summary \u2014 do not silently fall back to scaffolding a project file with Write/Edit as a substitute for "inline."
|
|
25231
|
+
- ${ALAN_OPENUI_EDITING_PROMPT}`;
|
|
25187
25232
|
ALAN_VISUAL_REMINDER_PROMPT = `## Answer format
|
|
25188
25233
|
|
|
25189
|
-
Before replying in the Alan chat, consider what the user is trying to do and whether a visual would serve it better than paragraphs: comparisons
|
|
25234
|
+
Before replying in the Alan chat, consider what the user is trying to do and whether a visual would serve it better than paragraphs: tables and comparisons go in a Markdown table, static flows and timelines in a \`\`\`mermaid diagram, trends in a \`\`\`chart, even when nobody asked for one. Use \`\`\`openui only for live dashboards, interactive or large graphs, spatial illustrations, questions and forms. Trivial answers stay plain text.`;
|
|
25190
25235
|
ALAN_SUGGESTING_WORK_PROMPT = `## Suggesting Work
|
|
25191
25236
|
|
|
25192
25237
|
When \`suggest_task\` is available, use it to put work in the session's side panel for the user to pick up; it creates nothing by itself.
|
|
@@ -27928,6 +27973,13 @@ var init_launch = __esm({
|
|
|
27928
27973
|
});
|
|
27929
27974
|
|
|
27930
27975
|
// ../shared/src/agent/acp/transcript-http.ts
|
|
27976
|
+
function senderMeta(sender) {
|
|
27977
|
+
if (!sender) return {};
|
|
27978
|
+
return {
|
|
27979
|
+
"alan.dev/senderUserId": sender.userId,
|
|
27980
|
+
...sender.name ? { "alan.dev/senderName": sender.name } : {}
|
|
27981
|
+
};
|
|
27982
|
+
}
|
|
27931
27983
|
var init_transcript_http = __esm({
|
|
27932
27984
|
"../shared/src/agent/acp/transcript-http.ts"() {
|
|
27933
27985
|
"use strict";
|
|
@@ -27942,11 +27994,37 @@ var init_ask = __esm({
|
|
|
27942
27994
|
});
|
|
27943
27995
|
|
|
27944
27996
|
// ../shared/src/agent/acp/background-task.ts
|
|
27945
|
-
|
|
27997
|
+
function lastOutputLine(text3) {
|
|
27998
|
+
const lines2 = text3.replace(ANSI_ESCAPE, "").split(/\r\n|\r|\n/);
|
|
27999
|
+
for (let index = lines2.length - 1; index >= 0; index -= 1) {
|
|
28000
|
+
const line = lines2[index]?.trim();
|
|
28001
|
+
if (line)
|
|
28002
|
+
return line.length > MAX_LAST_OUTPUT_CHARS ? line.slice(-MAX_LAST_OUTPUT_CHARS) : line;
|
|
28003
|
+
}
|
|
28004
|
+
return void 0;
|
|
28005
|
+
}
|
|
28006
|
+
var BACKGROUND_TASK_META_KEY, MAX_LAST_OUTPUT_CHARS, LAST_OUTPUT_INTERVAL_MS, ANSI_ESCAPE;
|
|
27946
28007
|
var init_background_task = __esm({
|
|
27947
28008
|
"../shared/src/agent/acp/background-task.ts"() {
|
|
27948
28009
|
"use strict";
|
|
27949
28010
|
BACKGROUND_TASK_META_KEY = "alan.dev/backgroundTask";
|
|
28011
|
+
MAX_LAST_OUTPUT_CHARS = 200;
|
|
28012
|
+
LAST_OUTPUT_INTERVAL_MS = 1e3;
|
|
28013
|
+
ANSI_ESCAPE = new RegExp(`${String.fromCharCode(27)}\\[[0-9;?]*[ -/]*[@-~]`, "g");
|
|
28014
|
+
}
|
|
28015
|
+
});
|
|
28016
|
+
|
|
28017
|
+
// ../shared/src/agent/acp/plan.ts
|
|
28018
|
+
var init_plan = __esm({
|
|
28019
|
+
"../shared/src/agent/acp/plan.ts"() {
|
|
28020
|
+
"use strict";
|
|
28021
|
+
}
|
|
28022
|
+
});
|
|
28023
|
+
|
|
28024
|
+
// ../shared/src/agent/acp/sent-at.ts
|
|
28025
|
+
var init_sent_at = __esm({
|
|
28026
|
+
"../shared/src/agent/acp/sent-at.ts"() {
|
|
28027
|
+
"use strict";
|
|
27950
28028
|
}
|
|
27951
28029
|
});
|
|
27952
28030
|
|
|
@@ -27966,13 +28044,6 @@ var init_types2 = __esm({
|
|
|
27966
28044
|
}
|
|
27967
28045
|
});
|
|
27968
28046
|
|
|
27969
|
-
// ../shared/src/agent/acp/presentation/terminal-events.ts
|
|
27970
|
-
var init_terminal_events = __esm({
|
|
27971
|
-
"../shared/src/agent/acp/presentation/terminal-events.ts"() {
|
|
27972
|
-
"use strict";
|
|
27973
|
-
}
|
|
27974
|
-
});
|
|
27975
|
-
|
|
27976
28047
|
// ../shared/src/agent/acp/presentation/file-edits.ts
|
|
27977
28048
|
var init_file_edits = __esm({
|
|
27978
28049
|
"../shared/src/agent/acp/presentation/file-edits.ts"() {
|
|
@@ -27987,6 +28058,13 @@ var init_notice_visibility = __esm({
|
|
|
27987
28058
|
}
|
|
27988
28059
|
});
|
|
27989
28060
|
|
|
28061
|
+
// ../shared/src/agent/acp/presentation/terminal-events.ts
|
|
28062
|
+
var init_terminal_events = __esm({
|
|
28063
|
+
"../shared/src/agent/acp/presentation/terminal-events.ts"() {
|
|
28064
|
+
"use strict";
|
|
28065
|
+
}
|
|
28066
|
+
});
|
|
28067
|
+
|
|
27990
28068
|
// ../shared/src/agent/acp/presentation/turn-artifacts.ts
|
|
27991
28069
|
var init_turn_artifacts = __esm({
|
|
27992
28070
|
"../shared/src/agent/acp/presentation/turn-artifacts.ts"() {
|
|
@@ -28085,7 +28163,7 @@ var init_conversation_usage = __esm({
|
|
|
28085
28163
|
});
|
|
28086
28164
|
|
|
28087
28165
|
// ../shared/src/agent/acp/mid-run-messages.ts
|
|
28088
|
-
var midRunMessageStatusSchema, midRunMessageViewSchema, midRunMessagesResponseSchema;
|
|
28166
|
+
var midRunMessageStatusSchema, midRunMessageViewSchema, midRunMessagesResponseSchema, followUpModeSchema, MAX_QUEUED_MESSAGE_LENGTH, editQueuedMessageSchema, steerQueuedMessageResultSchema;
|
|
28089
28167
|
var init_mid_run_messages = __esm({
|
|
28090
28168
|
"../shared/src/agent/acp/mid-run-messages.ts"() {
|
|
28091
28169
|
"use strict";
|
|
@@ -28104,6 +28182,28 @@ var init_mid_run_messages = __esm({
|
|
|
28104
28182
|
midRunMessagesResponseSchema = external_exports.object({
|
|
28105
28183
|
messages: external_exports.array(midRunMessageViewSchema)
|
|
28106
28184
|
});
|
|
28185
|
+
followUpModeSchema = external_exports.enum(["steer", "queue"]);
|
|
28186
|
+
MAX_QUEUED_MESSAGE_LENGTH = 1e5;
|
|
28187
|
+
editQueuedMessageSchema = external_exports.object({
|
|
28188
|
+
text: external_exports.string().trim().min(1).max(MAX_QUEUED_MESSAGE_LENGTH)
|
|
28189
|
+
});
|
|
28190
|
+
steerQueuedMessageResultSchema = external_exports.object({
|
|
28191
|
+
delivery: external_exports.enum(["steered", "queued"])
|
|
28192
|
+
});
|
|
28193
|
+
}
|
|
28194
|
+
});
|
|
28195
|
+
|
|
28196
|
+
// ../shared/src/agent/acp/read.ts
|
|
28197
|
+
var init_read = __esm({
|
|
28198
|
+
"../shared/src/agent/acp/read.ts"() {
|
|
28199
|
+
"use strict";
|
|
28200
|
+
}
|
|
28201
|
+
});
|
|
28202
|
+
|
|
28203
|
+
// ../shared/src/agent/acp/pending-prompts.ts
|
|
28204
|
+
var init_pending_prompts = __esm({
|
|
28205
|
+
"../shared/src/agent/acp/pending-prompts.ts"() {
|
|
28206
|
+
"use strict";
|
|
28107
28207
|
}
|
|
28108
28208
|
});
|
|
28109
28209
|
|
|
@@ -28114,10 +28214,14 @@ var init_types3 = __esm({
|
|
|
28114
28214
|
}
|
|
28115
28215
|
});
|
|
28116
28216
|
|
|
28117
|
-
// ../shared/src/agent/acp/
|
|
28118
|
-
var
|
|
28119
|
-
|
|
28217
|
+
// ../shared/src/agent/acp/provider-limit.ts
|
|
28218
|
+
var SYNTHETIC_META_KEY, PROBLEM_CODE_META_KEY, PROBLEM_RESETS_AT_META_KEY;
|
|
28219
|
+
var init_provider_limit = __esm({
|
|
28220
|
+
"../shared/src/agent/acp/provider-limit.ts"() {
|
|
28120
28221
|
"use strict";
|
|
28222
|
+
SYNTHETIC_META_KEY = "alan.dev/synthetic";
|
|
28223
|
+
PROBLEM_CODE_META_KEY = "alan.dev/problemCode";
|
|
28224
|
+
PROBLEM_RESETS_AT_META_KEY = "alan.dev/problemResetsAt";
|
|
28121
28225
|
}
|
|
28122
28226
|
});
|
|
28123
28227
|
|
|
@@ -28166,14 +28270,18 @@ var init_acp = __esm({
|
|
|
28166
28270
|
init_conversation_usage();
|
|
28167
28271
|
init_event();
|
|
28168
28272
|
init_mid_run_messages();
|
|
28273
|
+
init_pending_prompts();
|
|
28274
|
+
init_plan();
|
|
28169
28275
|
init_file_edits();
|
|
28170
28276
|
init_notice_visibility();
|
|
28171
28277
|
init_prepare_conversation_turns();
|
|
28172
28278
|
init_terminal_events();
|
|
28173
28279
|
init_turn_artifacts();
|
|
28174
28280
|
init_types3();
|
|
28281
|
+
init_provider_limit();
|
|
28175
28282
|
init_read();
|
|
28176
28283
|
init_reduce();
|
|
28284
|
+
init_sent_at();
|
|
28177
28285
|
init_session_activity();
|
|
28178
28286
|
init_transcript_byte_decoder();
|
|
28179
28287
|
init_transcript_fold();
|
|
@@ -28285,7 +28393,7 @@ var init_models = __esm({
|
|
|
28285
28393
|
// build it serves so the pin is auditable and does not drift with the alias.
|
|
28286
28394
|
id: "deepseek/deepseek-v4.1-flash",
|
|
28287
28395
|
name: "DeepSeek V4.1 Flash",
|
|
28288
|
-
description: "Fast
|
|
28396
|
+
description: "Fast, cheap all-rounder for routine edits and light agent work.",
|
|
28289
28397
|
enabled: true,
|
|
28290
28398
|
isDefault: true,
|
|
28291
28399
|
sortOrder: 10,
|
|
@@ -28301,7 +28409,7 @@ var init_models = __esm({
|
|
|
28301
28409
|
{
|
|
28302
28410
|
id: "deepseek/deepseek-v4-pro",
|
|
28303
28411
|
name: "DeepSeek V4 Pro",
|
|
28304
|
-
description: "
|
|
28412
|
+
description: "Legacy text-only reasoning model; prefer V4.1 Flash for coding.",
|
|
28305
28413
|
enabled: true,
|
|
28306
28414
|
isDefault: false,
|
|
28307
28415
|
sortOrder: 20,
|
|
@@ -28316,7 +28424,7 @@ var init_models = __esm({
|
|
|
28316
28424
|
{
|
|
28317
28425
|
id: "particle-ai/particle-1",
|
|
28318
28426
|
name: "Particle-1",
|
|
28319
|
-
description: "
|
|
28427
|
+
description: "Token-efficient coder: near DeepSeek Flash accuracy at ~45% fewer tokens.",
|
|
28320
28428
|
enabled: true,
|
|
28321
28429
|
isDefault: false,
|
|
28322
28430
|
sortOrder: 25,
|
|
@@ -28325,12 +28433,13 @@ var init_models = __esm({
|
|
|
28325
28433
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28326
28434
|
inputPriceMicroUsdPerMtok: 25e4,
|
|
28327
28435
|
outputPriceMicroUsdPerMtok: 1e6,
|
|
28328
|
-
cacheReadPriceMicroUsdPerMtok: 3e3
|
|
28436
|
+
cacheReadPriceMicroUsdPerMtok: 3e3,
|
|
28437
|
+
routing: { tier: "workhorse", priority: 5, strengths: ["speed", "cost", "general"] }
|
|
28329
28438
|
},
|
|
28330
28439
|
{
|
|
28331
28440
|
id: "z-ai/glm-5.3",
|
|
28332
28441
|
name: "GLM 5.3",
|
|
28333
|
-
description: "
|
|
28442
|
+
description: "Strong open coding agent for terminal work, security and multi-file refactors.",
|
|
28334
28443
|
enabled: true,
|
|
28335
28444
|
isDefault: false,
|
|
28336
28445
|
sortOrder: 30,
|
|
@@ -28343,14 +28452,14 @@ var init_models = __esm({
|
|
|
28343
28452
|
reasoning: true,
|
|
28344
28453
|
routing: {
|
|
28345
28454
|
tier: "strong",
|
|
28346
|
-
priority:
|
|
28347
|
-
strengths: ["architecture", "refactoring", "debugging"]
|
|
28455
|
+
priority: 15,
|
|
28456
|
+
strengths: ["architecture", "refactoring", "debugging", "high_stakes", "cost"]
|
|
28348
28457
|
}
|
|
28349
28458
|
},
|
|
28350
28459
|
{
|
|
28351
28460
|
id: "z-ai/glm-5.3-flash",
|
|
28352
28461
|
name: "GLM 5.3 Flash",
|
|
28353
|
-
description: "
|
|
28462
|
+
description: "Cheap multimodal GLM; strong default for routine and UI-heavy coding.",
|
|
28354
28463
|
enabled: true,
|
|
28355
28464
|
isDefault: false,
|
|
28356
28465
|
sortOrder: 40,
|
|
@@ -28361,12 +28470,16 @@ var init_models = __esm({
|
|
|
28361
28470
|
outputPriceMicroUsdPerMtok: 5e5,
|
|
28362
28471
|
cacheReadPriceMicroUsdPerMtok: 3e4,
|
|
28363
28472
|
reasoning: true,
|
|
28364
|
-
routing: {
|
|
28473
|
+
routing: {
|
|
28474
|
+
tier: "workhorse",
|
|
28475
|
+
priority: 15,
|
|
28476
|
+
strengths: ["ui_design", "speed", "cost", "general"]
|
|
28477
|
+
}
|
|
28365
28478
|
},
|
|
28366
28479
|
{
|
|
28367
28480
|
id: "z-ai/glm-5.3-flashx",
|
|
28368
28481
|
name: "GLM 5.3 FlashX",
|
|
28369
|
-
description: "
|
|
28482
|
+
description: "GLM Flash at ~200 tok/s; pay extra when interactive latency matters.",
|
|
28370
28483
|
enabled: true,
|
|
28371
28484
|
isDefault: false,
|
|
28372
28485
|
sortOrder: 50,
|
|
@@ -28375,12 +28488,13 @@ var init_models = __esm({
|
|
|
28375
28488
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28376
28489
|
inputPriceMicroUsdPerMtok: 37e4,
|
|
28377
28490
|
outputPriceMicroUsdPerMtok: 125e4,
|
|
28378
|
-
cacheReadPriceMicroUsdPerMtok: 9e4
|
|
28491
|
+
cacheReadPriceMicroUsdPerMtok: 9e4,
|
|
28492
|
+
routing: { tier: "workhorse", priority: 25, strengths: ["ui_design", "speed"] }
|
|
28379
28493
|
},
|
|
28380
28494
|
{
|
|
28381
28495
|
id: "z-ai/glm-5.3-prime",
|
|
28382
28496
|
name: "GLM 5.3 Prime",
|
|
28383
|
-
description: "
|
|
28497
|
+
description: "GLM 5.3 served faster for long interactive agent sessions; 2x price.",
|
|
28384
28498
|
enabled: true,
|
|
28385
28499
|
isDefault: false,
|
|
28386
28500
|
sortOrder: 60,
|
|
@@ -28389,12 +28503,13 @@ var init_models = __esm({
|
|
|
28389
28503
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28390
28504
|
inputPriceMicroUsdPerMtok: 28e5,
|
|
28391
28505
|
outputPriceMicroUsdPerMtok: 88e5,
|
|
28392
|
-
cacheReadPriceMicroUsdPerMtok: 56e4
|
|
28506
|
+
cacheReadPriceMicroUsdPerMtok: 56e4,
|
|
28507
|
+
routing: { tier: "strong", priority: 30, strengths: ["architecture", "speed", "high_stakes"] }
|
|
28393
28508
|
},
|
|
28394
28509
|
{
|
|
28395
28510
|
id: "qwen/qwen3.8-27b",
|
|
28396
28511
|
name: "Qwen3.8 27B",
|
|
28397
|
-
description: "
|
|
28512
|
+
description: "Small local-friendly coder; runs on a 24GB Mac, best for offline or light work.",
|
|
28398
28513
|
enabled: true,
|
|
28399
28514
|
isDefault: false,
|
|
28400
28515
|
sortOrder: 70,
|
|
@@ -28404,12 +28519,17 @@ var init_models = __esm({
|
|
|
28404
28519
|
inputPriceMicroUsdPerMtok: 15e4,
|
|
28405
28520
|
outputPriceMicroUsdPerMtok: 1875e3,
|
|
28406
28521
|
cacheReadPriceMicroUsdPerMtok: 37500,
|
|
28407
|
-
reasoning: true
|
|
28522
|
+
reasoning: true,
|
|
28523
|
+
routing: {
|
|
28524
|
+
tier: "workhorse",
|
|
28525
|
+
priority: 35,
|
|
28526
|
+
strengths: ["speed", "cost", "general", "frontend"]
|
|
28527
|
+
}
|
|
28408
28528
|
},
|
|
28409
28529
|
{
|
|
28410
28530
|
id: "qwen/qwen3.8-max-prime",
|
|
28411
28531
|
name: "Qwen3.8 Max Prime",
|
|
28412
|
-
description: "Qwen's flagship
|
|
28532
|
+
description: "Qwen's flagship for complex agentic and multimodal work, served at high throughput.",
|
|
28413
28533
|
enabled: true,
|
|
28414
28534
|
isDefault: false,
|
|
28415
28535
|
sortOrder: 80,
|
|
@@ -28418,12 +28538,17 @@ var init_models = __esm({
|
|
|
28418
28538
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28419
28539
|
inputPriceMicroUsdPerMtok: 4e6,
|
|
28420
28540
|
outputPriceMicroUsdPerMtok: 12e6,
|
|
28421
|
-
cacheReadPriceMicroUsdPerMtok: 5e5
|
|
28541
|
+
cacheReadPriceMicroUsdPerMtok: 5e5,
|
|
28542
|
+
routing: {
|
|
28543
|
+
tier: "strong",
|
|
28544
|
+
priority: 10,
|
|
28545
|
+
strengths: ["architecture", "ui_design", "long_context"]
|
|
28546
|
+
}
|
|
28422
28547
|
},
|
|
28423
28548
|
{
|
|
28424
28549
|
id: "moonshotai/kimi-k3",
|
|
28425
28550
|
name: "Kimi K3",
|
|
28426
|
-
description: "
|
|
28551
|
+
description: "Long-horizon repo specialist with image and video input; slower and pricier.",
|
|
28427
28552
|
enabled: true,
|
|
28428
28553
|
isDefault: false,
|
|
28429
28554
|
sortOrder: 90,
|
|
@@ -28434,12 +28559,16 @@ var init_models = __esm({
|
|
|
28434
28559
|
outputPriceMicroUsdPerMtok: 15e6,
|
|
28435
28560
|
cacheReadPriceMicroUsdPerMtok: 182e3,
|
|
28436
28561
|
reasoning: true,
|
|
28437
|
-
routing: {
|
|
28562
|
+
routing: {
|
|
28563
|
+
tier: "strong",
|
|
28564
|
+
priority: 12,
|
|
28565
|
+
strengths: ["architecture", "long_context", "debugging"]
|
|
28566
|
+
}
|
|
28438
28567
|
},
|
|
28439
28568
|
{
|
|
28440
28569
|
id: "moonshotai/kimi-k3.1-pro",
|
|
28441
28570
|
name: "Kimi K3.1 Pro",
|
|
28442
|
-
description: "
|
|
28571
|
+
description: "Best open Chinese model; top-tier long-horizon coding and terminal work.",
|
|
28443
28572
|
enabled: true,
|
|
28444
28573
|
isDefault: false,
|
|
28445
28574
|
sortOrder: 100,
|
|
@@ -28448,12 +28577,17 @@ var init_models = __esm({
|
|
|
28448
28577
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28449
28578
|
inputPriceMicroUsdPerMtok: 2e6,
|
|
28450
28579
|
outputPriceMicroUsdPerMtok: 1e7,
|
|
28451
|
-
cacheReadPriceMicroUsdPerMtok: 2e5
|
|
28580
|
+
cacheReadPriceMicroUsdPerMtok: 2e5,
|
|
28581
|
+
routing: {
|
|
28582
|
+
tier: "frontier",
|
|
28583
|
+
priority: 5,
|
|
28584
|
+
strengths: ["architecture", "long_context", "debugging", "high_stakes"]
|
|
28585
|
+
}
|
|
28452
28586
|
},
|
|
28453
28587
|
{
|
|
28454
28588
|
id: "minimax/minimax-m3.1-flash",
|
|
28455
28589
|
name: "MiniMax M3.1 Flash",
|
|
28456
|
-
description: "
|
|
28590
|
+
description: "Cheap, capable coder for agentic, UI and high-volume work.",
|
|
28457
28591
|
enabled: true,
|
|
28458
28592
|
isDefault: false,
|
|
28459
28593
|
sortOrder: 110,
|
|
@@ -28464,12 +28598,16 @@ var init_models = __esm({
|
|
|
28464
28598
|
outputPriceMicroUsdPerMtok: 6e5,
|
|
28465
28599
|
cacheReadPriceMicroUsdPerMtok: 15e3,
|
|
28466
28600
|
reasoning: true,
|
|
28467
|
-
routing: {
|
|
28601
|
+
routing: {
|
|
28602
|
+
tier: "workhorse",
|
|
28603
|
+
priority: 12,
|
|
28604
|
+
strengths: ["ui_design", "speed", "cost", "general"]
|
|
28605
|
+
}
|
|
28468
28606
|
},
|
|
28469
28607
|
{
|
|
28470
28608
|
id: "minimax/minimax-m3",
|
|
28471
28609
|
name: "MiniMax M3",
|
|
28472
|
-
description: "
|
|
28610
|
+
description: "Open multimodal agent model; strong tool use and computer control, older than M3.1 Flash.",
|
|
28473
28611
|
enabled: true,
|
|
28474
28612
|
isDefault: false,
|
|
28475
28613
|
sortOrder: 120,
|
|
@@ -28479,12 +28617,13 @@ var init_models = __esm({
|
|
|
28479
28617
|
inputPriceMicroUsdPerMtok: 3e5,
|
|
28480
28618
|
outputPriceMicroUsdPerMtok: 12e5,
|
|
28481
28619
|
cacheReadPriceMicroUsdPerMtok: 6e4,
|
|
28482
|
-
reasoning: true
|
|
28620
|
+
reasoning: true,
|
|
28621
|
+
routing: { tier: "strong", priority: 35, strengths: ["high_stakes", "general", "cost"] }
|
|
28483
28622
|
},
|
|
28484
28623
|
{
|
|
28485
28624
|
id: "nvidia/nemotron-3.5-lightning",
|
|
28486
28625
|
name: "Nemotron 3.5 Lightning",
|
|
28487
|
-
description: "
|
|
28626
|
+
description: "Tiny, fast text model for high-volume tool calls and simple edits.",
|
|
28488
28627
|
enabled: true,
|
|
28489
28628
|
isDefault: false,
|
|
28490
28629
|
sortOrder: 130,
|
|
@@ -28493,12 +28632,13 @@ var init_models = __esm({
|
|
|
28493
28632
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28494
28633
|
inputPriceMicroUsdPerMtok: 7e4,
|
|
28495
28634
|
outputPriceMicroUsdPerMtok: 2e5,
|
|
28496
|
-
cacheReadPriceMicroUsdPerMtok: 4e4
|
|
28635
|
+
cacheReadPriceMicroUsdPerMtok: 4e4,
|
|
28636
|
+
routing: { tier: "workhorse", priority: 20, strengths: ["speed", "cost", "general"] }
|
|
28497
28637
|
},
|
|
28498
28638
|
{
|
|
28499
28639
|
id: "nvidia/nemotron-3.5-super-vl",
|
|
28500
28640
|
name: "Nemotron 3.5 Super VL",
|
|
28501
|
-
description: "
|
|
28641
|
+
description: "Efficient multimodal agent; strong SWE-bench Pro and long-context work.",
|
|
28502
28642
|
enabled: true,
|
|
28503
28643
|
isDefault: false,
|
|
28504
28644
|
sortOrder: 140,
|
|
@@ -28507,12 +28647,17 @@ var init_models = __esm({
|
|
|
28507
28647
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28508
28648
|
inputPriceMicroUsdPerMtok: 15e4,
|
|
28509
28649
|
outputPriceMicroUsdPerMtok: 5e5,
|
|
28510
|
-
cacheReadPriceMicroUsdPerMtok: 2e4
|
|
28650
|
+
cacheReadPriceMicroUsdPerMtok: 2e4,
|
|
28651
|
+
routing: {
|
|
28652
|
+
tier: "strong",
|
|
28653
|
+
priority: 18,
|
|
28654
|
+
strengths: ["architecture", "ui_design", "long_context", "cost"]
|
|
28655
|
+
}
|
|
28511
28656
|
},
|
|
28512
28657
|
{
|
|
28513
28658
|
id: "nvidia/nemotron-3-nano-30b-a3b",
|
|
28514
28659
|
name: "Nemotron 3 Nano",
|
|
28515
|
-
description: "
|
|
28660
|
+
description: "Small, fast Nemotron for cheap routine coding.",
|
|
28516
28661
|
enabled: true,
|
|
28517
28662
|
isDefault: false,
|
|
28518
28663
|
sortOrder: 150,
|
|
@@ -28521,12 +28666,13 @@ var init_models = __esm({
|
|
|
28521
28666
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28522
28667
|
inputPriceMicroUsdPerMtok: 6e4,
|
|
28523
28668
|
outputPriceMicroUsdPerMtok: 24e4,
|
|
28524
|
-
cacheReadPriceMicroUsdPerMtok: 12e3
|
|
28669
|
+
cacheReadPriceMicroUsdPerMtok: 12e3,
|
|
28670
|
+
routing: { tier: "workhorse", priority: 45, strengths: ["speed", "cost", "general"] }
|
|
28525
28671
|
},
|
|
28526
28672
|
{
|
|
28527
28673
|
id: "nvidia/nemotron-3-super-120b-a12b",
|
|
28528
28674
|
name: "Nemotron 3 Super",
|
|
28529
|
-
description: "Mid-
|
|
28675
|
+
description: "Mid-size general Nemotron; solid, but 3.5 Super is the better pick.",
|
|
28530
28676
|
enabled: true,
|
|
28531
28677
|
isDefault: false,
|
|
28532
28678
|
sortOrder: 160,
|
|
@@ -28536,12 +28682,13 @@ var init_models = __esm({
|
|
|
28536
28682
|
inputPriceMicroUsdPerMtok: 3e5,
|
|
28537
28683
|
outputPriceMicroUsdPerMtok: 24e5,
|
|
28538
28684
|
cacheReadPriceMicroUsdPerMtok: 15e4,
|
|
28539
|
-
reasoning: true
|
|
28685
|
+
reasoning: true,
|
|
28686
|
+
routing: { tier: "strong", priority: 40, strengths: ["general", "architecture"] }
|
|
28540
28687
|
},
|
|
28541
28688
|
{
|
|
28542
28689
|
id: "nvidia/nemotron-3-ultra-550b-a55b",
|
|
28543
28690
|
name: "Nemotron 3 Ultra",
|
|
28544
|
-
description: "Largest Nemotron
|
|
28691
|
+
description: "Largest Nemotron; deep architecture work, though 3.5 Super is more efficient.",
|
|
28545
28692
|
enabled: true,
|
|
28546
28693
|
isDefault: false,
|
|
28547
28694
|
sortOrder: 170,
|
|
@@ -28551,12 +28698,13 @@ var init_models = __esm({
|
|
|
28551
28698
|
inputPriceMicroUsdPerMtok: 6e5,
|
|
28552
28699
|
outputPriceMicroUsdPerMtok: 24e5,
|
|
28553
28700
|
cacheReadPriceMicroUsdPerMtok: 12e4,
|
|
28554
|
-
reasoning: true
|
|
28701
|
+
reasoning: true,
|
|
28702
|
+
routing: { tier: "strong", priority: 38, strengths: ["architecture", "debugging"] }
|
|
28555
28703
|
},
|
|
28556
28704
|
{
|
|
28557
28705
|
id: "meta/muse-spark-1.3-contributor",
|
|
28558
28706
|
name: "Muse Spark 1.3 Contributor",
|
|
28559
|
-
description: "
|
|
28707
|
+
description: "Discounted Muse Spark that trains on your data; good for public, non-sensitive work.",
|
|
28560
28708
|
enabled: true,
|
|
28561
28709
|
isDefault: false,
|
|
28562
28710
|
sortOrder: 180,
|
|
@@ -28570,7 +28718,7 @@ var init_models = __esm({
|
|
|
28570
28718
|
{
|
|
28571
28719
|
id: "meta/muse-spark-1.3",
|
|
28572
28720
|
name: "Muse Spark 1.3",
|
|
28573
|
-
description: "
|
|
28721
|
+
description: "Long-context agentic coder with excellent 1M retrieval; real-world reports are mixed.",
|
|
28574
28722
|
enabled: true,
|
|
28575
28723
|
isDefault: false,
|
|
28576
28724
|
sortOrder: 190,
|
|
@@ -28579,12 +28727,17 @@ var init_models = __esm({
|
|
|
28579
28727
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28580
28728
|
inputPriceMicroUsdPerMtok: 125e4,
|
|
28581
28729
|
outputPriceMicroUsdPerMtok: 425e4,
|
|
28582
|
-
cacheReadPriceMicroUsdPerMtok: 15e4
|
|
28730
|
+
cacheReadPriceMicroUsdPerMtok: 15e4,
|
|
28731
|
+
routing: {
|
|
28732
|
+
tier: "strong",
|
|
28733
|
+
priority: 14,
|
|
28734
|
+
strengths: ["architecture", "ui_design", "long_context"]
|
|
28735
|
+
}
|
|
28583
28736
|
},
|
|
28584
28737
|
{
|
|
28585
28738
|
id: "meta/muse-spark-open",
|
|
28586
28739
|
name: "Muse Spark Open",
|
|
28587
|
-
description: "Open-weight Muse Spark
|
|
28740
|
+
description: "Open-weight Muse Spark; self-hostable coding agent for frontend and general work.",
|
|
28588
28741
|
enabled: true,
|
|
28589
28742
|
isDefault: false,
|
|
28590
28743
|
sortOrder: 200,
|
|
@@ -28593,12 +28746,13 @@ var init_models = __esm({
|
|
|
28593
28746
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28594
28747
|
inputPriceMicroUsdPerMtok: 125e4,
|
|
28595
28748
|
outputPriceMicroUsdPerMtok: 425e4,
|
|
28596
|
-
cacheReadPriceMicroUsdPerMtok: 15e4
|
|
28749
|
+
cacheReadPriceMicroUsdPerMtok: 15e4,
|
|
28750
|
+
routing: { tier: "strong", priority: 28, strengths: ["frontend", "general"] }
|
|
28597
28751
|
},
|
|
28598
28752
|
{
|
|
28599
28753
|
id: "meta/muse-wonder",
|
|
28600
28754
|
name: "Muse Wonder",
|
|
28601
|
-
description: "
|
|
28755
|
+
description: "Frontier agentic coder for long repo work; expensive and slow, weaker factual recall.",
|
|
28602
28756
|
enabled: true,
|
|
28603
28757
|
isDefault: false,
|
|
28604
28758
|
sortOrder: 210,
|
|
@@ -28607,12 +28761,17 @@ var init_models = __esm({
|
|
|
28607
28761
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28608
28762
|
inputPriceMicroUsdPerMtok: 4e6,
|
|
28609
28763
|
outputPriceMicroUsdPerMtok: 2e7,
|
|
28610
|
-
cacheReadPriceMicroUsdPerMtok: 2e5
|
|
28764
|
+
cacheReadPriceMicroUsdPerMtok: 2e5,
|
|
28765
|
+
routing: {
|
|
28766
|
+
tier: "frontier",
|
|
28767
|
+
priority: 10,
|
|
28768
|
+
strengths: ["architecture", "debugging", "long_context", "high_stakes"]
|
|
28769
|
+
}
|
|
28611
28770
|
},
|
|
28612
28771
|
{
|
|
28613
28772
|
id: "meta/muse-spark-1.2-contributor",
|
|
28614
28773
|
name: "Muse Spark 1.2 Contributor",
|
|
28615
|
-
description: "
|
|
28774
|
+
description: "Previous Muse Spark contributor tier; prefer 1.3.",
|
|
28616
28775
|
enabled: true,
|
|
28617
28776
|
isDefault: false,
|
|
28618
28777
|
sortOrder: 220,
|
|
@@ -28626,7 +28785,7 @@ var init_models = __esm({
|
|
|
28626
28785
|
{
|
|
28627
28786
|
id: "x-ai/grok-4.7",
|
|
28628
28787
|
name: "Grok 4.7",
|
|
28629
|
-
description: "
|
|
28788
|
+
description: "Frontier agentic coder and planner; strong reviews, but token-hungry.",
|
|
28630
28789
|
enabled: true,
|
|
28631
28790
|
isDefault: false,
|
|
28632
28791
|
sortOrder: 230,
|
|
@@ -28635,12 +28794,17 @@ var init_models = __esm({
|
|
|
28635
28794
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28636
28795
|
inputPriceMicroUsdPerMtok: 2e6,
|
|
28637
28796
|
outputPriceMicroUsdPerMtok: 6e6,
|
|
28638
|
-
cacheReadPriceMicroUsdPerMtok: 5e5
|
|
28797
|
+
cacheReadPriceMicroUsdPerMtok: 5e5,
|
|
28798
|
+
routing: {
|
|
28799
|
+
tier: "frontier",
|
|
28800
|
+
priority: 15,
|
|
28801
|
+
strengths: ["architecture", "debugging", "refactoring"]
|
|
28802
|
+
}
|
|
28639
28803
|
},
|
|
28640
28804
|
{
|
|
28641
28805
|
id: "google/gemini-4-argon",
|
|
28642
28806
|
name: "Gemini 4 Argon",
|
|
28643
|
-
description: "
|
|
28807
|
+
description: "Top reasoning and web-design model; excellent architecture and UI, expensive per task.",
|
|
28644
28808
|
enabled: true,
|
|
28645
28809
|
isDefault: false,
|
|
28646
28810
|
sortOrder: 240,
|
|
@@ -28649,7 +28813,12 @@ var init_models = __esm({
|
|
|
28649
28813
|
maxOutputTokens: HARNESS_MAX_OUTPUT_TOKENS,
|
|
28650
28814
|
inputPriceMicroUsdPerMtok: 2e6,
|
|
28651
28815
|
outputPriceMicroUsdPerMtok: 1e7,
|
|
28652
|
-
cacheReadPriceMicroUsdPerMtok: 1e5
|
|
28816
|
+
cacheReadPriceMicroUsdPerMtok: 1e5,
|
|
28817
|
+
routing: {
|
|
28818
|
+
tier: "frontier",
|
|
28819
|
+
priority: 12,
|
|
28820
|
+
strengths: ["architecture", "ui_design", "long_context", "high_stakes"]
|
|
28821
|
+
}
|
|
28653
28822
|
}
|
|
28654
28823
|
];
|
|
28655
28824
|
DEFAULT_HARNESS_MODEL_ID = HARNESS_MODEL_SEEDS.find((model2) => model2.isDefault)?.id ?? HARNESS_MODEL_SEEDS[0].id;
|
|
@@ -28961,7 +29130,7 @@ var init_constants = __esm({
|
|
|
28961
29130
|
});
|
|
28962
29131
|
|
|
28963
29132
|
// ../agent-core/src/acp/meta.ts
|
|
28964
|
-
var PROVIDER_PAYLOAD_META, TOOL_RESULT_ONLY_META, PARENT_TOOL_CALL_META, SUBAGENT_LAUNCHER_META, SUBAGENT_TASK_ID_META, SUBAGENT_OUTPUT_FILE_META, TODOS_META, NOTICE_KIND_META, ASK_USER_QUESTIONS_META, USER_ANSWER_META, AWAITING_TOOL_CALLS_META, EXIT_PLAN_MODE_INPUT_META, BACKGROUND_TASK_META, TASK_PROGRESS_META, RATE_LIMIT_META, MODEL_META, TOOLS_META, SLASH_COMMANDS_META;
|
|
29133
|
+
var PROVIDER_PAYLOAD_META, TOOL_RESULT_ONLY_META, PARENT_TOOL_CALL_META, SUBAGENT_LAUNCHER_META, SUBAGENT_TASK_ID_META, SUBAGENT_OUTPUT_FILE_META, TODOS_META, NOTICE_KIND_META, ASK_USER_QUESTIONS_META, USER_ANSWER_META, AWAITING_TOOL_CALLS_META, EXIT_PLAN_MODE_INPUT_META, BACKGROUND_TASK_META, TASK_PROGRESS_META, RATE_LIMIT_META, SYNTHETIC_META, PROBLEM_CODE_META, PROBLEM_RESETS_AT_META, MODEL_META, TOOLS_META, SLASH_COMMANDS_META;
|
|
28965
29134
|
var init_meta = __esm({
|
|
28966
29135
|
"../agent-core/src/acp/meta.ts"() {
|
|
28967
29136
|
"use strict";
|
|
@@ -28981,6 +29150,9 @@ var init_meta = __esm({
|
|
|
28981
29150
|
BACKGROUND_TASK_META = BACKGROUND_TASK_META_KEY;
|
|
28982
29151
|
TASK_PROGRESS_META = "alan.dev/taskProgress";
|
|
28983
29152
|
RATE_LIMIT_META = "alan.dev/rateLimit";
|
|
29153
|
+
SYNTHETIC_META = SYNTHETIC_META_KEY;
|
|
29154
|
+
PROBLEM_CODE_META = PROBLEM_CODE_META_KEY;
|
|
29155
|
+
PROBLEM_RESETS_AT_META = PROBLEM_RESETS_AT_META_KEY;
|
|
28984
29156
|
MODEL_META = "alan.dev/model";
|
|
28985
29157
|
TOOLS_META = "alan.dev/tools";
|
|
28986
29158
|
SLASH_COMMANDS_META = "alan.dev/slashCommands";
|
|
@@ -29006,13 +29178,13 @@ function logUpdate(source, message) {
|
|
|
29006
29178
|
function unhandledUpdate(kind, payload) {
|
|
29007
29179
|
return { sessionUpdate: "_alan/unhandled", kind, _meta: { [PROVIDER_PAYLOAD_META]: payload } };
|
|
29008
29180
|
}
|
|
29009
|
-
function noticeUpdate(severity, kind, title, description2) {
|
|
29181
|
+
function noticeUpdate(severity, kind, title, description2, meta3) {
|
|
29010
29182
|
return {
|
|
29011
29183
|
sessionUpdate: "notice",
|
|
29012
29184
|
severity,
|
|
29013
29185
|
title,
|
|
29014
29186
|
...description2 ? { description: description2 } : {},
|
|
29015
|
-
_meta: { [NOTICE_KIND_META]: kind }
|
|
29187
|
+
_meta: { ...meta3, [NOTICE_KIND_META]: kind }
|
|
29016
29188
|
};
|
|
29017
29189
|
}
|
|
29018
29190
|
function usageUpdates(report2, fallbackModel = "") {
|
|
@@ -29275,36 +29447,77 @@ var init_inline_media = __esm({
|
|
|
29275
29447
|
});
|
|
29276
29448
|
|
|
29277
29449
|
// ../agent-core/src/acp/plan.ts
|
|
29450
|
+
function planEntryStatus(value2) {
|
|
29451
|
+
return PLAN_ENTRY_STATUSES.get(asString(value2)) ?? "pending";
|
|
29452
|
+
}
|
|
29278
29453
|
function todoPlanUpdate(toolCallId, todos) {
|
|
29279
|
-
return
|
|
29280
|
-
|
|
29281
|
-
|
|
29282
|
-
|
|
29283
|
-
|
|
29284
|
-
|
|
29454
|
+
return planSnapshot(toolCallId, planEntries(todos), todos);
|
|
29455
|
+
}
|
|
29456
|
+
function planSnapshot(planId, entries2, raw = entries2) {
|
|
29457
|
+
return { sessionUpdate: "plan_update", planId, entries: entries2, _meta: { [TODOS_META]: raw } };
|
|
29458
|
+
}
|
|
29459
|
+
function todoItems(value2) {
|
|
29460
|
+
if (Array.isArray(value2)) return value2;
|
|
29461
|
+
if (typeof value2 !== "string") return [];
|
|
29462
|
+
const text3 = value2.trim();
|
|
29463
|
+
if (text3.startsWith("[")) {
|
|
29464
|
+
try {
|
|
29465
|
+
return asArray(JSON.parse(text3));
|
|
29466
|
+
} catch {
|
|
29467
|
+
return [];
|
|
29468
|
+
}
|
|
29469
|
+
}
|
|
29470
|
+
return text3.split("\n").flatMap((line) => {
|
|
29471
|
+
const match = NUMBERED_TODO.exec(line);
|
|
29472
|
+
return match ? [{ status: match[1], content: match[2] }] : [];
|
|
29473
|
+
});
|
|
29474
|
+
}
|
|
29475
|
+
function alanPlanUpdate(name, toolCallId, input2) {
|
|
29476
|
+
if (!normalizeToolName2(name).endsWith("updateplan")) return void 0;
|
|
29477
|
+
const steps = asArray(asRecord(input2)?.plan).flatMap((raw) => {
|
|
29478
|
+
const step = asRecord(raw);
|
|
29479
|
+
return step ? [{ ...step, content: asString(step.step) || asString(step.content) }] : [];
|
|
29480
|
+
});
|
|
29481
|
+
return steps.length > 0 ? todoPlanUpdate(toolCallId, steps) : void 0;
|
|
29482
|
+
}
|
|
29483
|
+
function entryId(todo) {
|
|
29484
|
+
const id = todo.id;
|
|
29485
|
+
if (typeof id === "string" && id !== "") return id;
|
|
29486
|
+
return typeof id === "number" ? String(id) : void 0;
|
|
29285
29487
|
}
|
|
29286
29488
|
function planEntries(todos) {
|
|
29287
29489
|
return todos.flatMap((raw) => {
|
|
29288
29490
|
const todo = asRecord(raw);
|
|
29289
29491
|
if (!todo) return [];
|
|
29290
|
-
const content = asString(todo.content) || asString(todo.activeForm);
|
|
29492
|
+
const content = asString(todo.content) || asString(todo.subject) || asString(todo.activeForm);
|
|
29291
29493
|
if (!content) return [];
|
|
29292
|
-
const
|
|
29293
|
-
return [
|
|
29494
|
+
const id = entryId(todo);
|
|
29495
|
+
return [
|
|
29496
|
+
{ ...id ? { id } : {}, content, priority: "medium", status: planEntryStatus(todo.status) }
|
|
29497
|
+
];
|
|
29294
29498
|
});
|
|
29295
29499
|
}
|
|
29296
|
-
var PLAN_ENTRY_STATUSES;
|
|
29297
|
-
var
|
|
29500
|
+
var PLAN_ENTRY_STATUSES, NUMBERED_TODO;
|
|
29501
|
+
var init_plan2 = __esm({
|
|
29298
29502
|
"../agent-core/src/acp/plan.ts"() {
|
|
29299
29503
|
"use strict";
|
|
29504
|
+
init_constants();
|
|
29300
29505
|
init_kernel2();
|
|
29301
29506
|
init_meta();
|
|
29302
29507
|
PLAN_ENTRY_STATUSES = /* @__PURE__ */ new Map([
|
|
29303
29508
|
["pending", "pending"],
|
|
29509
|
+
["todo", "pending"],
|
|
29510
|
+
["blocked", "pending"],
|
|
29304
29511
|
["in_progress", "in_progress"],
|
|
29512
|
+
["inProgress", "in_progress"],
|
|
29305
29513
|
["completed", "completed"],
|
|
29306
|
-
["
|
|
29514
|
+
["done", "completed"],
|
|
29515
|
+
["failed", "failed"],
|
|
29516
|
+
["cancelled", "cancelled"],
|
|
29517
|
+
["canceled", "cancelled"],
|
|
29518
|
+
["abandoned", "cancelled"]
|
|
29307
29519
|
]);
|
|
29520
|
+
NUMBERED_TODO = /^\s*\d+\.\s*\[(\w+)\]\s*(.+?)\s*$/;
|
|
29308
29521
|
}
|
|
29309
29522
|
});
|
|
29310
29523
|
|
|
@@ -29317,7 +29530,7 @@ var init_acp2 = __esm({
|
|
|
29317
29530
|
init_file_change();
|
|
29318
29531
|
init_inline_media();
|
|
29319
29532
|
init_meta();
|
|
29320
|
-
|
|
29533
|
+
init_plan2();
|
|
29321
29534
|
}
|
|
29322
29535
|
});
|
|
29323
29536
|
|
|
@@ -30952,7 +31165,7 @@ var init_background = __esm({
|
|
|
30952
31165
|
case "end": {
|
|
30953
31166
|
const task = this.#tasks.get(frame.taskId);
|
|
30954
31167
|
if (!task || !isRunning(task)) return [];
|
|
30955
|
-
this.#settle(task, frame.ending);
|
|
31168
|
+
this.#settle(task, frame.ending, frame.exitCode);
|
|
30956
31169
|
return this.#announce(task);
|
|
30957
31170
|
}
|
|
30958
31171
|
}
|
|
@@ -30968,6 +31181,7 @@ var init_background = __esm({
|
|
|
30968
31181
|
backgrounded: true,
|
|
30969
31182
|
kind: start.kind,
|
|
30970
31183
|
...label3 ? { label: label3 } : {},
|
|
31184
|
+
...start.command ? { command: start.command } : {},
|
|
30971
31185
|
startedAt: existing?.meta.startedAt ?? this.#now(),
|
|
30972
31186
|
stop: "native",
|
|
30973
31187
|
status: existing?.meta.status ?? "running",
|
|
@@ -30994,8 +31208,13 @@ var init_background = __esm({
|
|
|
30994
31208
|
...status === "stopped" && task.userStopRequested ? { stoppedByUser: true } : {}
|
|
30995
31209
|
};
|
|
30996
31210
|
}
|
|
30997
|
-
#settle(task, ending) {
|
|
31211
|
+
#settle(task, ending, exitCode) {
|
|
30998
31212
|
this.#setStatus(task, task.userStopRequested ? "stopped" : ending);
|
|
31213
|
+
task.meta = {
|
|
31214
|
+
...task.meta,
|
|
31215
|
+
endedAt: this.#now(),
|
|
31216
|
+
...exitCode === void 0 ? {} : { exitCode }
|
|
31217
|
+
};
|
|
30999
31218
|
}
|
|
31000
31219
|
#announce(task) {
|
|
31001
31220
|
if (!task.launcherToolCallId) return [];
|
|
@@ -31095,7 +31314,62 @@ var init_create_plan = __esm({
|
|
|
31095
31314
|
init_kernel2();
|
|
31096
31315
|
init_tool_call_id();
|
|
31097
31316
|
CURSOR_CREATE_PLAN = "cursor/create_plan";
|
|
31098
|
-
STATUSES = /* @__PURE__ */ new Set([
|
|
31317
|
+
STATUSES = /* @__PURE__ */ new Set([
|
|
31318
|
+
"pending",
|
|
31319
|
+
"in_progress",
|
|
31320
|
+
"completed",
|
|
31321
|
+
"failed",
|
|
31322
|
+
"cancelled"
|
|
31323
|
+
]);
|
|
31324
|
+
}
|
|
31325
|
+
});
|
|
31326
|
+
|
|
31327
|
+
// ../agent-core/src/providers/acp/cursor-todos.ts
|
|
31328
|
+
var CURSOR_UPDATE_TODOS, CURSOR_TODOS_PLAN_ID, CursorTodoList;
|
|
31329
|
+
var init_cursor_todos = __esm({
|
|
31330
|
+
"../agent-core/src/providers/acp/cursor-todos.ts"() {
|
|
31331
|
+
"use strict";
|
|
31332
|
+
init_acp2();
|
|
31333
|
+
init_kernel2();
|
|
31334
|
+
CURSOR_UPDATE_TODOS = "cursor/update_todos";
|
|
31335
|
+
CURSOR_TODOS_PLAN_ID = "cursor-todos";
|
|
31336
|
+
CursorTodoList = class {
|
|
31337
|
+
#entries = [];
|
|
31338
|
+
apply(params) {
|
|
31339
|
+
const incoming = asArray(params.todos).flatMap((raw) => {
|
|
31340
|
+
const todo = asRecord(raw);
|
|
31341
|
+
const id = asString(todo?.id);
|
|
31342
|
+
if (!todo || !id) return [];
|
|
31343
|
+
return [
|
|
31344
|
+
{
|
|
31345
|
+
id,
|
|
31346
|
+
content: asString(todo.content),
|
|
31347
|
+
priority: "medium",
|
|
31348
|
+
status: planEntryStatus(todo.status)
|
|
31349
|
+
}
|
|
31350
|
+
];
|
|
31351
|
+
});
|
|
31352
|
+
this.#entries = params.merge === true ? this.#merged(incoming) : incoming;
|
|
31353
|
+
return planSnapshot(
|
|
31354
|
+
CURSOR_TODOS_PLAN_ID,
|
|
31355
|
+
this.#entries.filter((entry2) => entry2.content !== "")
|
|
31356
|
+
);
|
|
31357
|
+
}
|
|
31358
|
+
/** The todos as Cursor settled them, for the `accepted` answer a request expects. */
|
|
31359
|
+
accepted() {
|
|
31360
|
+
return this.#entries;
|
|
31361
|
+
}
|
|
31362
|
+
#merged(incoming) {
|
|
31363
|
+
const next = [...this.#entries];
|
|
31364
|
+
for (const entry2 of incoming) {
|
|
31365
|
+
const index = next.findIndex((known2) => known2.id === entry2.id);
|
|
31366
|
+
const known = next[index];
|
|
31367
|
+
if (known) next[index] = { ...entry2, content: entry2.content || known.content };
|
|
31368
|
+
else next.push(entry2);
|
|
31369
|
+
}
|
|
31370
|
+
return next;
|
|
31371
|
+
}
|
|
31372
|
+
};
|
|
31099
31373
|
}
|
|
31100
31374
|
});
|
|
31101
31375
|
|
|
@@ -31212,10 +31486,40 @@ function promptSpend(result, profile) {
|
|
|
31212
31486
|
...asString(meta3?.modelId) ? { model: asString(meta3?.modelId) } : {}
|
|
31213
31487
|
};
|
|
31214
31488
|
}
|
|
31215
|
-
|
|
31489
|
+
function planEntriesOf(value2) {
|
|
31490
|
+
return asArray(value2).flatMap((raw) => {
|
|
31491
|
+
const entry2 = asRecord(raw);
|
|
31492
|
+
const content = asString(entry2?.content);
|
|
31493
|
+
if (!entry2 || !content) return [];
|
|
31494
|
+
const id = asString(entry2.id);
|
|
31495
|
+
const priority = asString(entry2.priority);
|
|
31496
|
+
return [
|
|
31497
|
+
{
|
|
31498
|
+
...id ? { id } : {},
|
|
31499
|
+
content,
|
|
31500
|
+
priority: isPlanPriority(priority) ? priority : "medium",
|
|
31501
|
+
status: planEntryStatus(entry2.status)
|
|
31502
|
+
}
|
|
31503
|
+
];
|
|
31504
|
+
});
|
|
31505
|
+
}
|
|
31506
|
+
function isPlanPriority(value2) {
|
|
31507
|
+
return PLAN_PRIORITIES.has(value2);
|
|
31508
|
+
}
|
|
31509
|
+
function toolPlan(update) {
|
|
31510
|
+
const name = asString(asRecord(asRecord(update._meta)?.["x.ai/tool"])?.name) || asString(update.name) || asString(update.title);
|
|
31511
|
+
const toolCallId = asString(update.toolCallId);
|
|
31512
|
+
const todos = asRecord(update.rawInput)?.todos;
|
|
31513
|
+
if (normalizeToolName2(name) === "todowrite" && Array.isArray(todos)) {
|
|
31514
|
+
return todoPlanUpdate(toolCallId, todos);
|
|
31515
|
+
}
|
|
31516
|
+
return alanPlanUpdate(name, toolCallId, update.rawInput);
|
|
31517
|
+
}
|
|
31518
|
+
var STOP_REASONS, CHUNKS, ECHOES, AcpTurn, PLAN_PRIORITIES;
|
|
31216
31519
|
var init_updates = __esm({
|
|
31217
31520
|
"../agent-core/src/providers/acp/updates.ts"() {
|
|
31218
31521
|
"use strict";
|
|
31522
|
+
init_constants();
|
|
31219
31523
|
init_acp2();
|
|
31220
31524
|
init_kernel2();
|
|
31221
31525
|
init_tool_call_id();
|
|
@@ -31283,14 +31587,16 @@ var init_updates = __esm({
|
|
|
31283
31587
|
this.#bursts.clear();
|
|
31284
31588
|
switch (kind) {
|
|
31285
31589
|
case "tool_call":
|
|
31286
|
-
case "tool_call_update":
|
|
31287
|
-
|
|
31590
|
+
case "tool_call_update": {
|
|
31591
|
+
const plan2 = toolPlan(update);
|
|
31592
|
+
return plan2 ? [toolUpdate2(update), plan2] : [toolUpdate2(update)];
|
|
31593
|
+
}
|
|
31288
31594
|
case "plan":
|
|
31289
31595
|
return [
|
|
31290
31596
|
{
|
|
31291
31597
|
sessionUpdate: "plan_update",
|
|
31292
31598
|
planId: "plan",
|
|
31293
|
-
entries:
|
|
31599
|
+
entries: planEntriesOf(update.entries)
|
|
31294
31600
|
}
|
|
31295
31601
|
];
|
|
31296
31602
|
case "usage_update":
|
|
@@ -31316,6 +31622,7 @@ var init_updates = __esm({
|
|
|
31316
31622
|
return fresh;
|
|
31317
31623
|
}
|
|
31318
31624
|
};
|
|
31625
|
+
PLAN_PRIORITIES = /* @__PURE__ */ new Set(["high", "medium", "low"]);
|
|
31319
31626
|
}
|
|
31320
31627
|
});
|
|
31321
31628
|
|
|
@@ -31350,6 +31657,7 @@ var init_session2 = __esm({
|
|
|
31350
31657
|
init_ask_question();
|
|
31351
31658
|
init_background();
|
|
31352
31659
|
init_create_plan();
|
|
31660
|
+
init_cursor_todos();
|
|
31353
31661
|
init_errors4();
|
|
31354
31662
|
init_fs();
|
|
31355
31663
|
init_permissions();
|
|
@@ -31367,6 +31675,7 @@ var init_session2 = __esm({
|
|
|
31367
31675
|
#between = [];
|
|
31368
31676
|
#early = [];
|
|
31369
31677
|
#tasks;
|
|
31678
|
+
#todos = new CursorTodoList();
|
|
31370
31679
|
#config;
|
|
31371
31680
|
#sessionId;
|
|
31372
31681
|
#state = "idle";
|
|
@@ -31656,6 +31965,10 @@ var init_session2 = __esm({
|
|
|
31656
31965
|
this.#deliver(tasks);
|
|
31657
31966
|
return;
|
|
31658
31967
|
}
|
|
31968
|
+
if (notification.method === CURSOR_UPDATE_TODOS) {
|
|
31969
|
+
this.#deliver([this.#todos.apply(asRecord(notification.params) ?? {})]);
|
|
31970
|
+
return;
|
|
31971
|
+
}
|
|
31659
31972
|
const update = readSessionUpdate(notification);
|
|
31660
31973
|
if (!update) {
|
|
31661
31974
|
this.#options.log.debug("acp.notification_ignored", { method: notification.method });
|
|
@@ -31697,6 +32010,12 @@ var init_session2 = __esm({
|
|
|
31697
32010
|
case CURSOR_CREATE_PLAN:
|
|
31698
32011
|
this.#proposePlan(request3);
|
|
31699
32012
|
return;
|
|
32013
|
+
case CURSOR_UPDATE_TODOS:
|
|
32014
|
+
this.#deliver([this.#todos.apply(asRecord(request3.params) ?? {})]);
|
|
32015
|
+
void this.#rpc.respond(request3.id, {
|
|
32016
|
+
outcome: { outcome: "accepted", todos: this.#todos.accepted() }
|
|
32017
|
+
}).catch(() => void 0);
|
|
32018
|
+
return;
|
|
31700
32019
|
case "fs/read_text_file":
|
|
31701
32020
|
case "fs/write_text_file":
|
|
31702
32021
|
void this.#serveFs(request3);
|
|
@@ -32039,7 +32358,8 @@ function shellStart(update, sessionId) {
|
|
|
32039
32358
|
kind: "shell",
|
|
32040
32359
|
sessionId,
|
|
32041
32360
|
...launcher ? { launcherToolCallId: acpToolCallId(launcher) } : {},
|
|
32042
|
-
...label3 ? { label: label3 } : {}
|
|
32361
|
+
...label3 ? { label: label3 } : {},
|
|
32362
|
+
...command ? { command } : {}
|
|
32043
32363
|
}
|
|
32044
32364
|
}
|
|
32045
32365
|
];
|
|
@@ -32052,7 +32372,8 @@ function shellEnd(update) {
|
|
|
32052
32372
|
const exitCode = snapshot.exit_code;
|
|
32053
32373
|
const failed = typeof exitCode === "number" && exitCode !== 0 || optional3(snapshot.signal) !== void 0;
|
|
32054
32374
|
const ending = killed ? "stopped" : failed ? "failed" : "completed";
|
|
32055
|
-
|
|
32375
|
+
const reported = typeof exitCode === "number" && !killed ? { exitCode } : {};
|
|
32376
|
+
return [{ type: "end", taskId, ending, ...reported }];
|
|
32056
32377
|
}
|
|
32057
32378
|
function subagentFrames(update, sessionId) {
|
|
32058
32379
|
const taskId = optional3(update.subagent_id);
|
|
@@ -33023,7 +33344,9 @@ function cloudExecutionSection(spec) {
|
|
|
33023
33344
|
);
|
|
33024
33345
|
if (spec.agentId !== SETUP_AGENT_ID)
|
|
33025
33346
|
lines2.push(
|
|
33026
|
-
"
|
|
33347
|
+
"Persisting a system requirement discovered during the work is routine, not a new decision for the user. Trigger: any check in this turn reports a missing system package, OS library, toolchain or runtime service the repository does not already provide. Record the requirement in the repository's environment setup and validate it in the same turn; never end by reporting it as blocked, and never ask whether to persist it. A skill that inspects the image and reports a missing prerequisite is evidence for this step: its own scope limits what that skill may install, and never means the requirement goes unpersisted.",
|
|
33348
|
+
"Use the alan-environment-setup skill's maintenance path when installed and follow its validation requirements. Keep the session's working branch and existing PR; when the session has neither, use a branch for this change rather than main. Report a tool or authorization blocker only after the repository change is written. A package added to a manifest and lockfile is not a system requirement; the existing install already consumes it, so leave environment scripts and the image build alone.",
|
|
33349
|
+
"A committed setup file only affects sessions after a build. Do not run a build to finish this work: every successful build, a branch build included, replaces the image every session boots from, so promotion is the user's decision. Tell the user the change is committed but not yet in the image, and that they start a build from the environment's Builds tab when they want new sessions to have it."
|
|
33027
33350
|
);
|
|
33028
33351
|
}
|
|
33029
33352
|
lines2.push(
|
|
@@ -33094,6 +33417,7 @@ Prefer relative paths and keep your work scoped to this project.` : void 0;
|
|
|
33094
33417
|
cloud,
|
|
33095
33418
|
spec.contextGraphEnabled === true ? ALAN_CONTEXT_SEARCH_PROMPT : void 0,
|
|
33096
33419
|
overlay,
|
|
33420
|
+
PLAN_UPKEEP_PROMPT,
|
|
33097
33421
|
ALAN_VISUAL_REMINDER_PROMPT
|
|
33098
33422
|
])
|
|
33099
33423
|
};
|
|
@@ -33110,7 +33434,7 @@ function buildCombinedSystemPrompt(input2) {
|
|
|
33110
33434
|
const text3 = system.join("\n\n");
|
|
33111
33435
|
return present([text3, ...append.filter((part) => !text3.includes(part))]).join("\n\n") || void 0;
|
|
33112
33436
|
}
|
|
33113
|
-
var import_node_path15, INSTALLED_SKILLS_MAX_CHARS, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS;
|
|
33437
|
+
var import_node_path15, PLAN_UPKEEP_PROMPT, INSTALLED_SKILLS_MAX_CHARS, INSTALLED_SKILL_DESCRIPTION_MAX_CHARS;
|
|
33114
33438
|
var init_system = __esm({
|
|
33115
33439
|
"../agent-core/src/prompt/system.ts"() {
|
|
33116
33440
|
"use strict";
|
|
@@ -33118,6 +33442,10 @@ var init_system = __esm({
|
|
|
33118
33442
|
init_agent2();
|
|
33119
33443
|
init_sections();
|
|
33120
33444
|
init_spec();
|
|
33445
|
+
PLAN_UPKEEP_PROMPT = [
|
|
33446
|
+
"## Plan upkeep",
|
|
33447
|
+
"For work with three or more steps, keep your todo list current in your own todo or plan tool (Alan's update_plan when you have none): write it before you start, mark one step in_progress before you work on it, mark it completed or failed the moment it ends, and settle every step before your final answer."
|
|
33448
|
+
].join("\n");
|
|
33121
33449
|
INSTALLED_SKILLS_MAX_CHARS = 8e3;
|
|
33122
33450
|
INSTALLED_SKILL_DESCRIPTION_MAX_CHARS = 200;
|
|
33123
33451
|
}
|
|
@@ -33481,7 +33809,7 @@ function steerEcho(request3) {
|
|
|
33481
33809
|
sessionUpdate: "user_message",
|
|
33482
33810
|
messageId: request3.steerId,
|
|
33483
33811
|
content: [{ type: "text", text: request3.text }],
|
|
33484
|
-
_meta: { [STEER_ID_META]: request3.steerId }
|
|
33812
|
+
_meta: { ...senderMeta(request3.sender), [STEER_ID_META]: request3.steerId }
|
|
33485
33813
|
};
|
|
33486
33814
|
}
|
|
33487
33815
|
function unansweredSteers(turn, result) {
|
|
@@ -33518,8 +33846,8 @@ function toTurnResult(harness, outcome2, spec, providerSessionId, clock, apiKeyS
|
|
|
33518
33846
|
}
|
|
33519
33847
|
}
|
|
33520
33848
|
}
|
|
33521
|
-
function refusalResult(harness,
|
|
33522
|
-
const problem = createCliProblem(
|
|
33849
|
+
function refusalResult(harness, refusal3, spec, clock, apiKeySupplied) {
|
|
33850
|
+
const problem = createCliProblem(refusal3.classified ?? specForErrorKind("not_authenticated"), {
|
|
33523
33851
|
harness,
|
|
33524
33852
|
phase: "preflight",
|
|
33525
33853
|
finality: "terminal",
|
|
@@ -33580,7 +33908,7 @@ function createPersistentDriver(provider5, options) {
|
|
|
33580
33908
|
log.warn("holder.mcp_server_not_offered", { runId, reason });
|
|
33581
33909
|
}
|
|
33582
33910
|
};
|
|
33583
|
-
const
|
|
33911
|
+
const open7 = async (spec, signal) => {
|
|
33584
33912
|
await options.nativeIdentity?.assertResolved();
|
|
33585
33913
|
let opened;
|
|
33586
33914
|
const operation = async () => {
|
|
@@ -33602,7 +33930,7 @@ function createPersistentDriver(provider5, options) {
|
|
|
33602
33930
|
const resumeId = requested !== void 0 && requested !== live.rejectedSessionId && provider5.canResume(wanted, requested) ? requested : void 0;
|
|
33603
33931
|
const planned = provider5.plan(spec, inputs, resumeId, managedMcp);
|
|
33604
33932
|
reportSkippedMcp(planned, spec.runId);
|
|
33605
|
-
const opened = await
|
|
33933
|
+
const opened = await open7(planned.spec);
|
|
33606
33934
|
live.current = {
|
|
33607
33935
|
session: opened.session,
|
|
33608
33936
|
key: planned.key,
|
|
@@ -33875,7 +34203,7 @@ function createPersistentDriver(provider5, options) {
|
|
|
33875
34203
|
return {
|
|
33876
34204
|
...preparationMethods({
|
|
33877
34205
|
provider: provider5,
|
|
33878
|
-
open:
|
|
34206
|
+
open: open7,
|
|
33879
34207
|
serial,
|
|
33880
34208
|
current: () => live.current,
|
|
33881
34209
|
running: () => live.turn !== void 0,
|
|
@@ -33887,8 +34215,8 @@ function createPersistentDriver(provider5, options) {
|
|
|
33887
34215
|
}
|
|
33888
34216
|
}),
|
|
33889
34217
|
runTurn: async (spec, sink, signal, inputs) => {
|
|
33890
|
-
const
|
|
33891
|
-
if (
|
|
34218
|
+
const refusal3 = await refuseRun(spec);
|
|
34219
|
+
if (refusal3) return refusal3;
|
|
33892
34220
|
if (live.fallbackOnly && options.fallback && inputs.codex === void 0)
|
|
33893
34221
|
return options.fallback.runTurn(spec, sink, signal, inputs);
|
|
33894
34222
|
if (signal.aborted) return { outcome: "aborted" };
|
|
@@ -33930,11 +34258,11 @@ function createPersistentDriver(provider5, options) {
|
|
|
33930
34258
|
steer,
|
|
33931
34259
|
activity: () => {
|
|
33932
34260
|
const session = live.current?.session;
|
|
33933
|
-
const
|
|
34261
|
+
const open8 = session !== void 0 && session.state !== "closed";
|
|
33934
34262
|
return {
|
|
33935
|
-
cliPid:
|
|
34263
|
+
cliPid: open8 ? session.pid ?? null : null,
|
|
33936
34264
|
awaitingInput: (live.turn?.waiting.size ?? 0) > 0,
|
|
33937
|
-
backgroundTasks:
|
|
34265
|
+
backgroundTasks: open8 ? session.backgroundTasks ?? 0 : 0
|
|
33938
34266
|
};
|
|
33939
34267
|
},
|
|
33940
34268
|
stopTask: async (taskId) => {
|
|
@@ -35715,11 +36043,12 @@ var init_parts = __esm({
|
|
|
35715
36043
|
}
|
|
35716
36044
|
/** OpenCode's to-do list is the plan, sent once per call although every frame repeats it. */
|
|
35717
36045
|
#plan(toolCallId, name, toolState) {
|
|
35718
|
-
const
|
|
35719
|
-
|
|
35720
|
-
|
|
36046
|
+
const input2 = toolState?.input;
|
|
36047
|
+
const todos = asRecord(input2)?.todos;
|
|
36048
|
+
const update = normalizeToolName2(name) === "todowrite" && Array.isArray(todos) ? todoPlanUpdate(toolCallId, todos) : alanPlanUpdate(name, toolCallId, input2);
|
|
36049
|
+
if (!update || this.#planned.has(toolCallId)) return [];
|
|
35721
36050
|
this.#planned.add(toolCallId);
|
|
35722
|
-
return [
|
|
36051
|
+
return [update];
|
|
35723
36052
|
}
|
|
35724
36053
|
#stepFinish(part, child) {
|
|
35725
36054
|
const id = asString(part.id);
|
|
@@ -37932,9 +38261,78 @@ var init_grammar_shared = __esm({
|
|
|
37932
38261
|
}
|
|
37933
38262
|
});
|
|
37934
38263
|
|
|
38264
|
+
// ../agent-core/src/providers/claude/task-list.ts
|
|
38265
|
+
var TASK_LIST_PLAN_ID, CREATED_TASK_ID, ClaudeTaskList;
|
|
38266
|
+
var init_task_list = __esm({
|
|
38267
|
+
"../agent-core/src/providers/claude/task-list.ts"() {
|
|
38268
|
+
"use strict";
|
|
38269
|
+
init_constants();
|
|
38270
|
+
init_acp2();
|
|
38271
|
+
init_kernel2();
|
|
38272
|
+
TASK_LIST_PLAN_ID = "claude-tasks";
|
|
38273
|
+
CREATED_TASK_ID = /#\s*(\d+)/;
|
|
38274
|
+
ClaudeTaskList = class {
|
|
38275
|
+
#tasks = /* @__PURE__ */ new Map();
|
|
38276
|
+
#pending = /* @__PURE__ */ new Map();
|
|
38277
|
+
toolUse(toolCallId, name, input2) {
|
|
38278
|
+
switch (normalizeToolName2(name)) {
|
|
38279
|
+
case "taskcreate": {
|
|
38280
|
+
const subject = asString(input2.subject) || asString(input2.activeForm);
|
|
38281
|
+
if (subject) this.#pending.set(toolCallId, { subject });
|
|
38282
|
+
return [];
|
|
38283
|
+
}
|
|
38284
|
+
case "taskupdate":
|
|
38285
|
+
return this.#update(input2);
|
|
38286
|
+
default:
|
|
38287
|
+
return [];
|
|
38288
|
+
}
|
|
38289
|
+
}
|
|
38290
|
+
toolResult(toolCallId, text3, structured) {
|
|
38291
|
+
const created = this.#pending.get(toolCallId);
|
|
38292
|
+
if (!created) return [];
|
|
38293
|
+
this.#pending.delete(toolCallId);
|
|
38294
|
+
const id = asString(asRecord(asRecord(structured)?.task)?.id) || CREATED_TASK_ID.exec(text3)?.[1];
|
|
38295
|
+
if (!id) return [];
|
|
38296
|
+
this.#tasks.set(id, { id, subject: created.subject, status: "pending" });
|
|
38297
|
+
return [this.#snapshot()];
|
|
38298
|
+
}
|
|
38299
|
+
#update(input2) {
|
|
38300
|
+
const id = asString(input2.taskId) || asString(input2.id) || asString(input2.task_id);
|
|
38301
|
+
const task = this.#tasks.get(id);
|
|
38302
|
+
if (!task) return [];
|
|
38303
|
+
const status = asString(input2.status);
|
|
38304
|
+
if (status === "deleted") {
|
|
38305
|
+
this.#tasks.delete(id);
|
|
38306
|
+
return [this.#snapshot()];
|
|
38307
|
+
}
|
|
38308
|
+
if (status) task.status = planEntryStatus(status);
|
|
38309
|
+
const subject = asString(input2.subject);
|
|
38310
|
+
if (subject) task.subject = subject;
|
|
38311
|
+
return [this.#snapshot()];
|
|
38312
|
+
}
|
|
38313
|
+
#snapshot() {
|
|
38314
|
+
const entries2 = [...this.#tasks.values()].map(
|
|
38315
|
+
(task) => ({
|
|
38316
|
+
id: task.id,
|
|
38317
|
+
content: task.subject,
|
|
38318
|
+
priority: "medium",
|
|
38319
|
+
status: task.status
|
|
38320
|
+
})
|
|
38321
|
+
);
|
|
38322
|
+
return planSnapshot(TASK_LIST_PLAN_ID, entries2);
|
|
38323
|
+
}
|
|
38324
|
+
};
|
|
38325
|
+
}
|
|
38326
|
+
});
|
|
38327
|
+
|
|
37935
38328
|
// ../agent-core/src/providers/claude/grammar-state.ts
|
|
37936
38329
|
function createClaudeGrammarState() {
|
|
37937
|
-
return {
|
|
38330
|
+
return {
|
|
38331
|
+
counter: 0,
|
|
38332
|
+
streamedTextIds: /* @__PURE__ */ new Set(),
|
|
38333
|
+
thoughtBlocks: /* @__PURE__ */ new Map(),
|
|
38334
|
+
taskList: new ClaudeTaskList()
|
|
38335
|
+
};
|
|
37938
38336
|
}
|
|
37939
38337
|
function synthId(state2, prefix2) {
|
|
37940
38338
|
state2.counter += 1;
|
|
@@ -37952,6 +38350,7 @@ var init_grammar_state = __esm({
|
|
|
37952
38350
|
"../agent-core/src/providers/claude/grammar-state.ts"() {
|
|
37953
38351
|
"use strict";
|
|
37954
38352
|
init_acp2();
|
|
38353
|
+
init_task_list();
|
|
37955
38354
|
ThoughtBlocks = class {
|
|
37956
38355
|
#blocks = /* @__PURE__ */ new Map();
|
|
37957
38356
|
#frames = /* @__PURE__ */ new Map();
|
|
@@ -38241,7 +38640,7 @@ function parseClaudeEvent(event, state2) {
|
|
|
38241
38640
|
case "assistant":
|
|
38242
38641
|
return parseAssistant(event, state2);
|
|
38243
38642
|
case "user":
|
|
38244
|
-
return parseUser(event);
|
|
38643
|
+
return parseUser(event, state2);
|
|
38245
38644
|
case "result":
|
|
38246
38645
|
return parseResult(event, state2);
|
|
38247
38646
|
case "rate_limit_event":
|
|
@@ -38289,9 +38688,15 @@ function blockUpdates(frame, block2) {
|
|
|
38289
38688
|
if (blockType === "text") return textUpdates(frame, block2);
|
|
38290
38689
|
frame.previousBlockWasText = false;
|
|
38291
38690
|
if (blockType === "thinking") return thoughtUpdates(frame);
|
|
38292
|
-
if (blockType === "tool_use") return parseToolUse(block2, frame.meta);
|
|
38691
|
+
if (blockType === "tool_use") return parseToolUse(block2, frame.meta, frame.state);
|
|
38293
38692
|
return [];
|
|
38294
38693
|
}
|
|
38694
|
+
function providerLimitMeta(event, message, meta3) {
|
|
38695
|
+
if (asString(message.model) !== "<synthetic>" || asString(event.error) !== "rate_limit") {
|
|
38696
|
+
return meta3;
|
|
38697
|
+
}
|
|
38698
|
+
return { _meta: { ...meta3._meta, [SYNTHETIC_META]: "rate_limit" } };
|
|
38699
|
+
}
|
|
38295
38700
|
function parseAssistant(event, state2) {
|
|
38296
38701
|
const message = asRecord(event.message);
|
|
38297
38702
|
if (!message) return [];
|
|
@@ -38300,7 +38705,8 @@ function parseAssistant(event, state2) {
|
|
|
38300
38705
|
const content = asArray(message.content);
|
|
38301
38706
|
const frame = {
|
|
38302
38707
|
messageId,
|
|
38303
|
-
meta: nesting(event),
|
|
38708
|
+
meta: providerLimitMeta(event, message, nesting(event)),
|
|
38709
|
+
state: state2,
|
|
38304
38710
|
alreadyStreamed: state2.streamedTextIds.has(messageId),
|
|
38305
38711
|
thoughts: thoughtsOf(event, content, messageId, state2),
|
|
38306
38712
|
thoughtEmitted: false,
|
|
@@ -38321,7 +38727,7 @@ function toolUseMeta(name, input2, meta3) {
|
|
|
38321
38727
|
...!isAsk && normalizeToolName2(name) === "exitplanmode" ? { [EXIT_PLAN_MODE_INPUT_META]: input2 } : {}
|
|
38322
38728
|
};
|
|
38323
38729
|
}
|
|
38324
|
-
function parseToolUse(block2, meta3) {
|
|
38730
|
+
function parseToolUse(block2, meta3, state2) {
|
|
38325
38731
|
const toolCallId = asString(block2.id);
|
|
38326
38732
|
if (!toolCallId) return [];
|
|
38327
38733
|
const name = canonicalizeManagedMcpToolName(asString(block2.name));
|
|
@@ -38341,12 +38747,17 @@ function parseToolUse(block2, meta3) {
|
|
|
38341
38747
|
_meta: toolUseMeta(name, inputRecord, meta3)
|
|
38342
38748
|
}
|
|
38343
38749
|
];
|
|
38344
|
-
if (
|
|
38345
|
-
|
|
38750
|
+
if (!meta3._meta?.[PARENT_TOOL_CALL_META]) {
|
|
38751
|
+
if (normalizeToolName2(name) === "todowrite") {
|
|
38752
|
+
updates.push(todoPlanUpdate(toolCallId, asArray(inputRecord.todos)));
|
|
38753
|
+
}
|
|
38754
|
+
const alanPlan = alanPlanUpdate(name, toolCallId, input2);
|
|
38755
|
+
if (alanPlan) updates.push(alanPlan);
|
|
38756
|
+
updates.push(...state2.taskList.toolUse(toolCallId, name, inputRecord));
|
|
38346
38757
|
}
|
|
38347
38758
|
return updates;
|
|
38348
38759
|
}
|
|
38349
|
-
function parseUser(event) {
|
|
38760
|
+
function parseUser(event, state2) {
|
|
38350
38761
|
const message = asRecord(event.message);
|
|
38351
38762
|
if (!message) return [];
|
|
38352
38763
|
const meta3 = nesting(event);
|
|
@@ -38358,6 +38769,7 @@ function parseUser(event) {
|
|
|
38358
38769
|
const text3 = flattenToolResult(block2.content);
|
|
38359
38770
|
const content = outputContent(text3);
|
|
38360
38771
|
const diffs = claudeFileChangeContents(event.tool_use_result);
|
|
38772
|
+
const tasks = block2.is_error === true || meta3._meta ? [] : state2.taskList.toolResult(toolCallId, text3, event.tool_use_result);
|
|
38361
38773
|
return [
|
|
38362
38774
|
{
|
|
38363
38775
|
sessionUpdate: "tool_call_update",
|
|
@@ -38366,7 +38778,8 @@ function parseUser(event) {
|
|
|
38366
38778
|
...content || diffs.length ? { content: [...diffs, ...content ?? []] } : {},
|
|
38367
38779
|
rawOutput: text3,
|
|
38368
38780
|
_meta: { ...meta3._meta, [PROVIDER_PAYLOAD_META]: event.tool_use_result ?? block2 }
|
|
38369
|
-
}
|
|
38781
|
+
},
|
|
38782
|
+
...tasks
|
|
38370
38783
|
];
|
|
38371
38784
|
});
|
|
38372
38785
|
}
|
|
@@ -38493,6 +38906,73 @@ var init_messages = __esm({
|
|
|
38493
38906
|
}
|
|
38494
38907
|
});
|
|
38495
38908
|
|
|
38909
|
+
// ../agent-core/src/providers/claude/task-output-tail.ts
|
|
38910
|
+
async function readFileTail(path18) {
|
|
38911
|
+
try {
|
|
38912
|
+
const file2 = await (0, import_promises23.open)(path18, "r");
|
|
38913
|
+
try {
|
|
38914
|
+
const { size } = await file2.stat();
|
|
38915
|
+
const length = Math.min(size, TAIL_BYTES);
|
|
38916
|
+
const buffer = Buffer.alloc(length);
|
|
38917
|
+
await file2.read(buffer, 0, length, size - length);
|
|
38918
|
+
return buffer.toString("utf8");
|
|
38919
|
+
} finally {
|
|
38920
|
+
await file2.close();
|
|
38921
|
+
}
|
|
38922
|
+
} catch {
|
|
38923
|
+
return "";
|
|
38924
|
+
}
|
|
38925
|
+
}
|
|
38926
|
+
var import_promises23, TAIL_BYTES, TaskOutputTail;
|
|
38927
|
+
var init_task_output_tail = __esm({
|
|
38928
|
+
"../agent-core/src/providers/claude/task-output-tail.ts"() {
|
|
38929
|
+
"use strict";
|
|
38930
|
+
import_promises23 = require("node:fs/promises");
|
|
38931
|
+
init_acp();
|
|
38932
|
+
TAIL_BYTES = MAX_LAST_OUTPUT_CHARS * 8;
|
|
38933
|
+
TaskOutputTail = class {
|
|
38934
|
+
#options;
|
|
38935
|
+
#loop;
|
|
38936
|
+
constructor(options) {
|
|
38937
|
+
this.#options = options;
|
|
38938
|
+
}
|
|
38939
|
+
/** Starts the timer if a running task has a file to read and none runs yet. */
|
|
38940
|
+
ensureRunning() {
|
|
38941
|
+
if (this.#loop || this.#options.records.outputWatched().length === 0) return;
|
|
38942
|
+
const loop = new AbortController();
|
|
38943
|
+
this.#loop = loop;
|
|
38944
|
+
void this.#run(loop.signal).finally(() => {
|
|
38945
|
+
if (this.#loop === loop) this.#loop = void 0;
|
|
38946
|
+
});
|
|
38947
|
+
}
|
|
38948
|
+
stop() {
|
|
38949
|
+
this.#loop?.abort();
|
|
38950
|
+
this.#loop = void 0;
|
|
38951
|
+
}
|
|
38952
|
+
async #run(signal) {
|
|
38953
|
+
while (!signal.aborted) {
|
|
38954
|
+
try {
|
|
38955
|
+
await this.#options.clock.sleep(LAST_OUTPUT_INTERVAL_MS, signal);
|
|
38956
|
+
} catch {
|
|
38957
|
+
return;
|
|
38958
|
+
}
|
|
38959
|
+
const watched = this.#options.records.outputWatched();
|
|
38960
|
+
if (watched.length === 0) return;
|
|
38961
|
+
await Promise.all(watched.map((record3) => this.#refresh(record3, signal)));
|
|
38962
|
+
}
|
|
38963
|
+
}
|
|
38964
|
+
async #refresh(record3, signal) {
|
|
38965
|
+
const path18 = record3.meta.outputFile;
|
|
38966
|
+
if (!path18) return;
|
|
38967
|
+
const text3 = await (this.#options.readTail ?? readFileTail)(path18);
|
|
38968
|
+
if (signal.aborted) return;
|
|
38969
|
+
const update = this.#options.records.noteOutput(record3, lastOutputLine(text3));
|
|
38970
|
+
if (update) this.#options.emit(update, record3.ownerTurnId);
|
|
38971
|
+
}
|
|
38972
|
+
};
|
|
38973
|
+
}
|
|
38974
|
+
});
|
|
38975
|
+
|
|
38496
38976
|
// ../agent-core/src/providers/claude/task-records.ts
|
|
38497
38977
|
function taskKind(taskType) {
|
|
38498
38978
|
return taskType === "local_bash" ? "shell" : "agent";
|
|
@@ -38505,13 +38985,27 @@ function launcherLabel(update) {
|
|
|
38505
38985
|
const description2 = asRecord(update.rawInput)?.description;
|
|
38506
38986
|
return nonEmpty(description2) ?? nonEmpty(update.title);
|
|
38507
38987
|
}
|
|
38988
|
+
function exitCodeOf(summary) {
|
|
38989
|
+
const code = summary ? EXIT_CODE.exec(summary)?.[1] : void 0;
|
|
38990
|
+
return code === void 0 ? void 0 : Number(code);
|
|
38991
|
+
}
|
|
38992
|
+
function outputFileOf(rawOutput) {
|
|
38993
|
+
return typeof rawOutput === "string" ? OUTPUT_FILE.exec(rawOutput)?.[1] : void 0;
|
|
38994
|
+
}
|
|
38995
|
+
function adoptOutputFile(record3, rawOutput) {
|
|
38996
|
+
const outputFile = outputFileOf(rawOutput);
|
|
38997
|
+
if (outputFile && !record3.meta.outputFile) record3.meta = { ...record3.meta, outputFile };
|
|
38998
|
+
}
|
|
38999
|
+
function launcherCommand(update) {
|
|
39000
|
+
return nonEmpty(asRecord(update.rawInput)?.command);
|
|
39001
|
+
}
|
|
38508
39002
|
function isSettled(update) {
|
|
38509
39003
|
return update.status === "completed" || update.status === "failed" || update.status === "cancelled";
|
|
38510
39004
|
}
|
|
38511
39005
|
function isRunningTask(record3) {
|
|
38512
39006
|
return record3.meta.status === "running" || record3.meta.status === "stopping";
|
|
38513
39007
|
}
|
|
38514
|
-
var STOPPED_STATUSES, TaskRecords;
|
|
39008
|
+
var STOPPED_STATUSES, EXIT_CODE, OUTPUT_FILE, TaskRecords;
|
|
38515
39009
|
var init_task_records = __esm({
|
|
38516
39010
|
"../agent-core/src/providers/claude/task-records.ts"() {
|
|
38517
39011
|
"use strict";
|
|
@@ -38523,10 +39017,13 @@ var init_task_records = __esm({
|
|
|
38523
39017
|
"cancelled",
|
|
38524
39018
|
"canceled"
|
|
38525
39019
|
]);
|
|
39020
|
+
EXIT_CODE = /\(exit code (-?\d+)\)/i;
|
|
39021
|
+
OUTPUT_FILE = /Output is being written to:\s*(\S+\.output)/;
|
|
38526
39022
|
TaskRecords = class {
|
|
38527
39023
|
#records = /* @__PURE__ */ new Map();
|
|
38528
|
-
/** Launchers are announced before Claude names their task, so the label
|
|
39024
|
+
/** Launchers are announced before Claude names their task, so the label and command wait here. */
|
|
38529
39025
|
#labels = /* @__PURE__ */ new Map();
|
|
39026
|
+
#commands = /* @__PURE__ */ new Map();
|
|
38530
39027
|
#now;
|
|
38531
39028
|
constructor(now) {
|
|
38532
39029
|
this.#now = now;
|
|
@@ -38604,6 +39101,44 @@ var init_task_records = __esm({
|
|
|
38604
39101
|
const stopped = record3.userStopRequested || status !== void 0 && STOPPED_STATUSES.has(status);
|
|
38605
39102
|
this.setStatus(record3, stopped ? "stopped" : failed ? "failed" : "completed");
|
|
38606
39103
|
}
|
|
39104
|
+
/** A shell's terminal status arrives before its notification, so the chat can show the end at once. */
|
|
39105
|
+
applyPatch(event) {
|
|
39106
|
+
const record3 = this.#records.get(asString(event.task_id));
|
|
39107
|
+
if (!record3) return;
|
|
39108
|
+
const patch = asRecord(event.patch);
|
|
39109
|
+
const status = nonEmpty(patch?.status)?.toLowerCase();
|
|
39110
|
+
const endTime = asFiniteNumber(patch?.end_time);
|
|
39111
|
+
if (endTime !== void 0) record3.meta = { ...record3.meta, endedAt: endTime };
|
|
39112
|
+
if (!status || !isRunningTask(record3) || record3.meta.kind !== "shell") return;
|
|
39113
|
+
if (status === "completed") this.settle(record3, status, false);
|
|
39114
|
+
else if (status === "failed") this.settle(record3, status, true);
|
|
39115
|
+
else if (STOPPED_STATUSES.has(status)) this.settle(record3, status, false);
|
|
39116
|
+
}
|
|
39117
|
+
/** Records how a task ended; an absent `endedAt` becomes the time this daemon heard of it. */
|
|
39118
|
+
recordOutcome(record3, outcome2) {
|
|
39119
|
+
const exitCode = exitCodeOf(outcome2.summary);
|
|
39120
|
+
record3.meta = {
|
|
39121
|
+
...record3.meta,
|
|
39122
|
+
endedAt: record3.meta.endedAt ?? outcome2.endedAt ?? this.#now(),
|
|
39123
|
+
...outcome2.outputFile ? { outputFile: outcome2.outputFile } : {},
|
|
39124
|
+
...outcome2.summary ? { summary: outcome2.summary } : {},
|
|
39125
|
+
...exitCode === void 0 ? {} : { exitCode }
|
|
39126
|
+
};
|
|
39127
|
+
}
|
|
39128
|
+
/** Running background shells whose output file is known: what the output tail reads. */
|
|
39129
|
+
outputWatched() {
|
|
39130
|
+
return [...this.#records.values()].filter(
|
|
39131
|
+
(record3) => record3.meta.backgrounded && record3.meta.kind === "shell" && isRunningTask(record3) && record3.meta.outputFile !== void 0
|
|
39132
|
+
);
|
|
39133
|
+
}
|
|
39134
|
+
/** Records a task's newest output line; the update to announce it, or nothing when it is unchanged. */
|
|
39135
|
+
noteOutput(record3, lastOutput) {
|
|
39136
|
+
if (!lastOutput || lastOutput === record3.meta.lastOutput || !isRunningTask(record3)) {
|
|
39137
|
+
return void 0;
|
|
39138
|
+
}
|
|
39139
|
+
record3.meta = { ...record3.meta, lastOutput };
|
|
39140
|
+
return this.metaUpdate(record3);
|
|
39141
|
+
}
|
|
38607
39142
|
/** The update that re-announces a task's meta on its launcher. */
|
|
38608
39143
|
metaUpdate(record3) {
|
|
38609
39144
|
if (!record3.launcherToolUseId) return void 0;
|
|
@@ -38617,10 +39152,17 @@ var init_task_records = __esm({
|
|
|
38617
39152
|
if (!isUpdate(update, "tool_call_update")) return update;
|
|
38618
39153
|
const label3 = launcherLabel(update);
|
|
38619
39154
|
if (label3 && !this.#labels.has(update.toolCallId)) this.#labels.set(update.toolCallId, label3);
|
|
39155
|
+
const command = launcherCommand(update);
|
|
39156
|
+
if (command && !this.#commands.has(update.toolCallId))
|
|
39157
|
+
this.#commands.set(update.toolCallId, command);
|
|
38620
39158
|
const record3 = this.#forLauncher(update.toolCallId);
|
|
38621
39159
|
if (!record3) return update;
|
|
38622
39160
|
const remembered = record3.meta.label ?? this.#labels.get(update.toolCallId);
|
|
38623
39161
|
if (!record3.meta.label && remembered) record3.meta = { ...record3.meta, label: remembered };
|
|
39162
|
+
adoptOutputFile(record3, update.rawOutput);
|
|
39163
|
+
const rememberedCommand = this.#commands.get(update.toolCallId);
|
|
39164
|
+
if (rememberedCommand && !record3.meta.command)
|
|
39165
|
+
record3.meta = { ...record3.meta, command: rememberedCommand };
|
|
38624
39166
|
if (isSettled(update) && record3.meta.kind === "agent" && isRunningTask(record3)) {
|
|
38625
39167
|
this.settle(record3, update.status ?? void 0, update.status !== "completed");
|
|
38626
39168
|
}
|
|
@@ -38780,6 +39322,93 @@ var init_background_tasks = __esm({
|
|
|
38780
39322
|
}
|
|
38781
39323
|
});
|
|
38782
39324
|
|
|
39325
|
+
// ../agent-core/src/providers/claude/live-usage.ts
|
|
39326
|
+
function readCounts(usage) {
|
|
39327
|
+
return {
|
|
39328
|
+
inputTokens: asFiniteNumber(usage.input_tokens) ?? 0,
|
|
39329
|
+
outputTokens: asFiniteNumber(usage.output_tokens) ?? 0,
|
|
39330
|
+
cacheReadTokens: asFiniteNumber(usage.cache_read_input_tokens) ?? 0,
|
|
39331
|
+
cacheWriteTokens: asFiniteNumber(usage.cache_creation_input_tokens) ?? 0
|
|
39332
|
+
};
|
|
39333
|
+
}
|
|
39334
|
+
function largest(a, b) {
|
|
39335
|
+
return {
|
|
39336
|
+
inputTokens: Math.max(a.inputTokens, b.inputTokens),
|
|
39337
|
+
outputTokens: Math.max(a.outputTokens, b.outputTokens),
|
|
39338
|
+
cacheReadTokens: Math.max(a.cacheReadTokens, b.cacheReadTokens),
|
|
39339
|
+
cacheWriteTokens: Math.max(a.cacheWriteTokens, b.cacheWriteTokens)
|
|
39340
|
+
};
|
|
39341
|
+
}
|
|
39342
|
+
var NO_COUNTS, ClaudeLiveUsage;
|
|
39343
|
+
var init_live_usage = __esm({
|
|
39344
|
+
"../agent-core/src/providers/claude/live-usage.ts"() {
|
|
39345
|
+
"use strict";
|
|
39346
|
+
init_acp2();
|
|
39347
|
+
init_kernel2();
|
|
39348
|
+
NO_COUNTS = {
|
|
39349
|
+
inputTokens: 0,
|
|
39350
|
+
outputTokens: 0,
|
|
39351
|
+
cacheReadTokens: 0,
|
|
39352
|
+
cacheWriteTokens: 0
|
|
39353
|
+
};
|
|
39354
|
+
ClaudeLiveUsage = class {
|
|
39355
|
+
#messages = /* @__PURE__ */ new Map();
|
|
39356
|
+
#announcedOutput = 0;
|
|
39357
|
+
/** `message_delta` names no message; it belongs to the last `message_start`. */
|
|
39358
|
+
#currentId;
|
|
39359
|
+
/** The usage a main-thread frame adds, or none when it changes nothing worth showing. */
|
|
39360
|
+
read(event, model2) {
|
|
39361
|
+
if (asString(event.parent_tool_use_id)) return [];
|
|
39362
|
+
const reading = this.#reading(event);
|
|
39363
|
+
if (!reading) return [];
|
|
39364
|
+
const known = this.#messages.get(reading.id) ?? NO_COUNTS;
|
|
39365
|
+
this.#messages.set(reading.id, largest(known, reading.counts));
|
|
39366
|
+
const total = this.#total();
|
|
39367
|
+
if (total.outputTokens <= this.#announcedOutput) return [];
|
|
39368
|
+
this.#announcedOutput = total.outputTokens;
|
|
39369
|
+
return usageUpdates({ ...total, model: model2, modelCalls: this.#messages.size });
|
|
39370
|
+
}
|
|
39371
|
+
/** A `result` settles every message so far; the next segment counts from nothing. */
|
|
39372
|
+
settle() {
|
|
39373
|
+
this.#messages.clear();
|
|
39374
|
+
}
|
|
39375
|
+
#reading(event) {
|
|
39376
|
+
const type = asString(event.type);
|
|
39377
|
+
if (type === "assistant") {
|
|
39378
|
+
const message = asRecord(event.message);
|
|
39379
|
+
const usage2 = asRecord(message?.usage);
|
|
39380
|
+
const id2 = asString(message?.id);
|
|
39381
|
+
return usage2 && id2 && asString(message?.model) !== "<synthetic>" ? { id: id2, counts: readCounts(usage2) } : void 0;
|
|
39382
|
+
}
|
|
39383
|
+
if (type !== "stream_event") return void 0;
|
|
39384
|
+
const inner = asRecord(event.event);
|
|
39385
|
+
const kind = asString(inner?.type);
|
|
39386
|
+
if (kind === "message_start") {
|
|
39387
|
+
const message = asRecord(inner?.message);
|
|
39388
|
+
const usage2 = asRecord(message?.usage);
|
|
39389
|
+
const id2 = asString(message?.id);
|
|
39390
|
+
this.#currentId = id2 || void 0;
|
|
39391
|
+
return id2 ? { id: id2, counts: usage2 ? { ...readCounts(usage2), outputTokens: 0 } : NO_COUNTS } : void 0;
|
|
39392
|
+
}
|
|
39393
|
+
if (kind !== "message_delta") return void 0;
|
|
39394
|
+
const usage = asRecord(inner?.usage);
|
|
39395
|
+
const id = this.#currentId;
|
|
39396
|
+
return usage && id ? { id, counts: readCounts(usage) } : void 0;
|
|
39397
|
+
}
|
|
39398
|
+
#total() {
|
|
39399
|
+
const sum = { ...NO_COUNTS };
|
|
39400
|
+
for (const counts of this.#messages.values()) {
|
|
39401
|
+
sum.inputTokens += counts.inputTokens;
|
|
39402
|
+
sum.outputTokens += counts.outputTokens;
|
|
39403
|
+
sum.cacheReadTokens += counts.cacheReadTokens;
|
|
39404
|
+
sum.cacheWriteTokens += counts.cacheWriteTokens;
|
|
39405
|
+
}
|
|
39406
|
+
return sum;
|
|
39407
|
+
}
|
|
39408
|
+
};
|
|
39409
|
+
}
|
|
39410
|
+
});
|
|
39411
|
+
|
|
38783
39412
|
// ../agent-core/src/providers/claude/task-events.ts
|
|
38784
39413
|
function text(record3, ...keys) {
|
|
38785
39414
|
for (const key of keys) {
|
|
@@ -38820,6 +39449,10 @@ function notificationResultText(notification) {
|
|
|
38820
39449
|
if (notification.totalTokens !== void 0) details.push(`Tokens: ${notification.totalTokens}.`);
|
|
38821
39450
|
return details.join(" ");
|
|
38822
39451
|
}
|
|
39452
|
+
function shellResultText(notification) {
|
|
39453
|
+
if (isInterrupted(notification)) return "Command stopped.";
|
|
39454
|
+
return notification.summary ?? `Command ${notification.status ?? "completed"}.`;
|
|
39455
|
+
}
|
|
38823
39456
|
function outputMeta(notification) {
|
|
38824
39457
|
return notification.outputFile ? { [SUBAGENT_OUTPUT_FILE_META]: notification.outputFile } : {};
|
|
38825
39458
|
}
|
|
@@ -38916,12 +39549,12 @@ function resultContextWindow(event, model2) {
|
|
|
38916
39549
|
if (!byModel) return void 0;
|
|
38917
39550
|
const own2 = asFiniteNumber(asRecord(byModel[model2])?.contextWindow);
|
|
38918
39551
|
if (own2 !== void 0) return own2;
|
|
38919
|
-
let
|
|
39552
|
+
let largest2;
|
|
38920
39553
|
for (const entry2 of Object.values(byModel)) {
|
|
38921
39554
|
const size = asFiniteNumber(asRecord(entry2)?.contextWindow);
|
|
38922
|
-
if (size !== void 0 && size > (
|
|
39555
|
+
if (size !== void 0 && size > (largest2 ?? 0)) largest2 = size;
|
|
38923
39556
|
}
|
|
38924
|
-
return
|
|
39557
|
+
return largest2;
|
|
38925
39558
|
}
|
|
38926
39559
|
function resultUsage(event, context) {
|
|
38927
39560
|
const usage = asRecord(event.usage);
|
|
@@ -38969,6 +39602,10 @@ var init_turn_result = __esm({
|
|
|
38969
39602
|
});
|
|
38970
39603
|
|
|
38971
39604
|
// ../agent-core/src/providers/claude/turn.ts
|
|
39605
|
+
function taskResultText(stoppedByUser, shell, notification) {
|
|
39606
|
+
if (stoppedByUser) return STOPPED_BY_USER_TEXT;
|
|
39607
|
+
return shell ? shellResultText(notification) : notificationResultText(notification);
|
|
39608
|
+
}
|
|
38972
39609
|
function isIdleUpdate(update) {
|
|
38973
39610
|
return isUpdate(update, "state_update") && update.state === "idle";
|
|
38974
39611
|
}
|
|
@@ -38995,6 +39632,7 @@ var init_turn3 = __esm({
|
|
|
38995
39632
|
init_background_tasks();
|
|
38996
39633
|
init_grammar();
|
|
38997
39634
|
init_grammar_state();
|
|
39635
|
+
init_live_usage();
|
|
38998
39636
|
init_task_events();
|
|
38999
39637
|
init_task_records();
|
|
39000
39638
|
init_turn_result();
|
|
@@ -39009,6 +39647,7 @@ var init_turn3 = __esm({
|
|
|
39009
39647
|
#suppressedResults = /* @__PURE__ */ new Set();
|
|
39010
39648
|
#announced = /* @__PURE__ */ new Set();
|
|
39011
39649
|
#awaitingAskDenialFallback = false;
|
|
39650
|
+
#liveUsage = new ClaudeLiveUsage();
|
|
39012
39651
|
#iterations = 0;
|
|
39013
39652
|
#contextTokens;
|
|
39014
39653
|
#providerErrorCode;
|
|
@@ -39069,6 +39708,14 @@ var init_turn3 = __esm({
|
|
|
39069
39708
|
readEvent(event) {
|
|
39070
39709
|
const parsed = this.#revise(parseClaudeEvent(event, this.grammar), event);
|
|
39071
39710
|
parsed.push(...this.#handle(event));
|
|
39711
|
+
if (asString(event.type) !== "result") {
|
|
39712
|
+
parsed.push(
|
|
39713
|
+
...this.#liveUsage.read(
|
|
39714
|
+
event,
|
|
39715
|
+
this.grammar.model?.trim() || this.#options.selectedModel?.trim() || "claude"
|
|
39716
|
+
)
|
|
39717
|
+
);
|
|
39718
|
+
}
|
|
39072
39719
|
const kept = parsed.filter((update) => {
|
|
39073
39720
|
if (!isIdleUpdate(update)) return true;
|
|
39074
39721
|
if (this.#finalized) return true;
|
|
@@ -39158,6 +39805,7 @@ var init_turn3 = __esm({
|
|
|
39158
39805
|
return updates.length ? updates : [unlinkedTaskEvent(event)];
|
|
39159
39806
|
}
|
|
39160
39807
|
if (subtype === "task_progress" || subtype === "task_updated") {
|
|
39808
|
+
if (subtype === "task_updated") this.taskRecords.applyPatch(event);
|
|
39161
39809
|
const updates = backgroundTaskProgress(event, this.tasks);
|
|
39162
39810
|
return updates.length ? updates : [unlinkedTaskEvent(event)];
|
|
39163
39811
|
}
|
|
@@ -39182,13 +39830,20 @@ var init_turn3 = __esm({
|
|
|
39182
39830
|
#taskEnding(event, notification) {
|
|
39183
39831
|
const record3 = this.taskRecords.get(asString(event.task_id));
|
|
39184
39832
|
const stoppedByUser = record3?.userStopRequested === true;
|
|
39185
|
-
if (record3)
|
|
39833
|
+
if (record3) {
|
|
39834
|
+
this.taskRecords.settle(record3, notification.status, isFailed(notification));
|
|
39835
|
+
this.taskRecords.recordOutcome(record3, {
|
|
39836
|
+
...notification.outputFile ? { outputFile: notification.outputFile } : {},
|
|
39837
|
+
...notification.summary ? { summary: notification.summary } : {}
|
|
39838
|
+
});
|
|
39839
|
+
}
|
|
39840
|
+
const shell = record3?.meta.kind === "shell";
|
|
39186
39841
|
if (!stoppedByUser) this.#settledWithoutUserStop = true;
|
|
39187
|
-
const interrupted2 = isInterrupted(notification) && !stoppedByUser &&
|
|
39842
|
+
const interrupted2 = isInterrupted(notification) && !stoppedByUser && !shell;
|
|
39188
39843
|
return {
|
|
39189
39844
|
record: record3,
|
|
39190
39845
|
failed: !stoppedByUser && isFailed(notification),
|
|
39191
|
-
resultText: stoppedByUser
|
|
39846
|
+
resultText: taskResultText(stoppedByUser, shell, notification),
|
|
39192
39847
|
notice: interrupted2 ? noticeUpdate(
|
|
39193
39848
|
"warning",
|
|
39194
39849
|
"background_agent_interrupted",
|
|
@@ -39269,6 +39924,7 @@ var init_turn3 = __esm({
|
|
|
39269
39924
|
}
|
|
39270
39925
|
#handleResult(event) {
|
|
39271
39926
|
this.#resultSeen = true;
|
|
39927
|
+
this.#liveUsage.settle();
|
|
39272
39928
|
const updates = resultUsage(event, {
|
|
39273
39929
|
activeModel: this.grammar.model,
|
|
39274
39930
|
selectedModel: this.#options.selectedModel,
|
|
@@ -39477,6 +40133,7 @@ var init_driver4 = __esm({
|
|
|
39477
40133
|
init_capabilities2();
|
|
39478
40134
|
init_grammar();
|
|
39479
40135
|
init_messages();
|
|
40136
|
+
init_task_output_tail();
|
|
39480
40137
|
init_task_records();
|
|
39481
40138
|
init_turn3();
|
|
39482
40139
|
STDERR_TAIL_LINES3 = 10;
|
|
@@ -39493,6 +40150,7 @@ var init_driver4 = __esm({
|
|
|
39493
40150
|
#stderr = [];
|
|
39494
40151
|
#replaysUserMessages;
|
|
39495
40152
|
#taskRecords;
|
|
40153
|
+
#outputTail;
|
|
39496
40154
|
#backgroundTurns = /* @__PURE__ */ new Map();
|
|
39497
40155
|
#lateSynthesisOwners = [];
|
|
39498
40156
|
#taskStops = /* @__PURE__ */ new Map();
|
|
@@ -39507,6 +40165,11 @@ var init_driver4 = __esm({
|
|
|
39507
40165
|
this.#options = options;
|
|
39508
40166
|
this.#replaysUserMessages = capabilities.supportsReplayUserMessages;
|
|
39509
40167
|
this.#taskRecords = new TaskRecords(() => options.clock.now());
|
|
40168
|
+
this.#outputTail = new TaskOutputTail({
|
|
40169
|
+
records: this.#taskRecords,
|
|
40170
|
+
clock: options.clock,
|
|
40171
|
+
emit: (update, ownerTurnId) => this.#emit({ type: "update", turnId: ownerTurnId ?? this.#current?.id, update })
|
|
40172
|
+
});
|
|
39510
40173
|
this.#launchFiles = launchFiles;
|
|
39511
40174
|
this.#resumeId = spec.args.resumeId;
|
|
39512
40175
|
this.#providerSessionId = spec.args.resumeId;
|
|
@@ -39773,6 +40436,7 @@ var init_driver4 = __esm({
|
|
|
39773
40436
|
this.#emit({ type: "update", turnId: backgroundTurn ? backgroundOwner : active?.id, update });
|
|
39774
40437
|
}
|
|
39775
40438
|
this.#finishLateSynthesis(backgroundTurn, lateOwner, record3);
|
|
40439
|
+
this.#outputTail.ensureRunning();
|
|
39776
40440
|
this.#noteSessionId(parser.sessionId);
|
|
39777
40441
|
if (!active || backgroundTurn) return;
|
|
39778
40442
|
if (line.kind === "record" && line.record.type === "result") active.lastResult = line.record;
|
|
@@ -39844,6 +40508,7 @@ var init_driver4 = __esm({
|
|
|
39844
40508
|
#onExit(exit, outputClosedEarly) {
|
|
39845
40509
|
const { code, signal } = exit;
|
|
39846
40510
|
this.#state = "closed";
|
|
40511
|
+
this.#outputTail.stop();
|
|
39847
40512
|
void removeLaunchFiles(this.#launchFiles).catch((error62) => {
|
|
39848
40513
|
this.#options.log.warn("claude.launch_files_cleanup_failed", { error: error62 });
|
|
39849
40514
|
});
|
|
@@ -39988,17 +40653,17 @@ async function claudeTurnInput(run3, context) {
|
|
|
39988
40653
|
const encoded = await Promise.all(
|
|
39989
40654
|
images.map(async (image) => ({
|
|
39990
40655
|
mimeType: image.mimeType,
|
|
39991
|
-
data: (await (0,
|
|
40656
|
+
data: (await (0, import_promises24.readFile)(image.path)).toString("base64")
|
|
39992
40657
|
}))
|
|
39993
40658
|
);
|
|
39994
40659
|
return { turnId: run3.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
|
|
39995
40660
|
}
|
|
39996
|
-
var import_node_crypto18,
|
|
40661
|
+
var import_node_crypto18, import_promises24, READ_ONLY_DISALLOWED_TOOLS, NO_COMMAND_DISALLOWED_TOOLS, DEFAULT_MCP_TIMEOUT_MS, CLOUD_SKILL_LISTING_MAX_DESCRIPTION_CHARS;
|
|
39997
40662
|
var init_run3 = __esm({
|
|
39998
40663
|
"../agent-core/src/providers/claude/run.ts"() {
|
|
39999
40664
|
"use strict";
|
|
40000
40665
|
import_node_crypto18 = require("node:crypto");
|
|
40001
|
-
|
|
40666
|
+
import_promises24 = require("node:fs/promises");
|
|
40002
40667
|
init_agent2();
|
|
40003
40668
|
init_mcp2();
|
|
40004
40669
|
init_prompt();
|
|
@@ -40335,6 +41000,218 @@ var init_exec_args = __esm({
|
|
|
40335
41000
|
}
|
|
40336
41001
|
});
|
|
40337
41002
|
|
|
41003
|
+
// ../agent-core/src/providers/codex/background-commands.ts
|
|
41004
|
+
function nonEmpty2(value2) {
|
|
41005
|
+
const text3 = asString(value2).trim();
|
|
41006
|
+
return text3 ? text3 : void 0;
|
|
41007
|
+
}
|
|
41008
|
+
function modelCommand(item) {
|
|
41009
|
+
const action = asRecord(asArray(item.commandActions)[0]);
|
|
41010
|
+
return nonEmpty2(action?.command) ?? nonEmpty2(item.command);
|
|
41011
|
+
}
|
|
41012
|
+
function isRunning3(task) {
|
|
41013
|
+
return task.meta.status === "running" || task.meta.status === "stopping";
|
|
41014
|
+
}
|
|
41015
|
+
function withMeta(task, update) {
|
|
41016
|
+
return isUpdate(update, "tool_call_update") ? { ...update, _meta: { ...update._meta, [BACKGROUND_TASK_META_KEY]: task.meta } } : update;
|
|
41017
|
+
}
|
|
41018
|
+
function metaUpdate(task) {
|
|
41019
|
+
return {
|
|
41020
|
+
sessionUpdate: "tool_call_update",
|
|
41021
|
+
toolCallId: task.toolCallId,
|
|
41022
|
+
_meta: { [BACKGROUND_TASK_META_KEY]: task.meta }
|
|
41023
|
+
};
|
|
41024
|
+
}
|
|
41025
|
+
function refusal2(error62) {
|
|
41026
|
+
if (error62 instanceof JsonRpcError && /experimentalApi/i.test(error62.message)) {
|
|
41027
|
+
return { ok: false, reason: "unsupported", message: error62.message };
|
|
41028
|
+
}
|
|
41029
|
+
return { ok: false, reason: "failed", message: String(error62) };
|
|
41030
|
+
}
|
|
41031
|
+
var TERMINATE_METHOD, TERMINATE_TIMEOUT_MS, OUTPUT_TAIL_CHARS, CodexBackgroundCommands;
|
|
41032
|
+
var init_background_commands = __esm({
|
|
41033
|
+
"../agent-core/src/providers/codex/background-commands.ts"() {
|
|
41034
|
+
"use strict";
|
|
41035
|
+
init_acp();
|
|
41036
|
+
init_kernel2();
|
|
41037
|
+
init_protocol();
|
|
41038
|
+
TERMINATE_METHOD = "thread/backgroundTerminals/terminate";
|
|
41039
|
+
TERMINATE_TIMEOUT_MS = 1e4;
|
|
41040
|
+
OUTPUT_TAIL_CHARS = MAX_LAST_OUTPUT_CHARS * 4;
|
|
41041
|
+
CodexBackgroundCommands = class {
|
|
41042
|
+
#tasks = /* @__PURE__ */ new Map();
|
|
41043
|
+
#clock;
|
|
41044
|
+
constructor(clock) {
|
|
41045
|
+
this.#clock = clock;
|
|
41046
|
+
}
|
|
41047
|
+
/** Background commands only: one still inside its turn is an ordinary tool call. */
|
|
41048
|
+
get running() {
|
|
41049
|
+
let count3 = 0;
|
|
41050
|
+
for (const task of this.#tasks.values())
|
|
41051
|
+
if (task.meta.backgrounded && isRunning3(task)) count3 += 1;
|
|
41052
|
+
return count3;
|
|
41053
|
+
}
|
|
41054
|
+
/** Stamps the updates a `commandExecution` item produced with its task meta. */
|
|
41055
|
+
read(notification, updates, ownerTurnId) {
|
|
41056
|
+
if (notification.method === "item/commandExecution/outputDelta") {
|
|
41057
|
+
return [...updates, ...this.#output(notification.params)];
|
|
41058
|
+
}
|
|
41059
|
+
const item = asRecord(notification.params.item);
|
|
41060
|
+
if (!item || asString(item.type) !== "commandExecution") return [...updates];
|
|
41061
|
+
const processId = nonEmpty2(item.processId);
|
|
41062
|
+
const toolCallId = nonEmpty2(item.id);
|
|
41063
|
+
if (!processId || !toolCallId) return [...updates];
|
|
41064
|
+
if (notification.method === "item/started") {
|
|
41065
|
+
const task2 = this.#start(item, processId, toolCallId, ownerTurnId);
|
|
41066
|
+
return updates.map((update) => withMeta(task2, update));
|
|
41067
|
+
}
|
|
41068
|
+
if (notification.method !== "item/completed") return [...updates];
|
|
41069
|
+
const task = this.#tasks.get(processId) ?? this.#start(item, processId, toolCallId, ownerTurnId);
|
|
41070
|
+
this.#settle(task, item);
|
|
41071
|
+
this.#tasks.delete(processId);
|
|
41072
|
+
return updates.map((update) => withMeta(task, update));
|
|
41073
|
+
}
|
|
41074
|
+
/**
|
|
41075
|
+
* A background command's newest output line, at most once per `LAST_OUTPUT_INTERVAL_MS`. A
|
|
41076
|
+
* command still inside its turn only collects output, so an ordinary tool call stays quiet.
|
|
41077
|
+
*/
|
|
41078
|
+
#output(params) {
|
|
41079
|
+
const itemId = asString(params.itemId);
|
|
41080
|
+
const task = [...this.#tasks.values()].find((candidate) => candidate.toolCallId === itemId);
|
|
41081
|
+
if (!task) return [];
|
|
41082
|
+
task.outputTail = `${task.outputTail}${asString(params.delta)}`.slice(-OUTPUT_TAIL_CHARS);
|
|
41083
|
+
const now = this.#clock.now();
|
|
41084
|
+
if (!task.meta.backgrounded || now - task.lastOutputEmittedAt < LAST_OUTPUT_INTERVAL_MS)
|
|
41085
|
+
return [];
|
|
41086
|
+
return this.#publishOutput(task, now);
|
|
41087
|
+
}
|
|
41088
|
+
#publishOutput(task, now) {
|
|
41089
|
+
const lastOutput = lastOutputLine(task.outputTail);
|
|
41090
|
+
if (!lastOutput || lastOutput === task.meta.lastOutput) return [];
|
|
41091
|
+
task.lastOutputEmittedAt = now;
|
|
41092
|
+
task.meta = { ...task.meta, lastOutput };
|
|
41093
|
+
return [metaUpdate(task)];
|
|
41094
|
+
}
|
|
41095
|
+
#start(item, processId, toolCallId, ownerTurnId) {
|
|
41096
|
+
const existing = this.#tasks.get(processId);
|
|
41097
|
+
if (existing) return existing;
|
|
41098
|
+
const command = modelCommand(item);
|
|
41099
|
+
const task = {
|
|
41100
|
+
meta: {
|
|
41101
|
+
taskId: processId,
|
|
41102
|
+
backgrounded: false,
|
|
41103
|
+
kind: "shell",
|
|
41104
|
+
...command ? { label: command, command } : {},
|
|
41105
|
+
startedAt: asFiniteNumber(item.startedAtMs) ?? this.#clock.now(),
|
|
41106
|
+
stop: "native",
|
|
41107
|
+
status: "running"
|
|
41108
|
+
},
|
|
41109
|
+
toolCallId,
|
|
41110
|
+
ownerTurnId,
|
|
41111
|
+
userStopRequested: false,
|
|
41112
|
+
outputTail: "",
|
|
41113
|
+
lastOutputEmittedAt: Number.NEGATIVE_INFINITY
|
|
41114
|
+
};
|
|
41115
|
+
this.#tasks.set(processId, task);
|
|
41116
|
+
return task;
|
|
41117
|
+
}
|
|
41118
|
+
#settle(task, item) {
|
|
41119
|
+
const exitCode = asFiniteNumber(item.exitCode);
|
|
41120
|
+
const failed = asString(item.status) === "failed" || exitCode !== void 0 && exitCode !== 0;
|
|
41121
|
+
const status = task.userStopRequested ? "stopped" : failed ? "failed" : "completed";
|
|
41122
|
+
const lastOutput = lastOutputLine(asString(item.aggregatedOutput)) ?? task.meta.lastOutput;
|
|
41123
|
+
task.meta = {
|
|
41124
|
+
...task.meta,
|
|
41125
|
+
...lastOutput ? { lastOutput } : {},
|
|
41126
|
+
status,
|
|
41127
|
+
endedAt: asFiniteNumber(item.completedAtMs) ?? this.#clock.now(),
|
|
41128
|
+
...task.userStopRequested ? { stoppedByUser: true } : {},
|
|
41129
|
+
...exitCode === void 0 || task.userStopRequested ? {} : { exitCode }
|
|
41130
|
+
};
|
|
41131
|
+
}
|
|
41132
|
+
/** The turn ended with these still running, so they now outlive it. */
|
|
41133
|
+
promote(turnId) {
|
|
41134
|
+
const promoted = [];
|
|
41135
|
+
for (const task of this.#tasks.values()) {
|
|
41136
|
+
if (task.ownerTurnId !== turnId || !isRunning3(task) || task.meta.backgrounded) continue;
|
|
41137
|
+
const lastOutput = lastOutputLine(task.outputTail);
|
|
41138
|
+
task.meta = { ...task.meta, backgrounded: true, ...lastOutput ? { lastOutput } : {} };
|
|
41139
|
+
promoted.push({ turnId, update: metaUpdate(task) });
|
|
41140
|
+
}
|
|
41141
|
+
return promoted;
|
|
41142
|
+
}
|
|
41143
|
+
/** The tool call ids of background commands still running for a turn. */
|
|
41144
|
+
launchersOf(turnId) {
|
|
41145
|
+
return [...this.#tasks.values()].filter((task) => task.ownerTurnId === turnId && task.meta.backgrounded && isRunning3(task)).map((task) => task.toolCallId);
|
|
41146
|
+
}
|
|
41147
|
+
async stop(processId, threadId, rpc, deliver) {
|
|
41148
|
+
const task = this.#tasks.get(processId);
|
|
41149
|
+
if (!task) return { ok: false, reason: "not_found" };
|
|
41150
|
+
if (!isRunning3(task)) return { ok: false, reason: "already_finished" };
|
|
41151
|
+
if (!threadId) return { ok: false, reason: "runtime_unavailable" };
|
|
41152
|
+
const wasRequested = task.userStopRequested;
|
|
41153
|
+
task.userStopRequested = true;
|
|
41154
|
+
task.meta = { ...task.meta, status: "stopping" };
|
|
41155
|
+
deliver([{ turnId: task.ownerTurnId, update: metaUpdate(task) }]);
|
|
41156
|
+
const result = await this.#terminate(rpc, threadId, processId);
|
|
41157
|
+
if (!result.ok && result.reason !== "timeout") {
|
|
41158
|
+
task.userStopRequested = wasRequested;
|
|
41159
|
+
if (this.#tasks.get(processId) === task && task.meta.status === "stopping") {
|
|
41160
|
+
task.meta = { ...task.meta, status: "running" };
|
|
41161
|
+
deliver([{ turnId: task.ownerTurnId, update: metaUpdate(task) }]);
|
|
41162
|
+
}
|
|
41163
|
+
}
|
|
41164
|
+
return result;
|
|
41165
|
+
}
|
|
41166
|
+
async #terminate(rpc, threadId, processId) {
|
|
41167
|
+
const timer = new AbortController();
|
|
41168
|
+
const answered = rpc.request(TERMINATE_METHOD, { threadId, processId }).then(
|
|
41169
|
+
(result) => asRecord(result)?.terminated === false ? { ok: false, reason: "already_finished" } : { ok: true },
|
|
41170
|
+
refusal2
|
|
41171
|
+
);
|
|
41172
|
+
const timedOut = this.#clock.sleep(TERMINATE_TIMEOUT_MS, timer.signal).then(
|
|
41173
|
+
() => ({
|
|
41174
|
+
ok: false,
|
|
41175
|
+
reason: "timeout",
|
|
41176
|
+
message: "Codex did not confirm the stop within 10s."
|
|
41177
|
+
}),
|
|
41178
|
+
() => ({ ok: false, reason: "timeout" })
|
|
41179
|
+
);
|
|
41180
|
+
try {
|
|
41181
|
+
return await Promise.race([answered, timedOut]);
|
|
41182
|
+
} finally {
|
|
41183
|
+
timer.abort();
|
|
41184
|
+
}
|
|
41185
|
+
}
|
|
41186
|
+
/** The app-server is gone and took its processes with it; nothing will report their exit. */
|
|
41187
|
+
settleAll() {
|
|
41188
|
+
const settled2 = [];
|
|
41189
|
+
for (const [processId, task] of this.#tasks) {
|
|
41190
|
+
this.#tasks.delete(processId);
|
|
41191
|
+
if (!isRunning3(task)) continue;
|
|
41192
|
+
task.meta = {
|
|
41193
|
+
...task.meta,
|
|
41194
|
+
status: task.userStopRequested ? "stopped" : "failed",
|
|
41195
|
+
endedAt: this.#clock.now(),
|
|
41196
|
+
summary: "The Codex app-server exited before the command finished.",
|
|
41197
|
+
...task.userStopRequested ? { stoppedByUser: true } : {}
|
|
41198
|
+
};
|
|
41199
|
+
settled2.push({
|
|
41200
|
+
turnId: task.ownerTurnId,
|
|
41201
|
+
update: {
|
|
41202
|
+
sessionUpdate: "tool_call_update",
|
|
41203
|
+
toolCallId: task.toolCallId,
|
|
41204
|
+
status: task.userStopRequested ? "cancelled" : "failed",
|
|
41205
|
+
_meta: { [BACKGROUND_TASK_META_KEY]: task.meta }
|
|
41206
|
+
}
|
|
41207
|
+
});
|
|
41208
|
+
}
|
|
41209
|
+
return settled2;
|
|
41210
|
+
}
|
|
41211
|
+
};
|
|
41212
|
+
}
|
|
41213
|
+
});
|
|
41214
|
+
|
|
40338
41215
|
// ../agent-core/src/providers/codex/elicitation.ts
|
|
40339
41216
|
function isFieldType(value2) {
|
|
40340
41217
|
return FIELD_TYPES.has(value2);
|
|
@@ -41188,7 +42065,8 @@ function mcpToolCall(item, id, completed) {
|
|
|
41188
42065
|
status: failed ? "failed" : statusOf2(item, completed),
|
|
41189
42066
|
rawInput: asRecord(item.arguments) ?? {}
|
|
41190
42067
|
};
|
|
41191
|
-
|
|
42068
|
+
const plan2 = alanPlanUpdate(name, id, base.rawInput);
|
|
42069
|
+
if (!completed) return [{ sessionUpdate: "tool_call_update", ...base }, ...plan2 ? [plan2] : []];
|
|
41192
42070
|
const payload = item.error ?? item.result ?? {};
|
|
41193
42071
|
return [terminal(base, typeof payload === "string" ? payload : JSON.stringify(payload, null, 2))];
|
|
41194
42072
|
}
|
|
@@ -41331,7 +42209,8 @@ var init_items = __esm({
|
|
|
41331
42209
|
PLAN_STATUS = /* @__PURE__ */ new Map([
|
|
41332
42210
|
["pending", "pending"],
|
|
41333
42211
|
["inProgress", "in_progress"],
|
|
41334
|
-
["completed", "completed"]
|
|
42212
|
+
["completed", "completed"],
|
|
42213
|
+
["failed", "failed"]
|
|
41335
42214
|
]);
|
|
41336
42215
|
}
|
|
41337
42216
|
});
|
|
@@ -41731,6 +42610,7 @@ var init_session4 = __esm({
|
|
|
41731
42610
|
init_protocol();
|
|
41732
42611
|
init_session();
|
|
41733
42612
|
init_auth();
|
|
42613
|
+
init_background_commands();
|
|
41734
42614
|
init_elicitation();
|
|
41735
42615
|
init_exec_args();
|
|
41736
42616
|
init_image_generation();
|
|
@@ -41755,6 +42635,7 @@ var init_session4 = __esm({
|
|
|
41755
42635
|
/** Session-level updates (thread start warnings, MCP startup) that open the next turn's log. */
|
|
41756
42636
|
#between = [];
|
|
41757
42637
|
#backgroundLaunchers = /* @__PURE__ */ new Map();
|
|
42638
|
+
#commands;
|
|
41758
42639
|
#workerOwners = /* @__PURE__ */ new Map();
|
|
41759
42640
|
#config = { approvals: "ask" };
|
|
41760
42641
|
#threadId;
|
|
@@ -41769,6 +42650,7 @@ var init_session4 = __esm({
|
|
|
41769
42650
|
this.#options = options;
|
|
41770
42651
|
this.#memory = memory;
|
|
41771
42652
|
this.#rateLimits = new CodexRateLimits(options.clock);
|
|
42653
|
+
this.#commands = new CodexBackgroundCommands(options.clock);
|
|
41772
42654
|
this.#lastTurn = new CodexTurn(memory, options.clock);
|
|
41773
42655
|
this.#host = hostProcess(
|
|
41774
42656
|
child,
|
|
@@ -41800,6 +42682,30 @@ var init_session4 = __esm({
|
|
|
41800
42682
|
get lastOutputAt() {
|
|
41801
42683
|
return this.#host.lastOutputAt;
|
|
41802
42684
|
}
|
|
42685
|
+
get backgroundTasks() {
|
|
42686
|
+
return this.#commands.running;
|
|
42687
|
+
}
|
|
42688
|
+
/** Stops one background command through the app-server; the thread and the turn carry on. */
|
|
42689
|
+
async stopTask(taskId) {
|
|
42690
|
+
if (this.#state === "closed" || this.#closing) {
|
|
42691
|
+
return { ok: false, reason: "runtime_unavailable", message: "Codex is no longer running." };
|
|
42692
|
+
}
|
|
42693
|
+
return this.#commands.stop(
|
|
42694
|
+
taskId,
|
|
42695
|
+
this.#threadId,
|
|
42696
|
+
this.#rpc,
|
|
42697
|
+
(updates) => this.#emitOwned(updates)
|
|
42698
|
+
);
|
|
42699
|
+
}
|
|
42700
|
+
#emitOwned(updates) {
|
|
42701
|
+
for (const { turnId, update } of updates) this.#emit({ type: "update", turnId, update });
|
|
42702
|
+
}
|
|
42703
|
+
/** Commands the turn leaves running keep the run open, and their completion lands on this turn. */
|
|
42704
|
+
#carryBackgroundCommands(turnId) {
|
|
42705
|
+
this.#emitOwned(this.#commands.promote(turnId));
|
|
42706
|
+
for (const toolCallId of this.#commands.launchersOf(turnId))
|
|
42707
|
+
this.#backgroundLaunchers.set(toolCallId, turnId);
|
|
42708
|
+
}
|
|
41803
42709
|
hasBackgroundWork(turnId) {
|
|
41804
42710
|
return turnId === void 0 ? this.#backgroundLaunchers.size > 0 : [...this.#backgroundLaunchers.values()].includes(turnId);
|
|
41805
42711
|
}
|
|
@@ -41942,6 +42848,7 @@ var init_session4 = __esm({
|
|
|
41942
42848
|
if (this.#current?.id !== id) return;
|
|
41943
42849
|
this.#current = void 0;
|
|
41944
42850
|
this.#lastTurn = turn;
|
|
42851
|
+
this.#carryBackgroundCommands(id);
|
|
41945
42852
|
if (this.#state === "busy") this.#state = "idle";
|
|
41946
42853
|
this.#host.scanDescendants(true);
|
|
41947
42854
|
this.#emit({ type: "turn_ended", turnId: id, outcome: outcome2 });
|
|
@@ -41999,9 +42906,10 @@ var init_session4 = __esm({
|
|
|
41999
42906
|
if (notification.method === "serverRequest/resolved") this.#dropResolved(notification);
|
|
42000
42907
|
const active = this.#ownerOf(notification);
|
|
42001
42908
|
const reader = active?.turn ?? this.#lastTurn;
|
|
42002
|
-
const
|
|
42909
|
+
const read3 = reader.read(notification);
|
|
42003
42910
|
const workerThreadId = asString(notification.params.threadId);
|
|
42004
42911
|
const ownerTurnId = active?.id ?? this.#workerOwners.get(workerThreadId);
|
|
42912
|
+
const updates = this.#commands.read(notification, read3, ownerTurnId);
|
|
42005
42913
|
if (active) {
|
|
42006
42914
|
for (const workerThreadId2 of this.#memory.workers.keys()) {
|
|
42007
42915
|
if (!this.#workerOwners.has(workerThreadId2))
|
|
@@ -42201,6 +43109,8 @@ var init_session4 = __esm({
|
|
|
42201
43109
|
const { code, signal } = exit;
|
|
42202
43110
|
this.#state = "closed";
|
|
42203
43111
|
this.#rpc.failPending(sessionClosedError("codex app-server"));
|
|
43112
|
+
this.#emitOwned(this.#commands.settleAll());
|
|
43113
|
+
this.#backgroundLaunchers.clear();
|
|
42204
43114
|
const active = this.#current;
|
|
42205
43115
|
if (active) {
|
|
42206
43116
|
this.#emitUpdates(active, active.images.settle());
|
|
@@ -42262,8 +43172,8 @@ async function withDeadline3(work, clock, ms, what) {
|
|
|
42262
43172
|
`codex app-server did not answer ${what} within ${ms} ms`
|
|
42263
43173
|
);
|
|
42264
43174
|
}
|
|
42265
|
-
async function handshake2(session,
|
|
42266
|
-
const experimentalApi =
|
|
43175
|
+
async function handshake2(session, log) {
|
|
43176
|
+
const experimentalApi = true;
|
|
42267
43177
|
const init = asRecord(
|
|
42268
43178
|
await session.rpc.request("initialize", {
|
|
42269
43179
|
clientInfo: CLIENT_INFO2,
|
|
@@ -42367,7 +43277,7 @@ function createCodexDriver(options = {}) {
|
|
|
42367
43277
|
await started;
|
|
42368
43278
|
try {
|
|
42369
43279
|
const opening = (async () => {
|
|
42370
|
-
await handshake2(session,
|
|
43280
|
+
await handshake2(session, resolved.log);
|
|
42371
43281
|
await preflight(session, spec, resolved.log);
|
|
42372
43282
|
return openThread(session, spec, resolved.log);
|
|
42373
43283
|
})();
|
|
@@ -42950,18 +43860,18 @@ var init_alan_code2 = __esm({
|
|
|
42950
43860
|
// src/capabilities/providers/managed.ts
|
|
42951
43861
|
async function readManagedProviderVersion(file2, backendKind) {
|
|
42952
43862
|
try {
|
|
42953
|
-
const selected = selectedSchema.parse(JSON.parse(await (0,
|
|
43863
|
+
const selected = selectedSchema.parse(JSON.parse(await (0, import_promises25.readFile)(file2, "utf8")));
|
|
42954
43864
|
const version2 = selected[backendKind];
|
|
42955
43865
|
return version2 !== void 0 && VERSION.test(version2) ? version2 : null;
|
|
42956
43866
|
} catch {
|
|
42957
43867
|
return null;
|
|
42958
43868
|
}
|
|
42959
43869
|
}
|
|
42960
|
-
var
|
|
43870
|
+
var import_promises25, VERSION, selectedSchema;
|
|
42961
43871
|
var init_managed2 = __esm({
|
|
42962
43872
|
"src/capabilities/providers/managed.ts"() {
|
|
42963
43873
|
"use strict";
|
|
42964
|
-
|
|
43874
|
+
import_promises25 = require("node:fs/promises");
|
|
42965
43875
|
init_process();
|
|
42966
43876
|
init_zod();
|
|
42967
43877
|
VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
@@ -50345,11 +51255,11 @@ async function inspectSkillPackage(packageRoot, options = {}) {
|
|
|
50345
51255
|
};
|
|
50346
51256
|
}
|
|
50347
51257
|
async function requirePackageRoot(packageRoot) {
|
|
50348
|
-
const root = await (0,
|
|
51258
|
+
const root = await (0, import_promises26.realpath)((0, import_node_path27.resolve)(packageRoot)).catch(() => null);
|
|
50349
51259
|
if (!root) {
|
|
50350
51260
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package directory does not exist");
|
|
50351
51261
|
}
|
|
50352
|
-
const rootStat = await (0,
|
|
51262
|
+
const rootStat = await (0, import_promises26.lstat)(root);
|
|
50353
51263
|
if (!rootStat.isDirectory()) {
|
|
50354
51264
|
throw new SkillPackageError("INVALID_PACKAGE_ROOT", "Skill package root must be a directory");
|
|
50355
51265
|
}
|
|
@@ -50375,12 +51285,12 @@ async function walkPackage(root, ignoredPaths) {
|
|
|
50375
51285
|
}
|
|
50376
51286
|
return files;
|
|
50377
51287
|
async function walkDirectory(directory) {
|
|
50378
|
-
const entries2 = await (0,
|
|
51288
|
+
const entries2 = await (0, import_promises26.readdir)(directory, { withFileTypes: true });
|
|
50379
51289
|
for (const entry2 of entries2) {
|
|
50380
51290
|
const absolutePath = (0, import_node_path27.resolve)(directory, entry2.name);
|
|
50381
51291
|
const normalizedPath = normalizeRelativePath(root, absolutePath);
|
|
50382
51292
|
if (isIgnored(normalizedPath, entry2.name, entry2.isDirectory(), ignored3)) continue;
|
|
50383
|
-
const entryStat = await (0,
|
|
51293
|
+
const entryStat = await (0, import_promises26.lstat)(absolutePath);
|
|
50384
51294
|
if (entryStat.isSymbolicLink()) {
|
|
50385
51295
|
throw new SkillPackageError(
|
|
50386
51296
|
"SYMLINK_BLOCKED",
|
|
@@ -50506,7 +51416,7 @@ function isSecretPath(path18) {
|
|
|
50506
51416
|
return name.endsWith(".private-key.pem") || name.endsWith(".private-key.key");
|
|
50507
51417
|
}
|
|
50508
51418
|
async function readPackageFile(file2) {
|
|
50509
|
-
const bytes2 = await (0,
|
|
51419
|
+
const bytes2 = await (0, import_promises26.readFile)(file2.absolutePath);
|
|
50510
51420
|
return {
|
|
50511
51421
|
bytes: bytes2,
|
|
50512
51422
|
manifest: {
|
|
@@ -50687,13 +51597,13 @@ function uint642(value2) {
|
|
|
50687
51597
|
buffer.writeBigUInt64BE(BigInt(value2));
|
|
50688
51598
|
return buffer;
|
|
50689
51599
|
}
|
|
50690
|
-
var import_node_buffer, import_node_crypto23,
|
|
51600
|
+
var import_node_buffer, import_node_crypto23, import_promises26, import_node_path27, import_yaml, TREE_HASH_PREFIX, ALWAYS_IGNORED_DIRECTORIES, ALWAYS_IGNORED_FILES, MARKDOWN_EXTENSIONS, IMAGE_EXTENSIONS2, CODE_EXTENSIONS, TEXT_EXTENSIONS, SECRET_BASENAMES, MARKDOWN_LINK_TARGET;
|
|
50691
51601
|
var init_skill_package = __esm({
|
|
50692
51602
|
"../shared/src/node/skill-package.ts"() {
|
|
50693
51603
|
"use strict";
|
|
50694
51604
|
import_node_buffer = require("node:buffer");
|
|
50695
51605
|
import_node_crypto23 = require("node:crypto");
|
|
50696
|
-
|
|
51606
|
+
import_promises26 = require("node:fs/promises");
|
|
50697
51607
|
import_node_path27 = require("node:path");
|
|
50698
51608
|
import_yaml = __toESM(require_dist(), 1);
|
|
50699
51609
|
init_contracts();
|
|
@@ -50813,7 +51723,7 @@ async function readLocalSkills(layout) {
|
|
|
50813
51723
|
async function isLocalSkillCurrent(entry2, contentHash, ignoredPaths) {
|
|
50814
51724
|
if (entry2.contentHash !== contentHash) return false;
|
|
50815
51725
|
try {
|
|
50816
|
-
if (await (0,
|
|
51726
|
+
if (await (0, import_promises27.realpath)(entry2.path) !== entry2.path) return false;
|
|
50817
51727
|
const inspected = await inspectSkillPackage(entry2.path, { expectedName: null, ignoredPaths });
|
|
50818
51728
|
return inspected.contentHash === contentHash;
|
|
50819
51729
|
} catch {
|
|
@@ -50828,7 +51738,7 @@ async function resolveLocalSkill(local, invocation) {
|
|
|
50828
51738
|
}
|
|
50829
51739
|
async function hasSkillFile(directory) {
|
|
50830
51740
|
try {
|
|
50831
|
-
return (await (0,
|
|
51741
|
+
return (await (0, import_promises27.stat)((0, import_node_path28.join)(directory, "SKILL.md"))).isFile();
|
|
50832
51742
|
} catch {
|
|
50833
51743
|
return false;
|
|
50834
51744
|
}
|
|
@@ -50883,7 +51793,7 @@ async function resolveSkillInvocations(layout, invocations, baked = "any") {
|
|
|
50883
51793
|
return missing2.length === 0 ? { kind: "resolved", skills: resolved } : { kind: "missing", names: missing2 };
|
|
50884
51794
|
}
|
|
50885
51795
|
async function folderCandidates(folder) {
|
|
50886
|
-
const entries2 = await (0,
|
|
51796
|
+
const entries2 = await (0, import_promises27.readdir)(folder, { withFileTypes: true }).catch(() => []);
|
|
50887
51797
|
return entries2.filter((entry2) => entry2.isDirectory() || entry2.isSymbolicLink()).map((entry2) => ({ directory: (0, import_node_path28.join)(folder, entry2.name) }));
|
|
50888
51798
|
}
|
|
50889
51799
|
async function nativeCandidates(layout) {
|
|
@@ -50928,11 +51838,11 @@ async function inspectIndexedSkill(directory, contentHash) {
|
|
|
50928
51838
|
return null;
|
|
50929
51839
|
}
|
|
50930
51840
|
}
|
|
50931
|
-
var
|
|
51841
|
+
var import_promises27, import_node_path28, installedFileSchema, localSkillsFileSchema, INDEX_CONCURRENCY;
|
|
50932
51842
|
var init_store = __esm({
|
|
50933
51843
|
"src/capabilities/skills/store.ts"() {
|
|
50934
51844
|
"use strict";
|
|
50935
|
-
|
|
51845
|
+
import_promises27 = require("node:fs/promises");
|
|
50936
51846
|
import_node_path28 = require("node:path");
|
|
50937
51847
|
init_alan_skill_identity();
|
|
50938
51848
|
init_skill_package();
|
|
@@ -51026,7 +51936,7 @@ var init_paths2 = __esm({
|
|
|
51026
51936
|
// src/capabilities/workspace/approved-paths.ts
|
|
51027
51937
|
async function realpathOrNull(path18) {
|
|
51028
51938
|
try {
|
|
51029
|
-
return await (0,
|
|
51939
|
+
return await (0, import_promises28.realpath)(path18);
|
|
51030
51940
|
} catch (error62) {
|
|
51031
51941
|
const code = errnoCode(error62);
|
|
51032
51942
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM") {
|
|
@@ -51083,11 +51993,11 @@ async function openApprovedPaths(options) {
|
|
|
51083
51993
|
roots
|
|
51084
51994
|
};
|
|
51085
51995
|
}
|
|
51086
|
-
var
|
|
51996
|
+
var import_promises28, MAX_RUN_PATHS, storeSchema;
|
|
51087
51997
|
var init_approved_paths = __esm({
|
|
51088
51998
|
"src/capabilities/workspace/approved-paths.ts"() {
|
|
51089
51999
|
"use strict";
|
|
51090
|
-
|
|
52000
|
+
import_promises28 = require("node:fs/promises");
|
|
51091
52001
|
init_zod();
|
|
51092
52002
|
init_kernel();
|
|
51093
52003
|
init_paths2();
|
|
@@ -51106,7 +52016,7 @@ function repositoryLockKey(commonDir, platform) {
|
|
|
51106
52016
|
async function readOwner(path18) {
|
|
51107
52017
|
let text3;
|
|
51108
52018
|
try {
|
|
51109
|
-
text3 = await (0,
|
|
52019
|
+
text3 = await (0, import_promises29.readFile)(path18, "utf8");
|
|
51110
52020
|
} catch (error62) {
|
|
51111
52021
|
if (errnoCode(error62) === "ENOENT") return { kind: "missing" };
|
|
51112
52022
|
return { kind: "unreadable" };
|
|
@@ -51127,7 +52037,7 @@ async function removeIfSame(path18, expected) {
|
|
|
51127
52037
|
if (current.kind !== "owner" || current.owner.since !== expected.since) return;
|
|
51128
52038
|
if (current.owner.pid !== expected.pid || current.owner.holder !== expected.holder) return;
|
|
51129
52039
|
}
|
|
51130
|
-
await (0,
|
|
52040
|
+
await (0, import_promises29.unlink)(path18).catch((error62) => {
|
|
51131
52041
|
if (errnoCode(error62) !== "ENOENT") throw error62;
|
|
51132
52042
|
});
|
|
51133
52043
|
}
|
|
@@ -51152,7 +52062,7 @@ function openRepositoryLocks(options) {
|
|
|
51152
52062
|
await removeIfSame(path18, read3.owner);
|
|
51153
52063
|
return null;
|
|
51154
52064
|
}
|
|
51155
|
-
const age = await (0,
|
|
52065
|
+
const age = await (0, import_promises29.stat)(path18).then(
|
|
51156
52066
|
(info) => clock.now() - info.mtimeMs,
|
|
51157
52067
|
() => 0
|
|
51158
52068
|
);
|
|
@@ -51167,12 +52077,12 @@ function openRepositoryLocks(options) {
|
|
|
51167
52077
|
const folder = async (commonDir) => {
|
|
51168
52078
|
const key = repositoryLockKey(commonDir, platform);
|
|
51169
52079
|
const dir = (0, import_node_path31.join)(options.dir, key);
|
|
51170
|
-
await (0,
|
|
52080
|
+
await (0, import_promises29.mkdir)(dir, { recursive: true, mode: 448 });
|
|
51171
52081
|
return { key, dir };
|
|
51172
52082
|
};
|
|
51173
52083
|
const createExclusive = async (path18, owner) => {
|
|
51174
52084
|
try {
|
|
51175
|
-
const handle = await (0,
|
|
52085
|
+
const handle = await (0, import_promises29.open)(path18, "wx", 384);
|
|
51176
52086
|
try {
|
|
51177
52087
|
await handle.writeFile(JSON.stringify(owner));
|
|
51178
52088
|
} finally {
|
|
@@ -51185,7 +52095,7 @@ function openRepositoryLocks(options) {
|
|
|
51185
52095
|
}
|
|
51186
52096
|
};
|
|
51187
52097
|
const liveRun = async (dir) => {
|
|
51188
|
-
const entries2 = await (0,
|
|
52098
|
+
const entries2 = await (0, import_promises29.readdir)(dir);
|
|
51189
52099
|
for (const entry2 of entries2) {
|
|
51190
52100
|
if (!entry2.startsWith(RUN_FILE_PREFIX)) continue;
|
|
51191
52101
|
const holder = await heldBy((0, import_node_path31.join)(dir, entry2));
|
|
@@ -51227,12 +52137,12 @@ function openRepositoryLocks(options) {
|
|
|
51227
52137
|
}
|
|
51228
52138
|
};
|
|
51229
52139
|
}
|
|
51230
|
-
var import_node_crypto25,
|
|
52140
|
+
var import_node_crypto25, import_promises29, import_node_path31, LOCK_FORMAT, EXCLUSIVE_FILE, RUN_FILE_PREFIX, UNREADABLE_GRACE_MS, ownerSchema;
|
|
51231
52141
|
var init_locks = __esm({
|
|
51232
52142
|
"src/capabilities/workspace/locks.ts"() {
|
|
51233
52143
|
"use strict";
|
|
51234
52144
|
import_node_crypto25 = require("node:crypto");
|
|
51235
|
-
|
|
52145
|
+
import_promises29 = require("node:fs/promises");
|
|
51236
52146
|
import_node_path31 = require("node:path");
|
|
51237
52147
|
init_zod();
|
|
51238
52148
|
init_kernel();
|
|
@@ -51285,7 +52195,7 @@ function opt(schema) {
|
|
|
51285
52195
|
return new Optional(schema);
|
|
51286
52196
|
}
|
|
51287
52197
|
function obj(properties, options = {}) {
|
|
51288
|
-
const { open:
|
|
52198
|
+
const { open: open7, ...annotations } = options;
|
|
51289
52199
|
const props = {};
|
|
51290
52200
|
const required2 = [];
|
|
51291
52201
|
for (const [name, property] of Object.entries(properties)) {
|
|
@@ -51300,7 +52210,7 @@ function obj(properties, options = {}) {
|
|
|
51300
52210
|
type: "object",
|
|
51301
52211
|
properties: props,
|
|
51302
52212
|
...required2.length > 0 ? { required: required2 } : {},
|
|
51303
|
-
...
|
|
52213
|
+
...open7 === true ? {} : { additionalProperties: false },
|
|
51304
52214
|
...annotations
|
|
51305
52215
|
};
|
|
51306
52216
|
}
|
|
@@ -55640,13 +56550,13 @@ var init_tracker = __esm({
|
|
|
55640
56550
|
}
|
|
55641
56551
|
}
|
|
55642
56552
|
#invalidate(winner) {
|
|
55643
|
-
const
|
|
56553
|
+
const open7 = this.#open;
|
|
55644
56554
|
const competitors = this.#competitors;
|
|
55645
56555
|
this.#open = void 0;
|
|
55646
56556
|
this.#competitors = void 0;
|
|
55647
56557
|
this.#pruneBudget = 256;
|
|
55648
|
-
if (
|
|
55649
|
-
staleCompetitor(
|
|
56558
|
+
if (open7 !== void 0)
|
|
56559
|
+
staleCompetitor(open7, winner);
|
|
55650
56560
|
if (competitors === void 0)
|
|
55651
56561
|
return;
|
|
55652
56562
|
for (const reference of competitors) {
|
|
@@ -56071,10 +56981,10 @@ function assertValidOp(op) {
|
|
|
56071
56981
|
throw new TypeError(`unknown op verb: ${String(op[0])}`);
|
|
56072
56982
|
}
|
|
56073
56983
|
}
|
|
56074
|
-
function assertPathArg(p,
|
|
56984
|
+
function assertPathArg(p, nonEmpty4 = false) {
|
|
56075
56985
|
if (!Array.isArray(p))
|
|
56076
56986
|
throw new TypeError("path is not an array");
|
|
56077
|
-
if (
|
|
56987
|
+
if (nonEmpty4 && p.length === 0)
|
|
56078
56988
|
throw new TypeError("path is empty");
|
|
56079
56989
|
assertSafePath(p);
|
|
56080
56990
|
}
|
|
@@ -60938,11 +61848,11 @@ function deriveRange(bounds, entries2, current) {
|
|
|
60938
61848
|
edits.set(edit.target, edit);
|
|
60939
61849
|
const active = selectActive(bounds.head, entries2);
|
|
60940
61850
|
const contributions = active.map((entry2) => contribute(entry2, edits.get(entry2.id)));
|
|
60941
|
-
const { settled: settled2, open:
|
|
61851
|
+
const { settled: settled2, open: open7 } = settle2([], contributions.flat());
|
|
60942
61852
|
const baseline = findBaseline(bounds.head, active);
|
|
60943
|
-
const messages = leadWithSystem([...settled2, ...orderToolResults(
|
|
61853
|
+
const messages = leadWithSystem([...settled2, ...orderToolResults(open7)], baseline);
|
|
60944
61854
|
const view2 = { head: bounds.head, entries: active, contributions, messages };
|
|
60945
|
-
return { bounds, entries: entries2, view: view2, edited: new Set(edits.keys()), settled: settled2, open:
|
|
61855
|
+
return { bounds, entries: entries2, view: view2, edited: new Set(edits.keys()), settled: settled2, open: open7, baseline, current };
|
|
60946
61856
|
}
|
|
60947
61857
|
function extendRange(previous, bounds, added, current) {
|
|
60948
61858
|
const entries2 = [...previous.entries, ...added];
|
|
@@ -60950,15 +61860,15 @@ function extendRange(previous, bounds, added, current) {
|
|
|
60950
61860
|
return deriveRange(bounds, entries2, current);
|
|
60951
61861
|
}
|
|
60952
61862
|
const contributions = added.map((entry2) => contribute(entry2, void 0));
|
|
60953
|
-
const { settled: settled2, open:
|
|
61863
|
+
const { settled: settled2, open: open7 } = settle2(previous.settled, [...previous.open, ...contributions.flat()]);
|
|
60954
61864
|
const baseline = previous.baseline !== void 0 ? previous.baseline : findBaseline(bounds.head, added);
|
|
60955
61865
|
const view2 = {
|
|
60956
61866
|
head: bounds.head,
|
|
60957
61867
|
entries: [...previous.view.entries, ...added],
|
|
60958
61868
|
contributions: [...previous.view.contributions, ...contributions],
|
|
60959
|
-
messages: leadWithSystem([...settled2, ...orderToolResults(
|
|
61869
|
+
messages: leadWithSystem([...settled2, ...orderToolResults(open7)], baseline)
|
|
60960
61870
|
};
|
|
60961
|
-
return { bounds, entries: entries2, view: view2, edited: previous.edited, settled: settled2, open:
|
|
61871
|
+
return { bounds, entries: entries2, view: view2, edited: previous.edited, settled: settled2, open: open7, baseline, current };
|
|
60962
61872
|
}
|
|
60963
61873
|
function findBaseline(head, entries2) {
|
|
60964
61874
|
for (const entry2 of entries2) {
|
|
@@ -61000,11 +61910,11 @@ function freezeJson(value2) {
|
|
|
61000
61910
|
deeplyFrozen.add(value2);
|
|
61001
61911
|
return value2;
|
|
61002
61912
|
}
|
|
61003
|
-
function settle2(settled2,
|
|
61004
|
-
const last =
|
|
61913
|
+
function settle2(settled2, open7) {
|
|
61914
|
+
const last = open7.findLastIndex((message) => message.role === "assistant");
|
|
61005
61915
|
if (last <= 0)
|
|
61006
|
-
return { settled: settled2, open:
|
|
61007
|
-
return { settled: [...settled2, ...orderToolResults(
|
|
61916
|
+
return { settled: settled2, open: open7 };
|
|
61917
|
+
return { settled: [...settled2, ...orderToolResults(open7.slice(0, last))], open: open7.slice(last) };
|
|
61008
61918
|
}
|
|
61009
61919
|
function rangeQuery(bounds) {
|
|
61010
61920
|
const head = bounds.head;
|
|
@@ -61822,9 +62732,9 @@ var init_streaming_json = __esm({
|
|
|
61822
62732
|
this.#string.change = void 0;
|
|
61823
62733
|
let index = 0;
|
|
61824
62734
|
while (index < text3.length && !this.#done) {
|
|
61825
|
-
const
|
|
61826
|
-
if (
|
|
61827
|
-
index = this.#readString(
|
|
62735
|
+
const open7 = this.#string;
|
|
62736
|
+
if (open7 !== void 0)
|
|
62737
|
+
index = this.#readString(open7, text3, index);
|
|
61828
62738
|
else if (this.#scalar !== "")
|
|
61829
62739
|
index = this.#readScalar(text3, index);
|
|
61830
62740
|
else
|
|
@@ -61850,12 +62760,12 @@ var init_streaming_json = __esm({
|
|
|
61850
62760
|
return this.#snapshot;
|
|
61851
62761
|
}
|
|
61852
62762
|
/** Read string characters from `start` until the string ends or the text does; returns the next index. */
|
|
61853
|
-
#readString(
|
|
62763
|
+
#readString(open7, text3, start) {
|
|
61854
62764
|
let runStart = start;
|
|
61855
62765
|
for (let index = start; index < text3.length; index++) {
|
|
61856
62766
|
const code = text3.charCodeAt(index);
|
|
61857
|
-
if (
|
|
61858
|
-
if (this.#continueEscape(
|
|
62767
|
+
if (open7.escape !== "") {
|
|
62768
|
+
if (this.#continueEscape(open7, text3[index])) {
|
|
61859
62769
|
runStart = index + 1;
|
|
61860
62770
|
continue;
|
|
61861
62771
|
}
|
|
@@ -61863,19 +62773,19 @@ var init_streaming_json = __esm({
|
|
|
61863
62773
|
}
|
|
61864
62774
|
if (code === QUOTE) {
|
|
61865
62775
|
if (index > runStart)
|
|
61866
|
-
this.#appendString(
|
|
61867
|
-
this.#endString(
|
|
62776
|
+
this.#appendString(open7, text3.slice(runStart, index));
|
|
62777
|
+
this.#endString(open7);
|
|
61868
62778
|
return index + 1;
|
|
61869
62779
|
}
|
|
61870
62780
|
if (code === BACKSLASH) {
|
|
61871
62781
|
if (index > runStart)
|
|
61872
|
-
this.#appendString(
|
|
61873
|
-
|
|
62782
|
+
this.#appendString(open7, text3.slice(runStart, index));
|
|
62783
|
+
open7.escape = "\\";
|
|
61874
62784
|
runStart = index + 1;
|
|
61875
62785
|
}
|
|
61876
62786
|
}
|
|
61877
62787
|
if (text3.length > runStart)
|
|
61878
|
-
this.#appendString(
|
|
62788
|
+
this.#appendString(open7, text3.slice(runStart));
|
|
61879
62789
|
return text3.length;
|
|
61880
62790
|
}
|
|
61881
62791
|
/** Read number or literal characters from `start` up to the next delimiter; returns the delimiter's index. */
|
|
@@ -61971,44 +62881,44 @@ var init_streaming_json = __esm({
|
|
|
61971
62881
|
return change;
|
|
61972
62882
|
}
|
|
61973
62883
|
/** Continue an escape with `char`; returns false when `char` is not part of it and must be read normally. */
|
|
61974
|
-
#continueEscape(
|
|
61975
|
-
if (
|
|
62884
|
+
#continueEscape(open7, char) {
|
|
62885
|
+
if (open7.escape === "\\") {
|
|
61976
62886
|
const decoded2 = SIMPLE_ESCAPES[char];
|
|
61977
62887
|
if (decoded2 !== void 0) {
|
|
61978
|
-
|
|
61979
|
-
this.#appendString(
|
|
62888
|
+
open7.escape = "";
|
|
62889
|
+
this.#appendString(open7, decoded2);
|
|
61980
62890
|
return true;
|
|
61981
62891
|
}
|
|
61982
62892
|
if (char === "u") {
|
|
61983
|
-
|
|
62893
|
+
open7.escape = "\\u";
|
|
61984
62894
|
return true;
|
|
61985
62895
|
}
|
|
61986
|
-
|
|
61987
|
-
this.#appendString(
|
|
62896
|
+
open7.escape = "";
|
|
62897
|
+
this.#appendString(open7, "\\");
|
|
61988
62898
|
return false;
|
|
61989
62899
|
}
|
|
61990
62900
|
if (isHexDigit(char)) {
|
|
61991
|
-
|
|
61992
|
-
if (
|
|
62901
|
+
open7.escape += char;
|
|
62902
|
+
if (open7.escape.length < 6)
|
|
61993
62903
|
return true;
|
|
61994
|
-
const decoded2 = String.fromCharCode(Number.parseInt(
|
|
61995
|
-
|
|
61996
|
-
this.#appendString(
|
|
62904
|
+
const decoded2 = String.fromCharCode(Number.parseInt(open7.escape.slice(2), 16));
|
|
62905
|
+
open7.escape = "";
|
|
62906
|
+
this.#appendString(open7, decoded2);
|
|
61997
62907
|
return true;
|
|
61998
62908
|
}
|
|
61999
|
-
const literal2 =
|
|
62000
|
-
|
|
62001
|
-
this.#appendString(
|
|
62909
|
+
const literal2 = open7.escape;
|
|
62910
|
+
open7.escape = "";
|
|
62911
|
+
this.#appendString(open7, literal2);
|
|
62002
62912
|
return false;
|
|
62003
62913
|
}
|
|
62004
|
-
#appendString(
|
|
62005
|
-
|
|
62006
|
-
if (
|
|
62914
|
+
#appendString(open7, text3) {
|
|
62915
|
+
open7.text += text3;
|
|
62916
|
+
if (open7.target !== "value")
|
|
62007
62917
|
return;
|
|
62008
|
-
this.#place(
|
|
62009
|
-
if (
|
|
62918
|
+
this.#place(open7.slot, open7.text);
|
|
62919
|
+
if (open7.path === void 0)
|
|
62010
62920
|
return;
|
|
62011
|
-
const change =
|
|
62921
|
+
const change = open7.change;
|
|
62012
62922
|
if (change !== void 0 && this.#changes.at(-1) === change) {
|
|
62013
62923
|
if (change.kind === "set")
|
|
62014
62924
|
change.value = change.value + text3;
|
|
@@ -62016,15 +62926,15 @@ var init_streaming_json = __esm({
|
|
|
62016
62926
|
change.text += text3;
|
|
62017
62927
|
return;
|
|
62018
62928
|
}
|
|
62019
|
-
|
|
62929
|
+
open7.change = this.#report({ kind: "append", path: open7.path, text: text3 });
|
|
62020
62930
|
}
|
|
62021
|
-
#endString(
|
|
62931
|
+
#endString(open7) {
|
|
62022
62932
|
this.#string = void 0;
|
|
62023
62933
|
const frame = this.#stack.at(-1);
|
|
62024
|
-
if (
|
|
62934
|
+
if (open7.target === "key") {
|
|
62025
62935
|
if (frame === void 0)
|
|
62026
62936
|
return;
|
|
62027
|
-
frame.key =
|
|
62937
|
+
frame.key = open7.text;
|
|
62028
62938
|
frame.phase = "colon";
|
|
62029
62939
|
return;
|
|
62030
62940
|
}
|
|
@@ -70424,7 +71334,7 @@ function relativeTitle(cwd, target) {
|
|
|
70424
71334
|
}
|
|
70425
71335
|
async function canonicalPath(target) {
|
|
70426
71336
|
try {
|
|
70427
|
-
return await (0,
|
|
71337
|
+
return await (0, import_promises30.realpath)(target);
|
|
70428
71338
|
} catch {
|
|
70429
71339
|
const parent = import_node_path32.default.dirname(target);
|
|
70430
71340
|
if (parent === target) return target;
|
|
@@ -70448,11 +71358,11 @@ async function withFileLock(target, run3) {
|
|
|
70448
71358
|
if (queues.get(key) === tail2) queues.delete(key);
|
|
70449
71359
|
}
|
|
70450
71360
|
}
|
|
70451
|
-
var
|
|
71361
|
+
var import_promises30, import_node_path32, ToolFailure, queues;
|
|
70452
71362
|
var init_shared2 = __esm({
|
|
70453
71363
|
"../alan-engine/src/tools/shared.ts"() {
|
|
70454
71364
|
"use strict";
|
|
70455
|
-
|
|
71365
|
+
import_promises30 = require("node:fs/promises");
|
|
70456
71366
|
import_node_path32 = __toESM(require("node:path"), 1);
|
|
70457
71367
|
ToolFailure = class extends Error {
|
|
70458
71368
|
};
|
|
@@ -70511,9 +71421,9 @@ function escapeRegExp(text3) {
|
|
|
70511
71421
|
}
|
|
70512
71422
|
function removeIndentation(text3) {
|
|
70513
71423
|
const lines2 = text3.split("\n");
|
|
70514
|
-
const
|
|
70515
|
-
if (
|
|
70516
|
-
const minIndent = Math.min(...
|
|
71424
|
+
const nonEmpty4 = lines2.filter((line) => line.trim().length > 0);
|
|
71425
|
+
if (nonEmpty4.length === 0) return text3;
|
|
71426
|
+
const minIndent = Math.min(...nonEmpty4.map((line) => /^(\s*)/.exec(line)?.[1].length ?? 0));
|
|
70517
71427
|
return lines2.map((line) => line.trim().length === 0 ? line : line.slice(minIndent)).join("\n");
|
|
70518
71428
|
}
|
|
70519
71429
|
function unescapeString(text3) {
|
|
@@ -70712,15 +71622,15 @@ var init_edit_replace = __esm({
|
|
|
70712
71622
|
const blockLines = contentLines.slice(i, j + 1);
|
|
70713
71623
|
if (blockLines.length === findLines.length) {
|
|
70714
71624
|
let matching = 0;
|
|
70715
|
-
let
|
|
71625
|
+
let nonEmpty4 = 0;
|
|
70716
71626
|
for (let k = 1; k < blockLines.length - 1; k++) {
|
|
70717
71627
|
const blockLine = blockLines[k].trim();
|
|
70718
71628
|
const findLine = findLines[k].trim();
|
|
70719
71629
|
if (blockLine.length === 0 && findLine.length === 0) continue;
|
|
70720
|
-
|
|
71630
|
+
nonEmpty4++;
|
|
70721
71631
|
if (blockLine === findLine) matching++;
|
|
70722
71632
|
}
|
|
70723
|
-
if (
|
|
71633
|
+
if (nonEmpty4 === 0 || matching / nonEmpty4 >= 0.5) {
|
|
70724
71634
|
yield blockLines.join("\n");
|
|
70725
71635
|
break;
|
|
70726
71636
|
}
|
|
@@ -70930,16 +71840,16 @@ var init_interactions = __esm({
|
|
|
70930
71840
|
const settled2 = await this.#session().commit(
|
|
70931
71841
|
async (tx) => {
|
|
70932
71842
|
const doc = await tx.doc(InteractionsDoc);
|
|
70933
|
-
const
|
|
70934
|
-
if (
|
|
70935
|
-
const answer2 = toAnswer(
|
|
70936
|
-
|
|
71843
|
+
const open7 = Object.values(doc.requests).filter((record3) => record3.toolCallId === toolCallId && record3.answer === null).sort((left, right) => right.requestedAt - left.requestedAt)[0];
|
|
71844
|
+
if (open7 === void 0) return void 0;
|
|
71845
|
+
const answer2 = toAnswer(open7, response);
|
|
71846
|
+
open7.answer = answer2;
|
|
70937
71847
|
if (answer2.kind === "allow" && answer2.always) {
|
|
70938
|
-
for (const grant of
|
|
71848
|
+
for (const grant of open7.grants ?? []) {
|
|
70939
71849
|
if (!doc.grants.includes(grant)) doc.grants.push(grant);
|
|
70940
71850
|
}
|
|
70941
71851
|
}
|
|
70942
|
-
return { question:
|
|
71852
|
+
return { question: open7.question !== null, answer: answer2 };
|
|
70943
71853
|
},
|
|
70944
71854
|
BACKGROUND_CONTEXT
|
|
70945
71855
|
);
|
|
@@ -71039,7 +71949,7 @@ function replacementsOf(args) {
|
|
|
71039
71949
|
}
|
|
71040
71950
|
async function editDiff(cwd, tool, args) {
|
|
71041
71951
|
const filepath = resolveIn(cwd, text2(args, "filePath"));
|
|
71042
|
-
const before = await (0,
|
|
71952
|
+
const before = await (0, import_promises31.readFile)(filepath, "utf8").catch(() => "");
|
|
71043
71953
|
try {
|
|
71044
71954
|
if (tool === "write") return unifiedDiff(filepath, before, text2(args, "content"));
|
|
71045
71955
|
const edits = replacementsOf(args);
|
|
@@ -71099,11 +72009,11 @@ function createApprovalsExtension(options) {
|
|
|
71099
72009
|
]
|
|
71100
72010
|
});
|
|
71101
72011
|
}
|
|
71102
|
-
var
|
|
72012
|
+
var import_promises31, import_node_path33, APPROVALS_EXTENSION_NAME, EDIT_TOOLS2, COMMAND_TOOLS, EDIT_GRANT, MAX_INPUT_TEXT, DENY_WRITES_MESSAGE;
|
|
71103
72013
|
var init_approvals = __esm({
|
|
71104
72014
|
"../alan-engine/src/engine/approvals.ts"() {
|
|
71105
72015
|
"use strict";
|
|
71106
|
-
|
|
72016
|
+
import_promises31 = require("node:fs/promises");
|
|
71107
72017
|
import_node_path33 = __toESM(require("node:path"), 1);
|
|
71108
72018
|
init_dist3();
|
|
71109
72019
|
init_dist4();
|
|
@@ -71420,7 +72330,7 @@ function processAlive(pid) {
|
|
|
71420
72330
|
}
|
|
71421
72331
|
async function lockOwner(path18) {
|
|
71422
72332
|
try {
|
|
71423
|
-
const pid = Number.parseInt((await (0,
|
|
72333
|
+
const pid = Number.parseInt((await (0, import_promises32.readFile)(path18, "utf8")).trim(), 10);
|
|
71424
72334
|
return Number.isInteger(pid) && pid > 0 ? pid : void 0;
|
|
71425
72335
|
} catch {
|
|
71426
72336
|
return void 0;
|
|
@@ -71431,12 +72341,12 @@ function isExists(error62) {
|
|
|
71431
72341
|
}
|
|
71432
72342
|
async function createLock(path18) {
|
|
71433
72343
|
const staged = `${path18}.${process.pid}.${(0, import_node_crypto26.randomUUID)().slice(0, 8)}`;
|
|
71434
|
-
await (0,
|
|
72344
|
+
await (0, import_promises32.writeFile)(staged, `${process.pid}
|
|
71435
72345
|
`, "utf8");
|
|
71436
72346
|
try {
|
|
71437
|
-
await (0,
|
|
72347
|
+
await (0, import_promises32.link)(staged, path18);
|
|
71438
72348
|
} finally {
|
|
71439
|
-
await (0,
|
|
72349
|
+
await (0, import_promises32.rm)(staged, { force: true });
|
|
71440
72350
|
}
|
|
71441
72351
|
}
|
|
71442
72352
|
async function acquireSessionLock(path18) {
|
|
@@ -71449,7 +72359,7 @@ async function acquireSessionLock(path18) {
|
|
|
71449
72359
|
release: async () => {
|
|
71450
72360
|
if (released) return;
|
|
71451
72361
|
released = true;
|
|
71452
|
-
await (0,
|
|
72362
|
+
await (0, import_promises32.rm)(path18, { force: true });
|
|
71453
72363
|
}
|
|
71454
72364
|
};
|
|
71455
72365
|
} catch (error62) {
|
|
@@ -71457,17 +72367,17 @@ async function acquireSessionLock(path18) {
|
|
|
71457
72367
|
const owner = await lockOwner(path18);
|
|
71458
72368
|
if (owner !== void 0 && processAlive(owner)) throw new SessionLockedError(path18, owner);
|
|
71459
72369
|
if (attempt > 0) throw new SessionLockedError(path18, owner);
|
|
71460
|
-
await (0,
|
|
72370
|
+
await (0, import_promises32.rm)(path18, { force: true });
|
|
71461
72371
|
}
|
|
71462
72372
|
}
|
|
71463
72373
|
throw new SessionLockedError(path18, void 0);
|
|
71464
72374
|
}
|
|
71465
|
-
var import_node_crypto26,
|
|
72375
|
+
var import_node_crypto26, import_promises32, SessionLockedError;
|
|
71466
72376
|
var init_lock = __esm({
|
|
71467
72377
|
"../alan-engine/src/engine/lock.ts"() {
|
|
71468
72378
|
"use strict";
|
|
71469
72379
|
import_node_crypto26 = require("node:crypto");
|
|
71470
|
-
|
|
72380
|
+
import_promises32 = require("node:fs/promises");
|
|
71471
72381
|
SessionLockedError = class extends Error {
|
|
71472
72382
|
lockPath;
|
|
71473
72383
|
ownerPid;
|
|
@@ -71485,7 +72395,7 @@ var init_lock = __esm({
|
|
|
71485
72395
|
|
|
71486
72396
|
// ../alan-engine/src/engine/rules.ts
|
|
71487
72397
|
async function exists(target) {
|
|
71488
|
-
return (0,
|
|
72398
|
+
return (0, import_promises33.stat)(target).then(
|
|
71489
72399
|
() => true,
|
|
71490
72400
|
() => false
|
|
71491
72401
|
);
|
|
@@ -71502,7 +72412,7 @@ async function findGitRoot(cwd) {
|
|
|
71502
72412
|
async function ruleFileIn(dir) {
|
|
71503
72413
|
for (const name of RULE_FILE_NAMES) {
|
|
71504
72414
|
const file2 = import_node_path34.default.join(dir, name);
|
|
71505
|
-
const text3 = await (0,
|
|
72415
|
+
const text3 = await (0, import_promises33.readFile)(file2, "utf8").catch(() => void 0);
|
|
71506
72416
|
if (text3 === void 0 || text3.trim() === "") continue;
|
|
71507
72417
|
const truncatedChars = Math.max(0, text3.length - MAX_RULE_FILE_CHARS);
|
|
71508
72418
|
return { path: file2, content: text3.slice(0, MAX_RULE_FILE_CHARS), truncatedChars };
|
|
@@ -71540,11 +72450,11 @@ ${file2.content.trimEnd()}${note}`;
|
|
|
71540
72450
|
async function projectInstructions(cwd) {
|
|
71541
72451
|
return renderProjectRules(await loadProjectRules(cwd));
|
|
71542
72452
|
}
|
|
71543
|
-
var
|
|
72453
|
+
var import_promises33, import_node_path34, RULE_FILE_NAMES, MAX_RULE_FILE_CHARS;
|
|
71544
72454
|
var init_rules2 = __esm({
|
|
71545
72455
|
"../alan-engine/src/engine/rules.ts"() {
|
|
71546
72456
|
"use strict";
|
|
71547
|
-
|
|
72457
|
+
import_promises33 = require("node:fs/promises");
|
|
71548
72458
|
import_node_path34 = __toESM(require("node:path"), 1);
|
|
71549
72459
|
RULE_FILE_NAMES = ["AGENTS.md", "CLAUDE.md"];
|
|
71550
72460
|
MAX_RULE_FILE_CHARS = 16e3;
|
|
@@ -71809,7 +72719,7 @@ async function anyUnreliable(paths) {
|
|
|
71809
72719
|
return false;
|
|
71810
72720
|
for (const path18 of paths) {
|
|
71811
72721
|
for (const candidate of [path18, ...ancestorsOf(path18)]) {
|
|
71812
|
-
const info = await (0,
|
|
72722
|
+
const info = await (0, import_promises34.statfs)(candidate).catch(() => void 0);
|
|
71813
72723
|
if (info === void 0)
|
|
71814
72724
|
continue;
|
|
71815
72725
|
if (UNRELIABLE_FILE_SYSTEMS.has(info.type))
|
|
@@ -71819,13 +72729,13 @@ async function anyUnreliable(paths) {
|
|
|
71819
72729
|
}
|
|
71820
72730
|
return false;
|
|
71821
72731
|
}
|
|
71822
|
-
var import_node_crypto27, import_node_fs19,
|
|
72732
|
+
var import_node_crypto27, import_node_fs19, import_promises34, import_node_path35, DEBOUNCE_MS, FSEVENTS_SETTLE_MS, DEFAULT_POLL_MS, DEFAULT_MAX_DIRECTORIES, OVERFLOW, HASH_MAX_BYTES, HASH_RECENT_MS, UNRELIABLE_FILE_SYSTEMS, BudgetExceeded, NodeFileWatcher;
|
|
71823
72733
|
var init_node_watch = __esm({
|
|
71824
72734
|
"../../node_modules/@earendil-works/pi-durable/dist/env/node-watch.js"() {
|
|
71825
72735
|
"use strict";
|
|
71826
72736
|
import_node_crypto27 = require("node:crypto");
|
|
71827
72737
|
import_node_fs19 = require("node:fs");
|
|
71828
|
-
|
|
72738
|
+
import_promises34 = require("node:fs/promises");
|
|
71829
72739
|
import_node_path35 = require("node:path");
|
|
71830
72740
|
init_env();
|
|
71831
72741
|
DEBOUNCE_MS = 50;
|
|
@@ -72038,7 +72948,7 @@ var init_node_watch = __esm({
|
|
|
72038
72948
|
const record3 = async (path18, stats) => {
|
|
72039
72949
|
let hash2;
|
|
72040
72950
|
if (this.#mode === "polling" && stats.isFile() && stats.size <= HASH_MAX_BYTES && Date.now() - stats.mtimeMs < HASH_RECENT_MS) {
|
|
72041
|
-
hash2 = await (0,
|
|
72951
|
+
hash2 = await (0, import_promises34.readFile)(path18).then((content) => (0, import_node_crypto27.createHash)("sha256").update(content).digest("hex"), () => void 0);
|
|
72042
72952
|
}
|
|
72043
72953
|
snapshot.set(path18, entryOf(stats, hash2));
|
|
72044
72954
|
};
|
|
@@ -72049,7 +72959,7 @@ var init_node_watch = __esm({
|
|
|
72049
72959
|
traversed.add(key);
|
|
72050
72960
|
let names2;
|
|
72051
72961
|
try {
|
|
72052
|
-
names2 = await (0,
|
|
72962
|
+
names2 = await (0, import_promises34.readdir)(directory);
|
|
72053
72963
|
} catch (error62) {
|
|
72054
72964
|
if (directory === target.path && isDenied(error62))
|
|
72055
72965
|
throw error62;
|
|
@@ -72063,7 +72973,7 @@ var init_node_watch = __esm({
|
|
|
72063
72973
|
const path18 = `${directory.endsWith(import_node_path35.sep) ? directory : directory + import_node_path35.sep}${name}`;
|
|
72064
72974
|
let kind = listed.get(path18);
|
|
72065
72975
|
if (kind === void 0) {
|
|
72066
|
-
const stats = await (0,
|
|
72976
|
+
const stats = await (0, import_promises34.lstat)(path18).catch(() => void 0);
|
|
72067
72977
|
if (stats === void 0)
|
|
72068
72978
|
continue;
|
|
72069
72979
|
kind = entryOf(stats).kind;
|
|
@@ -72081,20 +72991,20 @@ var init_node_watch = __esm({
|
|
|
72081
72991
|
for (const ancestor of ancestorsOf(target.path)) {
|
|
72082
72992
|
if (snapshot.has(ancestor))
|
|
72083
72993
|
continue;
|
|
72084
|
-
const stats2 = await (0,
|
|
72994
|
+
const stats2 = await (0, import_promises34.lstat)(ancestor).catch(() => void 0);
|
|
72085
72995
|
if (stats2 !== void 0)
|
|
72086
72996
|
snapshot.set(ancestor, { ...entryOf(stats2), size: 0, mtimeMs: 0 });
|
|
72087
72997
|
}
|
|
72088
72998
|
let stats;
|
|
72089
72999
|
try {
|
|
72090
|
-
stats = await (0,
|
|
73000
|
+
stats = await (0, import_promises34.stat)(target.path);
|
|
72091
73001
|
} catch (error62) {
|
|
72092
73002
|
if (isDenied(error62))
|
|
72093
73003
|
throw error62;
|
|
72094
73004
|
continue;
|
|
72095
73005
|
}
|
|
72096
73006
|
await record3(target.path, stats);
|
|
72097
|
-
if (stats.isFile() && (await (0,
|
|
73007
|
+
if (stats.isFile() && (await (0, import_promises34.lstat)(target.path).catch(() => void 0))?.isSymbolicLink()) {
|
|
72098
73008
|
linkedFiles.add(target.path);
|
|
72099
73009
|
}
|
|
72100
73010
|
if (stats.isDirectory()) {
|
|
@@ -72293,7 +73203,7 @@ function abortResult(signal, path18) {
|
|
|
72293
73203
|
}
|
|
72294
73204
|
async function pathExists(path18) {
|
|
72295
73205
|
try {
|
|
72296
|
-
await (0,
|
|
73206
|
+
await (0, import_promises35.access)(path18, import_node_fs20.constants.F_OK);
|
|
72297
73207
|
return true;
|
|
72298
73208
|
} catch {
|
|
72299
73209
|
return false;
|
|
@@ -72513,14 +73423,14 @@ function closedResult(what, path18) {
|
|
|
72513
73423
|
function symlinkRefused(path18, cause) {
|
|
72514
73424
|
return new FileError("invalid", "Refusing to follow a symbolic link", path18, cause);
|
|
72515
73425
|
}
|
|
72516
|
-
var import_node_child_process12, import_node_crypto28, import_node_fs20,
|
|
73426
|
+
var import_node_child_process12, import_node_crypto28, import_node_fs20, import_promises35, import_node_os4, import_node_path36, import_node_url4, MAX_TIMEOUT_MS, MAX_TIMEOUT_SECONDS, EXIT_STDIO_GRACE_MS, SPILL_HIGH_WATER_MARK, BINARY_READ_CHUNK, NodeTextLineReader, NodeBinaryReader, NodeDirReader, NodeExecutionEnv;
|
|
72517
73427
|
var init_node = __esm({
|
|
72518
73428
|
"../../node_modules/@earendil-works/pi-durable/dist/env/node.js"() {
|
|
72519
73429
|
"use strict";
|
|
72520
73430
|
import_node_child_process12 = require("node:child_process");
|
|
72521
73431
|
import_node_crypto28 = require("node:crypto");
|
|
72522
73432
|
import_node_fs20 = require("node:fs");
|
|
72523
|
-
|
|
73433
|
+
import_promises35 = require("node:fs/promises");
|
|
72524
73434
|
import_node_os4 = require("node:os");
|
|
72525
73435
|
import_node_path36 = require("node:path");
|
|
72526
73436
|
import_node_url4 = require("node:url");
|
|
@@ -72717,7 +73627,7 @@ var init_node = __esm({
|
|
|
72717
73627
|
const entryPath = (0, import_node_path36.resolve)(this.path, entry2.name);
|
|
72718
73628
|
let stats;
|
|
72719
73629
|
try {
|
|
72720
|
-
stats = await (0,
|
|
73630
|
+
stats = await (0, import_promises35.lstat)(entryPath);
|
|
72721
73631
|
} catch (error62) {
|
|
72722
73632
|
if (isNodeError2(error62) && error62.code === "ENOENT")
|
|
72723
73633
|
continue;
|
|
@@ -72803,7 +73713,7 @@ var init_node = __esm({
|
|
|
72803
73713
|
args = rest;
|
|
72804
73714
|
}
|
|
72805
73715
|
try {
|
|
72806
|
-
await (0,
|
|
73716
|
+
await (0, import_promises35.access)(cwd, import_node_fs20.constants.F_OK);
|
|
72807
73717
|
} catch (error62) {
|
|
72808
73718
|
const cause = toError3(error62);
|
|
72809
73719
|
return err(new ExecutionError("spawn_error", `Working directory does not exist: ${cwd}
|
|
@@ -73004,7 +73914,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73004
73914
|
if (aborted2)
|
|
73005
73915
|
return aborted2;
|
|
73006
73916
|
try {
|
|
73007
|
-
const file2 = await (0,
|
|
73917
|
+
const file2 = await (0, import_promises35.open)(resolved, "r");
|
|
73008
73918
|
const afterOpenAbort = abortResult(context.abortSignal, resolved);
|
|
73009
73919
|
if (afterOpenAbort) {
|
|
73010
73920
|
await file2.close().catch(() => void 0);
|
|
@@ -73022,7 +73932,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73022
73932
|
if (aborted2)
|
|
73023
73933
|
return aborted2;
|
|
73024
73934
|
try {
|
|
73025
|
-
return ok(await (0,
|
|
73935
|
+
return ok(await (0, import_promises35.readFile)(resolved, { encoding: "utf8", signal }));
|
|
73026
73936
|
} catch (error62) {
|
|
73027
73937
|
return err(toFileError(error62, resolved));
|
|
73028
73938
|
}
|
|
@@ -73055,7 +73965,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73055
73965
|
if (aborted2)
|
|
73056
73966
|
return aborted2;
|
|
73057
73967
|
try {
|
|
73058
|
-
return ok(await (0,
|
|
73968
|
+
return ok(await (0, import_promises35.readFile)(resolved, { signal }));
|
|
73059
73969
|
} catch (error62) {
|
|
73060
73970
|
return err(toFileError(error62, resolved));
|
|
73061
73971
|
}
|
|
@@ -73070,14 +73980,14 @@ Cannot execute bash commands.`, cause));
|
|
|
73070
73980
|
try {
|
|
73071
73981
|
let flags = import_node_fs20.constants.O_RDONLY;
|
|
73072
73982
|
if (process.platform === "win32") {
|
|
73073
|
-
if (noFollow && (await (0,
|
|
73983
|
+
if (noFollow && (await (0, import_promises35.lstat)(resolved)).isSymbolicLink())
|
|
73074
73984
|
return err(symlinkRefused(resolved));
|
|
73075
73985
|
} else {
|
|
73076
73986
|
flags |= import_node_fs20.constants.O_NONBLOCK;
|
|
73077
73987
|
if (noFollow)
|
|
73078
73988
|
flags |= import_node_fs20.constants.O_NOFOLLOW;
|
|
73079
73989
|
}
|
|
73080
|
-
file2 = await (0,
|
|
73990
|
+
file2 = await (0, import_promises35.open)(resolved, flags);
|
|
73081
73991
|
const stats = await file2.stat();
|
|
73082
73992
|
if (!stats.isFile()) {
|
|
73083
73993
|
await file2.close().catch(() => void 0);
|
|
@@ -73104,11 +74014,11 @@ Cannot execute bash commands.`, cause));
|
|
|
73104
74014
|
if (aborted2)
|
|
73105
74015
|
return aborted2;
|
|
73106
74016
|
try {
|
|
73107
|
-
await (0,
|
|
74017
|
+
await (0, import_promises35.mkdir)((0, import_node_path36.resolve)(resolved, ".."), { recursive: true });
|
|
73108
74018
|
const afterMkdirAbort = abortResult(signal, resolved);
|
|
73109
74019
|
if (afterMkdirAbort)
|
|
73110
74020
|
return afterMkdirAbort;
|
|
73111
|
-
await (0,
|
|
74021
|
+
await (0, import_promises35.writeFile)(resolved, content, { signal });
|
|
73112
74022
|
return ok(void 0);
|
|
73113
74023
|
} catch (error62) {
|
|
73114
74024
|
return err(toFileError(error62, resolved));
|
|
@@ -73121,11 +74031,11 @@ Cannot execute bash commands.`, cause));
|
|
|
73121
74031
|
if (aborted2)
|
|
73122
74032
|
return aborted2;
|
|
73123
74033
|
try {
|
|
73124
|
-
await (0,
|
|
74034
|
+
await (0, import_promises35.mkdir)((0, import_node_path36.resolve)(resolved, ".."), { recursive: true });
|
|
73125
74035
|
const afterMkdirAbort = abortResult(signal, resolved);
|
|
73126
74036
|
if (afterMkdirAbort)
|
|
73127
74037
|
return afterMkdirAbort;
|
|
73128
|
-
await (0,
|
|
74038
|
+
await (0, import_promises35.appendFile)(resolved, content);
|
|
73129
74039
|
const afterAppendAbort = abortResult(signal, resolved);
|
|
73130
74040
|
return afterAppendAbort ?? ok(void 0);
|
|
73131
74041
|
} catch (error62) {
|
|
@@ -73143,7 +74053,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73143
74053
|
}
|
|
73144
74054
|
let file2;
|
|
73145
74055
|
try {
|
|
73146
|
-
file2 = await (0,
|
|
74056
|
+
file2 = await (0, import_promises35.open)(resolved, "r+");
|
|
73147
74057
|
await file2.truncate(size);
|
|
73148
74058
|
const afterTruncateAbort = abortResult(signal, resolved);
|
|
73149
74059
|
return afterTruncateAbort ?? ok(void 0);
|
|
@@ -73161,7 +74071,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73161
74071
|
return aborted2;
|
|
73162
74072
|
let file2;
|
|
73163
74073
|
try {
|
|
73164
|
-
file2 = await (0,
|
|
74074
|
+
file2 = await (0, import_promises35.open)(resolved, "r+");
|
|
73165
74075
|
if ((await file2.stat()).isDirectory())
|
|
73166
74076
|
return err(new FileError("is_directory", "Is a directory", resolved));
|
|
73167
74077
|
await file2.sync();
|
|
@@ -73180,7 +74090,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73180
74090
|
if (aborted2)
|
|
73181
74091
|
return aborted2;
|
|
73182
74092
|
try {
|
|
73183
|
-
await (0,
|
|
74093
|
+
await (0, import_promises35.rename)(source, destination);
|
|
73184
74094
|
return ok(void 0);
|
|
73185
74095
|
} catch (error62) {
|
|
73186
74096
|
return err(toFileError(error62, source));
|
|
@@ -73192,7 +74102,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73192
74102
|
if (aborted2)
|
|
73193
74103
|
return aborted2;
|
|
73194
74104
|
try {
|
|
73195
|
-
return fileInfoFromStats(resolved, await (0,
|
|
74105
|
+
return fileInfoFromStats(resolved, await (0, import_promises35.lstat)(resolved));
|
|
73196
74106
|
} catch (error62) {
|
|
73197
74107
|
return err(toFileError(error62, resolved));
|
|
73198
74108
|
}
|
|
@@ -73204,7 +74114,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73204
74114
|
if (aborted2)
|
|
73205
74115
|
return aborted2;
|
|
73206
74116
|
try {
|
|
73207
|
-
const entries2 = await (0,
|
|
74117
|
+
const entries2 = await (0, import_promises35.readdir)(resolved, { withFileTypes: true });
|
|
73208
74118
|
const infos = [];
|
|
73209
74119
|
for (const entry2 of entries2) {
|
|
73210
74120
|
const loopAbort = abortResult(signal, resolved);
|
|
@@ -73212,7 +74122,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73212
74122
|
return loopAbort;
|
|
73213
74123
|
const entryPath = (0, import_node_path36.resolve)(resolved, entry2.name);
|
|
73214
74124
|
try {
|
|
73215
|
-
const info = fileInfoFromStats(entryPath, await (0,
|
|
74125
|
+
const info = fileInfoFromStats(entryPath, await (0, import_promises35.lstat)(entryPath));
|
|
73216
74126
|
if (info.ok)
|
|
73217
74127
|
infos.push(info.value);
|
|
73218
74128
|
} catch (error62) {
|
|
@@ -73230,7 +74140,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73230
74140
|
if (aborted2)
|
|
73231
74141
|
return aborted2;
|
|
73232
74142
|
try {
|
|
73233
|
-
const dir = await (0,
|
|
74143
|
+
const dir = await (0, import_promises35.opendir)(resolved);
|
|
73234
74144
|
const afterOpenAbort = abortResult(context.abortSignal, resolved);
|
|
73235
74145
|
if (afterOpenAbort) {
|
|
73236
74146
|
await dir.close().catch(() => void 0);
|
|
@@ -73247,7 +74157,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73247
74157
|
if (aborted2)
|
|
73248
74158
|
return aborted2;
|
|
73249
74159
|
try {
|
|
73250
|
-
return ok(await (0,
|
|
74160
|
+
return ok(await (0, import_promises35.realpath)(resolved));
|
|
73251
74161
|
} catch (error62) {
|
|
73252
74162
|
return err(toFileError(error62, resolved));
|
|
73253
74163
|
}
|
|
@@ -73266,7 +74176,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73266
74176
|
if (aborted2)
|
|
73267
74177
|
return aborted2;
|
|
73268
74178
|
try {
|
|
73269
|
-
await (0,
|
|
74179
|
+
await (0, import_promises35.mkdir)(resolved, { recursive: options?.recursive ?? true });
|
|
73270
74180
|
return ok(void 0);
|
|
73271
74181
|
} catch (error62) {
|
|
73272
74182
|
return err(toFileError(error62, resolved));
|
|
@@ -73278,7 +74188,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73278
74188
|
if (aborted2)
|
|
73279
74189
|
return aborted2;
|
|
73280
74190
|
try {
|
|
73281
|
-
await (0,
|
|
74191
|
+
await (0, import_promises35.rm)(resolved, { recursive: options?.recursive ?? false, force: options?.force ?? false });
|
|
73282
74192
|
return ok(void 0);
|
|
73283
74193
|
} catch (error62) {
|
|
73284
74194
|
return err(toFileError(error62, resolved));
|
|
@@ -73290,7 +74200,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73290
74200
|
return aborted2;
|
|
73291
74201
|
try {
|
|
73292
74202
|
prefix2 ??= "tmp-";
|
|
73293
|
-
return ok(await (0,
|
|
74203
|
+
return ok(await (0, import_promises35.mkdtemp)((0, import_node_path36.join)((0, import_node_os4.tmpdir)(), prefix2)));
|
|
73294
74204
|
} catch (error62) {
|
|
73295
74205
|
return err(toFileError(error62));
|
|
73296
74206
|
}
|
|
@@ -73301,7 +74211,7 @@ Cannot execute bash commands.`, cause));
|
|
|
73301
74211
|
return dir;
|
|
73302
74212
|
const filePath = (0, import_node_path36.join)(dir.value, `${options?.prefix ?? ""}${(0, import_node_crypto28.randomUUID)()}${options?.suffix ?? ""}`);
|
|
73303
74213
|
try {
|
|
73304
|
-
await (0,
|
|
74214
|
+
await (0, import_promises35.writeFile)(filePath, "");
|
|
73305
74215
|
return ok(filePath);
|
|
73306
74216
|
} catch (error62) {
|
|
73307
74217
|
return err(toFileError(error62, filePath));
|
|
@@ -73383,7 +74293,7 @@ async function openNodeSqliteDatabase(path18, options = {}) {
|
|
|
73383
74293
|
const checkpointPages = options.walAutoCheckpointPages ?? DEFAULT_WAL_AUTO_CHECKPOINT_PAGES;
|
|
73384
74294
|
const timeout2 = options.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS;
|
|
73385
74295
|
if (path18 !== ":memory:")
|
|
73386
|
-
await (0,
|
|
74296
|
+
await (0, import_promises36.mkdir)((0, import_node_path37.dirname)(path18), { recursive: true });
|
|
73387
74297
|
const database = new import_node_sqlite.DatabaseSync(path18, { timeout: timeout2 });
|
|
73388
74298
|
const adapter = new NodeSqliteDatabase(database);
|
|
73389
74299
|
try {
|
|
@@ -73399,11 +74309,11 @@ async function openNodeSqliteDatabase(path18, options = {}) {
|
|
|
73399
74309
|
throw error62;
|
|
73400
74310
|
}
|
|
73401
74311
|
}
|
|
73402
|
-
var
|
|
74312
|
+
var import_promises36, import_node_path37, import_node_sqlite, DEFAULT_WAL_AUTO_CHECKPOINT_PAGES, DEFAULT_BUSY_TIMEOUT_MS, ignore2, SerialOperationQueue, STATEMENT_CACHE_LIMIT, NodeSqliteExecutor, NodeSqliteTransaction, NodeSqliteDatabase;
|
|
73403
74313
|
var init_node2 = __esm({
|
|
73404
74314
|
"../../node_modules/@earendil-works/chord/dist/sqlite/node.js"() {
|
|
73405
74315
|
"use strict";
|
|
73406
|
-
|
|
74316
|
+
import_promises36 = require("node:fs/promises");
|
|
73407
74317
|
import_node_path37 = require("node:path");
|
|
73408
74318
|
import_node_sqlite = require("node:sqlite");
|
|
73409
74319
|
DEFAULT_WAL_AUTO_CHECKPOINT_PAGES = 1e3;
|
|
@@ -83907,12 +84817,12 @@ var init_servers = __esm({
|
|
|
83907
84817
|
});
|
|
83908
84818
|
|
|
83909
84819
|
// ../alan-engine/src/model/credentials.ts
|
|
83910
|
-
function
|
|
84820
|
+
function nonEmpty3(value2) {
|
|
83911
84821
|
return typeof value2 === "string" && value2.trim() !== "" ? value2.trim() : void 0;
|
|
83912
84822
|
}
|
|
83913
84823
|
function alanApiUrl(options = {}) {
|
|
83914
84824
|
const env = options.env ?? process.env;
|
|
83915
|
-
return (
|
|
84825
|
+
return (nonEmpty3(options.apiUrl) ?? nonEmpty3(env.ALAN_API_URL) ?? DEFAULT_ALAN_API_URL).replace(
|
|
83916
84826
|
/\/+$/,
|
|
83917
84827
|
""
|
|
83918
84828
|
);
|
|
@@ -83924,13 +84834,13 @@ function stripBearer(authorization) {
|
|
|
83924
84834
|
return authorization.replace(/^Bearer\s+/i, "").trim();
|
|
83925
84835
|
}
|
|
83926
84836
|
async function readAlanCredentialFile(path18) {
|
|
83927
|
-
const parsed = JSON.parse(await (0,
|
|
84837
|
+
const parsed = JSON.parse(await (0, import_promises37.readFile)(path18, "utf8"));
|
|
83928
84838
|
if (typeof parsed !== "object" || parsed === null) {
|
|
83929
84839
|
throw new Error(`Alan credential file is not a JSON object: ${path18}`);
|
|
83930
84840
|
}
|
|
83931
|
-
const authorization =
|
|
83932
|
-
const conversationId =
|
|
83933
|
-
const organizationId =
|
|
84841
|
+
const authorization = nonEmpty3(Reflect.get(parsed, "authorization"));
|
|
84842
|
+
const conversationId = nonEmpty3(Reflect.get(parsed, "conversationId"));
|
|
84843
|
+
const organizationId = nonEmpty3(Reflect.get(parsed, "organizationId"));
|
|
83934
84844
|
return {
|
|
83935
84845
|
apiKey: authorization === void 0 ? void 0 : stripBearer(authorization),
|
|
83936
84846
|
...conversationId ? { conversationId } : {},
|
|
@@ -83939,18 +84849,18 @@ async function readAlanCredentialFile(path18) {
|
|
|
83939
84849
|
}
|
|
83940
84850
|
function alanCredentialSource(explicit, env = process.env) {
|
|
83941
84851
|
if (explicit !== void 0) return explicit;
|
|
83942
|
-
const file2 =
|
|
84852
|
+
const file2 = nonEmpty3(env.ALAN_MCP_CREDENTIAL_FILE);
|
|
83943
84853
|
if (file2 === void 0) return { apiKey: void 0 };
|
|
83944
84854
|
return () => readAlanCredentialFile(file2);
|
|
83945
84855
|
}
|
|
83946
84856
|
async function resolveAlanCredentials(source) {
|
|
83947
84857
|
return typeof source === "function" ? source() : source;
|
|
83948
84858
|
}
|
|
83949
|
-
var
|
|
84859
|
+
var import_promises37, DEFAULT_ALAN_API_URL, ALAN_CONVERSATION_HEADER;
|
|
83950
84860
|
var init_credentials = __esm({
|
|
83951
84861
|
"../alan-engine/src/model/credentials.ts"() {
|
|
83952
84862
|
"use strict";
|
|
83953
|
-
|
|
84863
|
+
import_promises37 = require("node:fs/promises");
|
|
83954
84864
|
DEFAULT_ALAN_API_URL = "https://api.tryalan.ai";
|
|
83955
84865
|
ALAN_CONVERSATION_HEADER = "x-alan-conversation-id";
|
|
83956
84866
|
}
|
|
@@ -93030,8 +93940,8 @@ var init_ChatCompletionStream = __esm({
|
|
|
93030
93940
|
const structuredResponse = isParseableResponseFormat(__classPrivateFieldGet(this, _ChatCompletionStream_params, "f")?.response_format);
|
|
93031
93941
|
const boundedSnapshot = structuredResponse || __classPrivateFieldGet(this, _ChatCompletionStream_hasAutoParseableTool, "f");
|
|
93032
93942
|
const messageSnapshot = boundedSnapshot ? captureStructuredMessageSnapshot(choiceSnapshot) : choiceSnapshot.message;
|
|
93033
|
-
const
|
|
93034
|
-
const parseableContent = !
|
|
93943
|
+
const refusal3 = boundedSnapshot ? captureStructuredJSONSnapshot(messageSnapshot, "refusal") : messageSnapshot.refusal;
|
|
93944
|
+
const parseableContent = !refusal3 && structuredResponse;
|
|
93035
93945
|
const messageContent = parseableContent ? captureStructuredJSONSnapshot(messageSnapshot, "content") : messageSnapshot.content;
|
|
93036
93946
|
if (delta?.content != null && messageSnapshot.role === "assistant" && messageContent) {
|
|
93037
93947
|
this._emit("content", delta.content, messageContent);
|
|
@@ -93041,10 +93951,10 @@ var init_ChatCompletionStream = __esm({
|
|
|
93041
93951
|
parsed: messageSnapshot.parsed
|
|
93042
93952
|
});
|
|
93043
93953
|
}
|
|
93044
|
-
if (delta?.refusal != null && messageSnapshot.role === "assistant" &&
|
|
93954
|
+
if (delta?.refusal != null && messageSnapshot.role === "assistant" && refusal3) {
|
|
93045
93955
|
this._emit("refusal.delta", {
|
|
93046
93956
|
delta: delta.refusal,
|
|
93047
|
-
snapshot:
|
|
93957
|
+
snapshot: refusal3
|
|
93048
93958
|
});
|
|
93049
93959
|
}
|
|
93050
93960
|
if (choice.logprobs?.content != null && messageSnapshot.role === "assistant") {
|
|
@@ -93160,22 +94070,22 @@ var init_ChatCompletionStream = __esm({
|
|
|
93160
94070
|
const structuredResponse = isParseableResponseFormat(__classPrivateFieldGet(this, _ChatCompletionStream_params, "f")?.response_format);
|
|
93161
94071
|
const boundedSnapshot = structuredResponse || __classPrivateFieldGet(this, _ChatCompletionStream_hasAutoParseableTool, "f");
|
|
93162
94072
|
const messageSnapshot = boundedSnapshot ? captureStructuredMessageSnapshot(choiceSnapshot) : choiceSnapshot.message;
|
|
93163
|
-
const
|
|
93164
|
-
const parseableContent = !
|
|
94073
|
+
const refusal3 = boundedSnapshot ? captureStructuredJSONSnapshot(messageSnapshot, "refusal") : messageSnapshot.refusal;
|
|
94074
|
+
const parseableContent = !refusal3 && structuredResponse;
|
|
93165
94075
|
const content = parseableContent ? captureStructuredJSONSnapshot(messageSnapshot, "content") : messageSnapshot.content;
|
|
93166
|
-
if (content != null && (content !== "" || !
|
|
94076
|
+
if (content != null && (content !== "" || !refusal3 && !messageSnapshot.tool_calls?.length && !messageSnapshot.function_call) && !state2.content_done) {
|
|
93167
94077
|
if (parseableContent && __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f")) {
|
|
93168
94078
|
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_validateStructuredSnapshots).call(this, __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f"));
|
|
93169
94079
|
}
|
|
93170
94080
|
state2.content_done = true;
|
|
93171
94081
|
this._emit("content.done", {
|
|
93172
94082
|
content,
|
|
93173
|
-
parsed:
|
|
94083
|
+
parsed: refusal3 ? null : parseResponseFormatContent(__classPrivateFieldGet(this, _ChatCompletionStream_params, "f")?.response_format, parseableContent ? validateStructuredJSONSnapshot(content) : content)
|
|
93174
94084
|
});
|
|
93175
94085
|
}
|
|
93176
|
-
if (
|
|
94086
|
+
if (refusal3 && !state2.refusal_done) {
|
|
93177
94087
|
state2.refusal_done = true;
|
|
93178
|
-
this._emit("refusal.done", { refusal:
|
|
94088
|
+
this._emit("refusal.done", { refusal: refusal3 });
|
|
93179
94089
|
}
|
|
93180
94090
|
if (choiceSnapshot.logprobs?.content && !state2.logprobs_content_done) {
|
|
93181
94091
|
state2.logprobs_content_done = true;
|
|
@@ -93199,19 +94109,19 @@ var init_ChatCompletionStream = __esm({
|
|
|
93199
94109
|
continue;
|
|
93200
94110
|
}
|
|
93201
94111
|
const message = captureStructuredMessageSnapshot(choice);
|
|
93202
|
-
const
|
|
94112
|
+
const refusal3 = captureStructuredJSONSnapshot(message, "refusal");
|
|
93203
94113
|
const content = captureStructuredJSONSnapshot(message, "content");
|
|
93204
94114
|
const validatedTools = /* @__PURE__ */ new Map();
|
|
93205
94115
|
const toolCalls2 = captureSnapshotArray(message, "tool_calls", MAX_STREAM_TOOL_CALLS, "tool-call");
|
|
93206
94116
|
validatedMessages.set(choice, Object.freeze({
|
|
93207
94117
|
message,
|
|
93208
94118
|
content,
|
|
93209
|
-
refusal:
|
|
94119
|
+
refusal: refusal3,
|
|
93210
94120
|
toolCallCollection: toolCalls2,
|
|
93211
94121
|
toolCalls: validatedTools
|
|
93212
94122
|
}));
|
|
93213
94123
|
const state2 = __classPrivateFieldGet(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
93214
|
-
if (parseableContent && !
|
|
94124
|
+
if (parseableContent && !refusal3 && typeof content === "string") {
|
|
93215
94125
|
validateStructuredJSONSnapshot(content, finalJSONBudget, __classPrivateFieldGet(this, _ChatCompletionStream_partialJSONParseBudget, "f"));
|
|
93216
94126
|
}
|
|
93217
94127
|
for (const [index, identity2] of state2?.tool_call_identities ?? []) {
|
|
@@ -93324,16 +94234,16 @@ var init_ChatCompletionStream = __esm({
|
|
|
93324
94234
|
}
|
|
93325
94235
|
if (logprobs) {
|
|
93326
94236
|
if (choice.logprobs) {
|
|
93327
|
-
const { content: content2, refusal:
|
|
94237
|
+
const { content: content2, refusal: refusal4, ...rest3 } = logprobs;
|
|
93328
94238
|
assertIsEmpty(rest3);
|
|
93329
94239
|
assignOwnProperties(choice.logprobs, rest3);
|
|
93330
94240
|
if (content2) {
|
|
93331
94241
|
(_a7 = choice.logprobs).content ?? (_a7.content = []);
|
|
93332
94242
|
choice.logprobs.content.push(...content2);
|
|
93333
94243
|
}
|
|
93334
|
-
if (
|
|
94244
|
+
if (refusal4) {
|
|
93335
94245
|
(_b = choice.logprobs).refusal ?? (_b.refusal = []);
|
|
93336
|
-
choice.logprobs.refusal.push(...
|
|
94246
|
+
choice.logprobs.refusal.push(...refusal4);
|
|
93337
94247
|
}
|
|
93338
94248
|
} else {
|
|
93339
94249
|
choice.logprobs = { ...logprobs };
|
|
@@ -93362,16 +94272,16 @@ var init_ChatCompletionStream = __esm({
|
|
|
93362
94272
|
continue;
|
|
93363
94273
|
}
|
|
93364
94274
|
__classPrivateFieldGet(this, _ChatCompletionStream_audioDoneChoiceIndexes, "f").delete(index);
|
|
93365
|
-
const { audio, content, refusal:
|
|
94275
|
+
const { audio, content, refusal: refusal3, function_call, role, ...capturedDeltaFields } = delta;
|
|
93366
94276
|
const { tool_calls: capturedToolCallDelta, ...rest2 } = capturedDeltaFields;
|
|
93367
94277
|
const tool_calls = hasOwn(capturedDeltaFields, "tool_calls") ? capturedToolCallDelta : delta.tool_calls;
|
|
93368
94278
|
assertIsEmpty(rest2);
|
|
93369
94279
|
assignOwnProperties(choice.message, rest2);
|
|
93370
|
-
if (audio?.expires_at != null && audio.id == null && audio.data == null && audio.transcript == null && content == null &&
|
|
94280
|
+
if (audio?.expires_at != null && audio.id == null && audio.data == null && audio.transcript == null && content == null && refusal3 == null && function_call == null && role == null && tool_calls == null && Object.keys(rest2).length === 0) {
|
|
93371
94281
|
__classPrivateFieldGet(this, _ChatCompletionStream_audioDoneChoiceIndexes, "f").add(index);
|
|
93372
94282
|
}
|
|
93373
|
-
if (
|
|
93374
|
-
choice.message.refusal = (choice.message.refusal || "") +
|
|
94283
|
+
if (refusal3) {
|
|
94284
|
+
choice.message.refusal = (choice.message.refusal || "") + refusal3;
|
|
93375
94285
|
}
|
|
93376
94286
|
if (role) {
|
|
93377
94287
|
choice.message.role = role;
|
|
@@ -108054,9 +108964,9 @@ function killGroup(child, signal) {
|
|
|
108054
108964
|
killProcessTree3(child, signal);
|
|
108055
108965
|
}
|
|
108056
108966
|
async function saveFullOutput(text3) {
|
|
108057
|
-
await (0,
|
|
108967
|
+
await (0, import_promises38.mkdir)(OUTPUT_DIR, { recursive: true });
|
|
108058
108968
|
const file2 = import_node_path39.default.join(OUTPUT_DIR, `tool_${(0, import_node_crypto32.randomUUID)()}`);
|
|
108059
|
-
await (0,
|
|
108969
|
+
await (0, import_promises38.writeFile)(file2, text3, "utf8");
|
|
108060
108970
|
return file2;
|
|
108061
108971
|
}
|
|
108062
108972
|
function runCommand2(scope, args, cwd, timeout2) {
|
|
@@ -108140,7 +109050,7 @@ Use bash_output with this ID to read new output and kill_shell to stop it.`;
|
|
|
108140
109050
|
}
|
|
108141
109051
|
async function execute(scope, args, shells, options) {
|
|
108142
109052
|
const cwd = args.workdir ? resolvePath2(scope.cwd, args.workdir) : scope.cwd;
|
|
108143
|
-
const workdirInfo = await (0,
|
|
109053
|
+
const workdirInfo = await (0, import_promises38.stat)(cwd).catch(() => void 0);
|
|
108144
109054
|
if (!workdirInfo?.isDirectory())
|
|
108145
109055
|
throw new ToolFailure(`Working directory does not exist: ${cwd}`);
|
|
108146
109056
|
if (args.run_in_background === true) {
|
|
@@ -108199,13 +109109,13 @@ function createBashTool(cwd, shells, options = {}) {
|
|
|
108199
109109
|
execute: (args, api, context) => guard(context, () => execute({ cwd, api, context }, args, shells, options))
|
|
108200
109110
|
});
|
|
108201
109111
|
}
|
|
108202
|
-
var import_node_child_process14, import_node_crypto32,
|
|
109112
|
+
var import_node_child_process14, import_node_crypto32, import_promises38, import_node_os5, import_node_path39, DEFAULT_TIMEOUT_MS2, MAX_TIMEOUT_MS2, MAX_LINES, MAX_BYTES, MAX_METADATA_LENGTH, DETAILS_INTERVAL_MS, KILL_GRACE_MS, OUTPUT_DIR, DESCRIPTION, parameters, HEAD_CHARS, TAIL_CHARS;
|
|
108203
109113
|
var init_bash = __esm({
|
|
108204
109114
|
"../alan-engine/src/tools/bash.ts"() {
|
|
108205
109115
|
"use strict";
|
|
108206
109116
|
import_node_child_process14 = require("node:child_process");
|
|
108207
109117
|
import_node_crypto32 = require("node:crypto");
|
|
108208
|
-
|
|
109118
|
+
import_promises38 = require("node:fs/promises");
|
|
108209
109119
|
import_node_os5 = __toESM(require("node:os"), 1);
|
|
108210
109120
|
import_node_path39 = __toESM(require("node:path"), 1);
|
|
108211
109121
|
init_dist4();
|
|
@@ -108524,7 +109434,7 @@ function stampOf(info) {
|
|
|
108524
109434
|
return { mtimeMs: info.mtimeMs, size: info.size };
|
|
108525
109435
|
}
|
|
108526
109436
|
async function recordFileStamp(scope, filepath, info) {
|
|
108527
|
-
const current = info ?? await (0,
|
|
109437
|
+
const current = info ?? await (0, import_promises39.stat)(filepath);
|
|
108528
109438
|
await scope.api.commit(async (tx) => {
|
|
108529
109439
|
const doc = await tx.doc(FileReadsDoc, scope.api.conversationId);
|
|
108530
109440
|
doc.files[filepath] = stampOf(current);
|
|
@@ -108538,11 +109448,11 @@ async function assertUnchangedSinceRead(scope, filepath, info) {
|
|
|
108538
109448
|
throw new ToolFailure(modifiedSinceReadMessage(filepath));
|
|
108539
109449
|
}
|
|
108540
109450
|
}
|
|
108541
|
-
var
|
|
109451
|
+
var import_promises39, FileReadsDoc;
|
|
108542
109452
|
var init_file_reads = __esm({
|
|
108543
109453
|
"../alan-engine/src/tools/file-reads.ts"() {
|
|
108544
109454
|
"use strict";
|
|
108545
|
-
|
|
109455
|
+
import_promises39 = require("node:fs/promises");
|
|
108546
109456
|
init_dist4();
|
|
108547
109457
|
init_shared2();
|
|
108548
109458
|
FileReadsDoc = defineDoc({
|
|
@@ -108575,27 +109485,27 @@ function withLineEnding(edit, ending) {
|
|
|
108575
109485
|
};
|
|
108576
109486
|
}
|
|
108577
109487
|
async function applyEdit(scope, filepath, args) {
|
|
108578
|
-
const info = await (0,
|
|
109488
|
+
const info = await (0, import_promises40.stat)(filepath).catch(() => void 0);
|
|
108579
109489
|
const [first] = args.edits;
|
|
108580
109490
|
if (first !== void 0 && first.oldString === "" && args.edits.length === 1) {
|
|
108581
109491
|
if (info) throw new ToolFailure(EMPTY_OLD_STRING_MESSAGE);
|
|
108582
109492
|
scope.context.abortSignal?.throwIfAborted();
|
|
108583
|
-
await (0,
|
|
108584
|
-
await (0,
|
|
109493
|
+
await (0, import_promises40.mkdir)(import_node_path41.default.dirname(filepath), { recursive: true });
|
|
109494
|
+
await (0, import_promises40.writeFile)(filepath, first.newString, "utf8");
|
|
108585
109495
|
await recordFileStamp(scope, filepath);
|
|
108586
109496
|
return { before: "", after: first.newString };
|
|
108587
109497
|
}
|
|
108588
109498
|
if (!info) throw new ToolFailure(`File ${filepath} not found`);
|
|
108589
109499
|
if (info.isDirectory()) throw new ToolFailure(`Path is a directory, not a file: ${filepath}`);
|
|
108590
109500
|
await assertUnchangedSinceRead(scope, filepath, info);
|
|
108591
|
-
const before = await (0,
|
|
109501
|
+
const before = await (0, import_promises40.readFile)(filepath, "utf8");
|
|
108592
109502
|
const ending = detectLineEnding(before);
|
|
108593
109503
|
const after = applyReplacements(
|
|
108594
109504
|
before,
|
|
108595
109505
|
args.edits.map((edit) => withLineEnding(edit, ending))
|
|
108596
109506
|
);
|
|
108597
109507
|
scope.context.abortSignal?.throwIfAborted();
|
|
108598
|
-
await (0,
|
|
109508
|
+
await (0, import_promises40.writeFile)(filepath, after, "utf8");
|
|
108599
109509
|
await recordFileStamp(scope, filepath);
|
|
108600
109510
|
return { before, after };
|
|
108601
109511
|
}
|
|
@@ -108625,11 +109535,11 @@ function createEditTool(cwd) {
|
|
|
108625
109535
|
execute: (args, api, context) => guard(context, () => execute2({ cwd, api, context }, args))
|
|
108626
109536
|
});
|
|
108627
109537
|
}
|
|
108628
|
-
var
|
|
109538
|
+
var import_promises40, import_node_path41, DESCRIPTION2, replacement, parameters2;
|
|
108629
109539
|
var init_edit = __esm({
|
|
108630
109540
|
"../alan-engine/src/tools/edit.ts"() {
|
|
108631
109541
|
"use strict";
|
|
108632
|
-
|
|
109542
|
+
import_promises40 = require("node:fs/promises");
|
|
108633
109543
|
import_node_path41 = __toESM(require("node:path"), 1);
|
|
108634
109544
|
init_dist4();
|
|
108635
109545
|
init_build();
|
|
@@ -108699,7 +109609,7 @@ async function syntaxProblem(filepath) {
|
|
|
108699
109609
|
const extension = import_node_path42.default.extname(filepath).toLowerCase();
|
|
108700
109610
|
if (extension === ".py") return pythonProblem(filepath);
|
|
108701
109611
|
if (!TS_EXTENSIONS.has(extension) && extension !== ".json") return void 0;
|
|
108702
|
-
const source = await (0,
|
|
109612
|
+
const source = await (0, import_promises41.readFile)(filepath, "utf8").catch(() => void 0);
|
|
108703
109613
|
if (source === void 0) return void 0;
|
|
108704
109614
|
if (extension !== ".json") return typeScriptProblem(source);
|
|
108705
109615
|
try {
|
|
@@ -108751,12 +109661,12 @@ function withBudgetReminder(tools) {
|
|
|
108751
109661
|
})
|
|
108752
109662
|
);
|
|
108753
109663
|
}
|
|
108754
|
-
var import_node_child_process16,
|
|
109664
|
+
var import_node_child_process16, import_promises41, import_node_module, import_node_path42, TOOL_EXPERIMENTS, SYNTAX_TIMEOUT_MS, TS_EXTENSIONS, PY_PARSE, BUDGET_FIRST_REMINDER, BUDGET_REMINDER_EVERY;
|
|
108755
109665
|
var init_experiments = __esm({
|
|
108756
109666
|
"../alan-engine/src/tools/experiments.ts"() {
|
|
108757
109667
|
"use strict";
|
|
108758
109668
|
import_node_child_process16 = require("node:child_process");
|
|
108759
|
-
|
|
109669
|
+
import_promises41 = require("node:fs/promises");
|
|
108760
109670
|
import_node_module = require("node:module");
|
|
108761
109671
|
import_node_path42 = __toESM(require("node:path"), 1);
|
|
108762
109672
|
TOOL_EXPERIMENTS = [
|
|
@@ -108940,7 +109850,7 @@ function runRipgrep(binary, run3) {
|
|
|
108940
109850
|
});
|
|
108941
109851
|
}
|
|
108942
109852
|
async function readIgnoreRules(root) {
|
|
108943
|
-
const text3 = await (0,
|
|
109853
|
+
const text3 = await (0, import_promises42.readFile)(import_node_path43.default.join(root, ".gitignore"), "utf8").catch(() => "");
|
|
108944
109854
|
const rules = [];
|
|
108945
109855
|
for (const raw of text3.split(/\r?\n/)) {
|
|
108946
109856
|
const line = raw.trim();
|
|
@@ -108962,7 +109872,7 @@ async function* walkFiles(root, options) {
|
|
|
108962
109872
|
while (stack.length > 0) {
|
|
108963
109873
|
options.signal?.throwIfAborted();
|
|
108964
109874
|
const relativeDir = stack.pop() ?? "";
|
|
108965
|
-
const entries2 = await (0,
|
|
109875
|
+
const entries2 = await (0, import_promises42.readdir)(import_node_path43.default.join(root, relativeDir), { withFileTypes: true }).catch(
|
|
108966
109876
|
() => []
|
|
108967
109877
|
);
|
|
108968
109878
|
entries2.sort((a, b) => a.name.localeCompare(b.name));
|
|
@@ -108985,13 +109895,13 @@ async function* walkFiles(root, options) {
|
|
|
108985
109895
|
for (let i = directories.length - 1; i >= 0; i--) stack.push(directories[i]);
|
|
108986
109896
|
}
|
|
108987
109897
|
}
|
|
108988
|
-
var import_node_child_process17, import_node_fs23,
|
|
109898
|
+
var import_node_child_process17, import_node_fs23, import_promises42, import_node_path43, import_node_readline, ALWAYS_SKIPPED, ripgrepPath;
|
|
108989
109899
|
var init_search2 = __esm({
|
|
108990
109900
|
"../alan-engine/src/tools/search.ts"() {
|
|
108991
109901
|
"use strict";
|
|
108992
109902
|
import_node_child_process17 = require("node:child_process");
|
|
108993
109903
|
import_node_fs23 = require("node:fs");
|
|
108994
|
-
|
|
109904
|
+
import_promises42 = require("node:fs/promises");
|
|
108995
109905
|
import_node_path43 = __toESM(require("node:path"), 1);
|
|
108996
109906
|
import_node_readline = require("node:readline");
|
|
108997
109907
|
init_glob_match();
|
|
@@ -109023,7 +109933,7 @@ async function findFiles(root, pattern, signal) {
|
|
|
109023
109933
|
}
|
|
109024
109934
|
async function execute3(scope, args) {
|
|
109025
109935
|
const search = resolvePath2(scope.cwd, args.path ?? ".");
|
|
109026
|
-
const info = await (0,
|
|
109936
|
+
const info = await (0, import_promises43.stat)(search).catch(() => void 0);
|
|
109027
109937
|
if (info?.isFile()) throw new ToolFailure(`glob path must be a directory: ${search}`);
|
|
109028
109938
|
if (!info) throw new ToolFailure(`Directory not found: ${search}`);
|
|
109029
109939
|
const files = await findFiles(search, args.pattern, scope.context.abortSignal);
|
|
@@ -109054,11 +109964,11 @@ function createGlobTool(cwd) {
|
|
|
109054
109964
|
execute: (args, api, context) => guard(context, () => execute3({ cwd, api, context }, args))
|
|
109055
109965
|
});
|
|
109056
109966
|
}
|
|
109057
|
-
var
|
|
109967
|
+
var import_promises43, import_node_path44, DESCRIPTION3, LIMIT, parameters3;
|
|
109058
109968
|
var init_glob = __esm({
|
|
109059
109969
|
"../alan-engine/src/tools/glob.ts"() {
|
|
109060
109970
|
"use strict";
|
|
109061
|
-
|
|
109971
|
+
import_promises43 = require("node:fs/promises");
|
|
109062
109972
|
import_node_path44 = __toESM(require("node:path"), 1);
|
|
109063
109973
|
init_dist4();
|
|
109064
109974
|
init_build();
|
|
@@ -109105,7 +110015,7 @@ function isBinaryFile(filepath, bytes2) {
|
|
|
109105
110015
|
}
|
|
109106
110016
|
async function readSample(filepath, size) {
|
|
109107
110017
|
if (size === 0) return new Uint8Array();
|
|
109108
|
-
const handle = await (0,
|
|
110018
|
+
const handle = await (0, import_promises44.open)(filepath, "r");
|
|
109109
110019
|
try {
|
|
109110
110020
|
const buffer = Buffer.alloc(Math.min(SAMPLE_BYTES, size));
|
|
109111
110021
|
const { bytesRead } = await handle.read(buffer, 0, buffer.length, 0);
|
|
@@ -109117,7 +110027,7 @@ async function readSample(filepath, size) {
|
|
|
109117
110027
|
async function missing(filepath) {
|
|
109118
110028
|
const dir = import_node_path45.default.dirname(filepath);
|
|
109119
110029
|
const base = import_node_path45.default.basename(filepath).toLowerCase();
|
|
109120
|
-
const suggestions = await (0,
|
|
110030
|
+
const suggestions = await (0, import_promises44.readdir)(dir).then(
|
|
109121
110031
|
(items) => items.filter((item) => item.toLowerCase().includes(base) || base.includes(item.toLowerCase())).map((item) => import_node_path45.default.join(dir, item)).slice(0, 3)
|
|
109122
110032
|
).catch(() => []);
|
|
109123
110033
|
if (suggestions.length > 0) {
|
|
@@ -109131,12 +110041,12 @@ ${suggestions.join("\n")}`
|
|
|
109131
110041
|
throw new ToolFailure(`File not found: ${filepath}`);
|
|
109132
110042
|
}
|
|
109133
110043
|
async function listDirectory(dirpath) {
|
|
109134
|
-
const entries2 = await (0,
|
|
110044
|
+
const entries2 = await (0, import_promises44.readdir)(dirpath, { withFileTypes: true });
|
|
109135
110045
|
const names2 = await Promise.all(
|
|
109136
110046
|
entries2.map(async (entry2) => {
|
|
109137
110047
|
if (entry2.isDirectory()) return `${entry2.name}/`;
|
|
109138
110048
|
if (!entry2.isSymbolicLink()) return entry2.name;
|
|
109139
|
-
const target = await (0,
|
|
110049
|
+
const target = await (0, import_promises44.stat)(import_node_path45.default.join(dirpath, entry2.name)).catch(() => void 0);
|
|
109140
110050
|
return target?.isDirectory() ? `${entry2.name}/` : entry2.name;
|
|
109141
110051
|
})
|
|
109142
110052
|
);
|
|
@@ -109225,7 +110135,7 @@ async function readImage(scope, filepath, title, mimeType, size) {
|
|
|
109225
110135
|
details: { title, preview: message2, truncated: false }
|
|
109226
110136
|
};
|
|
109227
110137
|
}
|
|
109228
|
-
const data = (await (0,
|
|
110138
|
+
const data = (await (0, import_promises44.readFile)(filepath)).toString("base64");
|
|
109229
110139
|
const message = "Image read successfully";
|
|
109230
110140
|
return {
|
|
109231
110141
|
output: [
|
|
@@ -109285,7 +110195,7 @@ async function readText2(filepath, title, args, context) {
|
|
|
109285
110195
|
async function execute4(scope, args) {
|
|
109286
110196
|
const filepath = resolvePath2(scope.cwd, args.filePath);
|
|
109287
110197
|
const title = relativeTitle(scope.cwd, filepath);
|
|
109288
|
-
const info = await (0,
|
|
110198
|
+
const info = await (0, import_promises44.stat)(filepath).catch(() => void 0);
|
|
109289
110199
|
if (!info) return missing(filepath);
|
|
109290
110200
|
if (info.isDirectory()) return readDirectory(filepath, title, args);
|
|
109291
110201
|
const sample = await readSample(filepath, info.size);
|
|
@@ -109315,12 +110225,12 @@ function createReadTool(cwd) {
|
|
|
109315
110225
|
execute: (args, api, context) => guard(context, () => execute4({ cwd, api, context }, args))
|
|
109316
110226
|
});
|
|
109317
110227
|
}
|
|
109318
|
-
var import_node_fs24,
|
|
110228
|
+
var import_node_fs24, import_promises44, import_node_path45, import_node_readline2, DESCRIPTION4, DEFAULT_READ_LIMIT, MAX_LINE_LENGTH, MAX_LINE_SUFFIX, MAX_BYTES2, MAX_BYTES_LABEL, SAMPLE_BYTES, MAX_IMAGE_BYTES2, BINARY_EXTENSIONS, parameters4;
|
|
109319
110229
|
var init_read2 = __esm({
|
|
109320
110230
|
"../alan-engine/src/tools/read.ts"() {
|
|
109321
110231
|
"use strict";
|
|
109322
110232
|
import_node_fs24 = require("node:fs");
|
|
109323
|
-
|
|
110233
|
+
import_promises44 = require("node:fs/promises");
|
|
109324
110234
|
import_node_path45 = __toESM(require("node:path"), 1);
|
|
109325
110235
|
import_node_readline2 = require("node:readline");
|
|
109326
110236
|
init_dist4();
|
|
@@ -109430,9 +110340,9 @@ async function searchWithRipgrep(binary, root, target, args, signal) {
|
|
|
109430
110340
|
return matches;
|
|
109431
110341
|
}
|
|
109432
110342
|
async function searchFile(file2, regex, matches) {
|
|
109433
|
-
const info = await (0,
|
|
110343
|
+
const info = await (0, import_promises45.stat)(file2).catch(() => void 0);
|
|
109434
110344
|
if (!info?.isFile() || info.size > MAX_FALLBACK_FILE_BYTES) return;
|
|
109435
|
-
const buffer = await (0,
|
|
110345
|
+
const buffer = await (0, import_promises45.readFile)(file2).catch(() => void 0);
|
|
109436
110346
|
if (!buffer || isBinaryFile(file2, buffer.subarray(0, 4096))) return;
|
|
109437
110347
|
const lines2 = buffer.toString("utf8").split("\n");
|
|
109438
110348
|
for (let index = 0; index < lines2.length && matches.length < LIMIT2; index++) {
|
|
@@ -109484,7 +110394,7 @@ function formatGrep(matches) {
|
|
|
109484
110394
|
async function execute5(scope, args) {
|
|
109485
110395
|
if (!args.pattern) throw new ToolFailure("pattern is required");
|
|
109486
110396
|
const requested = resolvePath2(scope.cwd, args.path ?? ".");
|
|
109487
|
-
const info = await (0,
|
|
110397
|
+
const info = await (0, import_promises45.stat)(requested).catch(() => void 0);
|
|
109488
110398
|
if (!info) throw new ToolFailure(`Path not found: ${requested}`);
|
|
109489
110399
|
const root = info.isDirectory() ? requested : import_node_path46.default.dirname(requested);
|
|
109490
110400
|
const single = info.isDirectory() ? void 0 : requested;
|
|
@@ -109508,11 +110418,11 @@ function createGrepTool(cwd) {
|
|
|
109508
110418
|
execute: (args, api, context) => guard(context, () => execute5({ cwd, api, context }, args))
|
|
109509
110419
|
});
|
|
109510
110420
|
}
|
|
109511
|
-
var
|
|
110421
|
+
var import_promises45, import_node_path46, DESCRIPTION5, LIMIT2, MAX_LINE_LENGTH2, MAX_FALLBACK_FILE_BYTES, parameters5;
|
|
109512
110422
|
var init_grep = __esm({
|
|
109513
110423
|
"../alan-engine/src/tools/grep.ts"() {
|
|
109514
110424
|
"use strict";
|
|
109515
|
-
|
|
110425
|
+
import_promises45 = require("node:fs/promises");
|
|
109516
110426
|
import_node_path46 = __toESM(require("node:path"), 1);
|
|
109517
110427
|
init_dist4();
|
|
109518
110428
|
init_build();
|
|
@@ -109591,7 +110501,7 @@ ${render(".", 0)}`;
|
|
|
109591
110501
|
}
|
|
109592
110502
|
async function execute6(scope, args) {
|
|
109593
110503
|
const search = resolvePath2(scope.cwd, args.path ?? ".");
|
|
109594
|
-
const info = await (0,
|
|
110504
|
+
const info = await (0, import_promises46.stat)(search).catch(() => void 0);
|
|
109595
110505
|
if (!info) throw new ToolFailure(`Directory not found: ${search}`);
|
|
109596
110506
|
if (!info.isDirectory()) throw new ToolFailure(`Path is not a directory: ${search}`);
|
|
109597
110507
|
const files = await collectFiles(search, args.ignore ?? [], scope.context.abortSignal);
|
|
@@ -109610,11 +110520,11 @@ function createListTool(cwd) {
|
|
|
109610
110520
|
execute: (args, api, context) => guard(context, () => execute6({ cwd, api, context }, args))
|
|
109611
110521
|
});
|
|
109612
110522
|
}
|
|
109613
|
-
var
|
|
110523
|
+
var import_promises46, import_node_path47, DESCRIPTION6, IGNORE_PATTERNS, LIMIT3, parameters6;
|
|
109614
110524
|
var init_list = __esm({
|
|
109615
110525
|
"../alan-engine/src/tools/list.ts"() {
|
|
109616
110526
|
"use strict";
|
|
109617
|
-
|
|
110527
|
+
import_promises46 = require("node:fs/promises");
|
|
109618
110528
|
import_node_path47 = __toESM(require("node:path"), 1);
|
|
109619
110529
|
init_dist4();
|
|
109620
110530
|
init_build();
|
|
@@ -109866,7 +110776,7 @@ async function execute7(skills, args, signal) {
|
|
|
109866
110776
|
}
|
|
109867
110777
|
const dir = info.packageDirectory;
|
|
109868
110778
|
const location = import_node_path48.default.join(dir, "SKILL.md");
|
|
109869
|
-
const markdown = await (0,
|
|
110779
|
+
const markdown = await (0, import_promises47.readFile)(location, "utf8").catch((error62) => {
|
|
109870
110780
|
throw new ToolFailure(
|
|
109871
110781
|
`Skill "${info.name}" has no readable SKILL.md at ${location}: ${String(error62)}`
|
|
109872
110782
|
);
|
|
@@ -109899,11 +110809,11 @@ function createSkillTool(skills) {
|
|
|
109899
110809
|
execute: (args, _api, context) => guard(context, () => execute7(skills, args, context.abortSignal))
|
|
109900
110810
|
});
|
|
109901
110811
|
}
|
|
109902
|
-
var
|
|
110812
|
+
var import_promises47, import_node_path48, DESCRIPTION8, MAX_LISTED_FILES, MAX_SEARCH_RESULTS, parameters8;
|
|
109903
110813
|
var init_skill = __esm({
|
|
109904
110814
|
"../alan-engine/src/tools/skill.ts"() {
|
|
109905
110815
|
"use strict";
|
|
109906
|
-
|
|
110816
|
+
import_promises47 = require("node:fs/promises");
|
|
109907
110817
|
import_node_path48 = __toESM(require("node:path"), 1);
|
|
109908
110818
|
init_dist4();
|
|
109909
110819
|
init_build();
|
|
@@ -109943,9 +110853,9 @@ function todoJson(todos) {
|
|
|
109943
110853
|
}
|
|
109944
110854
|
function todoResult(todos) {
|
|
109945
110855
|
const json2 = todoJson(todos);
|
|
109946
|
-
const
|
|
110856
|
+
const open7 = todos.filter((todo) => todo.status !== "completed" && todo.status !== "cancelled");
|
|
109947
110857
|
return textResult(JSON.stringify(json2, null, 2), {
|
|
109948
|
-
title: `${
|
|
110858
|
+
title: `${open7.length} todos`,
|
|
109949
110859
|
todos: json2
|
|
109950
110860
|
});
|
|
109951
110861
|
}
|
|
@@ -110274,9 +111184,9 @@ function readRefusal(text3) {
|
|
|
110274
111184
|
...requestId === void 0 ? {} : { requestId }
|
|
110275
111185
|
};
|
|
110276
111186
|
}
|
|
110277
|
-
function refusalAction(
|
|
110278
|
-
const reset =
|
|
110279
|
-
switch (
|
|
111187
|
+
function refusalAction(refusal3) {
|
|
111188
|
+
const reset = refusal3.resetsAt?.slice(0, 10);
|
|
111189
|
+
switch (refusal3.error) {
|
|
110280
111190
|
case "quota_exceeded":
|
|
110281
111191
|
return `Web search allowance exhausted${reset ? `; it resets ${reset}` : ""}. Do not retry \u2014 continue without search or tell the user.`;
|
|
110282
111192
|
case "billing_review_required":
|
|
@@ -110284,26 +111194,26 @@ function refusalAction(refusal2) {
|
|
|
110284
111194
|
case "search_daily_limit":
|
|
110285
111195
|
return "Daily web search limit reached; it resets at 00:00 UTC. Continue without search rather than retrying.";
|
|
110286
111196
|
case "search_rate_limited":
|
|
110287
|
-
return `${
|
|
111197
|
+
return `${refusal3.message} \u2014 wait a few seconds, then retry the search.`;
|
|
110288
111198
|
case "too_many_in_flight":
|
|
110289
|
-
return `${
|
|
111199
|
+
return `${refusal3.message} \u2014 wait a moment, then retry.`;
|
|
110290
111200
|
case "not_a_member":
|
|
110291
111201
|
case "seat_required":
|
|
110292
111202
|
case "usage_plan_unassigned":
|
|
110293
111203
|
case "allowance_missing":
|
|
110294
111204
|
case "entitlement_invalid":
|
|
110295
111205
|
case "entitlement_unknown":
|
|
110296
|
-
return `Web search is not available for this account (${
|
|
111206
|
+
return `Web search is not available for this account (${refusal3.message}). Do not retry \u2014 report it to the user.`;
|
|
110297
111207
|
case "unsupported_billable_feature":
|
|
110298
111208
|
case "invalid_request":
|
|
110299
|
-
return `Web search rejected the request: ${
|
|
111209
|
+
return `Web search rejected the request: ${refusal3.message}`;
|
|
110300
111210
|
default:
|
|
110301
|
-
return
|
|
111211
|
+
return refusal3.retryable ? `Web search is temporarily unavailable (${refusal3.message}). Retry shortly.` : `Web search failed: ${refusal3.message}`;
|
|
110302
111212
|
}
|
|
110303
111213
|
}
|
|
110304
|
-
function describeRefusal(
|
|
110305
|
-
const action = refusalAction(
|
|
110306
|
-
return
|
|
111214
|
+
function describeRefusal(refusal3) {
|
|
111215
|
+
const action = refusalAction(refusal3);
|
|
111216
|
+
return refusal3.requestId ? `${action} [ref: ${refusal3.requestId}]` : action;
|
|
110307
111217
|
}
|
|
110308
111218
|
function truncate4(text3, max) {
|
|
110309
111219
|
const trimmed4 = text3.trim();
|
|
@@ -110375,12 +111285,12 @@ function createAlanWebSearch(source) {
|
|
|
110375
111285
|
}
|
|
110376
111286
|
return formatHits(query, hits);
|
|
110377
111287
|
}
|
|
110378
|
-
const
|
|
110379
|
-
const waitMs = (
|
|
110380
|
-
const retry =
|
|
111288
|
+
const refusal3 = readRefusal(text3);
|
|
111289
|
+
const waitMs = (refusal3?.retryAfterSeconds ?? 0) * 1e3;
|
|
111290
|
+
const retry = refusal3?.retryable === true && waitMs > 0 && waitMs <= MAX_AUTO_RETRY_WAIT_MS && attempt < MAX_AUTO_RETRIES2;
|
|
110381
111291
|
if (!retry) {
|
|
110382
111292
|
throw new ToolFailure(
|
|
110383
|
-
|
|
111293
|
+
refusal3 ? describeRefusal(refusal3) : `Alan websearch failed (${response.status}): ${truncate4(text3 || response.statusText, 500)}`
|
|
110384
111294
|
);
|
|
110385
111295
|
}
|
|
110386
111296
|
await sleep2(Math.round(waitMs * (0.6 + Math.random() * 0.8)), signal);
|
|
@@ -110426,14 +111336,14 @@ async function execute9(scope, args) {
|
|
|
110426
111336
|
const filepath = resolvePath2(scope.cwd, args.filePath);
|
|
110427
111337
|
const title = relativeTitle(scope.cwd, filepath);
|
|
110428
111338
|
return withFileLock(filepath, async () => {
|
|
110429
|
-
const info = await (0,
|
|
111339
|
+
const info = await (0, import_promises48.stat)(filepath).catch(() => void 0);
|
|
110430
111340
|
if (info?.isDirectory()) throw new ToolFailure(`Path is a directory, not a file: ${filepath}`);
|
|
110431
111341
|
const exists4 = info !== void 0;
|
|
110432
111342
|
if (info !== void 0) await assertUnchangedSinceRead(scope, filepath, info);
|
|
110433
|
-
const before = exists4 ? await (0,
|
|
111343
|
+
const before = exists4 ? await (0, import_promises48.readFile)(filepath, "utf8") : "";
|
|
110434
111344
|
scope.context.abortSignal?.throwIfAborted();
|
|
110435
|
-
await (0,
|
|
110436
|
-
await (0,
|
|
111345
|
+
await (0, import_promises48.mkdir)(import_node_path49.default.dirname(filepath), { recursive: true });
|
|
111346
|
+
await (0, import_promises48.writeFile)(filepath, args.content, "utf8");
|
|
110437
111347
|
await recordFileStamp(scope, filepath);
|
|
110438
111348
|
const stats = diffStats(before, args.content);
|
|
110439
111349
|
return textResult(exists4 ? "Wrote file successfully." : "Created file successfully.", {
|
|
@@ -110454,11 +111364,11 @@ function createWriteTool(cwd) {
|
|
|
110454
111364
|
execute: (args, api, context) => guard(context, () => execute9({ cwd, api, context }, args))
|
|
110455
111365
|
});
|
|
110456
111366
|
}
|
|
110457
|
-
var
|
|
111367
|
+
var import_promises48, import_node_path49, DESCRIPTION11, parameters11;
|
|
110458
111368
|
var init_write = __esm({
|
|
110459
111369
|
"../alan-engine/src/tools/write.ts"() {
|
|
110460
111370
|
"use strict";
|
|
110461
|
-
|
|
111371
|
+
import_promises48 = require("node:fs/promises");
|
|
110462
111372
|
import_node_path49 = __toESM(require("node:path"), 1);
|
|
110463
111373
|
init_dist4();
|
|
110464
111374
|
init_build();
|
|
@@ -110743,7 +111653,7 @@ async function openEngineSession(options) {
|
|
|
110743
111653
|
if (options.maxTurns !== void 0 && (!Number.isInteger(options.maxTurns) || options.maxTurns < 1))
|
|
110744
111654
|
throw new RangeError("maxTurns must be a positive integer");
|
|
110745
111655
|
const paths = sessionPaths(options.dir, options.sessionId);
|
|
110746
|
-
await (0,
|
|
111656
|
+
await (0, import_promises49.mkdir)(paths.root, { recursive: true });
|
|
110747
111657
|
const lock = await acquireSessionLock(paths.lock);
|
|
110748
111658
|
let mcp;
|
|
110749
111659
|
try {
|
|
@@ -110787,11 +111697,11 @@ async function openEngineSession(options) {
|
|
|
110787
111697
|
throw error62;
|
|
110788
111698
|
}
|
|
110789
111699
|
}
|
|
110790
|
-
var
|
|
111700
|
+
var import_promises49, import_node_path51, ctx, ENTRY_PAGE, SESSION_EXTENSION_NAME, USER_SHELL_ENTRY_KIND, DurableEngineSession;
|
|
110791
111701
|
var init_session6 = __esm({
|
|
110792
111702
|
"../alan-engine/src/engine/session.ts"() {
|
|
110793
111703
|
"use strict";
|
|
110794
|
-
|
|
111704
|
+
import_promises49 = require("node:fs/promises");
|
|
110795
111705
|
import_node_path51 = require("node:path");
|
|
110796
111706
|
init_context();
|
|
110797
111707
|
init_dist4();
|
|
@@ -112363,7 +113273,7 @@ function alanMcpServer(managedMcp, conversationId) {
|
|
|
112363
113273
|
}
|
|
112364
113274
|
async function exists2(path18) {
|
|
112365
113275
|
try {
|
|
112366
|
-
await (0,
|
|
113276
|
+
await (0, import_promises50.access)(path18);
|
|
112367
113277
|
return true;
|
|
112368
113278
|
} catch {
|
|
112369
113279
|
return false;
|
|
@@ -112378,7 +113288,7 @@ function createAlanPiHolderDriver(options) {
|
|
|
112378
113288
|
const thinking = { current: null };
|
|
112379
113289
|
const sessionSkills = async () => skills.current ?? await options.skillIndex?.() ?? [];
|
|
112380
113290
|
const managedAccess = () => options.managedMcp === void 0 ? void 0 : { apiOrigin: new URL(options.managedMcp.url).origin };
|
|
112381
|
-
const
|
|
113291
|
+
const open7 = async (planned) => {
|
|
112382
113292
|
if (planned.access === void 0) throw refuseWithoutCredential();
|
|
112383
113293
|
const storage = sessionPaths(options.storageDir, planned.conversationId);
|
|
112384
113294
|
const stored = await exists2(storage.database);
|
|
@@ -112518,7 +113428,7 @@ function createAlanPiHolderDriver(options) {
|
|
|
112518
113428
|
},
|
|
112519
113429
|
canResume: (planned, resumeId) => isAlanPiSessionOf(resumeId, planned.spec.conversationId),
|
|
112520
113430
|
planPreparation: (preparation, resumeId) => planPreparation(preparation, resumeId),
|
|
112521
|
-
open:
|
|
113431
|
+
open: open7,
|
|
112522
113432
|
turnInput: async (spec, inputs, contextPrefix) => {
|
|
112523
113433
|
const prefix2 = [agentPromptLiveState(spec), contextPrefix].filter(Boolean).join("\n\n");
|
|
112524
113434
|
return alanPiTurnInput(spec, inputs, prefix2 || void 0);
|
|
@@ -112543,11 +113453,11 @@ function createAlanPiHolderDriver(options) {
|
|
|
112543
113453
|
}
|
|
112544
113454
|
};
|
|
112545
113455
|
}
|
|
112546
|
-
var
|
|
113456
|
+
var import_promises50, SAFE_COMMANDS, NO_CREDENTIAL;
|
|
112547
113457
|
var init_alan_pi = __esm({
|
|
112548
113458
|
"src/holder/drivers/alan-pi.ts"() {
|
|
112549
113459
|
"use strict";
|
|
112550
|
-
|
|
113460
|
+
import_promises50 = require("node:fs/promises");
|
|
112551
113461
|
init_src();
|
|
112552
113462
|
init_classify2();
|
|
112553
113463
|
init_prompt();
|
|
@@ -112648,7 +113558,7 @@ function createAlanCodeOpenCodeDriver(options) {
|
|
|
112648
113558
|
const globalConfigDirectory = openCodeGlobalConfigDirectory(env, home);
|
|
112649
113559
|
const plain = alanCodeOpenCodePlain(env);
|
|
112650
113560
|
options.log.info("alan_code.engine", { command: engine.command, source: engine.source });
|
|
112651
|
-
const
|
|
113561
|
+
const open7 = async (planned) => {
|
|
112652
113562
|
if (planned.profile === void 0) throw refuseWithoutCredential();
|
|
112653
113563
|
const { opencode } = planned;
|
|
112654
113564
|
const profile = await prepareAlanCodeProfile({
|
|
@@ -112709,7 +113619,7 @@ function createAlanCodeOpenCodeDriver(options) {
|
|
|
112709
113619
|
};
|
|
112710
113620
|
},
|
|
112711
113621
|
canResume: () => true,
|
|
112712
|
-
open:
|
|
113622
|
+
open: open7,
|
|
112713
113623
|
turnInput: async (spec, inputs, contextPrefix) => openCodeTurnInput(spec, {
|
|
112714
113624
|
attachments: inputs.attachments,
|
|
112715
113625
|
skills: inputs.skills,
|
|
@@ -113098,6 +114008,7 @@ function droidToolCall(toolUse) {
|
|
|
113098
114008
|
const rawInput = isSubagent ? subagentInput(input2) : input2;
|
|
113099
114009
|
const resumeTaskId = isSubagent ? trimmed2(rawInput.task_id) ?? trimmed2(rawInput.taskId) ?? trimmed2(rawInput.resume) : void 0;
|
|
113100
114010
|
const title = presentName(rawName);
|
|
114011
|
+
const plan2 = normalizedName(rawName) === "todowrite" ? todoPlanUpdate(toolCallId, todoItems(input2.todos)) : alanPlanUpdate(rawName, toolCallId, input2);
|
|
113101
114012
|
return [
|
|
113102
114013
|
{
|
|
113103
114014
|
sessionUpdate: "tool_call_update",
|
|
@@ -113111,7 +114022,8 @@ function droidToolCall(toolUse) {
|
|
|
113111
114022
|
...isSubagent ? { [SUBAGENT_LAUNCHER_META]: true } : {},
|
|
113112
114023
|
...resumeTaskId ? { [SUBAGENT_TASK_ID_META]: resumeTaskId } : {}
|
|
113113
114024
|
}
|
|
113114
|
-
}
|
|
114025
|
+
},
|
|
114026
|
+
...plan2 ? [plan2] : []
|
|
113115
114027
|
];
|
|
113116
114028
|
}
|
|
113117
114029
|
function droidResultText(result) {
|
|
@@ -113793,17 +114705,17 @@ async function droidTurnInput(run3, context) {
|
|
|
113793
114705
|
const encoded = await Promise.all(
|
|
113794
114706
|
images.map(async (image) => ({
|
|
113795
114707
|
mimeType: image.mimeType,
|
|
113796
|
-
data: (await (0,
|
|
114708
|
+
data: (await (0, import_promises51.readFile)(image.path)).toString("base64")
|
|
113797
114709
|
}))
|
|
113798
114710
|
);
|
|
113799
114711
|
return { turnId: run3.runId, text: text3, ...encoded.length ? { images: encoded } : {} };
|
|
113800
114712
|
}
|
|
113801
|
-
var import_node_crypto37,
|
|
114713
|
+
var import_node_crypto37, import_promises51;
|
|
113802
114714
|
var init_run5 = __esm({
|
|
113803
114715
|
"../agent-core/src/providers/droid/run.ts"() {
|
|
113804
114716
|
"use strict";
|
|
113805
114717
|
import_node_crypto37 = require("node:crypto");
|
|
113806
|
-
|
|
114718
|
+
import_promises51 = require("node:fs/promises");
|
|
113807
114719
|
init_agent2();
|
|
113808
114720
|
init_mcp2();
|
|
113809
114721
|
init_prompt();
|
|
@@ -113937,7 +114849,7 @@ function settingsPath(env) {
|
|
|
113937
114849
|
async function readSettings(path18) {
|
|
113938
114850
|
let raw;
|
|
113939
114851
|
try {
|
|
113940
|
-
raw = (await (0,
|
|
114852
|
+
raw = (await (0, import_promises52.readFile)(path18, "utf8")).trim();
|
|
113941
114853
|
} catch {
|
|
113942
114854
|
return {};
|
|
113943
114855
|
}
|
|
@@ -113955,15 +114867,15 @@ async function selectAntigravityApiKeyMode(env) {
|
|
|
113955
114867
|
const settings3 = await readSettings(path18);
|
|
113956
114868
|
if (settings3 === "malformed") return "malformed";
|
|
113957
114869
|
if (settings3.modelProvider === "gemini") return "already_selected";
|
|
113958
|
-
await (0,
|
|
113959
|
-
await (0,
|
|
114870
|
+
await (0, import_promises52.mkdir)((0, import_node_path54.dirname)(path18), { recursive: true });
|
|
114871
|
+
await (0, import_promises52.writeFile)(path18, JSON.stringify({ ...settings3, modelProvider: "gemini" }), { mode: 384 });
|
|
113960
114872
|
return "selected";
|
|
113961
114873
|
}
|
|
113962
|
-
var
|
|
114874
|
+
var import_promises52, import_node_path54;
|
|
113963
114875
|
var init_api_key_mode = __esm({
|
|
113964
114876
|
"../agent-core/src/providers/antigravity/api-key-mode.ts"() {
|
|
113965
114877
|
"use strict";
|
|
113966
|
-
|
|
114878
|
+
import_promises52 = require("node:fs/promises");
|
|
113967
114879
|
import_node_path54 = require("node:path");
|
|
113968
114880
|
init_type_guards();
|
|
113969
114881
|
}
|
|
@@ -115206,7 +116118,7 @@ function parseConfig(raw) {
|
|
|
115206
116118
|
}
|
|
115207
116119
|
async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
115208
116120
|
const path18 = (0, import_node_path57.join)(cwd, ".mcp.json");
|
|
115209
|
-
const original = await (0,
|
|
116121
|
+
const original = await (0, import_promises53.readFile)(path18, "utf8").catch(() => null);
|
|
115210
116122
|
const config2 = parseConfig(original);
|
|
115211
116123
|
const next = {
|
|
115212
116124
|
...config2,
|
|
@@ -115223,19 +116135,19 @@ async function writeCommandCodeProjectMcp(cwd, mcp) {
|
|
|
115223
116135
|
}
|
|
115224
116136
|
}
|
|
115225
116137
|
};
|
|
115226
|
-
await (0,
|
|
115227
|
-
await (0,
|
|
116138
|
+
await (0, import_promises53.mkdir)(cwd, { recursive: true });
|
|
116139
|
+
await (0, import_promises53.writeFile)(path18, `${JSON.stringify(next, null, 2)}
|
|
115228
116140
|
`);
|
|
115229
116141
|
return async () => {
|
|
115230
|
-
if (original === null) await (0,
|
|
115231
|
-
else await (0,
|
|
116142
|
+
if (original === null) await (0, import_promises53.rm)(path18, { force: true });
|
|
116143
|
+
else await (0, import_promises53.writeFile)(path18, original);
|
|
115232
116144
|
};
|
|
115233
116145
|
}
|
|
115234
|
-
var
|
|
116146
|
+
var import_promises53, import_node_path57;
|
|
115235
116147
|
var init_project_mcp = __esm({
|
|
115236
116148
|
"../agent-core/src/providers/command-code/project-mcp.ts"() {
|
|
115237
116149
|
"use strict";
|
|
115238
|
-
|
|
116150
|
+
import_promises53 = require("node:fs/promises");
|
|
115239
116151
|
import_node_path57 = require("node:path");
|
|
115240
116152
|
init_agent2();
|
|
115241
116153
|
init_runtime_v2();
|
|
@@ -115279,20 +116191,25 @@ function eventKey2(event) {
|
|
|
115279
116191
|
return subtype ? `${base}/${subtype}` : base;
|
|
115280
116192
|
}
|
|
115281
116193
|
function toolCallStart(toolCallId, name, input2) {
|
|
115282
|
-
|
|
115283
|
-
|
|
115284
|
-
|
|
115285
|
-
|
|
115286
|
-
|
|
115287
|
-
|
|
115288
|
-
|
|
115289
|
-
|
|
115290
|
-
|
|
116194
|
+
const plan2 = normalizeToolName2(name) === "todowrite" ? todoPlanUpdate(toolCallId, todoItems(input2.todos)) : alanPlanUpdate(name, toolCallId, input2);
|
|
116195
|
+
return [
|
|
116196
|
+
{
|
|
116197
|
+
sessionUpdate: "tool_call_update",
|
|
116198
|
+
toolCallId,
|
|
116199
|
+
name,
|
|
116200
|
+
title: name,
|
|
116201
|
+
kind: toolKindFor(name),
|
|
116202
|
+
status: "in_progress",
|
|
116203
|
+
rawInput: input2
|
|
116204
|
+
},
|
|
116205
|
+
...plan2 ? [plan2] : []
|
|
116206
|
+
];
|
|
115291
116207
|
}
|
|
115292
116208
|
var COMMAND_CODE_GRAMMAR_NAME, SILENT3, CommandCodeGrammar;
|
|
115293
116209
|
var init_grammar3 = __esm({
|
|
115294
116210
|
"../agent-core/src/providers/command-code/grammar.ts"() {
|
|
115295
116211
|
"use strict";
|
|
116212
|
+
init_constants();
|
|
115296
116213
|
init_acp2();
|
|
115297
116214
|
init_kernel2();
|
|
115298
116215
|
COMMAND_CODE_GRAMMAR_NAME = "command_code_cli";
|
|
@@ -115352,13 +116269,11 @@ var init_grammar3 = __esm({
|
|
|
115352
116269
|
return this.#messageUpdate(event);
|
|
115353
116270
|
case "tool_running":
|
|
115354
116271
|
this.#answerId = void 0;
|
|
115355
|
-
return
|
|
115356
|
-
|
|
115357
|
-
|
|
115358
|
-
|
|
115359
|
-
|
|
115360
|
-
)
|
|
115361
|
-
];
|
|
116272
|
+
return toolCallStart(
|
|
116273
|
+
this.#toolId(commandCodeString(event.toolCallId)),
|
|
116274
|
+
commandCodeString(event.toolName) || "Tool",
|
|
116275
|
+
asRecord(event.input) ?? {}
|
|
116276
|
+
);
|
|
115362
116277
|
case "tool_completed":
|
|
115363
116278
|
return this.#toolCompleted(event);
|
|
115364
116279
|
default:
|
|
@@ -115399,13 +116314,11 @@ var init_grammar3 = __esm({
|
|
|
115399
116314
|
return parts3.flatMap((part) => {
|
|
115400
116315
|
const record3 = asRecord(part);
|
|
115401
116316
|
if (!record3 || record3.type !== "tool_use") return [];
|
|
115402
|
-
return
|
|
115403
|
-
|
|
115404
|
-
|
|
115405
|
-
|
|
115406
|
-
|
|
115407
|
-
)
|
|
115408
|
-
];
|
|
116317
|
+
return toolCallStart(
|
|
116318
|
+
this.#toolId(commandCodeString(record3.id)),
|
|
116319
|
+
commandCodeString(record3.name) || "Tool",
|
|
116320
|
+
asRecord(record3.input) ?? {}
|
|
116321
|
+
);
|
|
115409
116322
|
});
|
|
115410
116323
|
}
|
|
115411
116324
|
#toolCompleted(event) {
|
|
@@ -115461,7 +116374,7 @@ function processIsAlive(pid) {
|
|
|
115461
116374
|
return error62.code === "EPERM";
|
|
115462
116375
|
}
|
|
115463
116376
|
}
|
|
115464
|
-
function
|
|
116377
|
+
function isRunning4(meta3) {
|
|
115465
116378
|
return meta3.status === "running" || meta3.status === "stopping";
|
|
115466
116379
|
}
|
|
115467
116380
|
var SHELL_TOOL, STOP_TOOLS, REPORTED_STATUS, SHELL_STATUS, SWEEP_INTERVAL_MS, CommandCodeBackgroundTasks;
|
|
@@ -115524,7 +116437,7 @@ var init_background_tasks2 = __esm({
|
|
|
115524
116437
|
this.#sweptAt = now;
|
|
115525
116438
|
const updates = [];
|
|
115526
116439
|
for (const [launcher, task] of this.#tasks) {
|
|
115527
|
-
if (task.pid === void 0 || !
|
|
116440
|
+
if (task.pid === void 0 || !isRunning4(task.meta) || this.#isAlive(task.pid)) continue;
|
|
115528
116441
|
updates.push(...this.#settle(launcher, "stopped"));
|
|
115529
116442
|
}
|
|
115530
116443
|
return updates;
|
|
@@ -115536,7 +116449,7 @@ var init_background_tasks2 = __esm({
|
|
|
115536
116449
|
afterExit() {
|
|
115537
116450
|
const updates = [];
|
|
115538
116451
|
for (const [launcher, task] of this.#tasks) {
|
|
115539
|
-
if (!
|
|
116452
|
+
if (!isRunning4(task.meta)) continue;
|
|
115540
116453
|
const pid = task.pid;
|
|
115541
116454
|
if (task.meta.kind === "shell" && pid !== void 0 && this.#isAlive(pid)) continue;
|
|
115542
116455
|
updates.push(...this.#settle(launcher, "stopped"));
|
|
@@ -115646,7 +116559,7 @@ var init_background_tasks2 = __esm({
|
|
|
115646
116559
|
/** Moves a tracked task to a terminal status, if it is still running. */
|
|
115647
116560
|
#settle(launcher, status) {
|
|
115648
116561
|
const task = this.#tasks.get(launcher);
|
|
115649
|
-
if (!task || !
|
|
116562
|
+
if (!task || !isRunning4(task.meta)) return [];
|
|
115650
116563
|
task.meta = { ...task.meta, status };
|
|
115651
116564
|
return [this.#update(launcher, task.meta)];
|
|
115652
116565
|
}
|
|
@@ -117132,18 +118045,18 @@ function createConversationMcpAuthorization(options) {
|
|
|
117132
118045
|
}
|
|
117133
118046
|
|
|
117134
118047
|
// src/holder/mcp-helper-access.ts
|
|
117135
|
-
var
|
|
118048
|
+
var import_promises54 = require("node:fs/promises");
|
|
117136
118049
|
init_kernel();
|
|
117137
118050
|
function createHelperMcpAccess(options) {
|
|
117138
118051
|
return {
|
|
117139
118052
|
[Symbol.asyncDispose]: async () => {
|
|
117140
|
-
await (0,
|
|
118053
|
+
await (0, import_promises54.rm)(options.credentialPath, { force: true });
|
|
117141
118054
|
},
|
|
117142
118055
|
url: options.managedMcp.url,
|
|
117143
118056
|
authorization: async (signal) => {
|
|
117144
118057
|
const authorization = await options.managedMcp.authorization(signal);
|
|
117145
118058
|
if (authorization === void 0 || signal.aborted) {
|
|
117146
|
-
await (0,
|
|
118059
|
+
await (0, import_promises54.rm)(options.credentialPath, { force: true });
|
|
117147
118060
|
return void 0;
|
|
117148
118061
|
}
|
|
117149
118062
|
const credential = {
|
|
@@ -117159,7 +118072,7 @@ function createHelperMcpAccess(options) {
|
|
|
117159
118072
|
|
|
117160
118073
|
// src/holder/native-turn-bindings.ts
|
|
117161
118074
|
var import_node_crypto40 = require("node:crypto");
|
|
117162
|
-
var
|
|
118075
|
+
var import_promises56 = require("node:fs/promises");
|
|
117163
118076
|
var import_node_path60 = require("node:path");
|
|
117164
118077
|
init_runtime_v2();
|
|
117165
118078
|
init_zod();
|
|
@@ -117168,7 +118081,7 @@ init_platform();
|
|
|
117168
118081
|
init_alan_pi_identity();
|
|
117169
118082
|
|
|
117170
118083
|
// src/holder/prepared-session-state.ts
|
|
117171
|
-
var
|
|
118084
|
+
var import_promises55 = require("node:fs/promises");
|
|
117172
118085
|
var import_node_path59 = require("node:path");
|
|
117173
118086
|
init_runtime_v2();
|
|
117174
118087
|
init_zod();
|
|
@@ -117206,8 +118119,8 @@ async function writePreparedIdentity(directory, binding, providerSessionId) {
|
|
|
117206
118119
|
binding,
|
|
117207
118120
|
providerSessionId
|
|
117208
118121
|
});
|
|
117209
|
-
await (0,
|
|
117210
|
-
await (0,
|
|
118122
|
+
await (0, import_promises55.mkdir)(directory, { recursive: true, mode: 448 });
|
|
118123
|
+
await (0, import_promises55.chmod)(directory, 448);
|
|
117211
118124
|
await writeJsonFileAtomic((0, import_node_path59.join)(directory, "engine-session.json"), value2);
|
|
117212
118125
|
await createMetadataDurability().sync(directory);
|
|
117213
118126
|
}
|
|
@@ -117446,15 +118359,15 @@ async function openNativeTurnBindings(options) {
|
|
|
117446
118359
|
const { directory, machineId, conversationId } = options;
|
|
117447
118360
|
const runDirectory2 = (0, import_node_path60.join)(directory, "native-turn-bindings");
|
|
117448
118361
|
const orderPath = (0, import_node_path60.join)(directory, "native-message-order.json");
|
|
117449
|
-
await (0,
|
|
117450
|
-
await (0,
|
|
117451
|
-
await (0,
|
|
118362
|
+
await (0, import_promises56.mkdir)(runDirectory2, { recursive: true, mode: 448 });
|
|
118363
|
+
await (0, import_promises56.chmod)(directory, 448);
|
|
118364
|
+
await (0, import_promises56.chmod)(runDirectory2, 448);
|
|
117452
118365
|
await createMetadataDurability().sync(directory);
|
|
117453
118366
|
const stored = await readJsonFile(orderPath, projectionSchema);
|
|
117454
118367
|
if (stored.kind === "invalid") throw unavailable2();
|
|
117455
118368
|
let projection = stored.kind === "ok" ? stored.value : void 0;
|
|
117456
118369
|
const unresolved = /* @__PURE__ */ new Set();
|
|
117457
|
-
const names2 = await (0,
|
|
118370
|
+
const names2 = await (0, import_promises56.readdir)(runDirectory2);
|
|
117458
118371
|
for (const name of names2.filter((entry2) => entry2.endsWith(".json"))) {
|
|
117459
118372
|
const item = await readJsonFile((0, import_node_path60.join)(runDirectory2, name), bindingSchema);
|
|
117460
118373
|
if (item.kind !== "ok" || item.value.machineId !== machineId || item.value.conversationId !== conversationId || name !== `${item.value.runId}.json`)
|
|
@@ -117599,7 +118512,7 @@ async function openNativeTurnBindings(options) {
|
|
|
117599
118512
|
}
|
|
117600
118513
|
|
|
117601
118514
|
// src/holder/run-inputs.ts
|
|
117602
|
-
var
|
|
118515
|
+
var import_promises57 = require("node:fs/promises");
|
|
117603
118516
|
var import_node_path61 = require("node:path");
|
|
117604
118517
|
init_src();
|
|
117605
118518
|
var NO_RUN_INPUTS = {
|
|
@@ -117637,7 +118550,7 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
|
|
|
117637
118550
|
await commitAttribution?.setCoAuthor(spec.gitCoAuthor);
|
|
117638
118551
|
const dir = (0, import_node_path61.join)(tmpDir, "runs", spec.runId);
|
|
117639
118552
|
const cleanup = async () => {
|
|
117640
|
-
await (0,
|
|
118553
|
+
await (0, import_promises57.rm)(dir, { recursive: true, force: true });
|
|
117641
118554
|
};
|
|
117642
118555
|
try {
|
|
117643
118556
|
const credential = await source.fetchProviderCredential(spec.runId, signal);
|
|
@@ -117645,8 +118558,8 @@ async function prepareRunInputs(spec, { source, tmpDir, signal, skills = [], com
|
|
|
117645
118558
|
for (const [index, attachment] of (spec.attachments ?? []).entries()) {
|
|
117646
118559
|
const bytes2 = await source.downloadAttachment(spec.runId, attachment.id, signal);
|
|
117647
118560
|
const path18 = attachmentPath(spec, attachment, index, dir);
|
|
117648
|
-
await (0,
|
|
117649
|
-
await (0,
|
|
118561
|
+
await (0, import_promises57.mkdir)((0, import_node_path61.dirname)(path18), { recursive: true, mode: 448 });
|
|
118562
|
+
await (0, import_promises57.writeFile)(path18, bytes2, { mode: 384 });
|
|
117650
118563
|
const imageMimeType = attachment.kind === "image" ? detectImageMimeType(Buffer.from(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength)) : null;
|
|
117651
118564
|
attachments.push({
|
|
117652
118565
|
id: attachment.id,
|
|
@@ -117685,7 +118598,7 @@ init_platform();
|
|
|
117685
118598
|
|
|
117686
118599
|
// src/holder/admission.ts
|
|
117687
118600
|
var import_node_fs26 = require("node:fs");
|
|
117688
|
-
var
|
|
118601
|
+
var import_promises61 = require("node:fs/promises");
|
|
117689
118602
|
var import_node_os9 = require("node:os");
|
|
117690
118603
|
var import_node_path67 = require("node:path");
|
|
117691
118604
|
init_constants();
|
|
@@ -117702,12 +118615,12 @@ init_capabilities3();
|
|
|
117702
118615
|
init_kernel();
|
|
117703
118616
|
|
|
117704
118617
|
// src/holder/agent-context.ts
|
|
117705
|
-
var
|
|
118618
|
+
var import_promises58 = require("node:fs/promises");
|
|
117706
118619
|
var import_node_path63 = require("node:path");
|
|
117707
118620
|
init_prompt();
|
|
117708
118621
|
init_kernel();
|
|
117709
118622
|
async function readText3(path18) {
|
|
117710
|
-
return (0,
|
|
118623
|
+
return (0, import_promises58.readFile)(path18, "utf8").then(
|
|
117711
118624
|
(text3) => text3.trim(),
|
|
117712
118625
|
() => null
|
|
117713
118626
|
);
|
|
@@ -117754,12 +118667,12 @@ init_capabilities3();
|
|
|
117754
118667
|
|
|
117755
118668
|
// src/holder/claim-once.ts
|
|
117756
118669
|
var import_node_crypto41 = require("node:crypto");
|
|
117757
|
-
var
|
|
118670
|
+
var import_promises59 = require("node:fs/promises");
|
|
117758
118671
|
var import_node_path64 = require("node:path");
|
|
117759
118672
|
async function claimOnce(dir, name) {
|
|
117760
118673
|
try {
|
|
117761
|
-
await (0,
|
|
117762
|
-
await (await (0,
|
|
118674
|
+
await (0, import_promises59.mkdir)(dir, { recursive: true, mode: 448 });
|
|
118675
|
+
await (await (0, import_promises59.open)((0, import_node_path64.join)(dir, name), "wx")).close();
|
|
117763
118676
|
return true;
|
|
117764
118677
|
} catch {
|
|
117765
118678
|
return false;
|
|
@@ -117770,7 +118683,7 @@ function claimFirstLease(freshnessDir, path18) {
|
|
|
117770
118683
|
}
|
|
117771
118684
|
|
|
117772
118685
|
// src/holder/requested-checkout.ts
|
|
117773
|
-
var
|
|
118686
|
+
var import_promises60 = require("node:fs/promises");
|
|
117774
118687
|
var import_node_path65 = require("node:path");
|
|
117775
118688
|
init_capabilities3();
|
|
117776
118689
|
var REMOTE2 = "origin";
|
|
@@ -117794,7 +118707,7 @@ function notSwitched(checkout, current, reason) {
|
|
|
117794
118707
|
}
|
|
117795
118708
|
async function clone2(checkout, deps, signal) {
|
|
117796
118709
|
const parent = (0, import_node_path65.dirname)(checkout.path);
|
|
117797
|
-
await (0,
|
|
118710
|
+
await (0, import_promises60.mkdir)(parent, { recursive: true });
|
|
117798
118711
|
await assertValidBranch(deps.git, parent, checkout.branch, signal);
|
|
117799
118712
|
const output2 = await deps.git.run(
|
|
117800
118713
|
{
|
|
@@ -118102,7 +119015,7 @@ function volumeRoot(path18) {
|
|
|
118102
119015
|
}
|
|
118103
119016
|
async function exists3(path18) {
|
|
118104
119017
|
try {
|
|
118105
|
-
await (0,
|
|
119018
|
+
await (0, import_promises61.stat)(path18);
|
|
118106
119019
|
return true;
|
|
118107
119020
|
} catch {
|
|
118108
119021
|
return false;
|
|
@@ -118110,10 +119023,10 @@ async function exists3(path18) {
|
|
|
118110
119023
|
}
|
|
118111
119024
|
async function inspectReadiness(path18) {
|
|
118112
119025
|
try {
|
|
118113
|
-
if (!(await (0,
|
|
119026
|
+
if (!(await (0, import_promises61.stat)(path18)).isDirectory()) {
|
|
118114
119027
|
return { ready: false, missing: true, message: MESSAGES.missing };
|
|
118115
119028
|
}
|
|
118116
|
-
await (0,
|
|
119029
|
+
await (0, import_promises61.access)(path18, import_node_fs26.constants.R_OK | import_node_fs26.constants.W_OK | import_node_fs26.constants.X_OK);
|
|
118117
119030
|
return { ready: true };
|
|
118118
119031
|
} catch (error62) {
|
|
118119
119032
|
const code = errnoCode(error62) ?? "";
|
|
@@ -118159,8 +119072,8 @@ async function admitDefaultWorkspace(spec, context, skills) {
|
|
|
118159
119072
|
const { env } = context;
|
|
118160
119073
|
const path18 = resolveAlanDefaultWorkspacePath(env.HOME || env.USERPROFILE || (0, import_node_os9.homedir)());
|
|
118161
119074
|
try {
|
|
118162
|
-
await (0,
|
|
118163
|
-
await (0,
|
|
119075
|
+
await (0, import_promises61.mkdir)(path18, { recursive: true, mode: 448 });
|
|
119076
|
+
await (0, import_promises61.access)(path18, import_node_fs26.constants.R_OK | import_node_fs26.constants.W_OK | import_node_fs26.constants.X_OK);
|
|
118164
119077
|
return { kind: "admitted", spec: { ...spec, projectPath: path18 }, skills };
|
|
118165
119078
|
} catch (error62) {
|
|
118166
119079
|
const code = errnoCode(error62);
|
|
@@ -118297,7 +119210,7 @@ async function respondToTurn(runningRunId, driver, request3) {
|
|
|
118297
119210
|
}
|
|
118298
119211
|
|
|
118299
119212
|
// src/holder/session-facts.ts
|
|
118300
|
-
var
|
|
119213
|
+
var import_promises62 = require("node:fs/promises");
|
|
118301
119214
|
init_capabilities3();
|
|
118302
119215
|
init_platform();
|
|
118303
119216
|
var CLI_RSS_CACHE_MS = 1e4;
|
|
@@ -118326,8 +119239,8 @@ function createSessionFacts(options) {
|
|
|
118326
119239
|
const path18 = await resolveCommandOnPath(command, env, platform);
|
|
118327
119240
|
if (path18 === null) return null;
|
|
118328
119241
|
try {
|
|
118329
|
-
const real = await (0,
|
|
118330
|
-
const info = await (0,
|
|
119242
|
+
const real = await (0, import_promises62.realpath)(path18);
|
|
119243
|
+
const info = await (0, import_promises62.stat)(real);
|
|
118331
119244
|
return { command, key: `${real}:${info.ino}:${info.size}:${info.mtimeMs}` };
|
|
118332
119245
|
} catch {
|
|
118333
119246
|
return null;
|
|
@@ -118423,7 +119336,7 @@ function createSessionFacts(options) {
|
|
|
118423
119336
|
|
|
118424
119337
|
// src/holder/session-preparation.ts
|
|
118425
119338
|
var import_node_crypto42 = require("node:crypto");
|
|
118426
|
-
var
|
|
119339
|
+
var import_promises63 = require("node:fs/promises");
|
|
118427
119340
|
init_runtime_v2();
|
|
118428
119341
|
init_kernel();
|
|
118429
119342
|
init_platform();
|
|
@@ -118476,7 +119389,7 @@ function createHolderPreparation(options) {
|
|
|
118476
119389
|
signal.throwIfAborted();
|
|
118477
119390
|
if (!samePreparationBinding(fresh.binding, reference))
|
|
118478
119391
|
throw new LocalSessionActionError("forbidden");
|
|
118479
|
-
if (await (0,
|
|
119392
|
+
if (await (0, import_promises63.realpath)(reference.workspace) !== reference.workspace)
|
|
118480
119393
|
throw new LocalSessionActionError("invalid_path");
|
|
118481
119394
|
return fresh;
|
|
118482
119395
|
};
|
|
@@ -118678,7 +119591,7 @@ init_acp2();
|
|
|
118678
119591
|
init_kernel();
|
|
118679
119592
|
|
|
118680
119593
|
// src/run-log/directory.ts
|
|
118681
|
-
var
|
|
119594
|
+
var import_promises64 = require("node:fs/promises");
|
|
118682
119595
|
var import_node_path68 = require("node:path");
|
|
118683
119596
|
init_runtime_v2();
|
|
118684
119597
|
init_zod();
|
|
@@ -118693,7 +119606,8 @@ var runMetaSchema = external_exports.object({
|
|
|
118693
119606
|
turnOrdinal: external_exports.number().int().nullable(),
|
|
118694
119607
|
createdAt: external_exports.string(),
|
|
118695
119608
|
clientMessageId: external_exports.string().optional(),
|
|
118696
|
-
attachmentIds: external_exports.array(external_exports.string()).optional()
|
|
119609
|
+
attachmentIds: external_exports.array(external_exports.string()).optional(),
|
|
119610
|
+
sender: messageSenderSchema.optional()
|
|
118697
119611
|
}).optional(),
|
|
118698
119612
|
assistantMessage: external_exports.object({
|
|
118699
119613
|
id: external_exports.string(),
|
|
@@ -118712,7 +119626,7 @@ function runDirectory(runsDir, runId) {
|
|
|
118712
119626
|
}
|
|
118713
119627
|
async function isRunClaimed(runsDir, runId) {
|
|
118714
119628
|
try {
|
|
118715
|
-
return (await (0,
|
|
119629
|
+
return (await (0, import_promises64.stat)(runDirectory(runsDir, runId).log)).size > 0;
|
|
118716
119630
|
} catch (error62) {
|
|
118717
119631
|
if (errnoCode(error62) === "ENOENT") return false;
|
|
118718
119632
|
throw error62;
|
|
@@ -118720,7 +119634,7 @@ async function isRunClaimed(runsDir, runId) {
|
|
|
118720
119634
|
}
|
|
118721
119635
|
|
|
118722
119636
|
// src/run-log/conversation-index.ts
|
|
118723
|
-
var
|
|
119637
|
+
var import_promises65 = require("node:fs/promises");
|
|
118724
119638
|
var import_node_path69 = require("node:path");
|
|
118725
119639
|
init_runtime_v2();
|
|
118726
119640
|
init_zod();
|
|
@@ -118753,8 +119667,8 @@ async function indexConversationRun(runsDir, conversationId, ordinal, assistantO
|
|
|
118753
119667
|
const nextOrdinal = assistantOrdinal + 1;
|
|
118754
119668
|
if (nextOrdinal <= ordinal) throw new Error("Assistant order must follow the prompt");
|
|
118755
119669
|
const path18 = shardPath(runsDir, conversationId, ordinal);
|
|
118756
|
-
await (0,
|
|
118757
|
-
await (0,
|
|
119670
|
+
await (0, import_promises65.mkdir)((0, import_node_path69.dirname)(path18), { recursive: true, mode: 448 });
|
|
119671
|
+
await (0, import_promises65.appendFile)(path18, `${JSON.stringify({ ordinal, nextOrdinal, runId })}
|
|
118758
119672
|
`, { mode: 384 });
|
|
118759
119673
|
const coveragePath = (0, import_node_path69.join)((0, import_node_path69.dirname)((0, import_node_path69.dirname)(path18)), "coverage.json");
|
|
118760
119674
|
const coverage = await readJsonFile(coveragePath, coverageSchema2);
|
|
@@ -118773,10 +119687,10 @@ function nextCoverage(current, ordinal, nextOrdinal) {
|
|
|
118773
119687
|
|
|
118774
119688
|
// src/run-log/tail.ts
|
|
118775
119689
|
init_runtime_v2();
|
|
118776
|
-
var
|
|
119690
|
+
var TAIL_BYTES2 = 64 * 1024;
|
|
118777
119691
|
function tailWindows(size) {
|
|
118778
119692
|
const windows = [];
|
|
118779
|
-
for (let length = Math.min(size,
|
|
119693
|
+
for (let length = Math.min(size, TAIL_BYTES2); ; length *= 2) {
|
|
118780
119694
|
windows.push(Math.min(length, size));
|
|
118781
119695
|
if (length >= size || length > MAX_RUN_LOG_RECORD_BYTES) return windows;
|
|
118782
119696
|
}
|
|
@@ -119016,6 +119930,13 @@ async function claimRun(spec, context) {
|
|
|
119016
119930
|
}
|
|
119017
119931
|
var RUN_END_RETRY_MS = 5e3;
|
|
119018
119932
|
var RUN_END_DEADLINE_MS = 10 * 6e4;
|
|
119933
|
+
function problemMeta(problem) {
|
|
119934
|
+
if (!problem) return void 0;
|
|
119935
|
+
return {
|
|
119936
|
+
[PROBLEM_CODE_META]: problem.code,
|
|
119937
|
+
...problem.resetsAt ? { [PROBLEM_RESETS_AT_META]: problem.resetsAt } : {}
|
|
119938
|
+
};
|
|
119939
|
+
}
|
|
119019
119940
|
function resultEndUpdate(result, outcome2) {
|
|
119020
119941
|
return runEnded({
|
|
119021
119942
|
outcome: outcome2,
|
|
@@ -119048,7 +119969,15 @@ async function writeRunEnd(updates, log, spec, context) {
|
|
|
119048
119969
|
}
|
|
119049
119970
|
}
|
|
119050
119971
|
}
|
|
119051
|
-
|
|
119972
|
+
function resultAfterStop(result, signal) {
|
|
119973
|
+
if (!signal.aborted || result.outcome !== "failed") return result;
|
|
119974
|
+
return {
|
|
119975
|
+
outcome: "aborted",
|
|
119976
|
+
...result.providerSessionId === void 0 ? {} : { providerSessionId: result.providerSessionId }
|
|
119977
|
+
};
|
|
119978
|
+
}
|
|
119979
|
+
async function completeClaimedTurn(turnResult, spec, context, signal, log, events, reportedError, state2) {
|
|
119980
|
+
const result = resultAfterStop(turnResult, signal);
|
|
119052
119981
|
const outcome2 = result.outcome === "aborted" && signal.reason === "interrupted" ? "interrupted" : result.outcome;
|
|
119053
119982
|
const updates = [];
|
|
119054
119983
|
if ((outcome2 === "failed" || outcome2 === "interrupted") && !reportedError && result.message !== void 0) {
|
|
@@ -119056,7 +119985,9 @@ async function completeClaimedTurn(result, spec, context, signal, log, events, r
|
|
|
119056
119985
|
noticeUpdate(
|
|
119057
119986
|
"error",
|
|
119058
119987
|
outcome2 === "interrupted" ? "run_interrupted" : "run_failed",
|
|
119059
|
-
result.message
|
|
119988
|
+
result.message,
|
|
119989
|
+
void 0,
|
|
119990
|
+
problemMeta(result.problem)
|
|
119060
119991
|
)
|
|
119061
119992
|
);
|
|
119062
119993
|
}
|
|
@@ -119135,6 +120066,18 @@ async function runClaimedTurn(spec, claimed, context, signal) {
|
|
|
119135
120066
|
);
|
|
119136
120067
|
} catch (error62) {
|
|
119137
120068
|
context.log.error("holder.turn_threw", { runId: spec.runId, error: error62 });
|
|
120069
|
+
if (signal.aborted) {
|
|
120070
|
+
return completeClaimedTurn(
|
|
120071
|
+
{ outcome: "aborted" },
|
|
120072
|
+
spec,
|
|
120073
|
+
context,
|
|
120074
|
+
signal,
|
|
120075
|
+
log,
|
|
120076
|
+
events,
|
|
120077
|
+
reported.error,
|
|
120078
|
+
endState
|
|
120079
|
+
);
|
|
120080
|
+
}
|
|
119138
120081
|
try {
|
|
119139
120082
|
return await fail(error62 instanceof Error ? error62.message : String(error62));
|
|
119140
120083
|
} finally {
|