@nyte-ai/plugin 0.0.0-stage → 0.0.18

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 (134) hide show
  1. package/LICENSE +21 -0
  2. package/THIRD-PARTY-NOTICES.md +800 -0
  3. package/dist/chunks/billing-0y7dfkp2.js +146 -0
  4. package/dist/chunks/billing-2v3g7rd9.js +190 -0
  5. package/dist/chunks/billing-3j77ss7y.js +86 -0
  6. package/dist/chunks/billing-3scqmkzb.js +559 -0
  7. package/dist/chunks/billing-6z2kgtyt.js +51 -0
  8. package/dist/chunks/billing-8rjk35gr.js +444 -0
  9. package/dist/chunks/billing-9mfedmsh.js +373 -0
  10. package/dist/chunks/billing-9nn3yp18.js +176 -0
  11. package/dist/chunks/billing-9qc0eqh4.js +174 -0
  12. package/dist/chunks/billing-a9vqn66p.js +351 -0
  13. package/dist/chunks/billing-bv5zr32b.js +369 -0
  14. package/dist/chunks/billing-cy1rg619.js +302 -0
  15. package/dist/chunks/billing-ejx2hv52.js +323 -0
  16. package/dist/chunks/billing-h13r0byk.js +80 -0
  17. package/dist/chunks/billing-j643d12p.js +197 -0
  18. package/dist/chunks/billing-k2p1t25n.js +109 -0
  19. package/dist/chunks/billing-kn3d30b4.js +276 -0
  20. package/dist/chunks/billing-mvc33pv6.js +36 -0
  21. package/dist/chunks/billing-s4rrspsk.js +7 -0
  22. package/dist/chunks/billing-svrhh5a5.js +307 -0
  23. package/dist/chunks/billing-sxc70w72.js +161 -0
  24. package/dist/chunks/billing-t1qrxe16.js +41 -0
  25. package/dist/chunks/billing-tzr3cebf.js +20 -0
  26. package/dist/chunks/billing-wmcbg6fw.js +52 -0
  27. package/dist/chunks/billing-wmkxkypm.js +527 -0
  28. package/dist/chunks/billing-ye3wk5r3.js +205 -0
  29. package/dist/chunks/billing-zfpm2rt0.js +29 -0
  30. package/dist/examples/claude-code/LICENSE +21 -0
  31. package/dist/examples/claude-code/billing.d.ts +7 -0
  32. package/dist/examples/claude-code/billing.js +11 -0
  33. package/dist/examples/claude-code/claude-cli.d.ts +35 -0
  34. package/dist/examples/claude-code/claude-cli.js +15 -0
  35. package/dist/examples/claude-code/env.d.ts +1 -0
  36. package/dist/examples/claude-code/env.js +6 -0
  37. package/dist/examples/claude-code/index.d.ts +24 -0
  38. package/dist/examples/claude-code/index.js +149 -0
  39. package/dist/examples/claude-code/inert-mcp.d.ts +1 -0
  40. package/dist/examples/claude-code/inert-mcp.js +6 -0
  41. package/dist/examples/claude-code/model-catalog.d.ts +27 -0
  42. package/dist/examples/claude-code/model-catalog.js +12 -0
  43. package/dist/examples/claude-code/process.d.ts +22 -0
  44. package/dist/examples/claude-code/process.js +25 -0
  45. package/dist/examples/claude-code/replay.d.ts +4 -0
  46. package/dist/examples/claude-code/replay.js +11 -0
  47. package/dist/examples/claude-code/stream.d.ts +3 -0
  48. package/dist/examples/claude-code/stream.js +16 -0
  49. package/dist/examples/claude-code/transcript.d.ts +83 -0
  50. package/dist/examples/claude-code/transcript.js +23 -0
  51. package/dist/examples/claude-code/turn-relay.d.ts +48 -0
  52. package/dist/examples/claude-code/turn-relay.js +9 -0
  53. package/dist/examples/claude-code/wire.d.ts +372 -0
  54. package/dist/examples/claude-code/wire.js +18 -0
  55. package/dist/src/acp/connection.d.ts +24 -0
  56. package/dist/src/acp/connection.js +8 -0
  57. package/dist/src/acp/index.d.ts +54 -0
  58. package/dist/src/acp/index.js +1004 -0
  59. package/dist/src/acp/registry.d.ts +18 -0
  60. package/dist/src/acp/registry.js +8 -0
  61. package/dist/src/acp/thread.d.ts +46 -0
  62. package/dist/src/acp/thread.js +7 -0
  63. package/dist/src/acp/transcript.d.ts +8 -0
  64. package/dist/src/acp/transcript.js +11 -0
  65. package/dist/src/acp/translate.d.ts +33 -0
  66. package/dist/src/acp/translate.js +20 -0
  67. package/dist/src/approvals/approvals.d.ts +189 -0
  68. package/dist/src/approvals/approvals.js +143 -0
  69. package/dist/src/approvals/schema.d.ts +169 -0
  70. package/dist/src/approvals/schema.js +18 -0
  71. package/dist/src/bash-description.d.ts +30 -0
  72. package/dist/src/bash-description.js +18 -0
  73. package/dist/src/browser-tools.d.ts +25 -0
  74. package/dist/src/browser-tools.js +246 -0
  75. package/dist/src/canvas/canvas-compile.d.ts +48 -0
  76. package/dist/src/canvas/canvas-compile.js +8 -0
  77. package/dist/src/canvas/canvas-libraries.d.ts +32 -0
  78. package/dist/src/canvas/canvas-libraries.js +6 -0
  79. package/dist/src/canvas/canvas-preview.d.ts +107 -0
  80. package/dist/src/canvas/canvas-preview.js +12 -0
  81. package/dist/src/canvas/canvas-protocol.d.ts +184 -0
  82. package/dist/src/canvas/canvas-protocol.js +75 -0
  83. package/dist/src/canvas/canvas.d.ts +50 -0
  84. package/dist/src/canvas/canvas.js +221 -0
  85. package/dist/src/canvas/schema.d.ts +47 -0
  86. package/dist/src/canvas/schema.js +8 -0
  87. package/dist/src/claude-code-sdk/index.d.ts +35 -0
  88. package/dist/src/claude-code-sdk/index.js +368 -0
  89. package/dist/src/claude-code-sdk/session.d.ts +48 -0
  90. package/dist/src/claude-code-sdk/session.js +7 -0
  91. package/dist/src/claude-code-sdk/transcript.d.ts +19 -0
  92. package/dist/src/claude-code-sdk/transcript.js +15 -0
  93. package/dist/src/claude-code-sdk/translate.d.ts +18 -0
  94. package/dist/src/claude-code-sdk/translate.js +20 -0
  95. package/dist/src/client/mount.d.ts +44 -0
  96. package/dist/src/client/mount.js +252 -0
  97. package/dist/src/client/notifications.d.ts +35 -0
  98. package/dist/src/client/notifications.js +26 -0
  99. package/dist/src/client/presentation.d.ts +336 -0
  100. package/dist/src/client/presentation.js +373 -0
  101. package/dist/src/client/transcript-tui.d.ts +23 -0
  102. package/dist/src/client/transcript-tui.js +20 -0
  103. package/dist/src/client/transcript.d.ts +23 -0
  104. package/dist/src/client/transcript.js +51 -0
  105. package/dist/src/client.d.ts +53 -0
  106. package/dist/src/client.js +22 -0
  107. package/dist/src/codemode-runtime.d.ts +11 -0
  108. package/dist/src/codemode-runtime.js +10 -0
  109. package/dist/src/codemode-worker.d.ts +1 -0
  110. package/dist/src/codemode-worker.js +2 -0
  111. package/dist/src/codemode.d.ts +21 -0
  112. package/dist/src/codemode.js +170 -0
  113. package/dist/src/core.d.ts +43 -0
  114. package/dist/src/core.js +11 -0
  115. package/dist/src/openai-astra-context.d.ts +23 -0
  116. package/dist/src/openai-astra-context.js +14 -0
  117. package/dist/src/openai-compaction.d.ts +15 -0
  118. package/dist/src/openai-compaction.js +55 -0
  119. package/dist/src/question/client/questions-tui.d.ts +9 -0
  120. package/dist/src/question/client/questions-tui.js +19 -0
  121. package/dist/src/question/client/questions.d.ts +9 -0
  122. package/dist/src/question/client/questions.js +160 -0
  123. package/dist/src/question/question.d.ts +63 -0
  124. package/dist/src/question/question.js +9 -0
  125. package/dist/src/question/schema.d.ts +101 -0
  126. package/dist/src/question/schema.js +14 -0
  127. package/dist/src/rename.d.ts +78 -0
  128. package/dist/src/rename.js +78 -0
  129. package/dist/src/telemetry.d.ts +36 -0
  130. package/dist/src/telemetry.js +84 -0
  131. package/dist/src/web-search.d.ts +78 -0
  132. package/dist/src/web-search.js +219 -0
  133. package/package.json +190 -3
  134. package/README.md +0 -3
