veryfront 0.1.1158 → 0.1.1160
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/cli/commands/deploy/command.d.ts +15 -0
- package/esm/cli/commands/deploy/command.d.ts.map +1 -1
- package/esm/cli/commands/deploy/command.js +227 -16
- package/esm/cli/commands/deploy/index.d.ts +2 -2
- package/esm/cli/commands/deploy/index.d.ts.map +1 -1
- package/esm/cli/commands/deploy/index.js +1 -1
- package/esm/deno.js +1 -1
- package/esm/src/agent/runtime/tool-helpers.d.ts.map +1 -1
- package/esm/src/agent/runtime/tool-helpers.js +34 -6
- package/esm/src/agent/streaming/fork-runtime-part-mapper.d.ts.map +1 -1
- package/esm/src/agent/streaming/fork-runtime-part-mapper.js +3 -1
- package/esm/src/agent/streaming/fork-runtime-stream.d.ts.map +1 -1
- package/esm/src/agent/streaming/fork-runtime-stream.js +10 -1
- package/esm/src/html/html-injection.d.ts +3 -0
- package/esm/src/html/html-injection.d.ts.map +1 -1
- package/esm/src/html/html-injection.js +6 -2
- package/esm/src/release-assets/build-executor.d.ts.map +1 -1
- package/esm/src/release-assets/build-executor.js +34 -31
- package/esm/src/release-assets/client-module-map.d.ts +3 -1
- package/esm/src/release-assets/client-module-map.d.ts.map +1 -1
- package/esm/src/release-assets/client-module-map.js +18 -3
- package/esm/src/release-assets/route-path.d.ts +8 -0
- package/esm/src/release-assets/route-path.d.ts.map +1 -1
- package/esm/src/release-assets/route-path.js +39 -0
- package/esm/src/rendering/orchestrator/html.d.ts.map +1 -1
- package/esm/src/rendering/orchestrator/html.js +1 -0
- package/esm/src/tool/host-tools.d.ts.map +1 -1
- package/esm/src/tool/host-tools.js +10 -2
- package/esm/src/tool/remote-source-tools.d.ts.map +1 -1
- package/esm/src/tool/remote-source-tools.js +13 -11
- package/esm/src/tool/remote-tool-provenance.d.ts +5 -0
- package/esm/src/tool/remote-tool-provenance.d.ts.map +1 -0
- package/esm/src/tool/remote-tool-provenance.js +19 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -5
|
@@ -45,6 +45,8 @@ export type DeployOptions = Omit<ParsedDeployOptions, "skipSourcePush"> & {
|
|
|
45
45
|
skipSourcePush?: boolean;
|
|
46
46
|
assetManifestPollIntervalMs?: number;
|
|
47
47
|
assetManifestTimeoutMs?: number;
|
|
48
|
+
environmentPollIntervalMs?: number;
|
|
49
|
+
environmentTimeoutMs?: number;
|
|
48
50
|
};
|
|
49
51
|
/**
|
|
50
52
|
* Parse CLI arguments into validated DeployOptions
|
|
@@ -133,6 +135,18 @@ export interface ReleaseSourceVerification {
|
|
|
133
135
|
commitSha: string | null;
|
|
134
136
|
sourceDigest: string;
|
|
135
137
|
}
|
|
138
|
+
export interface EnvironmentReadinessOptions {
|
|
139
|
+
pollIntervalMs?: number;
|
|
140
|
+
timeoutMs?: number;
|
|
141
|
+
}
|
|
142
|
+
export interface EnvironmentReadinessTarget {
|
|
143
|
+
projectSlug: string;
|
|
144
|
+
environmentName: string;
|
|
145
|
+
url: string;
|
|
146
|
+
route?: string | null;
|
|
147
|
+
protected: boolean;
|
|
148
|
+
apiToken: string;
|
|
149
|
+
}
|
|
136
150
|
interface ReleaseSourceExpectation {
|
|
137
151
|
projectId: string;
|
|
138
152
|
releaseId: string;
|
|
@@ -196,6 +210,7 @@ export declare function resolvePushedSource(input: {
|
|
|
196
210
|
commitSha: string | null;
|
|
197
211
|
sourceDigest: string;
|
|
198
212
|
}>;
|
|
213
|
+
export declare function waitForEnvironmentReady(target: EnvironmentReadinessTarget, options?: EnvironmentReadinessOptions): Promise<void>;
|
|
199
214
|
export declare function waitForReleaseAssetManifest(client: ApiClient, projectSlug: string, releaseId: string, options?: {
|
|
200
215
|
expectedRoutes?: string[];
|
|
201
216
|
pollIntervalMs?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAI3E,OAAO,EACL,KAAK,SAAS,EAOf,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAIL,KAAK,aAAa,EAInB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAI3E,OAAO,EACL,KAAK,SAAS,EAOf,MAAM,wBAAwB,CAAC;AAShC,OAAO,EAIL,KAAK,aAAa,EAInB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAKnG;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;IAQ5B,oDAAoD;;IAEpD,mEAAmE;;GAGtE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;IAPzB,oDAAoD;;IAEpD,mEAAmE;;GAKR,CAAC;AAEhE;;GAEG;AACH,KAAK,mBAAmB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC;AAC/E,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,EAAE,gBAAgB,CAAC,GAAG;IACxE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;IAxBxB,oDAAoD;;IAEp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B,uBAAuB,CAC3C,MAAM,EAAE,0BAA0B,EAClC,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,IAAI,CAAC,CAiEf;AAgND,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,OAAO,CAAC,4BAA4B,CAAC,CAmCvC;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAkNzE"}
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @module cli/commands/deploy
|
|
8
8
|
*/
|
|
9
9
|
import { defineSchema, lazySchema } from "../../../src/schemas/index.js";
|
|
10
|
-
import { createFileSystem, cwd } from "../../../src/platform/index.js";
|
|
11
|
-
import { join, relative } from "../../../src/platform/compat/path/index.js";
|
|
12
|
-
import { getEnvironmentConfig } from "../../../src/config/index.js";
|
|
10
|
+
import { createFileSystem, cwd, runtime } from "../../../src/platform/index.js";
|
|
11
|
+
import { join, relative, resolve } from "../../../src/platform/compat/path/index.js";
|
|
12
|
+
import { getConfig, getEnvironmentConfig } from "../../../src/config/index.js";
|
|
13
13
|
import { createApiClient, readConfigFile, resolveConfigWithAuth, resolveConfigWithAuthDetails, writeProjectSlug, } from "../../shared/config.js";
|
|
14
14
|
import { CommonArgs, createArgParser } from "../../shared/args.js";
|
|
15
15
|
import { confirmPrompt, logInfo, logSuccess, logWarning } from "../../utils/index.js";
|
|
@@ -21,6 +21,8 @@ import { isAutoConfirmEnabled } from "../../shared/interactive.js";
|
|
|
21
21
|
import { isJsonMode, streamJsonLine } from "../../shared/json-output.js";
|
|
22
22
|
import { computeSourceDigest, getProjectTarget, normalizeControlPlane, readPushReceipt, resolveGitSource, validatePushReceipt, } from "../../shared/deployment-provenance.js";
|
|
23
23
|
import { routeForPage } from "../../../src/release-assets/route-path.js";
|
|
24
|
+
import { parseProjectDomain } from "../../../src/server/utils/domain-parser.js";
|
|
25
|
+
import { isWithinDirectory, normalizePath } from "../../../src/utils/path-utils.js";
|
|
24
26
|
/**
|
|
25
27
|
* Schema factory for deploy command arguments
|
|
26
28
|
*/
|
|
@@ -54,6 +56,8 @@ export function requiresExplicitDeployConfirmation(force) {
|
|
|
54
56
|
}
|
|
55
57
|
const MAX_RELEASE_SOURCE_VERIFICATION_ATTEMPTS = 20;
|
|
56
58
|
const MAX_RELEASE_SOURCE_VERIFICATION_DELAY_MS = 500;
|
|
59
|
+
const DEFAULT_ENVIRONMENT_POLL_INTERVAL_MS = 2_000;
|
|
60
|
+
const DEFAULT_ENVIRONMENT_TIMEOUT_MS = 120_000;
|
|
57
61
|
// Release creation can precede source-snapshot materialization. Only a
|
|
58
62
|
// successfully read, well-formed digest mismatch enters this convergence loop;
|
|
59
63
|
// validation and exhausted API-client transport errors still fail closed.
|
|
@@ -318,6 +322,154 @@ function buildEnvironmentUrl(projectSlug, environment) {
|
|
|
318
322
|
}
|
|
319
323
|
return `https://${projectSlug}.${environment.name}.veryfront.com`;
|
|
320
324
|
}
|
|
325
|
+
function buildCanonicalEnvironmentUrl(projectSlug, environmentName) {
|
|
326
|
+
return `https://${projectSlug}.${environmentName}.veryfront.com`;
|
|
327
|
+
}
|
|
328
|
+
function isMatchingVeryfrontHostedUrl(url, target) {
|
|
329
|
+
const hostname = url.hostname.toLowerCase();
|
|
330
|
+
if (!hostname.endsWith(".veryfront.com") && !hostname.endsWith(".veryfront.org")) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
const parsed = parseProjectDomain(hostname);
|
|
334
|
+
return parsed.isVeryfrontDomain &&
|
|
335
|
+
parsed.slug === target.projectSlug.toLowerCase() &&
|
|
336
|
+
parsed.environment === target.environmentName.toLowerCase();
|
|
337
|
+
}
|
|
338
|
+
function isVeryfrontSignInUrl(url) {
|
|
339
|
+
const hostname = url.hostname.toLowerCase();
|
|
340
|
+
return (hostname === "veryfront.com" || hostname === "veryfront.org") &&
|
|
341
|
+
(url.pathname === "/sign-in" || url.pathname.startsWith("/sign-in/"));
|
|
342
|
+
}
|
|
343
|
+
function buildEnvironmentProbeUrl(baseUrl, route) {
|
|
344
|
+
let url;
|
|
345
|
+
try {
|
|
346
|
+
url = new URL(baseUrl);
|
|
347
|
+
}
|
|
348
|
+
catch {
|
|
349
|
+
throw new Error(`Environment URL "${baseUrl}" is invalid. Check the environment configuration and deploy again.`);
|
|
350
|
+
}
|
|
351
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
352
|
+
throw new Error(`Environment URL "${baseUrl}" must use HTTP or HTTPS. Check the environment configuration and deploy again.`);
|
|
353
|
+
}
|
|
354
|
+
if (!route.startsWith("/")) {
|
|
355
|
+
throw new Error(`Environment readiness route "${route}" must start with "/".`);
|
|
356
|
+
}
|
|
357
|
+
const probeUrl = new URL(route, url);
|
|
358
|
+
return route === "/" ? probeUrl.origin : probeUrl.href;
|
|
359
|
+
}
|
|
360
|
+
function secureEnvironmentProbeUrl(url) {
|
|
361
|
+
const secureUrl = new URL(url);
|
|
362
|
+
secureUrl.protocol = "https:";
|
|
363
|
+
return secureUrl.href;
|
|
364
|
+
}
|
|
365
|
+
function buildEnvironmentReadinessProbes(target) {
|
|
366
|
+
const route = target.route === undefined ? "/" : target.route;
|
|
367
|
+
if (route === null)
|
|
368
|
+
return [];
|
|
369
|
+
const targetUrl = buildEnvironmentProbeUrl(target.url, route);
|
|
370
|
+
if (target.protected && !isMatchingVeryfrontHostedUrl(new URL(targetUrl), target)) {
|
|
371
|
+
return [
|
|
372
|
+
{
|
|
373
|
+
url: targetUrl,
|
|
374
|
+
authenticate: false,
|
|
375
|
+
acceptAuthenticationChallenge: true,
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
url: buildEnvironmentProbeUrl(buildCanonicalEnvironmentUrl(target.projectSlug, target.environmentName), route),
|
|
379
|
+
authenticate: true,
|
|
380
|
+
acceptAuthenticationChallenge: false,
|
|
381
|
+
},
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
return [{
|
|
385
|
+
url: target.protected ? secureEnvironmentProbeUrl(targetUrl) : targetUrl,
|
|
386
|
+
authenticate: target.protected,
|
|
387
|
+
acceptAuthenticationChallenge: false,
|
|
388
|
+
}];
|
|
389
|
+
}
|
|
390
|
+
function isSignInRedirect(response, requestUrl) {
|
|
391
|
+
if (response.status < 300 || response.status >= 400)
|
|
392
|
+
return false;
|
|
393
|
+
const location = response.headers.get("location");
|
|
394
|
+
if (!location)
|
|
395
|
+
return false;
|
|
396
|
+
try {
|
|
397
|
+
return isVeryfrontSignInUrl(new URL(location, requestUrl));
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function isTransientEnvironmentStatus(status) {
|
|
404
|
+
return status === 404 || status === 408 || status === 425 || status === 429 ||
|
|
405
|
+
status >= 500;
|
|
406
|
+
}
|
|
407
|
+
async function cancelResponseBody(response) {
|
|
408
|
+
try {
|
|
409
|
+
await response.body?.cancel();
|
|
410
|
+
}
|
|
411
|
+
catch {
|
|
412
|
+
// Readiness does not depend on response payload cleanup.
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
export async function waitForEnvironmentReady(target, options = {}) {
|
|
416
|
+
const pollIntervalMs = options.pollIntervalMs === undefined ||
|
|
417
|
+
!Number.isFinite(options.pollIntervalMs)
|
|
418
|
+
? DEFAULT_ENVIRONMENT_POLL_INTERVAL_MS
|
|
419
|
+
: Math.max(1, Math.trunc(options.pollIntervalMs));
|
|
420
|
+
const timeoutMs = options.timeoutMs === undefined || !Number.isFinite(options.timeoutMs)
|
|
421
|
+
? DEFAULT_ENVIRONMENT_TIMEOUT_MS
|
|
422
|
+
: Math.max(1, Math.trunc(options.timeoutMs));
|
|
423
|
+
const deadline = Date.now() + timeoutMs;
|
|
424
|
+
for (const probe of buildEnvironmentReadinessProbes(target)) {
|
|
425
|
+
const headers = new Headers({ "Cache-Control": "no-cache" });
|
|
426
|
+
if (probe.authenticate) {
|
|
427
|
+
headers.set("Cookie", `authToken=${target.apiToken}`);
|
|
428
|
+
}
|
|
429
|
+
let lastResponse = "no response";
|
|
430
|
+
for (;;) {
|
|
431
|
+
let response;
|
|
432
|
+
try {
|
|
433
|
+
response = await fetch(probe.url, {
|
|
434
|
+
method: "GET",
|
|
435
|
+
redirect: "manual",
|
|
436
|
+
headers,
|
|
437
|
+
signal: AbortSignal.timeout(Math.max(1, deadline - Date.now())),
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
lastResponse = "network error";
|
|
442
|
+
}
|
|
443
|
+
if (response) {
|
|
444
|
+
lastResponse = `HTTP ${response.status}`;
|
|
445
|
+
const signInRedirect = isSignInRedirect(response, probe.url);
|
|
446
|
+
const authenticationChallenge = signInRedirect ||
|
|
447
|
+
response.status === 401 ||
|
|
448
|
+
response.status === 403;
|
|
449
|
+
const ready = response.status >= 200 && response.status < 300 ||
|
|
450
|
+
response.status >= 300 && response.status < 400 && !signInRedirect ||
|
|
451
|
+
probe.acceptAuthenticationChallenge && authenticationChallenge;
|
|
452
|
+
await cancelResponseBody(response);
|
|
453
|
+
if (ready)
|
|
454
|
+
break;
|
|
455
|
+
if (authenticationChallenge) {
|
|
456
|
+
const message = probe.authenticate
|
|
457
|
+
? `Could not authenticate the protected environment URL ${probe.url}. Run veryfront login and deploy again.`
|
|
458
|
+
: `Environment URL ${probe.url} redirected to sign-in. Check its protection settings and deploy again.`;
|
|
459
|
+
throw new Error(message);
|
|
460
|
+
}
|
|
461
|
+
if (!isTransientEnvironmentStatus(response.status)) {
|
|
462
|
+
throw new Error(`Environment URL ${probe.url} returned HTTP ${response.status}. Check the environment configuration and deploy again.`);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const remainingMs = deadline - Date.now();
|
|
466
|
+
if (remainingMs <= 0) {
|
|
467
|
+
throw new Error(`Environment URL ${probe.url} did not become ready within ${Math.ceil(timeoutMs / 1000)}s (last response: ${lastResponse}). Check the deployment and run deploy again.`);
|
|
468
|
+
}
|
|
469
|
+
await wait(Math.min(pollIntervalMs, remainingMs));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
321
473
|
async function inferDeployProjectSlug(projectDir) {
|
|
322
474
|
const fs = createFileSystem();
|
|
323
475
|
const packagePath = join(projectDir, "package.json");
|
|
@@ -394,10 +546,36 @@ async function ensureProjectLinkedForDeploy(projectDir, env, dryRun, quiet) {
|
|
|
394
546
|
plannedProjectSlug: created.slug,
|
|
395
547
|
};
|
|
396
548
|
}
|
|
549
|
+
async function getProjectRouteDirectories(projectDir) {
|
|
550
|
+
const adapter = await runtime.get();
|
|
551
|
+
const config = await getConfig(projectDir, adapter);
|
|
552
|
+
return {
|
|
553
|
+
app: normalizeConfiguredRouteDirectory(config.directories?.app ?? "app"),
|
|
554
|
+
pages: normalizeConfiguredRouteDirectory(config.directories?.pages ?? "pages"),
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
function normalizeConfiguredRouteDirectory(path) {
|
|
558
|
+
return path.replace(/\\/g, "/");
|
|
559
|
+
}
|
|
560
|
+
function isAbsoluteConfiguredRouteDirectory(path) {
|
|
561
|
+
return path.startsWith("/") || /^[A-Za-z]:\//.test(path);
|
|
562
|
+
}
|
|
563
|
+
function resolveProjectRouteDirectory(projectDir, directory, name) {
|
|
564
|
+
if (isAbsoluteConfiguredRouteDirectory(directory)) {
|
|
565
|
+
throw new Error(`Configured ${name} directory "${directory}" must be project-relative. Set directories.${name} to a path inside the project, for example "${name}" or "src/${name}".`);
|
|
566
|
+
}
|
|
567
|
+
const projectRoot = normalizePath(projectDir);
|
|
568
|
+
const routeRoot = normalizePath(resolve(projectRoot, directory));
|
|
569
|
+
if (!isWithinDirectory(projectRoot, routeRoot)) {
|
|
570
|
+
throw new Error(`Configured ${name} directory "${directory}" resolves outside the project directory. Set directories.${name} to a project-relative path inside the project.`);
|
|
571
|
+
}
|
|
572
|
+
return routeRoot;
|
|
573
|
+
}
|
|
397
574
|
async function collectProjectPageRoutes(projectDir) {
|
|
398
575
|
const fs = createFileSystem();
|
|
576
|
+
const directories = await getProjectRouteDirectories(projectDir);
|
|
399
577
|
const routes = new Set();
|
|
400
|
-
async function walk(dir) {
|
|
578
|
+
async function walk(rootDir, dir, routeRoot) {
|
|
401
579
|
let entries;
|
|
402
580
|
try {
|
|
403
581
|
if (!(await fs.exists(dir)))
|
|
@@ -410,23 +588,25 @@ async function collectProjectPageRoutes(projectDir) {
|
|
|
410
588
|
for await (const entry of entries) {
|
|
411
589
|
const path = join(dir, entry.name);
|
|
412
590
|
if (entry.isDirectory) {
|
|
413
|
-
await walk(path);
|
|
591
|
+
await walk(rootDir, path, routeRoot);
|
|
414
592
|
continue;
|
|
415
593
|
}
|
|
416
594
|
if (!/\.(tsx|ts|jsx|mdx|js)$/.test(entry.name))
|
|
417
595
|
continue;
|
|
418
|
-
const relativePath = relative(
|
|
596
|
+
const relativePath = relative(rootDir, path).replace(/\\/g, "/");
|
|
419
597
|
if (relativePath === "." || relativePath === ".." || relativePath.startsWith("../")) {
|
|
420
598
|
continue;
|
|
421
599
|
}
|
|
422
|
-
const route = routeForPage(relativePath);
|
|
600
|
+
const route = routeForPage(`${routeRoot}/${relativePath}`);
|
|
423
601
|
if (route)
|
|
424
602
|
routes.add(route);
|
|
425
603
|
}
|
|
426
604
|
}
|
|
605
|
+
const appDir = resolveProjectRouteDirectory(projectDir, directories.app, "app");
|
|
606
|
+
const pagesDir = resolveProjectRouteDirectory(projectDir, directories.pages, "pages");
|
|
427
607
|
await Promise.all([
|
|
428
|
-
walk(
|
|
429
|
-
walk(
|
|
608
|
+
walk(appDir, appDir, "app"),
|
|
609
|
+
walk(pagesDir, pagesDir, "pages"),
|
|
430
610
|
]);
|
|
431
611
|
return [...routes].sort();
|
|
432
612
|
}
|
|
@@ -478,7 +658,7 @@ export async function waitForReleaseAssetManifest(client, projectSlug, releaseId
|
|
|
478
658
|
* Create a release and deploy to an environment
|
|
479
659
|
*/
|
|
480
660
|
export async function deployCommand(options) {
|
|
481
|
-
const { projectDir = cwd(), branch, env, releaseName, dryRun, force, quiet, skipSourcePush, assetManifestPollIntervalMs, assetManifestTimeoutMs, } = options;
|
|
661
|
+
const { projectDir = cwd(), branch, env, releaseName, dryRun, force, quiet, skipSourcePush, assetManifestPollIntervalMs, assetManifestTimeoutMs, environmentPollIntervalMs, environmentTimeoutMs, } = options;
|
|
482
662
|
if (isJsonMode()) {
|
|
483
663
|
return deployCommandJson(options);
|
|
484
664
|
}
|
|
@@ -486,11 +666,13 @@ export async function deployCommand(options) {
|
|
|
486
666
|
const environmentConfig = getEnvironmentConfig();
|
|
487
667
|
const setup = await ensureProjectLinkedForDeploy(projectDir, environmentConfig, dryRun, quiet);
|
|
488
668
|
let { config, client, project } = setup;
|
|
489
|
-
const expectedPageRoutes = await collectProjectPageRoutes(projectDir);
|
|
490
669
|
if (dryRun && !project) {
|
|
491
670
|
spinner.stop();
|
|
492
671
|
if (!quiet) {
|
|
493
|
-
|
|
672
|
+
const actions = skipSourcePush
|
|
673
|
+
? `create release and deploy to "${env}"`
|
|
674
|
+
: `push source to "${branch}", create release, and deploy to "${env}"`;
|
|
675
|
+
logInfo(`Would ${actions} for project ${setup.plannedProjectSlug}`);
|
|
494
676
|
}
|
|
495
677
|
return;
|
|
496
678
|
}
|
|
@@ -566,6 +748,7 @@ export async function deployCommand(options) {
|
|
|
566
748
|
let release;
|
|
567
749
|
let deployment;
|
|
568
750
|
let verification;
|
|
751
|
+
let environmentUrl;
|
|
569
752
|
try {
|
|
570
753
|
release = await createRelease(client, project.id, { name: releaseName, branch });
|
|
571
754
|
if (!release.version)
|
|
@@ -579,6 +762,7 @@ export async function deployCommand(options) {
|
|
|
579
762
|
sourceDigest: source.sourceDigest,
|
|
580
763
|
});
|
|
581
764
|
spinner.update(`Waiting for release assets for ${release.version}...`);
|
|
765
|
+
const expectedPageRoutes = await collectProjectPageRoutes(projectDir);
|
|
582
766
|
await waitForReleaseAssetManifest(client, project.slug, release.id, {
|
|
583
767
|
expectedRoutes: expectedPageRoutes,
|
|
584
768
|
pollIntervalMs: assetManifestPollIntervalMs,
|
|
@@ -598,6 +782,19 @@ export async function deployCommand(options) {
|
|
|
598
782
|
commitSha: source.commitSha,
|
|
599
783
|
sourceDigest: source.sourceDigest,
|
|
600
784
|
}, { verifiedRelease });
|
|
785
|
+
environmentUrl = buildEnvironmentUrl(verification.projectSlug, environment);
|
|
786
|
+
spinner.update(`Waiting for ${env} URL...`);
|
|
787
|
+
await waitForEnvironmentReady({
|
|
788
|
+
projectSlug: verification.projectSlug,
|
|
789
|
+
environmentName: environment.name,
|
|
790
|
+
url: environmentUrl,
|
|
791
|
+
route: expectedPageRoutes.find((route) => !route.includes("[")) ?? null,
|
|
792
|
+
protected: environment.protected,
|
|
793
|
+
apiToken: config.apiToken,
|
|
794
|
+
}, {
|
|
795
|
+
pollIntervalMs: environmentPollIntervalMs,
|
|
796
|
+
timeoutMs: environmentTimeoutMs,
|
|
797
|
+
});
|
|
601
798
|
spinner.stop();
|
|
602
799
|
}
|
|
603
800
|
catch (error) {
|
|
@@ -617,7 +814,7 @@ export async function deployCommand(options) {
|
|
|
617
814
|
const routingConvergenceWarning = getDeploymentRoutingConvergenceWarning(deployment);
|
|
618
815
|
if (routingConvergenceWarning)
|
|
619
816
|
logWarning(routingConvergenceWarning);
|
|
620
|
-
logInfo(` URL: ${
|
|
817
|
+
logInfo(` URL: ${environmentUrl}`);
|
|
621
818
|
logInfo(` Protected: ${environment.protected ? "yes" : "no"}`);
|
|
622
819
|
logInfo(verification.commitSha
|
|
623
820
|
? ` Commit: ${verification.commitSha}`
|
|
@@ -628,7 +825,7 @@ export async function deployCommand(options) {
|
|
|
628
825
|
console.log(getPostDeployTips());
|
|
629
826
|
}
|
|
630
827
|
async function deployCommandJson(options) {
|
|
631
|
-
const { projectDir = cwd(), branch, env, releaseName, dryRun, force, skipSourcePush, assetManifestPollIntervalMs, assetManifestTimeoutMs, } = options;
|
|
828
|
+
const { projectDir = cwd(), branch, env, releaseName, dryRun, force, skipSourcePush, assetManifestPollIntervalMs, assetManifestTimeoutMs, environmentPollIntervalMs, environmentTimeoutMs, } = options;
|
|
632
829
|
try {
|
|
633
830
|
// JSON mode requires --force or --yes to prevent accidental deploys
|
|
634
831
|
if (requiresExplicitDeployConfirmation(force)) {
|
|
@@ -645,7 +842,6 @@ async function deployCommandJson(options) {
|
|
|
645
842
|
const environmentConfig = getEnvironmentConfig();
|
|
646
843
|
const setup = await ensureProjectLinkedForDeploy(projectDir, environmentConfig, dryRun, true);
|
|
647
844
|
let { config, client, project } = setup;
|
|
648
|
-
const expectedPageRoutes = await collectProjectPageRoutes(projectDir);
|
|
649
845
|
streamJsonLine({ type: "step", name: "resolve-config", status: "completed" });
|
|
650
846
|
if (dryRun && !project) {
|
|
651
847
|
streamJsonLine({
|
|
@@ -742,6 +938,7 @@ async function deployCommandJson(options) {
|
|
|
742
938
|
});
|
|
743
939
|
streamJsonLine({ type: "step", name: "verify-release-source", status: "completed" });
|
|
744
940
|
streamJsonLine({ type: "step", name: "wait-release-assets", status: "started" });
|
|
941
|
+
const expectedPageRoutes = await collectProjectPageRoutes(projectDir);
|
|
745
942
|
await waitForReleaseAssetManifest(client, project.slug, release.id, {
|
|
746
943
|
expectedRoutes: expectedPageRoutes,
|
|
747
944
|
pollIntervalMs: assetManifestPollIntervalMs,
|
|
@@ -764,6 +961,20 @@ async function deployCommandJson(options) {
|
|
|
764
961
|
sourceDigest: source.sourceDigest,
|
|
765
962
|
}, { verifiedRelease });
|
|
766
963
|
streamJsonLine({ type: "step", name: "verify-deployment", status: "completed" });
|
|
964
|
+
const environmentUrl = buildEnvironmentUrl(verification.projectSlug, environment);
|
|
965
|
+
streamJsonLine({ type: "step", name: "wait-environment-url", status: "started" });
|
|
966
|
+
await waitForEnvironmentReady({
|
|
967
|
+
projectSlug: verification.projectSlug,
|
|
968
|
+
environmentName: environment.name,
|
|
969
|
+
url: environmentUrl,
|
|
970
|
+
route: expectedPageRoutes.find((route) => !route.includes("[")) ?? null,
|
|
971
|
+
protected: environment.protected,
|
|
972
|
+
apiToken: config.apiToken,
|
|
973
|
+
}, {
|
|
974
|
+
pollIntervalMs: environmentPollIntervalMs,
|
|
975
|
+
timeoutMs: environmentTimeoutMs,
|
|
976
|
+
});
|
|
977
|
+
streamJsonLine({ type: "step", name: "wait-environment-url", status: "completed" });
|
|
767
978
|
const routingConvergenceWarning = getDeploymentRoutingConvergenceWarning(deployment);
|
|
768
979
|
if (routingConvergenceWarning) {
|
|
769
980
|
streamJsonLine({
|
|
@@ -786,7 +997,7 @@ async function deployCommandJson(options) {
|
|
|
786
997
|
environment: env,
|
|
787
998
|
environmentId: verification.environmentId,
|
|
788
999
|
deploymentId: verification.deploymentId,
|
|
789
|
-
url:
|
|
1000
|
+
url: environmentUrl,
|
|
790
1001
|
protected: environment.protected,
|
|
791
1002
|
routingConvergence: deployment.routing_convergence ?? null,
|
|
792
1003
|
commitSha: verification.commitSha,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deploy command - Create and deploy releases
|
|
3
3
|
*/
|
|
4
|
-
export { assertProjectOwnership, createDeployment, createRelease, DeployArgsSchema, deployCommand, getDeployment, getDeploymentRoutingConvergenceWarning, getEnvironmentByName, getProject, getRelease, getReleaseSourceDigest, parseDeployArgs, requiresExplicitDeployConfirmation, resolvePushedSource, verifyDeployment, verifyReleaseSource, waitForReleaseAssetManifest, } from "./command.js";
|
|
5
|
-
export type { Deployment, DeploymentRoutingConvergence, DeploymentVerification, DeployOptions, ReleaseSourceVerification, } from "./command.js";
|
|
4
|
+
export { assertProjectOwnership, createDeployment, createRelease, DeployArgsSchema, deployCommand, getDeployment, getDeploymentRoutingConvergenceWarning, getEnvironmentByName, getProject, getRelease, getReleaseSourceDigest, parseDeployArgs, requiresExplicitDeployConfirmation, resolvePushedSource, verifyDeployment, verifyReleaseSource, waitForEnvironmentReady, waitForReleaseAssetManifest, } from "./command.js";
|
|
5
|
+
export type { Deployment, DeploymentRoutingConvergence, DeploymentVerification, DeployOptions, EnvironmentReadinessOptions, EnvironmentReadinessTarget, ReleaseSourceVerification, } from "./command.js";
|
|
6
6
|
export { handleDeployCommand } from "./handler.js";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,sCAAsC,EACtC,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,UAAU,EACV,4BAA4B,EAC5B,sBAAsB,EACtB,aAAa,EACb,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/deploy/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,sCAAsC,EACtC,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,eAAe,EACf,kCAAkC,EAClC,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,2BAA2B,GAC5B,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,UAAU,EACV,4BAA4B,EAC5B,sBAAsB,EACtB,aAAa,EACb,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Deploy command - Create and deploy releases
|
|
3
3
|
*/
|
|
4
|
-
export { assertProjectOwnership, createDeployment, createRelease, DeployArgsSchema, deployCommand, getDeployment, getDeploymentRoutingConvergenceWarning, getEnvironmentByName, getProject, getRelease, getReleaseSourceDigest, parseDeployArgs, requiresExplicitDeployConfirmation, resolvePushedSource, verifyDeployment, verifyReleaseSource, waitForReleaseAssetManifest, } from "./command.js";
|
|
4
|
+
export { assertProjectOwnership, createDeployment, createRelease, DeployArgsSchema, deployCommand, getDeployment, getDeploymentRoutingConvergenceWarning, getEnvironmentByName, getProject, getRelease, getReleaseSourceDigest, parseDeployArgs, requiresExplicitDeployConfirmation, resolvePushedSource, verifyDeployment, verifyReleaseSource, waitForEnvironmentReady, waitForReleaseAssetManifest, } from "./command.js";
|
|
5
5
|
export { handleDeployCommand } from "./handler.js";
|
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,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B;AAyCD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,EAC/D,OAAO,CAAC,EAAE;IACR,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,8BAA8B,CAAC,EAAE,cAAc,EAAE,CAAC;IAClD,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;IACzC,uBAAuB,CAAC,EAAE,+BAA+B,CAAC;IAC1D,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GACA,OAAO,CAAC,cAAc,EAAE,CAAC,CAgJ3B"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { executeTool, isToolVisibleTo, toolRegistry } from "../../tool/index.js";
|
|
9
9
|
import { assertLocalToolId, toolToProviderDefinition } from "../../tool/registry.js";
|
|
10
|
+
import { getRemoteToolProvenance } from "../../tool/remote-tool-provenance.js";
|
|
10
11
|
import { SKILL_TOOL_IDS } from "../../skill/types.js";
|
|
11
12
|
import { serverLogger } from "../../utils/index.js";
|
|
12
13
|
import { createError, PERMISSION_DENIED, toError } from "../../errors/index.js";
|
|
@@ -62,6 +63,15 @@ export function parseToolArgs(rawArgs) {
|
|
|
62
63
|
export function isDynamicTool(name) {
|
|
63
64
|
return toolRegistry.get(name)?.type === "dynamic";
|
|
64
65
|
}
|
|
66
|
+
function getConfiguredRemoteToolName(entry) {
|
|
67
|
+
return typeof entry === "object" ? getRemoteToolProvenance(entry) : undefined;
|
|
68
|
+
}
|
|
69
|
+
function getConfiguredToolAuthorizationName(toolName, entry) {
|
|
70
|
+
return getConfiguredRemoteToolName(entry) ?? toolName;
|
|
71
|
+
}
|
|
72
|
+
function isRemoteToolAllowed(toolName, allowedRemoteToolNames) {
|
|
73
|
+
return allowedRemoteToolNames === undefined || allowedRemoteToolNames.includes(toolName);
|
|
74
|
+
}
|
|
65
75
|
/**
|
|
66
76
|
* Resolve a configured tool name for a caller: the caller's own tool by short
|
|
67
77
|
* name first, then an exact registry id — returning only tools visible to the
|
|
@@ -173,7 +183,8 @@ export function resolveConfiguredTool(toolsConfig, toolName, context, options) {
|
|
|
173
183
|
return registryTool && isToolVisibleTo(registryTool, context) ? registryTool : null;
|
|
174
184
|
}
|
|
175
185
|
if (configuredEntry && typeof configuredEntry === "object") {
|
|
176
|
-
if (options?.allowIntegrationStyleConcreteTools !== true
|
|
186
|
+
if (options?.allowIntegrationStyleConcreteTools !== true &&
|
|
187
|
+
getConfiguredRemoteToolName(configuredEntry) === undefined) {
|
|
177
188
|
assertLocalToolId(toolName);
|
|
178
189
|
assertLocalToolId(configuredEntry.id);
|
|
179
190
|
}
|
|
@@ -182,9 +193,18 @@ export function resolveConfiguredTool(toolsConfig, toolName, context, options) {
|
|
|
182
193
|
return null;
|
|
183
194
|
}
|
|
184
195
|
export async function executeConfiguredTool(toolName, input, toolsConfig, context, allowedRemoteToolNames, remoteToolSources, sourceIntegrationPolicy, options) {
|
|
196
|
+
const configuredEntry = toolsConfig === true ? undefined : toolsConfig?.[toolName];
|
|
197
|
+
const configuredRemoteToolName = getConfiguredRemoteToolName(configuredEntry);
|
|
198
|
+
const authorizationToolName = getConfiguredToolAuthorizationName(toolName, configuredEntry);
|
|
185
199
|
if (sourceIntegrationPolicy &&
|
|
186
|
-
!isIntegrationToolAllowedBySourcePolicy(
|
|
187
|
-
throw new Error(`Tool "${
|
|
200
|
+
!isIntegrationToolAllowedBySourcePolicy(authorizationToolName, sourceIntegrationPolicy)) {
|
|
201
|
+
throw new Error(`Tool "${authorizationToolName}" is not allowed by the source integration policy`);
|
|
202
|
+
}
|
|
203
|
+
if (configuredRemoteToolName !== undefined &&
|
|
204
|
+
!isRemoteToolAllowed(configuredRemoteToolName, allowedRemoteToolNames)) {
|
|
205
|
+
throw PERMISSION_DENIED.create({
|
|
206
|
+
detail: `Tool "${configuredRemoteToolName}" is not allowed for this run`,
|
|
207
|
+
});
|
|
188
208
|
}
|
|
189
209
|
const configuredTool = resolveConfiguredTool(toolsConfig, toolName, context, {
|
|
190
210
|
allowIntegrationStyleConcreteTools: options?.strictConfiguredToolsOnly,
|
|
@@ -292,9 +312,12 @@ export async function getAvailableTools(toolsConfig, options) {
|
|
|
292
312
|
const remoteToolNames = new Set(remoteDefs.map((def) => def.name));
|
|
293
313
|
const explicitlyRequestedRemoteToolNames = new Set();
|
|
294
314
|
const unresolvedConfiguredToolNames = [];
|
|
315
|
+
const configuredAuthorizationToolNames = new Map();
|
|
295
316
|
for (const [name, entry] of Object.entries(toolsConfig)) {
|
|
317
|
+
const configuredRemoteToolName = getConfiguredRemoteToolName(entry);
|
|
318
|
+
const authorizationToolName = getConfiguredToolAuthorizationName(name, entry);
|
|
296
319
|
if (sourceIntegrationPolicy &&
|
|
297
|
-
!isIntegrationToolAllowedBySourcePolicy(
|
|
320
|
+
!isIntegrationToolAllowedBySourcePolicy(authorizationToolName, sourceIntegrationPolicy)) {
|
|
298
321
|
continue;
|
|
299
322
|
}
|
|
300
323
|
if (entry === true) {
|
|
@@ -319,10 +342,15 @@ export async function getAvailableTools(toolsConfig, options) {
|
|
|
319
342
|
continue;
|
|
320
343
|
}
|
|
321
344
|
if (entry && typeof entry === "object") {
|
|
322
|
-
if (
|
|
345
|
+
if (configuredRemoteToolName !== undefined &&
|
|
346
|
+
!isRemoteToolAllowed(configuredRemoteToolName, options?.allowedRemoteToolNames)) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (!strictConfiguredToolsOnly && configuredRemoteToolName === undefined) {
|
|
323
350
|
assertLocalToolId(name);
|
|
324
351
|
assertLocalToolId(entry.id);
|
|
325
352
|
}
|
|
353
|
+
configuredAuthorizationToolNames.set(name, authorizationToolName);
|
|
326
354
|
addToolDefinition(tools, name, entry);
|
|
327
355
|
}
|
|
328
356
|
}
|
|
@@ -348,6 +376,6 @@ export async function getAvailableTools(toolsConfig, options) {
|
|
|
348
376
|
throwUnknownConfiguredToolsError(unresolvedConfiguredToolNames, visibleLocalToolNames, remoteToolNames);
|
|
349
377
|
}
|
|
350
378
|
return sourceIntegrationPolicy
|
|
351
|
-
? tools.filter((definition) => isIntegrationToolAllowedBySourcePolicy(definition.name, sourceIntegrationPolicy))
|
|
379
|
+
? tools.filter((definition) => isIntegrationToolAllowedBySourcePolicy(configuredAuthorizationToolNames.get(definition.name) ?? definition.name, sourceIntegrationPolicy))
|
|
352
380
|
: tools;
|
|
353
381
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-runtime-part-mapper.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-part-mapper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAM1E,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElG,KAAK,gBAAgB,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AACjE,KAAK,kBAAkB,GAAG,OAAO,CAAC,QAAQ,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AAIrE,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED,sCAAsC;AACtC,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAw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AC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,6BAA6B,CAAC;AAUjE,mCAAmC;AACnC,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,uBAAuB,GAC7B,KAAK,CAAC,gBAAgB,GAAG,kBAAkB,CAAC,CAyD9C;AAMD,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAe5F;AA0ED,oDAAoD;AACpD,wBAAgB,mCAAmC,CACjD,KAAK,GAAE;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAO,GAC/C,6BAA6B,CAO/B;AAED,6CAA6C;AAC7C,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,6BAA6B,GACnC,QAAQ,EAAE,CAkKZ;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,GAAE;IAAE,MAAM,CAAC,EAAE,uBAAuB,CAAA;CAAO,GAC/C,6BAA6B,CAE/B;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,sBAAsB,EAC7B,KAAK,EAAE,6BAA6B,GACnC,QAAQ,EAAE,CAEZ"}
|
|
@@ -277,7 +277,9 @@ export function mapAgUiRuntimeEventToForkParts(event, state) {
|
|
|
277
277
|
case "error": {
|
|
278
278
|
const errorText = typeof event.errorText === "string"
|
|
279
279
|
? event.errorText
|
|
280
|
-
:
|
|
280
|
+
: typeof event.error === "string"
|
|
281
|
+
? event.error
|
|
282
|
+
: "Framework stream failed";
|
|
281
283
|
return [{ type: "error", error: new Error(errorText) }];
|
|
282
284
|
}
|
|
283
285
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-runtime-stream.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EAET,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"fork-runtime-stream.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/streaming/fork-runtime-stream.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EAET,KAAK,qBAAqB,EAC3B,MAAM,qBAAqB,CAAC;AAoB7B,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAO1D,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClG,OAAO,EAEL,KAAK,+BAA+B,EACrC,MAAM,qCAAqC,CAAC;AAE7C,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAElG,OAAO,EACL,uBAAuB,EACvB,mCAAmC,EACnC,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EACL,gCAAgC,EAChC,6BAA6B,GAC9B,MAAM,iCAAiC,CAAC;AAEzC,gDAAgD;AAChD,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACpC,KAAK,EAAE,WAAW,CAAC,SAAS,e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,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;AAE7C,kDAAkD;AAClD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,YAAY,CAOf;AAED,4CAA4C;AAC5C,wBAAgB,gCAAgC,CAAC,KAAK,EAAE;IACtD,eAAe,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,YAAY,EAAE,CAWjB;AAED,0CAA0C;AAC1C,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,MAAM,CAET;AAED,mDAAmD;AACnD,wBAAsB,mCAAmC,CAAC,KAAK,EAAE;IAC/D,0BAA0B,EAAE,MAAM,CAAC;IACnC,YAAY,CAAC,EAAE,qCAAqC,CAAC;IACrD,IAAI,EAAE,eAAe,CAAC;IACtB,eAAe,EAAE,YAAY,EAAE,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC;IAAE,0BAA0B,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG,IAAI,CAAC,CAoB1F;AAED,iCAAiC;AACjC,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,GAAG,uBAAuB,CA6GhG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
2
|
import { createToolsFromHostDefinitions, traceHostTools, } from "../../tool/index.js";
|
|
3
|
+
import { getRemoteToolProvenance } from "../../tool/remote-tool-provenance.js";
|
|
3
4
|
import { runWithVeryfrontCloudContextAsync } from "../../provider/veryfront-cloud/context.js";
|
|
4
5
|
import { streamDataStreamEvents } from "./data-stream.js";
|
|
5
6
|
import { buildRecoveredStepParts, createForkRuntimeStreamMappingState, mapAgUiRuntimeEventToForkParts, } from "./fork-runtime-part-mapper.js";
|
|
@@ -89,6 +90,14 @@ async function prepareForkRuntimeStep(input) {
|
|
|
89
90
|
system: input.buildInstructions(),
|
|
90
91
|
};
|
|
91
92
|
}
|
|
93
|
+
function getForkRuntimeAuthorizationToolNames(toolNames, runtimeTools) {
|
|
94
|
+
return toolNames.map((toolName) => {
|
|
95
|
+
const runtimeTool = runtimeTools[toolName];
|
|
96
|
+
return runtimeTool && typeof runtimeTool === "object"
|
|
97
|
+
? getRemoteToolProvenance(runtimeTool) ?? toolName
|
|
98
|
+
: toolName;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
92
101
|
/** Run agent runtime fork step. */
|
|
93
102
|
export async function runAgentRuntimeForkStep(input) {
|
|
94
103
|
let resolveResponsePromise;
|
|
@@ -126,7 +135,7 @@ export async function runAgentRuntimeForkStep(input) {
|
|
|
126
135
|
}),
|
|
127
136
|
}
|
|
128
137
|
: {}),
|
|
129
|
-
__vfAllowedRemoteTools: input.forkToolNames,
|
|
138
|
+
__vfAllowedRemoteTools: getForkRuntimeAuthorizationToolNames(input.forkToolNames, input.runtimeTools),
|
|
130
139
|
...(input.sourceIntegrationPolicy
|
|
131
140
|
? { __vfSourceIntegrationPolicy: input.sourceIntegrationPolicy }
|
|
132
141
|
: {}),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HTMLMetadata } from "../transforms/mdx/types.js";
|
|
2
|
+
import { type ConfiguredRouteDirectories } from "../release-assets/route-path.js";
|
|
2
3
|
import type { ReleaseAssetManifest } from "../release-assets/manifest-schema.js";
|
|
3
4
|
export interface InjectHTMLContentOptions {
|
|
4
5
|
mode: string;
|
|
@@ -39,6 +40,8 @@ export interface InjectHTMLContentOptions {
|
|
|
39
40
|
projectStylesheetHref?: string;
|
|
40
41
|
/** Ready release asset manifest used to hydrate full HTML client pages */
|
|
41
42
|
releaseAssetManifest?: ReleaseAssetManifest | null;
|
|
43
|
+
/** Configured route directories used to map physical page paths to route keys */
|
|
44
|
+
directories?: ConfiguredRouteDirectories;
|
|
42
45
|
}
|
|
43
46
|
export declare function injectHTMLContent(template: string, content: string, metadata: HTMLMetadata, options: InjectHTMLContentOptions): string;
|
|
44
47
|
//# sourceMappingURL=html-injection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-injection.d.ts","sourceRoot":"","sources":["../../../src/src/html/html-injection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAsB/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IAC3C,gDAAgD;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,WAAW,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IACvC,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OA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OAAO,CAAC;IACzB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0EAA0E;IAC1E,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACnD,iFAAiF;IACjF,WAAW,CAAC,EAAE,0BAA0B,CAAC;CAC1C;AAgBD,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,wBAAwB,GAChC,MAAM,CAqHR"}
|
|
@@ -5,6 +5,7 @@ import { buildNonceAttribute, escapeHTML } from "./html-escape.js";
|
|
|
5
5
|
import { escapeInlineJsonText, jsonForInlineScript, } from "../security/client/html-sanitizer.js";
|
|
6
6
|
import { getDevScripts, getDevStyles, getPreviewStylesheetLink, getProdScripts, getStudioScripts, } from "./dev-scripts.js";
|
|
7
7
|
import { buildReleaseAssetModules } from "../release-assets/client-module-map.js";
|
|
8
|
+
import { routeForConfiguredPage, } from "../release-assets/route-path.js";
|
|
8
9
|
function toProjectRelativePath(absolutePath, projectDir) {
|
|
9
10
|
const normalizedPath = absolutePath.replace(/\\/g, "/");
|
|
10
11
|
if (!projectDir)
|
|
@@ -54,12 +55,13 @@ export function injectHTMLContent(template, content, metadata, options) {
|
|
|
54
55
|
const hasBodyClose = /<\/body>/i.test(html);
|
|
55
56
|
// Inject hydration data for 'use client' pages (before scripts, so client.js can find it)
|
|
56
57
|
if (options.pagePath && options.isClientPage && hasBodyClose) {
|
|
58
|
+
const pagePath = toProjectRelativePath(options.pagePath, options.projectDir);
|
|
57
59
|
// Serialize with jsonForInlineScript, not raw JSON.stringify: route params
|
|
58
60
|
// (and slug) are URL-derived and decoded, so a segment like `%3C/script%3E`
|
|
59
61
|
// would otherwise break out of the <script> tag (reflected XSS). This escapes
|
|
60
62
|
// `<`, `>`, `&`, and line separators, matching the main shell hydration path.
|
|
61
63
|
const hydrationData = jsonForInlineScript({
|
|
62
|
-
pagePath
|
|
64
|
+
pagePath,
|
|
63
65
|
slug: options.slug,
|
|
64
66
|
isClientPage: true,
|
|
65
67
|
params: options.params ?? {},
|
|
@@ -67,7 +69,9 @@ export function injectHTMLContent(template, content, metadata, options) {
|
|
|
67
69
|
isLocalProject: options.isLocalProject ?? options.mode === "development",
|
|
68
70
|
environment: options.environment,
|
|
69
71
|
}),
|
|
70
|
-
releaseAssetModules: buildReleaseAssetModules(options.releaseAssetManifest
|
|
72
|
+
releaseAssetModules: buildReleaseAssetModules(options.releaseAssetManifest, {
|
|
73
|
+
route: routeForConfiguredPage(pagePath, options.directories),
|
|
74
|
+
}),
|
|
71
75
|
});
|
|
72
76
|
const nonceAttr = buildNonceAttribute(options.nonce);
|
|
73
77
|
const hydrationScript = `<script id="veryfront-hydration-data" type="application/json"${nonceAttr}>${hydrationData}</script>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"build-executor.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/build-executor.ts"],"names":[],"mappings":"AAmBA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAkD5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA2B/C,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,iCAAiC;IACj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C;CAChB,CAAC,CAkCD;AAkbD,wBAAsB,8BAA8B,CAAC,OAAO,EAAE;IAC5D,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,GAAG,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC,GAAG,OAAO,CAAC;IACV,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC,CAqCD;AA4DD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,sBAAsB,EAC7B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
|
|
@@ -34,11 +34,12 @@ import { ensureDefaultBundlerContracts } from "../extensions/bundler/defaults.js
|
|
|
34
34
|
import { register, tryResolve } from "../extensions/contracts.js";
|
|
35
35
|
import { getEsbuildLoader } from "../utils/path-utils.js";
|
|
36
36
|
import { extractCandidatesFromFiles } from "../html/styles-builder/candidate-extractor.js";
|
|
37
|
+
import { FRAMEWORK_CANDIDATES } from "../server/handlers/dev/framework-candidates.generated.js";
|
|
37
38
|
import { validatePathSync } from "../security/path-validation.js";
|
|
38
39
|
import { collectCssImportPaths, CSS_IMPORTING_SOURCE_EXTENSIONS, } from "../html/styles-builder/css-import-extraction.js";
|
|
39
40
|
import { computeHashBytes } from "../utils/index.js";
|
|
40
41
|
import { RELEASE_ASSET_BASE_PATH, RELEASE_ASSET_CONTENT_TYPES, RELEASE_ASSET_DEPENDENCY_IMPORT_MAP_ENV_FLAG, RELEASE_ASSET_MANIFEST_SCHEMA_VERSION, RELEASE_ASSET_MAX_SIZE_BYTES, RELEASE_ASSET_UPLOAD_CONCURRENCY, releaseAssetUrl, } from "./constants.js";
|
|
41
|
-
import { routeForPage } from "./route-path.js";
|
|
42
|
+
import { configuredRoutePath, normalizeLogicalPath, routeForConfiguredPage, routeForPage, } from "./route-path.js";
|
|
42
43
|
export { routeForPage } from "./route-path.js";
|
|
43
44
|
const logger = serverLogger.component("release-asset-build");
|
|
44
45
|
/** Browser module source extensions eligible for transform. */
|
|
@@ -98,33 +99,37 @@ function isTransformableBrowserModule(path) {
|
|
|
98
99
|
return true;
|
|
99
100
|
}
|
|
100
101
|
/** True when a logical path should seed the browser module graph. */
|
|
101
|
-
function isBrowserModule(path) {
|
|
102
|
+
function isBrowserModule(path, directories) {
|
|
102
103
|
if (!isTransformableBrowserModule(path))
|
|
103
104
|
return false;
|
|
104
|
-
if (
|
|
105
|
+
if (routeForConfiguredPage(path, directories) !== null)
|
|
105
106
|
return true;
|
|
106
|
-
return
|
|
107
|
+
return isConfiguredAppRouterLayout(path, directories) ||
|
|
108
|
+
BROWSER_MODULE_DIRS.some((dir) => path.startsWith(dir));
|
|
107
109
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
110
|
+
function isConfiguredAppRouterLayout(path, directories) {
|
|
111
|
+
const appPath = configuredRoutePath(path, directories, "app");
|
|
112
|
+
if (!appPath?.startsWith("app/"))
|
|
110
113
|
return false;
|
|
111
|
-
const withoutPrefix =
|
|
114
|
+
const withoutPrefix = appPath.slice("app/".length);
|
|
112
115
|
const segments = withoutPrefix.split("/");
|
|
113
116
|
const fileName = segments.pop();
|
|
114
117
|
if (!fileName || !/^layout\.(tsx|ts|jsx|mdx|js)$/.test(fileName))
|
|
115
118
|
return false;
|
|
116
119
|
return !segments.some((segment) => segment.startsWith("@") || segment.startsWith("_"));
|
|
117
120
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
121
|
+
function collectConfiguredAppRouterLayoutsForPage(logicalPath, directories, knownPaths) {
|
|
122
|
+
const appPath = configuredRoutePath(logicalPath, directories, "app");
|
|
123
|
+
if (!appPath || routeForPage(appPath) === null)
|
|
120
124
|
return [];
|
|
121
125
|
const segments = logicalPath.split("/");
|
|
122
126
|
segments.pop();
|
|
127
|
+
const appRootDepth = normalizeLogicalPath(directories.app).split("/").filter(Boolean).length;
|
|
123
128
|
const layouts = [];
|
|
124
|
-
for (let depth =
|
|
129
|
+
for (let depth = appRootDepth; depth <= segments.length; depth++) {
|
|
125
130
|
const dir = segments.slice(0, depth).join("/");
|
|
126
131
|
for (const ext of BROWSER_MODULE_EXTENSIONS) {
|
|
127
|
-
const candidate = `${dir}/layout${ext}`;
|
|
132
|
+
const candidate = dir ? `${dir}/layout${ext}` : `layout${ext}`;
|
|
128
133
|
if (knownPaths.has(candidate)) {
|
|
129
134
|
layouts.push(candidate);
|
|
130
135
|
break;
|
|
@@ -133,6 +138,12 @@ function collectAppRouterLayoutsForPage(logicalPath, knownPaths) {
|
|
|
133
138
|
}
|
|
134
139
|
return layouts;
|
|
135
140
|
}
|
|
141
|
+
function releaseRouterDirectories(config) {
|
|
142
|
+
return {
|
|
143
|
+
app: config.directories?.app ?? "app",
|
|
144
|
+
pages: config.directories?.pages ?? "pages",
|
|
145
|
+
};
|
|
146
|
+
}
|
|
136
147
|
function resolveKnownModulePath(path, knownPaths) {
|
|
137
148
|
const normalized = normalizeLogicalPath(path
|
|
138
149
|
.replace(/^\/?_vf_modules\//, "")
|
|
@@ -150,19 +161,6 @@ function resolveKnownModulePath(path, knownPaths) {
|
|
|
150
161
|
}
|
|
151
162
|
return null;
|
|
152
163
|
}
|
|
153
|
-
function normalizeLogicalPath(path) {
|
|
154
|
-
const parts = [];
|
|
155
|
-
for (const part of path.split("/")) {
|
|
156
|
-
if (!part || part === ".")
|
|
157
|
-
continue;
|
|
158
|
-
if (part === "..") {
|
|
159
|
-
parts.pop();
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
parts.push(part);
|
|
163
|
-
}
|
|
164
|
-
return parts.join("/");
|
|
165
|
-
}
|
|
166
164
|
function normalizeProjectSpecifier(specifier, logicalPath) {
|
|
167
165
|
if (specifier.startsWith("http://") ||
|
|
168
166
|
specifier.startsWith("https://") ||
|
|
@@ -1085,8 +1083,9 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
1085
1083
|
for (const file of files) {
|
|
1086
1084
|
if (typeof file.content !== "string")
|
|
1087
1085
|
continue;
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1086
|
+
const logicalPath = file.path.replace(/\\/g, "/");
|
|
1087
|
+
const abs = resolveMaterializedReleasePath(tempDir, logicalPath);
|
|
1088
|
+
sourceByPath.set(normalizeLogicalPath(logicalPath), file.content);
|
|
1090
1089
|
await fs.mkdir(dirname(abs), { recursive: true });
|
|
1091
1090
|
await fs.writeTextFile(abs, file.content);
|
|
1092
1091
|
}
|
|
@@ -1102,6 +1101,7 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
1102
1101
|
const vendorHttpImports = input.vendorHttpImports ?? vendorHttpImportsWithCache;
|
|
1103
1102
|
const vendorDependencies = isDependencyImportMapEnabled();
|
|
1104
1103
|
const releaseConfig = await resolveReleaseConfigFromSourceFiles(sourceByPath, input, tempDir);
|
|
1104
|
+
const routeDirectories = releaseRouterDirectories(releaseConfig);
|
|
1105
1105
|
const releaseReactVersion = await resolveReleaseReactVersion(sourceByPath, releaseConfig, input.reactVersion, tempDir);
|
|
1106
1106
|
const transformingModules = new Set();
|
|
1107
1107
|
async function transformProjectModule(logicalPath) {
|
|
@@ -1183,7 +1183,7 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
1183
1183
|
return null;
|
|
1184
1184
|
}
|
|
1185
1185
|
for (const logicalPath of sourceByPath.keys()) {
|
|
1186
|
-
if (!isBrowserModule(logicalPath))
|
|
1186
|
+
if (!isBrowserModule(logicalPath, routeDirectories))
|
|
1187
1187
|
continue;
|
|
1188
1188
|
const failure = await transformProjectModule(logicalPath);
|
|
1189
1189
|
if (failure)
|
|
@@ -1304,14 +1304,14 @@ async function runBuildInner(input, tempDir, client, transform) {
|
|
|
1304
1304
|
// B2. Routes: walk the transformed browser import closure from each page entrypoint.
|
|
1305
1305
|
// Modules missing from transformedModules are recorded as closure gaps.
|
|
1306
1306
|
const routes = {};
|
|
1307
|
-
const pageModules = Object.keys(modules).filter((p) =>
|
|
1307
|
+
const pageModules = Object.keys(modules).filter((p) => routeForConfiguredPage(p, routeDirectories) !== null);
|
|
1308
1308
|
for (const logicalPath of pageModules) {
|
|
1309
|
-
const route =
|
|
1309
|
+
const route = routeForConfiguredPage(logicalPath, routeDirectories);
|
|
1310
1310
|
if (!route)
|
|
1311
1311
|
continue;
|
|
1312
1312
|
const entryModules = [
|
|
1313
1313
|
logicalPath,
|
|
1314
|
-
...
|
|
1314
|
+
...collectConfiguredAppRouterLayoutsForPage(logicalPath, routeDirectories, knownPaths),
|
|
1315
1315
|
];
|
|
1316
1316
|
const { modules: closureModules, gaps: closureGaps } = await collectRouteClosure(entryModules, transformedModules, knownPaths);
|
|
1317
1317
|
// Include only modules we actually have in the manifest (transformed +
|
|
@@ -1538,7 +1538,10 @@ function mergeModuleCssImports(sourceByPath, stylesheet) {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
/** Extract Tailwind class candidates from materialized source. */
|
|
1540
1540
|
function collectClassCandidates(sourceByPath) {
|
|
1541
|
-
|
|
1541
|
+
const candidates = extractCandidatesFromFiles([...sourceByPath.entries()].map(([path, content]) => ({ path, content })));
|
|
1542
|
+
for (const candidate of FRAMEWORK_CANDIDATES)
|
|
1543
|
+
candidates.add(candidate);
|
|
1544
|
+
return candidates;
|
|
1542
1545
|
}
|
|
1543
1546
|
/** Run an async task over items with a fixed concurrency limit.
|
|
1544
1547
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { ReleaseAssetManifest } from "./manifest-schema.js";
|
|
2
|
-
export declare function buildReleaseAssetModules(manifest?: ReleaseAssetManifest | null
|
|
2
|
+
export declare function buildReleaseAssetModules(manifest?: ReleaseAssetManifest | null, options?: {
|
|
3
|
+
route?: string | null;
|
|
4
|
+
}): Record<string, string> | undefined;
|
|
3
5
|
//# sourceMappingURL=client-module-map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-module-map.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/client-module-map.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,wBAAgB,wBAAwB,CACtC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"client-module-map.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/client-module-map.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,wBAAgB,wBAAwB,CACtC,QAAQ,CAAC,EAAE,oBAAoB,GAAG,IAAI,EACtC,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GACtC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAuBpC"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
1
|
import { releaseAssetUrl } from "./constants.js";
|
|
2
|
-
export function buildReleaseAssetModules(manifest) {
|
|
2
|
+
export function buildReleaseAssetModules(manifest, options = {}) {
|
|
3
3
|
if (!manifest)
|
|
4
4
|
return undefined;
|
|
5
|
+
const routeModules = options.route ? manifest.routes[options.route]?.modules : undefined;
|
|
6
|
+
const buildFallback = () => {
|
|
7
|
+
const fallbackModules = {};
|
|
8
|
+
for (const [path, entry] of Object.entries(manifest.modules)) {
|
|
9
|
+
fallbackModules[path] = releaseAssetUrl(entry.contentHash, "js");
|
|
10
|
+
}
|
|
11
|
+
return Object.keys(fallbackModules).length > 0 ? fallbackModules : undefined;
|
|
12
|
+
};
|
|
13
|
+
if (!routeModules)
|
|
14
|
+
return buildFallback();
|
|
15
|
+
if (routeModules.length === 0)
|
|
16
|
+
return buildFallback();
|
|
5
17
|
const modules = {};
|
|
6
|
-
for (const
|
|
18
|
+
for (const path of routeModules) {
|
|
19
|
+
const entry = manifest.modules[path];
|
|
20
|
+
if (!entry)
|
|
21
|
+
return buildFallback();
|
|
7
22
|
modules[path] = releaseAssetUrl(entry.contentHash, "js");
|
|
8
23
|
}
|
|
9
|
-
return
|
|
24
|
+
return modules;
|
|
10
25
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
export interface ConfiguredRouteDirectories {
|
|
2
|
+
app?: string;
|
|
3
|
+
pages?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function normalizeLogicalPath(path: string): string;
|
|
6
|
+
export declare function pathBelowRoot(path: string, root: string): string | null;
|
|
7
|
+
export declare function configuredRoutePath(path: string, directories: ConfiguredRouteDirectories | undefined, routeRoot: "app" | "pages"): string | null;
|
|
1
8
|
/** Derive a route path from a page module logical path. */
|
|
2
9
|
export declare function routeForPage(logicalPath: string): string | null;
|
|
10
|
+
export declare function routeForConfiguredPage(path: string, directories?: ConfiguredRouteDirectories): string | null;
|
|
3
11
|
//# sourceMappingURL=route-path.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-path.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/route-path.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-path.d.ts","sourceRoot":"","sources":["../../../src/src/release-assets/route-path.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,0BAA0B;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAWzD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOvE;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,0BAA0B,GAAG,SAAS,EACnD,SAAS,EAAE,KAAK,GAAG,OAAO,GACzB,MAAM,GAAG,IAAI,CAGf;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAuC/D;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,0BAA0B,GACvC,MAAM,GAAG,IAAI,CAWf"}
|
|
@@ -7,6 +7,33 @@ function stripPageModuleExtension(logicalPath) {
|
|
|
7
7
|
return null;
|
|
8
8
|
return logicalPath.replace(PAGE_MODULE_EXTENSION, "");
|
|
9
9
|
}
|
|
10
|
+
export function normalizeLogicalPath(path) {
|
|
11
|
+
const parts = [];
|
|
12
|
+
for (const part of path.replace(/\\/g, "/").split("/")) {
|
|
13
|
+
if (!part || part === ".")
|
|
14
|
+
continue;
|
|
15
|
+
if (part === "..") {
|
|
16
|
+
parts.pop();
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
parts.push(part);
|
|
20
|
+
}
|
|
21
|
+
return parts.join("/");
|
|
22
|
+
}
|
|
23
|
+
export function pathBelowRoot(path, root) {
|
|
24
|
+
const normalizedPath = normalizeLogicalPath(path);
|
|
25
|
+
const normalizedRoot = normalizeLogicalPath(root);
|
|
26
|
+
if (normalizedRoot === "")
|
|
27
|
+
return normalizedPath;
|
|
28
|
+
if (normalizedPath === normalizedRoot)
|
|
29
|
+
return "";
|
|
30
|
+
const prefix = `${normalizedRoot}/`;
|
|
31
|
+
return normalizedPath.startsWith(prefix) ? normalizedPath.slice(prefix.length) : null;
|
|
32
|
+
}
|
|
33
|
+
export function configuredRoutePath(path, directories, routeRoot) {
|
|
34
|
+
const relativePath = pathBelowRoot(path, directories?.[routeRoot] ?? routeRoot);
|
|
35
|
+
return relativePath === null ? null : `${routeRoot}/${relativePath}`;
|
|
36
|
+
}
|
|
10
37
|
/** Derive a route path from a page module logical path. */
|
|
11
38
|
export function routeForPage(logicalPath) {
|
|
12
39
|
if (logicalPath.startsWith("pages/")) {
|
|
@@ -45,3 +72,15 @@ export function routeForPage(logicalPath) {
|
|
|
45
72
|
}
|
|
46
73
|
return null;
|
|
47
74
|
}
|
|
75
|
+
export function routeForConfiguredPage(path, directories) {
|
|
76
|
+
const appPath = configuredRoutePath(path, directories, "app");
|
|
77
|
+
if (appPath) {
|
|
78
|
+
const route = routeForPage(appPath);
|
|
79
|
+
if (route !== null)
|
|
80
|
+
return route;
|
|
81
|
+
}
|
|
82
|
+
const pagesPath = configuredRoutePath(path, directories, "pages");
|
|
83
|
+
if (pagesPath)
|
|
84
|
+
return routeForPage(pagesPath);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/html.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAmIlF,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAsB;gBAExB,MAAM,EAAE,mBAAmB;IAIjC,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBjE,kBAAkB,CACtB,WAAW,EAAE,cAAc,EAC3B,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAC3C,OAAO,CAAC,cAAc,CAAC;YAkEZ,sBAAsB;
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../../src/src/rendering/orchestrator/html.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAClF,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAmIlF,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAsB;gBAExB,MAAM,EAAE,mBAAmB;IAIjC,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBjE,kBAAkB,CACtB,WAAW,EAAE,cAAc,EAC3B,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,GAC3C,OAAO,CAAC,cAAc,CAAC;YAkEZ,sBAAsB;YA+DtB,4BAA4B;YAiB5B,wBAAwB;YAmBxB,gBAAgB;YAyBhB,kBAAkB;IAwDhC,OAAO,CAAC,cAAc;IAQtB;;;;;;OAMG;IACG,qBAAqB,CACzB,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE,KAAK,GACX,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAwB/C,yBAAyB,CAC7B,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;YAqDzC,eAAe;YAkBf,gBAAgB;IA+G9B;;;;OAIG;YACW,gBAAgB;CAc/B"}
|
|
@@ -205,6 +205,7 @@ export class HTMLGenerator {
|
|
|
205
205
|
importMapJson,
|
|
206
206
|
projectStylesheetHref,
|
|
207
207
|
releaseAssetManifest,
|
|
208
|
+
directories: this.config.config.directories,
|
|
208
209
|
});
|
|
209
210
|
if (injectedHtml.trimStart().toLowerCase().startsWith("<!doctype"))
|
|
210
211
|
return injectedHtml;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-tools.d.ts","sourceRoot":"","sources":["../../../src/src/tool/host-tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAU,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAA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AAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACnD;AA2DD,0CAA0C;AAC1C,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC;AACX,0CAA0C;AAC1C,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,OAAO,CAAC,EAAE,8BAA8B,GACvC,OAAO,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as dntShim from "../../_dnt.shims.js";
|
|
2
2
|
import { dynamicTool, tool } from "./factory.js";
|
|
3
3
|
import { agentLogger } from "../utils/index.js";
|
|
4
|
+
import { getRemoteToolProvenance, markRemoteToolProvenance } from "./remote-tool-provenance.js";
|
|
4
5
|
function isRecord(value) {
|
|
5
6
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
7
|
}
|
|
@@ -49,8 +50,9 @@ export function createToolsFromHostDefinitions(definitions, options = {}) {
|
|
|
49
50
|
continue;
|
|
50
51
|
const execute = async (input, context) => await definition.execute(input, normalizeExecutionContext(toolName, context, options));
|
|
51
52
|
try {
|
|
53
|
+
let materializedTool;
|
|
52
54
|
if (definition.inputSchemaJson) {
|
|
53
|
-
|
|
55
|
+
materializedTool = dynamicTool({
|
|
54
56
|
id: toolName,
|
|
55
57
|
description: definition.description,
|
|
56
58
|
inputSchema: definition.inputSchema,
|
|
@@ -60,7 +62,7 @@ export function createToolsFromHostDefinitions(definitions, options = {}) {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
else if (isSchemaLike(definition.inputSchema)) {
|
|
63
|
-
|
|
65
|
+
materializedTool = tool({
|
|
64
66
|
id: toolName,
|
|
65
67
|
description: definition.description,
|
|
66
68
|
inputSchema: definition.inputSchema,
|
|
@@ -68,6 +70,12 @@ export function createToolsFromHostDefinitions(definitions, options = {}) {
|
|
|
68
70
|
mcp: definition.mcp,
|
|
69
71
|
});
|
|
70
72
|
}
|
|
73
|
+
if (materializedTool) {
|
|
74
|
+
const canonicalRemoteToolName = getRemoteToolProvenance(definition);
|
|
75
|
+
tools[toolName] = canonicalRemoteToolName
|
|
76
|
+
? markRemoteToolProvenance(materializedTool, canonicalRemoteToolName)
|
|
77
|
+
: materializedTool;
|
|
78
|
+
}
|
|
71
79
|
}
|
|
72
80
|
catch (error) {
|
|
73
81
|
agentLogger.warn("Skipping host tool: schema conversion failed", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-source-tools.d.ts","sourceRoot":"","sources":["../../../src/src/tool/remote-source-tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remote-source-tools.d.ts","sourceRoot":"","sources":["../../../src/src/tool/remote-source-tools.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE/F,uDAAuD;AACvD,MAAM,WAAW,gCAAgC;IAC/C,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAkBD,4CAA4C;AAC5C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,SAAS,cAAc,EAAE,EACtC,OAAO,GAAE,IAAI,CAAC,gCAAgC,EAAE,SAAS,CAAM,GAC9D,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CA0BxC;AAED,sCAAsC;AACtC,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAKjD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineSchema } from "../schemas/index.js";
|
|
2
2
|
import { dynamicTool } from "./factory.js";
|
|
3
|
+
import { markRemoteToolProvenance } from "./remote-tool-provenance.js";
|
|
3
4
|
/**
|
|
4
5
|
* Permissive input schema used for remote tools whose JSON Schema is
|
|
5
6
|
* sourced from the remote and we only need a no-op contract `Schema<T>` to
|
|
@@ -17,19 +18,20 @@ function toToolInputRecord(input) {
|
|
|
17
18
|
export function createToolsFromRemoteDefinitions(source, definitions, options = {}) {
|
|
18
19
|
return Object.fromEntries(definitions.map((definition) => {
|
|
19
20
|
const toolName = options.toolNameAliases?.[definition.name] ?? definition.name;
|
|
21
|
+
const remoteTool = markRemoteToolProvenance(dynamicTool({
|
|
22
|
+
id: toolName,
|
|
23
|
+
description: definition.description,
|
|
24
|
+
inputSchema: getRemoteToolPassthroughSchema(),
|
|
25
|
+
inputSchemaJson: definition.parameters,
|
|
26
|
+
mcp: {
|
|
27
|
+
title: definition.title,
|
|
28
|
+
annotations: definition.annotations,
|
|
29
|
+
},
|
|
30
|
+
execute: async (input, context) => await source.executeTool(definition.name, toToolInputRecord(input), context),
|
|
31
|
+
}), definition.name);
|
|
20
32
|
return [
|
|
21
33
|
toolName,
|
|
22
|
-
|
|
23
|
-
id: toolName,
|
|
24
|
-
description: definition.description,
|
|
25
|
-
inputSchema: getRemoteToolPassthroughSchema(),
|
|
26
|
-
inputSchemaJson: definition.parameters,
|
|
27
|
-
mcp: {
|
|
28
|
-
title: definition.title,
|
|
29
|
-
annotations: definition.annotations,
|
|
30
|
-
},
|
|
31
|
-
execute: async (input, context) => await source.executeTool(definition.name, toToolInputRecord(input), context),
|
|
32
|
-
}),
|
|
34
|
+
remoteTool,
|
|
33
35
|
];
|
|
34
36
|
}));
|
|
35
37
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Mark a runtime tool as materialized from a trusted remote tool source. */
|
|
2
|
+
export declare function markRemoteToolProvenance<T extends object>(tool: T, canonicalToolName: string): T;
|
|
3
|
+
/** Return the canonical remote tool name carried by trusted provenance. */
|
|
4
|
+
export declare function getRemoteToolProvenance(value: unknown): string | undefined;
|
|
5
|
+
//# sourceMappingURL=remote-tool-provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-tool-provenance.d.ts","sourceRoot":"","sources":["../../../src/src/tool/remote-tool-provenance.ts"],"names":[],"mappings":"AAMA,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EACvD,IAAI,EAAE,CAAC,EACP,iBAAiB,EAAE,MAAM,GACxB,CAAC,CAMH;AAED,2EAA2E;AAC3E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAS1E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const REMOTE_TOOL_PROVENANCE = Symbol("veryfront.remote-tool-provenance");
|
|
2
|
+
/** Mark a runtime tool as materialized from a trusted remote tool source. */
|
|
3
|
+
export function markRemoteToolProvenance(tool, canonicalToolName) {
|
|
4
|
+
Object.defineProperty(tool, REMOTE_TOOL_PROVENANCE, {
|
|
5
|
+
value: canonicalToolName,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
});
|
|
8
|
+
return tool;
|
|
9
|
+
}
|
|
10
|
+
/** Return the canonical remote tool name carried by trusted provenance. */
|
|
11
|
+
export function getRemoteToolProvenance(value) {
|
|
12
|
+
if (typeof value !== "object" || value === null) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
const canonicalToolName = value[REMOTE_TOOL_PROVENANCE];
|
|
16
|
+
return typeof canonicalToolName === "string" && canonicalToolName.length > 0
|
|
17
|
+
? canonicalToolName
|
|
18
|
+
: undefined;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1160",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -332,10 +332,10 @@
|
|
|
332
332
|
"@types/react": "19.2.14",
|
|
333
333
|
"@types/react-dom": "19.2.3",
|
|
334
334
|
"ws": "8.21.0",
|
|
335
|
-
"@veryfront/ext-bundler-esbuild": "0.1.
|
|
336
|
-
"@veryfront/ext-content-mdx": "0.1.
|
|
337
|
-
"@veryfront/ext-css-tailwind": "0.1.
|
|
338
|
-
"@veryfront/ext-parser-babel": "0.1.
|
|
335
|
+
"@veryfront/ext-bundler-esbuild": "0.1.1160",
|
|
336
|
+
"@veryfront/ext-content-mdx": "0.1.1160",
|
|
337
|
+
"@veryfront/ext-css-tailwind": "0.1.1160",
|
|
338
|
+
"@veryfront/ext-parser-babel": "0.1.1160"
|
|
339
339
|
},
|
|
340
340
|
"devDependencies": {
|
|
341
341
|
"@types/node": "20.9.0"
|