@andorra-labs/code 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/acp-agent.d.ts +54 -0
- package/dist/src/acp-agent.js +991 -0
- package/dist/src/agent-execution.js +4 -0
- package/dist/src/agent-mcp-catalog.js +2 -0
- package/dist/src/agent-mcp.d.ts +2 -0
- package/dist/src/agent-mcp.js +84 -2
- package/dist/src/andorra/entry.js +21 -3
- package/dist/src/andorra/hosted.d.ts +3 -0
- package/dist/src/andorra/hosted.js +5 -1
- package/dist/src/andorra/notices.d.ts +10 -1
- package/dist/src/andorra/notices.js +25 -2
- package/dist/src/andorra/terminal.d.ts +2 -0
- package/dist/src/andorra/terminal.js +2 -2
- package/dist/src/app-server/protocol.d.ts +6 -2
- package/dist/src/app-server/protocol.js +1 -1
- package/dist/src/app-server/workspace.d.ts +1 -0
- package/dist/src/app-server/workspace.js +141 -10
- package/dist/src/app-server.d.ts +8 -0
- package/dist/src/app-server.js +87 -41
- package/dist/src/auth/AuthManager.js +4 -4
- package/dist/src/browser-bridge.d.ts +1 -0
- package/dist/src/browser-bridge.js +5 -2
- package/dist/src/browser-external-app.d.ts +27 -0
- package/dist/src/browser-external-app.js +60 -0
- package/dist/src/browser-panel-tool.d.ts +6 -0
- package/dist/src/browser-panel-tool.js +36 -0
- package/dist/src/browser-server.d.ts +5 -0
- package/dist/src/browser-server.js +27 -3
- package/dist/src/browser-view.d.ts +16 -0
- package/dist/src/browser-view.js +60 -2
- package/dist/src/bug-report.d.ts +81 -0
- package/dist/src/bug-report.js +235 -0
- package/dist/src/claude-provider.d.ts +2 -1
- package/dist/src/claude-provider.js +10 -8
- package/dist/src/cli-sign-in.d.ts +3 -1
- package/dist/src/cli-sign-in.js +4 -1
- package/dist/src/cli.js +164 -34
- package/dist/src/coding-tools.js +7 -7
- package/dist/src/command-screens.d.ts +9 -2
- package/dist/src/command-screens.js +161 -94
- package/dist/src/commands.d.ts +1 -1
- package/dist/src/commands.js +1 -0
- package/dist/src/completion-gates.d.ts +22 -0
- package/dist/src/completion-gates.js +11 -0
- package/dist/src/config.d.ts +5 -0
- package/dist/src/config.js +48 -0
- package/dist/src/google-provider.d.ts +31 -0
- package/dist/src/google-provider.js +153 -0
- package/dist/src/graph-health.js +1 -1
- package/dist/src/graph-manager-chat.js +6 -1
- package/dist/src/graph-sync.d.ts +1 -0
- package/dist/src/graph-sync.js +93 -34
- package/dist/src/graph-tool.d.ts +2 -0
- package/dist/src/graph-tool.js +2 -2
- package/dist/src/graph-ui/app.js +67 -8
- package/dist/src/graph-ui/edge-router.js +121 -53
- package/dist/src/graph-visibility.d.ts +31 -0
- package/dist/src/graph-visibility.js +102 -0
- package/dist/src/live-model.d.ts +24 -0
- package/dist/src/live-model.js +37 -0
- package/dist/src/managed-sign-in.d.ts +1 -0
- package/dist/src/managed-sign-in.js +13 -0
- package/dist/src/membership-errors.d.ts +2 -0
- package/dist/src/membership-errors.js +5 -1
- package/dist/src/membership.d.ts +3 -0
- package/dist/src/membership.js +19 -2
- package/dist/src/model-health-cache.js +1 -1
- package/dist/src/model-metadata.js +8 -1
- package/dist/src/paged-transcript.d.ts +2 -0
- package/dist/src/paged-transcript.js +16 -0
- package/dist/src/provider-connection.js +17 -0
- package/dist/src/provider-engine.d.ts +5 -0
- package/dist/src/provider-engine.js +3 -3
- package/dist/src/provider-import.js +3 -1
- package/dist/src/provider-settings.js +14 -2
- package/dist/src/providers.d.ts +16 -2
- package/dist/src/providers.js +36 -12
- package/dist/src/react-runtime.js +21 -5
- package/dist/src/read-document-tool.d.ts +2 -0
- package/dist/src/read-document-tool.js +6 -6
- package/dist/src/remote/engine-pool.js +26 -2
- package/dist/src/runtime-environment.d.ts +1 -0
- package/dist/src/runtime-environment.js +13 -0
- package/dist/src/save-lock.js +14 -7
- package/dist/src/session-title.d.ts +3 -0
- package/dist/src/session-title.js +5 -2
- package/dist/src/sign-in-detection.d.ts +1 -1
- package/dist/src/sign-in-detection.js +10 -3
- package/dist/src/sign-in-offer.js +1 -1
- package/dist/src/skill-commands.js +1 -1
- package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
- package/dist/src/skills/bundled/graph-manager/errors.md +1 -0
- package/dist/src/skills/bundled/provenance.json +7 -2
- package/dist/src/skills/runtime-skills.js +1 -0
- package/dist/src/telemetry/uploader.d.ts +7 -1
- package/dist/src/telemetry/uploader.js +11 -2
- package/dist/src/terminal-links.d.ts +16 -0
- package/dist/src/terminal-links.js +113 -0
- package/dist/src/terminal-ui.d.ts +8 -1
- package/dist/src/terminal-ui.js +40 -14
- package/dist/src/tool-catalog.js +1 -1
- package/dist/src/trajectory.js +6 -1
- package/dist/src/transcript.d.ts +2 -0
- package/dist/src/transcript.js +2 -1
- package/dist/src/types.d.ts +2 -0
- package/package.json +2 -1
|
@@ -5,7 +5,7 @@ import { changeConfigFile, configDirectory, loadConfig } from './config.js';
|
|
|
5
5
|
import { applySignInImports, detectSignIns } from './sign-in-detection.js';
|
|
6
6
|
const DETECT_TIMEOUT_MS = 8_000;
|
|
7
7
|
const MAX_ATTEMPTS = 3;
|
|
8
|
-
const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode' };
|
|
8
|
+
const NAME = { claude: 'Claude', codex: 'ChatGPT', grok: 'Grok', opencode: 'OpenCode', google: 'Google' };
|
|
9
9
|
const statePath = (home) => join(home, 'sign-in-offer.json');
|
|
10
10
|
export async function readSignInOfferState(home = configDirectory()) {
|
|
11
11
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const BUILTIN_COMMANDS = new Set([
|
|
2
|
-
'browser', 'session', 'login', 'auth', 'model', 'providers', 'subagent', 'reasoning',
|
|
2
|
+
'browser', 'session', 'resume', 'login', 'auth', 'model', 'providers', 'subagent', 'reasoning',
|
|
3
3
|
'graph', 'codegraph', 'dashboard', 'attach', 'usage', 'permissions', 'jev',
|
|
4
4
|
'feedback', 'yolo', 'tools', 'skill', 'skills', 'plugins', 'mcp', 'logout', 'status',
|
|
5
5
|
'clear', 'compact', 'goal', 'help', 'exit', 'quit',
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bug-report
|
|
3
|
+
description: "Report a bug in Andorra Code to the Andorra team: ask the user what went wrong, write it up, and send it once they approve. Use when the user types /bug-report or says something in Andorra Code itself is broken and wants it reported."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Report a bug in Andorra Code
|
|
7
|
+
|
|
8
|
+
This sends a bug report about **Andorra Code itself** (the terminal app, the desktop app, sign-in, graphs,
|
|
9
|
+
models, tools) to the Andorra team. It is not for bugs in the user's own project: if that is what they
|
|
10
|
+
describe, say so and help with the project instead.
|
|
11
|
+
|
|
12
|
+
You send the report with the `submit_bug_report` tool. The tool shows the user the exact text and sends it
|
|
13
|
+
only when they choose **Send report**, so you never send anything they have not read.
|
|
14
|
+
|
|
15
|
+
## Before you ask anything
|
|
16
|
+
|
|
17
|
+
- The report needs a signed-in Andorra account. Any plan can report, Free included. If you already know
|
|
18
|
+
the user is signed out (an earlier error said so, or `andorra auth status` reports it), tell them to sign
|
|
19
|
+
in first (`andorra login`, `/login`, or Account in the desktop app) and stop. Otherwise carry on: the
|
|
20
|
+
tool checks, and tells you if they are signed out.
|
|
21
|
+
- If `submit_bug_report` is not among your tools, this run cannot send reports. Say so and ask the user to
|
|
22
|
+
type `/bug-report` at the start of a new message.
|
|
23
|
+
- Use what the user already told you, in this message and earlier in the conversation. Do not ask again
|
|
24
|
+
for something they have said.
|
|
25
|
+
|
|
26
|
+
## The interview
|
|
27
|
+
|
|
28
|
+
Ask one question at a time, in plain words, and wait for each answer. Use `ask_user` when you have it;
|
|
29
|
+
otherwise ask in your reply and continue when they answer. Skip a question whose answer you already have.
|
|
30
|
+
|
|
31
|
+
1. **What went wrong?** What they were trying to do and what happened. Ask for the exact error text if
|
|
32
|
+
there was one.
|
|
33
|
+
2. **How to make it happen again.** The steps, from a known starting point. "I don't know" or "it happened
|
|
34
|
+
once" is a fine answer: record it as that.
|
|
35
|
+
3. **What they expected** to happen instead.
|
|
36
|
+
4. **How often and since when**, if it is not already clear: every time or sometimes, and whether it
|
|
37
|
+
worked before (an update, a new setting, a different model).
|
|
38
|
+
5. **Anything else that helps**: which model or graph, the terminal app or the desktop app, a screenshot
|
|
39
|
+
described in words.
|
|
40
|
+
|
|
41
|
+
Stop asking once you can write a report someone else could act on. Three or four questions is usual; do
|
|
42
|
+
not go through the list for its own sake, and do not ask for the app version or operating system (the
|
|
43
|
+
tool attaches those).
|
|
44
|
+
|
|
45
|
+
## Write the report
|
|
46
|
+
|
|
47
|
+
- `title`: one line naming the problem, specific enough to tell it from other reports ("Desktop: Send does
|
|
48
|
+
nothing after attaching a PDF"), at most 120 characters.
|
|
49
|
+
- `description`: what happened, in the user's words, with the error text. Add "Happens every time" or
|
|
50
|
+
"Happened once", and what changed recently if they said.
|
|
51
|
+
- `steps`: numbered steps. Leave it out if the user does not know them.
|
|
52
|
+
- `expected` and `actual`: one or two sentences each.
|
|
53
|
+
|
|
54
|
+
Rules for the text:
|
|
55
|
+
|
|
56
|
+
- Report what the user said. Do not add steps, causes or details they did not give you, and do not guess
|
|
57
|
+
at a diagnosis. If you looked something up yourself (a log line, a version), say that it is your
|
|
58
|
+
observation.
|
|
59
|
+
- **Leave private material out**: no API keys, tokens or passwords, no file contents or source code from
|
|
60
|
+
their project, no prompts or conversation text, no personal data about other people. Describe instead
|
|
61
|
+
("a 40-line TypeScript file"). If the user pasted a secret, do not repeat it, and tell them it was left
|
|
62
|
+
out.
|
|
63
|
+
- Keep it short. The limits are 4,000 bytes for the description, 2,000 for steps and actual, 1,000 for
|
|
64
|
+
expected.
|
|
65
|
+
|
|
66
|
+
## Send it
|
|
67
|
+
|
|
68
|
+
Call `submit_bug_report` once with the fields above. Then:
|
|
69
|
+
|
|
70
|
+
- `sent: true`: give the user the `reference` (for example `BR-1234`) and thank them. There is no page to
|
|
71
|
+
open: the tracker is private, so do not offer a link or promise a reply.
|
|
72
|
+
- `sent: false` with a `userReply`: they want a change. Make it and call the tool again so they confirm
|
|
73
|
+
the new text.
|
|
74
|
+
- `sent: false` without one: they chose not to send. Say nothing was sent and stop.
|
|
75
|
+
- An error: tell the user what it said in plain words. Signed out: they sign in and run `/bug-report`
|
|
76
|
+
again. Daily limit reached: say when they can send it. Service unavailable: say so; do not retry in a
|
|
77
|
+
loop.
|
|
78
|
+
|
|
79
|
+
Send one report per problem. If the user describes two separate bugs, finish the first, then ask whether
|
|
80
|
+
to report the second.
|
|
@@ -139,6 +139,13 @@ and the upsert reply's `placed` says where it went.
|
|
|
139
139
|
3. `andorra_graph_publish`. A `REVISION_CONFLICT` means someone saved a newer revision: begin a new edit draft
|
|
140
140
|
from the latest, reapply your changes, validate and publish again.
|
|
141
141
|
4. If the user stops partway, `andorra_graph_discard` the draft.
|
|
142
|
+
5. If the user said which projects should offer the graph ("only this project", "only in X"), set it right after
|
|
143
|
+
publishing with `andorra_graph_visibility_set`: `projects: "this"` for the project the task runs in, a list of
|
|
144
|
+
registered project paths for named projects (`andorra_graph_visibility_get` lists them in `registeredProjects`;
|
|
145
|
+
in the Graph Builder the task does not run in the user's project, so name it this way), or `"all"` to list it
|
|
146
|
+
everywhere again.
|
|
147
|
+
`andorra_graph_visibility_get` reads the current setting. Never record visibility in graph metadata, which
|
|
148
|
+
nothing reads. If the call fails (for example `PROJECT_NOT_REGISTERED`), tell the user it was not applied.
|
|
142
149
|
|
|
143
150
|
## 6. Delete or restore
|
|
144
151
|
|
|
@@ -158,5 +165,6 @@ it can be restored.
|
|
|
158
165
|
## 7. Report
|
|
159
166
|
|
|
160
167
|
The graph id and revision, what changed, how to run it (`/graph` in the terminal to select it, the desktop's
|
|
161
|
-
graph picker, or `andorra --graph <id>`), and that cloud sync may still be pending.
|
|
168
|
+
graph picker, or `andorra --graph <id>`), and that cloud sync may still be pending. Say which projects list the graph
|
|
169
|
+
when you set it. Name anything you could not
|
|
162
170
|
validate.
|
|
@@ -24,6 +24,7 @@ validation error.
|
|
|
24
24
|
| `DRAFT_NOT_FOUND` / `DRAFT_BUSY` | The draft expired (one hour), was discarded, or is publishing. | Begin a new draft; wait for a publish to finish. |
|
|
25
25
|
| `DRAFT_LIMIT` | 24 drafts are open. | Discard unused drafts. |
|
|
26
26
|
| `FREE_TIER_LIMIT` | A free account's limit: one custom graph, at most 3 nodes, no Orchestrator. | Stay within it, or tell the user a paid plan lifts it. |
|
|
27
|
+
| `MEMBERSHIP_UNAVAILABLE` | The account service did not answer the membership check. Not an account or plan problem. | Wait a few seconds and retry the same call; the draft is kept. Do not ask the user to sign in or question their subscription. Tell the user only if retries keep failing. |
|
|
27
28
|
| `AUTH_REQUIRED` / `MEMBERSHIP_REQUIRED` / `AUTH_CHANGED` | Not signed in, no membership, or the account changed mid-edit. | Ask the user to sign in (`andorra login`); retry with the current account. |
|
|
28
29
|
| `DEFAULT_GRAPH` | Deleting or restoring the Default graph. | Not allowed. |
|
|
29
30
|
| `CONFIRMATION_MISMATCH` | `confirm` is not the graph id. | Ask the user to confirm, then pass the id in `confirm`. |
|
|
@@ -714,18 +714,23 @@
|
|
|
714
714
|
{
|
|
715
715
|
"source": "src/skills/bundled/graph-manager/SKILL.md",
|
|
716
716
|
"asset": "graph-manager/SKILL.md",
|
|
717
|
-
"sha256": "
|
|
717
|
+
"sha256": "fcb0b27d6db360f402b2f6cb4a4bbecbfe7f670eec6b91ccb74aedaf21bfcb91"
|
|
718
718
|
},
|
|
719
719
|
{
|
|
720
720
|
"source": "src/skills/bundled/graph-manager/errors.md",
|
|
721
721
|
"asset": "graph-manager/errors.md",
|
|
722
|
-
"sha256": "
|
|
722
|
+
"sha256": "5e084ffffcc69e0d8c405a27428763f743431e3db6d704f369c01f0893e6db04"
|
|
723
723
|
},
|
|
724
724
|
{
|
|
725
725
|
"source": "src/skills/bundled/graph-manager/patterns.md",
|
|
726
726
|
"asset": "graph-manager/patterns.md",
|
|
727
727
|
"sha256": "bf57e2421697360cc293109b5eaa84ecff0d93fc5dcd957a34d8173ca91b1e2c"
|
|
728
728
|
},
|
|
729
|
+
{
|
|
730
|
+
"source": "src/skills/bundled/bug-report/SKILL.md",
|
|
731
|
+
"asset": "bug-report/SKILL.md",
|
|
732
|
+
"sha256": "20777e7df3e9a93e2062f681069d09a090b487268cf12a2f5359f989ab809e2d"
|
|
733
|
+
},
|
|
729
734
|
{
|
|
730
735
|
"source": "src/skills/bundled/diagram/SKILL.md",
|
|
731
736
|
"asset": "diagram/SKILL.md",
|
|
@@ -19,6 +19,7 @@ const bundled = [
|
|
|
19
19
|
{ id: 'andorra:manage-skills', path: 'manage-skills/SKILL.md', description: "List, install, turn on or off, and remove Andorra Code skills and plugins. Use when the user asks what skills they have, wants to add a skill from GitHub or a folder, disable one, or clean up skills they no longer use.", source: 'bundled', loadWhen: 'before installing, copying, listing, turning on or off, or removing a skill or plugin' },
|
|
20
20
|
{ id: 'andorra:create-agent', path: 'create-agent/SKILL.md', description: "Design a reusable Andorra Code Agent (a role with its own instructions, model, capabilities and input/output contract) and produce a file the user imports into their Agent library. Use when the user wants a custom reviewer, tester, researcher or other role to reuse across graphs.", source: 'bundled' },
|
|
21
21
|
{ id: 'andorra:doctor', path: 'doctor/SKILL.md', description: "Check that Andorra Code is set up and healthy: Node, sign-in, configuration, providers, MCP servers, disk space. Use when something does not work (no models, tools missing, sign-in errors, tasks failing at start) or the user asks to check their setup.", source: 'bundled' },
|
|
22
|
+
{ id: 'andorra:bug-report', path: 'bug-report/SKILL.md', description: "Report a bug in Andorra Code to the Andorra team: ask the user what went wrong, write it up, and send it once they approve. Use when the user types /bug-report or says something in Andorra Code itself is broken and wants it reported.", source: 'bundled' },
|
|
22
23
|
{ id: 'andorra:write-instructions', path: 'write-instructions/SKILL.md', description: "Create or improve a repository's agent instructions (ANDORRA.md or AGENTS.md): build and test commands, conventions, and rules agents must follow. Use when the user wants agents to work the way their team does, or asks to set up or tighten project instructions.", source: 'bundled' },
|
|
23
24
|
{ id: 'andorra:graph-manager', path: 'graph-manager/SKILL.md', description: "Design, create, edit, delete or restore Andorra Code graphs (multi-agent pipelines) from the user's requirements, through Andorra's graph tools. Use when the user wants a new graph, wants to change how an existing graph routes work, or wants a graph removed or brought back.", source: 'bundled' },
|
|
24
25
|
{ id: 'andorra:diagram', path: 'diagram/SKILL.md', description: "Draw a UML-style diagram in a reply instead of hand-typed arrows. Use when about to describe or explain a graph, process, routing, state machine, call sequence, data model or code structure to the user, including when reviewing an Andorra graph.", source: 'bundled', loadWhen: 'before describing or explaining a graph, workflow, state machine, call sequence or code structure to the user' },
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { type TelemetryEvent } from './schema.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Where events are posted. In a run of this repository's own test runner (its marker variable is set) there is
|
|
4
|
+
* no endpoint unless the test names one, so a test that starts an engine against a throwaway home can never
|
|
5
|
+
* report to the production service as a new installation. Nothing a user's own tools set (Node's test-runner
|
|
6
|
+
* variables among them) switches reporting off.
|
|
7
|
+
*/
|
|
8
|
+
export declare function telemetryEndpoint(env?: NodeJS.ProcessEnv): string | undefined;
|
|
3
9
|
export interface UploadDependencies {
|
|
4
10
|
reporting?: () => Promise<boolean>;
|
|
5
11
|
fetch?: typeof globalThis.fetch;
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
|
+
import { TEST_RUN_MARKER } from '../andorra/hosted.js';
|
|
2
3
|
import { AUTH_DEPLOYMENT } from '../auth/deployment.js';
|
|
3
4
|
import { enqueue, pruneGeneration, pruneOld, readSpool, rewriteSpool, spoolNames, sweepOutbox, withSpoolLock, withSpoolLockWait, } from './outbox.js';
|
|
4
5
|
import { serializeTelemetryEvent } from './schema.js';
|
|
5
6
|
import { uploadSignal } from './uploads.js';
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Where events are posted. In a run of this repository's own test runner (its marker variable is set) there is
|
|
9
|
+
* no endpoint unless the test names one, so a test that starts an engine against a throwaway home can never
|
|
10
|
+
* report to the production service as a new installation. Nothing a user's own tools set (Node's test-runner
|
|
11
|
+
* variables among them) switches reporting off.
|
|
12
|
+
*/
|
|
13
|
+
export function telemetryEndpoint(env = process.env) {
|
|
14
|
+
if (env[TEST_RUN_MARKER] && !env.ANDORRA_TELEMETRY_URL)
|
|
15
|
+
return undefined;
|
|
16
|
+
const configured = env.ANDORRA_TELEMETRY_URL || AUTH_DEPLOYMENT.telemetryBaseUrl;
|
|
8
17
|
return configured ? configured.replace(/\/+$/, '') : undefined;
|
|
9
18
|
}
|
|
10
19
|
const REQUEST_TIMEOUT_MS = 5_000;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A web address inside one painted row: `start`/`end` index the row's text, `url` is the whole address. */
|
|
2
|
+
export interface RowLink {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
url: string;
|
|
6
|
+
}
|
|
7
|
+
/** The web addresses in one source line, without trailing sentence punctuation. */
|
|
8
|
+
export declare function lineUrls(line: string): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Finds where each address of `line` landed in the rows `line` wrapped into. A terminal only
|
|
11
|
+
* auto-detects an address on the row it starts on, so a wrapped address is clickable on its first
|
|
12
|
+
* row alone unless every piece is marked as a link to the whole address.
|
|
13
|
+
*/
|
|
14
|
+
export declare function wrappedLinks(line: string, rows: readonly string[]): (RowLink[] | undefined)[];
|
|
15
|
+
/** Wraps each link range of `text` in an OSC 8 hyperlink; pieces of one address share an id so terminals hover them together. */
|
|
16
|
+
export declare function hyperlinkRow(text: string, links: readonly RowLink[] | undefined): string;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
const URL_PATTERN = /https?:\/\/[^\s<>"'`]+/g;
|
|
3
|
+
const LINKABLE = /^[\x21-\x7e]+$/;
|
|
4
|
+
const CLOSERS = { ')': '(', ']': '[', '}': '{' };
|
|
5
|
+
/** Characters after which an address may start: whitespace or the punctuation that encloses one, as in `label (https://…)`. */
|
|
6
|
+
const OPENER = /[\s([{<"'`]/u;
|
|
7
|
+
const count = (text, character) => text.split(character).length - 1;
|
|
8
|
+
/** Drops sentence punctuation and unmatched closing brackets from the end, keeping balanced ones such as `Function_(mathematics)`. */
|
|
9
|
+
function trimTrailing(url) {
|
|
10
|
+
for (;;) {
|
|
11
|
+
const last = url.at(-1) ?? '';
|
|
12
|
+
const opener = CLOSERS[last];
|
|
13
|
+
if (opener ? count(url, last) > count(url, opener) : /[.,;:!?]/.test(last))
|
|
14
|
+
url = url.slice(0, -1);
|
|
15
|
+
else
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** The web addresses in one source line, without trailing sentence punctuation. */
|
|
20
|
+
export function lineUrls(line) {
|
|
21
|
+
return [...line.matchAll(URL_PATTERN)].map(match => trimTrailing(match[0])).filter(url => url.length > 'https://'.length && LINKABLE.test(url));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Finds where each address of `line` landed in the rows `line` wrapped into. A terminal only
|
|
25
|
+
* auto-detects an address on the row it starts on, so a wrapped address is clickable on its first
|
|
26
|
+
* row alone unless every piece is marked as a link to the whole address.
|
|
27
|
+
*/
|
|
28
|
+
export function wrappedLinks(line, rows) {
|
|
29
|
+
const urls = lineUrls(line);
|
|
30
|
+
const result = rows.map(() => undefined);
|
|
31
|
+
if (!urls.length)
|
|
32
|
+
return result;
|
|
33
|
+
let index = 0, consumed = 0;
|
|
34
|
+
for (const [rowIndex, row] of rows.entries()) {
|
|
35
|
+
const links = [];
|
|
36
|
+
let position = 0;
|
|
37
|
+
while (index < urls.length) {
|
|
38
|
+
const url = urls[index];
|
|
39
|
+
if (consumed > 0) {
|
|
40
|
+
const start = row.search(/\S/u);
|
|
41
|
+
const remaining = url.slice(consumed);
|
|
42
|
+
let length = 0;
|
|
43
|
+
while (start >= 0 && length < remaining.length && row[start + length] === remaining[length])
|
|
44
|
+
length++;
|
|
45
|
+
if (!length) {
|
|
46
|
+
consumed = 0;
|
|
47
|
+
index++;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
links.push({ start, end: start + length, url });
|
|
51
|
+
consumed += length;
|
|
52
|
+
position = start + length;
|
|
53
|
+
if (consumed < url.length)
|
|
54
|
+
break;
|
|
55
|
+
consumed = 0;
|
|
56
|
+
index++;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const whole = row.indexOf(url, position);
|
|
60
|
+
if (whole >= 0) {
|
|
61
|
+
links.push({ start: whole, end: whole + url.length, url });
|
|
62
|
+
position = whole + url.length;
|
|
63
|
+
index++;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
let start = -1;
|
|
67
|
+
for (let at = position; at < row.length; at++) {
|
|
68
|
+
const tail = row.slice(at).trimEnd();
|
|
69
|
+
if (tail && (at === 0 || OPENER.test(row[at - 1])) && url.startsWith(tail) && continues(rows, rowIndex + 1, url.slice(tail.length))) {
|
|
70
|
+
start = at;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (start < 0)
|
|
75
|
+
break;
|
|
76
|
+
const piece = row.slice(start).trimEnd();
|
|
77
|
+
links.push({ start, end: start + piece.length, url });
|
|
78
|
+
consumed = piece.length;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
if (links.length)
|
|
82
|
+
result[rowIndex] = links;
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/** Whether `rest` is spelled out at the start of the rows from `from` on, as wrapping a long address leaves it. */
|
|
87
|
+
function continues(rows, from, rest) {
|
|
88
|
+
for (let row = from; rest && row < rows.length; row++) {
|
|
89
|
+
const text = rows[row].trimStart();
|
|
90
|
+
let length = 0;
|
|
91
|
+
while (length < rest.length && text[length] === rest[length])
|
|
92
|
+
length++;
|
|
93
|
+
if (!length || (length < rest.length && length < text.trimEnd().length))
|
|
94
|
+
return false;
|
|
95
|
+
rest = rest.slice(length);
|
|
96
|
+
}
|
|
97
|
+
return !rest;
|
|
98
|
+
}
|
|
99
|
+
/** Wraps each link range of `text` in an OSC 8 hyperlink; pieces of one address share an id so terminals hover them together. */
|
|
100
|
+
export function hyperlinkRow(text, links) {
|
|
101
|
+
if (!links?.length)
|
|
102
|
+
return text;
|
|
103
|
+
let out = '', cursor = 0;
|
|
104
|
+
for (const link of [...links].sort((a, b) => a.start - b.start)) {
|
|
105
|
+
const end = Math.min(link.end, text.length);
|
|
106
|
+
if (link.start < cursor || link.start >= end || !LINKABLE.test(link.url))
|
|
107
|
+
continue;
|
|
108
|
+
const id = createHash('sha256').update(link.url).digest('hex').slice(0, 12);
|
|
109
|
+
out += text.slice(cursor, link.start) + `\x1b]8;id=${id};${link.url}\x1b\\` + text.slice(link.start, end) + '\x1b]8;;\x1b\\';
|
|
110
|
+
cursor = end;
|
|
111
|
+
}
|
|
112
|
+
return out + text.slice(cursor);
|
|
113
|
+
}
|
|
@@ -38,6 +38,8 @@ export interface TerminalStatus {
|
|
|
38
38
|
codeIntel?: string;
|
|
39
39
|
account?: AccountPresentation;
|
|
40
40
|
jevEnabled?: boolean;
|
|
41
|
+
/** Jev is on but the last run could not use it (signed out, or the account lookup failed); cleared when the Jev setting changes. */
|
|
42
|
+
jevOffThisRun?: boolean;
|
|
41
43
|
goal?: SessionGoal;
|
|
42
44
|
changes?: PanelChanges;
|
|
43
45
|
terminals?: readonly PanelTerminal[];
|
|
@@ -48,6 +50,8 @@ export interface TerminalOptions extends TerminalStatus {
|
|
|
48
50
|
workspace: string;
|
|
49
51
|
version: string;
|
|
50
52
|
appName?: string;
|
|
53
|
+
/** The current session's id, read on every frame so a resume, fork or /new shows at once. */
|
|
54
|
+
sessionId?: () => string | undefined;
|
|
51
55
|
tokenClock?: () => number;
|
|
52
56
|
clipboardImageProbe?: () => Promise<Buffer | undefined>;
|
|
53
57
|
clipboardTextWriter?: (text: string) => Promise<void>;
|
|
@@ -109,6 +113,7 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
109
113
|
requests: number;
|
|
110
114
|
}): void;
|
|
111
115
|
private readonly tokenClock;
|
|
116
|
+
private readonly sessionId;
|
|
112
117
|
private speedMeters;
|
|
113
118
|
private speedInvocations;
|
|
114
119
|
private activeSpeedNode;
|
|
@@ -142,6 +147,8 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
142
147
|
private value;
|
|
143
148
|
private cursor;
|
|
144
149
|
private transcript;
|
|
150
|
+
/** The newest transcript entry, while it is one that a later print with the same key rewrites. */
|
|
151
|
+
private replaceable?;
|
|
145
152
|
private expandedTranscript;
|
|
146
153
|
private todos;
|
|
147
154
|
private expandedTodos;
|
|
@@ -238,7 +245,7 @@ export declare class TerminalUI extends EventEmitter {
|
|
|
238
245
|
loadScreen<T>(title: string, load: (signal: AbortSignal) => Promise<T>, options?: ScreenOptions): Promise<T | undefined>;
|
|
239
246
|
private openModal;
|
|
240
247
|
private finishModal;
|
|
241
|
-
print(text: string, detail?: string, toolCall?: ToolCallStamp, conversation?: boolean, notice?: boolean, alignRight?: boolean, clipRows?: boolean): void;
|
|
248
|
+
print(text: string, detail?: string, toolCall?: ToolCallStamp, conversation?: boolean, notice?: boolean, alignRight?: boolean, clipRows?: boolean, replaceKey?: string): void;
|
|
242
249
|
printPrompt(text: string, title?: string): void;
|
|
243
250
|
appendThinking(delta: string): void;
|
|
244
251
|
clearConversation(): void;
|
package/dist/src/terminal-ui.js
CHANGED
|
@@ -4,10 +4,12 @@ import { PassThrough } from 'node:stream';
|
|
|
4
4
|
import { StringDecoder } from 'node:string_decoder';
|
|
5
5
|
import { stripVTControlCharacters } from 'node:util';
|
|
6
6
|
import stringWidth from 'string-width';
|
|
7
|
+
import { hyperlinkRow, wrappedLinks } from './terminal-links.js';
|
|
7
8
|
import { DashboardMetrics } from './dashboard.js';
|
|
8
9
|
import { dashboardRows } from './dashboard-view.js';
|
|
9
10
|
import { goalStatusLabel } from './session-goal.js';
|
|
10
11
|
import { transcriptColor } from './transcript.js';
|
|
12
|
+
import { ANDORRA_BUBBLE_SPEAKER, ANDORRA_BUBBLE_TAIL } from './andorra/notices.js';
|
|
11
13
|
import { ToolCallClock, toolHeaderRows } from './tool-call-clock.js';
|
|
12
14
|
import { formatDuration, formatHms } from './duration.js';
|
|
13
15
|
import { PagedTranscript } from './paged-transcript.js';
|
|
@@ -27,7 +29,7 @@ const SKILL_TOKEN = String.fromCodePoint(0x10FFFD);
|
|
|
27
29
|
const composerGraphemes = (text) => graphemes(text).flatMap(part => isToken(part) && part.length > 2 ? [part.slice(0, 2), part.slice(2)] : [part]);
|
|
28
30
|
const clean = (text) => stripVTControlCharacters(text).replace(/\r\n?/g, '\n').replace(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/g, '').replace(/[\u{100000}-\u{10FFFF}]/gu, '').replace(/\t/g, ' ');
|
|
29
31
|
const oneLine = (text) => clean(text).replace(/\n/g, ' ');
|
|
30
|
-
const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/status', '/clear', '/compact', '/goal', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
|
|
32
|
+
const commands = ['/model', '/providers', '/subagent', '/reasoning', '/graph', '/codegraph', '/dashboard', '/browser', '/attach', '/skills', '/skill', '/plugins', '/mcp', '/usage', '/permissions', '/yolo', '/jev', '/feedback', '/tools', '/session', '/resume', '/status', '/clear', '/compact', '/goal', '/help', '/login', '/logout', '/auth status', '/auth logout', '/exit', '/quit'];
|
|
31
33
|
const argumentCompletions = {
|
|
32
34
|
'/jev': ['/jev status', '/jev on', '/jev off', '/jev global on', '/jev global off'],
|
|
33
35
|
'/feedback': ['/feedback status', '/feedback on', '/feedback off'],
|
|
@@ -59,7 +61,7 @@ const OVERRIDE_HINT = 'Choose a model to override the nodes with · /model';
|
|
|
59
61
|
const commandDescriptions = {
|
|
60
62
|
'/browser': 'Open the browser workspace',
|
|
61
63
|
'/attach': 'Attach a file or folder to your next task',
|
|
62
|
-
'/session': 'Browse and resume saved sessions',
|
|
64
|
+
'/session': 'Browse and resume saved sessions', '/resume': 'Browse and resume saved sessions',
|
|
63
65
|
'/login': 'Sign in or create an Andorra account', '/logout': 'Sign out of the Andorra account', '/logout codex': 'Sign out of every Codex account', '/auth logout': 'Sign out of the Andorra account', '/auth status': 'Account and membership status',
|
|
64
66
|
'/model': 'Choose a model', '/providers': 'Choose or edit providers',
|
|
65
67
|
'/subagent': 'Choose the provider and model external hosts run Andorra with',
|
|
@@ -81,9 +83,9 @@ const submittedCommand = (value) => {
|
|
|
81
83
|
const [token] = value.trim().split(/\s+/);
|
|
82
84
|
return commands.some(command => command.split(/\s+/)[0] === token) ? token : undefined;
|
|
83
85
|
};
|
|
84
|
-
const workingCommandHint = (command) => `${command} doesn't run while a task is working.
|
|
86
|
+
const workingCommandHint = (command) => `${command} doesn't run while a task is working. Run ${command} once this task has finished.`
|
|
85
87
|
+ (command === '/graph' ? ' Switching graphs clears the previous graph progress and starts fresh.' : '');
|
|
86
|
-
const liveRunCommands = ['/browser', '/attach', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools', '/exit', '/quit'];
|
|
88
|
+
const liveRunCommands = ['/model', '/browser', '/attach', '/yolo', '/permissions', '/jev', '/help', '/status', '/usage', '/tools', '/exit', '/quit'];
|
|
87
89
|
const paint = (text, color = GRAY) => typeof color === 'number'
|
|
88
90
|
? `\x1b[38;5;${color}m${text}\x1b[0m`
|
|
89
91
|
: `\x1b[${color}m${text}\x1b[0m`;
|
|
@@ -296,6 +298,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
296
298
|
finishTask() { this.runActive = false; this.dashboardMetrics.finishTask(); this.scheduleRender(); }
|
|
297
299
|
resetDashboardSession(usage) { this.dashboardMetrics.resetSession(usage); this.dashboardModel = 0; this.dashboardGraphOffset = 0; this.nodeModels.clear(); this.dashboardNotices = []; this.scheduleRender(); }
|
|
298
300
|
tokenClock;
|
|
301
|
+
sessionId;
|
|
299
302
|
speedMeters = new Map();
|
|
300
303
|
speedInvocations = new Map();
|
|
301
304
|
activeSpeedNode;
|
|
@@ -553,6 +556,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
553
556
|
value = [];
|
|
554
557
|
cursor = 0;
|
|
555
558
|
transcript = new PagedTranscript();
|
|
559
|
+
/** The newest transcript entry, while it is one that a later print with the same key rewrites. */
|
|
560
|
+
replaceable;
|
|
556
561
|
expandedTranscript = false;
|
|
557
562
|
todos = [];
|
|
558
563
|
expandedTodos = false;
|
|
@@ -654,6 +659,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
654
659
|
this.appName = oneLine(options.appName ?? 'ANDORRA CODE');
|
|
655
660
|
this.status = { ...options };
|
|
656
661
|
this.tokenClock = options.tokenClock;
|
|
662
|
+
this.sessionId = options.sessionId;
|
|
657
663
|
this.clipboardImageProbe = options.clipboardImageProbe;
|
|
658
664
|
this.clipboardTextWriter = options.clipboardTextWriter;
|
|
659
665
|
emitKeypressEvents(this.keys);
|
|
@@ -810,6 +816,9 @@ export class TerminalUI extends EventEmitter {
|
|
|
810
816
|
return Promise.reject(new Error('Terminal is closed'));
|
|
811
817
|
if (this.modal)
|
|
812
818
|
return Promise.reject(new Error('A terminal screen is already active'));
|
|
819
|
+
// A screen that yields to the run's questions never opens over one already asked: it yields at once.
|
|
820
|
+
if (options.yieldToQuestions && this.pending && !this.pending.conversationPrompt)
|
|
821
|
+
return Promise.reject(new DOMException('Screen yielded to a question', 'AbortError'));
|
|
813
822
|
if (options.signal?.aborted)
|
|
814
823
|
return Promise.reject(new DOMException('Screen aborted', 'AbortError'));
|
|
815
824
|
if (!this.started)
|
|
@@ -845,7 +854,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
845
854
|
modal.resolve(value);
|
|
846
855
|
this.scheduleRender();
|
|
847
856
|
}
|
|
848
|
-
print(text, detail, toolCall, conversation = false, notice = true, alignRight = false, clipRows = false) {
|
|
857
|
+
print(text, detail, toolCall, conversation = false, notice = true, alignRight = false, clipRows = false, replaceKey) {
|
|
849
858
|
if (notice) {
|
|
850
859
|
this.dashboardNotices.push(clean(String(text)).slice(0, 100_000));
|
|
851
860
|
this.dashboardNotices = this.dashboardNotices.slice(-12);
|
|
@@ -855,9 +864,14 @@ export class TerminalUI extends EventEmitter {
|
|
|
855
864
|
this.modal.lines = [...this.modal.lines, ...lines].slice(-100);
|
|
856
865
|
const entry = { text: lines.join('\n'), ...(detail ? { detail: clean(detail) } : {}),
|
|
857
866
|
...(toolCall ? { toolCall, timing: this.toolClock.get(toolCall.key) } : {}), ...(conversation ? { conversation: true } : {}), ...(alignRight ? { alignRight: true } : {}), ...(clipRows && detail ? { clipRows: true } : {}) };
|
|
867
|
+
const replaced = replaceKey !== undefined && this.replaceable?.key === replaceKey ? this.replaceable.entry : undefined;
|
|
858
868
|
if (this.scroll)
|
|
859
|
-
this.scroll
|
|
860
|
-
|
|
869
|
+
this.scroll = Math.max(0, this.scroll + this.transcriptRows(entry, this.chatColumns()).length - (replaced ? this.transcriptRows(replaced, this.chatColumns()).length : 0));
|
|
870
|
+
if (replaced)
|
|
871
|
+
this.transcript.replaceLast(entry);
|
|
872
|
+
else
|
|
873
|
+
this.transcript.append(entry);
|
|
874
|
+
this.replaceable = replaceKey === undefined ? undefined : { key: replaceKey, entry };
|
|
861
875
|
this.scheduleRender();
|
|
862
876
|
}
|
|
863
877
|
printPrompt(text, title = '') {
|
|
@@ -901,6 +915,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
901
915
|
if (this.scroll)
|
|
902
916
|
this.scroll += this.transcriptRows(entry, this.chatColumns()).length;
|
|
903
917
|
this.transcript.append(entry);
|
|
918
|
+
this.replaceable = undefined;
|
|
904
919
|
this.scheduleRender();
|
|
905
920
|
}
|
|
906
921
|
appendThinking(delta) {
|
|
@@ -922,6 +937,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
922
937
|
if (this.closed)
|
|
923
938
|
return;
|
|
924
939
|
this.transcript.clear();
|
|
940
|
+
this.replaceable = undefined;
|
|
925
941
|
this.expandedTranscript = false;
|
|
926
942
|
this.expandedPromptIds.clear();
|
|
927
943
|
this.collapsedPromptIds.clear();
|
|
@@ -968,7 +984,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
968
984
|
this.visitedNodes.clear();
|
|
969
985
|
this.stoppedNode = undefined;
|
|
970
986
|
}
|
|
971
|
-
|
|
987
|
+
const jevSettingChanged = partial.jevEnabled !== undefined && partial.jevEnabled !== this.status.jevEnabled && partial.jevOffThisRun === undefined;
|
|
988
|
+
this.status = { ...this.status, ...partial, ...(partial.activity !== undefined && partial.backgroundActivity === undefined ? { backgroundActivity: false } : {}), ...(jevSettingChanged ? { jevOffThisRun: false } : {}) };
|
|
972
989
|
if (partial.activity === 'Ready') {
|
|
973
990
|
this.activeNodes.clear();
|
|
974
991
|
this.toolClock.stop();
|
|
@@ -2359,7 +2376,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
2359
2376
|
modal.offset = Math.max(0, Math.min(modal.offset, Math.max(0, content.length - viewport)));
|
|
2360
2377
|
const visible = content.slice(modal.offset, modal.offset + viewport);
|
|
2361
2378
|
const title = clip(` ${modal.title} `, cardWidth - 2);
|
|
2362
|
-
const
|
|
2379
|
+
const modalSession = oneLine(this.sessionId?.() ?? '');
|
|
2380
|
+
const rows = [paint(clip(`◈ ${this.appName}${modalSession ? ` ${modalSession}` : ''}`, width), GRAY), '', paint(` ╭${title}${'─'.repeat(Math.max(0, cardWidth - 2 - stringWidth(title)))}╮`, GRAY)];
|
|
2363
2381
|
for (const line of description)
|
|
2364
2382
|
rows.push(paint(' │ ', GRAY) + paint(pad(line, innerWidth), GRAY) + paint(' │', GRAY));
|
|
2365
2383
|
for (let index = 0; index < viewport; index++) {
|
|
@@ -2390,10 +2408,15 @@ export class TerminalUI extends EventEmitter {
|
|
|
2390
2408
|
const aligned = alignRight && stringWidth(line) <= allowance;
|
|
2391
2409
|
const lead = diff || box || isBrand || aligned ? undefined : /^\s*(?:(?:[•◦└]|\d{1,3}[.)])\s+)?/u.exec(line)?.[0];
|
|
2392
2410
|
const hang = lead ? stringWidth(lead) : 0;
|
|
2411
|
+
// The bubble's tail is part of its box; only the speaker's name keeps the text color.
|
|
2412
|
+
if (line === ANDORRA_BUBBLE_TAIL + ANDORRA_BUBBLE_SPEAKER)
|
|
2413
|
+
return [{ text: line, color, segments: [{ text: ANDORRA_BUBBLE_TAIL, color: GRAY }, { text: ANDORRA_BUBBLE_SPEAKER, color }] }];
|
|
2393
2414
|
const rows = lead && hang > 0 && hang <= allowance / 2 && stringWidth(line) > allowance
|
|
2394
2415
|
? wrap(line.slice(lead.length), allowance - hang).map((text, index) => (index ? ' '.repeat(hang) : lead) + text)
|
|
2395
2416
|
: wrap(line, allowance);
|
|
2396
|
-
|
|
2417
|
+
const shown = rows.map(text => aligned && text ? ' '.repeat(allowance - stringWidth(text)) + text : text);
|
|
2418
|
+
const links = wrappedLinks(line, shown);
|
|
2419
|
+
return shown.map((text, index) => ({ text, color, ...(links[index] ? { links: links[index] } : {}) }));
|
|
2397
2420
|
});
|
|
2398
2421
|
}
|
|
2399
2422
|
transcriptRows(entry, width) {
|
|
@@ -2424,7 +2447,8 @@ export class TerminalUI extends EventEmitter {
|
|
|
2424
2447
|
const rows = text.split('\n');
|
|
2425
2448
|
const elapsed = entry.timing ? formatDuration(this.toolClock.elapsed(entry.timing)) : undefined;
|
|
2426
2449
|
const right = [entry.toolCall.timestamp, elapsed].filter(Boolean).join(' · ');
|
|
2427
|
-
|
|
2450
|
+
// No blank row after a call: its result is the next entry and reads as part of it.
|
|
2451
|
+
return [...toolHeaderRows(rows[0], right, Math.max(1, width - 4)), ...rows.slice(1)].flatMap(row => this.wrapTranscript(row, width));
|
|
2428
2452
|
}
|
|
2429
2453
|
render() {
|
|
2430
2454
|
if (!this.started || this.closed)
|
|
@@ -2508,7 +2532,9 @@ export class TerminalUI extends EventEmitter {
|
|
|
2508
2532
|
visible[0] = { text: `? Scrollback ? ${this.scroll} lines below ? Page Down to return`, color: DIM };
|
|
2509
2533
|
this.expandedPromptVisible = visible.some(row => row.promptExpanded);
|
|
2510
2534
|
const status = this.status;
|
|
2511
|
-
const
|
|
2535
|
+
const sessionId = oneLine(this.sessionId?.() ?? '');
|
|
2536
|
+
const title = sessionId ? `\u25c8 ${this.appName} ${sessionId}` : `\u25c8 ${this.appName}`;
|
|
2537
|
+
const top = this.dashboard ? `${title} \u00b7 Dashboard \u00b7 Ctrl+B transcript` : title;
|
|
2512
2538
|
const version = clip(`v${this.version}`, Math.floor(width / 3));
|
|
2513
2539
|
const header = paint(pad(top, width - stringWidth(version)), DIM) + paint(version, FAINT);
|
|
2514
2540
|
const label = choices ? this.pending?.choiceTitle || 'Choose an answer' : this.pending?.title ? this.pending.title : this.pending && !this.pending.regular ? 'Your approval' : this.pending?.conversationPrompt && this.value[0] === '/' ? 'Commands · Enter runs · Tab completes' : this.steering && status.activity && status.activity !== 'Ready' ? status.activity === 'Paused' ? 'Paused - Send direction to resume' : 'Steer this run · Enter to send' : '';
|
|
@@ -2520,7 +2546,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2520
2546
|
const workingLabel = clip(workingText, Math.max(0, width - 6));
|
|
2521
2547
|
const wave = Math.floor(elapsed / 120) % 11;
|
|
2522
2548
|
const topBorder = working && workingLabel ? paint('╭ ', GRAY) + [...workingLabel].map((character, index) => paint(character, index < 7 && Math.abs(index - wave) <= 1 ? 255 : GRAY)).join('') + paint(' ' + '─'.repeat(Math.max(0, width - 4 - stringWidth(workingLabel))) + '╮', GRAY) : paint('╭' + borderLabel + '─'.repeat(Math.max(0, width - 2 - stringWidth(borderLabel))) + '╮', GRAY);
|
|
2523
|
-
const lines = [header, paint(clip(` ${status.account ? `Account: ${oneLine(status.account.label)} | ` : ''}${oneLine(this.workspace)}`, width), FAINT), ...visible.map(line => line.segments ? ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join('') : paint(' ' + clip(line.text, width - 2), line.color)), ...thinkingLines.map(line => paint(' ' + pad(line, width - 4), GRAY)), ...agentLines, ...todoLines.map(line => paint(' ' + clip(line, width - 2), GRAY))];
|
|
2549
|
+
const lines = [header, paint(clip(` ${status.account ? `Account: ${oneLine(status.account.label)} | ` : ''}${oneLine(this.workspace)}`, width), FAINT), ...visible.map(line => line.segments ? ' ' + line.segments.map(segment => paint(segment.text, segment.color ?? GRAY)).join('') : paint(' ' + hyperlinkRow(clip(line.text, width - 2), line.links), line.color)), ...thinkingLines.map(line => paint(' ' + pad(line, width - 4), GRAY)), ...agentLines, ...todoLines.map(line => paint(' ' + clip(line, width - 2), GRAY))];
|
|
2524
2550
|
if (completion && popupRows) {
|
|
2525
2551
|
const cardWidth = width - 4;
|
|
2526
2552
|
const popupTitle = clip(' Commands · ↑↓ move · Enter runs · Tab completes ', cardWidth - 2);
|
|
@@ -2555,7 +2581,7 @@ export class TerminalUI extends EventEmitter {
|
|
|
2555
2581
|
const model = oneLine(`${active.label} · Thinking: ${active.reasoningEffort ?? 'provider default'}`);
|
|
2556
2582
|
const branch = oneLine(status.branch || 'no branch');
|
|
2557
2583
|
const branchWidth = Math.min(Math.floor(width / 3), stringWidth(branch) + 3);
|
|
2558
|
-
const jev = oneLine(status.account?.jevQuota ?? 'Jev unavailable').replace(/^Jev(?= )/, status.jevEnabled === false ? 'Jev [Disabled] ·' : status.jevEnabled === true ? 'Jev [Enabled] ·' : 'Jev');
|
|
2584
|
+
const jev = oneLine(status.account?.jevQuota ?? 'Jev unavailable').replace(/^Jev(?= )/, status.jevEnabled === false ? 'Jev [Disabled] ·' : status.jevEnabled === true ? (status.jevOffThisRun ? 'Jev [Off this run] ·' : 'Jev [Enabled] ·') : 'Jev');
|
|
2559
2585
|
const jevWidth = Math.min(stringWidth(jev), width - 1);
|
|
2560
2586
|
const andorraUsage = this.andorraSegment();
|
|
2561
2587
|
const andorraText = andorraUsage?.forms.find(text => stringWidth(model) + 1 + stringWidth(text) + 3 + jevWidth <= width - 1);
|
package/dist/src/tool-catalog.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toolFamily } from './decision/toolFamilies.js';
|
|
2
2
|
import { canonicalToolName } from './tool-names.js';
|
|
3
3
|
import { identifierTokens } from './context-selection.js';
|
|
4
|
-
const PROTECTED = new Set(['complete_agent', 'complete', 'complete_task', 'submit_completion', 'update_todos', 'ask_user', 'load_project_skill', 'restore_tools', 'prepare_steps', 'update_widget', 'Skill', 'read_skill_resource', 'expand_tool_output', 'read_artifact', 'write_artifact']);
|
|
4
|
+
const PROTECTED = new Set(['complete_agent', 'complete', 'complete_task', 'submit_completion', 'update_todos', 'ask_user', 'submit_bug_report', 'load_project_skill', 'restore_tools', 'prepare_steps', 'update_widget', 'Skill', 'read_skill_resource', 'expand_tool_output', 'read_artifact', 'write_artifact']);
|
|
5
5
|
const GIT_WORDS = /\b(git|commit|branch|rebase|merge|stash|diff|blame|checkout|pull request|pr\b|push|history|log)\b/i;
|
|
6
6
|
const MEMORY_WORDS = /\b(remember|recall|memory|previous(ly)?|last time|earlier|convention|decision history)\b/i;
|
|
7
7
|
const WEB_WORDS = /\b(docs?|documentation|https?:\/\/|url|website|web|online|latest version|api reference|changelog|npm package|look up|search the)\b/i;
|
package/dist/src/trajectory.js
CHANGED
|
@@ -12,6 +12,10 @@ function capReply(reply) {
|
|
|
12
12
|
return `[REDACTED: unparsable reply naming a browser tool, ${reply.length} characters]`;
|
|
13
13
|
return reply.length <= UNPARSED_REPLY_LIMIT ? reply : `${reply.slice(0, UNPARSED_REPLY_LIMIT)}… [${reply.length - UNPARSED_REPLY_LIMIT} more characters]`;
|
|
14
14
|
}
|
|
15
|
+
function connectionCauseOf(error) {
|
|
16
|
+
const cause = error?.connectionCause;
|
|
17
|
+
return typeof cause === 'string' && /^[A-Z][A-Z0-9_]{0,63}$/.test(cause) ? cause : undefined;
|
|
18
|
+
}
|
|
15
19
|
function unparsedReplyOf(error) {
|
|
16
20
|
const reply = error && typeof error === 'object' ? error.unparsedReply : undefined;
|
|
17
21
|
return typeof reply === 'string' ? reply : undefined;
|
|
@@ -365,7 +369,7 @@ export async function createSessionTrajectory(options = {}) {
|
|
|
365
369
|
const started = performance.now();
|
|
366
370
|
const forward = request.onRetry;
|
|
367
371
|
const onRetry = async ({ unparsedReply, ...retry }) => {
|
|
368
|
-
await record('model.retry', { ...metadata, durationMs: performance.now() - started, retry: retry.retry, reason: retry.reason,
|
|
372
|
+
await record('model.retry', { ...metadata, durationMs: performance.now() - started, retry: retry.retry, reason: retry.reason, ...(retry.cause === undefined ? {} : { cause: retry.cause }),
|
|
369
373
|
...(unparsedReply === undefined ? {} : { unparsedReply: capReply(unparsedReply) }) });
|
|
370
374
|
await forward?.(retry);
|
|
371
375
|
};
|
|
@@ -379,6 +383,7 @@ export async function createSessionTrajectory(options = {}) {
|
|
|
379
383
|
await record('model.error', {
|
|
380
384
|
...metadata, durationMs: performance.now() - started, aborted: request.signal.aborted,
|
|
381
385
|
error: { name: error instanceof Error ? error.name : 'Error', message: error instanceof Error ? error.message : String(error),
|
|
386
|
+
...(connectionCauseOf(error) === undefined ? {} : { connectionCause: connectionCauseOf(error) }),
|
|
382
387
|
...(unparsedReplyOf(error) === undefined ? {} : { unparsedReply: capReply(unparsedReplyOf(error)) }) },
|
|
383
388
|
});
|
|
384
389
|
throw error;
|
package/dist/src/transcript.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export interface TranscriptEntry {
|
|
|
7
7
|
detail?: string;
|
|
8
8
|
toolCall?: ToolCallStamp;
|
|
9
9
|
clipRows?: boolean;
|
|
10
|
+
/** A line with the same key that is still the newest one is rewritten by this entry, not followed by it. */
|
|
11
|
+
replaceKey?: string;
|
|
10
12
|
}
|
|
11
13
|
export declare function transcriptColor(text: string): number | string;
|
|
12
14
|
export declare function formatAnswer(summary: string): TranscriptEntry;
|