@@ -0,0 +1,252 @@
1
+ // src/client/mount.ts
2
+ function derives(entry) {
3
+ return typeof entry === "function";
4
+ }
5
+ function registry(key, siblings) {
6
+ const items = new Set;
7
+ const derivations = new Set;
8
+ function add(entry) {
9
+ if (derives(entry)) {
10
+ derivations.add(entry);
11
+ return () => void derivations.delete(entry);
12
+ }
13
+ items.add(entry);
14
+ return () => void items.delete(entry);
15
+ }
16
+ return {
17
+ add,
18
+ list() {
19
+ const draft = new Map([...items].map((item) => [key(item), item]));
20
+ for (const derive of derivations)
21
+ derive({
22
+ set: (id, item) => void draft.set(id, item),
23
+ get: (id) => draft.get(id),
24
+ delete: (id) => void draft.delete(id),
25
+ ids: () => [...draft.keys()],
26
+ wrap: (id, wrap) => {
27
+ const inner = draft.get(id);
28
+ if (inner !== undefined)
29
+ draft.set(id, wrap(inner));
30
+ }
31
+ }, siblings());
32
+ return [...draft.values()];
33
+ }
34
+ };
35
+ }
36
+ function settingsRegistry(siblings) {
37
+ const base = registry((item) => item.id, siblings);
38
+ const values = new Map;
39
+ const listeners = new Map;
40
+ const current = (id) => {
41
+ const definition = base.list().find((item) => item.id === id);
42
+ if (definition === undefined)
43
+ throw new Error(`No setting is declared with id ${id}.`);
44
+ return values.has(id) ? values.get(id) : definition.default;
45
+ };
46
+ async function* watch(id) {
47
+ let pending = Promise.withResolvers();
48
+ const listener = (value) => pending.resolve(value);
49
+ const set = listeners.get(id) ?? new Set;
50
+ set.add(listener);
51
+ listeners.set(id, set);
52
+ try {
53
+ yield current(id);
54
+ for (;; ) {
55
+ const value = await pending.promise;
56
+ pending = Promise.withResolvers();
57
+ yield value;
58
+ }
59
+ } finally {
60
+ set.delete(listener);
61
+ }
62
+ }
63
+ function add(entry) {
64
+ if (derives(entry))
65
+ return base.add(entry);
66
+ const remove = base.add(entry);
67
+ return Object.assign(remove, {
68
+ get: async () => current(entry.id),
69
+ set: async (value) => {
70
+ values.set(entry.id, value);
71
+ for (const listener of listeners.get(entry.id) ?? [])
72
+ listener(value);
73
+ },
74
+ watch: () => watch(entry.id)
75
+ });
76
+ }
77
+ return { add, list: () => base.list(), value: async (id) => current(id), watch };
78
+ }
79
+ function memoryStorage(client) {
80
+ const values = new Map;
81
+ async function get(key) {
82
+ return values.get(key);
83
+ }
84
+ const storage = {
85
+ get,
86
+ set: async (key, value) => void values.set(key, value),
87
+ delete: async (key) => void values.delete(key),
88
+ keys: async () => [...values.keys()],
89
+ at: () => storage,
90
+ secrets: {
91
+ get: async () => {
92
+ return;
93
+ },
94
+ set: async () => {
95
+ throw new Error(`The ${client} client keeps no plugin secrets.`);
96
+ },
97
+ delete: async () => {
98
+ return;
99
+ }
100
+ }
101
+ };
102
+ return storage;
103
+ }
104
+ function causeMessage(cause) {
105
+ return cause instanceof Error ? cause.message : String(cause);
106
+ }
107
+ async function mountClientPlugins(options) {
108
+ const handlers = {
109
+ run_ended_anywhere: [],
110
+ app_ready: [],
111
+ session_opened: [],
112
+ before_submit: [],
113
+ session_closed: [],
114
+ app_closing: []
115
+ };
116
+ const controller = new AbortController;
117
+ const apis = [];
118
+ const register = (api, name, entry) => {
119
+ const handler = "run" in entry ? { order: entry.order ?? 0, run: entry.run, api } : { order: 0, run: entry, api };
120
+ const list = handlers[name];
121
+ list.push(handler);
122
+ list.sort((left, right) => left.order - right.order);
123
+ return () => {
124
+ const index = list.findIndex((candidate) => candidate === handler);
125
+ if (index !== -1)
126
+ list.splice(index, 1);
127
+ };
128
+ };
129
+ const context = (api, session, run) => ({
130
+ api,
131
+ signal: AbortSignal.any([controller.signal, AbortSignal.timeout(5000)]),
132
+ session,
133
+ head: null,
134
+ run
135
+ });
136
+ const reportFrom = (api, cause) => options.report(apis.find((entry) => entry.api === api)?.plugin.id ?? "plugin", causeMessage(cause));
137
+ const observe = async (list, event, session, run = null) => {
138
+ for (const handler of list) {
139
+ try {
140
+ await handler.run(event, context(handler.api, session, run));
141
+ } catch (cause) {
142
+ reportFrom(handler.api, cause);
143
+ }
144
+ }
145
+ };
146
+ for (const plugin of options.plugins) {
147
+ const registries = {
148
+ commands: registry((item) => item.name, () => registries),
149
+ settings: settingsRegistry(() => registries),
150
+ renderers: registry((item) => `${item.kind.kind}:${item.framework}`, () => registries),
151
+ keybindings: registry((item) => item.key, () => registries)
152
+ };
153
+ for (const command of plugin.contribute?.commands ?? [])
154
+ registries.commands.add(command);
155
+ for (const setting of plugin.contribute?.settings ?? [])
156
+ registries.settings.add(setting);
157
+ for (const renderer of plugin.contribute?.renderers ?? [])
158
+ registries.renderers.add(renderer);
159
+ for (const binding of plugin.contribute?.keybindings ?? [])
160
+ registries.keybindings.add(binding);
161
+ const api = {
162
+ side: "client",
163
+ sdk: options.connection,
164
+ contribute: registries,
165
+ storage: memoryStorage(options.client.name),
166
+ signal: controller.signal,
167
+ hook: (name, entry) => register(api, name, entry),
168
+ report: (issue) => options.report(plugin.id, issue.message),
169
+ reload: () => {
170
+ return;
171
+ },
172
+ client: options.client,
173
+ get session() {
174
+ return options.session();
175
+ },
176
+ ui: { notify: options.notify }
177
+ };
178
+ const hooks = plugin.hooks ?? {};
179
+ if (hooks.run_ended_anywhere !== undefined)
180
+ register(api, "run_ended_anywhere", hooks.run_ended_anywhere);
181
+ if (hooks.app_ready !== undefined)
182
+ register(api, "app_ready", hooks.app_ready);
183
+ if (hooks.session_opened !== undefined)
184
+ register(api, "session_opened", hooks.session_opened);
185
+ if (hooks.before_submit !== undefined)
186
+ register(api, "before_submit", hooks.before_submit);
187
+ if (hooks.session_closed !== undefined)
188
+ register(api, "session_closed", hooks.session_closed);
189
+ if (hooks.app_closing !== undefined)
190
+ register(api, "app_closing", hooks.app_closing);
191
+ apis.push({ plugin, api });
192
+ }
193
+ await Promise.all(apis.map(async ({ plugin, api }) => {
194
+ try {
195
+ await plugin.activate?.(api);
196
+ } catch (cause) {
197
+ options.report(plugin.id, causeMessage(cause));
198
+ }
199
+ }));
200
+ const renderers = new Map;
201
+ for (const { api } of apis)
202
+ for (const renderer of api.contribute.renderers.list())
203
+ if (options.client.frameworks.includes(renderer.framework) && !renderers.has(renderer.kind.kind))
204
+ renderers.set(renderer.kind.kind, renderer);
205
+ const ends = new Map;
206
+ let seeded = false;
207
+ await observe(handlers.app_ready, { restored: false }, null);
208
+ return {
209
+ ids: apis.map(({ plugin }) => plugin.id),
210
+ draw(session, message, placement) {
211
+ const renderer = renderers.get(message.partKind);
212
+ if (renderer === undefined)
213
+ return;
214
+ const part = session.part(message.part);
215
+ return renderer.render({ state: message.state, version: message.version, placement }, (action, input) => part.act(action, input));
216
+ },
217
+ sessionsChanged(sessions) {
218
+ for (const info of sessions) {
219
+ for (const head of info.heads) {
220
+ const key = `${info.id}/${head.name}`;
221
+ const last = head.execution.kind === "idle" ? head.execution.lastRun : null;
222
+ if (last === null || ends.get(key) === last.id)
223
+ continue;
224
+ ends.set(key, last.id);
225
+ if (seeded)
226
+ observe(handlers.run_ended_anywhere, { session: info.id, run: last.id, end: last.end }, info.id, last.id);
227
+ }
228
+ }
229
+ seeded = true;
230
+ },
231
+ async switched(previous, next) {
232
+ if (previous !== null)
233
+ await observe(handlers.session_closed, { session: previous }, previous.id);
234
+ await observe(handlers.session_opened, { session: next }, next.id);
235
+ },
236
+ async beforeSubmit(draft) {
237
+ for (const handler of handlers.before_submit) {
238
+ const decision = await handler.run(draft, context(handler.api, draft.session, null));
239
+ if (decision.action !== "continue")
240
+ return decision;
241
+ }
242
+ return { action: "continue" };
243
+ },
244
+ async dispose() {
245
+ await observe(handlers.app_closing, undefined, null);
246
+ controller.abort();
247
+ }
248
+ };
249
+ }
250
+ export {
251
+ mountClientPlugins
252
+ };
@@ -0,0 +1,35 @@
1
+ import type { RunEnd } from "@nyte-ai/schema";
2
+ /**
3
+ * Tells the user when a run ends in any session this client can see:
4
+ * finished, stopped, or failed with the reason. Sessions a parent spawned
5
+ * stay quiet, so a delegation does not ring once per child.
6
+ *
7
+ * @category plugins
8
+ * @since 0.1.0
9
+ */
10
+ declare const _default: {
11
+ id: string;
12
+ hooks: {
13
+ run_ended_anywhere: (event: Readonly<{
14
+ readonly session: import("@nyte-ai/schema").SessionId;
15
+ readonly run: import("@nyte-ai/schema").RunId;
16
+ readonly end: RunEnd;
17
+ }>, { api }: {
18
+ readonly api: {
19
+ readonly side: "client";
20
+ readonly sdk: import("@nyte-ai/core").Connection;
21
+ readonly contribute: import("@nyte-ai/core").Registries<"client">;
22
+ readonly storage: import("@nyte-ai/core").PluginStorage;
23
+ readonly signal: AbortSignal;
24
+ hook<N extends "run_ended_anywhere" | "app_ready" | "session_opened" | "before_submit" | "session_closed" | "app_closing">(name: N, entry: import("@nyte-ai/core").HookEntry<"client", N>): import("@nyte-ai/schema").Disposer;
25
+ report(issue: import("@nyte-ai/schema").ValidationIssue): void;
26
+ reload(): void;
27
+ } & import("@nyte-ai/plugin/client").ClientApi;
28
+ readonly signal: AbortSignal;
29
+ readonly session: import("@nyte-ai/schema").SessionId | null;
30
+ readonly head: import("@nyte-ai/schema").HeadName | null;
31
+ readonly run: import("@nyte-ai/schema").RunId | null;
32
+ }) => Promise<void>;
33
+ };
34
+ };
35
+ export default _default;
@@ -0,0 +1,26 @@
1
+ // src/client/notifications.ts
2
+ var notifications_default = {
3
+ id: "notifications",
4
+ hooks: {
5
+ run_ended_anywhere: async (event, { api }) => {
6
+ const info = await api.sdk.session(event.session).info();
7
+ if (info.parent !== null)
8
+ return;
9
+ const title = info.name ?? undefined;
10
+ const { end } = event;
11
+ if (end.kind === "completed")
12
+ api.ui.notify({ title, message: "Run finished", level: "info" });
13
+ else if (end.kind === "stopped")
14
+ api.ui.notify({ title, message: "Run stopped", level: "warning" });
15
+ else
16
+ api.ui.notify({ title, message: `Run failed: ${line(end)}`, level: "error" });
17
+ }
18
+ }
19
+ };
20
+ function line(end) {
21
+ const text = end.failure.message.replace(/\s+/g, " ").trim();
22
+ return text.length > 120 ? `${text.slice(0, 119)}…` : text;
23
+ }
24
+ export {
25
+ notifications_default as default
26
+ };
@@ -0,0 +1,336 @@
1
+ import { text, thinking } from "@nyte-ai/core";
2
+ import type { PartState } from "@nyte-ai/core";
3
+ import type { Execution, Failure, HeadInfo, Message, MessageSource, SessionInfo, ToolClass, ToolPartState, UserContent } from "@nyte-ai/schema";
4
+ /**
5
+ * A message the user sent, or one a child, job or action delivered for them.
6
+ *
7
+ * @category presentation
8
+ */
9
+ export type UserMessage = Extract<Message, {
10
+ readonly kind: "user";
11
+ }>;
12
+ /**
13
+ * A message that carries a part: text, thinking, a tool call or a plugin's part.
14
+ *
15
+ * @category presentation
16
+ */
17
+ export type PartMessage = Extract<Message, {
18
+ readonly kind: "part";
19
+ }>;
20
+ /**
21
+ * A part message holding a tool call.
22
+ *
23
+ * @category presentation
24
+ */
25
+ export type ToolMessage = PartMessage & {
26
+ readonly state: ToolPartState;
27
+ };
28
+ /**
29
+ * A part message holding assistant text.
30
+ *
31
+ * @category presentation
32
+ */
33
+ export type TextMessage = PartMessage & {
34
+ readonly state: PartState<typeof text>;
35
+ };
36
+ /**
37
+ * A part message holding the model's thinking.
38
+ *
39
+ * @category presentation
40
+ */
41
+ export type ThinkingMessage = PartMessage & {
42
+ readonly state: PartState<typeof thinking>;
43
+ };
44
+ /**
45
+ * A user message a child session or background job delivered as its report.
46
+ *
47
+ * @category presentation
48
+ */
49
+ export type ReportMessage = UserMessage & {
50
+ readonly source: Extract<MessageSource, {
51
+ readonly kind: "child" | "job";
52
+ }>;
53
+ };
54
+ /**
55
+ * Narrows to a tool call's part.
56
+ *
57
+ * @category presentation
58
+ */
59
+ export declare function showsTool(message: Message): message is ToolMessage;
60
+ /**
61
+ * Narrows to an assistant text part.
62
+ *
63
+ * @category presentation
64
+ */
65
+ export declare function showsText(message: Message): message is TextMessage;
66
+ /**
67
+ * Narrows to a thinking part.
68
+ *
69
+ * @category presentation
70
+ */
71
+ export declare function showsThinking(message: Message): message is ThinkingMessage;
72
+ /**
73
+ * A part a client has no renderer for, shown raw: the text its state carries
74
+ * as `markdown` or `text`, else its state as indented JSON.
75
+ *
76
+ * @category presentation
77
+ */
78
+ export type RawPart = {
79
+ readonly format: "text" | "json";
80
+ readonly body: string;
81
+ };
82
+ /**
83
+ * Reads a part's state raw, for a part kind or state shape this client does
84
+ * not know, such as one a newer host or an absent plugin sent.
85
+ *
86
+ * @category presentation
87
+ */
88
+ export declare function readRawPart(message: PartMessage): RawPart;
89
+ /**
90
+ * Narrows to the report a child or job delivered; a person or an action sent the rest.
91
+ *
92
+ * @category presentation
93
+ */
94
+ export declare function showsReport(message: UserMessage): message is ReportMessage;
95
+ /**
96
+ * What a user message shows: an action's label in place of the prompt it sent.
97
+ *
98
+ * @category presentation
99
+ */
100
+ export declare function shownContent(message: UserMessage): UserContent;
101
+ /**
102
+ * The tense a tool line speaks in: running, done, or none when the call did
103
+ * not finish and no verb would be true.
104
+ *
105
+ * @category presentation
106
+ */
107
+ export type ToolTense = "running" | "past" | "none";
108
+ /**
109
+ * The colour family of a tool line's state.
110
+ *
111
+ * @category presentation
112
+ */
113
+ export type ToolTone = "running" | "attention" | "success" | "failure" | "stopped";
114
+ /**
115
+ * The word a tool line adds after its subject when the outcome needs saying.
116
+ *
117
+ * @category presentation
118
+ */
119
+ export type ToolWord = "Needs input" | "Failed" | "Blocked" | "Stopped" | "Interrupted";
120
+ /**
121
+ * How every client shows a tool call's state; clients change only case and glyphs.
122
+ *
123
+ * @category presentation
124
+ */
125
+ export interface ToolStatus {
126
+ readonly tense: ToolTense;
127
+ readonly tone: ToolTone;
128
+ readonly word: ToolWord | undefined;
129
+ }
130
+ /**
131
+ * A settled call reads its outcome. An open call whose run failed was cut off,
132
+ * not failed by the tool: the user's stop reads "Stopped", anything else
133
+ * "Interrupted", and the turn's failure notice says why.
134
+ *
135
+ * @category presentation
136
+ */
137
+ export declare function toolStatus(message: Pick<ToolMessage, "state" | "status">): ToolStatus;
138
+ /**
139
+ * A settled call's text: its text content, failure message or rejection reason.
140
+ *
141
+ * @category presentation
142
+ */
143
+ export declare function toolOutput(state: ToolPartState): string;
144
+ /**
145
+ * The mark a session list draws for a head's execution.
146
+ *
147
+ * @category presentation
148
+ */
149
+ export type SessionMark = "waiting" | "retry" | "working" | "failed" | "idle";
150
+ /**
151
+ * The mark for an execution; a session without one is idle.
152
+ *
153
+ * @category presentation
154
+ */
155
+ export declare function executionMark(execution: Execution | undefined): SessionMark;
156
+ /**
157
+ * The head a session row speaks for: `main`, else the first.
158
+ *
159
+ * @category presentation
160
+ */
161
+ export declare function mainHead(session: Pick<SessionInfo, "heads">): HeadInfo | undefined;
162
+ /**
163
+ * The mark for a session's main head.
164
+ *
165
+ * @category presentation
166
+ */
167
+ export declare function sessionMark(session: Pick<SessionInfo, "heads">): SessionMark;
168
+ /**
169
+ * The text after a one-line draft's leading `/name `, while the caret is past
170
+ * it: `start` is where that text begins, `query` runs from there to the caret.
171
+ *
172
+ * @category presentation
173
+ */
174
+ export interface CommandArgument {
175
+ readonly command: string;
176
+ readonly start: number;
177
+ readonly query: string;
178
+ }
179
+ /**
180
+ * Finds the text a draft gives the command it starts with, or undefined when
181
+ * it starts with none, spans lines, or the caret is before that text.
182
+ *
183
+ * @category presentation
184
+ */
185
+ export declare function findCommandArgument(value: string, cursor: number): CommandArgument | undefined;
186
+ /**
187
+ * The `@` mention or `/` command the caret is in, with the word's bounds.
188
+ *
189
+ * @category presentation
190
+ */
191
+ export interface CompletionTrigger {
192
+ readonly kind: "@" | "/";
193
+ readonly start: number;
194
+ readonly end: number;
195
+ readonly query: string;
196
+ }
197
+ /**
198
+ * Finds the completion trigger around the caret, or undefined outside one.
199
+ *
200
+ * @category presentation
201
+ */
202
+ export declare function completionTrigger(value: string, cursor?: number): CompletionTrigger | undefined;
203
+ /**
204
+ * The verb for each tense that asserts one.
205
+ *
206
+ * @category presentation
207
+ */
208
+ export type ToolVerbs = Readonly<Record<Exclude<ToolTense, "none">, string>>;
209
+ type DelegateClass = Extract<ToolClass, {
210
+ readonly kind: "delegate";
211
+ }>;
212
+ /**
213
+ * How a custom tool reads: its verbs, and the name and server an MCP tool
214
+ * carries, or a fixed detail for a built-in.
215
+ *
216
+ * @category presentation
217
+ */
218
+ export interface CustomTool {
219
+ readonly verbs: ToolVerbs;
220
+ readonly name?: string;
221
+ readonly server?: string;
222
+ readonly detail?: string;
223
+ }
224
+ /**
225
+ * Reads a custom tool's label: a built-in's own words, an MCP tool's name and
226
+ * server, a phrase used as its own verb, or a bare name that "Ran".
227
+ *
228
+ * @category presentation
229
+ */
230
+ export declare function customTool(label: string): CustomTool;
231
+ /**
232
+ * The verbs a tool call speaks with.
233
+ *
234
+ * @category presentation
235
+ */
236
+ export declare function toolVerbs(toolClass: ToolClass): ToolVerbs;
237
+ /**
238
+ * What a verbless line adds after its subject so the tool stays named: a path
239
+ * alone does not say read from edit. A command or a custom tool needs nothing.
240
+ *
241
+ * @category presentation
242
+ */
243
+ export declare function toolNoun(toolClass: ToolClass): string | undefined;
244
+ /**
245
+ * The agent a delegate call names, "subagent" when the call gave no title.
246
+ *
247
+ * @category presentation
248
+ */
249
+ export declare function delegateSubject(toolClass: DelegateClass): string;
250
+ /**
251
+ * What a call acts on, in full: a path, a command, an agent's title, or a
252
+ * custom tool's name.
253
+ *
254
+ * @category presentation
255
+ */
256
+ export declare function toolSubject(toolClass: ToolClass): string | undefined;
257
+ /**
258
+ * One line naming a call: the tense's verb before the subject, or the subject
259
+ * and its noun when no verb is true. A custom tool without a name reads as its label.
260
+ *
261
+ * @category presentation
262
+ */
263
+ export declare function toolTitle(toolClass: ToolClass, tense: ToolTense, subject?: string | undefined): string;
264
+ /**
265
+ * A path relative to the working directory when it lies inside it.
266
+ *
267
+ * @category presentation
268
+ */
269
+ export declare function tidyPath(path: string, cwd: string | undefined): string;
270
+ /**
271
+ * The last segment of a path; the working directory reads as its own name.
272
+ *
273
+ * @category presentation
274
+ */
275
+ export declare function placeName(path: string, cwd: string | undefined): string;
276
+ /**
277
+ * A command on one line, without a leading `cd` into the working directory.
278
+ *
279
+ * @category presentation
280
+ */
281
+ export declare function condensedCommand(command: string, cwd: string | undefined): string;
282
+ /**
283
+ * An elapsed time as a tool or turn shows it: 4.2s, 42s, 5m 3s, 1h 12m. A
284
+ * negative span reads as zero.
285
+ *
286
+ * @category presentation
287
+ */
288
+ export declare function formatDuration(ms: number): string;
289
+ /**
290
+ * A span in whole seconds, as a settled turn's thinking or a retry countdown
291
+ * shows it: 42s, 5m, 5m 3s, 1h, 1h 12m. A negative span reads as zero.
292
+ *
293
+ * @category presentation
294
+ */
295
+ export declare function formatWholeDuration(ms: number): string;
296
+ /**
297
+ * A subject short enough for a narrow line, with the full one as `title`
298
+ * when they differ.
299
+ *
300
+ * @category presentation
301
+ */
302
+ export interface ToolDetail {
303
+ readonly text: string;
304
+ readonly title?: string;
305
+ }
306
+ /**
307
+ * The compact subject of a call, relative to the working directory.
308
+ *
309
+ * @category presentation
310
+ */
311
+ export declare function toolDetail(toolClass: ToolClass, cwd: string | undefined): ToolDetail | undefined;
312
+ /**
313
+ * The step that gets a failed run going again. Each client names it its own
314
+ * way: a command, a key or a settings page.
315
+ *
316
+ * @category presentation
317
+ */
318
+ export type Recovery = "compact" | "sign-in" | "switch-model";
319
+ /**
320
+ * What a failed run says: one sentence, its tone, and the step that recovers
321
+ * from it when the user has one to take.
322
+ *
323
+ * @category presentation
324
+ */
325
+ export interface FailureNotice {
326
+ readonly text: string;
327
+ readonly tone: "neutral" | "danger";
328
+ readonly recovery: Recovery | undefined;
329
+ }
330
+ /**
331
+ * The notice for a run's failure.
332
+ *
333
+ * @category presentation
334
+ */
335
+ export declare function failureNotice(failure: Failure): FailureNotice;
336
+ export {};