@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
@@ -1,530 +0,0 @@
1
- import {
2
- BACKGROUND_TOOL2,
3
- NYTE_SERVER2,
4
- NYTE_TOOL_PREFIX2,
5
- emptyMessage3,
6
- mirrorCall2,
7
- Translator3
8
- } from "./bash-description-ye3wk5r3.js";
9
-
10
- // src/claude-code-sdk/session.ts
11
- import { randomUUID } from "node:crypto";
12
- import { createSdkMcpServer } from "@anthropic-ai/claude-agent-sdk";
13
- import { createAssistantMessageEventStream } from "@nyte-ai/ai";
14
- import { Type } from "typebox";
15
- import { Value } from "typebox/value";
16
- var ALLOW = { behavior: "allow" };
17
- var SKIPPED = "Nyte did not run this tool call.";
18
- var toolUseId = Type.String({ minLength: 1 });
19
- var toolInput = Type.Record(Type.String(), Type.Unknown());
20
- var APPROVAL_HOOK_SECONDS = 7 * 24 * 60 * 60;
21
-
22
- class Inbox {
23
- #items = [];
24
- #waiter;
25
- #ended = false;
26
- has(match) {
27
- return this.#items.some(match);
28
- }
29
- push(item) {
30
- this.#items.push(item);
31
- this.#wake();
32
- }
33
- clear() {
34
- this.#items.length = 0;
35
- }
36
- end() {
37
- this.#ended = true;
38
- this.#wake();
39
- }
40
- async next() {
41
- while (this.#items.length === 0 && !this.#ended)
42
- await new Promise((resolve) => this.#waiter = resolve);
43
- return this.#items.shift();
44
- }
45
- async* [Symbol.asyncIterator]() {
46
- for (;; ) {
47
- const item = await this.next();
48
- if (item === undefined)
49
- return;
50
- yield item;
51
- }
52
- }
53
- #wake() {
54
- const waiter = this.#waiter;
55
- this.#waiter = undefined;
56
- waiter?.();
57
- }
58
- }
59
- function toolError(text) {
60
- return { content: [{ type: "text", text }], isError: true };
61
- }
62
- function reply(message) {
63
- return {
64
- content: message.content.map((block) => block.type === "text" ? { type: "text", text: block.text } : { type: "image", data: block.data, mimeType: block.mimeType }),
65
- isError: message.isError
66
- };
67
- }
68
- function resultText(content) {
69
- if (!Array.isArray(content))
70
- return content ?? "";
71
- return content.map((block) => block.type === "text" ? block.text : `[${block.type} content]`).join(`
72
- `);
73
- }
74
- function storePath(key) {
75
- return key.subpath === undefined ? key.sessionId : `${key.sessionId}/${key.subpath}`;
76
- }
77
- function memoryStore(session, history) {
78
- const files = new Map([[session, [...history]]]);
79
- return {
80
- append: async (key, entries) => {
81
- files.set(storePath(key), [...files.get(storePath(key)) ?? [], ...entries]);
82
- },
83
- load: async (key) => files.get(storePath(key)) ?? null
84
- };
85
- }
86
-
87
- class ClaudeCodeSession2 {
88
- key;
89
- known = [];
90
- #prompts = new Inbox;
91
- #turn = new Inbox;
92
- #results = new Map;
93
- #questions = new Map;
94
- #asking = new Set;
95
- #changes = new Set;
96
- #replies = new Map;
97
- #gates = new Map;
98
- #permits = new Map;
99
- #approve;
100
- #server;
101
- #query;
102
- #tools;
103
- #order = [];
104
- #settings;
105
- #background = [];
106
- #notes = [];
107
- #idle = true;
108
- #held = false;
109
- #stderr = "";
110
- #failure;
111
- constructor(launch) {
112
- this.key = launch.key;
113
- this.#settings = { effort: launch.effort, ultracode: launch.ultracode };
114
- this.#tools = launch.tools;
115
- this.#approve = launch.approve;
116
- const session = launch.session;
117
- this.#server = createSdkMcpServer({ name: NYTE_SERVER2, tools: [] });
118
- this.#server.instance.server.registerCapabilities({ tools: { listChanged: true } });
119
- this.#server.instance.server.fallbackRequestHandler = async (request, extra) => {
120
- if (request.method === "tools/list")
121
- return {
122
- tools: this.#tools.map((tool) => ({
123
- name: tool.name,
124
- description: tool.description,
125
- inputSchema: { ...tool.parameters, type: "object" }
126
- }))
127
- };
128
- if (request.method !== "tools/call")
129
- throw new Error(`Nyte does not serve ${request.method}.`);
130
- const { _meta: meta } = extra;
131
- const id = meta?.["claudecode/toolUseId"];
132
- return Value.Check(toolUseId, id) ? await this.#call(id, extra.signal) : toolError("Claude Code sent no tool use id for this Nyte tool call.");
133
- };
134
- const options = {
135
- model: launch.model,
136
- cwd: launch.cwd,
137
- systemPrompt: { type: "preset", preset: "claude_code" },
138
- includePartialMessages: true,
139
- mcpServers: { [NYTE_SERVER2]: this.#server },
140
- disallowedTools: ["Bash"],
141
- allowedTools: ["Grep", "Glob"],
142
- permissionMode: "default",
143
- canUseTool: async (name, input, { signal, toolUseID, agentID }) => {
144
- if (name.startsWith(NYTE_TOOL_PREFIX2))
145
- return agentID === undefined ? ALLOW : { behavior: "deny", message: "Only the main agent can use Nyte's tools." };
146
- if (name === "AskUserQuestion") {
147
- if (agentID !== undefined)
148
- return { behavior: "deny", message: "Only the main agent can ask the user questions." };
149
- const answers = await this.#question(toolUseID, signal);
150
- return answers === null ? { behavior: "deny", message: "The user did not answer." } : { behavior: "allow", updatedInput: { ...input, answers } };
151
- }
152
- return await this.#permit(toolUseID, name, input, agentID === undefined, signal);
153
- },
154
- hooks: {
155
- PreToolUse: [
156
- {
157
- hooks: [(input, _id, { signal }) => this.#beforeTool(input, signal)],
158
- timeout: APPROVAL_HOOK_SECONDS
159
- }
160
- ]
161
- },
162
- thinking: launch.thinking ? { type: "adaptive", display: "summarized" } : { type: "disabled" },
163
- env: {
164
- ...process.env,
165
- ...launch.env,
166
- CLAUDE_AGENT_SDK_CLIENT_APP: "nyte",
167
- CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1"
168
- },
169
- stderr: (chunk) => this.#stderr = (this.#stderr + chunk).slice(-4096),
170
- pathToClaudeCodeExecutable: launch.claude
171
- };
172
- if (launch.effort !== undefined)
173
- options.effort = launch.effort;
174
- if (launch.ultracode)
175
- options.settings = { ultracode: true, enableWorkflows: true };
176
- if (launch.history.length > 0) {
177
- options.resume = session;
178
- options.sessionStore = memoryStore(session, launch.history);
179
- }
180
- this.#query = launch.query({ prompt: this.#prompts, options });
181
- this.#pump();
182
- }
183
- get closed() {
184
- return this.#failure !== undefined;
185
- }
186
- async configure(effort, ultracode) {
187
- if (this.#settings.effort === effort && this.#settings.ultracode === ultracode)
188
- return;
189
- this.#settings = { effort, ultracode };
190
- await this.#query.applyFlagSettings({
191
- effortLevel: effort ?? null,
192
- ultracode: ultracode ? true : null,
193
- enableWorkflows: ultracode ? true : null
194
- });
195
- }
196
- expose(tools) {
197
- if (JSON.stringify(tools) === JSON.stringify(this.#tools))
198
- return;
199
- this.#tools = tools;
200
- this.#server.instance.sendToolListChanged();
201
- }
202
- deliver(messages) {
203
- for (const message of messages) {
204
- if (message.role !== "toolResult")
205
- continue;
206
- const id = message.toolCallId;
207
- if (this.#replies.has(id))
208
- this.#reply(id).resolve(reply(message));
209
- else
210
- this.#gates.get(id)?.resolve({
211
- behavior: "deny",
212
- message: message.content.flatMap((block) => block.type === "text" ? [block.text] : []).join(`
213
- `) || SKIPPED
214
- });
215
- }
216
- }
217
- recording(id) {
218
- const position = this.#order.findIndex((known) => known === id);
219
- for (const [index, earlier] of this.#order.entries()) {
220
- if (index > position)
221
- break;
222
- this.#gate(earlier).resolve(index === position ? ALLOW : { behavior: "deny", message: SKIPPED });
223
- }
224
- }
225
- send(content) {
226
- if (this.#idle)
227
- this.#turn.clear();
228
- this.#idle = false;
229
- this.#held = false;
230
- this.#prompts.push({
231
- type: "user",
232
- message: { role: "user", content: [...content] },
233
- parent_tool_use_id: null,
234
- origin: { kind: "human" }
235
- });
236
- }
237
- respond(model, signal) {
238
- const stream = createAssistantMessageEventStream();
239
- const output = emptyMessage3(model);
240
- const translator = new Translator3(model, output, stream);
241
- const abort = () => this.close(new Error("Request was aborted"));
242
- signal?.addEventListener("abort", abort, { once: true });
243
- (async () => {
244
- try {
245
- stream.push({ type: "start", partial: output });
246
- let failure;
247
- for (;; ) {
248
- const item = await this.#turn.next();
249
- if (item === undefined)
250
- throw this.#failure ?? new Error("Claude Code exited.");
251
- if (item.type === "system") {
252
- if (item.state !== "idle" || !this.#held)
253
- continue;
254
- this.#held = false;
255
- this.#idle = true;
256
- if (output.stopReason === "pending")
257
- output.stopReason = "stop";
258
- break;
259
- }
260
- if (item.type === "result" && this.#held)
261
- continue;
262
- if (item.type === "assistant") {
263
- if (item.error !== undefined)
264
- failure = item.message.content.flatMap((block) => block.type === "text" ? [block.text] : []).join(`
265
- `);
266
- continue;
267
- }
268
- if (item.type === "result") {
269
- if (item.subtype !== "success")
270
- throw new Error(failure ?? (item.errors.join(`
271
- `) || `Claude Code failed: ${item.subtype}`));
272
- if (item.is_error)
273
- throw new Error(failure ?? item.result);
274
- this.#idle = true;
275
- if (output.stopReason === "pending")
276
- output.stopReason = "stop";
277
- break;
278
- }
279
- this.#held = false;
280
- const stop = translator.apply(item.event);
281
- if (stop === "tool_use") {
282
- if (output.content.some((block) => block.type === "toolCall"))
283
- break;
284
- continue;
285
- }
286
- if (stop !== undefined && this.#background.length > 0) {
287
- translator.append(mirrorCall2(`claude-code-background-${randomUUID()}`, BACKGROUND_TOOL2, {
288
- tasks: [...this.#background]
289
- }));
290
- output.stopReason = "toolUse";
291
- this.#held = true;
292
- break;
293
- }
294
- }
295
- if (output.stopReason === "error")
296
- throw new Error(output.errorMessage ?? "Claude Code failed.");
297
- if (output.stopReason === "aborted" || output.stopReason === "pending")
298
- throw new Error("Claude Code ended without a response.");
299
- stream.push({ type: "done", reason: output.stopReason, message: output });
300
- } catch (error) {
301
- output.stopReason = signal?.aborted === true ? "aborted" : "error";
302
- output.errorMessage = error instanceof Error ? error.message : String(error);
303
- stream.push({ type: "error", reason: output.stopReason, error: output });
304
- this.close(error instanceof Error ? error : new Error(String(error)));
305
- } finally {
306
- signal?.removeEventListener("abort", abort);
307
- stream.end();
308
- }
309
- })();
310
- return stream;
311
- }
312
- get asking() {
313
- return this.#asking.size > 0;
314
- }
315
- answer(id, answers) {
316
- this.#pending(id).resolve(answers);
317
- }
318
- async result(id, signal) {
319
- await this.#until(() => this.#results.has(id), signal);
320
- const output = this.#results.get(id);
321
- if (output === undefined)
322
- throw this.#failure ?? new Error("Claude Code is no longer running this turn.");
323
- return output;
324
- }
325
- async background(signal) {
326
- await this.#until(() => this.#turn.has((item) => item.type === "stream_event" || item.type === "system"), signal);
327
- if (this.#failure !== undefined)
328
- throw this.#failure;
329
- const notes = this.#notes.splice(0);
330
- return notes.length === 0 ? "Background work finished." : notes.join(`
331
-
332
- `);
333
- }
334
- close(reason = new Error("Claude Code closed.")) {
335
- if (this.#failure !== undefined)
336
- return;
337
- this.#failure = reason;
338
- for (const pending of this.#questions.values())
339
- pending.resolve(null);
340
- for (const pending of this.#replies.values())
341
- pending.resolve(toolError(reason.message));
342
- for (const pending of this.#gates.values())
343
- pending.resolve({ behavior: "deny", message: reason.message });
344
- this.#prompts.end();
345
- this.#turn.end();
346
- this.#query.close();
347
- this.#changed();
348
- }
349
- #pending(id) {
350
- const known = this.#questions.get(id);
351
- if (known !== undefined)
352
- return known;
353
- const created = Promise.withResolvers();
354
- this.#questions.set(id, created);
355
- return created;
356
- }
357
- async#question(id, signal) {
358
- const pending = this.#pending(id);
359
- const cancel = () => this.answer(id, null);
360
- this.#asking.add(id);
361
- signal.addEventListener("abort", cancel, { once: true });
362
- try {
363
- return await pending.promise;
364
- } finally {
365
- this.#asking.delete(id);
366
- signal.removeEventListener("abort", cancel);
367
- }
368
- }
369
- #reply(id) {
370
- const known = this.#replies.get(id);
371
- if (known !== undefined)
372
- return known;
373
- const created = Promise.withResolvers();
374
- this.#replies.set(id, created);
375
- return created;
376
- }
377
- #gate(id) {
378
- const known = this.#gates.get(id);
379
- if (known !== undefined)
380
- return known;
381
- const created = Promise.withResolvers();
382
- this.#gates.set(id, created);
383
- return created;
384
- }
385
- async#call(id, signal) {
386
- const pending = this.#reply(id);
387
- const cancel = () => pending.resolve(toolError("Request was aborted"));
388
- signal.addEventListener("abort", cancel, { once: true });
389
- try {
390
- return await pending.promise;
391
- } finally {
392
- this.#replies.delete(id);
393
- signal.removeEventListener("abort", cancel);
394
- }
395
- }
396
- #permit(id, name, input, main, signal) {
397
- const known = this.#permits.get(id);
398
- if (known !== undefined)
399
- return known;
400
- const decided = (async () => {
401
- if (main) {
402
- const recorded = await this.#recorded(id, signal);
403
- if (recorded.behavior === "deny")
404
- return recorded;
405
- }
406
- return this.#approve(name, input, signal);
407
- })();
408
- this.#permits.set(id, decided);
409
- return decided;
410
- }
411
- async#beforeTool(input, signal) {
412
- if (input.hook_event_name !== "PreToolUse" || input.tool_name.startsWith(NYTE_TOOL_PREFIX2) || input.tool_name === "AskUserQuestion")
413
- return {};
414
- const decided = await this.#permit(input.tool_use_id, input.tool_name, Value.Check(toolInput, input.tool_input) ? input.tool_input : {}, input.agent_id === undefined, signal);
415
- return decided.behavior === "allow" ? {} : {
416
- hookSpecificOutput: {
417
- hookEventName: "PreToolUse",
418
- permissionDecision: "deny",
419
- permissionDecisionReason: decided.message
420
- }
421
- };
422
- }
423
- async#recorded(id, signal) {
424
- const pending = this.#gate(id);
425
- const cancel = () => pending.resolve({ behavior: "deny", message: "Request was aborted" });
426
- signal.addEventListener("abort", cancel, { once: true });
427
- try {
428
- return await pending.promise;
429
- } finally {
430
- signal.removeEventListener("abort", cancel);
431
- }
432
- }
433
- async#until(ready, signal) {
434
- while (!ready() && this.#failure === undefined) {
435
- signal.throwIfAborted();
436
- await new Promise((resolve) => {
437
- const done = () => {
438
- this.#changes.delete(done);
439
- signal.removeEventListener("abort", done);
440
- resolve();
441
- };
442
- this.#changes.add(done);
443
- signal.addEventListener("abort", done, { once: true });
444
- });
445
- }
446
- if (signal.aborted) {
447
- this.close(new Error("Request was aborted"));
448
- signal.throwIfAborted();
449
- }
450
- }
451
- async#pump() {
452
- try {
453
- for await (const message of this.#query)
454
- this.#route(message);
455
- this.close(new Error(`Claude Code exited.${this.#detail()}`));
456
- } catch (error) {
457
- const message = error instanceof Error ? error.message : String(error);
458
- this.close(new Error(`${message}${this.#detail()}`, { cause: error }));
459
- }
460
- }
461
- #detail() {
462
- const tail = this.#stderr.trim().slice(-500);
463
- return tail === "" ? "" : ` (${tail})`;
464
- }
465
- #route(message) {
466
- switch (message.type) {
467
- case "stream_event":
468
- if (message.parent_tool_use_id !== null)
469
- break;
470
- this.#track(message.event);
471
- this.#turn.push(message);
472
- break;
473
- case "assistant":
474
- if (message.parent_tool_use_id === null)
475
- this.#turn.push(message);
476
- break;
477
- case "result":
478
- this.#turn.push(message);
479
- break;
480
- case "user": {
481
- const content = message.message.content;
482
- if (message.parent_tool_use_id !== null || !Array.isArray(content))
483
- break;
484
- for (const block of content)
485
- if (block.type === "tool_result")
486
- this.#results.set(block.tool_use_id, {
487
- text: resultText(block.content),
488
- isError: block.is_error === true
489
- });
490
- break;
491
- }
492
- case "system":
493
- if (message.subtype === "background_tasks_changed")
494
- this.#background = message.tasks.flatMap((task) => task.ambient === true ? [] : [task.description]);
495
- else if (message.subtype === "task_notification")
496
- this.#notes.push(message.summary);
497
- else if (message.subtype === "session_state_changed" && message.state === "idle")
498
- this.#turn.push(message);
499
- break;
500
- default:
501
- break;
502
- }
503
- this.#changed();
504
- }
505
- #track(event) {
506
- if (event.type === "message_start") {
507
- for (const id of this.#order) {
508
- this.#gates.delete(id);
509
- this.#permits.delete(id);
510
- }
511
- this.#order = [];
512
- return;
513
- }
514
- if (event.type !== "content_block_start" || event.content_block.type !== "tool_use")
515
- return;
516
- const id = event.content_block.id;
517
- if (event.content_block.name.startsWith(NYTE_TOOL_PREFIX2)) {
518
- this.#reply(id);
519
- return;
520
- }
521
- this.#order.push(id);
522
- this.#gate(id);
523
- }
524
- #changed() {
525
- for (const change of this.#changes)
526
- change();
527
- }
528
- }
529
-
530
- export { ClaudeCodeSession2 };
@@ -1,78 +0,0 @@
1
- import type { Command, SettingDefinition } from "@nyte-ai/core";
2
- /**
3
- * Names a search provider the `web_search` tool can route to.
4
- *
5
- * @category plugins
6
- * @since 0.1.0
7
- */
8
- export type SearchProvider = (typeof PROVIDERS)[number];
9
- declare const PROVIDERS: readonly ["exa", "tavily", "firecrawl", "parallel"];
10
- /**
11
- * Returns one search hit as the tool reports it.
12
- *
13
- * @category plugins
14
- * @since 0.1.0
15
- */
16
- export interface SearchResult {
17
- readonly url: string;
18
- readonly title: string | null;
19
- readonly content: string | null;
20
- }
21
- /**
22
- * Returns what one adapter call needs: the query, the provider's key or
23
- * undefined for its keyless route, the fetch to send with, and a signal.
24
- *
25
- * @category plugins
26
- * @since 0.1.0
27
- */
28
- export interface SearchInput {
29
- readonly query: string;
30
- readonly key: string | undefined;
31
- readonly fetch: typeof globalThis.fetch;
32
- readonly signal: AbortSignal;
33
- }
34
- /**
35
- * One adapter per provider: Tavily over its REST endpoint, the others over
36
- * one stateless MCP `tools/call` to their public route. Each sends through
37
- * the given fetch only and returns the hits it recognised.
38
- *
39
- * @category plugins
40
- * @since 0.1.0
41
- */
42
- export declare const adapters: {
43
- readonly [P in SearchProvider]: (input: SearchInput) => Promise<readonly SearchResult[]>;
44
- };
45
- /**
46
- * Adds `web_search`, routed by the host setting `web_search.provider` to
47
- * Tavily, Exa, Firecrawl or Parallel. A provider's key lives in the plugin's
48
- * secrets under the provider's id, set with the `websearch-key` command; without one
49
- * the provider's keyless route is used.
50
- *
51
- * @category plugins
52
- * @since 0.1.0
53
- */
54
- declare const _default: {
55
- id: string;
56
- contribute: {
57
- settings: SettingDefinition<"exa" | "firecrawl" | "parallel" | "tavily">[];
58
- commands: Command<keyof import("@nyte-ai/core").SideTable>[];
59
- };
60
- activate(api: {
61
- readonly side: "core";
62
- readonly sdk: import("@nyte-ai/core").Connection;
63
- readonly contribute: import("@nyte-ai/core").Registries<"core">;
64
- readonly storage: import("@nyte-ai/core").PluginStorage;
65
- readonly signal: AbortSignal;
66
- hook<N extends import("@nyte-ai/core").HookName<"core">>(name: N, entry: import("@nyte-ai/core").HookEntry<"core", N>): import("@nyte-ai/schema").Disposer;
67
- report(issue: import("@nyte-ai/schema").ValidationIssue): void;
68
- reload(): void;
69
- } & {
70
- readonly session: import("@nyte-ai/core").Session;
71
- readonly env: import("@nyte-ai/core").ExecutionEnv;
72
- wrapEnv(wrap: import("@nyte-ai/core").EnvironmentWrap): import("@nyte-ai/schema").Disposer;
73
- readonly inputs: import("@nyte-ai/core").Resources;
74
- request<T = string>(input: import("@nyte-ai/schema").ModelRequestInput<T>): Promise<import("@nyte-ai/schema").ModelRequestOutcome<T>>;
75
- approve(call: import("@nyte-ai/core").RuntimeCall, signal: AbortSignal): Promise<import("@nyte-ai/core").RuntimeVerdict>;
76
- }): void;
77
- };
78
- export default _default;