@nyte-ai/plugin 0.0.25-beta.1 → 0.0.25-nightly.20261101.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/THIRD-PARTY-NOTICES.md +49 -32
  2. package/dist/chunks/bash-description-0ah30s12.js +33 -0
  3. package/dist/chunks/bash-description-4h0hnsv4.js +68 -0
  4. package/dist/chunks/{bash-description-dnvgk30y.js → bash-description-4rfavmha.js} +32 -1
  5. package/dist/chunks/bash-description-5dpf5hpt.js +724 -0
  6. package/dist/chunks/{bash-description-yyd9jznf.js → bash-description-94km1hm2.js} +1 -1
  7. package/dist/chunks/{bash-description-svrhh5a5.js → bash-description-99k8z2r7.js} +3 -2
  8. package/dist/chunks/bash-description-9gw9ets8.js +162 -0
  9. package/dist/chunks/{bash-description-h13r0byk.js → bash-description-axnga0jz.js} +3 -3
  10. package/dist/chunks/bash-description-b78pre8c.js +147 -0
  11. package/dist/chunks/{bash-description-ye3wk5r3.js → bash-description-bas41ptb.js} +6 -24
  12. package/dist/chunks/{bash-description-2v3g7rd9.js → bash-description-bj5yh7tr.js} +26 -64
  13. package/dist/chunks/{bash-description-6z2kgtyt.js → bash-description-bkhr9zrz.js} +4 -4
  14. package/dist/chunks/{bash-description-hg64tqf1.js → bash-description-f754ge33.js} +49 -3
  15. package/dist/chunks/{bash-description-zz15raxk.js → bash-description-ff18794t.js} +1 -1
  16. package/dist/chunks/{bash-description-wmcbg6fw.js → bash-description-g7gfy7nw.js} +1 -1
  17. package/dist/chunks/{bash-description-1neewp76.js → bash-description-hp4rb8k4.js} +4 -3
  18. package/dist/chunks/bash-description-myvnmtt2.js +125 -0
  19. package/dist/chunks/{bash-description-9nn3yp18.js → bash-description-q2v8wbn8.js} +9 -1
  20. package/dist/chunks/bash-description-qwyy182r.js +452 -0
  21. package/dist/chunks/bash-description-rxpx004v.js +295 -0
  22. package/dist/chunks/{bash-description-eqp7ap2w.js → bash-description-z1581a29.js} +23 -9
  23. package/dist/src/acp/connection.d.ts +3 -1
  24. package/dist/src/acp/connection.js +3 -3
  25. package/dist/src/acp/index.d.ts +7 -4
  26. package/dist/src/acp/index.js +41 -8
  27. package/dist/src/acp/registry.d.ts +9 -0
  28. package/dist/src/acp/registry.js +5 -3
  29. package/dist/src/acp/thread.js +2 -2
  30. package/dist/src/acp/transcript.js +2 -2
  31. package/dist/src/acp/translate.d.ts +10 -2
  32. package/dist/src/acp/translate.js +3 -1
  33. package/dist/src/approvals/approvals.d.ts +1 -1
  34. package/dist/src/approvals/approvals.js +2 -2
  35. package/dist/src/approvals/schema.d.ts +3 -3
  36. package/dist/src/approvals/schema.js +1 -1
  37. package/dist/src/browser-tools.js +8 -2
  38. package/dist/src/canvas/canvas-compile.js +2 -2
  39. package/dist/src/canvas/canvas-preview.js +2 -2
  40. package/dist/src/canvas/canvas-protocol.d.ts +46 -0
  41. package/dist/src/canvas/canvas-protocol.js +11 -1
  42. package/dist/src/canvas/canvas.d.ts +17 -3
  43. package/dist/src/canvas/canvas.js +75 -31
  44. package/dist/src/canvas/schema.d.ts +28 -7
  45. package/dist/src/canvas/schema.js +2 -2
  46. package/dist/src/claude-code-sdk/index.d.ts +0 -10
  47. package/dist/src/claude-code-sdk/index.js +19 -179
  48. package/dist/src/claude-code-sdk/session.d.ts +22 -23
  49. package/dist/src/claude-code-sdk/session.js +6 -3
  50. package/dist/src/claude-code-sdk/transcript.d.ts +0 -6
  51. package/dist/src/claude-code-sdk/transcript.js +2 -4
  52. package/dist/src/claude-code-sdk/translate.d.ts +1 -5
  53. package/dist/src/claude-code-sdk/translate.js +2 -8
  54. package/dist/src/client/mount.d.ts +4 -2
  55. package/dist/src/client/mount.js +3 -0
  56. package/dist/src/client/notifications.d.ts +12 -4
  57. package/dist/src/client/notifications.js +25 -10
  58. package/dist/src/client/presentation.d.ts +138 -8
  59. package/dist/src/client/presentation.js +86 -371
  60. package/dist/src/codemode.js +151 -46
  61. package/dist/src/core.d.ts +1 -1
  62. package/dist/src/question/client/questions-tui.js +3 -3
  63. package/dist/src/question/client/questions.js +3 -3
  64. package/dist/src/question/question.js +84 -5
  65. package/dist/src/question/schema.js +3 -3
  66. package/dist/src/rename.d.ts +7 -35
  67. package/dist/src/rename.js +115 -48
  68. package/dist/src/subagents.d.ts +30 -0
  69. package/dist/src/subagents.js +323 -0
  70. package/dist/src/tool-search.d.ts +49 -0
  71. package/dist/src/tool-search.js +14 -0
  72. package/dist/src/web/body.d.ts +3 -0
  73. package/dist/src/web/body.js +6 -0
  74. package/dist/src/web/fetch.d.ts +16 -0
  75. package/dist/src/web/fetch.js +8 -0
  76. package/dist/src/web/html-markdown.d.ts +9 -0
  77. package/dist/src/web/html-markdown.js +10 -0
  78. package/dist/src/web/index.d.ts +24 -0
  79. package/dist/src/web/index.js +93 -0
  80. package/dist/src/web/providers.d.ts +60 -0
  81. package/dist/src/web/providers.js +11 -0
  82. package/dist/src/web/search.d.ts +21 -0
  83. package/dist/src/web/search.js +6 -0
  84. package/package.json +16 -7
  85. package/dist/chunks/bash-description-3j77ss7y.js +0 -86
  86. package/dist/chunks/bash-description-wbe8w0te.js +0 -530
  87. package/dist/src/web-search.d.ts +0 -78
  88. package/dist/src/web-search.js +0 -219
