veryfront 0.1.190 → 0.1.192

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 (48) hide show
  1. package/esm/cli/mcp/standalone.d.ts +1 -7
  2. package/esm/cli/mcp/standalone.d.ts.map +1 -1
  3. package/esm/cli/mcp/standalone.js +85 -0
  4. package/esm/cli/mcp/tools/context7-tools.d.ts +3 -0
  5. package/esm/cli/mcp/tools/context7-tools.d.ts.map +1 -0
  6. package/esm/cli/mcp/tools/context7-tools.js +90 -0
  7. package/esm/cli/mcp/tools.d.ts.map +1 -1
  8. package/esm/cli/mcp/tools.js +2 -0
  9. package/esm/deno.js +1 -1
  10. package/esm/src/agent/ag-ui-handler.d.ts.map +1 -1
  11. package/esm/src/agent/ag-ui-handler.js +17 -1
  12. package/esm/src/agent/factory.d.ts.map +1 -1
  13. package/esm/src/agent/factory.js +2 -1
  14. package/esm/src/agent/human-input.d.ts.map +1 -1
  15. package/esm/src/agent/human-input.js +1 -0
  16. package/esm/src/agent/runtime/resume-session.d.ts +1 -0
  17. package/esm/src/agent/runtime/resume-session.d.ts.map +1 -1
  18. package/esm/src/agent/runtime/resume-session.js +23 -1
  19. package/esm/src/agent/types.d.ts +2 -0
  20. package/esm/src/agent/types.d.ts.map +1 -1
  21. package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
  22. package/esm/src/internal-agents/run-stream.js +14 -0
  23. package/esm/src/internal-agents/session-manager.d.ts +1 -0
  24. package/esm/src/internal-agents/session-manager.d.ts.map +1 -1
  25. package/esm/src/internal-agents/session-manager.js +3 -0
  26. package/esm/src/tool/context7.d.ts +9 -0
  27. package/esm/src/tool/context7.d.ts.map +1 -0
  28. package/esm/src/tool/context7.js +19 -0
  29. package/esm/src/tool/index.d.ts +2 -0
  30. package/esm/src/tool/index.d.ts.map +1 -1
  31. package/esm/src/tool/index.js +1 -0
  32. package/esm/src/utils/version-constant.d.ts +1 -1
  33. package/esm/src/utils/version-constant.js +1 -1
  34. package/package.json +1 -1
  35. package/src/cli/mcp/standalone.ts +94 -0
  36. package/src/cli/mcp/tools/context7-tools.ts +110 -0
  37. package/src/cli/mcp/tools.ts +2 -0
  38. package/src/deno.js +1 -1
  39. package/src/src/agent/ag-ui-handler.ts +21 -0
  40. package/src/src/agent/factory.ts +2 -0
  41. package/src/src/agent/human-input.ts +1 -0
  42. package/src/src/agent/runtime/resume-session.ts +31 -1
  43. package/src/src/agent/types.ts +2 -0
  44. package/src/src/internal-agents/run-stream.ts +18 -0
  45. package/src/src/internal-agents/session-manager.ts +4 -0
  46. package/src/src/tool/context7.ts +34 -0
  47. package/src/src/tool/index.ts +2 -0
  48. package/src/src/utils/version-constant.ts +1 -1
@@ -1,10 +1,3 @@
1
- /**
2
- * Standalone MCP Server
3
- *
4
- * Runs as a separate process (`veryfront mcp`), communicates over stdio.
5
- * Pulls runtime data from the dev server's Dashboard API over HTTP.
6
- * Falls back gracefully when the dev server is not running.
7
- */
8
1
  export interface StandaloneMCPConfig {
9
2
  port?: number;
10
3
  }
@@ -25,6 +18,7 @@ export declare class StandaloneMCPServer {
25
18
  private handlePromptsList;
26
19
  private handlePromptsGet;
27
20
  private createTools;
21
+ private createContext7Tools;
28
22
  }
29
23
  export declare function createStandaloneMCPServer(config?: StandaloneMCPConfig): StandaloneMCPServer;
30
24
  //# sourceMappingURL=standalone.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../../src/cli/mcp/standalone.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA8BH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAA4B;gBAEnC,MAAM,GAAE,mBAAwB;IAM5C,KAAK,IAAI,IAAI;IAWb,IAAI,IAAI,IAAI;YAME,aAAa;IAW3B,OAAO,CAAC,cAAc;YAgCR,eAAe;IAqB7B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,mBAAmB;YAyBb,mBAAmB;IA6CjC,OAAO,CAAC,iBAAiB;YAkBX,gBAAgB;IAwB9B,OAAO,CAAC,WAAW;CA8JpB;AAED,wBAAgB,yBAAyB,CAAC,MAAM,GAAE,mBAAwB,GAAG,mBAAmB,CAI/F"}
1
+ {"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../../src/cli/mcp/standalone.ts"],"names":[],"mappings":"AAsCA,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAA4B;gBAEnC,MAAM,GAAE,mBAAwB;IAM5C,KAAK,IAAI,IAAI;IAWb,IAAI,IAAI,IAAI;YAME,aAAa;IAW3B,OAAO,CAAC,cAAc;YAgCR,eAAe;IAqB7B,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,mBAAmB;YAyBb,mBAAmB;IA6CjC,OAAO,CAAC,iBAAiB;YAkBX,gBAAgB;IAwB9B,OAAO,CAAC,WAAW;IAgKnB,OAAO,CAAC,mBAAmB;CA0F5B;AAED,wBAAgB,yBAAyB,CAAC,MAAM,GAAE,mBAAwB,GAAG,mBAAmB,CAI/F"}
@@ -5,6 +5,7 @@
5
5
  * Pulls runtime data from the dev server's Dashboard API over HTTP.
6
6
  * Falls back gracefully when the dev server is not running.
7
7
  */
8
+ import * as dntShim from "../../_dnt.shims.js";
8
9
  import { readTextFile } from "../../src/platform/index.js";
9
10
  import { DevServerClient } from "./dev-server-client.js";
10
11
  import { startStdioJsonRpc } from "./stdio.js";
@@ -349,6 +350,90 @@ export class StandaloneMCPServer {
349
350
  }
350
351
  },
351
352
  },
