veryfront 0.1.1006 → 0.1.1007
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.
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-stream.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/run-stream.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,IAAI,OAAO,EAC5B,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"run-stream.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/run-stream.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,IAAI,OAAO,EAC5B,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,KAAK,EACV,+BAA+B,EAC/B,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAEL,KAAK,IAAI,EAGV,MAAM,kBAAkB,CAAC;AAU1B,OAAO,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAsCxD,MAAM,WAAW,+BAA+B;IAC9C,cAAc,EAAE,sBAAsB,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC;IAC5C,mBAAmB,CAAC,EAAE;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,cAAc,CAAC,EAAE,+BAA+B,CAAC,gBAAgB,CAAC,CAAC;IACnE,8BAA8B,CAAC,EAAE,CAC/B,KAAK,EAAE,+BAA+B,KACnC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC7C,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;AAoCD,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,KAAK,EACZ,KAAK,EAAE,oBAAoB,EAC3B,cAAc,EAAE,sBAAsB,EACtC,2BAA2B,CAAC,EAAE,MAAM,EAAE,EACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;;cAsFrD;AAwSD,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,QAAQ,CAAC,CAyWnB"}
|
|
@@ -2,6 +2,7 @@ import * as dntShim from "../../_dnt.shims.js";
|
|
|
2
2
|
import { AgentRuntime, } from "../agent/index.js";
|
|
3
3
|
import { normalizeAgUiRuntimeMessages } from "../agent/ag-ui/runtime-support.js";
|
|
4
4
|
import { compactForStep, estimateOverhead } from "../chat/message-prep.js";
|
|
5
|
+
import { getRuntimeRemoteToolSources, } from "../agent/runtime/mcp-server-tool-sources.js";
|
|
5
6
|
import { convertAgentRuntimeMessagesToProviderMessages, convertProviderMessagesToAgentRuntimeMessages, } from "../agent/runtime/message-adapter.js";
|
|
6
7
|
import { createAgentServiceSandboxTools } from "../sandbox/index.js";
|
|
7
8
|
import { tryResolve } from "../extensions/contracts.js";
|
|
@@ -9,7 +10,7 @@ import { importFirstPartyExtensionModule } from "../extensions/first-party-impor
|
|
|
9
10
|
import { SandboxShellToolsProviderName, } from "../extensions/sandbox/index.js";
|
|
10
11
|
import { resolveHostedRuntimeAllowedToolNames } from "../agent/hosted/runtime-essential-tools.js";
|
|
11
12
|
import { SKILL_TOOL_IDS } from "../skill/types.js";
|
|
12
|
-
import { isToolVisibleTo, toolRegistry } from "../tool/index.js";
|
|
13
|
+
import { isToolVisibleTo, toolRegistry, } from "../tool/index.js";
|
|
13
14
|
import { defineSchema, lazySchema } from "../schemas/index.js";
|
|
14
15
|
import { createStreamTransformState, finalizeRunEvents, formatAgUiEvent, mapRuntimeEventToAgUi, parseSseJsonEvents, } from "./ag-ui-sse.js";
|
|
15
16
|
import { AgentRunCancelledError } from "./session-manager.js";
|
|
@@ -238,11 +239,22 @@ function getRuntimeToolAllowlist(forwardedProps) {
|
|
|
238
239
|
* Intersects the merged run tool set with the restrictive tool allowlist.
|
|
239
240
|
* Skill runtime/delegation tools are preserved for skill-enabled agents,
|
|
240
241
|
* mirroring the hosted chat runtime's allowlist semantics.
|
|
242
|
+
*
|
|
243
|
+
* The allowlist bounds this run's direct tool surface only: preserved skill
|
|
244
|
+
* delegation tools (`invoke_agent`) can spawn child runs whose tool assembly
|
|
245
|
+
* derives from the child agent's own config and is not capped by this run's
|
|
246
|
+
* allowlist. Strict schedules must exclude delegation via agent config.
|
|
241
247
|
*/
|
|
242
248
|
function applyRuntimeToolAllowlist(mergedTools, toolAllowlist, agent) {
|
|
243
|
-
if (!toolAllowlist || !mergedTools
|
|
249
|
+
if (!toolAllowlist || !mergedTools) {
|
|
244
250
|
return mergedTools;
|
|
245
251
|
}
|
|
252
|
+
if (mergedTools === true) {
|
|
253
|
+
// buildMergedTools always expands `tools: true` into a concrete record,
|
|
254
|
+
// so this is unreachable; if that invariant ever breaks, fail closed
|
|
255
|
+
// rather than silently skipping enforcement.
|
|
256
|
+
return {};
|
|
257
|
+
}
|
|
246
258
|
const availableSkillIds = agent.config.skills === true
|
|
247
259
|
? ["*"]
|
|
248
260
|
: Array.isArray(agent.config.skills)
|
|
@@ -287,6 +299,48 @@ function getForwardedIntegrationToolDefinitions(forwardedProps) {
|
|
|
287
299
|
parameters: def.inputSchema ?? def.parameters ?? { type: "object", properties: {} },
|
|
288
300
|
}));
|
|
289
301
|
}
|
|
302
|
+
function getRemoteToolDiscoveryContext(input) {
|
|
303
|
+
return {
|
|
304
|
+
agentId: input.agent.id,
|
|
305
|
+
runId: input.runInput.runId,
|
|
306
|
+
...(input.deps.projectAgentSandbox?.authToken
|
|
307
|
+
? { authToken: input.deps.projectAgentSandbox.authToken }
|
|
308
|
+
: {}),
|
|
309
|
+
...(input.deps.projectAgentSandbox?.projectId
|
|
310
|
+
? { projectId: input.deps.projectAgentSandbox.projectId }
|
|
311
|
+
: {}),
|
|
312
|
+
...(input.runInput.parentRunId ? { parentRunId: input.runInput.parentRunId } : {}),
|
|
313
|
+
...(input.runInput.state !== undefined ? { state: input.runInput.state } : {}),
|
|
314
|
+
context: input.runInput.context,
|
|
315
|
+
forwardedProps: input.runInput.forwardedProps,
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
async function getDeclaredRemoteSourceToolNames(input) {
|
|
319
|
+
const sources = getRuntimeRemoteToolSources(input.agent.config);
|
|
320
|
+
if (!sources?.length) {
|
|
321
|
+
return [];
|
|
322
|
+
}
|
|
323
|
+
const context = getRemoteToolDiscoveryContext(input);
|
|
324
|
+
const toolNames = new Set();
|
|
325
|
+
for (const source of sources) {
|
|
326
|
+
try {
|
|
327
|
+
for (const definition of await source.listTools(context)) {
|
|
328
|
+
if (typeof definition.name === "string" && definition.name.length > 0) {
|
|
329
|
+
toolNames.add(definition.name);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
logger.warn("Failed to inspect remote tool source for restrictive allowlist fallback", {
|
|
335
|
+
runId: input.runInput.runId,
|
|
336
|
+
agentId: input.agent.id,
|
|
337
|
+
sourceId: source.id,
|
|
338
|
+
error: error instanceof Error ? error.message : String(error),
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return [...toolNames];
|
|
343
|
+
}
|
|
290
344
|
function compactRuntimeMessagesForStream(messages, mergedTools) {
|
|
291
345
|
const toolCount = mergedTools && mergedTools !== true ? Object.keys(mergedTools).length : 0;
|
|
292
346
|
return convertProviderMessagesToAgentRuntimeMessages(compactForStep(convertAgentRuntimeMessagesToProviderMessages(messages), estimateOverhead("", toolCount)));
|
|
@@ -309,31 +363,46 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
|
|
|
309
363
|
const grantedRemoteToolNames = forwardedAllowedRemoteToolNames === undefined
|
|
310
364
|
? undefined
|
|
311
365
|
: mergeRemoteToolNames(sourceAllowedRemoteToolNames, forwardedAllowedRemoteToolNames);
|
|
366
|
+
const runtimeToolAllowlist = getRuntimeToolAllowlist(input.forwardedProps);
|
|
367
|
+
if (runtimeToolAllowlist === null && forwardedAllowedRemoteToolNames !== undefined) {
|
|
368
|
+
logger.debug("runtimeOverrides.allowedTools is additive on internal runs; use runtimeOverrides.toolAllowlist to restrict the run tool surface", { runId: input.runId, agentId: agent.id });
|
|
369
|
+
}
|
|
370
|
+
const forwardedIntegrationToolDefs = getForwardedIntegrationToolDefinitions(input.forwardedProps);
|
|
371
|
+
const availableForwardedToolNames = forwardedIntegrationToolDefs?.map((tool) => tool.name);
|
|
312
372
|
// A restrictive toolAllowlist caps remote exposure too: it intersects the
|
|
313
373
|
// tightest existing remote filter (forwarded grants, else the agent source's
|
|
314
|
-
// own __vfAllowedRemoteTools)
|
|
315
|
-
// remote
|
|
316
|
-
//
|
|
317
|
-
|
|
374
|
+
// own __vfAllowedRemoteTools). With neither present, discover the agent's
|
|
375
|
+
// declared remote-source surface and intersect with that. A bare allowlist
|
|
376
|
+
// entry can narrow actual remote sources, but never becomes an implicit
|
|
377
|
+
// project-scoped integration grant (#2768).
|
|
318
378
|
const sourceRemoteFilterBase = Object.hasOwn(agent.config, "__vfAllowedRemoteTools")
|
|
319
379
|
? sourceAllowedRemoteToolNames
|
|
320
380
|
: undefined;
|
|
381
|
+
const remoteFallbackBase = runtimeToolAllowlist !== null &&
|
|
382
|
+
grantedRemoteToolNames === undefined &&
|
|
383
|
+
sourceRemoteFilterBase === undefined
|
|
384
|
+
? await getDeclaredRemoteSourceToolNames({ agent, runInput: input, deps })
|
|
385
|
+
: undefined;
|
|
321
386
|
const allowedRemoteToolNames = runtimeToolAllowlist === null
|
|
322
387
|
? grantedRemoteToolNames
|
|
323
|
-
: (grantedRemoteToolNames ?? sourceRemoteFilterBase ?? [
|
|
324
|
-
const forwardedIntegrationToolDefs = getForwardedIntegrationToolDefinitions(input.forwardedProps);
|
|
325
|
-
const availableForwardedToolNames = forwardedIntegrationToolDefs?.map((tool) => tool.name);
|
|
388
|
+
: (grantedRemoteToolNames ?? sourceRemoteFilterBase ?? remoteFallbackBase ?? []).filter((toolName) => runtimeToolAllowlist.has(toolName));
|
|
326
389
|
const sandboxTools = await buildProjectAgentSandboxTools({ agent, deps });
|
|
327
390
|
const availableLocalTools = {
|
|
328
391
|
...(deps.localTools ?? {}),
|
|
329
392
|
...(sandboxTools.tools ?? {}),
|
|
330
393
|
};
|
|
331
394
|
const mergedTools = applyRuntimeToolAllowlist(buildMergedTools(agent, input, deps.sessionManager, availableForwardedToolNames, Object.keys(availableLocalTools).length > 0 ? availableLocalTools : undefined), runtimeToolAllowlist, agent);
|
|
395
|
+
// Provider-native tools (e.g. web_search) are provider-side and bypass the
|
|
396
|
+
// merged tool record, so cap them against the allowlist explicitly.
|
|
397
|
+
const cappedProviderTools = runtimeToolAllowlist !== null && Array.isArray(agent.config.providerTools)
|
|
398
|
+
? agent.config.providerTools.filter((toolName) => typeof toolName === "string" && runtimeToolAllowlist.has(toolName))
|
|
399
|
+
: undefined;
|
|
332
400
|
const runtimeAgent = {
|
|
333
401
|
...agent,
|
|
334
402
|
config: {
|
|
335
403
|
...agent.config,
|
|
336
404
|
tools: mergedTools,
|
|
405
|
+
...(cappedProviderTools !== undefined ? { providerTools: cappedProviderTools } : {}),
|
|
337
406
|
...(allowedRemoteToolNames !== undefined
|
|
338
407
|
? { __vfAllowedRemoteTools: allowedRemoteToolNames }
|
|
339
408
|
: {}),
|