@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.107
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/admin/admin.schemas.d.ts +3 -0
- package/dist/agents/agents.schemas.d.ts +9 -9
- package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
- package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
- package/dist/automations/automations.module.d.ts +16 -0
- package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
- package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
- package/dist/automations/automations.schemas.js +253 -0
- package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
- package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
- package/dist/{schedules → automations}/calendar.d.ts +8 -8
- package/dist/{schedules → automations}/calendar.js +2 -2
- package/dist/automations/effective-settings.d.ts +28 -0
- package/dist/automations/effective-settings.js +25 -0
- package/dist/automations/errors.d.ts +19 -0
- package/dist/automations/errors.js +19 -0
- package/dist/automations/events/coalesce.d.ts +28 -0
- package/dist/automations/events/coalesce.js +131 -0
- package/dist/automations/events/deadline.d.ts +10 -0
- package/dist/automations/events/deadline.js +24 -0
- package/dist/automations/events/dispatcher.d.ts +74 -0
- package/dist/automations/events/dispatcher.js +353 -0
- package/dist/automations/events/events.module.d.ts +7 -0
- package/dist/automations/events/events.module.js +26 -0
- package/dist/automations/events/guards.d.ts +32 -0
- package/dist/automations/events/guards.js +87 -0
- package/dist/automations/events/sweep.job.d.ts +49 -0
- package/dist/automations/events/sweep.job.js +202 -0
- package/dist/automations/events/token.d.ts +5 -0
- package/dist/automations/events/token.js +5 -0
- package/dist/automations/events/trigger-events.service.d.ts +47 -0
- package/dist/automations/events/trigger-events.service.js +254 -0
- package/dist/{schedules → automations}/fire.d.ts +57 -17
- package/dist/{schedules → automations}/fire.js +311 -79
- package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
- package/dist/{schedules → automations}/grant-rules.js +5 -5
- package/dist/automations/job-ids.d.ts +113 -0
- package/dist/automations/job-ids.js +117 -0
- package/dist/{schedules → automations}/pause.d.ts +3 -3
- package/dist/{schedules → automations}/pause.js +3 -3
- package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
- package/dist/{schedules → automations}/run-tracker.js +68 -56
- package/dist/{schedules → automations}/scan.job.d.ts +12 -8
- package/dist/{schedules → automations}/scan.job.js +39 -23
- package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
- package/dist/{schedules → automations}/schedule-math.js +17 -7
- package/dist/{schedules → automations}/store.d.ts +57 -27
- package/dist/{schedules → automations}/store.js +102 -52
- package/dist/automations/store.module.d.ts +6 -0
- package/dist/{schedules → automations}/store.module.js +9 -9
- package/dist/automations/types.d.ts +178 -0
- package/dist/{schedules → automations}/unattended.d.ts +22 -11
- package/dist/{schedules → automations}/unattended.js +53 -30
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +7 -6
- package/dist/channels/file-delivery.d.ts +26 -11
- package/dist/channels/file-delivery.js +32 -11
- package/dist/channels/outbound.d.ts +8 -8
- package/dist/channels/outbound.js +32 -30
- package/dist/channels/threads.d.ts +1 -1
- package/dist/channels/threads.js +1 -1
- package/dist/config/schema.d.ts +8 -1
- package/dist/config/schema.js +56 -6
- package/dist/conversations/approval-profile.d.ts +2 -2
- package/dist/conversations/approval-profile.js +3 -3
- package/dist/conversations/artifacts.d.ts +20 -17
- package/dist/conversations/artifacts.js +30 -37
- package/dist/conversations/attachments.controller.d.ts +6 -19
- package/dist/conversations/attachments.controller.js +8 -59
- package/dist/conversations/attachments.service.d.ts +30 -74
- package/dist/conversations/attachments.service.js +51 -193
- package/dist/conversations/conversations.controller.d.ts +7 -1
- package/dist/conversations/conversations.controller.js +26 -10
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/conversations.service.d.ts +112 -35
- package/dist/conversations/conversations.service.js +160 -43
- package/dist/conversations/event-log.d.ts +1 -0
- package/dist/conversations/events.d.ts +95 -27
- package/dist/conversations/events.js +108 -10
- package/dist/conversations/files.d.ts +66 -64
- package/dist/conversations/files.js +127 -147
- package/dist/conversations/message-context.d.ts +2 -2
- package/dist/conversations/message-context.js +1 -1
- package/dist/conversations/permission-profile-store.d.ts +2 -1
- package/dist/conversations/permission-profiles.controller.d.ts +3 -0
- package/dist/conversations/permission-profiles.service.js +1 -1
- package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
- package/dist/conversations/prompt-suggestion-request.js +4 -2
- package/dist/conversations/prompt-suggestions.d.ts +3 -3
- package/dist/conversations/prompt-suggestions.js +11 -10
- package/dist/conversations/queue.d.ts +7 -4
- package/dist/conversations/queue.js +6 -2
- package/dist/conversations/queue.service.d.ts +5 -5
- package/dist/conversations/queue.service.js +27 -16
- package/dist/ctx/create-ctx.d.ts +23 -2
- package/dist/ctx/create-ctx.js +78 -3
- package/dist/db/kernel-schema.d.ts +184 -27
- package/dist/devices/device-project-files.service.d.ts +88 -0
- package/dist/devices/device-project-files.service.js +249 -0
- package/dist/devices/device-projects.service.d.ts +40 -0
- package/dist/devices/device-projects.service.js +16 -13
- package/dist/devices/devices.controller.d.ts +9 -3
- package/dist/devices/devices.controller.js +27 -5
- package/dist/devices/devices.module.js +9 -1
- package/dist/devices/devices.schemas.js +6 -1
- package/dist/devices/dto.d.ts +15 -0
- package/dist/devices/dto.js +11 -0
- package/dist/devices/project-paths.d.ts +29 -0
- package/dist/devices/project-paths.js +66 -0
- package/dist/devices/project-rules.d.ts +5 -1
- package/dist/devices/project-rules.js +5 -1
- package/dist/errors.d.ts +53 -13
- package/dist/errors.js +53 -13
- package/dist/evals/canonical-json.d.ts +7 -0
- package/dist/evals/canonical-json.js +21 -0
- package/dist/evals/reconstruct.d.ts +10 -1
- package/dist/evals/reconstruct.js +20 -1
- package/dist/evals/recorded-tools.d.ts +0 -2
- package/dist/evals/recorded-tools.js +1 -16
- package/dist/evals/snapshot.d.ts +26 -3
- package/dist/evals/snapshot.js +110 -57
- package/dist/evals/worker.d.ts +4 -3
- package/dist/evals/worker.js +8 -4
- package/dist/extensions/host.d.ts +9 -2
- package/dist/extensions/host.js +12 -0
- package/dist/extensions/instance.d.ts +3 -1
- package/dist/extensions/instance.js +4 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/permission-set.d.ts +17 -1
- package/dist/extensions/permission-set.js +13 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/files/blob-objects.d.ts +124 -0
- package/dist/files/blob-objects.js +341 -0
- package/dist/files/blob-sweep.job.d.ts +122 -0
- package/dist/files/blob-sweep.job.js +389 -0
- package/dist/files/blobs.service.d.ts +135 -0
- package/dist/files/blobs.service.js +300 -0
- package/dist/files/conversation-media.d.ts +41 -0
- package/dist/files/conversation-media.js +124 -0
- package/dist/files/deliveries.d.ts +64 -0
- package/dist/files/deliveries.js +156 -0
- package/dist/files/deliveries.module.d.ts +6 -0
- package/dist/files/deliveries.module.js +24 -0
- package/dist/files/draft-cleanup.job.d.ts +26 -0
- package/dist/files/draft-cleanup.job.js +93 -0
- package/dist/files/files.module.d.ts +1 -1
- package/dist/files/files.module.js +3 -2
- package/dist/files/hash-job.d.ts +127 -0
- package/dist/files/hash-job.js +447 -0
- package/dist/files/library-backfill.d.ts +63 -0
- package/dist/files/library-backfill.js +143 -0
- package/dist/files/library-files.service.d.ts +255 -0
- package/dist/files/library-files.service.js +883 -0
- package/dist/files/library-jobs.module.d.ts +8 -0
- package/dist/files/library-jobs.module.js +27 -0
- package/dist/files/library-query.d.ts +127 -0
- package/dist/files/library-query.js +322 -0
- package/dist/files/library-read.module.d.ts +9 -0
- package/dist/files/library-read.module.js +30 -0
- package/dist/files/library.controller.d.ts +77 -0
- package/dist/files/library.controller.js +235 -0
- package/dist/files/library.module.d.ts +9 -0
- package/dist/files/library.module.js +29 -0
- package/dist/files/library.schemas.d.ts +46 -0
- package/dist/files/library.schemas.js +49 -0
- package/dist/files/previewers.controller.d.ts +20 -0
- package/dist/files/previewers.controller.js +47 -0
- package/dist/files/previewers.d.ts +25 -11
- package/dist/files/previewers.js +43 -27
- package/dist/files/referenced-files.d.ts +150 -0
- package/dist/files/referenced-files.js +234 -0
- package/dist/git/gateway.js +2 -2
- package/dist/html/html-document.controller.d.ts +8 -1
- package/dist/html/html-document.controller.js +19 -1
- package/dist/html/html-document.service.d.ts +19 -4
- package/dist/html/html-document.service.js +43 -22
- package/dist/html/html-token.d.ts +10 -1
- package/dist/html/html-token.js +14 -0
- package/dist/html/html.module.js +8 -1
- package/dist/http/api.module.js +10 -5
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/identity/settings.d.ts +26 -0
- package/dist/identity/settings.js +33 -2
- package/dist/inbox/inbox.module.js +2 -2
- package/dist/inbox/inbox.service.d.ts +8 -8
- package/dist/inbox/inbox.service.js +7 -7
- package/dist/infra/config/kernel-config.service.js +10 -5
- package/dist/infra/outbox/registry.d.ts +111 -2
- package/dist/infra/outbox/registry.js +104 -9
- package/dist/infra/throttler/named-throttlers.d.ts +2 -0
- package/dist/infra/throttler/named-throttlers.js +14 -0
- package/dist/kernel.module.js +3 -0
- package/dist/lifecycle/kernel-lifecycle.js +6 -0
- package/dist/models/purposes.js +1 -1
- package/dist/orgs/offboarding.js +1 -1
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +3 -3
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +75 -13
- package/dist/orgs/settings.service.js +104 -26
- package/dist/platform/exclusions.js +45 -8
- package/dist/platform/file-ref.d.ts +18 -3
- package/dist/platform/file-ref.js +22 -11
- package/dist/platform/operation.js +6 -2
- package/dist/platform/ops/admin.ops.js +5 -2
- package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
- package/dist/platform/ops/automations.ops.js +560 -0
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +77 -3
- package/dist/platform/ops/files.ops.d.ts +18 -0
- package/dist/platform/ops/files.ops.js +267 -0
- package/dist/platform/ops/inbox.ops.js +4 -4
- package/dist/platform/ops/org-settings.ops.js +6 -2
- package/dist/platform/ops/orgs.ops.js +2 -1
- package/dist/platform/ops/platform.ops.js +4 -4
- package/dist/platform/ops/shares.ops.js +2 -2
- package/dist/platform/platform-ops.module.d.ts +3 -2
- package/dist/platform/platform-ops.module.js +10 -5
- package/dist/platform/route-schemas.js +6 -3
- package/dist/push/jobs.d.ts +3 -3
- package/dist/push/jobs.js +2 -2
- package/dist/push/preferences.service.js +1 -1
- package/dist/push/push-owed.d.ts +3 -3
- package/dist/push/push-owed.js +6 -6
- package/dist/push/push.schemas.d.ts +4 -4
- package/dist/push/push.schemas.js +3 -3
- package/dist/push/recipients.d.ts +4 -4
- package/dist/push/recipients.js +23 -23
- package/dist/push/texts.d.ts +3 -3
- package/dist/push/texts.js +2 -2
- package/dist/push/triggers.d.ts +1 -1
- package/dist/roles/worker.module.js +18 -4
- package/dist/runtime/compaction-settings.service.d.ts +13 -1
- package/dist/runtime/compaction-settings.service.js +16 -1
- package/dist/runtime/compaction.service.d.ts +3 -1
- package/dist/runtime/compaction.service.js +3 -1
- package/dist/runtime/context/build.d.ts +24 -1
- package/dist/runtime/context/build.js +33 -11
- package/dist/runtime/context/cache-expiry.d.ts +31 -0
- package/dist/runtime/context/cache-expiry.js +60 -0
- package/dist/runtime/context/cache-ttl.d.ts +18 -0
- package/dist/runtime/context/cache-ttl.js +30 -0
- package/dist/runtime/context/compaction.d.ts +9 -2
- package/dist/runtime/context/compaction.js +64 -21
- package/dist/runtime/context/in-context-compaction.d.ts +156 -0
- package/dist/runtime/context/in-context-compaction.js +310 -0
- package/dist/runtime/context/run-context.d.ts +38 -0
- package/dist/runtime/context/run-context.js +54 -0
- package/dist/runtime/hook-calls.d.ts +2 -1
- package/dist/runtime/hook-calls.js +5 -2
- package/dist/runtime/maintenance.d.ts +16 -4
- package/dist/runtime/maintenance.js +79 -18
- package/dist/runtime/model-call.d.ts +34 -5
- package/dist/runtime/model-call.js +207 -22
- package/dist/runtime/providers.js +11 -1
- package/dist/runtime/run-finish.d.ts +4 -4
- package/dist/runtime/run-finish.js +3 -3
- package/dist/runtime/run-queue.js +12 -7
- package/dist/runtime/run-steps.d.ts +4 -2
- package/dist/runtime/run-steps.js +10 -5
- package/dist/runtime/run-worker.js +7 -1
- package/dist/runtime/runtime.module.js +6 -3
- package/dist/runtime/subagents/dispatch.js +11 -3
- package/dist/sandbox/browse-roots.d.ts +8 -0
- package/dist/sandbox/browse-roots.js +22 -0
- package/dist/sandbox/network-grants.d.ts +4 -4
- package/dist/sandbox/network-grants.js +7 -7
- package/dist/sandbox/operation-authority.d.ts +10 -3
- package/dist/sandbox/operation-authority.js +20 -10
- package/dist/sandbox/operation-intents.d.ts +3 -1
- package/dist/sandbox/operation-intents.js +11 -4
- package/dist/sandbox/permission-call-grants.js +2 -2
- package/dist/sandbox/permission-facts.js +1 -1
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +22 -11
- package/dist/sandbox/review/permission-candidate.d.ts +1 -1
- package/dist/sandbox/review/permission-candidate.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +15 -5
- package/dist/sandbox/sandbox.service.js +14 -8
- package/dist/shares/liveness.d.ts +26 -12
- package/dist/shares/liveness.js +79 -20
- package/dist/shares/revoke.d.ts +16 -11
- package/dist/shares/revoke.js +18 -14
- package/dist/shares/share-objects.d.ts +16 -21
- package/dist/shares/share-objects.js +25 -55
- package/dist/shares/share-open.service.d.ts +8 -4
- package/dist/shares/share-open.service.js +14 -11
- package/dist/shares/shares.controller.d.ts +16 -5
- package/dist/shares/shares.controller.js +39 -5
- package/dist/shares/shares.module.d.ts +4 -4
- package/dist/shares/shares.module.js +7 -6
- package/dist/shares/shares.schemas.d.ts +4 -0
- package/dist/shares/shares.schemas.js +2 -0
- package/dist/shares/shares.service.d.ts +93 -54
- package/dist/shares/shares.service.js +292 -131
- package/dist/shares/sweep.job.d.ts +18 -39
- package/dist/shares/sweep.job.js +47 -206
- package/dist/storage/purge.d.ts +1 -1
- package/dist/storage/purge.js +2 -2
- package/dist/tools/approvals.service.d.ts +6 -6
- package/dist/tools/approvals.service.js +19 -19
- package/dist/tools/builtin-names.d.ts +12 -12
- package/dist/tools/builtin-names.js +29 -29
- package/dist/tools/builtins/artifacts.d.ts +21 -13
- package/dist/tools/builtins/artifacts.js +81 -51
- package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
- package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
- package/dist/tools/builtins/builtin-tools.d.ts +15 -9
- package/dist/tools/builtins/builtin-tools.js +33 -22
- package/dist/tools/builtins/conversation-files.d.ts +23 -13
- package/dist/tools/builtins/conversation-files.js +62 -83
- package/dist/tools/builtins/image/generate.d.ts +7 -1
- package/dist/tools/builtins/image/generate.js +1 -1
- package/dist/tools/builtins/platform.js +1 -0
- package/dist/tools/builtins/sandbox/common.d.ts +6 -2
- package/dist/tools/builtins/sandbox/deliver.js +6 -7
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +6 -5
- package/dist/tools/builtins/sandbox/fetch-attachment.js +19 -12
- package/dist/tools/call-scope.d.ts +1 -1
- package/dist/tools/git-asks.js +1 -1
- package/dist/tools/git-push-policy.d.ts +3 -3
- package/dist/tools/git-push-policy.js +6 -6
- package/dist/tools/network-asks.d.ts +3 -3
- package/dist/tools/network-asks.js +3 -3
- package/dist/tools/pipeline.d.ts +4 -4
- package/dist/tools/pipeline.js +2 -2
- package/dist/tools/policy.d.ts +3 -3
- package/dist/tools/policy.js +3 -3
- package/dist/tools/tools.module.js +15 -9
- package/dist/ui/call-extension.d.ts +6 -4
- package/dist/ui/call-extension.js +5 -4
- package/dist/ui/embed-token.js +6 -3
- package/dist/ui/registry.d.ts +21 -5
- package/dist/ui/registry.js +24 -6
- package/dist/ui/ui.schemas.d.ts +22 -0
- package/dist/ui/ui.schemas.js +22 -4
- package/dist/ui/views.controller.d.ts +13 -3
- package/dist/ui/views.controller.js +33 -2
- package/dist/ui/views.d.ts +29 -1
- package/dist/ui/views.js +131 -7
- package/package.json +3 -3
- package/src/migrations/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -0
- package/src/migrations/0190_file_library.sql +285 -0
- package/src/migrations/0191_file_library_copy.sql +4 -0
- package/dist/platform/ops/schedules.ops.js +0 -509
- package/dist/schedules/effective-settings.d.ts +0 -22
- package/dist/schedules/effective-settings.js +0 -18
- package/dist/schedules/errors.d.ts +0 -8
- package/dist/schedules/errors.js +0 -8
- package/dist/schedules/job-ids.d.ts +0 -81
- package/dist/schedules/job-ids.js +0 -95
- package/dist/schedules/schedules.module.d.ts +0 -16
- package/dist/schedules/schedules.schemas.js +0 -213
- package/dist/schedules/store.module.d.ts +0 -6
- package/dist/schedules/types.d.ts +0 -110
- /package/dist/{schedules → automations}/types.js +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { ApiError } from "../errors.js";
|
|
3
|
+
import { clipped } from "./project-rules.js";
|
|
4
|
+
/** The longest path relative to a project the kernel takes (the add route's bound). */
|
|
5
|
+
export const MAX_PROJECT_RELATIVE_PATH = 4096;
|
|
6
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are what it refuses
|
|
7
|
+
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
8
|
+
/**
|
|
9
|
+
* A path relative to a device project (composer menus §5) that is refused: absolute, escaping the
|
|
10
|
+
* project root with `..`, holding a backslash or a control character, or too long. 422
|
|
11
|
+
* `device.path_outside_project` with the path (clipped) in `details`.
|
|
12
|
+
*/
|
|
13
|
+
export const pathOutsideProject = (rel) => new ApiError("device.path_outside_project", "Give a path relative to the project root that stays inside it: no absolute path, no .. above the root, no backslashes or control characters", [{ path: clipped(rel) }]);
|
|
14
|
+
/**
|
|
15
|
+
* `rel` normalized as a posix path relative to a project's root: `""` for the root itself, no
|
|
16
|
+
* `.` segments, no doubled or trailing `/`, `..` resolved. Refused ({@link pathOutsideProject})
|
|
17
|
+
* when it is absolute, climbs above the root, holds a backslash or a control character (NUL
|
|
18
|
+
* included), or is longer than {@link MAX_PROJECT_RELATIVE_PATH}. Pure string work: the device
|
|
19
|
+
* is never asked, so a symlink below the root is the provider's and its browse scope's to judge.
|
|
20
|
+
*/
|
|
21
|
+
export function projectRelativePath(rel) {
|
|
22
|
+
if (rel.length > MAX_PROJECT_RELATIVE_PATH ||
|
|
23
|
+
rel.startsWith("/") ||
|
|
24
|
+
rel.includes("\\") ||
|
|
25
|
+
CONTROL.test(rel)) {
|
|
26
|
+
throw pathOutsideProject(rel);
|
|
27
|
+
}
|
|
28
|
+
if (rel === "")
|
|
29
|
+
return "";
|
|
30
|
+
const n = posix.normalize(rel);
|
|
31
|
+
if (n === ".." || n.startsWith("../") || posix.isAbsolute(n))
|
|
32
|
+
throw pathOutsideProject(rel);
|
|
33
|
+
const trimmed = n.endsWith("/") ? n.slice(0, -1) : n;
|
|
34
|
+
return trimmed === "." ? "" : trimmed;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The absolute device path of `rel` (normalized through {@link projectRelativePath}, so refused
|
|
38
|
+
* the same way) inside the project rooted at `projectPath`, which must itself be absolute and
|
|
39
|
+
* normalized (no `.` / `..` segments, no doubled or trailing `/`): an internal error otherwise.
|
|
40
|
+
*/
|
|
41
|
+
export function joinProjectPath(projectPath, rel) {
|
|
42
|
+
// the project path is the kernel's own (a stored project): one that is not absolute and
|
|
43
|
+
// normalized is a kernel bug, never the person's path
|
|
44
|
+
if (!posix.isAbsolute(projectPath) ||
|
|
45
|
+
posix.normalize(projectPath) !== projectPath ||
|
|
46
|
+
(projectPath !== "/" && projectPath.endsWith("/"))) {
|
|
47
|
+
throw new Error(`joinProjectPath: the project path ${JSON.stringify(clipped(projectPath))} is not absolute and normalized`);
|
|
48
|
+
}
|
|
49
|
+
const r = projectRelativePath(rel);
|
|
50
|
+
const root = projectPath;
|
|
51
|
+
if (r === "")
|
|
52
|
+
return root;
|
|
53
|
+
return root === "/" ? `/${r}` : `${root}/${r}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* {@link projectRelativePath} for a path that must name a file below the root: one that
|
|
57
|
+
* normalizes to the root itself (`"."`, `"./"`, `"a/.."`) is refused with
|
|
58
|
+
* `device.path_outside_project` as well, its path in `details` as given (none when empty).
|
|
59
|
+
*/
|
|
60
|
+
export function projectFilePath(rel) {
|
|
61
|
+
const r = projectRelativePath(rel);
|
|
62
|
+
if (r === "") {
|
|
63
|
+
throw new ApiError("device.path_outside_project", "The project root is not a file; give the path of a file inside the project", rel === "" ? undefined : [{ path: clipped(rel) }]);
|
|
64
|
+
}
|
|
65
|
+
return r;
|
|
66
|
+
}
|
|
@@ -24,7 +24,11 @@ export declare const projectNotFound: (name: string) => ApiError;
|
|
|
24
24
|
* the resolved path is not one a device can hold.
|
|
25
25
|
*/
|
|
26
26
|
export declare const outsideMode: (path: string) => ApiError;
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* A project directory above the owner's home: named by the project (`name`, when there is one),
|
|
29
|
+
* never by its absolute path, which stays out of the message.
|
|
30
|
+
*/
|
|
31
|
+
export declare const tooBroad: (name?: string) => ApiError;
|
|
28
32
|
/** A device-supplied or person-supplied string inside a message, bounded. */
|
|
29
33
|
export declare function clipped(s: string, max?: number): string;
|
|
30
34
|
export {};
|
|
@@ -9,7 +9,11 @@ export const projectNotFound = (name) => new ApiError("device.project_not_found"
|
|
|
9
9
|
* the resolved path is not one a device can hold.
|
|
10
10
|
*/
|
|
11
11
|
export const outsideMode = (path) => new ApiError("device.project_outside_mode", `${clipped(path)} is outside what the device lets a project reach; pick a directory inside its base`);
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A project directory above the owner's home: named by the project (`name`, when there is one),
|
|
14
|
+
* never by its absolute path, which stays out of the message.
|
|
15
|
+
*/
|
|
16
|
+
export const tooBroad = (name) => new ApiError("device.project_path_too_broad", `${name === undefined ? "This directory" : `The project "${clipped(name)}"`} holds the owner's home directory (or other people's): pick the project's own directory, the home or below it`);
|
|
13
17
|
/** A device-supplied or person-supplied string inside a message, bounded. */
|
|
14
18
|
export function clipped(s, max = 200) {
|
|
15
19
|
return s.length <= max ? s : `${s.slice(0, max)}…`;
|
package/dist/errors.d.ts
CHANGED
|
@@ -80,6 +80,8 @@ export declare const ERROR_CODES: {
|
|
|
80
80
|
* the Platform tool (only a person turns it on).
|
|
81
81
|
*/
|
|
82
82
|
readonly "org.external_sharing_not_allowed": 400;
|
|
83
|
+
/** An org's navigation setting puts more than 3 plugin pages in the primary navigation. */
|
|
84
|
+
readonly "org_settings.nav_primary_limit": 400;
|
|
83
85
|
/** A deployment setting set in the startup config (file, Nacos or env): read-only in the admin console. */
|
|
84
86
|
readonly "deployment.setting_readonly": 409;
|
|
85
87
|
/** Allowing outside-sandbox runs platform-wide through an API token or the Platform tool (only off). */
|
|
@@ -381,6 +383,12 @@ export declare const ERROR_CODES: {
|
|
|
381
383
|
readonly "conversation.queue_item_not_found": 404;
|
|
382
384
|
/** A sub-agent's conversation takes no messages from people (sub-agents spec §6.1). */
|
|
383
385
|
readonly "conversation.read_only": 409;
|
|
386
|
+
/**
|
|
387
|
+
* A referenced project file is not there to reference (composer menus §5): the conversation has
|
|
388
|
+
* no device project, the path leaves it, or the device reports no file there;
|
|
389
|
+
* `details: [{ path?, reason? }]`.
|
|
390
|
+
*/
|
|
391
|
+
readonly "conversation.project_file_unavailable": 422;
|
|
384
392
|
readonly "run.not_active": 409;
|
|
385
393
|
/** A run that is not one of the conversation's (the live draft route, spec 2026-11-07 §3.2). */
|
|
386
394
|
readonly "run.not_found": 404;
|
|
@@ -446,12 +454,29 @@ export declare const ERROR_CODES: {
|
|
|
446
454
|
readonly "ui.action_failed": 502;
|
|
447
455
|
readonly "ui.invalid_view": 502;
|
|
448
456
|
readonly "ui.timeout": 504;
|
|
457
|
+
/** A component query's params are over `UI_LIMITS.componentQueryParamsBytes` as JSON. */
|
|
458
|
+
readonly "ui.query_params_too_large": 413;
|
|
459
|
+
/** A component query's result is over `UI_LIMITS.componentQueryBytes` as JSON, or not JSON. */
|
|
460
|
+
readonly "ui.query_result_too_large": 502;
|
|
461
|
+
/** A component query did not answer within 10 seconds (its signal aborted). */
|
|
462
|
+
readonly "ui.query_timeout": 504;
|
|
463
|
+
/** A component query handler threw. */
|
|
464
|
+
readonly "ui.query_failed": 502;
|
|
465
|
+
/** No query handler for that component, or the component is not offered to the caller. */
|
|
466
|
+
readonly "ui.query_not_found": 404;
|
|
449
467
|
readonly "storage.unavailable": 503;
|
|
450
468
|
readonly "attachment.not_found": 404;
|
|
451
469
|
readonly "attachment.not_ready": 409;
|
|
452
470
|
readonly "attachment.too_large": 413;
|
|
453
471
|
readonly "attachment.type_not_allowed": 415;
|
|
454
472
|
readonly "attachment.too_many_pending": 429;
|
|
473
|
+
readonly "file.not_found": 404;
|
|
474
|
+
readonly "file.not_ready": 409;
|
|
475
|
+
readonly "file.hash_mismatch": 422;
|
|
476
|
+
readonly "file.deleted": 410;
|
|
477
|
+
readonly "file.too_large": 413;
|
|
478
|
+
readonly "file.type_not_allowed": 415;
|
|
479
|
+
readonly "file.too_many_pending": 429;
|
|
455
480
|
readonly "sandbox.unavailable": 503;
|
|
456
481
|
readonly "sandbox.busy": 409;
|
|
457
482
|
/** A cloud sandbox provider refused an instance with the open public network. */
|
|
@@ -549,6 +574,13 @@ export declare const ERROR_CODES: {
|
|
|
549
574
|
readonly "device.project_path_unreadable": 422;
|
|
550
575
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
551
576
|
readonly "device.project_refused": 422;
|
|
577
|
+
/**
|
|
578
|
+
* A path relative to a device project that leaves it (composer menus §5): absolute, `..` above
|
|
579
|
+
* the root, a backslash or a control character; `details: [{ path }]`.
|
|
580
|
+
*/
|
|
581
|
+
readonly "device.path_outside_project": 422;
|
|
582
|
+
/** The device's provider cannot list its directories for its owner (no `list` / owner browse). */
|
|
583
|
+
readonly "device.list_unsupported": 409;
|
|
552
584
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
553
585
|
readonly "device_sign_in.authorization_pending": 400;
|
|
554
586
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -565,28 +597,36 @@ export declare const ERROR_CODES: {
|
|
|
565
597
|
readonly "device.credential_invalid": 401;
|
|
566
598
|
/** A device stream hop from another gateway replica without a valid MAC (or replayed). */
|
|
567
599
|
readonly "device.stream_hop_refused": 401;
|
|
568
|
-
/** The
|
|
569
|
-
readonly "
|
|
600
|
+
/** The automation is missing, deleted, in another org or not the caller's to see. */
|
|
601
|
+
readonly "automation.not_found": 404;
|
|
570
602
|
/** Not a 5-field cron expression (no seconds field). */
|
|
571
|
-
readonly "
|
|
603
|
+
readonly "automation.invalid_cron": 400;
|
|
572
604
|
/** Not an IANA time zone. */
|
|
573
|
-
readonly "
|
|
605
|
+
readonly "automation.invalid_time_zone": 400;
|
|
574
606
|
/** A `once` time that is not a local date-time `YYYY-MM-DDTHH:mm[:ss]`. */
|
|
575
|
-
readonly "
|
|
607
|
+
readonly "automation.invalid_once_time": 400;
|
|
576
608
|
/** A `once` time that is not in the future. */
|
|
577
|
-
readonly "
|
|
609
|
+
readonly "automation.once_in_past": 400;
|
|
578
610
|
/** Two fire times closer than the org's `minIntervalMinutes`. */
|
|
579
|
-
readonly "
|
|
611
|
+
readonly "automation.interval_too_short": 400;
|
|
580
612
|
/** The creator or the org has as many active and paused tasks as the org allows. */
|
|
581
|
-
readonly "
|
|
582
|
-
/** The org turned
|
|
583
|
-
readonly "
|
|
613
|
+
readonly "automation.limit_reached": 409;
|
|
614
|
+
/** The org turned automations off. */
|
|
615
|
+
readonly "automation.disabled": 409;
|
|
584
616
|
/** Where the task runs is inconsistent or not the creator's to use (conversation, chat, device). */
|
|
585
|
-
readonly "
|
|
617
|
+
readonly "automation.target_invalid": 400;
|
|
586
618
|
/** A tool the creator cannot pre-approve for the task (spec §7). */
|
|
587
|
-
readonly "
|
|
619
|
+
readonly "automation.grant_not_allowed": 400;
|
|
620
|
+
/** An event trigger names a source that is not an enabled trigger source of the org. */
|
|
621
|
+
readonly "automation.event_source_unavailable": 400;
|
|
622
|
+
/** An event trigger names an event type its source does not declare (or a directed one). */
|
|
623
|
+
readonly "automation.event_type_unknown": 400;
|
|
624
|
+
/** An event trigger's filter names a missing or unfilterable fact, or mistypes a value. */
|
|
625
|
+
readonly "automation.filter_invalid": 400;
|
|
588
626
|
/** An org admin may pause, resume and delete another person's task, never edit it. */
|
|
589
|
-
readonly "
|
|
627
|
+
readonly "automation.forbidden": 403;
|
|
628
|
+
/** "Run now" and trial runs: an event automation runs only on its events (no run now, no trial). */
|
|
629
|
+
readonly "automation.run_now_unsupported": 409;
|
|
590
630
|
readonly "skill.not_found": 404;
|
|
591
631
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
592
632
|
readonly "skill.file_not_found": 404;
|
package/dist/errors.js
CHANGED
|
@@ -80,6 +80,8 @@ export const ERROR_CODES = {
|
|
|
80
80
|
* the Platform tool (only a person turns it on).
|
|
81
81
|
*/
|
|
82
82
|
"org.external_sharing_not_allowed": 400,
|
|
83
|
+
/** An org's navigation setting puts more than 3 plugin pages in the primary navigation. */
|
|
84
|
+
"org_settings.nav_primary_limit": 400,
|
|
83
85
|
/** A deployment setting set in the startup config (file, Nacos or env): read-only in the admin console. */
|
|
84
86
|
"deployment.setting_readonly": 409,
|
|
85
87
|
/** Allowing outside-sandbox runs platform-wide through an API token or the Platform tool (only off). */
|
|
@@ -381,6 +383,12 @@ export const ERROR_CODES = {
|
|
|
381
383
|
"conversation.queue_item_not_found": 404,
|
|
382
384
|
/** A sub-agent's conversation takes no messages from people (sub-agents spec §6.1). */
|
|
383
385
|
"conversation.read_only": 409,
|
|
386
|
+
/**
|
|
387
|
+
* A referenced project file is not there to reference (composer menus §5): the conversation has
|
|
388
|
+
* no device project, the path leaves it, or the device reports no file there;
|
|
389
|
+
* `details: [{ path?, reason? }]`.
|
|
390
|
+
*/
|
|
391
|
+
"conversation.project_file_unavailable": 422,
|
|
384
392
|
"run.not_active": 409,
|
|
385
393
|
/** A run that is not one of the conversation's (the live draft route, spec 2026-11-07 §3.2). */
|
|
386
394
|
"run.not_found": 404,
|
|
@@ -446,12 +454,29 @@ export const ERROR_CODES = {
|
|
|
446
454
|
"ui.action_failed": 502,
|
|
447
455
|
"ui.invalid_view": 502,
|
|
448
456
|
"ui.timeout": 504,
|
|
457
|
+
/** A component query's params are over `UI_LIMITS.componentQueryParamsBytes` as JSON. */
|
|
458
|
+
"ui.query_params_too_large": 413,
|
|
459
|
+
/** A component query's result is over `UI_LIMITS.componentQueryBytes` as JSON, or not JSON. */
|
|
460
|
+
"ui.query_result_too_large": 502,
|
|
461
|
+
/** A component query did not answer within 10 seconds (its signal aborted). */
|
|
462
|
+
"ui.query_timeout": 504,
|
|
463
|
+
/** A component query handler threw. */
|
|
464
|
+
"ui.query_failed": 502,
|
|
465
|
+
/** No query handler for that component, or the component is not offered to the caller. */
|
|
466
|
+
"ui.query_not_found": 404,
|
|
449
467
|
"storage.unavailable": 503,
|
|
450
468
|
"attachment.not_found": 404,
|
|
451
469
|
"attachment.not_ready": 409,
|
|
452
470
|
"attachment.too_large": 413,
|
|
453
471
|
"attachment.type_not_allowed": 415,
|
|
454
472
|
"attachment.too_many_pending": 429,
|
|
473
|
+
"file.not_found": 404,
|
|
474
|
+
"file.not_ready": 409,
|
|
475
|
+
"file.hash_mismatch": 422,
|
|
476
|
+
"file.deleted": 410,
|
|
477
|
+
"file.too_large": 413,
|
|
478
|
+
"file.type_not_allowed": 415,
|
|
479
|
+
"file.too_many_pending": 429,
|
|
455
480
|
"sandbox.unavailable": 503,
|
|
456
481
|
"sandbox.busy": 409,
|
|
457
482
|
/** A cloud sandbox provider refused an instance with the open public network. */
|
|
@@ -549,6 +574,13 @@ export const ERROR_CODES = {
|
|
|
549
574
|
"device.project_path_unreadable": 422,
|
|
550
575
|
/** The device provider refused the project's directory (its reason is the message and details). */
|
|
551
576
|
"device.project_refused": 422,
|
|
577
|
+
/**
|
|
578
|
+
* A path relative to a device project that leaves it (composer menus §5): absolute, `..` above
|
|
579
|
+
* the root, a backslash or a control character; `details: [{ path }]`.
|
|
580
|
+
*/
|
|
581
|
+
"device.path_outside_project": 422,
|
|
582
|
+
/** The device's provider cannot list its directories for its owner (no `list` / owner browse). */
|
|
583
|
+
"device.list_unsupported": 409,
|
|
552
584
|
/** Device sign-in (RFC 8628 style): the person has not approved the code yet; keep polling. */
|
|
553
585
|
"device_sign_in.authorization_pending": 400,
|
|
554
586
|
/** Device sign-in: the program polls faster than the interval; add 5 seconds and keep polling. */
|
|
@@ -565,28 +597,36 @@ export const ERROR_CODES = {
|
|
|
565
597
|
"device.credential_invalid": 401,
|
|
566
598
|
/** A device stream hop from another gateway replica without a valid MAC (or replayed). */
|
|
567
599
|
"device.stream_hop_refused": 401,
|
|
568
|
-
/** The
|
|
569
|
-
"
|
|
600
|
+
/** The automation is missing, deleted, in another org or not the caller's to see. */
|
|
601
|
+
"automation.not_found": 404,
|
|
570
602
|
/** Not a 5-field cron expression (no seconds field). */
|
|
571
|
-
"
|
|
603
|
+
"automation.invalid_cron": 400,
|
|
572
604
|
/** Not an IANA time zone. */
|
|
573
|
-
"
|
|
605
|
+
"automation.invalid_time_zone": 400,
|
|
574
606
|
/** A `once` time that is not a local date-time `YYYY-MM-DDTHH:mm[:ss]`. */
|
|
575
|
-
"
|
|
607
|
+
"automation.invalid_once_time": 400,
|
|
576
608
|
/** A `once` time that is not in the future. */
|
|
577
|
-
"
|
|
609
|
+
"automation.once_in_past": 400,
|
|
578
610
|
/** Two fire times closer than the org's `minIntervalMinutes`. */
|
|
579
|
-
"
|
|
611
|
+
"automation.interval_too_short": 400,
|
|
580
612
|
/** The creator or the org has as many active and paused tasks as the org allows. */
|
|
581
|
-
"
|
|
582
|
-
/** The org turned
|
|
583
|
-
"
|
|
613
|
+
"automation.limit_reached": 409,
|
|
614
|
+
/** The org turned automations off. */
|
|
615
|
+
"automation.disabled": 409,
|
|
584
616
|
/** Where the task runs is inconsistent or not the creator's to use (conversation, chat, device). */
|
|
585
|
-
"
|
|
617
|
+
"automation.target_invalid": 400,
|
|
586
618
|
/** A tool the creator cannot pre-approve for the task (spec §7). */
|
|
587
|
-
"
|
|
619
|
+
"automation.grant_not_allowed": 400,
|
|
620
|
+
/** An event trigger names a source that is not an enabled trigger source of the org. */
|
|
621
|
+
"automation.event_source_unavailable": 400,
|
|
622
|
+
/** An event trigger names an event type its source does not declare (or a directed one). */
|
|
623
|
+
"automation.event_type_unknown": 400,
|
|
624
|
+
/** An event trigger's filter names a missing or unfilterable fact, or mistypes a value. */
|
|
625
|
+
"automation.filter_invalid": 400,
|
|
588
626
|
/** An org admin may pause, resume and delete another person's task, never edit it. */
|
|
589
|
-
"
|
|
627
|
+
"automation.forbidden": 403,
|
|
628
|
+
/** "Run now" and trial runs: an event automation runs only on its events (no run now, no trial). */
|
|
629
|
+
"automation.run_now_unsupported": 409,
|
|
590
630
|
"skill.not_found": 404,
|
|
591
631
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
592
632
|
"skill.file_not_found": 404,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON (eval replay matching): object keys sorted recursively by code point, arrays in
|
|
3
|
+
* order, `undefined` left out by the JSON rules. A leaf module, so request building
|
|
4
|
+
* (`evals/reconstruct.ts`, reached from the runtime through the in-context summary) does not pull
|
|
5
|
+
* in the tool pipeline that `recorded-tools.ts` needs.
|
|
6
|
+
*/
|
|
7
|
+
export declare function canonicalJson(v: unknown): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical JSON (eval replay matching): object keys sorted recursively by code point, arrays in
|
|
3
|
+
* order, `undefined` left out by the JSON rules. A leaf module, so request building
|
|
4
|
+
* (`evals/reconstruct.ts`, reached from the runtime through the in-context summary) does not pull
|
|
5
|
+
* in the tool pipeline that `recorded-tools.ts` needs.
|
|
6
|
+
*/
|
|
7
|
+
export function canonicalJson(v) {
|
|
8
|
+
const norm = (x) => {
|
|
9
|
+
if (Array.isArray(x))
|
|
10
|
+
return x.map(norm);
|
|
11
|
+
if (x !== null && typeof x === "object") {
|
|
12
|
+
const o = x;
|
|
13
|
+
const out = {};
|
|
14
|
+
for (const k of Object.keys(o).sort())
|
|
15
|
+
out[k] = norm(o[k]);
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
return x;
|
|
19
|
+
};
|
|
20
|
+
return JSON.stringify(norm(v) ?? null);
|
|
21
|
+
}
|
|
@@ -27,7 +27,9 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
27
27
|
* - `context_fit` (context compaction spec §4.9, never for a baseline): the candidate model's window
|
|
28
28
|
* makes the hard fit guard plan a different trim than the recorded `model_call.request.fit` (the
|
|
29
29
|
* recorded plan is replayed for a baseline; a candidate applies its recomputed plan);
|
|
30
|
-
* - `run_outcome_note`: the rebuilt run outcome notes differ from the recorded `runOutcomeSeqs
|
|
30
|
+
* - `run_outcome_note`: the rebuilt run outcome notes differ from the recorded `runOutcomeSeqs`;
|
|
31
|
+
* - `automation_event_block`: the rebuilt event automation blocks differ from the recorded
|
|
32
|
+
* `automationEventSeqs`.
|
|
31
33
|
*/
|
|
32
34
|
/** 还原结果与原请求不一致的原因。 */
|
|
33
35
|
export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing" | "definition_missing"
|
|
@@ -59,6 +61,13 @@ export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing"
|
|
|
59
61
|
* the log alone, so a candidate cannot change them.
|
|
60
62
|
*/
|
|
61
63
|
| "run_outcome_note"
|
|
64
|
+
/**
|
|
65
|
+
* Collaboration spec §4.6: the rebuild renders the event automation block
|
|
66
|
+
* (`automationEventBlock`) for another set of messages than the request recorded in
|
|
67
|
+
* `model_call.request.automationEventSeqs`: a request sent before the block was rendered.
|
|
68
|
+
* Judged for every reconstruction: the block comes from the log alone.
|
|
69
|
+
*/
|
|
70
|
+
| "automation_event_block"
|
|
62
71
|
/** 整轮回放(T5):有工具调用没有匹配到记录(模型收到 REPLAY_NO_RECORDING)。 */
|
|
63
72
|
| "tool_unmatched";
|
|
64
73
|
export interface ReconstructOptions {
|
|
@@ -5,13 +5,14 @@ import { sameModel, selectionAt } from "../conversations/selection.js";
|
|
|
5
5
|
import { ApiError } from "../errors.js";
|
|
6
6
|
import { COMPACTION_SETTINGS } from "../identity/settings.js";
|
|
7
7
|
import { latestSummary, mediaRefs, planMedia, } from "../runtime/context/build.js";
|
|
8
|
+
import { selectCacheTtl, trustedCache } from "../runtime/context/cache-ttl.js";
|
|
8
9
|
import { applyFit, estimateAfterFit, planFit, planningBounds, planSqueezedFit, sentOutputCap, } from "../runtime/context/fit.js";
|
|
9
10
|
import { assertRecordedPermissionEvents, permissionContextHistory, RecordedPermissionContextError, } from "../runtime/context/permission-profile.js";
|
|
10
11
|
import { estimateTokens } from "../runtime/context/tokens.js";
|
|
11
12
|
import { assembleModelRequest, } from "../runtime/model-call.js";
|
|
12
13
|
import { CHILD_REMOVED_TOOLS } from "../runtime/subagents/definition.js";
|
|
13
14
|
import { AGENT_TOOL } from "../tools/builtin-names.js";
|
|
14
|
-
import { canonicalJson } from "./
|
|
15
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
15
16
|
import { toEvents } from "./snapshot.js";
|
|
16
17
|
/** `R` when the caller did not resolve the org's settings (the built-in platform default). */
|
|
17
18
|
const DEFAULT_RESERVE_TOKENS = COMPACTION_SETTINGS.parse({}).reserveTokens;
|
|
@@ -47,6 +48,7 @@ const DRIFT_ORDER = [
|
|
|
47
48
|
"media_changed",
|
|
48
49
|
"context_fit",
|
|
49
50
|
"run_outcome_note",
|
|
51
|
+
"automation_event_block",
|
|
50
52
|
"tool_unmatched",
|
|
51
53
|
];
|
|
52
54
|
function findCall(events, seq) {
|
|
@@ -198,6 +200,16 @@ export function reconstructInputs(s, modelCallSeq, opts) {
|
|
|
198
200
|
}
|
|
199
201
|
const budget = opts.mediaBudgetBytes ?? rec.mediaBudgetBytes;
|
|
200
202
|
const readWindow = opts.readImagesPerRequest ?? rec.readImagesPerRequest;
|
|
203
|
+
// the prompt cache tier: a recorded transport option, not model-visible, so no DriftReason
|
|
204
|
+
// either way (idle compaction spec §9.2). The baseline sends the recorded value while the model
|
|
205
|
+
// still offers it (never a value the model does not offer); a candidate recomputes it for its
|
|
206
|
+
// model, with the long tier on when the recording asked for one.
|
|
207
|
+
const cacheTtl = baseline
|
|
208
|
+
? rec.cacheTtl !== undefined &&
|
|
209
|
+
trustedCache(opts.model.cache)?.ttlOptions.includes(rec.cacheTtl)
|
|
210
|
+
? rec.cacheTtl
|
|
211
|
+
: undefined
|
|
212
|
+
: selectCacheTtl(opts.model.cache, rec.cacheTtl !== undefined);
|
|
201
213
|
const input = {
|
|
202
214
|
events: inputEvents(all, call),
|
|
203
215
|
agent,
|
|
@@ -209,6 +221,7 @@ export function reconstructInputs(s, modelCallSeq, opts) {
|
|
|
209
221
|
tools,
|
|
210
222
|
toolSearch: rec.catalog !== undefined,
|
|
211
223
|
...(rec.toolChoice !== undefined && { toolChoice: rec.toolChoice }),
|
|
224
|
+
...(cacheTtl !== undefined && { cacheTtl }),
|
|
212
225
|
...(opts.mediaInfo !== undefined && { mediaInfo: opts.mediaInfo }),
|
|
213
226
|
...(opts.media !== undefined && { media: opts.media }),
|
|
214
227
|
...(budget !== undefined && { mediaBudgetBytes: budget }),
|
|
@@ -283,6 +296,12 @@ export function reconstructFromInputs(s, gathered, opts) {
|
|
|
283
296
|
if (notes.length !== recordedNotes.length || notes.some((x, i) => x !== recordedNotes[i])) {
|
|
284
297
|
drift.add("run_outcome_note");
|
|
285
298
|
}
|
|
299
|
+
// event automation blocks: from the log alone, so only a request sent before they existed differs
|
|
300
|
+
const blocks = meta.automationEventSeqs ?? [];
|
|
301
|
+
const recordedBlocks = rec.automationEventSeqs ?? [];
|
|
302
|
+
if (blocks.length !== recordedBlocks.length || blocks.some((x, i) => x !== recordedBlocks[i])) {
|
|
303
|
+
drift.add("automation_event_block");
|
|
304
|
+
}
|
|
286
305
|
// 媒体:按附件 id 与记录比较
|
|
287
306
|
const recordedMedia = new Map((rec.media ?? []).map((m) => [m.attachmentId, m]));
|
|
288
307
|
for (const m of meta.media ?? []) {
|
|
@@ -46,8 +46,6 @@ export interface RecordedCall {
|
|
|
46
46
|
*/
|
|
47
47
|
media?: ReadMedia[];
|
|
48
48
|
}
|
|
49
|
-
/** 规范化 JSON:对象键递归按码点排序,数组保持顺序;`undefined` 按 JSON 规则省略。 */
|
|
50
|
-
export declare function canonicalJson(v: unknown): string;
|
|
51
49
|
/** The matching key of a call: the canonical JSON of its input without the ignored fields. */
|
|
52
50
|
export declare function matchKey(toolKey: string, input: unknown): string;
|
|
53
51
|
/**
|
|
@@ -4,6 +4,7 @@ import { devicePathsChangeFromPayload, devicePathsLevel, } from "../runtime/cont
|
|
|
4
4
|
import { assistantIdemKey } from "../runtime/model-call.js";
|
|
5
5
|
import { MATCH_IGNORED_FIELDS } from "../tools/builtin-names.js";
|
|
6
6
|
import { RUN_STOPPED_TEXT } from "../tools/pipeline.js";
|
|
7
|
+
import { canonicalJson } from "./canonical-json.js";
|
|
7
8
|
/**
|
|
8
9
|
* 整轮回放的工具管线(C6 / Review Focus 3):只回放原运行记录的工具结果,**从不执行任何工具**——
|
|
9
10
|
* 不经过策略、审批、沙箱、连接器,也不调用任何处理函数。每个调用按 (toolKey, 规范化参数) 精确匹配第一条未用的记录;
|
|
@@ -11,22 +12,6 @@ import { RUN_STOPPED_TEXT } from "../tools/pipeline.js";
|
|
|
11
12
|
*/
|
|
12
13
|
/** 没有匹配记录时模型看到的工具结果(模型可见,英文)。 */
|
|
13
14
|
export const REPLAY_NO_RECORDING = "[replay] No recorded result matches this tool call (same tool and arguments); the tool was not executed during replay.";
|
|
14
|
-
/** 规范化 JSON:对象键递归按码点排序,数组保持顺序;`undefined` 按 JSON 规则省略。 */
|
|
15
|
-
export function canonicalJson(v) {
|
|
16
|
-
const norm = (x) => {
|
|
17
|
-
if (Array.isArray(x))
|
|
18
|
-
return x.map(norm);
|
|
19
|
-
if (x !== null && typeof x === "object") {
|
|
20
|
-
const o = x;
|
|
21
|
-
const out = {};
|
|
22
|
-
for (const k of Object.keys(o).sort())
|
|
23
|
-
out[k] = norm(o[k]);
|
|
24
|
-
return out;
|
|
25
|
-
}
|
|
26
|
-
return x;
|
|
27
|
-
};
|
|
28
|
-
return JSON.stringify(norm(v) ?? null);
|
|
29
|
-
}
|
|
30
15
|
/** The matching key of a call: the canonical JSON of its input without the ignored fields. */
|
|
31
16
|
export function matchKey(toolKey, input) {
|
|
32
17
|
const ignored = MATCH_IGNORED_FIELDS[toolKey];
|
package/dist/evals/snapshot.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ConversationSource, ToolSpec } from "@capybara-hq/plugin-sdk";
|
|
|
2
2
|
import { type AgentDefinition } from "../agents/definition.js";
|
|
3
3
|
import type { ConversationEvent, ConversationEventType } from "../conversations/events.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
5
|
+
import { type FollowUpNarrowing } from "../runtime/subagents/definition.js";
|
|
5
6
|
/**
|
|
6
7
|
* 评测用例快照(C3):复制截至某次运行终态的会话事件、这些事件引用的 agent 版本定义、请求用到的工具定义
|
|
7
8
|
* (按 specHash)。回放只读快照,不改原对话的日志;媒体不复制字节,回放时按引用取原附件。
|
|
@@ -59,11 +60,33 @@ export interface CaseSnapshot {
|
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
63
|
+
* The follow-up narrowing of run `runId`: the one on the last sub-agent task message up to the
|
|
64
|
+
* run's last event (its terminal event when it has one), if any. A task message logged after the
|
|
65
|
+
* run (a later follow-up's, which a live snapshot may hold) never narrows this run's definition.
|
|
66
|
+
* Without any event of the run, every event counts.
|
|
67
|
+
*/
|
|
68
|
+
export declare function runTaskNarrowing(events: readonly SnapshotEvent[], runId: string): FollowUpNarrowing | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Takes a case snapshot of a run. The conversation not in the org, or the run not the
|
|
71
|
+
* conversation's → `conversation.not_found`; the run without a terminal event yet →
|
|
72
|
+
* `eval.run_not_finished` (409); over `maxBytes` bytes serialized → `eval.case_too_large` (413).
|
|
73
|
+
* The caller passes `maxBytes` (`evals.maxCaseBytes`).
|
|
65
74
|
*/
|
|
66
75
|
export declare function takeSnapshot(db: KernelSchemaDb, orgId: string, conversationId: string, runId: string, maxBytes: number): Promise<CaseSnapshot>;
|
|
76
|
+
/**
|
|
77
|
+
* A snapshot of events the caller already holds, for a request built live rather than stored (the
|
|
78
|
+
* in-context compaction summary, idle compaction spec §9.4): no terminal event is required and no
|
|
79
|
+
* byte cap applies, since nothing is stored. `runId` is the run of the call the request rebuilds;
|
|
80
|
+
* `conversation.not_found` as in {@link takeSnapshot}. `agentId` is the caller's check: a
|
|
81
|
+
* conversation whose agent differs is not found either.
|
|
82
|
+
*/
|
|
83
|
+
export declare function liveSnapshot(db: KernelSchemaDb, input: {
|
|
84
|
+
orgId: string;
|
|
85
|
+
conversationId: string;
|
|
86
|
+
runId: string;
|
|
87
|
+
agentId: string;
|
|
88
|
+
events: readonly ConversationEvent[];
|
|
89
|
+
}): Promise<CaseSnapshot>;
|
|
67
90
|
/**
|
|
68
91
|
* Reads a stored snapshot (`eval_cases.snapshot`): each version's definition goes through
|
|
69
92
|
* `normalizeStoredDefinition` (missing turned-off lists read as empty). Other fields as they are.
|