@@ -10,7 +10,7 @@ import {
10
10
  LIBRARY_EXPORTS2,
11
11
  canvasFilesComment2,
12
12
  KIT_EXPORTS2
13
- } from "./bash-description-dnvgk30y.js";
13
+ } from "./bash-description-4rfavmha.js";
14
14
 
15
15
  // src/canvas/canvas-compile.ts
16
16
  import { init, parse } from "es-module-lexer/minimal";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MIRROR_TOOL2
3
- } from "./bash-description-9nn3yp18.js";
3
+ } from "./bash-description-q2v8wbn8.js";
4
4
 
5
5
  // src/acp/transcript.ts
6
6
  var RESULT_LIMIT = 2000;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CANVAS_CODE_LIMIT2
3
- } from "./bash-description-dnvgk30y.js";
3
+ } from "./bash-description-4rfavmha.js";
4
4
 
5
5
  // src/canvas/schema.ts
6
6
  import { definePart } from "@nyte-ai/core";
@@ -11,7 +11,8 @@ var CANVAS_REVISIONS_KEPT2 = 50;
11
11
  var drawn = {
12
12
  runtime: Type.Integer({ minimum: 1 }),
13
13
  title: Type.String({ minLength: 1, maxLength: 120 }),
14
- height: Type.Union([Type.Number(), Type.Null()])
14
+ height: Type.Union([Type.Number(), Type.Null()]),
15
+ heights: Type.Optional(Type.Array(Type.Object({ width: Type.Integer({ minimum: 1 }), height: Type.Number({ minimum: 0 }) }), { maxItems: 8 }))
15
16
  };