353
+ ...this.createContext7Tools(),
354
+ ];
355
+ }
356
+ createContext7Tools() {
357
+ const isAvailable = () => Boolean(dntShim.Deno.env.get("CONTEXT7_API_KEY"));
358
+ let source;
359
+ const getSource = async () => {
360
+ if (!source) {
361
+ const { createContext7ToolSource } = await import("../../src/tool/index.js");
362
+ source = createContext7ToolSource();
363
+ }
364
+ return source;
365
+ };
366
+ const notConfigured = {
367
+ error: "context7_not_configured",
368
+ message: "Context7 API key not configured. Set the CONTEXT7_API_KEY environment variable.",
369
+ };
370
+ return [
371
+ {
372
+ name: "c7_resolve_library",
373
+ description: "Resolves a package or product name to a Context7-compatible library ID. " +
374
+ "Call this before c7_query_docs to obtain the correct library ID. " +
375
+ "Returns matching libraries with metadata (name, description, snippet count, reputation).",
376
+ inputSchema: {
377
+ type: "object",
378
+ properties: {
379
+ libraryName: {
380
+ type: "string",
381
+ description: "Library name to search for. Use the official name with proper punctuation — e.g., 'Next.js' not 'nextjs'.",
382
+ },
383
+ query: {
384
+ type: "string",
385
+ description: "The question or task you need help with. Used to rank results by relevance.",
386
+ },
387
+ },
388
+ required: ["libraryName", "query"],
389
+ },
390
+ async execute(args) {
391
+ if (!isAvailable())
392
+ return notConfigured;
393
+ try {
394
+ return await (await getSource()).executeTool("resolve-library-id", args);
395
+ }
396
+ catch (error) {
397
+ return {
398
+ error: "context7_request_failed",
399
+ message: error instanceof Error ? error.message : String(error),
400
+ };
401
+ }
402
+ },
403
+ },
404
+ {
405
+ name: "c7_query_docs",
406
+ description: "Retrieves up-to-date documentation and code examples from Context7 for a library. " +
407
+ "You must call c7_resolve_library first to obtain the library ID, unless the user " +
408
+ "provides one directly in '/org/project' format.",
409
+ inputSchema: {
410
+ type: "object",
411
+ properties: {
412
+ libraryId: {
413
+ type: "string",
414
+ description: "Context7-compatible library ID (e.g., '/vercel/next.js', '/supabase/supabase').",
415
+ },
416
+ query: {
417
+ type: "string",
418
+ description: "The question or task you need help with. Be specific and include relevant details.",
419
+ },
420
+ },
421
+ required: ["libraryId", "query"],
422
+ },
423
+ async execute(args) {
424
+ if (!isAvailable())
425
+ return notConfigured;
426
+ try {
427
+ return await (await getSource()).executeTool("query-docs", args);
428
+ }
429
+ catch (error) {
430
+ return {
431
+ error: "context7_request_failed",
432
+ message: error instanceof Error ? error.message : String(error),
433
+ };
434
+ }
435
+ },
436
+ },
352
437
  ];
353
438
  }
354
439
  }
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from "../../../src/mcp/index.js";
2
+ export declare const context7Tools: MCPTool[];
3
+ //# sourceMappingURL=context7-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context7-tools.d.ts","sourceRoot":"","sources":["../../../../src/cli/mcp/tools/context7-tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AA2GzD,eAAO,MAAM,aAAa,EAAE,OAAO,EAAoC,CAAC"}
@@ -0,0 +1,90 @@
1
+ import * as dntShim from "../../../_dnt.shims.js";
2
+ import { z } from "zod";
3
+ import { createContext7ToolSource } from "../../../src/tool/index.js";
4
+ let _source;
5
+ function getSource() {
6
+ if (!_source) {
7
+ _source = createContext7ToolSource();
8
+ }
9
+ return _source;
10
+ }
11
+ function isContext7Available() {
12
+ return Boolean(dntShim.Deno.env.get("CONTEXT7_API_KEY"));
13
+ }
14
+ const c7ResolveLibrary = {
15
+ name: "c7_resolve_library",
16
+ title: "Context7: Resolve Library ID",
17
+ description: "Resolves a package or product name to a Context7-compatible library ID. " +
18
+ "Call this before c7_query_docs to obtain the correct library ID. " +
19
+ "Returns matching libraries with metadata (name, description, snippet count, reputation).",
20
+ annotations: {
21
+ readOnlyHint: true,
22
+ destructiveHint: false,
23
+ idempotentHint: true,
24
+ openWorldHint: true,
25
+ },
26
+ inputSchema: z.object({
27
+ libraryName: z
28
+ .string()
29
+ .describe("Library name to search for. Use the official name with proper punctuation — e.g., 'Next.js' not 'nextjs'."),
30
+ query: z
31
+ .string()
32
+ .describe("The question or task you need help with. Used to rank results by relevance."),
33
+ }),
34
+ execute: async (input) => {
35
+ if (!isContext7Available()) {
36
+ return {
37
+ error: "context7_not_configured",
38
+ message: "Context7 API key not configured. Set the CONTEXT7_API_KEY environment variable.",
39
+ };
40
+ }
41
+ try {
42
+ return await getSource().executeTool("resolve-library-id", input);
43
+ }
44
+ catch (error) {
45
+ return {
46
+ error: "context7_request_failed",
47
+ message: error instanceof Error ? error.message : String(error),
48
+ };
49
+ }
50
+ },
51
+ };
52
+ const c7QueryDocs = {
53
+ name: "c7_query_docs",
54
+ title: "Context7: Query Documentation",
55
+ description: "Retrieves up-to-date documentation and code examples from Context7 for a library. " +
56
+ "You must call c7_resolve_library first to obtain the library ID, unless the user " +
57
+ "provides one directly in '/org/project' format.",
58
+ annotations: {
59
+ readOnlyHint: true,
60
+ destructiveHint: false,
61
+ idempotentHint: true,
62
+ openWorldHint: true,
63
+ },
64
+ inputSchema: z.object({
65
+ libraryId: z
66
+ .string()
67
+ .describe("Context7-compatible library ID (e.g., '/vercel/next.js', '/supabase/supabase')."),
68
+ query: z
69
+ .string()
70
+ .describe("The question or task you need help with. Be specific and include relevant details."),
71
+ }),
72
+ execute: async (input) => {
73
+ if (!isContext7Available()) {
74
+ return {
75
+ error: "context7_not_configured",
76
+ message: "Context7 API key not configured. Set the CONTEXT7_API_KEY environment variable.",
77
+ };
78
+ }
79
+ try {
80
+ return await getSource().executeTool("query-docs", input);
81
+ }
82
+ catch (error) {
83
+ return {
84
+ error: "context7_request_failed",
85
+ message: error instanceof Error ? error.message : String(error),
86
+ };
87
+ }
88
+ },
89
+ };
90
+ export const context7Tools = [c7ResolveLibrary, c7QueryDocs];
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/cli/mcp/tools.ts"],"names":[],"mappings":"AAAA;;4BAE4B;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAA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AAO,gBAAgB,CAAC,CAAC;AAEzD,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,gBAAgB,EAAE,iBAAiB,CAsBtE,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,OAAO,EAU7B,CAAC;AAEF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEzD;AAED,wBAAgB,SAAS,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAExE"}
@@ -8,6 +8,7 @@ import { getEnvironmentConfig } from "../../src/config/index.js";
8
8
  import { advancedTools } from "./advanced-tools.js";
