@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.38
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/bootstrap.json +5 -5
- package/dist/admin/admin.module.d.ts +3 -2
- package/dist/admin/admin.module.js +9 -5
- package/dist/admin/audit-log.service.d.ts +51 -0
- package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
- package/dist/admin/audit.controller.d.ts +18 -6
- package/dist/admin/audit.controller.js +36 -6
- package/dist/admin/audit.schemas.d.ts +9 -1
- package/dist/admin/audit.schemas.js +22 -2
- package/dist/admin/org-network.controller.d.ts +30 -0
- package/dist/admin/org-network.controller.js +77 -0
- package/dist/admin/org-network.schemas.d.ts +16 -0
- package/dist/admin/org-network.schemas.js +27 -0
- package/dist/admin/org-network.service.d.ts +41 -0
- package/dist/admin/org-network.service.js +101 -0
- package/dist/admin/outbox-dead.controller.d.ts +4 -6
- package/dist/admin/outbox-dead.controller.js +9 -6
- package/dist/admin/outbox-dead.schemas.d.ts +16 -0
- package/dist/admin/outbox-dead.schemas.js +25 -1
- package/dist/admin/outbox-dead.service.d.ts +16 -7
- package/dist/admin/outbox-dead.service.js +34 -10
- package/dist/admin/overview.service.d.ts +3 -3
- package/dist/admin/overview.service.js +0 -1
- package/dist/agents/agent-lookup.js +2 -10
- package/dist/agents/agents.service.js +9 -20
- package/dist/agents/definition.d.ts +3 -51
- package/dist/agents/definition.js +4 -254
- package/dist/agents/org-templates.js +2 -6
- package/dist/agents/readiness.controller.d.ts +4 -12
- package/dist/agents/readiness.controller.js +4 -12
- package/dist/agents/readiness.service.d.ts +23 -11
- package/dist/agents/readiness.service.js +31 -14
- package/dist/agents/templates.d.ts +0 -6
- package/dist/agents/templates.js +8 -34
- package/dist/background/store.d.ts +2 -0
- package/dist/background/store.js +3 -1
- package/dist/background/wake-rules.js +2 -1
- package/dist/catalog/admin-catalog.controller.d.ts +1 -2
- package/dist/catalog/admin-catalog.controller.js +1 -2
- package/dist/catalog/appearance.service.js +1 -3
- package/dist/catalog/catalog-content.d.ts +1 -1
- package/dist/catalog/catalog-content.js +1 -4
- package/dist/catalog/catalog-items.js +3 -3
- package/dist/catalog/catalog-scope.service.d.ts +10 -28
- package/dist/catalog/catalog-scope.service.js +22 -73
- package/dist/catalog/cli.d.ts +0 -11
- package/dist/catalog/cli.js +0 -20
- package/dist/catalog/component-scope.service.js +0 -2
- package/dist/catalog/component-state.js +2 -2
- package/dist/catalog/install-status.d.ts +6 -0
- package/dist/catalog/install-status.js +6 -0
- package/dist/catalog/job-ids.d.ts +0 -4
- package/dist/catalog/job-ids.js +0 -4
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +2 -0
- package/dist/catalog/org-catalog.service.js +8 -3
- package/dist/catalog/org-extension-switch.d.ts +7 -2
- package/dist/catalog/org-extension-switch.js +56 -9
- package/dist/catalog/org-plugin-uploads.d.ts +6 -15
- package/dist/catalog/org-plugin-uploads.js +9 -27
- package/dist/catalog/owned-items.js +1 -3
- package/dist/catalog/platform-import-update.js +1 -1
- package/dist/catalog/plugin-import.d.ts +15 -13
- package/dist/catalog/plugin-import.js +21 -30
- package/dist/catalog/plugin-install.d.ts +3 -43
- package/dist/catalog/plugin-install.js +8 -150
- package/dist/catalog/plugin-package.d.ts +5 -10
- package/dist/catalog/plugin-package.js +12 -33
- package/dist/catalog/plugin-upgrade.js +5 -4
- package/dist/catalog/scope-jobs.d.ts +34 -34
- package/dist/catalog/scope-jobs.js +50 -37
- package/dist/catalog/scope-orgs.d.ts +1 -1
- package/dist/catalog/scope-orgs.js +1 -2
- package/dist/catalog/scope-sync-workers.d.ts +4 -3
- package/dist/catalog/scope-sync-workers.js +18 -6
- package/dist/catalog/scope-sync.d.ts +56 -59
- package/dist/catalog/scope-sync.js +96 -166
- package/dist/catalog/unshare.d.ts +3 -4
- package/dist/catalog/unshare.js +5 -8
- package/dist/channels/job-ids.d.ts +2 -6
- package/dist/channels/job-ids.js +2 -6
- package/dist/channels/outbound.d.ts +1 -1
- package/dist/channels/outbound.js +1 -1
- package/dist/channels/supervisor.d.ts +2 -3
- package/dist/channels/supervisor.js +2 -3
- package/dist/client/client-access.service.js +1 -1
- package/dist/config/env.js +19 -1
- package/dist/config/load.d.ts +0 -6
- package/dist/config/load.js +8 -27
- package/dist/config/schema.d.ts +54 -47
- package/dist/config/schema.js +198 -42
- package/dist/conversations/attachments.service.d.ts +10 -3
- package/dist/conversations/attachments.service.js +49 -16
- package/dist/conversations/conversations.controller.d.ts +0 -39
- package/dist/conversations/conversations.controller.js +0 -39
- package/dist/conversations/event-log.js +4 -1
- package/dist/conversations/events.d.ts +71 -46
- package/dist/conversations/events.js +124 -112
- package/dist/conversations/media-types.d.ts +25 -0
- package/dist/conversations/media-types.js +38 -0
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.service.js +9 -2
- package/dist/conversations/titles.js +6 -0
- package/dist/ctx/create-ctx.d.ts +8 -1
- package/dist/ctx/create-ctx.js +13 -3
- package/dist/ctx/net.d.ts +50 -0
- package/dist/ctx/net.js +67 -0
- package/dist/ctx/secrets.d.ts +24 -7
- package/dist/ctx/secrets.js +97 -30
- package/dist/db/kernel-schema.d.ts +27 -6
- package/dist/devices/devices.service.js +2 -1
- package/dist/errors.d.ts +10 -2
- package/dist/errors.js +10 -2
- package/dist/evals/reconstruct.d.ts +4 -17
- package/dist/evals/reconstruct.js +13 -53
- package/dist/evals/recorded-tools.d.ts +0 -27
- package/dist/evals/recorded-tools.js +2 -92
- package/dist/evals/run-replay.d.ts +1 -6
- package/dist/evals/run-replay.js +10 -17
- package/dist/evals/sets.service.d.ts +17 -5
- package/dist/evals/sets.service.js +33 -12
- package/dist/evals/snapshot.d.ts +1 -2
- package/dist/evals/snapshot.js +4 -17
- package/dist/extensions/admin-ops.d.ts +6 -1
- package/dist/extensions/admin-ops.js +17 -4
- package/dist/extensions/admin-view.d.ts +7 -4
- package/dist/extensions/admin-view.js +27 -21
- package/dist/extensions/bootstrap.js +0 -1
- package/dist/extensions/cli.js +0 -1
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +9 -4
- package/dist/extensions/host.js +14 -8
- package/dist/extensions/installs.d.ts +1 -3
- package/dist/extensions/instance.d.ts +0 -2
- package/dist/extensions/instance.js +0 -3
- package/dist/extensions/org-config.d.ts +4 -4
- package/dist/extensions/org-config.js +13 -22
- package/dist/extensions/package.d.ts +6 -6
- package/dist/extensions/package.js +3 -7
- package/dist/extensions/permission-view.d.ts +2 -4
- package/dist/extensions/plugin-items.d.ts +21 -1
- package/dist/extensions/plugin-items.js +28 -0
- package/dist/extensions/sync.js +5 -10
- package/dist/extensions/unavailable.js +0 -1
- package/dist/http/api.module.js +4 -1
- package/dist/identity/audit.d.ts +0 -12
- package/dist/identity/audit.js +0 -27
- package/dist/identity/auth.controller.js +5 -9
- package/dist/identity/cookies.d.ts +4 -9
- package/dist/identity/cookies.js +8 -32
- package/dist/identity/initial-passwords.d.ts +1 -1
- package/dist/identity/initial-passwords.js +1 -2
- package/dist/identity/sessions.d.ts +0 -6
- package/dist/identity/sessions.js +0 -18
- package/dist/inbox/platform-inbox.service.d.ts +33 -1
- package/dist/inbox/platform-inbox.service.js +56 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
- package/dist/infra/cli/master-key-rewrap.js +24 -0
- package/dist/infra/config/kernel-config.service.js +0 -17
- package/dist/infra/database/transaction-host.d.ts +32 -1
- package/dist/infra/database/transaction-host.js +30 -4
- package/dist/infra/database/xact-lock.d.ts +16 -0
- package/dist/infra/database/xact-lock.js +28 -1
- package/dist/infra/health/health.controller.js +8 -0
- package/dist/infra/health/process-fault.d.ts +16 -0
- package/dist/infra/health/process-fault.js +49 -0
- package/dist/infra/lifecycle/process-guards.d.ts +8 -2
- package/dist/infra/lifecycle/process-guards.js +12 -3
- package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
- package/dist/infra/lifecycle/shutdown-signals.js +28 -13
- package/dist/infra/outbox/outbox.service.d.ts +12 -9
- package/dist/infra/outbox/outbox.service.js +22 -26
- package/dist/infra/outbox/registry.d.ts +15 -7
- package/dist/infra/outbox/registry.js +39 -23
- package/dist/lifecycle/kernel-lifecycle.js +1 -7
- package/dist/models/enablement.d.ts +5 -6
- package/dist/models/enablement.js +7 -14
- package/dist/net/public-address.d.ts +21 -1
- package/dist/net/public-address.js +56 -10
- package/dist/net/safe-fetch.d.ts +4 -1
- package/dist/net/safe-fetch.js +15 -4
- package/dist/orgs/directory-sync.js +2 -0
- package/dist/orgs/members.service.js +5 -0
- package/dist/orgs/network-allowances.service.d.ts +79 -0
- package/dist/orgs/network-allowances.service.js +371 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +9 -2
- package/dist/orgs/org-lock.d.ts +28 -2
- package/dist/orgs/org-lock.js +59 -4
- package/dist/orgs/orgs.controller.d.ts +11 -2
- package/dist/orgs/orgs.controller.js +19 -3
- package/dist/orgs/orgs.module.d.ts +3 -2
- package/dist/orgs/orgs.module.js +6 -2
- package/dist/orgs/orgs.schemas.d.ts +12 -0
- package/dist/orgs/orgs.schemas.js +5 -0
- package/dist/orgs/orgs.service.js +6 -1
- package/dist/orgs/settings.controller.d.ts +3 -2
- package/dist/orgs/settings.service.d.ts +59 -14
- package/dist/orgs/settings.service.js +102 -20
- package/dist/overrides.d.ts +7 -7
- package/dist/overrides.js +4 -4
- package/dist/packages/tgz.d.ts +0 -2
- package/dist/packages/tgz.js +0 -2
- package/dist/platform/exclusions.js +0 -5
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/admin.ops.d.ts +2 -2
- package/dist/platform/ops/admin.ops.js +9 -6
- package/dist/platform/ops/agents.ops.js +1 -1
- package/dist/platform/ops/connectors.ops.js +46 -1
- package/dist/platform/ops/evals.ops.js +1 -64
- package/dist/platform/ops/extensions-admin.ops.js +1 -1
- package/dist/platform/ops/inbox.ops.js +16 -3
- package/dist/platform/ops/org-plugins.ops.js +1 -1
- package/dist/platform/ops/orgs.ops.d.ts +11 -3
- package/dist/platform/ops/orgs.ops.js +139 -5
- package/dist/platform/ops/outbox.ops.js +5 -5
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker-role.d.ts +2 -3
- package/dist/roles/worker-role.js +3 -13
- package/dist/runtime/checkpointer.d.ts +3 -0
- package/dist/runtime/checkpointer.js +7 -4
- package/dist/runtime/context/build.d.ts +56 -18
- package/dist/runtime/context/build.js +143 -50
- package/dist/runtime/context/compaction.d.ts +1 -3
- package/dist/runtime/context/compaction.js +42 -8
- package/dist/runtime/context/run-context.js +1 -2
- package/dist/runtime/context/skills.d.ts +27 -56
- package/dist/runtime/context/skills.js +42 -114
- package/dist/runtime/context/tool-changes.d.ts +3 -3
- package/dist/runtime/context/tool-changes.js +6 -16
- package/dist/runtime/hook-calls.d.ts +6 -6
- package/dist/runtime/hook-calls.js +7 -7
- package/dist/runtime/langgraph-loop.js +9 -3
- package/dist/runtime/maintenance.d.ts +3 -11
- package/dist/runtime/maintenance.js +5 -20
- package/dist/runtime/model-call.d.ts +5 -0
- package/dist/runtime/model-call.js +48 -36
- package/dist/runtime/providers.d.ts +33 -35
- package/dist/runtime/providers.js +64 -109
- package/dist/runtime/run-context.service.js +7 -22
- package/dist/runtime/run-deletion.d.ts +6 -0
- package/dist/runtime/run-deletion.js +39 -16
- package/dist/runtime/run-execution.d.ts +56 -3
- package/dist/runtime/run-execution.js +81 -11
- package/dist/runtime/run-finish.js +2 -1
- package/dist/runtime/run-liveness.d.ts +11 -0
- package/dist/runtime/run-liveness.js +19 -0
- package/dist/runtime/run-orphan-check.job.js +2 -1
- package/dist/runtime/run-queue.js +8 -16
- package/dist/runtime/run-worker.d.ts +2 -2
- package/dist/runtime/run-worker.js +8 -6
- package/dist/runtime/step-log.d.ts +5 -0
- package/dist/runtime/step-log.js +9 -4
- package/dist/runtime/subagents/definition.d.ts +16 -20
- package/dist/runtime/subagents/definition.js +27 -27
- package/dist/runtime/subagents/dispatch.d.ts +6 -2
- package/dist/runtime/subagents/dispatch.js +17 -3
- package/dist/runtime/subagents/org-agents.js +1 -2
- package/dist/runtime/subagents/preamble.d.ts +3 -2
- package/dist/runtime/subagents/preamble.js +3 -2
- package/dist/runtime/subagents/render.d.ts +1 -2
- package/dist/runtime/subagents/render.js +1 -2
- package/dist/runtime/subagents/skill-fork.d.ts +2 -4
- package/dist/runtime/subagents/template-skills.d.ts +47 -0
- package/dist/runtime/subagents/template-skills.js +76 -0
- package/dist/runtime/waits.js +3 -1
- package/dist/schedules/effective-settings.d.ts +9 -3
- package/dist/schedules/effective-settings.js +5 -4
- package/dist/schedules/fire.js +11 -0
- package/dist/schedules/scheduled-tasks.service.js +5 -0
- package/dist/schedules/unattended.d.ts +2 -0
- package/dist/schedules/unattended.js +6 -1
- package/dist/skills/agent-skills.service.js +1 -2
- package/dist/skills/catalog.d.ts +1 -3
- package/dist/skills/catalog.js +1 -3
- package/dist/skills/conversation-catalog.d.ts +1 -2
- package/dist/skills/conversation-catalog.js +1 -2
- package/dist/skills/usable.js +2 -3
- package/dist/storage/storage.service.js +9 -1
- package/dist/tools/approvals.service.js +2 -4
- package/dist/tools/builtin-names.d.ts +2 -9
- package/dist/tools/builtin-names.js +4 -13
- package/dist/tools/builtins/sandbox/bash.js +3 -3
- package/dist/tools/builtins/sandbox/common.d.ts +7 -13
- package/dist/tools/builtins/sandbox/common.js +8 -115
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
- package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
- package/dist/tools/builtins/sandbox/glob.js +1 -3
- package/dist/tools/builtins/sandbox/grep.js +3 -5
- package/dist/tools/builtins/sandbox/index.d.ts +8 -5
- package/dist/tools/builtins/sandbox/index.js +10 -5
- package/dist/tools/builtins/sandbox/read.js +3 -2
- package/dist/tools/builtins/tool-search.d.ts +4 -7
- package/dist/tools/builtins/tool-search.js +6 -10
- package/dist/tools/connector-account-policies.d.ts +30 -3
- package/dist/tools/connector-account-policies.js +54 -7
- package/dist/tools/connector-content.js +1 -0
- package/dist/tools/connectors.controller.d.ts +24 -11
- package/dist/tools/connectors.controller.js +35 -6
- package/dist/tools/connectors.schemas.d.ts +14 -1
- package/dist/tools/connectors.schemas.js +14 -2
- package/dist/tools/connectors.service.d.ts +22 -0
- package/dist/tools/connectors.service.js +65 -6
- package/dist/tools/drift.d.ts +6 -2
- package/dist/tools/drift.js +10 -5
- package/dist/tools/git-push-policy.d.ts +4 -1
- package/dist/tools/git-push-policy.js +3 -1
- package/dist/tools/info.d.ts +1 -7
- package/dist/tools/info.js +5 -18
- package/dist/tools/job-ids.d.ts +0 -4
- package/dist/tools/job-ids.js +1 -6
- package/dist/tools/pipeline.d.ts +4 -10
- package/dist/tools/pipeline.js +17 -62
- package/dist/tools/policy.d.ts +6 -2
- package/dist/tools/policy.js +14 -12
- package/dist/tools/registry.js +1 -5
- package/dist/ui/views.d.ts +5 -5
- package/dist/ui/views.js +10 -16
- package/package.json +3 -3
- package/src/migrations/0137_audit_org_idx.sql +5 -0
- package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
- package/src/migrations/0139_retire_legacy_forms.sql +183 -0
- package/src/migrations/0140_retire_history_forms.sql +148 -0
- package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
- package/src/migrations/0142_backfill_event_fields.sql +74 -0
- package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
- package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
- package/src/migrations/0145_org_network_allowances.sql +12 -0
- package/dist/admin/platform-audit.service.d.ts +0 -41
- package/dist/conversations/job-ids.d.ts +0 -6
- package/dist/conversations/job-ids.js +0 -6
- package/dist/extensions/job-ids.d.ts +0 -6
- package/dist/extensions/job-ids.js +0 -6
- package/dist/infra/queue/retired-schedulers.d.ts +0 -7
- package/dist/infra/queue/retired-schedulers.js +0 -9
- package/dist/orgs/job-ids.d.ts +0 -8
- package/dist/orgs/job-ids.js +0 -8
- package/dist/runtime/context/legacy-text.d.ts +0 -22
- package/dist/runtime/context/legacy-text.js +0 -37
- package/dist/runtime/job-ids.d.ts +0 -10
- package/dist/runtime/job-ids.js +0 -10
- package/dist/runtime/retired-schedulers.d.ts +0 -7
- package/dist/runtime/retired-schedulers.js +0 -31
- package/dist/storage/job-ids.d.ts +0 -6
- package/dist/storage/job-ids.js +0 -6
- package/dist/tools/legacy-data.d.ts +0 -34
- package/dist/tools/legacy-data.js +0 -76
- package/dist/tools/legacy-keys.d.ts +0 -51
- package/dist/tools/legacy-keys.js +0 -114
|
@@ -11,17 +11,6 @@ import { CHILD_REMOVED_TOOLS } from "../runtime/subagents/definition.js";
|
|
|
11
11
|
import { AGENT_TOOL } from "../tools/builtin-names.js";
|
|
12
12
|
import { canonicalJson } from "./recorded-tools.js";
|
|
13
13
|
import { toEvents } from "./snapshot.js";
|
|
14
|
-
/**
|
|
15
|
-
* Does a definition from before skills were on by default pin skills? Read raw: the normalizer
|
|
16
|
-
* drops `skills.pinned` (skills default-on spec §4, §9).
|
|
17
|
-
*/
|
|
18
|
-
const pinsSkills = (d) => {
|
|
19
|
-
const skills = typeof d === "object" && d !== null ? d.skills : undefined;
|
|
20
|
-
const pinned = typeof skills === "object" && skills !== null
|
|
21
|
-
? skills.pinned
|
|
22
|
-
: undefined;
|
|
23
|
-
return Array.isArray(pinned) && pinned.length > 0;
|
|
24
|
-
};
|
|
25
14
|
/** `R` when the caller did not resolve the org's settings (the built-in platform default). */
|
|
26
15
|
const DEFAULT_RESERVE_TOKENS = COMPACTION_SETTINGS.parse({}).reserveTokens;
|
|
27
16
|
/** Two hard-fit plans trim the same messages and blocks (the recorded plan may be absent). */
|
|
@@ -47,9 +36,7 @@ const DRIFT_ORDER = [
|
|
|
47
36
|
"tools_changed",
|
|
48
37
|
"tool_spec_missing",
|
|
49
38
|
"definition_missing",
|
|
50
|
-
"pinned_changed",
|
|
51
39
|
"subagent_changed",
|
|
52
|
-
"legacy_event",
|
|
53
40
|
"params_changed",
|
|
54
41
|
"model_switched",
|
|
55
42
|
"media_missing",
|
|
@@ -85,12 +72,6 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
85
72
|
const call = findCall(all, modelCallSeq);
|
|
86
73
|
const rec = call.payload.request;
|
|
87
74
|
const drift = new Set();
|
|
88
|
-
if (rec.tools === undefined ||
|
|
89
|
-
rec.params === undefined ||
|
|
90
|
-
rec.absorbedUpToSeq === undefined ||
|
|
91
|
-
rec.maxOutputTokens === undefined) {
|
|
92
|
-
drift.add("legacy_event");
|
|
93
|
-
}
|
|
94
75
|
const origVersion = recordedVersion(s, all, call);
|
|
95
76
|
const version = opts.agentVersion ?? origVersion;
|
|
96
77
|
const started = subagentStartedOf(all);
|
|
@@ -137,22 +118,11 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
137
118
|
model: { provider: call.payload.provider, model: call.payload.model },
|
|
138
119
|
});
|
|
139
120
|
}
|
|
140
|
-
// pinned_changed (skills default-on spec §9): the snapshot in effect at the call pinned skills,
|
|
141
|
-
// and no candidate pins any more (the migration rewrote the stored versions without pins). The
|
|
142
|
-
// stub of definition_missing is no candidate, so it is skipped then; a child reports a logged
|
|
143
|
-
// pin as subagent_changed instead.
|
|
144
|
-
if (!baseline && started === undefined && !drift.has("definition_missing")) {
|
|
145
|
-
const snap = inputEvents(all, call)
|
|
146
|
-
.filter((e) => e.type === "skills_catalog")
|
|
147
|
-
.at(-1);
|
|
148
|
-
if ((snap?.payload.pinned ?? []).length > 0)
|
|
149
|
-
drift.add("pinned_changed");
|
|
150
|
-
}
|
|
151
121
|
// 工具:按记录的顺序从快照取定义;取不到的从请求里去掉(基线与候选一样)
|
|
152
122
|
const tools = [];
|
|
153
123
|
const seen = new Set();
|
|
154
|
-
const kept = (list) =>
|
|
155
|
-
for (const t of [...
|
|
124
|
+
const kept = (list) => list.filter((t) => s.toolSpecs[t.specHash] !== undefined);
|
|
125
|
+
for (const t of [...rec.tools, ...(rec.catalog ?? [])]) {
|
|
156
126
|
if (seen.has(t.key))
|
|
157
127
|
continue;
|
|
158
128
|
seen.add(t.key);
|
|
@@ -173,11 +143,11 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
173
143
|
}
|
|
174
144
|
let params = opts.params;
|
|
175
145
|
if (params === undefined) {
|
|
176
|
-
const
|
|
177
|
-
const clean = sanitizeParams(opts.model.parameters, recorded);
|
|
146
|
+
const clean = sanitizeParams(opts.model.parameters, rec.params);
|
|
178
147
|
params = clean.value;
|
|
179
|
-
if (clean.dropped.length > 0 || !sameParams(clean.value,
|
|
148
|
+
if (clean.dropped.length > 0 || !sameParams(clean.value, rec.params)) {
|
|
180
149
|
drift.add("params_changed");
|
|
150
|
+
}
|
|
181
151
|
}
|
|
182
152
|
const budget = opts.mediaBudgetBytes ?? rec.mediaBudgetBytes;
|
|
183
153
|
const built = assembleModelRequest({
|
|
@@ -186,7 +156,7 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
186
156
|
agentVersion: version,
|
|
187
157
|
model: opts.model,
|
|
188
158
|
step: call.payload.step,
|
|
189
|
-
|
|
159
|
+
absorbedUpToSeq: rec.absorbedUpToSeq,
|
|
190
160
|
params,
|
|
191
161
|
tools,
|
|
192
162
|
toolSearch: rec.catalog !== undefined,
|
|
@@ -194,13 +164,11 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
194
164
|
...(opts.mediaInfo !== undefined && { mediaInfo: opts.mediaInfo }),
|
|
195
165
|
...(opts.media !== undefined && { media: opts.media }),
|
|
196
166
|
...(budget !== undefined && { mediaBudgetBytes: budget }),
|
|
197
|
-
defaultMaxOutputTokens: rec.maxOutputTokens
|
|
167
|
+
defaultMaxOutputTokens: rec.maxOutputTokens,
|
|
198
168
|
// The baseline replays the recorded output cap as sent: the runtime may have clamped it below
|
|
199
169
|
// the agent's `maxOutputTokens` knob (context compaction spec §4.3), and recomputing it from the
|
|
200
170
|
// knob would replay a larger cap. A candidate below recomputes the clamp and the trim instead.
|
|
201
|
-
...(baseline && rec.maxOutputTokens
|
|
202
|
-
? { recordedMaxOutputTokens: rec.maxOutputTokens }
|
|
203
|
-
: {}),
|
|
171
|
+
...(baseline && { recordedMaxOutputTokens: rec.maxOutputTokens }),
|
|
204
172
|
// the baseline replays the recorded trim (no reserve needed); a candidate below recomputes it
|
|
205
173
|
...(baseline && rec.fit !== undefined ? { fit: rec.fit } : {}),
|
|
206
174
|
});
|
|
@@ -240,16 +208,12 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
240
208
|
if (meta.systemHash !== rec.systemHash)
|
|
241
209
|
drift.add("system_hash");
|
|
242
210
|
// 与记录比较时排除快照里缺定义的工具(已记 tool_spec_missing)
|
|
243
|
-
if (rec.tools
|
|
244
|
-
|
|
245
|
-
!sameList(meta.catalog, rec.catalog === undefined ? undefined : kept(rec.catalog)))) {
|
|
211
|
+
if (!sameList(meta.tools, kept(rec.tools)) ||
|
|
212
|
+
!sameList(meta.catalog, rec.catalog === undefined ? undefined : kept(rec.catalog))) {
|
|
246
213
|
drift.add("tools_changed");
|
|
247
214
|
}
|
|
248
215
|
}
|
|
249
216
|
// 媒体:按附件 id 与记录比较
|
|
250
|
-
if (meta.media !== undefined && (rec.media === undefined || rec.mediaBudgetBytes === undefined)) {
|
|
251
|
-
drift.add("legacy_event");
|
|
252
|
-
}
|
|
253
217
|
const recordedMedia = new Map((rec.media ?? []).map((m) => [m.attachmentId, m]));
|
|
254
218
|
for (const m of meta.media ?? []) {
|
|
255
219
|
const was = recordedMedia.get(m.attachmentId);
|
|
@@ -257,14 +221,13 @@ export function reconstructRequest(s, modelCallSeq, opts) {
|
|
|
257
221
|
drift.add("media_missing");
|
|
258
222
|
}
|
|
259
223
|
else if (baseline &&
|
|
260
|
-
rec.media !== undefined &&
|
|
261
224
|
(was === undefined || was.outcome !== m.outcome || was.etag !== m.etag)) {
|
|
262
225
|
drift.add("media_changed");
|
|
263
226
|
}
|
|
264
227
|
}
|
|
265
|
-
if (baseline
|
|
228
|
+
if (baseline) {
|
|
266
229
|
const now = new Set((meta.media ?? []).map((m) => m.attachmentId));
|
|
267
|
-
if (rec.media.some((m) => !now.has(m.attachmentId)))
|
|
230
|
+
if ((rec.media ?? []).some((m) => !now.has(m.attachmentId)))
|
|
268
231
|
drift.add("media_changed");
|
|
269
232
|
}
|
|
270
233
|
return { request, meta, drift: DRIFT_ORDER.filter((r) => drift.has(r)), mediaTokens };
|
|
@@ -314,8 +277,7 @@ const parentSide = (d, started) => canonicalJson({
|
|
|
314
277
|
* Does a candidate change what a sub-agent (child) case would run (`subagent_changed`, spec
|
|
315
278
|
* §15.1)? Pure, from the snapshot alone, comparing the model-visible parts of the effective
|
|
316
279
|
* definition (instructions, turned-off skills, tools) with the logged one (`logged`, from its
|
|
317
|
-
* `subagent_started`).
|
|
318
|
-
* differs from every candidate: none pins any more (skills default-on spec §9).
|
|
280
|
+
* `subagent_started`).
|
|
319
281
|
* - the same agent version (`sameVersion`): the candidate is the logged definition with
|
|
320
282
|
* overrides (instructions, model, params), compared field by field;
|
|
321
283
|
* - another version of the case's agent: for an org agent child (`source: "agent"`) that agent's
|
|
@@ -336,8 +298,6 @@ const parentSide = (d, started) => canonicalJson({
|
|
|
336
298
|
export function subagentChanged(started, logged, candidate, sameVersion,
|
|
337
299
|
/** The parent's definition at the case's version (the snapshot's), for template children. */
|
|
338
300
|
original) {
|
|
339
|
-
if (pinsSkills(started.definition))
|
|
340
|
-
return true;
|
|
341
301
|
const keepAgent = hasAgent(logged);
|
|
342
302
|
const childTools = (d) => childToolsOf(d, keepAgent);
|
|
343
303
|
const differs = (instructions, skills, tools) => instructions !== logged.instructions ||
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { EventLog } from "../conversations/event-log.js";
|
|
2
2
|
import { type DevicePathsPayload } from "../runtime/context/device-paths.js";
|
|
3
|
-
import { type LegacyScope } from "../tools/legacy-keys.js";
|
|
4
3
|
import { type ToolPipeline, type ToolStepContext } from "../tools/pipeline.js";
|
|
5
4
|
import type { CaseSnapshot } from "./snapshot.js";
|
|
6
5
|
/**
|
|
@@ -22,8 +21,6 @@ export interface RecordedCall {
|
|
|
22
21
|
contentTypes?: string[];
|
|
23
22
|
/** 原 `tool_call_started` 的定义指纹(没有开始事件的调用为空串)。 */
|
|
24
23
|
specHash: string;
|
|
25
|
-
/** The recorded call used release-candidate names; `toolKey` and `inputKey` are already the current ones. */
|
|
26
|
-
legacy?: true;
|
|
27
24
|
/**
|
|
28
25
|
* The payload (roots, and the sandbox level when recorded) of the latest `device_paths` event
|
|
29
26
|
* the original run had logged by this call's step (environments spec §13.1, ruling R22): set on
|
|
@@ -33,27 +30,6 @@ export interface RecordedCall {
|
|
|
33
30
|
*/
|
|
34
31
|
devicePaths?: DevicePathsPayload;
|
|
35
32
|
}
|
|
36
|
-
/**
|
|
37
|
-
* The connectors and extensions an rc `<x>__<tool>` key can name, from positive evidence in the
|
|
38
|
-
* snapshot only (a head with no evidence, or evidence of both kinds, stays unmapped, so its
|
|
39
|
-
* recorded calls are unmatched, which is a safe miss):
|
|
40
|
-
* - a connector: the tool definition the key was recorded with (`toolSpecs`, found by the specHash of
|
|
41
|
-
* its `tool_call_started` or its `model_call` tools / catalog entry) has `connectorData`;
|
|
42
|
-
* - an extension: that definition exists without `connectorData` and its name is the key's tool
|
|
43
|
-
* part, or an rc-era agent definition names exactly that tool as a `{ kind: "plugin", plugin: x, name }`
|
|
44
|
-
* ref.
|
|
45
|
-
*/
|
|
46
|
-
export declare function legacyScopeOf(s: CaseSnapshot): LegacyScope;
|
|
47
|
-
/**
|
|
48
|
-
* A recorded call in the current names: an rc builtin or `<x>__<tool>` key becomes its current
|
|
49
|
-
* key with the input's parameters renamed. Only the recorded side is ever normalized; a call
|
|
50
|
-
* already in current names (or one that cannot be mapped) is returned as is.
|
|
51
|
-
*/
|
|
52
|
-
export declare function currentCall(name: string, input: unknown, scope: LegacyScope): {
|
|
53
|
-
name: string;
|
|
54
|
-
input: unknown;
|
|
55
|
-
legacy: boolean;
|
|
56
|
-
};
|
|
57
33
|
/** 规范化 JSON:对象键递归按码点排序,数组保持顺序;`undefined` 按 JSON 规则省略。 */
|
|
58
34
|
export declare function canonicalJson(v: unknown): string;
|
|
59
35
|
/** The matching key of a call: the canonical JSON of its input without the ignored fields. */
|
|
@@ -76,10 +52,7 @@ export declare class RecordedToolPipeline implements Pick<ToolPipeline, "runStep
|
|
|
76
52
|
private readonly d;
|
|
77
53
|
private readonly used;
|
|
78
54
|
private misses;
|
|
79
|
-
private legacyHits;
|
|
80
55
|
constructor(d: RecordedToolPipelineDeps);
|
|
81
|
-
/** Calls so far matched with a recording made under release-candidate tool names. */
|
|
82
|
-
legacyMatches(): number;
|
|
83
56
|
/** 至今没有匹配到记录的调用数。 */
|
|
84
57
|
unmatched(): number;
|
|
85
58
|
runStep(ctx: ToolStepContext): Promise<{
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { devicePathsChange, devicePathsLevel, } from "../runtime/context/device-paths.js";
|
|
2
2
|
import { assistantIdemKey } from "../runtime/model-call.js";
|
|
3
3
|
import { MATCH_IGNORED_FIELDS } from "../tools/builtin-names.js";
|
|
4
|
-
import { isLegacyPrefixedKey, legacyToolInput, legacyToolKey, } from "../tools/legacy-keys.js";
|
|
5
4
|
import { RUN_STOPPED_TEXT } from "../tools/pipeline.js";
|
|
6
5
|
/**
|
|
7
6
|
* 整轮回放的工具管线(C6 / Review Focus 3):只回放原运行记录的工具结果,**从不执行任何工具**——
|
|
@@ -10,85 +9,6 @@ import { RUN_STOPPED_TEXT } from "../tools/pipeline.js";
|
|
|
10
9
|
*/
|
|
11
10
|
/** 没有匹配记录时模型看到的工具结果(模型可见,英文)。 */
|
|
12
11
|
export const REPLAY_NO_RECORDING = "[replay] No recorded result matches this tool call (same tool and arguments); the tool was not executed during replay.";
|
|
13
|
-
/**
|
|
14
|
-
* The connectors and extensions an rc `<x>__<tool>` key can name, from positive evidence in the
|
|
15
|
-
* snapshot only (a head with no evidence, or evidence of both kinds, stays unmapped, so its
|
|
16
|
-
* recorded calls are unmatched, which is a safe miss):
|
|
17
|
-
* - a connector: the tool definition the key was recorded with (`toolSpecs`, found by the specHash of
|
|
18
|
-
* its `tool_call_started` or its `model_call` tools / catalog entry) has `connectorData`;
|
|
19
|
-
* - an extension: that definition exists without `connectorData` and its name is the key's tool
|
|
20
|
-
* part, or an rc-era agent definition names exactly that tool as a `{ kind: "plugin", plugin: x, name }`
|
|
21
|
-
* ref.
|
|
22
|
-
*/
|
|
23
|
-
export function legacyScopeOf(s) {
|
|
24
|
-
const hashes = new Map();
|
|
25
|
-
const note = (key, hash) => {
|
|
26
|
-
if (!isLegacyPrefixedKey(key))
|
|
27
|
-
return;
|
|
28
|
-
const set = hashes.get(key) ?? new Set();
|
|
29
|
-
if (hash !== undefined && hash !== "")
|
|
30
|
-
set.add(hash);
|
|
31
|
-
hashes.set(key, set);
|
|
32
|
-
};
|
|
33
|
-
for (const e of s.events) {
|
|
34
|
-
if (e.type === "tool_call_started") {
|
|
35
|
-
const p = e.payload;
|
|
36
|
-
note(p.toolKey, p.specHash);
|
|
37
|
-
}
|
|
38
|
-
else if (e.type === "model_call") {
|
|
39
|
-
const r = e.payload.request;
|
|
40
|
-
for (const t of [...(r?.tools ?? []), ...(r?.catalog ?? [])])
|
|
41
|
-
note(t.key, t.specHash);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const extensionNames = new Set();
|
|
45
|
-
const connectorSlugs = new Set();
|
|
46
|
-
const planted = new Set();
|
|
47
|
-
// rc-era snapshots hold definitions from before tools were on by default: an enabled `tools`
|
|
48
|
-
// list of refs (tools default-on spec §2)
|
|
49
|
-
for (const def of Object.values(s.definitions)) {
|
|
50
|
-
const refs = def.tools;
|
|
51
|
-
if (!Array.isArray(refs))
|
|
52
|
-
continue;
|
|
53
|
-
for (const t of refs) {
|
|
54
|
-
if (t?.kind === "plugin" && typeof t.plugin === "string" && typeof t.name === "string") {
|
|
55
|
-
planted.add(`${t.plugin}__${t.name}`);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
for (const [key, set] of hashes) {
|
|
60
|
-
const i = key.indexOf("__");
|
|
61
|
-
const head = key.slice(0, i);
|
|
62
|
-
const tool = key.slice(i + 2);
|
|
63
|
-
for (const h of set) {
|
|
64
|
-
const spec = s.toolSpecs[h];
|
|
65
|
-
if (spec === undefined)
|
|
66
|
-
continue;
|
|
67
|
-
if (spec.connectorData !== undefined) {
|
|
68
|
-
connectorSlugs.add(head);
|
|
69
|
-
}
|
|
70
|
-
else if (spec.name === tool) {
|
|
71
|
-
extensionNames.add(head);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
for (const key of planted) {
|
|
76
|
-
if (hashes.has(key))
|
|
77
|
-
extensionNames.add(key.slice(0, key.indexOf("__")));
|
|
78
|
-
}
|
|
79
|
-
return { connectorSlugs, extensionNames };
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* A recorded call in the current names: an rc builtin or `<x>__<tool>` key becomes its current
|
|
83
|
-
* key with the input's parameters renamed. Only the recorded side is ever normalized; a call
|
|
84
|
-
* already in current names (or one that cannot be mapped) is returned as is.
|
|
85
|
-
*/
|
|
86
|
-
export function currentCall(name, input, scope) {
|
|
87
|
-
const key = legacyToolKey(name, scope);
|
|
88
|
-
if (key === null)
|
|
89
|
-
return { name, input, legacy: false };
|
|
90
|
-
return { name: key, input: legacyToolInput(name, input), legacy: true };
|
|
91
|
-
}
|
|
92
12
|
/** 规范化 JSON:对象键递归按码点排序,数组保持顺序;`undefined` 按 JSON 规则省略。 */
|
|
93
13
|
export function canonicalJson(v) {
|
|
94
14
|
const norm = (x) => {
|
|
@@ -156,7 +76,6 @@ export function recordedCalls(s) {
|
|
|
156
76
|
if (current !== undefined)
|
|
157
77
|
pathsOf.set(a, current);
|
|
158
78
|
}
|
|
159
|
-
const scope = legacyScopeOf(s);
|
|
160
79
|
const out = [];
|
|
161
80
|
for (const e of own) {
|
|
162
81
|
if (e.type !== "assistant_message")
|
|
@@ -170,11 +89,9 @@ export function recordedCalls(s) {
|
|
|
170
89
|
const r = results.get(call.id);
|
|
171
90
|
if (!r)
|
|
172
91
|
continue;
|
|
173
|
-
const cur = currentCall(call.name, call.input, scope);
|
|
174
92
|
out.push({
|
|
175
|
-
toolKey:
|
|
176
|
-
inputKey: matchKey(
|
|
177
|
-
...(cur.legacy && { legacy: true }),
|
|
93
|
+
toolKey: call.name,
|
|
94
|
+
inputKey: matchKey(call.name, call.input),
|
|
178
95
|
content: r.content,
|
|
179
96
|
isError: r.isError,
|
|
180
97
|
...(r.loadedTools !== undefined && { loadedTools: r.loadedTools }),
|
|
@@ -195,14 +112,9 @@ export class RecordedToolPipeline {
|
|
|
195
112
|
d;
|
|
196
113
|
used = new Set();
|
|
197
114
|
misses = 0;
|
|
198
|
-
legacyHits = 0;
|
|
199
115
|
constructor(d) {
|
|
200
116
|
this.d = d;
|
|
201
117
|
}
|
|
202
|
-
/** Calls so far matched with a recording made under release-candidate tool names. */
|
|
203
|
-
legacyMatches() {
|
|
204
|
-
return this.legacyHits;
|
|
205
|
-
}
|
|
206
118
|
/** 至今没有匹配到记录的调用数。 */
|
|
207
119
|
unmatched() {
|
|
208
120
|
return this.misses;
|
|
@@ -271,8 +183,6 @@ export class RecordedToolPipeline {
|
|
|
271
183
|
if (i < 0)
|
|
272
184
|
return undefined;
|
|
273
185
|
this.used.add(i);
|
|
274
|
-
if (this.d.recordings[i]?.legacy === true)
|
|
275
|
-
this.legacyHits++;
|
|
276
186
|
return this.d.recordings[i];
|
|
277
187
|
}
|
|
278
188
|
}
|
|
@@ -11,7 +11,7 @@ import type { AgentLoop, LoopOutcome } from "../runtime/loop.js";
|
|
|
11
11
|
import { type MediaSourceDeps } from "../runtime/model-call.js";
|
|
12
12
|
import type { ProviderRegistry } from "../runtime/providers.js";
|
|
13
13
|
import type { RunFinish } from "../runtime/run-finish.js";
|
|
14
|
-
import type
|
|
14
|
+
import { type CaseSnapshot, type SnapshotEvent } from "./snapshot.js";
|
|
15
15
|
import type { ResolvedCandidate } from "./step-replay.js";
|
|
16
16
|
/**
|
|
17
17
|
* 整轮回放(D2 / C6):在 `kind = 'eval'` 的隐藏对话里跑**同一个** `LangGraphLoop`,工具管线换成
|
|
@@ -42,11 +42,6 @@ export interface RunReplayResult {
|
|
|
42
42
|
usage: ModelUsage;
|
|
43
43
|
steps: number;
|
|
44
44
|
unmatched: number;
|
|
45
|
-
/**
|
|
46
|
-
* Set when a call was matched with a recording made under the release-candidate tool names
|
|
47
|
-
* (`sandbox_edit` for `Edit`, `docs__search` for `mcp__docs__search`, old parameter names).
|
|
48
|
-
*/
|
|
49
|
-
legacyKeyMatch?: true;
|
|
50
45
|
}
|
|
51
46
|
/** 原运行(基线)的同形摘要。 */
|
|
52
47
|
export type RunBaseline = Omit<RunReplayResult, "conversationId" | "outcome" | "unmatched">;
|
package/dist/evals/run-replay.js
CHANGED
|
@@ -27,7 +27,8 @@ import { runContextIdemKey } from "../runtime/run-context.service.js";
|
|
|
27
27
|
import { recordedSkillForks } from "../runtime/subagents/skill-fork.js";
|
|
28
28
|
import { skillsCatalogIdemKey } from "../skills/catalog.js";
|
|
29
29
|
import { ACTIVE_EVAL_STATUSES, addUsage, consumeTokens, TOO_MANY_ERRORS, usageTokens, } from "./budget.js";
|
|
30
|
-
import {
|
|
30
|
+
import { RecordedToolPipeline, recordedCalls } from "./recorded-tools.js";
|
|
31
|
+
import { toEvents } from "./snapshot.js";
|
|
31
32
|
/** 写种子时发现已失去认领或运行已不在执行:本次执行停下,不留评测对话。 */
|
|
32
33
|
export class ReplayClaimLost extends Error {
|
|
33
34
|
constructor() {
|
|
@@ -210,7 +211,7 @@ const ZERO = {
|
|
|
210
211
|
cacheWriteTokens: 0,
|
|
211
212
|
};
|
|
212
213
|
/** 一次运行的工具调用序列、最后的回复、停止原因、用量与步数(基线与候选同一算法)。 */
|
|
213
|
-
function summarize(events, runId
|
|
214
|
+
function summarize(events, runId) {
|
|
214
215
|
const toolCalls = [];
|
|
215
216
|
let usage = ZERO;
|
|
216
217
|
let last = null;
|
|
@@ -224,12 +225,7 @@ function summarize(events, runId, scope) {
|
|
|
224
225
|
for (const b of p.content) {
|
|
225
226
|
if (b.type !== "tool_call")
|
|
226
227
|
continue;
|
|
227
|
-
|
|
228
|
-
toolCalls.push({ name: b.name, input: b.input });
|
|
229
|
-
else {
|
|
230
|
-
const { name, input } = currentCall(b.name, b.input, scope);
|
|
231
|
-
toolCalls.push({ name, input });
|
|
232
|
-
}
|
|
228
|
+
toolCalls.push({ name: b.name, input: b.input });
|
|
233
229
|
}
|
|
234
230
|
last = { content: p.content, stopReason: p.stopReason };
|
|
235
231
|
}
|
|
@@ -253,9 +249,7 @@ function summarize(events, runId, scope) {
|
|
|
253
249
|
}
|
|
254
250
|
/** 原运行(快照)的摘要,作为整轮回放的基线。 */
|
|
255
251
|
export function runBaseline(s) {
|
|
256
|
-
|
|
257
|
-
// shows real differences
|
|
258
|
-
return summarize(s.events, s.runId, legacyScopeOf(s));
|
|
252
|
+
return summarize(s.events, s.runId);
|
|
259
253
|
}
|
|
260
254
|
/**
|
|
261
255
|
* 删掉一个评测对话(崩溃重跑前清掉上一次的残留):先删它各次运行的 checkpoint,再删对话(事件、运行随之级联删除)。
|
|
@@ -279,17 +273,17 @@ export async function deleteEvalConversation(d, conversationId) {
|
|
|
279
273
|
.execute();
|
|
280
274
|
}
|
|
281
275
|
/**
|
|
282
|
-
*
|
|
276
|
+
* Where each step of the original run had taken in absorbable events (its first attempt's
|
|
277
|
+
* `absorbedUpToSeq`).
|
|
283
278
|
*/
|
|
284
279
|
function absorbedByStep(s) {
|
|
285
280
|
const out = new Map();
|
|
286
|
-
for (const e of s
|
|
281
|
+
for (const e of toEvents(s)) {
|
|
287
282
|
if (e.runId !== s.runId || e.type !== "model_call")
|
|
288
283
|
continue;
|
|
289
|
-
|
|
290
|
-
if (out.has(p.step))
|
|
284
|
+
if (out.has(e.payload.step))
|
|
291
285
|
continue;
|
|
292
|
-
out.set(
|
|
286
|
+
out.set(e.payload.step, e.payload.request.absorbedUpToSeq);
|
|
293
287
|
}
|
|
294
288
|
return out;
|
|
295
289
|
}
|
|
@@ -668,6 +662,5 @@ export async function replayRun(d, s, candidate, evalRunId, signal) {
|
|
|
668
662
|
outcome: outcome.kind,
|
|
669
663
|
...summary,
|
|
670
664
|
unmatched: pipeline.unmatched(),
|
|
671
|
-
...(pipeline.legacyMatches() > 0 && { legacyKeyMatch: true }),
|
|
672
665
|
};
|
|
673
666
|
}
|
|
@@ -61,7 +61,9 @@ export interface SampleInput {
|
|
|
61
61
|
/** 用例标题:触发消息文本的前 80 个字符(按码点)。 */
|
|
62
62
|
export declare const CASE_TITLE_CHARS = 80;
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
64
|
+
* The text of the snapshot run's trigger message (the latest `user_message` before its
|
|
65
|
+
* `run_started`, never a template skill's invocation written after a sub-agent's task),
|
|
66
|
+
* whitespace collapsed, first 80 characters.
|
|
65
67
|
*/
|
|
66
68
|
export declare function caseTitle(s: CaseSnapshot): string;
|
|
67
69
|
/**
|
|
@@ -118,10 +120,20 @@ export declare class EvalSetsService {
|
|
|
118
120
|
*/
|
|
119
121
|
private insertCase;
|
|
120
122
|
/**
|
|
121
|
-
*
|
|
122
|
-
* `
|
|
123
|
-
*
|
|
124
|
-
|
|
123
|
+
* The admission checks of a case, in one place (the route and the Platform operation's precheck
|
|
124
|
+
* both call it); throws the `ApiError` the route gives. Writes nothing. Capacity is checked before
|
|
125
|
+
* the snapshot is taken (it can be large) and again under the lock when the case is written.
|
|
126
|
+
*/
|
|
127
|
+
checkAddCase(orgId: string, setId: string, input: {
|
|
128
|
+
conversationId: string;
|
|
129
|
+
runId: string;
|
|
130
|
+
}): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Adds a run as a case. Admission is `checkAddCase` (conversation not in the org or an eval
|
|
133
|
+
* conversation -> `conversation.not_found`; the conversation's agent is not the set's ->
|
|
134
|
+
* `eval.agent_mismatch`; manual compaction run -> `eval.compact_not_replayable`; already in the
|
|
135
|
+
* set -> `eval.case_exists`; set full -> `eval.too_many_cases`; run not finished / snapshot too
|
|
136
|
+
* large -> `eval.run_not_finished` / `eval.case_too_large` (`takeSnapshot`)).
|
|
125
137
|
*/
|
|
126
138
|
addCase(orgId: string, actor: string, setId: string, input: {
|
|
127
139
|
conversationId: string;
|
|
@@ -44,7 +44,9 @@ const STATUSES = {
|
|
|
44
44
|
any: ["completed", "failed", "aborted"],
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* The text of the snapshot run's trigger message (the latest `user_message` before its
|
|
48
|
+
* `run_started`, never a template skill's invocation written after a sub-agent's task),
|
|
49
|
+
* whitespace collapsed, first 80 characters.
|
|
48
50
|
*/
|
|
49
51
|
export function caseTitle(s) {
|
|
50
52
|
const started = s.events.find((e) => e.type === "run_started" && e.runId === s.runId);
|
|
@@ -56,6 +58,10 @@ export function caseTitle(s) {
|
|
|
56
58
|
if (e.type !== "user_message")
|
|
57
59
|
continue;
|
|
58
60
|
const payload = e.payload;
|
|
61
|
+
// a template sub-agent's skill (or the notice that it could not be read), written after its
|
|
62
|
+
// task: the task titles the case
|
|
63
|
+
if (payload.skill?.template || payload.templateSkillNotice !== undefined)
|
|
64
|
+
continue;
|
|
59
65
|
// a skill invocation: what the person typed, never the rendered skill (content[0])
|
|
60
66
|
if (payload.skill !== undefined) {
|
|
61
67
|
text = typedInvocation(payload.skill);
|
|
@@ -402,12 +408,11 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
|
|
|
402
408
|
return this.insertCaseIn(orgId, actor, setId, snapshot, extra, { max, json, plans, base });
|
|
403
409
|
}
|
|
404
410
|
/**
|
|
405
|
-
*
|
|
406
|
-
* `
|
|
407
|
-
*
|
|
408
|
-
* `eval.run_not_finished` / `eval.case_too_large`(`takeSnapshot`)。
|
|
411
|
+
* The admission checks of a case, in one place (the route and the Platform operation's precheck
|
|
412
|
+
* both call it); throws the `ApiError` the route gives. Writes nothing. Capacity is checked before
|
|
413
|
+
* the snapshot is taken (it can be large) and again under the lock when the case is written.
|
|
409
414
|
*/
|
|
410
|
-
async
|
|
415
|
+
async checkAddCase(orgId, setId, input) {
|
|
411
416
|
const set = await this.liveSet(orgId, setId);
|
|
412
417
|
const conv = await this.db
|
|
413
418
|
.selectFrom("conversations")
|
|
@@ -423,15 +428,18 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
|
|
|
423
428
|
if (conv.agent_id !== set.agent_id) {
|
|
424
429
|
throw new ApiError("eval.agent_mismatch", "The run belongs to a different agent");
|
|
425
430
|
}
|
|
426
|
-
// a manual compaction run has no model step to replay (context compaction spec §4.7): it would
|
|
427
|
-
// take a set slot and never produce a result, so it is refused with a clear code
|
|
428
431
|
const run = await this.db
|
|
429
432
|
.selectFrom("runs")
|
|
430
|
-
.select("compact")
|
|
433
|
+
.select(["status", "compact"])
|
|
431
434
|
.where("id", "=", input.runId)
|
|
432
435
|
.where("conversation_id", "=", input.conversationId)
|
|
433
436
|
.executeTakeFirst();
|
|
434
|
-
if (run
|
|
437
|
+
if (run === undefined) {
|
|
438
|
+
throw new ApiError("conversation.not_found", "Conversation or run not found");
|
|
439
|
+
}
|
|
440
|
+
// a manual compaction run has no model step to replay (context compaction spec §4.7): it would
|
|
441
|
+
// take a set slot and never produce a result, so it is refused with a clear code
|
|
442
|
+
if (run.compact) {
|
|
435
443
|
throw new ApiError("eval.compact_not_replayable", "A manual compaction run has no model step to replay, so it cannot be an eval case");
|
|
436
444
|
}
|
|
437
445
|
const exists = await this.db
|
|
@@ -442,10 +450,23 @@ let EvalSetsService = EvalSetsService_1 = class EvalSetsService {
|
|
|
442
450
|
.executeTakeFirst();
|
|
443
451
|
if (exists)
|
|
444
452
|
throw caseExists();
|
|
445
|
-
|
|
446
|
-
|
|
453
|
+
if (run.status === "running" || run.status === "queued") {
|
|
454
|
+
throw new ApiError("eval.run_not_finished", "The run has not finished yet");
|
|
455
|
+
}
|
|
456
|
+
const { maxCasesPerSet } = this.config.get().evals;
|
|
447
457
|
if ((await this.caseCount(this.db, setId)) >= maxCasesPerSet)
|
|
448
458
|
throw tooMany(maxCasesPerSet);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Adds a run as a case. Admission is `checkAddCase` (conversation not in the org or an eval
|
|
462
|
+
* conversation -> `conversation.not_found`; the conversation's agent is not the set's ->
|
|
463
|
+
* `eval.agent_mismatch`; manual compaction run -> `eval.compact_not_replayable`; already in the
|
|
464
|
+
* set -> `eval.case_exists`; set full -> `eval.too_many_cases`; run not finished / snapshot too
|
|
465
|
+
* large -> `eval.run_not_finished` / `eval.case_too_large` (`takeSnapshot`)).
|
|
466
|
+
*/
|
|
467
|
+
async addCase(orgId, actor, setId, input, actorTokenId, auditDetail) {
|
|
468
|
+
await this.checkAddCase(orgId, setId, input);
|
|
469
|
+
const { maxCasesPerSet, maxCaseBytes } = this.config.get().evals;
|
|
449
470
|
const snapshot = await takeSnapshot(this.db, orgId, input.conversationId, input.runId, maxCaseBytes);
|
|
450
471
|
const r = await this.insertCase(orgId, actor, setId, snapshot, {
|
|
451
472
|
sampled: false,
|
package/dist/evals/snapshot.d.ts
CHANGED
|
@@ -66,8 +66,7 @@ export interface CaseSnapshot {
|
|
|
66
66
|
export declare function takeSnapshot(db: KernelSchemaDb, orgId: string, conversationId: string, runId: string, maxBytes: number): Promise<CaseSnapshot>;
|
|
67
67
|
/**
|
|
68
68
|
* Reads a stored snapshot (`eval_cases.snapshot`): each version's definition goes through
|
|
69
|
-
* `normalizeStoredDefinition` (
|
|
70
|
-
* Other fields as they are.
|
|
69
|
+
* `normalizeStoredDefinition` (missing turned-off lists read as empty). Other fields as they are.
|
|
71
70
|
*/
|
|
72
71
|
export declare function readSnapshot(raw: unknown): CaseSnapshot;
|
|
73
72
|
/** 快照事件还原为日志事件(`createdAt` 转回 Date)。 */
|
package/dist/evals/snapshot.js
CHANGED
|
@@ -84,7 +84,7 @@ export async function takeSnapshot(db, orgId, conversationId, runId, maxBytes) {
|
|
|
84
84
|
}
|
|
85
85
|
else if (e.type === "model_call") {
|
|
86
86
|
const req = e.payload.request;
|
|
87
|
-
for (const t of [...
|
|
87
|
+
for (const t of [...req.tools, ...(req.catalog ?? [])])
|
|
88
88
|
hashes.add(t.specHash);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -97,7 +97,7 @@ export async function takeSnapshot(db, orgId, conversationId, runId, maxBytes) {
|
|
|
97
97
|
.orderBy("version")
|
|
98
98
|
.execute();
|
|
99
99
|
for (const r of defRows) {
|
|
100
|
-
definitions[String(r.version)] =
|
|
100
|
+
definitions[String(r.version)] = normalizeStoredDefinition(r.definition);
|
|
101
101
|
}
|
|
102
102
|
const toolSpecs = {};
|
|
103
103
|
if (hashes.size > 0) {
|
|
@@ -151,28 +151,15 @@ export async function takeSnapshot(db, orgId, conversationId, runId, maxBytes) {
|
|
|
151
151
|
throw tooLarge();
|
|
152
152
|
return snapshot;
|
|
153
153
|
}
|
|
154
|
-
/**
|
|
155
|
-
* A definition as a snapshot holds it: normalized (`normalizeStoredDefinition`), and one from
|
|
156
|
-
* before tools were on by default keeps its enabled list next to it: rc tool keys are read by its
|
|
157
|
-
* extension refs (`legacyScopeOf`); the runtime ignores it (tools default-on spec §2).
|
|
158
|
-
*/
|
|
159
|
-
function snapshotDefinition(d) {
|
|
160
|
-
const enabled = d?.tools;
|
|
161
|
-
return {
|
|
162
|
-
...normalizeStoredDefinition(d),
|
|
163
|
-
...(Array.isArray(enabled) && { tools: enabled }),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
154
|
/**
|
|
167
155
|
* Reads a stored snapshot (`eval_cases.snapshot`): each version's definition goes through
|
|
168
|
-
* `normalizeStoredDefinition` (
|
|
169
|
-
* Other fields as they are.
|
|
156
|
+
* `normalizeStoredDefinition` (missing turned-off lists read as empty). Other fields as they are.
|
|
170
157
|
*/
|
|
171
158
|
export function readSnapshot(raw) {
|
|
172
159
|
const s = raw;
|
|
173
160
|
const definitions = {};
|
|
174
161
|
for (const [v, d] of Object.entries(s.definitions ?? {})) {
|
|
175
|
-
definitions[v] =
|
|
162
|
+
definitions[v] = normalizeStoredDefinition(d);
|
|
176
163
|
}
|
|
177
164
|
return {
|
|
178
165
|
...s,
|
|
@@ -3,6 +3,7 @@ import { SuperAdminLock } from "../identity/super-admin.js";
|
|
|
3
3
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
6
7
|
import type { KernelLogger } from "../log.js";
|
|
7
8
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
8
9
|
import { ExtensionAdmin, type PublishBus } from "./admin-view.js";
|
|
@@ -73,6 +74,8 @@ export declare class ExtensionAdminOps {
|
|
|
73
74
|
private readonly log;
|
|
74
75
|
/** One enabled provider per single-provider extension point (checked in the enable). */
|
|
75
76
|
private readonly singleProvider;
|
|
77
|
+
/** The plugin scope sync a deploy owes (`oweDeployedExtensionSync`). */
|
|
78
|
+
private readonly outbox;
|
|
76
79
|
constructor(kdb: KernelDb, txHost: TransactionHost,
|
|
77
80
|
/** The super admin lock (identity/super-admin.ts): joins the transaction. */
|
|
78
81
|
adminLock: SuperAdminLock,
|
|
@@ -97,7 +100,9 @@ export declare class ExtensionAdminOps {
|
|
|
97
100
|
*/
|
|
98
101
|
lifecycle: ExtensionLifecycle, log: KernelLogger,
|
|
99
102
|
/** One enabled provider per single-provider extension point (checked in the enable). */
|
|
100
|
-
singleProvider: SingleProviderGuard
|
|
103
|
+
singleProvider: SingleProviderGuard,
|
|
104
|
+
/** The plugin scope sync a deploy owes (`oweDeployedExtensionSync`). */
|
|
105
|
+
outbox: Pick<OutboxService, "add">);
|
|
101
106
|
private get db();
|
|
102
107
|
/**
|
|
103
108
|
* New install or version change (upgrade / downgrade): the install record points at package
|