@nyte-ai/plugin 0.0.0-stage → 0.0.19

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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/THIRD-PARTY-NOTICES.md +866 -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-4vz9pxyx.js +22 -0
  8. package/dist/chunks/billing-6z2kgtyt.js +51 -0
  9. package/dist/chunks/billing-8rjk35gr.js +444 -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-hg64tqf1.js +97 -0
  18. package/dist/chunks/billing-j643d12p.js +197 -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-tm34gm2p.js +528 -0
  26. package/dist/chunks/billing-tzr3cebf.js +20 -0
  27. package/dist/chunks/billing-v3hg5rc7.js +373 -0
  28. package/dist/chunks/billing-wmcbg6fw.js +52 -0
  29. package/dist/chunks/billing-ye3wk5r3.js +205 -0
  30. package/dist/chunks/billing-zfpm2rt0.js +29 -0
  31. package/dist/examples/claude-code/LICENSE +21 -0
  32. package/dist/examples/claude-code/billing.d.ts +7 -0
  33. package/dist/examples/claude-code/billing.js +11 -0
  34. package/dist/examples/claude-code/claude-cli.d.ts +35 -0
  35. package/dist/examples/claude-code/claude-cli.js +15 -0
  36. package/dist/examples/claude-code/env.d.ts +1 -0
  37. package/dist/examples/claude-code/env.js +6 -0
  38. package/dist/examples/claude-code/index.d.ts +24 -0
  39. package/dist/examples/claude-code/index.js +149 -0
  40. package/dist/examples/claude-code/inert-mcp.d.ts +1 -0
  41. package/dist/examples/claude-code/inert-mcp.js +6 -0
  42. package/dist/examples/claude-code/model-catalog.d.ts +27 -0
  43. package/dist/examples/claude-code/model-catalog.js +12 -0
  44. package/dist/examples/claude-code/process.d.ts +22 -0
  45. package/dist/examples/claude-code/process.js +25 -0
  46. package/dist/examples/claude-code/replay.d.ts +4 -0
  47. package/dist/examples/claude-code/replay.js +11 -0
  48. package/dist/examples/claude-code/stream.d.ts +3 -0
  49. package/dist/examples/claude-code/stream.js +16 -0
  50. package/dist/examples/claude-code/transcript.d.ts +83 -0
  51. package/dist/examples/claude-code/transcript.js +23 -0
  52. package/dist/examples/claude-code/turn-relay.d.ts +48 -0
  53. package/dist/examples/claude-code/turn-relay.js +9 -0
  54. package/dist/examples/claude-code/wire.d.ts +372 -0
  55. package/dist/examples/claude-code/wire.js +18 -0
  56. package/dist/src/acp/connection.d.ts +24 -0
  57. package/dist/src/acp/connection.js +8 -0
  58. package/dist/src/acp/index.d.ts +54 -0
  59. package/dist/src/acp/index.js +1005 -0
  60. package/dist/src/acp/registry.d.ts +18 -0
  61. package/dist/src/acp/registry.js +9 -0
  62. package/dist/src/acp/thread.d.ts +46 -0
  63. package/dist/src/acp/thread.js +7 -0
  64. package/dist/src/acp/transcript.d.ts +8 -0
  65. package/dist/src/acp/transcript.js +11 -0
  66. package/dist/src/acp/translate.d.ts +33 -0
  67. package/dist/src/acp/translate.js +20 -0
  68. package/dist/src/approvals/approvals.d.ts +189 -0
  69. package/dist/src/approvals/approvals.js +143 -0
  70. package/dist/src/approvals/schema.d.ts +169 -0
  71. package/dist/src/approvals/schema.js +18 -0
  72. package/dist/src/bash-description.d.ts +30 -0
  73. package/dist/src/bash-description.js +18 -0
  74. package/dist/src/browser-tools.d.ts +25 -0
  75. package/dist/src/browser-tools.js +246 -0
  76. package/dist/src/canvas/canvas-compile.d.ts +48 -0
  77. package/dist/src/canvas/canvas-compile.js +8 -0
  78. package/dist/src/canvas/canvas-libraries.d.ts +32 -0
  79. package/dist/src/canvas/canvas-libraries.js +6 -0
  80. package/dist/src/canvas/canvas-preview.d.ts +107 -0
  81. package/dist/src/canvas/canvas-preview.js +12 -0
  82. package/dist/src/canvas/canvas-protocol.d.ts +184 -0
  83. package/dist/src/canvas/canvas-protocol.js +75 -0
  84. package/dist/src/canvas/canvas.d.ts +50 -0
  85. package/dist/src/canvas/canvas.js +221 -0
  86. package/dist/src/canvas/schema.d.ts +47 -0
  87. package/dist/src/canvas/schema.js +8 -0
  88. package/dist/src/claude-code-sdk/index.d.ts +35 -0
  89. package/dist/src/claude-code-sdk/index.js +379 -0
  90. package/dist/src/claude-code-sdk/session.d.ts +50 -0
  91. package/dist/src/claude-code-sdk/session.js +7 -0
  92. package/dist/src/claude-code-sdk/transcript.d.ts +19 -0
  93. package/dist/src/claude-code-sdk/transcript.js +15 -0
  94. package/dist/src/claude-code-sdk/translate.d.ts +18 -0
  95. package/dist/src/claude-code-sdk/translate.js +20 -0
  96. package/dist/src/client/mount.d.ts +44 -0
  97. package/dist/src/client/mount.js +252 -0
  98. package/dist/src/client/notifications.d.ts +36 -0
  99. package/dist/src/client/notifications.js +24 -0
  100. package/dist/src/client/presentation.d.ts +362 -0
  101. package/dist/src/client/presentation.js +391 -0
  102. package/dist/src/client/transcript-tui.d.ts +23 -0
  103. package/dist/src/client/transcript-tui.js +20 -0
  104. package/dist/src/client/transcript.d.ts +23 -0
  105. package/dist/src/client/transcript.js +51 -0
  106. package/dist/src/client.d.ts +53 -0
  107. package/dist/src/client.js +22 -0
  108. package/dist/src/codemode-runtime.d.ts +11 -0
  109. package/dist/src/codemode-runtime.js +10 -0
  110. package/dist/src/codemode-worker.d.ts +1 -0
  111. package/dist/src/codemode-worker.js +2 -0
  112. package/dist/src/codemode.d.ts +21 -0
  113. package/dist/src/codemode.js +170 -0
  114. package/dist/src/core.d.ts +43 -0
  115. package/dist/src/core.js +11 -0
  116. package/dist/src/find-on-path.d.ts +4 -0
  117. package/dist/src/find-on-path.js +8 -0
  118. package/dist/src/openai-astra-context.d.ts +23 -0
  119. package/dist/src/openai-astra-context.js +14 -0
  120. package/dist/src/openai-compaction.d.ts +15 -0
  121. package/dist/src/openai-compaction.js +55 -0
  122. package/dist/src/question/client/questions-tui.d.ts +9 -0
  123. package/dist/src/question/client/questions-tui.js +19 -0
  124. package/dist/src/question/client/questions.d.ts +9 -0
  125. package/dist/src/question/client/questions.js +160 -0
  126. package/dist/src/question/question.d.ts +63 -0
  127. package/dist/src/question/question.js +9 -0
  128. package/dist/src/question/schema.d.ts +101 -0
  129. package/dist/src/question/schema.js +14 -0
  130. package/dist/src/rename.d.ts +79 -0
  131. package/dist/src/rename.js +91 -0
  132. package/dist/src/telemetry.d.ts +36 -0
  133. package/dist/src/telemetry.js +84 -0
  134. package/dist/src/web-search.d.ts +78 -0
  135. package/dist/src/web-search.js +219 -0
  136. package/package.json +190 -3
  137. 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,36 @@
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, or failed with the reason. A stopped run stays quiet because
5
+ * someone asked for it, and so do sessions a parent spawned, so a delegation
6
+ * does not ring once per child.
7
+ *
8
+ * @category plugins
9
+ * @since 0.1.0
10
+ */
11
+ declare const _default: {
12
+ id: string;
13
+ hooks: {
14
+ run_ended_anywhere: (event: Readonly<{
15
+ readonly session: import("@nyte-ai/schema").SessionId;
16
+ readonly run: import("@nyte-ai/schema").RunId;
17
+ readonly end: RunEnd;
18
+ }>, { api }: {
19
+ readonly api: {
20
+ readonly side: "client";
21
+ readonly sdk: import("@nyte-ai/core").Connection;
22
+ readonly contribute: import("@nyte-ai/core").Registries<"client">;
23
+ readonly storage: import("@nyte-ai/core").PluginStorage;
24
+ readonly signal: AbortSignal;
25
+ 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;
26
+ report(issue: import("@nyte-ai/schema").ValidationIssue): void;
27
+ reload(): void;
28
+ } & import("@nyte-ai/plugin/client").ClientApi;
29
+ readonly signal: AbortSignal;
30
+ readonly session: import("@nyte-ai/schema").SessionId | null;
31
+ readonly head: import("@nyte-ai/schema").HeadName | null;
32
+ readonly run: import("@nyte-ai/schema").RunId | null;
33
+ }) => Promise<void>;
34
+ };
35
+ };
36
+ export default _default;
@@ -0,0 +1,24 @@
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 === "failed")
14
+ api.ui.notify({ title, message: `Run failed: ${line(end)}`, level: "error" });
15
+ }
16
+ }
17
+ };
18
+ function line(end) {
19
+ const text = end.failure.message.replace(/\s+/g, " ").trim();
20
+ return text.length > 120 ? `${text.slice(0, 119)}…` : text;
21
+ }
22
+ export {
23
+ notifications_default as default
24
+ };
@@ -0,0 +1,362 @@
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, UserStatus } 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
+ type PendingStatus = Extract<UserStatus, {
96
+ readonly kind: "pending";
97
+ }>;
98
+ /**
99
+ * A message that waits in the queue: unsent, or pending for a later turn. A pending steer sent
100
+ * while idle or joining the live run is never one.
101
+ *
102
+ * @category presentation
103
+ */
104
+ export type QueuedMessage = UserMessage & {
105
+ readonly status: Extract<UserStatus, {
106
+ readonly kind: "unsent";
107
+ }> | (PendingStatus & {
108
+ readonly schedule: Exclude<PendingStatus["schedule"], {
109
+ readonly kind: "joined";
110
+ }>;
111
+ });
112
+ };
113
+ /**
114
+ * Whether a message waits in the queue rather than showing in the transcript. A retrying send
115
+ * always waits. Reports, joined steers and steers sent while idle stay in the transcript.
116
+ * Other messages wait only while a run is active.
117
+ *
118
+ * @category presentation
119
+ */
120
+ export declare function waitsInQueue(message: UserMessage, running: boolean): message is QueuedMessage;
121
+ /**
122
+ * What a user message shows: an action's label in place of the prompt it sent.
123
+ *
124
+ * @category presentation
125
+ */
126
+ export declare function shownContent(message: UserMessage): UserContent;
127
+ /**
128
+ * The tense a tool line speaks in: running, done, or none when the call did
129
+ * not finish and no verb would be true.
130
+ *
131
+ * @category presentation
132
+ */
133
+ export type ToolTense = "running" | "past" | "none";
134
+ /**
135
+ * The colour family of a tool line's state.
136
+ *
137
+ * @category presentation
138
+ */
139
+ export type ToolTone = "running" | "attention" | "success" | "failure" | "stopped";
140
+ /**
141
+ * The word a tool line adds after its subject when the outcome needs saying.
142
+ *
143
+ * @category presentation
144
+ */
145
+ export type ToolWord = "Needs input" | "Failed" | "Blocked" | "Stopped" | "Interrupted";
146
+ /**
147
+ * How every client shows a tool call's state; clients change only case and glyphs.
148
+ *
149
+ * @category presentation
150
+ */
151
+ export interface ToolStatus {
152
+ readonly tense: ToolTense;
153
+ readonly tone: ToolTone;
154
+ readonly word: ToolWord | undefined;
155
+ }
156
+ /**
157
+ * A settled call reads its outcome. An open call whose run failed was cut off,
158
+ * not failed by the tool: the user's stop reads "Stopped", anything else
159
+ * "Interrupted", and the turn's failure notice says why.
160
+ *
161
+ * @category presentation
162
+ */
163
+ export declare function toolStatus(message: Pick<ToolMessage, "state" | "status">): ToolStatus;
164
+ /**
165
+ * A settled call's text: its text content, failure message or rejection reason.
166
+ *
167
+ * @category presentation
168
+ */
169
+ export declare function toolOutput(state: ToolPartState): string;
170
+ /**
171
+ * The mark a session list draws for a head's execution.
172
+ *
173
+ * @category presentation
174
+ */
175
+ export type SessionMark = "waiting" | "retry" | "working" | "failed" | "idle";
176
+ /**
177
+ * The mark for an execution; a session without one is idle.
178
+ *
179
+ * @category presentation
180
+ */
181
+ export declare function executionMark(execution: Execution | undefined): SessionMark;
182
+ /**
183
+ * The head a session row speaks for: `main`, else the first.
184
+ *
185
+ * @category presentation
186
+ */
187
+ export declare function mainHead(session: Pick<SessionInfo, "heads">): HeadInfo | undefined;
188
+ /**
189
+ * The mark for a session's main head.
190
+ *
191
+ * @category presentation
192
+ */
193
+ export declare function sessionMark(session: Pick<SessionInfo, "heads">): SessionMark;
194
+ /**
195
+ * The text after a one-line draft's leading `/name `, while the caret is past
196
+ * it: `start` is where that text begins, `query` runs from there to the caret.
197
+ *
198
+ * @category presentation
199
+ */
200
+ export interface CommandArgument {
201
+ readonly command: string;
202
+ readonly start: number;
203
+ readonly query: string;
204
+ }
205
+ /**
206
+ * Finds the text a draft gives the command it starts with, or undefined when
207
+ * it starts with none, spans lines, or the caret is before that text.
208
+ *
209
+ * @category presentation
210
+ */
211
+ export declare function findCommandArgument(value: string, cursor: number): CommandArgument | undefined;
212
+ /**
213
+ * The `@` mention or `/` command the caret is in, with the word's bounds.
214
+ *
215
+ * @category presentation
216
+ */
217
+ export interface CompletionTrigger {
218
+ readonly kind: "@" | "/";
219
+ readonly start: number;
220
+ readonly end: number;
221
+ readonly query: string;
222
+ }
223
+ /**
224
+ * Finds the completion trigger around the caret, or undefined outside one.
225
+ *
226
+ * @category presentation
227
+ */
228
+ export declare function completionTrigger(value: string, cursor?: number): CompletionTrigger | undefined;
229
+ /**
230
+ * The verb for each tense that asserts one.
231
+ *
232
+ * @category presentation
233
+ */
234
+ export type ToolVerbs = Readonly<Record<Exclude<ToolTense, "none">, string>>;
235
+ type DelegateClass = Extract<ToolClass, {
236
+ readonly kind: "delegate";
237
+ }>;
238
+ /**
239
+ * How a custom tool reads: its verbs, and the name and server an MCP tool
240
+ * carries, or a fixed detail for a built-in.
241
+ *
242
+ * @category presentation
243
+ */
244
+ export interface CustomTool {
245
+ readonly verbs: ToolVerbs;
246
+ readonly name?: string;
247
+ readonly server?: string;
248
+ readonly detail?: string;
249
+ }
250
+ /**
251
+ * Reads a custom tool's label: a built-in's own words, an MCP tool's name and
252
+ * server, a phrase used as its own verb, or a bare name that "Ran".
253
+ *
254
+ * @category presentation
255
+ */
256
+ export declare function customTool(label: string): CustomTool;
257
+ /**
258
+ * The verbs a tool call speaks with.
259
+ *
260
+ * @category presentation
261
+ */
262
+ export declare function toolVerbs(toolClass: ToolClass): ToolVerbs;
263
+ /**
264
+ * What a verbless line adds after its subject so the tool stays named: a path
265
+ * alone does not say read from edit. A command or a custom tool needs nothing.
266
+ *
267
+ * @category presentation
268
+ */
269
+ export declare function toolNoun(toolClass: ToolClass): string | undefined;
270
+ /**
271
+ * The agent a delegate call names, "subagent" when the call gave no title.
272
+ *
273
+ * @category presentation
274
+ */
275
+ export declare function delegateSubject(toolClass: DelegateClass): string;
276
+ /**
277
+ * What a call acts on, in full: a path, a command, an agent's title, or a
278
+ * custom tool's name.
279
+ *
280
+ * @category presentation
281
+ */
282
+ export declare function toolSubject(toolClass: ToolClass): string | undefined;
283
+ /**
284
+ * One line naming a call: the tense's verb before the subject, or the subject
285
+ * and its noun when no verb is true. A custom tool without a name reads as its label.
286
+ *
287
+ * @category presentation
288
+ */
289
+ export declare function toolTitle(toolClass: ToolClass, tense: ToolTense, subject?: string | undefined): string;
290
+ /**
291
+ * A path relative to the working directory when it lies inside it.
292
+ *
293
+ * @category presentation
294
+ */
295
+ export declare function tidyPath(path: string, cwd: string | undefined): string;
296
+ /**
297
+ * The last segment of a path; the working directory reads as its own name.
298
+ *
299
+ * @category presentation
300
+ */
301
+ export declare function placeName(path: string, cwd: string | undefined): string;
302
+ /**
303
+ * A command on one line, without a leading `cd` into the working directory.
304
+ *
305
+ * @category presentation
306
+ */
307
+ export declare function condensedCommand(command: string, cwd: string | undefined): string;
308
+ /**
309
+ * An elapsed time as a tool or turn shows it: 4.2s, 42s, 5m 3s, 1h 12m. A
310
+ * negative span reads as zero.
311
+ *
312
+ * @category presentation
313
+ */
314
+ export declare function formatDuration(ms: number): string;
315
+ /**
316
+ * A span in whole seconds, as a settled turn's thinking or a retry countdown
317
+ * shows it: 42s, 5m, 5m 3s, 1h, 1h 12m. A negative span reads as zero.
318
+ *
319
+ * @category presentation
320
+ */
321
+ export declare function formatWholeDuration(ms: number): string;
322
+ /**
323
+ * A subject short enough for a narrow line, with the full one as `title`
324
+ * when they differ.
325
+ *
326
+ * @category presentation
327
+ */
328
+ export interface ToolDetail {
329
+ readonly text: string;
330
+ readonly title?: string;
331
+ }
332
+ /**
333
+ * The compact subject of a call, relative to the working directory.
334
+ *
335
+ * @category presentation
336
+ */
337
+ export declare function toolDetail(toolClass: ToolClass, cwd: string | undefined): ToolDetail | undefined;
338
+ /**
339
+ * The step that gets a failed run going again. Each client names it its own
340
+ * way: a command, a key or a settings page.
341
+ *
342
+ * @category presentation
343
+ */
344
+ export type Recovery = "compact" | "sign-in" | "switch-model";
345
+ /**
346
+ * What a failed run says: one sentence, its tone, and the step that recovers
347
+ * from it when the user has one to take.
348
+ *
349
+ * @category presentation
350
+ */
351
+ export interface FailureNotice {
352
+ readonly text: string;
353
+ readonly tone: "neutral" | "danger";
354
+ readonly recovery: Recovery | undefined;
355
+ }
356
+ /**
357
+ * The notice for a run's failure.
358
+ *
359
+ * @category presentation
360
+ */
361
+ export declare function failureNotice(failure: Failure): FailureNotice;
362
+ export {};