9
9
  import { remoteFileTools } from "./remote-file-tools.js";
10
10
  import { issuesMcpTools } from "../../src/issues/index.js";
11
+ import { context7Tools } from "./tools/context7-tools.js";
11
12
  import { DEFAULT_MCP_PORT } from "../shared/constants.js";
12
13
  const CACHE_DIRS = {
13
14
  all: [".cache/veryfront-modules", ".cache/veryfront-mdx-esm"],
@@ -149,6 +150,7 @@ export const allTools = [
149
150
  ...advancedTools,
150
151
  ...remoteFileTools,
151
152
  ...issuesMcpTools,
153
+ ...context7Tools,
152
154
  vfGetErrors,
153
155
  vfGetLogs,
154
156
  vfClearCache,
package/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.190",
3
+ "version": "0.1.192",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -1 +1 @@
1
- {"version":3,"file":"ag-ui-handler.d.ts","sourceRoot":"","sources":["../../../src/src/agent/ag-ui-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAW,MAAM,YAAY,CAAC;AACjD,OAAO,EAG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E,MAAM,EACf,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,0BAA0B,EAClC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,CAAC,YAAY,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC"}
@@ -198,13 +198,23 @@ function enqueueEvent(controller, event, payload) {
198
198
  }
199
199
  }
200
200
  async function createAgUiStreamResponse(options) {
201
- const { agentId, request, runId, threadId, upstreamBody, upstreamStatus, upstreamStatusText, onFinish, onError, } = options;
201
+ const { agentId, request, runId, threadId, upstreamBody, upstreamStatus, upstreamStatusText, onFinish, onError, onToolCallSeen, } = options;
202
202
  const stream = new ReadableStream({
203
203
  start: async (controller) => {
204
204
  const state = createStreamTransformState();
205
205
  let reader = null;
206
206
  let remainder = "";
207
207
  const decoder = new TextDecoder();
208
+ const prepareToolResultIfNeeded = (event, payload) => {
209
+ if (event !== "ToolCallStart" && event !== "ToolCallArgs" &&
210
+ event !== "ToolCallEnd") {
211
+ return;
212
+ }
213
+ const toolCallId = typeof payload.toolCallId === "string" ? payload.toolCallId : null;
214
+ if (toolCallId) {
215
+ onToolCallSeen?.(toolCallId);
216
+ }
217
+ };
208
218
  if (!enqueueEvent(controller, "RunStarted", { runId, threadId, agentId })) {
209
219
  return;
210
220
  }
@@ -235,6 +245,7 @@ async function createAgUiStreamResponse(options) {
235
245
  remainder = parsed.remainder;
236
246
  for (const event of parsed.events) {
237
247
  for (const mapped of mapRuntimeEventToAgUi(state, event)) {
248
+ prepareToolResultIfNeeded(mapped.event, mapped.payload);
238
249
  if (!enqueueEvent(controller, mapped.event, mapped.payload)) {
239
250
  return;
240
251
  }
@@ -245,6 +256,7 @@ async function createAgUiStreamResponse(options) {
245
256
  const parsed = parseSseJsonEvents(remainder);
246
257
  for (const event of parsed.events) {
247
258
  for (const mapped of mapRuntimeEventToAgUi(state, event)) {
259
+ prepareToolResultIfNeeded(mapped.event, mapped.payload);
248
260
  if (!enqueueEvent(controller, mapped.event, mapped.payload)) {
249
261
  return;
250
262
  }
@@ -309,6 +321,7 @@ function createInjectedAgUiTool(runId, tool, sessionManager) {
309
321
  if (!toolCallId) {
310
322
  throw new Error(`Missing toolCallId for injected tool "${tool.name}"`);
311
323
  }
324
+ sessionManager.prepareForSignal(runId, toolCallId);
312
325
  const submitted = await sessionManager.waitForSignal(runId, toolCallId);
313
326
  if (submitted.isError) {
314
327
  throw new Error(typeof submitted.result === "string"
@@ -367,6 +380,9 @@ async function createAgUiInjectedToolsStreamResponse(agent, request, baseContext
367
380
  onError: () => {
368
381
  sessionManager.failRun(runId);
369
382
  },
383
+ onToolCallSeen: (toolCallId) => {
384
+ sessionManager.prepareForSignal(runId, toolCallId);
385
+ },
370
386
  });
371
387
  }
372
388
  function mergeConfig(config, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/src/agent/factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,eAAe,EAKhB,MAAM,YAAY,CAAC;AA+CpB,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CA4MhD;AAcD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,YAAY,CAAC,GACnD,eAAe,EAAE,CAcnB"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/src/agent/factory.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,eAAe,EAKhB,MAAM,YAAY,CAAC;AA+CpB,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CA8MhD;AAcD;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,YAAY,CAAC,GACnD,eAAe,EAAE,CAcnB"}
@@ -137,7 +137,8 @@ export function agent(config) {
137
137
  const stream = await runtime.stream(inputMessages, input.context, {
138
138
  onToolCall: input.onToolCall,
139
139
  onChunk: input.onChunk,
140
- }, input.model, input.maxOutputTokens);
140
+ onFinish: input.onFinish,
141
+ }, input.model, input.maxOutputTokens, input.abortSignal);
141
142
  return createAgentStreamResult(stream);
142
143
  }, { "agent.id": id, "agent.input_type": input.input ? "string" : "messages" });
143
144
  },
@@ -1 +1 @@
1
- {"version":3,"file":"human-input.d.ts","sourceRoot":"","sources":["../../../src/src/agent/human-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAI7D,eAAO,MAAM,sBAAsB;;;;;iBAKjC,CAAC;AAUH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAuChC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMlC,CAAC;AAEH,eAAO,MAAM,8BAA8B,oGAG1C,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;gCASjC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIzC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACtE,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAA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CAAC;AAEtF,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,uBAAuB,CAAC,qBAAqB,CAAC,CAAC;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CACvF;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAClC,QAAQ,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;CAMrC;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;gBAApB,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CAI1C;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,gBAAgB,CAAC,CAqB3B"}
@@ -94,6 +94,7 @@ export class InvalidHumanInputResultError extends Error {
94
94
  }
95
95
  }
96
96
  export async function waitForHumanInput(options) {
97
+ options.sessionManager.prepareForSignal(options.runId, options.toolCallId);
97
98
  const pendingRequest = HumanInputPendingRequestSchema.parse({
98
99
  runId: options.runId,
99
100
  toolCallId: options.toolCallId,
@@ -47,6 +47,7 @@ export declare class RunResumeSessionManager<T> {
47
47
  runId: string;
48
48
  threadId: string;
49
49
  }): AbortSignal;
50
+ prepareForSignal(runId: string, waitKey: string): void;
50
51
  waitForSignal(runId: string, waitKey: string): Promise<T>;
51
52
  submitSignal(runId: string, input: {
52
53
  waitKey: string;
@@ -1 +1 @@
1
- {"version":3,"file":"resume-session.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/resume-session.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KAAE,GAAG,WAAW;IA4BjE,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAiBhD,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAuD/D,YAAY,CACV,KAAK,EAAE,MAAM,EACb,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,CAAA;KAAE,GACnC,wBAAwB;IA+C3B,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAkBjC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAMhC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM5B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIpD,KAAK,IAAI,IAAI;CAOd"}
@@ -110,6 +110,7 @@ export class RunResumeSessionManager {
110
110
  status: "running",
111
111
  abortController: new AbortController(),
112
112
  waitingState: null,
113
+ preparedWaitKeys: new Set(),
113
114
  submittedValues: new Map(),
114
115
  waitingTimeoutId: null,
115
116
  sessionTimeoutId: null,
@@ -118,6 +119,18 @@ export class RunResumeSessionManager {
118
119
  this.touchSession(session);
119
120
  return session.abortController.signal;
120
121
  }
122
+ prepareForSignal(runId, waitKey) {
123
+ const session = this.sessions.get(runId);
124
+ if (!session) {
125
+ throw new RunNotActiveError(runId);
126
+ }
127
+ if (session.status === "completed" || session.status === "failed" ||
128
+ session.status === "cancelled") {
129
+ throw new RunNotActiveError(runId);
130
+ }
131
+ session.preparedWaitKeys.add(waitKey);
132
+ this.touchSession(session);
133
+ }
121
134
  async waitForSignal(runId, waitKey) {
122
135
  const session = this.sessions.get(runId);
123
136
  if (!session || session.status === "completed" || session.status === "failed") {
@@ -126,6 +139,7 @@ export class RunResumeSessionManager {
126
139
  if (session.abortController.signal.aborted || session.status === "cancelled") {
127
140
  throw new RunCancelledError();
128
141
  }
142
+ session.preparedWaitKeys.add(waitKey);
129
143
  const existingValue = session.submittedValues.get(waitKey);
130
144
  if (existingValue) {
131
145
  session.status = "running";
@@ -185,7 +199,15 @@ export class RunResumeSessionManager {
185
199
  session.status === "cancelled") {
186
200
  throw new RunNotActiveError(runId);
187
201
  }
188
- if (!session.waitingState || session.waitingState.waitKey !== input.waitKey) {
202
+ if (!session.waitingState) {
203
+ if (!session.preparedWaitKeys.has(input.waitKey)) {
204
+ throw new WaitNotPendingError(runId, input.waitKey);
205
+ }
206
+ session.submittedValues.set(input.waitKey, normalized);
207
+ this.touchSession(session);
208
+ return { accepted: true };
209
+ }
210
+ if (session.waitingState.waitKey !== input.waitKey) {
189
211
  throw new WaitNotPendingError(runId, input.waitKey);
190
212
  }
191
213
  session.submittedValues.set(input.waitKey, normalized);
@@ -141,6 +141,8 @@ export interface Agent {
141
141
  maxOutputTokens?: number;
142
142
  onToolCall?: (toolCall: ToolCall) => void;
143
143
  onChunk?: (chunk: string) => void;
144
+ onFinish?: (response: AgentResponse) => void;
145
+ abortSignal?: AbortSignal;
144
146
  }): Promise<AgentStreamResult>;
145
147
  respond(request: Request): Promise<Response>;
146
148
  getMemory(): Memory<Message>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/agent/types.ts"],"names":[],"mappings":"AAAA;;4BAE4B;AAE5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG3D,YAAY,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,YAAY,EACZ,OAAO,EACP,WAAW,EACX,aAAa,EACb,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,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,gCAAgC,CACpD,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,QAAQ,CAAC,CA6NnB"}
1
+ {"version":3,"file":"run-stream.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/run-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,IAAI,OAAO,EAC5B,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAYxD,MAAM,WAAW,+BAA+B;IAC9C,cAAc,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAClC;QACH,MAAM,EAAE,CACN,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,CAAC,EAAE;YACV,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;SAC9C,EACD,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,WAAW,CAAC,EAAE,WAAW,KACtB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;KAC1C,CAAC;CACH;AAoJD,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,QAAQ,CAAC,CA8OnB"}
@@ -20,6 +20,7 @@ function createInjectedStudioTool(runId, toolName, description, parameters, sess
20
20
  if (!toolCallId) {
21
21
  throw new Error(`Missing toolCallId for injected tool "${toolName}"`);
22
22
  }
23
+ sessionManager.prepareForToolResult(runId, toolCallId);
23
24
  const waitResult = await sessionManager.waitForToolResult(runId, toolCallId);
24
25
  if (waitResult.isError) {
25
26
  throw new Error(typeof waitResult.result === "string"
@@ -198,6 +199,17 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
198
199
  clientAttached = false;
199
200
  }
200
201
  };
202
+ const prepareToolResultIfNeeded = (event, payload) => {
203
+ if (event !== "ToolCallStart" && event !== "ToolCallArgs" &&
204
+ event !== "ToolCallEnd") {
205
+ return;
206
+ }
207
+ const toolCallId = typeof payload.toolCallId === "string" ? payload.toolCallId : null;
208
+ if (!toolCallId) {
209
+ return;
210
+ }
211
+ deps.sessionManager.prepareForToolResult(input.runId, toolCallId);
212
+ };
201
213
  const throwIfAborted = () => {
202
214
  if (aborted || abortSignal.aborted) {
203
215
  throw new AgentRunCancelledError();
@@ -236,6 +248,7 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
236
248
  remainder = parsed.remainder;
237
249
  for (const event of parsed.events) {
238
250
  for (const mappedEvent of mapRuntimeEventToAgUi(state, event)) {
251
+ prepareToolResultIfNeeded(mappedEvent.event, mappedEvent.payload);
239
252
  enqueueIfAttached(mappedEvent.event, mappedEvent.payload);
240
253
  }
241
254
  }
@@ -244,6 +257,7 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
244
257
  const trailingEvents = parseSseJsonEvents(`${remainder}\n\n`);
245
258
  for (const event of trailingEvents.events) {
246
259
  for (const mappedEvent of mapRuntimeEventToAgUi(state, event)) {
260
+ prepareToolResultIfNeeded(mappedEvent.event, mappedEvent.payload);
247
261
  enqueueIfAttached(mappedEvent.event, mappedEvent.payload);
248
262
  }
249
263
  }
@@ -33,6 +33,7 @@ export declare class AgentRunSessionManager {
33
33
  result: unknown;
34
34
  isError: boolean;
35
35
  }>;
36
+ prepareForToolResult(runId: string, toolCallId: string): void;
36
37
  submitToolResult(runId: string, input: {
37
38
  toolCallId: string;
38
39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AAI;IAIjD,KAAK,IAAI,IAAI;CAGd;AAoBD,wBAAgB,4CAA4C,IAAI,IAAI,CAGnE;AAED,eAAO,MAAM,sBAAsB,wBAAoC,CAAC"}
@@ -87,6 +87,9 @@ export class AgentRunSessionManager {
87
87
  throw error;
88
88
  }
89
89
  }
90
+ prepareForToolResult(runId, toolCallId) {
91
+ this.sessions.prepareForSignal(runId, toolCallId);
92
+ }
90
93
  submitToolResult(runId, input) {
91
94
  const normalized = {
92
95
  result: input.result,
@@ -0,0 +1,9 @@
1
+ import type { RemoteToolSource } from "./types.js";
2
+ export interface Context7ToolSourceConfig {
3
+ /** Context7 API key. Falls back to Deno.env.get("CONTEXT7_API_KEY"). */
4
+ apiKey?: string;
5
+ /** Override the default endpoint (useful for testing). */
6
+ endpoint?: string;
7
+ }
8
+ export declare function createContext7ToolSource(config?: Context7ToolSourceConfig): RemoteToolSource;
9
+ //# sourceMappingURL=context7.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context7.d.ts","sourceRoot":"","sources":["../../../src/src/tool/context7.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,WAAW,wBAAwB;IACvC,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAcD,wBAAgB,wBAAwB,CACtC,MAAM,GAAE,wBAA6B,GACpC,gBAAgB,CAQlB"}
@@ -0,0 +1,19 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
2
+ import { createRemoteMCPToolSource } from "./remote-mcp.js";
3
+ const DEFAULT_ENDPOINT = "https://mcp.context7.com/mcp";
4
+ function resolveApiKey(config) {
5
+ const key = config.apiKey ?? dntShim.Deno.env.get("CONTEXT7_API_KEY");
6
+ if (!key) {
7
+ throw new Error("Context7 API key is required. Pass apiKey or set the CONTEXT7_API_KEY environment variable.");
8
+ }
9
+ return key;
10
+ }
11
+ export function createContext7ToolSource(config = {}) {
12
+ return createRemoteMCPToolSource({
13
+ id: "context7",
14
+ endpoint: config.endpoint ?? DEFAULT_ENDPOINT,
15
+ headers: () => ({
16
+ CONTEXT7_API_KEY: resolveApiKey(config),
17
+ }),
18
+ });
19
+ }
@@ -48,6 +48,8 @@ export { dynamicTool, tool } from "./factory.js";
48
48
  export type { DynamicToolConfig } from "./factory.js";
49
49
  export { createRemoteMCPToolSource } from "./remote-mcp.js";
50
50
  export type { RemoteMCPToolSourceConfig } from "./remote-mcp.js";
51
+ export { createContext7ToolSource } from "./context7.js";
52
+ export type { Context7ToolSourceConfig } from "./context7.js";
51
53
  export { createToolsFromRemoteDefinitions, loadRemoteToolsFromSource, } from "./remote-source-tools.js";
52
54
  export type { RemoteToolMaterializationOptions } from "./remote-source-tools.js";
53
55
  export { toolRegistry } from "./registry.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/tool/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,cAAc,EACd,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EACL,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/tool/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACV,cAAc,EACd,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,YAAY,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EACL,gCAAgC,EAChC,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
@@ -45,6 +45,7 @@
45
45
  import "../../_dnt.polyfills.js";
46
46
  export { dynamicTool, tool } from "./factory.js";
47
47
  export { createRemoteMCPToolSource } from "./remote-mcp.js";
48
+ export { createContext7ToolSource } from "./context7.js";
48
49
  export { createToolsFromRemoteDefinitions, loadRemoteToolsFromSource, } from "./remote-source-tools.js";
49
50
  export { toolRegistry } from "./registry.js";
50
51
  export { executeTool } from "./executor.js";
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.190";
1
+ export declare const VERSION = "0.1.192";
2
2
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.190";
3
+ export const VERSION = "0.1.192";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.190",
3
+ "version": "0.1.192",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
@@ -5,6 +5,8 @@
5
5
  * Pulls runtime data from the dev server's Dashboard API over HTTP.
6
6
  * Falls back gracefully when the dev server is not running.
7
7
  */
8
+ import * as dntShim from "../../_dnt.shims.js";
9
+
8
10
 
9
11
  import { readTextFile } from "../../src/platform/index.js";
10
12
  import type { StdinReader } from "../../src/platform/index.js";
@@ -409,6 +411,98 @@ export class StandaloneMCPServer {
409
411
  }
410
412
  },
411
413
  },
414
+ ...this.createContext7Tools(),
415
+ ];
416
+ }
417
+
418
+ private createContext7Tools(): StandaloneTool[] {
419
+ const isAvailable = () => Boolean(dntShim.Deno.env.get("CONTEXT7_API_KEY"));
420
+
421
+ let source: {
422
+ executeTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
423
+ } | undefined;
424
+
425
+ const getSource = async () => {
426
+ if (!source) {
427
+ const { createContext7ToolSource } = await import("../../src/tool/index.js");
428
+ source = createContext7ToolSource();
429
+ }
430
+ return source;
431
+ };
432
+
433
+ const notConfigured = {
434
+ error: "context7_not_configured",
435
+ message: "Context7 API key not configured. Set the CONTEXT7_API_KEY environment variable.",
436
+ };
437
+
438
+ return [
439
+ {
440
+ name: "c7_resolve_library",
441
+ description: "Resolves a package or product name to a Context7-compatible library ID. " +
442
+ "Call this before c7_query_docs to obtain the correct library ID. " +
443
+ "Returns matching libraries with metadata (name, description, snippet count, reputation).",
444
+ inputSchema: {
445
+ type: "object",
446
+ properties: {
447
+ libraryName: {
448
+ type: "string",
449
+ description:
450
+ "Library name to search for. Use the official name with proper punctuation — e.g., 'Next.js' not 'nextjs'.",
451
+ },
452
+ query: {
453
+ type: "string",
454
+ description:
455
+ "The question or task you need help with. Used to rank results by relevance.",
456
+ },
457
+ },
458
+ required: ["libraryName", "query"],
459
+ },
460
+ async execute(args) {
461
+ if (!isAvailable()) return notConfigured;
462
+ try {
463
+ return await (await getSource()).executeTool("resolve-library-id", args);
464
+ } catch (error) {
465
+ return {
466
+ error: "context7_request_failed",
467
+ message: error instanceof Error ? error.message : String(error),
468
+ };
469
+ }
470
+ },
471
+ },
472
+ {
473
+ name: "c7_query_docs",
474
+ description:
475
+ "Retrieves up-to-date documentation and code examples from Context7 for a library. " +
476
+ "You must call c7_resolve_library first to obtain the library ID, unless the user " +
477
+ "provides one directly in '/org/project' format.",
478
+ inputSchema: {
479
+ type: "object",
480
+ properties: {
481
+ libraryId: {
482
+ type: "string",
483
+ description:
484
+ "Context7-compatible library ID (e.g., '/vercel/next.js', '/supabase/supabase').",
485
+ },
486
+ query: {
487
+ type: "string",
488
+ description:
489
+ "The question or task you need help with. Be specific and include relevant details.",
490
+ },
491
+ },
492
+ required: ["libraryId", "query"],
493
+ },
494
+ async execute(args) {
495
+ if (!isAvailable()) return notConfigured;
496
+ try {
497
+ return await (await getSource()).executeTool("query-docs", args);
498
+ } catch (error) {
499
+ return {
500
+ error: "context7_request_failed",
501
+ message: error instanceof Error ? error.message : String(error),
502
+ };
503
+ }
504
+ },
505
+ },
412
506
  ];
413
507
  }
414
508
  }
@@ -0,0 +1,110 @@
1
+ import * as dntShim from "../../../_dnt.shims.js";
2
+ import { z } from "zod";
3
+ import type { MCPTool } from "../../../src/mcp/index.js";
4
+ import { createContext7ToolSource } from "../../../src/tool/index.js";
5
+
6
+ let _source: ReturnType<typeof createContext7ToolSource> | undefined;
7
+
8
+ function getSource() {
9
+ if (!_source) {
10
+ _source = createContext7ToolSource();
11
+ }
12
+ return _source;
13
+ }
14
+
15
+ function isContext7Available(): boolean {
16
+ return Boolean(dntShim.Deno.env.get("CONTEXT7_API_KEY"));
17
+ }
18
+
19
+ const c7ResolveLibrary: MCPTool<
20
+ { libraryName: string; query: string },
21
+ unknown
22
+ > = {
23
+ name: "c7_resolve_library",
24
+ title: "Context7: Resolve Library ID",
25
+ description: "Resolves a package or product name to a Context7-compatible library ID. " +
26
+ "Call this before c7_query_docs to obtain the correct library ID. " +
27
+ "Returns matching libraries with metadata (name, description, snippet count, reputation).",
28
+ annotations: {
29
+ readOnlyHint: true,
30
+ destructiveHint: false,
31
+ idempotentHint: true,
32
+ openWorldHint: true,
33
+ },
34
+ inputSchema: z.object({
35
+ libraryName: z
36
+ .string()
37
+ .describe(
38
+ "Library name to search for. Use the official name with proper punctuation — e.g., 'Next.js' not 'nextjs'.",
39
+ ),
40
+ query: z
41
+ .string()
42
+ .describe(
43
+ "The question or task you need help with. Used to rank results by relevance.",
44
+ ),
45
+ }),
46
+ execute: async (input) => {
47
+ if (!isContext7Available()) {
48
+ return {
49
+ error: "context7_not_configured",
50
+ message: "Context7 API key not configured. Set the CONTEXT7_API_KEY environment variable.",
51
+ };
52
+ }
53
+ try {
54
+ return await getSource().executeTool("resolve-library-id", input);
55
+ } catch (error) {
56
+ return {
57
+ error: "context7_request_failed",
58
+ message: error instanceof Error ? error.message : String(error),
59
+ };
60
+ }
61
+ },
62
+ };
63
+
64
+ const c7QueryDocs: MCPTool<
65
+ { libraryId: string; query: string },
66
+ unknown
67
+ > = {
68
+ name: "c7_query_docs",
69
+ title: "Context7: Query Documentation",
70
+ description:
71
+ "Retrieves up-to-date documentation and code examples from Context7 for a library. " +
72
+ "You must call c7_resolve_library first to obtain the library ID, unless the user " +
73
+ "provides one directly in '/org/project' format.",
74
+ annotations: {
75
+ readOnlyHint: true,
76
+ destructiveHint: false,
77
+ idempotentHint: true,
78
+ openWorldHint: true,
79
+ },
80
+ inputSchema: z.object({
81
+ libraryId: z
82
+ .string()
83
+ .describe(
84
+ "Context7-compatible library ID (e.g., '/vercel/next.js', '/supabase/supabase').",
85
+ ),
86
+ query: z
87
+ .string()
88
+ .describe(
89
+ "The question or task you need help with. Be specific and include relevant details.",
90
+ ),
91
+ }),
92
+ execute: async (input) => {
93
+ if (!isContext7Available()) {
94
+ return {
95
+ error: "context7_not_configured",
96
+ message: "Context7 API key not configured. Set the CONTEXT7_API_KEY environment variable.",
97
+ };
98
+ }
99
+ try {
100
+ return await getSource().executeTool("query-docs", input);
101
+ } catch (error) {
102
+ return {
103
+ error: "context7_request_failed",
104
+ message: error instanceof Error ? error.message : String(error),
105
+ };
106
+ }
107
+ },
108
+ };
109
+
110
+ export const context7Tools: MCPTool[] = [c7ResolveLibrary, c7QueryDocs];
@@ -17,6 +17,7 @@ import type { MCPTool } from "../../src/mcp/index.js";
17
17
  import { advancedTools } from "./advanced-tools.js";
18
18
  import { remoteFileTools } from "./remote-file-tools.js";
19
19
  import { issuesMcpTools } from "../../src/issues/index.js";
20
+ import { context7Tools } from "./tools/context7-tools.js";
20
21
  import { DEFAULT_MCP_PORT } from "../shared/constants.js";
21
22
 
22
23
  export type { MCPTool };
@@ -235,6 +236,7 @@ export const allTools: MCPTool[] = [
235
236
  ...advancedTools,
236
237
  ...remoteFileTools,
237
238
  ...issuesMcpTools,
239
+ ...context7Tools,
238
240
  vfGetErrors,
239
241
  vfGetLogs,
240
242
  vfClearCache,
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.190",
3
+ "version": "0.1.192",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "exclude": [
@@ -277,6 +277,7 @@ async function createAgUiStreamResponse(
277
277
  upstreamStatusText?: string;
278
278
  onFinish?: () => void;
279
279
  onError?: (error: unknown) => void;
280
+ onToolCallSeen?: (toolCallId: string) => void;
280
281
  },
281
282
  ): Promise<Response> {
282
283
  const {
@@ -289,6 +290,7 @@ async function createAgUiStreamResponse(
289
290
  upstreamStatusText,
290
291
  onFinish,
291
292
  onError,
293
+ onToolCallSeen,
292
294
  } = options;
293
295
 
294
296
  const stream = new ReadableStream<Uint8Array>({
@@ -297,6 +299,19 @@ async function createAgUiStreamResponse(
297
299
  let reader: ReadableStreamDefaultReader<Uint8Array> | null = null;
298
300
  let remainder = "";
299
301
  const decoder = new TextDecoder();
302
+ const prepareToolResultIfNeeded = (event: string, payload: Record<string, unknown>) => {
303
+ if (
304
+ event !== "ToolCallStart" && event !== "ToolCallArgs" &&
305
+ event !== "ToolCallEnd"
306
+ ) {
307
+ return;
308
+ }
309
+
310
+ const toolCallId = typeof payload.toolCallId === "string" ? payload.toolCallId : null;
311
+ if (toolCallId) {
312
+ onToolCallSeen?.(toolCallId);
313
+ }
314
+ };
300
315
 
301
316
  if (!enqueueEvent(controller, "RunStarted", { runId, threadId, agentId })) {
302
317
  return;
@@ -332,6 +347,7 @@ async function createAgUiStreamResponse(
332
347
 
333
348
  for (const event of parsed.events as AgUiRuntimePart[]) {
334
349
  for (const mapped of mapRuntimeEventToAgUi(state, event)) {
350
+ prepareToolResultIfNeeded(mapped.event, mapped.payload);
335
351
  if (!enqueueEvent(controller, mapped.event, mapped.payload)) {
336
352
  return;
337
353
  }
@@ -343,6 +359,7 @@ async function createAgUiStreamResponse(
343
359
  const parsed = parseSseJsonEvents(remainder);
344
360
  for (const event of parsed.events as AgUiRuntimePart[]) {
345
361
  for (const mapped of mapRuntimeEventToAgUi(state, event)) {
362
+ prepareToolResultIfNeeded(mapped.event, mapped.payload);
346
363
  if (!enqueueEvent(controller, mapped.event, mapped.payload)) {
347
364
  return;
348
365
  }
@@ -421,6 +438,7 @@ function createInjectedAgUiTool(
421
438
  throw new Error(`Missing toolCallId for injected tool "${tool.name}"`);
422
439
  }
423
440
 
441
+ sessionManager.prepareForSignal(runId, toolCallId);
424
442
  const submitted = await sessionManager.waitForSignal(runId, toolCallId);
425
443
  if (submitted.isError) {
426
444
  throw new Error(
@@ -501,6 +519,9 @@ async function createAgUiInjectedToolsStreamResponse(
501
519
  onError: () => {
502
520
  sessionManager.failRun(runId);
503
521
  },
522
+ onToolCallSeen: (toolCallId) => {
523
+ sessionManager.prepareForSignal(runId, toolCallId);
524
+ },
504
525
  });
505
526
  }
506
527
 
@@ -190,9 +190,11 @@ export function agent(config: AgentConfig): Agent {
190
190
  {
191
191
  onToolCall: input.onToolCall,
192
192
  onChunk: input.onChunk,
193
+ onFinish: input.onFinish,
193
194
  },
194
195
  input.model,
195
196
  input.maxOutputTokens,
197
+ input.abortSignal,
196
198
  );
197
199
 
198
200
  return createAgentStreamResult(stream);
@@ -130,6 +130,7 @@ export class InvalidHumanInputResultError extends Error {
130
130
  export async function waitForHumanInput(
131
131
  options: WaitForHumanInputOptions,
132
132
  ): Promise<HumanInputResult> {
133
+ options.sessionManager.prepareForSignal(options.runId, options.toolCallId);
133
134
  const pendingRequest = HumanInputPendingRequestSchema.parse({
134
135
  runId: options.runId,
135
136
  toolCallId: options.toolCallId,
@@ -57,6 +57,7 @@ type RunSession<T> = {
57
57
  status: RunSessionStatus;
58
58
  abortController: AbortController;
59
59
  waitingState: WaitingState<T> | null;
60
+ preparedWaitKeys: Set<string>;
60
61
  submittedValues: Map<string, SubmittedValue<T>>;
61
62
  waitingTimeoutId: number | null;
62
63
  sessionTimeoutId: number | null;
@@ -171,6 +172,7 @@ export class RunResumeSessionManager<T> {
171
172
  status: "running",
172
173
  abortController: new AbortController(),
173
174
  waitingState: null,
175
+ preparedWaitKeys: new Set(),
174
176
  submittedValues: new Map(),
175
177
  waitingTimeoutId: null,
176
178
  sessionTimeoutId: null,
@@ -181,6 +183,23 @@ export class RunResumeSessionManager<T> {
181
183
  return session.abortController.signal;
182
184
  }
183
185
 
186
+ prepareForSignal(runId: string, waitKey: string): void {
187
+ const session = this.sessions.get(runId);
188
+ if (!session) {
189
+ throw new RunNotActiveError(runId);
190
+ }
191
+
192
+ if (
193
+ session.status === "completed" || session.status === "failed" ||
194
+ session.status === "cancelled"
195
+ ) {
196
+ throw new RunNotActiveError(runId);
197
+ }
198
+
199
+ session.preparedWaitKeys.add(waitKey);
200
+ this.touchSession(session);
201
+ }
202
+
184
203
  async waitForSignal(runId: string, waitKey: string): Promise<T> {
185
204
  const session = this.sessions.get(runId);
186
205
  if (!session || session.status === "completed" || session.status === "failed") {
@@ -191,6 +210,7 @@ export class RunResumeSessionManager<T> {
191
210
  throw new RunCancelledError();
192
211
  }
193
212
 
213
+ session.preparedWaitKeys.add(waitKey);
194
214
  const existingValue = session.submittedValues.get(waitKey);
195
215
  if (existingValue) {
196
216
  session.status = "running";
@@ -265,7 +285,17 @@ export class RunResumeSessionManager<T> {
265
285
  throw new RunNotActiveError(runId);
266
286
  }
267
287
 
268
- if (!session.waitingState || session.waitingState.waitKey !== input.waitKey) {
288
+ if (!session.waitingState) {
289
+ if (!session.preparedWaitKeys.has(input.waitKey)) {
290
+ throw new WaitNotPendingError(runId, input.waitKey);
291
+ }
292
+
293
+ session.submittedValues.set(input.waitKey, normalized);
294
+ this.touchSession(session);
295
+ return { accepted: true };
296
+ }
297
+
298
+ if (session.waitingState.waitKey !== input.waitKey) {
269
299
  throw new WaitNotPendingError(runId, input.waitKey);
270
300
  }
271
301
 
@@ -219,6 +219,8 @@ export interface Agent {
219
219
  maxOutputTokens?: number;
220
220
  onToolCall?: (toolCall: ToolCall) => void;
221
221
  onChunk?: (chunk: string) => void;
222
+ onFinish?: (response: AgentResponse) => void;
223
+ abortSignal?: AbortSignal;
222
224
  }): Promise<AgentStreamResult>;
223
225
 
224
226
  respond(request: Request): Promise<Response>;
@@ -66,6 +66,7 @@ function createInjectedStudioTool(
66
66
  throw new Error(`Missing toolCallId for injected tool "${toolName}"`);
67
67
  }
68
68
 
69
+ sessionManager.prepareForToolResult(runId, toolCallId);
69
70
  const waitResult = await sessionManager.waitForToolResult(runId, toolCallId);
70
71
  if (waitResult.isError) {
71
72
  throw new Error(
@@ -284,6 +285,21 @@ export async function createRuntimeAgentStreamResponse(
284
285
  clientAttached = false;
285
286
  }
286
287
  };
288
+ const prepareToolResultIfNeeded = (event: string, payload: Record<string, unknown>) => {
289
+ if (
290
+ event !== "ToolCallStart" && event !== "ToolCallArgs" &&
291
+ event !== "ToolCallEnd"
292
+ ) {
293
+ return;
294
+ }
295
+
296
+ const toolCallId = typeof payload.toolCallId === "string" ? payload.toolCallId : null;
297
+ if (!toolCallId) {
298
+ return;
299
+ }
300
+
301
+ deps.sessionManager.prepareForToolResult(input.runId, toolCallId);
302
+ };
287
303
 
288
304
  const throwIfAborted = () => {
289
305
  if (aborted || abortSignal.aborted) {
@@ -330,6 +346,7 @@ export async function createRuntimeAgentStreamResponse(
330
346
 
331
347
  for (const event of parsed.events) {
332
348
  for (const mappedEvent of mapRuntimeEventToAgUi(state, event)) {
349
+ prepareToolResultIfNeeded(mappedEvent.event, mappedEvent.payload);
333
350
  enqueueIfAttached(mappedEvent.event, mappedEvent.payload);
334
351
  }
335
352
  }
@@ -340,6 +357,7 @@ export async function createRuntimeAgentStreamResponse(
340
357
  const trailingEvents = parseSseJsonEvents(`${remainder}\n\n`);
341
358
  for (const event of trailingEvents.events) {
342
359
  for (const mappedEvent of mapRuntimeEventToAgUi(state, event)) {
360
+ prepareToolResultIfNeeded(mappedEvent.event, mappedEvent.payload);
343
361
  enqueueIfAttached(mappedEvent.event, mappedEvent.payload);
344
362
  }
345
363
  }
@@ -129,6 +129,10 @@ export class AgentRunSessionManager {
129
129
  }
130
130
  }
131
131
 
132
+ prepareForToolResult(runId: string, toolCallId: string): void {
133
+ this.sessions.prepareForSignal(runId, toolCallId);
134
+ }
135
+
132
136
  submitToolResult(
133
137
  runId: string,
134
138
  input: { toolCallId: string; result: unknown; isError?: boolean },
@@ -0,0 +1,34 @@
1
+ import * as dntShim from "../../_dnt.shims.js";
2
+ import { createRemoteMCPToolSource } from "./remote-mcp.js";
3
+ import type { RemoteToolSource } from "./types.js";
4
+
5
+ export interface Context7ToolSourceConfig {
6
+ /** Context7 API key. Falls back to Deno.env.get("CONTEXT7_API_KEY"). */
7
+ apiKey?: string;
8
+ /** Override the default endpoint (useful for testing). */
9
+ endpoint?: string;
10
+ }
11
+
12
+ const DEFAULT_ENDPOINT = "https://mcp.context7.com/mcp";
13
+
14
+ function resolveApiKey(config: Context7ToolSourceConfig): string {
15
+ const key = config.apiKey ?? dntShim.Deno.env.get("CONTEXT7_API_KEY");
16
+ if (!key) {
17
+ throw new Error(
18
+ "Context7 API key is required. Pass apiKey or set the CONTEXT7_API_KEY environment variable.",
19
+ );
20
+ }
21
+ return key;
22
+ }
23
+
24
+ export function createContext7ToolSource(
25
+ config: Context7ToolSourceConfig = {},
26
+ ): RemoteToolSource {
27
+ return createRemoteMCPToolSource({
28
+ id: "context7",
29
+ endpoint: config.endpoint ?? DEFAULT_ENDPOINT,
30
+ headers: () => ({
31
+ CONTEXT7_API_KEY: resolveApiKey(config),
32
+ }),
33
+ });
34
+ }
@@ -57,6 +57,8 @@ export { dynamicTool, tool } from "./factory.js";
57
57
  export type { DynamicToolConfig } from "./factory.js";
58
58
  export { createRemoteMCPToolSource } from "./remote-mcp.js";
59
59
  export type { RemoteMCPToolSourceConfig } from "./remote-mcp.js";
60
+ export { createContext7ToolSource } from "./context7.js";
61
+ export type { Context7ToolSourceConfig } from "./context7.js";
60
62
  export {
61
63
  createToolsFromRemoteDefinitions,
62
64
  loadRemoteToolsFromSource,
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.190";
3
+ export const VERSION = "0.1.192";