veryfront 0.1.1101 → 0.1.1103
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 +1 -1
- package/esm/src/agent/factory.d.ts.map +1 -1
- package/esm/src/agent/factory.js +2 -0
- package/esm/src/agent/hosted/cloud-runtime-system-messages.d.ts +5 -0
- package/esm/src/agent/hosted/cloud-runtime-system-messages.d.ts.map +1 -1
- package/esm/src/agent/hosted/cloud-runtime-system-messages.js +3 -2
- package/esm/src/agent/runtime/agent-invocation-contract.d.ts +1 -0
- package/esm/src/agent/runtime/agent-invocation-contract.d.ts.map +1 -1
- package/esm/src/agent/runtime/agent-invocation-contract.js +1 -0
- package/esm/src/agent/runtime/effective-agent-system.d.ts +8 -0
- package/esm/src/agent/runtime/effective-agent-system.d.ts.map +1 -0
- package/esm/src/agent/runtime/effective-agent-system.js +9 -0
- package/esm/src/data/helpers.d.ts +20 -3
- package/esm/src/data/helpers.d.ts.map +1 -1
- package/esm/src/data/helpers.js +46 -12
- package/esm/src/data/static-data-fetcher.d.ts.map +1 -1
- package/esm/src/data/static-data-fetcher.js +15 -0
- package/esm/src/html/hydration-script-builder/templates/renderer.d.ts.map +1 -1
- package/esm/src/html/hydration-script-builder/templates/renderer.js +52 -28
- package/esm/src/internal-agents/run-stream.d.ts +1 -0
- package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
- package/esm/src/internal-agents/run-stream.js +53 -0
- package/esm/src/internal-agents/run-system-prompt.d.ts +42 -0
- package/esm/src/internal-agents/run-system-prompt.d.ts.map +1 -0
- package/esm/src/internal-agents/run-system-prompt.js +109 -0
- package/esm/src/internal-agents/schema.d.ts +2 -0
- package/esm/src/internal-agents/schema.d.ts.map +1 -1
- package/esm/src/internal-agents/schema.js +1 -0
- package/esm/src/modules/server/module-server.d.ts.map +1 -1
- package/esm/src/modules/server/module-server.js +15 -9
- package/esm/src/rendering/orchestrator/module-loader/build-failure.d.ts +20 -0
- package/esm/src/rendering/orchestrator/module-loader/build-failure.d.ts.map +1 -0
- package/esm/src/rendering/orchestrator/module-loader/build-failure.js +26 -0
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts +2 -1
- package/esm/src/rendering/orchestrator/module-loader/index.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/index.js +69 -7
- package/esm/src/rendering/orchestrator/module-loader/module-persistence.d.ts +6 -0
- package/esm/src/rendering/orchestrator/module-loader/module-persistence.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/module-loader/module-persistence.js +49 -0
- package/esm/src/rendering/orchestrator/pipeline.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/pipeline.js +10 -1
- package/esm/src/routing/api/context-builder.d.ts +26 -15
- package/esm/src/routing/api/context-builder.d.ts.map +1 -1
- package/esm/src/routing/api/context-builder.js +34 -15
- package/esm/src/routing/api/module-loader/loader.js +57 -1
- package/esm/src/server/dev-server/middleware.d.ts.map +1 -1
- package/esm/src/server/dev-server/middleware.js +29 -6
- package/esm/src/server/handlers/request/agent-stream.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/agent-stream.handler.js +1 -0
- package/esm/src/server/handlers/request/ssr/ssr.handler.d.ts.map +1 -1
- package/esm/src/server/handlers/request/ssr/ssr.handler.js +6 -4
- package/esm/src/transforms/esm/import-attributes.d.ts +32 -0
- package/esm/src/transforms/esm/import-attributes.d.ts.map +1 -0
- package/esm/src/transforms/esm/import-attributes.js +116 -0
- package/esm/src/transforms/esm/import-parser.d.ts.map +1 -1
- package/esm/src/transforms/esm/import-parser.js +68 -18
- package/esm/src/transforms/esm/lexer.d.ts +18 -0
- package/esm/src/transforms/esm/lexer.d.ts.map +1 -1
- package/esm/src/transforms/esm/lexer.js +21 -0
- package/esm/src/transforms/esm/specifier-resolver.d.ts.map +1 -1
- package/esm/src/transforms/esm/specifier-resolver.js +13 -0
- package/esm/src/transforms/esm/transform-utils.d.ts +8 -0
- package/esm/src/transforms/esm/transform-utils.d.ts.map +1 -1
- package/esm/src/transforms/esm/transform-utils.js +11 -1
- package/esm/src/transforms/import-rewriter/project-paths.d.ts +26 -0
- package/esm/src/transforms/import-rewriter/project-paths.d.ts.map +1 -0
- package/esm/src/transforms/import-rewriter/project-paths.js +49 -0
- package/esm/src/transforms/import-rewriter/strategies/alias-strategy.d.ts +0 -1
- package/esm/src/transforms/import-rewriter/strategies/alias-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/alias-strategy.js +5 -20
- package/esm/src/transforms/import-rewriter/strategies/asset-strategy.d.ts +1 -1
- package/esm/src/transforms/import-rewriter/strategies/asset-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/asset-strategy.js +62 -12
- package/esm/src/transforms/import-rewriter/strategies/bare-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/bare-strategy.js +19 -3
- package/esm/src/transforms/import-rewriter/strategies/node-builtin-strategy.d.ts +11 -0
- package/esm/src/transforms/import-rewriter/strategies/node-builtin-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/node-builtin-strategy.js +13 -0
- package/esm/src/transforms/import-rewriter/strategies/relative-strategy.d.ts +0 -1
- package/esm/src/transforms/import-rewriter/strategies/relative-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/relative-strategy.js +2 -16
- package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.d.ts.map +1 -1
- package/esm/src/transforms/import-rewriter/strategies/veryfront-strategy.js +4 -3
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts +4 -2
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.d.ts.map +1 -1
- package/esm/src/transforms/mdx/esm-module-loader/module-fetcher/nested-imports.js +23 -7
- package/esm/src/transforms/pipeline/stages/browser-node-builtin-imports.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/browser-node-builtin-imports.js +5 -0
- package/esm/src/transforms/pipeline/stages/browser-server-exports-strip.d.ts +25 -3
- package/esm/src/transforms/pipeline/stages/browser-server-exports-strip.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/browser-server-exports-strip.js +285 -44
- package/esm/src/transforms/pipeline/stages/compile.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/compile.js +6 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts +9 -5
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.d.ts.map +1 -1
- package/esm/src/transforms/pipeline/stages/ssr-vf-modules/transform.js +23 -9
- package/esm/src/transforms/shared/server-only-packages.d.ts +30 -0
- package/esm/src/transforms/shared/server-only-packages.d.ts.map +1 -0
- package/esm/src/transforms/shared/server-only-packages.js +47 -0
- package/esm/src/types/entities/getEntityInfo.d.ts.map +1 -1
- package/esm/src/types/entities/getEntityInfo.js +10 -2
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -5
package/esm/deno.js
CHANGED
|
@@ -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;
|
|
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;AAsFpB,oBAAoB;AACpB,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK,CAyNhD;AAcD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,YAAY,CAAC,GACnD,eAAe,EAAE,CAanB"}
|
package/esm/src/agent/factory.js
CHANGED
|
@@ -13,6 +13,7 @@ import { createError, toError } from "../errors/index.js";
|
|
|
13
13
|
import { COMMON_BLOCKED_PATTERNS, securityMiddleware } from "./middleware/security/validator.js";
|
|
14
14
|
import { withSpan } from "../observability/tracing/otlp-setup.js";
|
|
15
15
|
import { resolveConfiguredAgentModel } from "./runtime/model-resolution.js";
|
|
16
|
+
import { setEffectiveAgentSystem } from "./runtime/effective-agent-system.js";
|
|
16
17
|
import { defineSchema } from "../schemas/index.js";
|
|
17
18
|
import { getMessageSchema } from "./schemas/agent.schema.js";
|
|
18
19
|
import { isRequestBodyTooLargeError, readBodyWithLimit, } from "../security/input-validation/limits.js";
|
|
@@ -204,6 +205,7 @@ export function agent(config) {
|
|
|
204
205
|
return runtime.clearMemory();
|
|
205
206
|
},
|
|
206
207
|
};
|
|
208
|
+
setEffectiveAgentSystem(agentInstance, augmentedSystem);
|
|
207
209
|
agentRegistry.register(id, agentInstance);
|
|
208
210
|
return agentInstance;
|
|
209
211
|
}
|
|
@@ -11,6 +11,11 @@ export type CreateVeryfrontCloudRuntimeSystemMessagesInput = {
|
|
|
11
11
|
branchId?: string | null;
|
|
12
12
|
environmentContext?: string;
|
|
13
13
|
};
|
|
14
|
+
/** Builds the shared project-context prompt block (project reference + branch). */
|
|
15
|
+
export declare function buildProjectContextPromptBlock(input: {
|
|
16
|
+
projectId: string;
|
|
17
|
+
branchId?: string | null;
|
|
18
|
+
}): string;
|
|
14
19
|
/** Create Veryfront Cloud runtime system messages. */
|
|
15
20
|
export declare function createVeryfrontCloudRuntimeSystemMessages(input: CreateVeryfrontCloudRuntimeSystemMessagesInput): ChatSystemMessage[];
|
|
16
21
|
/** Builds Veryfront Cloud runtime instructions. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloud-runtime-system-messages.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/cloud-runtime-system-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,wEAAwE;AACxE,MAAM,MAAM,8CAA8C,GAAG;IAC3D,KAAK,EAAE,8BAA8B,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"cloud-runtime-system-messages.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/cloud-runtime-system-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,uBAAuB,CAAC;AAEhF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,wEAAwE;AACxE,MAAM,MAAM,8CAA8C,GAAG;IAC3D,KAAK,EAAE,8BAA8B,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AASF,mFAAmF;AACnF,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACrD,MAAM,CAcR;AAED,sDAAsD;AACtD,wBAAgB,yCAAyC,CACvD,KAAK,EAAE,8CAA8C,GACpD,iBAAiB,EAAE,CAsBrB;AAED,mDAAmD;AACnD,wBAAgB,sCAAsC,CACpD,KAAK,EAAE,kCAAkC,CAAC,8BAA8B,CAAC,GACxE,iBAAiB,EAAE,CASrB"}
|
|
@@ -6,7 +6,8 @@ function createProjectInstructionsBlock(instructions) {
|
|
|
6
6
|
content: `CRITICAL: You MUST follow these project-specific guidelines:\n\n${instructions}`,
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
/** Builds the shared project-context prompt block (project reference + branch). */
|
|
10
|
+
export function buildProjectContextPromptBlock(input) {
|
|
10
11
|
const branchLine = input.branchId
|
|
11
12
|
? `branch_id: "${input.branchId}"`
|
|
12
13
|
: "branch_id: main (no branch_id needed for file operations)";
|
|
@@ -27,7 +28,7 @@ export function createVeryfrontCloudRuntimeSystemMessages(input) {
|
|
|
27
28
|
runtimeBlocks.push(createProjectInstructionsBlock(input.instructions));
|
|
28
29
|
}
|
|
29
30
|
if (input.projectId) {
|
|
30
|
-
runtimeBlocks.push(
|
|
31
|
+
runtimeBlocks.push(buildProjectContextPromptBlock({
|
|
31
32
|
projectId: input.projectId,
|
|
32
33
|
branchId: input.branchId,
|
|
33
34
|
}));
|
|
@@ -397,6 +397,7 @@ export type RuntimeAgentControlPlaneStreamRequest = {
|
|
|
397
397
|
messages: RuntimeAgentRunInvocation["messages"];
|
|
398
398
|
tools: RuntimeAgentRunInvocation["tools"];
|
|
399
399
|
context: RuntimeAgentRunInvocation["context"];
|
|
400
|
+
runtimeTargetBranchId?: RuntimeAgentProjectContext["runtimeTargetBranchId"];
|
|
400
401
|
credentials?: RuntimeAgentRunInvocation["credentials"];
|
|
401
402
|
agentSource: RuntimeAgentRunInvocation["agentSource"];
|
|
402
403
|
agentConfig?: RuntimeAgentRunInvocation["agentConfig"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-invocation-contract.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/agent-invocation-contract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAuBnF,eAAO,MAAM,0BAA0B,gEAEtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,0DAAyC,CAAC;AAE9E,eAAO,MAAM,+BAA+B,gEAAkD,CAAC;AAE/F;;GAEG;AACH,eAAO,MAAM,4BAA4B,0DAA8C,CAAC;AAExF,eAAO,MAAM,8BAA8B,gEAK1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,0DAA6C,CAAC;AAEtF,eAAO,MAAM,uBAAuB,gEAAkD,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,oBAAoB,0DAAsC,CAAC;AAExE,eAAO,MAAM,6BAA6B,gEAKzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,0DAA4C,CAAC;AASpF,eAAO,MAAM,yBAAyB;;;;;;GAWrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;GAAwC,CAAC;AAE5E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;GAuB5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;GAA+C,CAAC;AAE1F,eAAO,MAAM,kCAAkC;;;;;;;;;;GAgB9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;GAAiD,CAAC;AAE9F,eAAO,MAAM,+BAA+B,gEAE3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,0DAA8C,CAAC;AAExF,KAAK,gCAAgC,GAAG;IACtC,iBAAiB,CAAC,EAAE,WAAW,CAAC,UAAU,C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D,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,wDAAwD,CACtE,KAAK,EAAE,yBAAyB,GAC/B,qCAAqC,
|
|
1
|
+
{"version":3,"file":"agent-invocation-contract.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/agent-invocation-contract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAuBnF,eAAO,MAAM,0BAA0B,gEAEtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,0DAAyC,CAAC;AAE9E,eAAO,MAAM,+BAA+B,gEAAkD,CAAC;AAE/F;;GAEG;AACH,eAAO,MAAM,4BAA4B,0DAA8C,CAAC;AAExF,eAAO,MAAM,8BAA8B,gEAK1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,0DAA6C,CAAC;AAEtF,eAAO,MAAM,uBAAuB,gEAAkD,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,oBAAoB,0DAAsC,CAAC;AAExE,eAAO,MAAM,6BAA6B,gEAKzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,0DAA4C,CAAC;AASpF,eAAO,MAAM,yBAAyB;;;;;;GAWrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;GAAwC,CAAC;AAE5E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;GAuB5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;GAA+C,CAAC;AAE1F,eAAO,MAAM,kCAAkC;;;;;;;;;;GAgB9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;GAAiD,CAAC;AAE9F,eAAO,MAAM,+BAA+B,gEAE3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,0DAA8C,CAAC;AAExF,KAAK,gCAAgC,GAAG;IACtC,iBAAiB,CAAC,EAAE,W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AAa,CAAC,CAAC;IACvD,cAAc,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;CAC9D,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,wDAAwD,CACtE,KAAK,EAAE,yBAAyB,GAC/B,qCAAqC,CAevC;AAED,2CAA2C;AAC3C,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,yBAAyB,CAAC,CAEpC;AAED,6DAA6D;AAC7D,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,yBAAyB,GAAG,QAAQ,CAAC,CAK/C"}
|
|
@@ -246,6 +246,7 @@ export function buildRuntimeAgentControlPlaneStreamRequestFromInvocation(input)
|
|
|
246
246
|
messages: input.messages,
|
|
247
247
|
tools: input.tools,
|
|
248
248
|
context: input.context,
|
|
249
|
+
runtimeTargetBranchId: input.run.project.runtimeTargetBranchId ?? null,
|
|
249
250
|
...(input.credentials ? { credentials: input.credentials } : {}),
|
|
250
251
|
agentSource: input.agentSource,
|
|
251
252
|
...(input.agentConfig ? { agentConfig: input.agentConfig } : {}),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Agent } from "../types.js";
|
|
2
|
+
type AgentSystem = Agent["config"]["system"];
|
|
3
|
+
/** Records the system resolver used by an agent's private runtime. */
|
|
4
|
+
export declare function setEffectiveAgentSystem(agent: Agent, system: AgentSystem): void;
|
|
5
|
+
/** Returns the effective runtime system resolver, including through config-preserving wrappers. */
|
|
6
|
+
export declare function getEffectiveAgentSystem(agent: Agent): AgentSystem;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=effective-agent-system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effective-agent-system.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/effective-agent-system.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,KAAK,WAAW,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC;AAU7C,sEAAsE;AACtE,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAE/E;AAED,mGAAmG;AACnG,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,GAAG,WAAW,CAEjE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const EFFECTIVE_AGENT_SYSTEM = Symbol("veryfront.effectiveAgentSystem");
|
|
2
|
+
/** Records the system resolver used by an agent's private runtime. */
|
|
3
|
+
export function setEffectiveAgentSystem(agent, system) {
|
|
4
|
+
agent.config[EFFECTIVE_AGENT_SYSTEM] = system;
|
|
5
|
+
}
|
|
6
|
+
/** Returns the effective runtime system resolver, including through config-preserving wrappers. */
|
|
7
|
+
export function getEffectiveAgentSystem(agent) {
|
|
8
|
+
return agent.config[EFFECTIVE_AGENT_SYSTEM] ?? agent.config.system;
|
|
9
|
+
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import type { DataResult } from "./types.js";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Redirect the request from a data loader.
|
|
4
|
+
*
|
|
5
|
+
* Return it or throw it. `throw redirect("/login")` behaves exactly like
|
|
6
|
+
* `return redirect("/login")`.
|
|
7
|
+
*/
|
|
3
8
|
export declare function redirect(destination: string, permanent?: boolean): DataResult;
|
|
4
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Render the 404 page from a data loader.
|
|
11
|
+
*
|
|
12
|
+
* Return it or throw it. `throw notFound()` behaves exactly like
|
|
13
|
+
* `return notFound()`, which is useful deep inside a helper that has no clean
|
|
14
|
+
* way to return to the loader.
|
|
15
|
+
*/
|
|
5
16
|
export declare function notFound(): DataResult;
|
|
6
17
|
/**
|
|
7
18
|
* True when `value` is a control-flow result produced by {@link notFound} or
|
|
@@ -11,8 +22,14 @@ export declare function notFound(): DataResult;
|
|
|
11
22
|
* naturally and is what people coming from other frameworks reach for. Thrown,
|
|
12
23
|
* the plain object is not an `Error`, so the SSR error handler stringified it
|
|
13
24
|
* to `[object Object]` and returned a 500 instead of the intended 404 or
|
|
14
|
-
* redirect. Recognising the
|
|
25
|
+
* redirect. Recognising the brand lets a thrown result behave like a returned
|
|
15
26
|
* one.
|
|
27
|
+
*
|
|
28
|
+
* The check is on the brand, never on the shape. A loader that does
|
|
29
|
+
* `throw await response.json()` against an upstream answering
|
|
30
|
+
* `{ notFound: true, message: "record locked" }` is reporting a failure, and
|
|
31
|
+
* reading that as a 404 would render the wrong page, log nothing, and cache a
|
|
32
|
+
* 404 the site never asked for.
|
|
16
33
|
*/
|
|
17
34
|
export declare function isDataControlResult(value: unknown): value is DataResult;
|
|
18
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/src/data/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/src/data/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA2B7C;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,UAAU,CAE3E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,IAAI,UAAU,CAErC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAIvE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAGlE"}
|
package/esm/src/data/helpers.js
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Brand marking an object as produced by {@link notFound} or {@link redirect}.
|
|
3
|
+
*
|
|
4
|
+
* A registered symbol, so a result built by one copy of this module is
|
|
5
|
+
* recognised by another. Project code and the framework do not always share a
|
|
6
|
+
* module instance, and isolated data fetching crosses a realm boundary.
|
|
7
|
+
*
|
|
8
|
+
* Symbols are dropped by `structuredClone`, so the brand does not survive
|
|
9
|
+
* `postMessage`. Worker-side code normalises a thrown control result before it
|
|
10
|
+
* is posted back, while the object is still in-realm.
|
|
11
|
+
*/
|
|
12
|
+
const DATA_CONTROL_RESULT = Symbol.for("veryfront.dataControlResult");
|
|
13
|
+
/**
|
|
14
|
+
* Mark a result as framework-produced control flow.
|
|
15
|
+
*
|
|
16
|
+
* The brand is non-enumerable, so it stays out of `Object.keys`,
|
|
17
|
+
* `JSON.stringify`, and the `DataResult` schema. A returned control result
|
|
18
|
+
* behaves exactly as it did before the brand existed.
|
|
19
|
+
*/
|
|
20
|
+
function brandDataControlResult(result) {
|
|
21
|
+
Object.defineProperty(result, DATA_CONTROL_RESULT, { value: true });
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Redirect the request from a data loader.
|
|
26
|
+
*
|
|
27
|
+
* Return it or throw it. `throw redirect("/login")` behaves exactly like
|
|
28
|
+
* `return redirect("/login")`.
|
|
29
|
+
*/
|
|
2
30
|
export function redirect(destination, permanent = false) {
|
|
3
|
-
return { redirect: { destination, permanent } };
|
|
31
|
+
return brandDataControlResult({ redirect: { destination, permanent } });
|
|
4
32
|
}
|
|
5
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Render the 404 page from a data loader.
|
|
35
|
+
*
|
|
36
|
+
* Return it or throw it. `throw notFound()` behaves exactly like
|
|
37
|
+
* `return notFound()`, which is useful deep inside a helper that has no clean
|
|
38
|
+
* way to return to the loader.
|
|
39
|
+
*/
|
|
6
40
|
export function notFound() {
|
|
7
|
-
return { notFound: true };
|
|
41
|
+
return brandDataControlResult({ notFound: true });
|
|
8
42
|
}
|
|
9
43
|
/**
|
|
10
44
|
* True when `value` is a control-flow result produced by {@link notFound} or
|
|
@@ -14,19 +48,19 @@ export function notFound() {
|
|
|
14
48
|
* naturally and is what people coming from other frameworks reach for. Thrown,
|
|
15
49
|
* the plain object is not an `Error`, so the SSR error handler stringified it
|
|
16
50
|
* to `[object Object]` and returned a 500 instead of the intended 404 or
|
|
17
|
-
* redirect. Recognising the
|
|
51
|
+
* redirect. Recognising the brand lets a thrown result behave like a returned
|
|
18
52
|
* one.
|
|
53
|
+
*
|
|
54
|
+
* The check is on the brand, never on the shape. A loader that does
|
|
55
|
+
* `throw await response.json()` against an upstream answering
|
|
56
|
+
* `{ notFound: true, message: "record locked" }` is reporting a failure, and
|
|
57
|
+
* reading that as a 404 would render the wrong page, log nothing, and cache a
|
|
58
|
+
* 404 the site never asked for.
|
|
19
59
|
*/
|
|
20
60
|
export function isDataControlResult(value) {
|
|
21
61
|
if (value === null || typeof value !== "object")
|
|
22
62
|
return false;
|
|
23
|
-
|
|
24
|
-
return false;
|
|
25
|
-
const candidate = value;
|
|
26
|
-
if (candidate.notFound === true)
|
|
27
|
-
return true;
|
|
28
|
-
const destination = candidate.redirect?.destination;
|
|
29
|
-
return typeof destination === "string";
|
|
63
|
+
return value[DATA_CONTROL_RESULT] === true;
|
|
30
64
|
}
|
|
31
65
|
/**
|
|
32
66
|
* Reduce a thrown control result to the shape a returned one produces.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/static-data-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA2DxE,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,YAAY;IAFhC,OAAO,CAAC,oBAAoB,CAAoC;gBAE5C,YAAY,EAAE,YAAY;IAExC,KAAK,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IA4ChF,OAAO,CAAC,uBAAuB;YAMjB,iBAAiB;IAuB/B,OAAO,CAAC,eAAe;YAQT,iBAAiB;YA+BjB,UAAU;YAqEV,sBAAsB;
|
|
1
|
+
{"version":3,"file":"static-data-fetcher.d.ts","sourceRoot":"","sources":["../../../src/src/data/static-data-fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA2DxE,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,YAAY;IAFhC,OAAO,CAAC,oBAAoB,CAAoC;gBAE5C,YAAY,EAAE,YAAY;IAExC,KAAK,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IA4ChF,OAAO,CAAC,uBAAuB;YAMjB,iBAAiB;IAuB/B,OAAO,CAAC,eAAe;YAQT,iBAAiB;YA+BjB,UAAU;YAqEV,sBAAsB;IAuFpC;;;;;OAKG;IACH,OAAO,CAAC,QAAQ;CAIjB"}
|
|
@@ -188,6 +188,21 @@ export class StaticDataFetcher {
|
|
|
188
188
|
const start = performance.now();
|
|
189
189
|
try {
|
|
190
190
|
const result = await this.executeStaticData(getStaticData, context, REVALIDATION_TIMEOUT_MS, `getStaticData revalidation for ${pathname}`);
|
|
191
|
+
// A background revalidation refreshes a page that is already being
|
|
192
|
+
// served. A notFound or redirect is not a refreshed page, so keep
|
|
193
|
+
// the entry that is live and let the next revalidation try again.
|
|
194
|
+
// Storing it would serve a 404 for the previously healthy page, and
|
|
195
|
+
// a control result carries no revalidate interval, so the entry
|
|
196
|
+
// would never revalidate again either.
|
|
197
|
+
if (result.notFound || result.redirect) {
|
|
198
|
+
serverLogger.warn("DATA_REVALIDATION_CONTROL_RESULT background revalidation returned a control result, keeping the cached entry", {
|
|
199
|
+
pathname,
|
|
200
|
+
durationMs: Math.round(performance.now() - start),
|
|
201
|
+
cacheKey,
|
|
202
|
+
control: result.notFound ? "notFound" : "redirect",
|
|
203
|
+
});
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
191
206
|
this.storeCacheEntry(cacheKey, result);
|
|
192
207
|
}
|
|
193
208
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/renderer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../../src/src/html/hydration-script-builder/templates/renderer.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,cAoT7B,CAAC"}
|
|
@@ -3,17 +3,59 @@ export const getRendererScript = () => `
|
|
|
3
3
|
|
|
4
4
|
// True when a dynamic import failed because the module could not be
|
|
5
5
|
// fetched (404 / network), as opposed to being fetched and then failing to
|
|
6
|
-
// link or evaluate. Browsers
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// link or evaluate. Browsers word this as a TypeError naming the dynamic
|
|
7
|
+
// import itself; link failures are SyntaxErrors and evaluation failures are
|
|
8
|
+
// whatever the module threw. The wording is matched against the dynamic
|
|
9
|
+
// import phrases only, so app code throwing "Failed to load user profile"
|
|
10
|
+
// at module scope is not mistaken for a missing module.
|
|
9
11
|
function isModuleNotFoundError(error) {
|
|
10
12
|
if (!error) return false;
|
|
11
13
|
if (error instanceof SyntaxError) return false;
|
|
12
14
|
const message = String((error && error.message) || error);
|
|
13
|
-
return /(?:
|
|
15
|
+
return /(?:dynamically imported module|Importing a module script failed|Failed to load module script)/i
|
|
14
16
|
.test(message);
|
|
15
17
|
}
|
|
16
18
|
|
|
19
|
+
// Picks the error that describes the failure best. An error that proves a
|
|
20
|
+
// module was reached (link or evaluation) always beats one that only proves
|
|
21
|
+
// a URL could not be fetched, because a 404 on a path that was never
|
|
22
|
+
// expected to exist explains nothing. Otherwise the earlier error wins: it
|
|
23
|
+
// names the module the router actually intended to load.
|
|
24
|
+
function preferReachedModuleError(earlier, later) {
|
|
25
|
+
if (!earlier) return later;
|
|
26
|
+
if (!later) return earlier;
|
|
27
|
+
if (isModuleNotFoundError(earlier) && !isModuleNotFoundError(later)) return later;
|
|
28
|
+
return earlier;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Loads a Pages Router page, retrying at <route>/index.js because both
|
|
32
|
+
// pages/about.tsx and pages/about/index.tsx are valid sources for the same
|
|
33
|
+
// route. The retry is unconditional: gating it on the wording of the
|
|
34
|
+
// first rejection turned any unrecognized wording into a blank page. Error
|
|
35
|
+
// selection, not the retry, is what must stay precise.
|
|
36
|
+
async function loadPageModuleWithIndexFallback(
|
|
37
|
+
basePath,
|
|
38
|
+
pageSlug,
|
|
39
|
+
pageModuleError,
|
|
40
|
+
importModule,
|
|
41
|
+
) {
|
|
42
|
+
try {
|
|
43
|
+
return await importModule(basePath + '.js');
|
|
44
|
+
} catch (error) {
|
|
45
|
+
const routeError = preferReachedModuleError(pageModuleError, error);
|
|
46
|
+
|
|
47
|
+
// An index slug already resolves to <route>/index.js, so the retry
|
|
48
|
+
// would ask for <route>/index/index.js.
|
|
49
|
+
if (pageSlug === 'index' || pageSlug.endsWith('/index')) throw routeError;
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
return await importModule(basePath + '/index.js');
|
|
53
|
+
} catch (indexError) {
|
|
54
|
+
throw preferReachedModuleError(routeError, indexError);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
17
59
|
async function renderPage(pathname) {
|
|
18
60
|
const resolvedPathname = (() => {
|
|
19
61
|
const input = typeof pathname === 'string' ? pathname : window.location.pathname;
|
|
@@ -128,30 +170,12 @@ export const getRendererScript = () => `
|
|
|
128
170
|
const prefix = pageSlug.startsWith('@/') ? '' : '/pages';
|
|
129
171
|
const basePath = MODULE_SERVER_URL + prefix + '/' + pageSlug;
|
|
130
172
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
pageModuleError
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// be found. If it was found but failed to link or evaluate, retrying
|
|
138
|
-
// a path that does not exist replaces a precise error ("does not
|
|
139
|
-
// provide an export named 'createHash'") with a misleading 404.
|
|
140
|
-
const canRetryAsIndex = isModuleNotFoundError(error) &&
|
|
141
|
-
pageSlug !== 'index' && !pageSlug.endsWith('/index');
|
|
142
|
-
|
|
143
|
-
if (!canRetryAsIndex) throw pageModuleError;
|
|
144
|
-
|
|
145
|
-
try {
|
|
146
|
-
pageModule = await import(basePath + '/index.js');
|
|
147
|
-
} catch (indexError) {
|
|
148
|
-
// For a real <route>/index.tsx page, the first 404 was expected
|
|
149
|
-
// and this retry is the path that matters: if it reached a module
|
|
150
|
-
// and failed to link or evaluate, its error is the real one. Only
|
|
151
|
-
// when the retry 404s as well does the original describe more.
|
|
152
|
-
throw isModuleNotFoundError(indexError) ? pageModuleError : indexError;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
173
|
+
pageModule = await loadPageModuleWithIndexFallback(
|
|
174
|
+
basePath,
|
|
175
|
+
pageSlug,
|
|
176
|
+
pageModuleError,
|
|
177
|
+
(moduleUrl) => import(moduleUrl),
|
|
178
|
+
);
|
|
155
179
|
}
|
|
156
180
|
|
|
157
181
|
if (!pageModule) {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|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AAQ,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;AAoXD,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,QAAQ,CAAC,CAqdnB"}
|
|
@@ -3,6 +3,8 @@ import { normalizeAgUiRuntimeMessages } from "../agent/ag-ui/runtime-support.js"
|
|
|
3
3
|
import { compactForStep, estimateOverhead } from "../chat/message-prep.js";
|
|
4
4
|
import { getRuntimeRemoteToolSources, } from "../agent/runtime/mcp-server-tool-sources.js";
|
|
5
5
|
import { buildRuntimeUsageTraceAttributes } from "../agent/runtime/trace-usage.js";
|
|
6
|
+
import { getProviderNativeToolNames } from "../agent/runtime/provider-native-tool-inventory.js";
|
|
7
|
+
import { selectProviderCompatibleToolNames } from "../agent/runtime/provider-tool-compat.js";
|
|
6
8
|
import { convertAgentRuntimeMessagesToProviderMessages, convertProviderMessagesToAgentRuntimeMessages, } from "../agent/runtime/message-adapter.js";
|
|
7
9
|
import { createAgentServiceSandboxTools } from "../sandbox/index.js";
|
|
8
10
|
import { tryResolve } from "../extensions/contracts.js";
|
|
@@ -15,6 +17,7 @@ import { addSpanEvent, setSpanAttributes, withSpan, } from "../observability/tra
|
|
|
15
17
|
import { defineSchema, lazySchema } from "../schemas/index.js";
|
|
16
18
|
import { createStreamTransformState, finalizeRunEvents, formatAgUiEvent, mapRuntimeEventToAgUi, parseSseJsonEvents, } from "./ag-ui-sse.js";
|
|
17
19
|
import { AgentRunCancelledError } from "./session-manager.js";
|
|
20
|
+
import { createInternalAgentRunSystemPromptResolver } from "./run-system-prompt.js";
|
|
18
21
|
import { serverLogger } from "../utils/index.js";
|
|
19
22
|
const getAnyObjectSchema = defineSchema((v) => v.record(v.string(), v.unknown()));
|
|
20
23
|
const anyObjectSchema = lazySchema(getAnyObjectSchema);
|
|
@@ -303,6 +306,23 @@ function applyRuntimeToolAllowlist(mergedTools, toolAllowlist, agent) {
|
|
|
303
306
|
}
|
|
304
307
|
return Object.fromEntries(Object.entries(mergedTools).filter(([toolName]) => allowedToolNames.has(toolName)));
|
|
305
308
|
}
|
|
309
|
+
function getRequiredLocalToolNames(input) {
|
|
310
|
+
if (!input.mergedTools || input.mergedTools === true) {
|
|
311
|
+
return [];
|
|
312
|
+
}
|
|
313
|
+
return Object.entries(input.mergedTools)
|
|
314
|
+
.filter(([toolName, entry]) => {
|
|
315
|
+
if (entry && typeof entry === "object") {
|
|
316
|
+
return true;
|
|
317
|
+
}
|
|
318
|
+
if (Object.hasOwn(input.availableLocalTools, toolName)) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
const registryTool = toolRegistry.get(toolName);
|
|
322
|
+
return Boolean(registryTool && isToolVisibleTo(registryTool, { agentId: input.agent.id }));
|
|
323
|
+
})
|
|
324
|
+
.map(([toolName]) => toolName);
|
|
325
|
+
}
|
|
306
326
|
function getServerResolvedProjectToolNames(forwardedProps) {
|
|
307
327
|
const runtimeOverrides = isRecord(forwardedProps?.runtimeOverrides)
|
|
308
328
|
? forwardedProps.runtimeOverrides
|
|
@@ -430,10 +450,43 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
|
|
|
430
450
|
const cappedProviderTools = runtimeToolAllowlist !== null && Array.isArray(agent.config.providerTools)
|
|
431
451
|
? agent.config.providerTools.filter((toolName) => typeof toolName === "string" && runtimeToolAllowlist.has(toolName))
|
|
432
452
|
: undefined;
|
|
453
|
+
const effectiveProviderToolNames = cappedProviderTools ??
|
|
454
|
+
(Array.isArray(agent.config.providerTools)
|
|
455
|
+
? agent.config.providerTools.filter((toolName) => typeof toolName === "string")
|
|
456
|
+
: []);
|
|
457
|
+
const modelSupportedProviderToolNames = new Set(getProviderNativeToolNames({ model: agent.config.model }));
|
|
458
|
+
const providerToolNames = effectiveProviderToolNames.filter((toolName) => modelSupportedProviderToolNames.has(toolName));
|
|
459
|
+
const mergedToolNames = mergedTools && mergedTools !== true ? Object.keys(mergedTools) : [];
|
|
460
|
+
const allowedRemoteToolNameSet = new Set(allowedRemoteToolNames ?? []);
|
|
461
|
+
const forwardedToolNames = (forwardedIntegrationToolDefs?.map((def) => def.name) ?? [])
|
|
462
|
+
.filter((toolName) => allowedRemoteToolNameSet.has(toolName));
|
|
463
|
+
const localToolNames = getRequiredLocalToolNames({
|
|
464
|
+
mergedTools,
|
|
465
|
+
availableLocalTools,
|
|
466
|
+
agent,
|
|
467
|
+
});
|
|
468
|
+
const runtimeToolNames = selectProviderCompatibleToolNames([
|
|
469
|
+
...new Set([
|
|
470
|
+
...mergedToolNames,
|
|
471
|
+
...providerToolNames,
|
|
472
|
+
...(allowedRemoteToolNames ?? []),
|
|
473
|
+
...forwardedToolNames,
|
|
474
|
+
]),
|
|
475
|
+
].sort(), {
|
|
476
|
+
model: agent.config.model,
|
|
477
|
+
requiredToolNames: localToolNames,
|
|
478
|
+
});
|
|
433
479
|
const runtimeAgent = {
|
|
434
480
|
...agent,
|
|
435
481
|
config: {
|
|
436
482
|
...agent.config,
|
|
483
|
+
system: createInternalAgentRunSystemPromptResolver({
|
|
484
|
+
agent,
|
|
485
|
+
runInput: input,
|
|
486
|
+
projectId: deps.projectAgentSandbox?.projectId ?? null,
|
|
487
|
+
branchId: deps.projectAgentSandbox?.branchId,
|
|
488
|
+
toolNames: runtimeToolNames,
|
|
489
|
+
}),
|
|
437
490
|
tools: mergedTools,
|
|
438
491
|
...(cappedProviderTools !== undefined ? { providerTools: cappedProviderTools } : {}),
|
|
439
492
|
...(allowedRemoteToolNames !== undefined
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal Agent Run System Prompt
|
|
3
|
+
*
|
|
4
|
+
* Composes the system prompt for project-runtime agent runs, mirroring the
|
|
5
|
+
* hosted chat runtime's instruction assembly. Before this, internal runs used
|
|
6
|
+
* the agent's authored instructions verbatim, so request-scoped agents (e.g.
|
|
7
|
+
* Studio-created project agents) never learned the project reference, branch,
|
|
8
|
+
* Studio environment context, or effective tool surface of the run they were
|
|
9
|
+
* executing in and asked users for values the harness already knew.
|
|
10
|
+
*
|
|
11
|
+
* The composed prompt extends the agent's resolved base instructions (which
|
|
12
|
+
* already include the factory's skill manifest for skill-enabled agents) with:
|
|
13
|
+
* - the shared project-context block (project reference + branch)
|
|
14
|
+
* - the requested model
|
|
15
|
+
* - the caller-supplied environment context (`studio_context` context item)
|
|
16
|
+
* - the effective run tool inventory
|
|
17
|
+
*
|
|
18
|
+
* @module
|
|
19
|
+
*/
|
|
20
|
+
import type { Agent } from "../agent/index.js";
|
|
21
|
+
import type { RuntimeRunAgentInput } from "./schema.js";
|
|
22
|
+
/** Caller-supplied run context extracted from the `studio_context` item. */
|
|
23
|
+
export type InternalAgentStudioRunContext = {
|
|
24
|
+
environmentContext?: string;
|
|
25
|
+
projectId?: string;
|
|
26
|
+
branchId?: string | null;
|
|
27
|
+
};
|
|
28
|
+
/** Extracts the Studio-supplied run context from run context items. */
|
|
29
|
+
export declare function getInternalAgentStudioRunContext(context: RuntimeRunAgentInput["context"]): InternalAgentStudioRunContext;
|
|
30
|
+
/** Input payload for compose internal agent run system prompt. */
|
|
31
|
+
export type ComposeInternalAgentRunSystemPromptInput = {
|
|
32
|
+
agent: Agent;
|
|
33
|
+
runInput: RuntimeRunAgentInput;
|
|
34
|
+
projectId?: string | null;
|
|
35
|
+
branchId?: string | null;
|
|
36
|
+
toolNames: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
/** Composes the internal agent run system prompt. */
|
|
39
|
+
export declare function composeInternalAgentRunSystemPrompt(input: ComposeInternalAgentRunSystemPromptInput): Promise<string>;
|
|
40
|
+
/** Creates a lazy system prompt resolver for an internal agent run. */
|
|
41
|
+
export declare function createInternalAgentRunSystemPromptResolver(input: ComposeInternalAgentRunSystemPromptInput): () => Promise<string>;
|
|
42
|
+
//# sourceMappingURL=run-system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-system-prompt.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/run-system-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAU/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAKxD,4EAA4E;AAC5E,MAAM,MAAM,6BAA6B,GAAG;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAqBF,uEAAuE;AACvE,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACvC,6BAA6B,CAmB/B;AAYD,kEAAkE;AAClE,MAAM,MAAM,wCAAwC,GAAG;IACrD,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAAC;AAEF,qDAAqD;AACrD,wBAAsB,mCAAmC,CACvD,KAAK,EAAE,wCAAwC,GAC9C,OAAO,CAAC,MAAM,CAAC,CAwCjB;AAED,uEAAuE;AACvE,wBAAgB,0CAA0C,CACxD,KAAK,EAAE,wCAAwC,GAC9C,MAAM,OAAO,CAAC,MAAM,CAAC,CAEvB"}
|