16
17
  var revision = Type.Object({
17
18
  number: Type.Integer({ minimum: 1 }),
@@ -23,7 +24,7 @@ var state = standard(Type.Object({
23
24
  ...drawn,
24
25
  code: Type.String({ maxLength: CANVAS_CODE_LIMIT2 }),
25
26
  error: Type.Union([Type.String(), Type.Null()]),
26
- revisions: Type.Optional(Type.Array(revision, { maxItems: CANVAS_REVISIONS_KEPT2 }))
27
+ revisions: Type.Array(revision, { minItems: 1, maxItems: CANVAS_REVISIONS_KEPT2 })
27
28
  }));
28
29
  var actions = {
29
30
  replace: {
@@ -0,0 +1,125 @@
1
+ import {
2
+ readCapped2
3
+ } from "./bash-description-0ah30s12.js";
4
+ import {
5
+ htmlToMarkdown2,
6
+ htmlToText2
7
+ } from "./bash-description-5dpf5hpt.js";
8
+
9
+ // src/web/fetch.ts
10
+ import { attachFile } from "@nyte-ai/core";
11
+ import { standard } from "@nyte-ai/schema";
12
+ import { Type } from "typebox";
13
+ var MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
14
+ var INLINE_CHARS = 50 * 1024;
15
+ var MAX_REDIRECTS = 10;
16
+ var DEFAULT_TIMEOUT_SECONDS = 30;
17
+ var MAX_TIMEOUT_SECONDS = 120;
18
+ var USER_AGENT = "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko); compatible; Nyte/1.0; +https://nyte.sh";
19
+ var fetchParameters = Type.Object({
20
+ url: Type.String({ minLength: 1, description: "The http:// or https:// URL to fetch." }),
21
+ format: Type.Optional(Type.Union([Type.Literal("markdown"), Type.Literal("text"), Type.Literal("html")], {
22
+ description: "What to return the page as. Defaults to markdown."
23
+ })),
24
+ timeout: Type.Optional(Type.Number({
25
+ exclusiveMinimum: 0,
26
+ maximum: MAX_TIMEOUT_SECONDS,
27
+ description: `Seconds to wait, at most ${MAX_TIMEOUT_SECONDS}. Defaults to ${DEFAULT_TIMEOUT_SECONDS}.`
28
+ }))
29
+ });
30
+ var ACCEPT = {
31
+ markdown: "text/markdown;q=1.0, text/x-markdown;q=0.9, text/plain;q=0.8, text/html;q=0.7, */*;q=0.1",
32
+ text: "text/plain;q=1.0, text/markdown;q=0.9, text/html;q=0.8, */*;q=0.1",
33
+ html: "text/html;q=1.0, application/xhtml+xml;q=0.9, text/plain;q=0.8, text/markdown;q=0.7, */*;q=0.1"
34
+ };
35
+ function webFetch2(fetch) {
36
+ return {
37
+ name: "web_fetch",
38
+ description: "Fetch an http(s) URL and return it as markdown (the default), text or HTML; an image comes back as a file. Read-only. Prefer a more specific tool when one fits.",
39
+ parameters: standard(fetchParameters),
40
+ class: (args) => ({ kind: "custom", label: `Fetching ${args.url}` }),
41
+ effects: "none",
42
+ approval: "never",
43
+ replay: "safe",
44
+ async execute(args, invocation) {
45
+ const url = URL.parse(args.url);
46
+ if (url === null || url.protocol !== "http:" && url.protocol !== "https:")
47
+ throw new Error(`Fetch an http:// or https:// URL; ${args.url} isn't one.`);
48
+ const format = args.format ?? "markdown";
49
+ const seconds = args.timeout ?? DEFAULT_TIMEOUT_SECONDS;
50
+ const page = await invocation.memo("page", async () => {
51
+ const deadline = AbortSignal.timeout(seconds * 1000);
52
+ const signal = AbortSignal.any([invocation.signal, deadline]);
53
+ try {
54
+ const response = await follow(fetch, url, format, signal);
55
+ const mime = (response.headers.get("content-type") ?? "").split(";", 1)[0]?.trim().toLowerCase() ?? "";
56
+ if (mime.startsWith("image/") && mime !== "image/svg+xml" && mime !== "image/vnd.fastbidsheet") {
57
+ const bytes = await readCapped2(response, MAX_RESPONSE_BYTES);
58
+ const image = await attachFile(invocation.env.files, async function* () {
59
+ yield bytes;
60
+ }(), { mime });
61
+ return image.kind === "file" ? { kind: "image", blob: image.blob, mime } : image;
62
+ }
63
+ if (mime !== "" && !mime.startsWith("text/") && mime !== "application/json" && !mime.endsWith("+json") && mime !== "application/xml" && !mime.endsWith("+xml") && mime !== "application/javascript" && mime !== "application/x-javascript") {
64
+ await response.body?.cancel();
65
+ throw new Error(`${url.href} is ${mime}; web_fetch reads text, HTML and images.`);
66
+ }
67
+ const body = new TextDecoder().decode(await readCapped2(response, MAX_RESPONSE_BYTES));
68
+ const text = mime !== "text/html" || format === "html" ? body : format === "markdown" ? htmlToMarkdown2(body) : htmlToText2(body);
69
+ return {
70
+ kind: "text",
71
+ text: text.length > INLINE_CHARS ? `${text.slice(0, INLINE_CHARS)}
72
+
73
+ … Cut at ${INLINE_CHARS} of ${text.length} characters.` : text
74
+ };
75
+ } catch (error) {
76
+ if (deadline.aborted && !invocation.signal.aborted)
77
+ throw new Error(`${url.href} didn't answer within ${seconds} s.`, { cause: error });
78
+ throw error;
79
+ }
80
+ });
81
+ if (page.kind === "image")
82
+ return { content: [{ kind: "file", blob: page.blob, mime: page.mime }] };
83
+ return {
84
+ content: [{ kind: "text", text: page.text === "" ? "The page is empty." : page.text }]
85
+ };
86
+ }
87
+ };
88
+ }
89
+ async function follow(fetch, start, format, signal) {
90
+ let url = start;
91
+ for (let hop = 0;hop <= MAX_REDIRECTS; hop += 1) {
92
+ const response = await get(fetch, url, format, signal);
93
+ const location = response.headers.get("location");
94
+ if (response.status < 300 || response.status >= 400 || location === null) {
95
+ if (response.ok)
96
+ return response;
97
+ await response.body?.cancel();
98
+ throw new Error(`${url.href} answered HTTP ${response.status}${response.statusText === "" ? "" : ` ${response.statusText}`}.`);
99
+ }
100
+ await response.body?.cancel();
101
+ const next = new URL(location, url);
102
+ if (next.protocol !== "http:" && next.protocol !== "https:")
103
+ throw new Error(`${url.href} redirects to ${next.href}, which isn't http(s).`);
104
+ url = next;
105
+ }
106
+ throw new Error(`${start.href} redirects more than ${MAX_REDIRECTS} times.`);
107
+ }
108
+ async function get(fetch, url, format, signal) {
109
+ const send = (agent) => fetch(url, {
110
+ headers: {
111
+ "User-Agent": agent,
112
+ Accept: ACCEPT[format],
113
+ "Accept-Language": "en-US,en;q=0.9"
114
+ },
115
+ redirect: "manual",
116
+ signal
117
+ });
118
+ const response = await send(USER_AGENT);
119
+ if (response.status !== 403 || response.headers.get("cf-mitigated") !== "challenge")
120
+ return response;
121
+ await response.body?.cancel();
122
+ return send("nyte");
123
+ }
124
+
125
+ export { webFetch2 };
@@ -13,6 +13,14 @@ var mirrorArguments2 = Type.Object({
13
13
  input: Type.Record(Type.String(), Type.Unknown()),
14
14
  paths: Type.Array(Type.String())
15
15
  });
16
+ var count = Type.Optional(Type.Union([Type.Number(), Type.Null()]));
17
+ var agentUsage2 = Type.Object({
18
+ inputTokens: Type.Number(),
19
+ outputTokens: Type.Number(),
20
+ totalTokens: Type.Number(),
21
+ cachedReadTokens: count,
22
+ cachedWriteTokens: count
23
+ });
16
24
  var command = Type.Union([
17
25
  Type.String({ minLength: 1 }),
18
26
  Type.Array(Type.String(), { minItems: 1 })
@@ -173,4 +181,4 @@ class Translator2 {
173
181
  }
174
182
  }
175
183
 
176
- export { ACP_PROVIDER2, ACP_API2, MIRROR_TOOL2, mirrorArguments2, emptyMessage2, mirrorClass2, toolText2, Translator2 };
184
+ export { ACP_PROVIDER2, ACP_API2, MIRROR_TOOL2, mirrorArguments2, agentUsage2, emptyMessage2, mirrorClass2, toolText2, Translator2 };
@@ -0,0 +1,452 @@
1
+ // src/client/presentation.ts
2
+ import { isPart, text, thinking, tool } from "@nyte-ai/core";
3
+ import { jobTaskState as jobTaskState2 } from "@nyte-ai/schema";
4
+ function showsTool2(message) {
5
+ return isPart(message, tool);
6
+ }
7
+ function showsText2(message) {
8
+ return isPart(message, text);
9
+ }
10
+ function showsThinking2(message) {
11
+ return isPart(message, thinking);
12
+ }
13
+ function readRawPart2(message) {
14
+ const { state } = message;
15
+ if (typeof state === "object" && state !== null && !Array.isArray(state)) {
16
+ const prose = "markdown" in state ? state.markdown : ("text" in state) ? state.text : undefined;
17
+ if (typeof prose === "string")
18
+ return { format: "text", body: prose };
19
+ }
20
+ return { format: "json", body: state === undefined ? "null" : JSON.stringify(state, null, 2) };
21
+ }
22
+ function showsReport2(message) {
23
+ return message.source.kind === "child" || message.source.kind === "job";
24
+ }
25
+ function shownContent2(message) {
26
+ return message.source.kind === "action" ? message.source.label : message.content;
27
+ }
28
+ var RUNNING = { tense: "running", tone: "running", word: undefined };
29
+ function toolStatus2(message) {
30
+ const { state, status } = message;
31
+ if (state.phase !== "settled") {
32
+ if (status.kind === "failed")
33
+ return status.failure.class === "aborted" ? { tense: "none", tone: "stopped", word: "Stopped" } : { tense: "none", tone: "stopped", word: "Interrupted" };
34
+ if (status.kind === "waiting" && status.on.kind === "part")
35
+ return { tense: "running", tone: "attention", word: "Needs input" };
36
+ return RUNNING;
37
+ }
38
+ switch (state.outcome.kind) {
39
+ case "ok":
40
+ return { tense: "past", tone: "success", word: undefined };
41
+ case "failed":
42
+ return { tense: "none", tone: "failure", word: "Failed" };
43
+ case "rejected":
44
+ return { tense: "none", tone: "failure", word: "Blocked" };
45
+ case "stopped":
46
+ return { tense: "none", tone: "stopped", word: "Stopped" };
47
+ case "interrupted":
48
+ return { tense: "none", tone: "stopped", word: "Interrupted" };
49
+ default: {
50
+ const _exhaustive = state.outcome;
51
+ return _exhaustive;
52
+ }
53
+ }
54
+ }
55
+ function toolOutput2(state) {
56
+ if (state.phase !== "settled")
57
+ return "";
58
+ switch (state.outcome.kind) {
59
+ case "ok":
60
+ return state.outcome.content.flatMap((content) => content.kind === "text" && content.text !== "" ? [content.text] : []).join(`
61
+ `);
62
+ case "failed":
63
+ return state.outcome.message;
64
+ case "rejected":
65
+ return state.outcome.reason;
66
+ case "stopped":
67
+ case "interrupted":
68
+ return "";
69
+ default: {
70
+ const _exhaustive = state.outcome;
71
+ return _exhaustive;
72
+ }
73
+ }
74
+ }
75
+ function taskLabel2(state) {
76
+ return TASK_LABELS[state];
77
+ }
78
+ var TASK_LABELS = {
79
+ waiting: "Needs attention",
80
+ retrying: "Retrying",
81
+ working: "Working",
82
+ background: "Working in the background",
83
+ failed: "Failed",
84
+ done: "Done"
85
+ };
86
+ function callTaskState2(status) {
87
+ return CALL_STATES[status.tone];
88
+ }
89
+ var CALL_STATES = {
90
+ running: "working",
91
+ attention: "waiting",
92
+ failure: "failed",
93
+ success: "done",
94
+ stopped: "done"
95
+ };
96
+ function taskEnded2(state) {
97
+ return state === "done" || state === "failed";
98
+ }
99
+ function agentGroupSummary2(states) {
100
+ const total = states.length;
101
+ const going = states.filter((state) => !taskEnded2(state)).length;
102
+ const done = taskLabel2("done").toLowerCase();
103
+ if (going > 0)
104
+ return {
105
+ title: `Running ${String(total)} agents…`,
106
+ detail: going === total ? undefined : `(${String(total - going)} ${done})`
107
+ };
108
+ const failed = states.filter((state) => state === "failed").length;
109
+ return {
110
+ title: `${String(total)} agents ${done}`,
111
+ detail: failed === 0 ? undefined : `· ${String(failed)} ${taskLabel2("failed").toLowerCase()}`
112
+ };
113
+ }
114
+ var IDLE = { kind: "idle" };
115
+ function runStatus2(execution) {
116
+ switch (execution?.kind) {
117
+ case undefined:
118
+ return IDLE;
119
+ case "idle":
120
+ return execution.lastRun === null ? IDLE : endedStatus2(execution.lastRun.end);
121
+ case "live":
122
+ return { kind: "working", run: execution.run.id, stopping: execution.stopping };
123
+ case "waiting":
124
+ return execution.on.kind === "part" ? { kind: "waiting-for-approval", run: execution.run.id } : { kind: "working", run: execution.run.id, stopping: false };
125
+ case "retrying":
126
+ return { kind: "retrying", run: execution.run.id };
127
+ default: {
128
+ const _exhaustive = execution;
129
+ return _exhaustive;
130
+ }
131
+ }
132
+ }
133
+ function endedStatus2(end) {
134
+ switch (end.kind) {
135
+ case "completed":
136
+ return { kind: "completed" };
137
+ case "stopped":
138
+ return { kind: "stopped" };
139
+ case "failed":
140
+ return { kind: "failed", failure: end.failure };
141
+ default: {
142
+ const _exhaustive = end;
143
+ return _exhaustive;
144
+ }
145
+ }
146
+ }
147
+ function runMark2(status) {
148
+ switch (status.kind) {
149
+ case "idle":
150
+ case "completed":
151
+ case "stopped":
152
+ return "done";
153
+ case "failed":
154
+ return "failed";
155
+ case "working":
156
+ return "working";
157
+ case "retrying":
158
+ return "retrying";
159
+ case "waiting-for-approval":
160
+ return "waiting";
161
+ default: {
162
+ const _exhaustive = status;
163
+ return _exhaustive;
164
+ }
165
+ }
166
+ }
167
+ function rowMark2(status, background) {
168
+ if ("run" in status)
169
+ return runMark2(status);
170
+ if (background.waiting > 0)
171
+ return "waiting";
172
+ if (status.kind === "failed")
173
+ return "failed";
174
+ return background.working > 0 ? "background" : runMark2(status);
175
+ }
176
+ function backgroundLabel2(background) {
177
+ if (background.waiting > 0)
178
+ return `${taskLabel2("waiting")} in the background`;
179
+ return background.working > 0 ? `${String(background.working)} working in the background` : undefined;
180
+ }
181
+ function planningLabel2(planningMs) {
182
+ if (planningMs < PLANNING_DELAY_MS2)
183
+ return;
184
+ return planningMs < SLOW_PLANNING_MS2 ? PLANNING_LABEL2 : "Taking longer than expected…";
185
+ }
186
+ var PLANNING_LABEL2 = "Planning next moves";
187
+ var PLANNING_DELAY_MS2 = 200;
188
+ var SLOW_PLANNING_MS2 = 15000;
189
+ function executionMark2(execution) {
190
+ return runMark2(runStatus2(execution));
191
+ }
192
+ function mainHead2(session) {
193
+ return session.heads.find((head) => head.name === "main") ?? session.heads[0];
194
+ }
195
+ function sessionMark2(session) {
196
+ const head = mainHead2(session);
197
+ return head === undefined ? "done" : rowMark2(runStatus2(head.execution), head.background);
198
+ }
199
+ function sessionTitle2(session) {
200
+ return session.name ?? (session.parent === null ? "New chat" : SUBAGENT_TITLE2);
201
+ }
202
+ var SUBAGENT_TITLE2 = "Subagent";
203
+ var COMMAND_ARGUMENT = /^[ \t]*\/([a-z0-9][a-z0-9-]*)[ \t]+/u;
204
+ function findCommandArgument2(value, cursor) {
205
+ const found = COMMAND_ARGUMENT.exec(value);
206
+ const command = found?.[1];
207
+ if (found === null || command === undefined || /[\r\n]/u.test(value))
208
+ return;
209
+ const start = found[0].length;
210
+ return cursor < start ? undefined : { command, start, query: value.slice(start, cursor) };
211
+ }
212
+ function completionTrigger2(value, cursor = value.length) {
213
+ const caret = Math.max(0, Math.min(cursor, value.length));
214
+ let start = caret;
215
+ while (start > 0 && (value[start - 1] ?? "").trim() !== "")
216
+ start -= 1;
217
+ const kind = value[start];
218
+ if (start === caret || kind !== "@" && kind !== "/")
219
+ return;
220
+ let end = caret;
221
+ while (end < value.length && (value[end] ?? "").trim() !== "")
222
+ end += 1;
223
+ return { kind, start, end, query: value.slice(start + 1, caret) };
224
+ }
225
+ var RAN = { running: "Running", past: "Ran" };
226
+ var CLASS_VERBS = {
227
+ read: { running: "Reading", past: "Read" },
228
+ list: { running: "Listing", past: "Listed" },
229
+ edit: { running: "Editing", past: "Edited" },
230
+ shell: RAN
231
+ };
232
+ var DELEGATE_VERBS = {
233
+ task: { running: "Delegating", past: "Delegated" },
234
+ create: { running: "Creating", past: "Created" },
235
+ send: { running: "Messaging", past: "Messaged" },
236
+ await: { running: "Waiting on", past: "Waited on" },
237
+ read: { running: "Reading transcript", past: "Read transcript" },
238
+ stop: { running: "Stopping", past: "Stopped" }
239
+ };
240
+ var DELEGATE_NOUNS = {
241
+ task: "agent",
242
+ create: "agent",
243
+ send: "message",
244
+ await: "wait",
245
+ read: "transcript",
246
+ stop: "stop"
247
+ };
248
+ var NAMED_TOOLS = new Map([
249
+ ["codemode", { verbs: { running: "Running script", past: "Ran script" } }],
250
+ ["tool_search", { verbs: { running: "Exploring", past: "Explored" }, detail: "available tools" }],
251
+ ["websearch", { verbs: { running: "Searching web", past: "Searched web" } }],
252
+ ["web_search", { verbs: { running: "Searching web", past: "Searched web" } }],
253
+ ["webfetch", { verbs: { running: "Fetching page", past: "Fetched page" } }],
254
+ ["web_fetch", { verbs: { running: "Fetching page", past: "Fetched page" } }],
255
+ ["rename_chat", { verbs: { running: "Renaming chat", past: "Renamed chat" } }],
256
+ ["browser_open", { verbs: { running: "Opening page", past: "Opened page" } }],
257
+ ["browser_click", { verbs: { running: "Clicking", past: "Clicked" } }],
258
+ ["browser_type", { verbs: { running: "Typing", past: "Typed" } }],
259
+ ["browser_press", { verbs: { running: "Pressing key", past: "Pressed key" } }],
260
+ ["browser_scroll", { verbs: { running: "Scrolling", past: "Scrolled" } }],
261
+ ["browser_wait", { verbs: { running: "Waiting", past: "Waited" } }],
262
+ ["browser_snapshot", { verbs: { running: "Taking snapshot", past: "Took snapshot" } }],
263
+ [
264
+ "browser_console",
265
+ { verbs: { running: "Checking console logs", past: "Checked console logs" } }
266
+ ],
267
+ ["browser_evaluate", { verbs: { running: "Executing JS", past: "Executed JS" } }]
268
+ ]);
269
+ var MCP_LABEL = /^(?<server>[^:\s]+): (?<name>\S+)$/u;
270
+ var MCP_NAME = /^mcp__(?<server>.+?)__(?<name>.+)$/u;
271
+ function customTool2(label) {
272
+ const named = NAMED_TOOLS.get(label);
273
+ if (named !== undefined)
274
+ return named;
275
+ const mcp = (MCP_LABEL.exec(label) ?? MCP_NAME.exec(label))?.groups;
276
+ if (mcp?.server !== undefined && mcp.name !== undefined)
277
+ return { verbs: RAN, name: mcp.name, server: mcp.server };
278
+ if (/\s/u.test(label))
279
+ return { verbs: { running: label, past: label } };
280
+ return { verbs: RAN, name: label };
281
+ }
282
+ function customDetail(custom) {
283
+ if (custom.name === undefined)
284
+ return custom.detail;
285
+ return custom.server === undefined ? custom.name : `${custom.name} in ${custom.server}`;
286
+ }
287
+ function toolVerbs2(toolClass) {
288
+ switch (toolClass.kind) {
289
+ case "read":
290
+ case "list":
291
+ case "edit":
292
+ case "shell":
293
+ return CLASS_VERBS[toolClass.kind];
294
+ case "delegate":
295
+ return DELEGATE_VERBS[toolClass.role];
296
+ case "custom":
297
+ return customTool2(toolClass.label).verbs;
298
+ default: {
299
+ const _exhaustive = toolClass;
300
+ return _exhaustive;
301
+ }
302
+ }
303
+ }
304
+ function toolNoun2(toolClass) {
305
+ switch (toolClass.kind) {
306
+ case "read":
307
+ case "list":
308
+ case "edit":
309
+ return toolClass.kind;
310
+ case "delegate":
311
+ return DELEGATE_NOUNS[toolClass.role];
312
+ case "shell":
313
+ case "custom":
314
+ return;
315
+ default: {
316
+ const _exhaustive = toolClass;
317
+ return _exhaustive;
318
+ }
319
+ }
320
+ }
321
+ function delegateSubject2(toolClass) {
322
+ return toolClass.title ?? "subagent";
323
+ }
324
+ function toolSubject2(toolClass) {
325
+ switch (toolClass.kind) {
326
+ case "read":
327
+ case "list":
328
+ case "edit":
329
+ return toolClass.path;
330
+ case "shell":
331
+ return toolClass.command;
332
+ case "delegate":
333
+ return delegateSubject2(toolClass);
334
+ case "custom":
335
+ return customDetail(customTool2(toolClass.label));
336
+ default: {
337
+ const _exhaustive = toolClass;
338
+ return _exhaustive;
339
+ }
340
+ }
341
+ }
342
+ function toolTitle2(toolClass, tense, subject = toolSubject2(toolClass)) {
343
+ if (tense !== "none") {
344
+ const verb = toolVerbs2(toolClass)[tense];
345
+ return subject === undefined ? verb : `${verb} ${subject}`;
346
+ }
347
+ if (toolClass.kind === "custom" && customTool2(toolClass.label).name === undefined)
348
+ return toolClass.label;
349
+ return [subject, toolNoun2(toolClass)].filter((word) => word !== undefined).join(" ");
350
+ }
351
+ function tidyPath2(path, cwd) {
352
+ if (cwd !== undefined && path.startsWith(`${cwd}/`))
353
+ return path.slice(cwd.length + 1);
354
+ return path;
355
+ }
356
+ function basename(path) {
357
+ return path.split(/[\\/]/u).at(-1) ?? path;
358
+ }
359
+ function placeName2(path, cwd) {
360
+ const tidy = tidyPath2(path, cwd);
361
+ if (tidy === "." || tidy === "./" || tidy === cwd)
362
+ return basename(cwd ?? tidy) || tidy;
363
+ return basename(tidy.replace(/[\\/]+$/u, "")) || tidy;
364
+ }
365
+ function condensedCommand2(command, cwd) {
366
+ const compact = command.replaceAll(/\s+/gu, " ").trim();
367
+ if (cwd === undefined)
368
+ return compact;
369
+ const prefix = [cwd, `"${cwd}"`, `'${cwd}'`].flatMap((dir) => [`cd ${dir} && `, `cd ${dir}; `]).find((candidate) => compact.startsWith(candidate));
370
+ return prefix === undefined ? compact : compact.slice(prefix.length);
371
+ }
372
+ function formatDuration2(ms) {
373
+ const seconds = Math.max(0, ms) / 1000;
374
+ if (seconds < 10)
375
+ return `${seconds.toFixed(1)}s`;
376
+ if (seconds < 60)
377
+ return `${String(Math.floor(seconds))}s`;
378
+ const minutes = Math.floor(seconds / 60);
379
+ if (minutes < 60)
380
+ return `${String(minutes)}m ${String(Math.floor(seconds % 60))}s`;
381
+ return `${String(Math.floor(minutes / 60))}h ${String(minutes % 60)}m`;
382
+ }
383
+ function formatWholeDuration2(ms) {
384
+ const seconds = Math.max(0, Math.round(ms / 1000));
385
+ const minutes = Math.floor(seconds / 60);
386
+ const hours = Math.floor(minutes / 60);
387
+ if (hours > 0)
388
+ return minutes % 60 === 0 ? `${String(hours)}h` : `${String(hours)}h ${String(minutes % 60)}m`;
389
+ if (minutes > 0)
390
+ return seconds % 60 === 0 ? `${String(minutes)}m` : `${String(minutes)}m ${String(seconds % 60)}s`;
391
+ return `${String(seconds)}s`;
392
+ }
393
+ function toolDetail2(toolClass, cwd) {
394
+ switch (toolClass.kind) {
395
+ case "edit": {
396
+ const title = tidyPath2(toolClass.path, cwd);
397
+ return { text: basename(title), title };
398
+ }
399
+ case "read":
400
+ case "list":
401
+ return { text: placeName2(toolClass.path, cwd), title: tidyPath2(toolClass.path, cwd) };
402
+ case "shell":
403
+ return { text: condensedCommand2(toolClass.command, cwd) };
404
+ case "delegate":
405
+ return { text: delegateSubject2(toolClass) };
406
+ case "custom": {
407
+ const detail = customDetail(customTool2(toolClass.label));
408
+ return detail === undefined ? undefined : { text: detail };
409
+ }
410
+ default: {
411
+ const _exhaustive = toolClass;
412
+ return _exhaustive;
413
+ }
414
+ }
415
+ }
416
+ var NOTICE_LIMIT = 180;
417
+ function oneLine(message) {
418
+ const compact = message.replaceAll(/\s+/gu, " ").trim();
419
+ if (compact === "")
420
+ return;
421
+ return compact.length <= NOTICE_LIMIT ? compact : `${compact.slice(0, NOTICE_LIMIT - 1).trimEnd()}…`;
422
+ }
423
+ function danger(notice, recovery) {
424
+ return { text: notice, tone: "danger", recovery };
425
+ }
426
+ function failureNotice2(failure) {
427
+ switch (failure.class) {
428
+ case "aborted":
429
+ return { text: "Run stopped.", tone: "neutral", recovery: undefined };
430
+ case "rate_limit":
431
+ return danger("Rate limit reached. Try again shortly.");
432
+ case "context_window":
433
+ return danger("This chat no longer fits the model's context window.", "compact");
434
+ case "quota":
435
+ return danger("Provider quota reached.", "switch-model");
436
+ case "auth":
437
+ return danger("The provider rejected the sign-in.", "sign-in");
438
+ case "overloaded":
439
+ return danger("The model is temporarily unavailable. Try again shortly.");
440
+ case "network":
441
+ return danger("Connection lost. Check your network and try again.");
442
+ case "provider":
443
+ case "runner":
444
+ return danger(oneLine(failure.message) ?? "Request failed.");
445
+ default: {
446
+ const _exhaustive = failure.class;
447
+ return _exhaustive;
448
+ }
449
+ }
450
+ }
451
+
452
+ export { showsTool2, showsText2, showsThinking2, readRawPart2, showsReport2, shownContent2, toolStatus2, toolOutput2, taskLabel2, callTaskState2, taskEnded2, agentGroupSummary2, runStatus2, endedStatus2, runMark2, rowMark2, backgroundLabel2, planningLabel2, PLANNING_LABEL2, PLANNING_DELAY_MS2, SLOW_PLANNING_MS2, executionMark2, mainHead2, sessionMark2, sessionTitle2, SUBAGENT_TITLE2, findCommandArgument2, completionTrigger2, customTool2, toolVerbs2, toolNoun2, delegateSubject2, toolSubject2, toolTitle2, tidyPath2, placeName2, condensedCommand2, formatDuration2, formatWholeDuration2, toolDetail2, failureNotice2, jobTaskState2 };