@agent-native/core 0.229.0-nightly-20261116153227 → 0.229.0
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/dist/cli/create.js +9 -6
- package/dist/cli/package-lifecycle.js +18 -2
- package/dist/cli/process.d.ts +7 -0
- package/dist/cli/process.js +20 -0
- package/dist/cli/workspace-dev.js +3 -15
- package/dist/client/resources/use-resources.d.ts +7 -0
- package/dist/client/resources/use-resources.js +24 -2
- package/dist/client/review/use-review.d.ts +2 -0
- package/dist/client/review/use-review.js +11 -0
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts +16 -4
- package/dist/deploy/build.js +22 -0
- package/dist/framework-package-versions.json +11 -11
- package/dist/free-name/index.d.ts +11 -3
- package/dist/free-name/index.js +8 -6
- package/dist/free-name/server.d.ts +1 -1
- package/dist/local-artifacts/index.d.ts +13 -0
- package/dist/local-artifacts/index.js +75 -2
- package/dist/resources/handlers.d.ts +6 -0
- package/dist/resources/handlers.js +143 -5
- package/dist/resources/store.d.ts +15 -2
- package/dist/resources/store.js +60 -8
- package/dist/review/actions/create-review-comment.js +7 -3
- package/dist/review/actions/reply-review-comment.js +7 -3
- package/dist/review/actions/update-review-comment.d.ts +6 -0
- package/dist/review/actions/update-review-comment.js +42 -7
- package/dist/review/attachments.d.ts +19 -0
- package/dist/review/attachments.js +73 -1
- package/dist/review/errors.d.ts +4 -0
- package/dist/review/errors.js +9 -0
- package/dist/review/index.d.ts +1 -1
- package/dist/review/index.js +1 -1
- package/dist/review/notifications.js +4 -5
- package/dist/review/store.d.ts +11 -0
- package/dist/review/store.js +21 -2
- package/dist/server/first-touch-route.d.ts +1 -1
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +2 -1
- package/dist/templates/default/.agents/skills/actions/SKILL.md +2 -1
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +2 -1
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +2 -1
- package/dist/testing/cpu-time.d.ts +20 -0
- package/dist/testing/cpu-time.js +38 -0
- package/dist/usage/actions/get-builder-credit-status.js +7 -3
- package/docs/content/toolkit-comments-review.mdx +53 -0
- package/migration-manifest.json +1 -1
- package/package.json +8 -4
- package/src/templates/chat/.agents/skills/actions/SKILL.md +2 -1
- package/src/templates/default/.agents/skills/actions/SKILL.md +2 -1
- package/src/templates/headless/.agents/skills/actions/SKILL.md +2 -1
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +2 -1
package/dist/cli/create.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { execFileSync, execSync, spawnSync } from "child_process";
|
|
1
|
+
import { execFileSync, execSync, spawnSync, } from "child_process";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import { Readable, Transform, Writable } from "node:stream";
|
|
4
4
|
import { pipeline } from "node:stream/promises";
|
|
@@ -14,6 +14,7 @@ import { noteCreateCancelled, noteCreateProject, noteCreateStep, } from "./activ
|
|
|
14
14
|
import { releasedFrameworkPackageVersion } from "./framework-package-versions.js";
|
|
15
15
|
import { GIT_SYMLINK_MODE, GitHttpUnavailableError, withGitHttpRemote, } from "./git-http.js";
|
|
16
16
|
import { envProxyDispatcher } from "./http-proxy.js";
|
|
17
|
+
import { shimSpawnTarget } from "./process.js";
|
|
17
18
|
import { createAgentSymlink, prepareAgentSymlink, rebaseAgentSymlinkTarget, setupAgentSymlinks, } from "./setup-agents.js";
|
|
18
19
|
import { resolveTarExecutable } from "./tar-command.js";
|
|
19
20
|
import { applyTemplateLayer, readTemplateLayer } from "./template-layer.js";
|
|
@@ -1313,6 +1314,10 @@ function findLocalPackage(name) {
|
|
|
1313
1314
|
}
|
|
1314
1315
|
return undefined;
|
|
1315
1316
|
}
|
|
1317
|
+
function runNpm(args, options) {
|
|
1318
|
+
const [command, commandArgs, shell] = shimSpawnTarget("npm", args);
|
|
1319
|
+
execFileSync(command, commandArgs, { ...options, shell });
|
|
1320
|
+
}
|
|
1316
1321
|
function localPackageTarball(packageDir) {
|
|
1317
1322
|
const cached = localPackageTarballs.get(packageDir);
|
|
1318
1323
|
if (cached)
|
|
@@ -1320,8 +1325,7 @@ function localPackageTarball(packageDir) {
|
|
|
1320
1325
|
ensureLocalPackageBuildOutputs(packageDir);
|
|
1321
1326
|
const packDir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-native-local-package-"));
|
|
1322
1327
|
const npmCacheDir = path.join(packDir, "npm-cache");
|
|
1323
|
-
|
|
1324
|
-
execFileSync(npm, ["pack", "--ignore-scripts", "--pack-destination", packDir], {
|
|
1328
|
+
runNpm(["pack", "--ignore-scripts", "--pack-destination", packDir], {
|
|
1325
1329
|
cwd: packageDir,
|
|
1326
1330
|
env: {
|
|
1327
1331
|
...process.env,
|
|
@@ -1344,7 +1348,7 @@ function localPackageTarball(packageDir) {
|
|
|
1344
1348
|
rewritePublishedPackageManifest(path.join(unpackDir, "package", "package.json"));
|
|
1345
1349
|
const repackDir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-native-local-package-repack-"));
|
|
1346
1350
|
const repackNpmCacheDir = path.join(repackDir, "npm-cache");
|
|
1347
|
-
|
|
1351
|
+
runNpm(["pack", "--ignore-scripts", "--pack-destination", repackDir], {
|
|
1348
1352
|
cwd: path.join(unpackDir, "package"),
|
|
1349
1353
|
env: {
|
|
1350
1354
|
...process.env,
|
|
@@ -1394,10 +1398,9 @@ function ensureLocalPackageBuildOutputs(packageDir) {
|
|
|
1394
1398
|
if (typeof packageJson.scripts?.build !== "string") {
|
|
1395
1399
|
throw new Error(`Cannot pack local package ${String(packageJson.name ?? packageDir)} because ${missing.join(", ")} is missing and package.json has no build script.`);
|
|
1396
1400
|
}
|
|
1397
|
-
const npm = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
1398
1401
|
const npmCacheDir = fs.mkdtempSync(path.join(os.tmpdir(), "agent-native-local-package-build-cache-"));
|
|
1399
1402
|
try {
|
|
1400
|
-
|
|
1403
|
+
runNpm(["run", "build"], {
|
|
1401
1404
|
cwd: packageDir,
|
|
1402
1405
|
encoding: "utf-8",
|
|
1403
1406
|
env: { ...process.env, npm_config_cache: npmCacheDir },
|
|
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { assertAgentNativePackageManifest, } from "../package-lifecycle/manifest.js";
|
|
6
|
+
import { shimSpawnTarget } from "./process.js";
|
|
6
7
|
import { resolveTarExecutable } from "./tar-command.js";
|
|
7
8
|
const defaultIO = {
|
|
8
9
|
out: (message) => console.log(message),
|
|
@@ -87,7 +88,20 @@ export async function loadLifecyclePackage(name, cwd, spawn = spawnSync) {
|
|
|
87
88
|
}
|
|
88
89
|
const stage = fs.mkdtempSync(path.join(os.tmpdir(), "agent-native-package-inspect-"));
|
|
89
90
|
try {
|
|
90
|
-
const
|
|
91
|
+
const [npm, npmArgs, shell] = shimSpawnTarget("npm", [
|
|
92
|
+
"pack",
|
|
93
|
+
name,
|
|
94
|
+
"--ignore-scripts",
|
|
95
|
+
"--json",
|
|
96
|
+
"--pack-destination",
|
|
97
|
+
stage,
|
|
98
|
+
]);
|
|
99
|
+
const packed = spawn(npm, npmArgs, {
|
|
100
|
+
cwd,
|
|
101
|
+
encoding: "utf8",
|
|
102
|
+
stdio: "pipe",
|
|
103
|
+
shell,
|
|
104
|
+
});
|
|
91
105
|
if (packed.status !== 0) {
|
|
92
106
|
throw new Error(`Unable to download package metadata for '${name}'`);
|
|
93
107
|
}
|
|
@@ -494,9 +508,11 @@ async function applyTransaction(root, changes, spawn) {
|
|
|
494
508
|
fs.renameSync(path.join(stage, String(index)), change.path);
|
|
495
509
|
}
|
|
496
510
|
const packageManager = detectPackageManager(installRoot);
|
|
497
|
-
const
|
|
511
|
+
const [command, args, shell] = shimSpawnTarget(packageManager, ["install"]);
|
|
512
|
+
const result = spawn(command, args, {
|
|
498
513
|
cwd: installRoot,
|
|
499
514
|
stdio: "inherit",
|
|
515
|
+
shell,
|
|
500
516
|
});
|
|
501
517
|
if (result.status !== 0) {
|
|
502
518
|
throw new Error(`${packageManager} install failed with status ${result.status}`);
|
package/dist/cli/process.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export declare const WORKSPACE_DEPLOY_BUILD_ENV = "AGENT_NATIVE_WORKSPACE_DEPLOY
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function markDevServerReady(env?: NodeJS.ProcessEnv): void;
|
|
12
12
|
export declare function cliSpawnOptions(options?: Pick<SpawnOptions, "env" | "shell" | "stdio">, platform?: NodeJS.Platform): Pick<SpawnOptions, "env" | "shell" | "stdio">;
|
|
13
|
+
/**
|
|
14
|
+
* The `[command, args, shell]` to spawn a package-manager shim such as npm or
|
|
15
|
+
* pnpm. On Windows these are `.cmd` files, which Node starts only through a
|
|
16
|
+
* shell (CVE-2024-27980; `spawn("npm.cmd", args)` fails with EINVAL), and the
|
|
17
|
+
* shell needs the command line quoted because paths may contain spaces.
|
|
18
|
+
*/
|
|
19
|
+
export declare function shimSpawnTarget(command: string, args: string[], platform?: NodeJS.Platform): [string, string[], boolean];
|
|
13
20
|
export declare function runDevServer(command: string, args: string[], options?: {
|
|
14
21
|
env?: NodeJS.ProcessEnv;
|
|
15
22
|
shell?: boolean;
|
package/dist/cli/process.js
CHANGED
|
@@ -27,6 +27,26 @@ export function cliSpawnOptions(options = {}, platform = process.platform) {
|
|
|
27
27
|
env: options.env ?? process.env,
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The `[command, args, shell]` to spawn a package-manager shim such as npm or
|
|
32
|
+
* pnpm. On Windows these are `.cmd` files, which Node starts only through a
|
|
33
|
+
* shell (CVE-2024-27980; `spawn("npm.cmd", args)` fails with EINVAL), and the
|
|
34
|
+
* shell needs the command line quoted because paths may contain spaces.
|
|
35
|
+
*/
|
|
36
|
+
export function shimSpawnTarget(command, args, platform = process.platform) {
|
|
37
|
+
if (platform !== "win32")
|
|
38
|
+
return [command, args, false];
|
|
39
|
+
const quoted = args.map((arg) => {
|
|
40
|
+
// cmd.exe has no reliable way to escape these inside a quoted argument.
|
|
41
|
+
if (/["%]/.test(arg)) {
|
|
42
|
+
throw new Error(`Cannot run ${command} on Windows: path contains '"' or '%': ${arg}`);
|
|
43
|
+
}
|
|
44
|
+
return /[\s&|<>^()!]/.test(arg)
|
|
45
|
+
? `"${arg.replace(/(\\*)$/, "$1$1")}"`
|
|
46
|
+
: arg;
|
|
47
|
+
});
|
|
48
|
+
return [[command, ...quoted].join(" "), [], true];
|
|
49
|
+
}
|
|
30
50
|
export function runDevServer(command, args, options = {}) {
|
|
31
51
|
const env = {
|
|
32
52
|
...(options.env ?? process.env),
|
|
@@ -14,23 +14,11 @@ import { withWorkspaceRootEnv } from "../shared/workspace-default-app.js";
|
|
|
14
14
|
import { inferWorkspaceAppRootHomePath, readConfiguredWorkspaceAppHomePath, } from "../workspace-app-config.js";
|
|
15
15
|
import { attachGatewaySocketErrorSink, normalizeOrigin, rewriteRedirectLocation, escapeHtml, } from "./gateway-helpers.js";
|
|
16
16
|
import { openUrlInBrowser } from "./open-url.js";
|
|
17
|
-
import { DEV_SERVER_SUPERVISOR_ENV } from "./process.js";
|
|
17
|
+
import { DEV_SERVER_SUPERVISOR_ENV, shimSpawnTarget } from "./process.js";
|
|
18
18
|
import { captureSentryException } from "./sentry-telemetry.js";
|
|
19
|
-
//
|
|
20
|
-
// the command line quoted because app directories may contain spaces.
|
|
19
|
+
// App directories may contain spaces, so Windows gets a quoted command line.
|
|
21
20
|
export function pnpmSpawnTarget(args, platform = process.platform) {
|
|
22
|
-
|
|
23
|
-
return ["pnpm", args, false];
|
|
24
|
-
const quoted = args.map((arg) => {
|
|
25
|
-
// cmd.exe has no reliable way to escape these inside a quoted argument.
|
|
26
|
-
if (/["%]/.test(arg)) {
|
|
27
|
-
throw new Error(`Cannot run pnpm on Windows: path contains '"' or '%': ${arg}`);
|
|
28
|
-
}
|
|
29
|
-
return /[\s&|<>^()!]/.test(arg)
|
|
30
|
-
? `"${arg.replace(/(\\*)$/, "$1$1")}"`
|
|
31
|
-
: arg;
|
|
32
|
-
});
|
|
33
|
-
return [["pnpm", ...quoted].join(" "), [], true];
|
|
21
|
+
return shimSpawnTarget("pnpm", args, platform);
|
|
34
22
|
}
|
|
35
23
|
const DEFAULT_GATEWAY_HOST = "127.0.0.1";
|
|
36
24
|
const DEFAULT_GATEWAY_PORT = 8080;
|
|
@@ -100,6 +100,13 @@ export declare function useCreateResource(): import("@tanstack/react-query").Use
|
|
|
100
100
|
shared?: boolean;
|
|
101
101
|
uniqueSkillPath?: boolean;
|
|
102
102
|
}, unknown>;
|
|
103
|
+
/**
|
|
104
|
+
* The error for a resource write that came back not ok. It keeps the status
|
|
105
|
+
* and, when the server explains a refusal (a rename onto a taken name, say),
|
|
106
|
+
* its message, `errorCode` and `details`, so the write-failure toast shows the
|
|
107
|
+
* message and `isNameTaken` finds the free name.
|
|
108
|
+
*/
|
|
109
|
+
export declare function resourceWriteError(res: Response, fallback: string): Promise<Error>;
|
|
103
110
|
export declare function useUpdateResource(): import("@tanstack/react-query").UseMutationResult<Resource, Error, {
|
|
104
111
|
id: string;
|
|
105
112
|
content?: string;
|
|
@@ -197,6 +197,27 @@ export function useCreateResource() {
|
|
|
197
197
|
},
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* The error for a resource write that came back not ok. It keeps the status
|
|
202
|
+
* and, when the server explains a refusal (a rename onto a taken name, say),
|
|
203
|
+
* its message, `errorCode` and `details`, so the write-failure toast shows the
|
|
204
|
+
* message and `isNameTaken` finds the free name.
|
|
205
|
+
*/
|
|
206
|
+
export async function resourceWriteError(res, fallback) {
|
|
207
|
+
// coercion-ok: a body that isn't JSON has no message to keep; the error still says what failed through `fallback` and the status.
|
|
208
|
+
const body = (await res.json().catch(() => null));
|
|
209
|
+
const message = typeof body?.error === "string" ? body.error : undefined;
|
|
210
|
+
return Object.assign(new Error(message ?? fallback), {
|
|
211
|
+
status: res.status,
|
|
212
|
+
...(message !== undefined && res.status < 500
|
|
213
|
+
? { actionMessage: message }
|
|
214
|
+
: {}),
|
|
215
|
+
...(typeof body?.errorCode === "string"
|
|
216
|
+
? { errorCode: body.errorCode }
|
|
217
|
+
: {}),
|
|
218
|
+
...(body?.details !== undefined ? { details: body.details } : {}),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
200
221
|
export function useUpdateResource() {
|
|
201
222
|
const queryClient = useQueryClient();
|
|
202
223
|
return useMutation({
|
|
@@ -206,8 +227,9 @@ export function useUpdateResource() {
|
|
|
206
227
|
headers: { "Content-Type": "application/json" },
|
|
207
228
|
body: JSON.stringify(body),
|
|
208
229
|
});
|
|
209
|
-
if (!res.ok)
|
|
210
|
-
throw
|
|
230
|
+
if (!res.ok) {
|
|
231
|
+
throw await resourceWriteError(res, `Update failed: ${res.statusText}`);
|
|
232
|
+
}
|
|
211
233
|
return res.json();
|
|
212
234
|
},
|
|
213
235
|
onSuccess: (_data, variables) => {
|
|
@@ -132,6 +132,8 @@ export interface UpdateReviewCommentInput {
|
|
|
132
132
|
resourceId: string;
|
|
133
133
|
commentId: string;
|
|
134
134
|
body?: string;
|
|
135
|
+
/** The comment's images, in place of the ones it has; [] removes them. */
|
|
136
|
+
attachments?: Record<string, unknown>[];
|
|
135
137
|
anchor?: unknown;
|
|
136
138
|
anchorKind?: string | null;
|
|
137
139
|
anchorVersion?: number | null;
|
|
@@ -531,6 +531,11 @@ export function useUpdateReviewComment() {
|
|
|
531
531
|
? {
|
|
532
532
|
...comment,
|
|
533
533
|
...(input.body !== undefined ? { body: input.body } : {}),
|
|
534
|
+
...(input.attachments !== undefined
|
|
535
|
+
? {
|
|
536
|
+
metadata: withReviewAttachments(comment.metadata, input.attachments),
|
|
537
|
+
}
|
|
538
|
+
: {}),
|
|
534
539
|
...(input.anchor !== undefined
|
|
535
540
|
? { anchor: input.anchor }
|
|
536
541
|
: {}),
|
|
@@ -663,3 +668,9 @@ export function useUpdateResourceSuggestion() {
|
|
|
663
668
|
};
|
|
664
669
|
});
|
|
665
670
|
}
|
|
671
|
+
/** A comment's metadata with its images swapped, as the server writes it. */
|
|
672
|
+
function withReviewAttachments(metadata, attachments) {
|
|
673
|
+
const { attachments: _previous, ...rest } = metadata ?? {};
|
|
674
|
+
const next = attachments.length ? { ...rest, attachments } : rest;
|
|
675
|
+
return Object.keys(next).length ? next : null;
|
|
676
|
+
}
|
package/dist/collab/routes.d.ts
CHANGED
|
@@ -26,9 +26,9 @@ export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import
|
|
|
26
26
|
ok: boolean;
|
|
27
27
|
}>>;
|
|
28
28
|
export declare const postCollabText: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
29
|
+
text?: undefined;
|
|
29
30
|
ok?: undefined;
|
|
30
31
|
error: string;
|
|
31
|
-
text?: undefined;
|
|
32
32
|
} | {
|
|
33
33
|
error?: undefined;
|
|
34
34
|
ok: boolean;
|
package/dist/deploy/build.d.ts
CHANGED
|
@@ -188,19 +188,31 @@ export declare function patchCloudflareModuleServerOutput(serverDir: string): vo
|
|
|
188
188
|
export declare function bundleYjsRuntimeForServerlessOutput(serverDir: string, projectCwd: string): string[];
|
|
189
189
|
export declare function prepareVercelFunctionOutputs(outputDir: string, projectCwd: string): void;
|
|
190
190
|
export declare function shouldBundleYjsRuntimeForPreset(targetPreset: string): boolean;
|
|
191
|
-
export declare function nitroServerCodeSplittingGroupsForPreset(targetPreset: string): {
|
|
191
|
+
export declare function nitroServerCodeSplittingGroupsForPreset(targetPreset: string): ({
|
|
192
192
|
test: RegExp;
|
|
193
193
|
name: () => string;
|
|
194
|
+
debugName: "drizzle-orm";
|
|
195
|
+
priority: number;
|
|
196
|
+
} | {
|
|
197
|
+
test: RegExp;
|
|
198
|
+
name: () => string;
|
|
199
|
+
debugName: string;
|
|
194
200
|
entriesAware: boolean;
|
|
195
|
-
}[];
|
|
201
|
+
})[];
|
|
196
202
|
export declare function nitroServerCodeSplittingConfigForPreset(targetPreset: string): {
|
|
197
203
|
output: {
|
|
198
204
|
codeSplitting: {
|
|
199
|
-
groups: {
|
|
205
|
+
groups: ({
|
|
206
|
+
test: RegExp;
|
|
207
|
+
name: () => string;
|
|
208
|
+
debugName: "drizzle-orm";
|
|
209
|
+
priority: number;
|
|
210
|
+
} | {
|
|
200
211
|
test: RegExp;
|
|
201
212
|
name: () => string;
|
|
213
|
+
debugName: string;
|
|
202
214
|
entriesAware: boolean;
|
|
203
|
-
}[];
|
|
215
|
+
})[];
|
|
204
216
|
};
|
|
205
217
|
};
|
|
206
218
|
} | {
|
package/dist/deploy/build.js
CHANGED
|
@@ -3905,13 +3905,35 @@ export function shouldBundleYjsRuntimeForPreset(targetPreset) {
|
|
|
3905
3905
|
targetPreset === "node-server");
|
|
3906
3906
|
}
|
|
3907
3907
|
const NITRO_AGENT_NATIVE_SERVER_CHUNK_RE = /@agent-native[\\/](?:core|creative-context)(?:[\\/]|$)/;
|
|
3908
|
+
// Packages whose modules extend classes defined in their own other modules.
|
|
3909
|
+
// Split across chunks, they can import each other in a cycle, and whichever
|
|
3910
|
+
// chunk an app reaches first evaluates `class X extends Y` before Y exists:
|
|
3911
|
+
// "Class extends value undefined is not a constructor or null" at module load.
|
|
3912
|
+
// On 11/16 drizzle-orm was split into seven `_libs/drizzle-orm*.mjs` chunks
|
|
3913
|
+
// once the Core group became entries-aware, and four workspace apps crashed
|
|
3914
|
+
// on every request. Each of these packages stays in one chunk.
|
|
3915
|
+
const NITRO_SINGLE_CHUNK_SERVER_PACKAGES = ["drizzle-orm"];
|
|
3916
|
+
function nodeModulesPackageRe(packageName) {
|
|
3917
|
+
const escaped = packageName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3918
|
+
return new RegExp(`[\\\\/]node_modules[\\\\/]${escaped}[\\\\/]`);
|
|
3919
|
+
}
|
|
3908
3920
|
export function nitroServerCodeSplittingGroupsForPreset(targetPreset) {
|
|
3909
3921
|
return shouldBundleYjsRuntimeForPreset(targetPreset) ||
|
|
3910
3922
|
isAwsAmplifyPreset(targetPreset)
|
|
3911
3923
|
? [
|
|
3924
|
+
...NITRO_SINGLE_CHUNK_SERVER_PACKAGES.map((packageName) => ({
|
|
3925
|
+
test: nodeModulesPackageRe(packageName),
|
|
3926
|
+
name: () => `_libs/${packageName}`,
|
|
3927
|
+
// Names the group in the bundler timing report; `name` is a function.
|
|
3928
|
+
debugName: packageName,
|
|
3929
|
+
// Above Nitro's per-package `_libs` group and the Core group, so
|
|
3930
|
+
// nothing else claims part of the package.
|
|
3931
|
+
priority: 20,
|
|
3932
|
+
})),
|
|
3912
3933
|
{
|
|
3913
3934
|
test: NITRO_AGENT_NATIVE_SERVER_CHUNK_RE,
|
|
3914
3935
|
name: () => "agent-native-core",
|
|
3936
|
+
debugName: "agent-native-core",
|
|
3915
3937
|
// Preserve dynamic-import boundaries. A package-wide chunk pulls
|
|
3916
3938
|
// optional agent, integration and rendering code into every cold
|
|
3917
3939
|
// request, even when that request only reads application data.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@agent-native/agentkit": "0.229.0
|
|
2
|
+
"@agent-native/agentkit": "0.229.0",
|
|
3
3
|
"@agent-native/code-agents-ui": "0.1.75",
|
|
4
|
-
"@agent-native/core": "0.229.0
|
|
5
|
-
"@agent-native/core-corpus": "0.229.0
|
|
6
|
-
"@agent-native/creative-context": "0.8.
|
|
7
|
-
"@agent-native/dispatch": "0.42.8
|
|
4
|
+
"@agent-native/core": "0.229.0",
|
|
5
|
+
"@agent-native/core-corpus": "0.229.0",
|
|
6
|
+
"@agent-native/creative-context": "0.8.73",
|
|
7
|
+
"@agent-native/dispatch": "0.42.8",
|
|
8
8
|
"@agent-native/embedding": "0.2.0",
|
|
9
9
|
"@agent-native/migrate": "0.0.7",
|
|
10
|
-
"@agent-native/otel": "0.1.
|
|
11
|
-
"@agent-native/pinpoint": "0.1.
|
|
12
|
-
"@agent-native/recap-cli": "0.5.
|
|
13
|
-
"@agent-native/scheduling": "0.3.0
|
|
10
|
+
"@agent-native/otel": "0.1.40",
|
|
11
|
+
"@agent-native/pinpoint": "0.1.116",
|
|
12
|
+
"@agent-native/recap-cli": "0.5.104",
|
|
13
|
+
"@agent-native/scheduling": "0.3.0",
|
|
14
14
|
"@agent-native/shared-app-config": "0.1.2",
|
|
15
|
-
"@agent-native/skills": "0.4.8
|
|
16
|
-
"@agent-native/toolkit": "0.229.0
|
|
15
|
+
"@agent-native/skills": "0.4.8",
|
|
16
|
+
"@agent-native/toolkit": "0.229.0"
|
|
17
17
|
}
|
|
@@ -12,18 +12,26 @@ export interface NameTakenDetails {
|
|
|
12
12
|
/** A free name to use instead. */
|
|
13
13
|
suggestion: string;
|
|
14
14
|
}
|
|
15
|
+
export interface FreeNameOptions {
|
|
16
|
+
/**
|
|
17
|
+
* What goes between the name and its number: "-" by default, so
|
|
18
|
+
* "home-2.html". A slug whose alphabet has no "-" passes "_".
|
|
19
|
+
*/
|
|
20
|
+
separator?: string;
|
|
21
|
+
}
|
|
15
22
|
/**
|
|
16
23
|
* The preferred name if it's free, otherwise the first free one of
|
|
17
24
|
* "stem-2.ext", "stem-3.ext", and so on. Picking is not claiming: two writers
|
|
18
25
|
* can pick the same name at once, so the write that claims it must still be
|
|
19
26
|
* refused, or retried, when the name was taken in between.
|
|
20
27
|
*/
|
|
21
|
-
export declare function nextFreeName(preferred: string, taken: ReadonlySet<string> | ((name: string) => boolean)): string;
|
|
28
|
+
export declare function nextFreeName(preferred: string, taken: ReadonlySet<string> | ((name: string) => boolean), { separator }?: FreeNameOptions): string;
|
|
22
29
|
/**
|
|
23
30
|
* Whether `name` is `preferred` or one of the names {@link nextFreeName}
|
|
24
|
-
* would pick for it, such as "home-3.html" for "home.html".
|
|
31
|
+
* would pick for it, such as "home-3.html" for "home.html". Pass the same
|
|
32
|
+
* `separator` the names were picked with.
|
|
25
33
|
*/
|
|
26
|
-
export declare function isFreeNameFor(name: string, preferred: string): boolean;
|
|
34
|
+
export declare function isFreeNameFor(name: string, preferred: string, { separator }?: FreeNameOptions): boolean;
|
|
27
35
|
/**
|
|
28
36
|
* True for the refusal `nameTaken()` throws, however it reached this side: the
|
|
29
37
|
* action route, `useAction`, or an app's own fetch that kept `errorCode` and
|
package/dist/free-name/index.js
CHANGED
|
@@ -19,28 +19,30 @@ function splitExtension(name) {
|
|
|
19
19
|
* can pick the same name at once, so the write that claims it must still be
|
|
20
20
|
* refused, or retried, when the name was taken in between.
|
|
21
21
|
*/
|
|
22
|
-
export function nextFreeName(preferred, taken) {
|
|
22
|
+
export function nextFreeName(preferred, taken, { separator = "-" } = {}) {
|
|
23
23
|
const isTaken = typeof taken === "function" ? taken : (name) => taken.has(name);
|
|
24
24
|
if (!isTaken(preferred))
|
|
25
25
|
return preferred;
|
|
26
26
|
const { stem, extension } = splitExtension(preferred);
|
|
27
27
|
for (let suffix = 2;; suffix += 1) {
|
|
28
|
-
const candidate = `${stem}
|
|
28
|
+
const candidate = `${stem}${separator}${suffix}${extension}`;
|
|
29
29
|
if (!isTaken(candidate))
|
|
30
30
|
return candidate;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Whether `name` is `preferred` or one of the names {@link nextFreeName}
|
|
35
|
-
* would pick for it, such as "home-3.html" for "home.html".
|
|
35
|
+
* would pick for it, such as "home-3.html" for "home.html". Pass the same
|
|
36
|
+
* `separator` the names were picked with.
|
|
36
37
|
*/
|
|
37
|
-
export function isFreeNameFor(name, preferred) {
|
|
38
|
+
export function isFreeNameFor(name, preferred, { separator = "-" } = {}) {
|
|
38
39
|
if (name === preferred)
|
|
39
40
|
return true;
|
|
40
41
|
const { stem, extension } = splitExtension(preferred);
|
|
41
|
-
|
|
42
|
+
const prefix = `${stem}${separator}`;
|
|
43
|
+
if (!name.startsWith(prefix) || !name.endsWith(extension))
|
|
42
44
|
return false;
|
|
43
|
-
const suffix = name.slice(
|
|
45
|
+
const suffix = name.slice(prefix.length, name.length - extension.length);
|
|
44
46
|
return /^[1-9]\d*$/.test(suffix) && Number(suffix) >= 2;
|
|
45
47
|
}
|
|
46
48
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionContractError } from "../action.js";
|
|
2
2
|
export { isFreeNameFor, isNameTaken, NAME_TAKEN_ERROR_CODE, nextFreeName, } from "./index.js";
|
|
3
|
-
export type { NameTakenDetails } from "./index.js";
|
|
3
|
+
export type { FreeNameOptions, NameTakenDetails } from "./index.js";
|
|
4
4
|
/**
|
|
5
5
|
* The one typed refusal for a name another record already has. It says so
|
|
6
6
|
* and carries a free name, so a person or an agent can take that instead of
|
|
@@ -167,6 +167,19 @@ export declare function listLocalWorkspaceResources(options?: LocalWorkspaceReso
|
|
|
167
167
|
export declare function readLocalWorkspaceResource(options: LocalWorkspaceResourceOptions & {
|
|
168
168
|
path: string;
|
|
169
169
|
}): Promise<LocalWorkspaceResourceFile | null>;
|
|
170
|
+
/**
|
|
171
|
+
* Whether two resource paths name one local workspace file, so that writing
|
|
172
|
+
* one and deleting the other would lose it. That's the same resource path
|
|
173
|
+
* spelled another way (".agent/skills/x/SKILL.md" is "skills/x/SKILL.md",
|
|
174
|
+
* and deleting either removes the skill from every skill root), or one file
|
|
175
|
+
* on disk, as "skills/Review/SKILL.md" and "skills/review/SKILL.md" are on a
|
|
176
|
+
* case-insensitive disk. False when either file is missing, and when the
|
|
177
|
+
* disk gives files no ids to compare.
|
|
178
|
+
*/
|
|
179
|
+
export declare function isSameLocalWorkspaceFile(options: LocalWorkspaceResourceOptions & {
|
|
180
|
+
path: string;
|
|
181
|
+
otherPath: string;
|
|
182
|
+
}): Promise<boolean>;
|
|
170
183
|
export declare function writeLocalWorkspaceResource(options: WriteLocalWorkspaceResourceOptions): Promise<LocalWorkspaceResourceMeta>;
|
|
171
184
|
export declare function deleteLocalWorkspaceResource(options: LocalWorkspaceResourceOptions & {
|
|
172
185
|
path: string;
|
|
@@ -931,6 +931,72 @@ export async function readLocalWorkspaceResource(options) {
|
|
|
931
931
|
throw error;
|
|
932
932
|
}
|
|
933
933
|
}
|
|
934
|
+
/**
|
|
935
|
+
* Whether two resource paths name one local workspace file, so that writing
|
|
936
|
+
* one and deleting the other would lose it. That's the same resource path
|
|
937
|
+
* spelled another way (".agent/skills/x/SKILL.md" is "skills/x/SKILL.md",
|
|
938
|
+
* and deleting either removes the skill from every skill root), or one file
|
|
939
|
+
* on disk, as "skills/Review/SKILL.md" and "skills/review/SKILL.md" are on a
|
|
940
|
+
* case-insensitive disk. False when either file is missing, and when the
|
|
941
|
+
* disk gives files no ids to compare.
|
|
942
|
+
*/
|
|
943
|
+
export async function isSameLocalWorkspaceFile(options) {
|
|
944
|
+
if (normalizeLocalWorkspaceResourcePath(options.path) ===
|
|
945
|
+
normalizeLocalWorkspaceResourcePath(options.otherPath)) {
|
|
946
|
+
return true;
|
|
947
|
+
}
|
|
948
|
+
const workspaceRoot = await resolveLocalWorkspaceRoot(options);
|
|
949
|
+
if (!workspaceRoot)
|
|
950
|
+
return false;
|
|
951
|
+
const statOf = (resourcePath) => fs.stat(localWorkspaceResourceAbsolutePath(workspaceRoot, resourcePath, {
|
|
952
|
+
preferExisting: true,
|
|
953
|
+
}).absolutePath, { bigint: true });
|
|
954
|
+
try {
|
|
955
|
+
const [first, second] = await Promise.all([
|
|
956
|
+
statOf(options.path),
|
|
957
|
+
statOf(options.otherPath),
|
|
958
|
+
]);
|
|
959
|
+
return (first.ino !== 0n && first.dev === second.dev && first.ino === second.ino);
|
|
960
|
+
}
|
|
961
|
+
catch (error) {
|
|
962
|
+
if (errorCode(error) === "ENOENT")
|
|
963
|
+
return false;
|
|
964
|
+
throw error;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
/** Errors a disk gives when it can't make hard links. */
|
|
968
|
+
const HARD_LINK_UNSUPPORTED_CODES = new Set(["EPERM", "ENOTSUP", "ENOSYS"]);
|
|
969
|
+
/**
|
|
970
|
+
* Moves a finished temp file to a path that must still be free. A rename
|
|
971
|
+
* would replace a file another process made there after the caller's check;
|
|
972
|
+
* a hard link, or an exclusive copy where the disk has no hard links, fails
|
|
973
|
+
* instead, with `EEXIST`.
|
|
974
|
+
*/
|
|
975
|
+
async function moveTempFileToFreePath(tempPath, absolutePath, resourcePath) {
|
|
976
|
+
try {
|
|
977
|
+
try {
|
|
978
|
+
await fs.link(tempPath, absolutePath);
|
|
979
|
+
}
|
|
980
|
+
catch (error) {
|
|
981
|
+
const code = errorCode(error);
|
|
982
|
+
if (code === undefined || !HARD_LINK_UNSUPPORTED_CODES.has(code)) {
|
|
983
|
+
throw error;
|
|
984
|
+
}
|
|
985
|
+
await fs.copyFile(tempPath, absolutePath, fs.constants.COPYFILE_EXCL);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
catch (error) {
|
|
989
|
+
if (errorCode(error) === "EEXIST") {
|
|
990
|
+
throw Object.assign(new Error(`File "${resourcePath}" already exists`), {
|
|
991
|
+
code: "EEXIST",
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
throw error;
|
|
995
|
+
}
|
|
996
|
+
finally {
|
|
997
|
+
await fs.rm(tempPath, { force: true });
|
|
998
|
+
}
|
|
999
|
+
}
|
|
934
1000
|
export async function writeLocalWorkspaceResource(options) {
|
|
935
1001
|
const workspaceRoot = await resolveLocalWorkspaceRoot(options);
|
|
936
1002
|
if (!workspaceRoot) {
|
|
@@ -946,7 +1012,9 @@ export async function writeLocalWorkspaceResource(options) {
|
|
|
946
1012
|
path: resourcePath,
|
|
947
1013
|
});
|
|
948
1014
|
if (options.ifNotExists && existing) {
|
|
949
|
-
throw new Error(`File "${resourcePath}" already exists`)
|
|
1015
|
+
throw Object.assign(new Error(`File "${resourcePath}" already exists`), {
|
|
1016
|
+
code: "EEXIST",
|
|
1017
|
+
});
|
|
950
1018
|
}
|
|
951
1019
|
if (options.expectedHash &&
|
|
952
1020
|
(!existing || existing.hash !== options.expectedHash)) {
|
|
@@ -959,7 +1027,12 @@ export async function writeLocalWorkspaceResource(options) {
|
|
|
959
1027
|
await fs.mkdir(path.dirname(absolutePath), { recursive: true });
|
|
960
1028
|
const tempPath = path.join(path.dirname(absolutePath), `.${path.basename(absolutePath)}.${process.pid}.${crypto.randomUUID()}.tmp`);
|
|
961
1029
|
await fs.writeFile(tempPath, options.content, "utf8");
|
|
962
|
-
|
|
1030
|
+
if (options.ifNotExists) {
|
|
1031
|
+
await moveTempFileToFreePath(tempPath, absolutePath, resourcePath);
|
|
1032
|
+
}
|
|
1033
|
+
else {
|
|
1034
|
+
await fs.rename(tempPath, absolutePath);
|
|
1035
|
+
}
|
|
963
1036
|
const stat = await fs.stat(absolutePath);
|
|
964
1037
|
return localWorkspaceResourceMeta(resourcePath, absolutePath, options.content, stat);
|
|
965
1038
|
});
|
|
@@ -36,7 +36,13 @@ export declare function handleCreateResource(event: any): Promise<import("./stor
|
|
|
36
36
|
error: string;
|
|
37
37
|
}>;
|
|
38
38
|
export declare function handleUpdateResource(event: any): Promise<import("./store.js").Resource | {
|
|
39
|
+
errorCode?: undefined;
|
|
40
|
+
details?: undefined;
|
|
39
41
|
error: string;
|
|
42
|
+
} | {
|
|
43
|
+
error: string;
|
|
44
|
+
errorCode: string;
|
|
45
|
+
details: Record<string, unknown> | undefined;
|
|
40
46
|
}>;
|
|
41
47
|
export declare function handleDeleteResource(event: any): Promise<{
|
|
42
48
|
ok?: undefined;
|