@capybara-hq/kernel 0.1.0-rc.35 → 0.1.0-rc.37
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 -3
- package/dist/admin/admin.module.js +6 -6
- 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/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.module.js +3 -0
- 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 +8 -19
- package/dist/agents/readiness.controller.js +11 -25
- package/dist/agents/readiness.service.d.ts +42 -0
- package/dist/agents/readiness.service.js +78 -0
- 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 +53 -47
- package/dist/config/schema.js +190 -40
- 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/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.js +1 -2
- package/dist/ctx/secrets.d.ts +24 -7
- package/dist/ctx/secrets.js +97 -30
- package/dist/db/kernel-schema.d.ts +17 -6
- package/dist/errors.d.ts +5 -2
- package/dist/errors.js +5 -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/host.d.ts +2 -3
- package/dist/extensions/host.js +1 -5
- 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 +2 -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/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/orgs/orgs.module.d.ts +2 -2
- package/dist/orgs/orgs.module.js +2 -2
- 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 +3 -7
- package/dist/overrides.js +2 -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.d.ts +3 -3
- package/dist/platform/ops/agents.ops.js +7 -10
- 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 +5 -3
- package/dist/platform/ops/orgs.ops.js +19 -4
- package/dist/platform/ops/outbox.ops.js +5 -5
- package/dist/roles/worker-role.d.ts +2 -3
- package/dist/roles/worker-role.js +3 -13
- 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 +1 -0
- 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.js +4 -3
- 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/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/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/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 +56 -0
- package/dist/tools/drift.d.ts +1 -1
- package/dist/tools/drift.js +1 -1
- 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 +16 -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/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
|
@@ -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
|
|
@@ -11,6 +11,7 @@ import { SDK_VERSION } from "@capybara-hq/plugin-sdk";
|
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import semver from "semver";
|
|
14
|
+
import { oweDeployedExtensionSync } from "../catalog/scope-jobs.js";
|
|
14
15
|
import { pluginSchemaName } from "../ctx/create-ctx.js";
|
|
15
16
|
import { ApiError } from "../errors.js";
|
|
16
17
|
import { audit } from "../identity/audit.js";
|
|
@@ -20,6 +21,7 @@ import { afterCommit } from "../infra/database/after-commit.js";
|
|
|
20
21
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
21
22
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
22
23
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
24
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
23
25
|
import { KERNEL_BUS, KERNEL_LOGGER } from "../infra/tokens.js";
|
|
24
26
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
25
27
|
import { ExtensionAdmin } from "./admin-view.js";
|
|
@@ -44,6 +46,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
44
46
|
lifecycle;
|
|
45
47
|
log;
|
|
46
48
|
singleProvider;
|
|
49
|
+
outbox;
|
|
47
50
|
constructor(kdb, txHost,
|
|
48
51
|
/** The super admin lock (identity/super-admin.ts): joins the transaction. */
|
|
49
52
|
adminLock,
|
|
@@ -68,7 +71,9 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
68
71
|
*/
|
|
69
72
|
lifecycle, log,
|
|
70
73
|
/** One enabled provider per single-provider extension point (checked in the enable). */
|
|
71
|
-
singleProvider
|
|
74
|
+
singleProvider,
|
|
75
|
+
/** The plugin scope sync a deploy owes (`oweDeployedExtensionSync`). */
|
|
76
|
+
outbox) {
|
|
72
77
|
this.kdb = kdb;
|
|
73
78
|
this.txHost = txHost;
|
|
74
79
|
this.adminLock = adminLock;
|
|
@@ -82,6 +87,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
82
87
|
this.lifecycle = lifecycle;
|
|
83
88
|
this.log = log;
|
|
84
89
|
this.singleProvider = singleProvider;
|
|
90
|
+
this.outbox = outbox;
|
|
85
91
|
}
|
|
86
92
|
get db() {
|
|
87
93
|
return this.kdb.db;
|
|
@@ -136,8 +142,7 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
136
142
|
throw new ApiError("extension.name_mismatch", `Package ${sha256} contains extension ${pkg.name}, not ${name}`);
|
|
137
143
|
}
|
|
138
144
|
// The downgrade check needs the target package's migration files: read and parse the package
|
|
139
|
-
// outside the transaction (inside it only _migrations is compared).
|
|
140
|
-
// pre-0.1.0 format -> extension.legacy_format.
|
|
145
|
+
// outside the transaction (inside it only _migrations is compared).
|
|
141
146
|
const target = await readExtensionPackage(await this.blobs.get(sha256), {
|
|
142
147
|
maxBytes: this.config.get().packages.maxBytes,
|
|
143
148
|
hostSdkVersion: SDK_VERSION,
|
|
@@ -282,6 +287,9 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
282
287
|
afterCommit(() => this.notify(name));
|
|
283
288
|
if (leftDisabled !== undefined)
|
|
284
289
|
return { changed: true, state: "disabled", leftDisabled };
|
|
290
|
+
// A new version of an enabled extension is a deploy: it owes its plugin's scope sync
|
|
291
|
+
if (row?.desired_state === "enabled")
|
|
292
|
+
await oweDeployedExtensionSync(this.outbox, db, name);
|
|
285
293
|
return { changed: true, state: row?.desired_state ?? "disabled" };
|
|
286
294
|
}
|
|
287
295
|
/**
|
|
@@ -393,6 +401,10 @@ let ExtensionAdminOps = class ExtensionAdminOps {
|
|
|
393
401
|
.execute();
|
|
394
402
|
await this.audit(actor, actorTokenId, state === "enabled" ? "extension.enabled" : "extension.disabled", name, row.version, row.sha256, { ...ownerDetail(owner), ...auditDetail });
|
|
395
403
|
afterCommit(() => this.notify(name));
|
|
404
|
+
// The enable is the deploy: it owes its plugin's scope sync, which installs it where its scope
|
|
405
|
+
// wants it on (a replica that has not loaded it yet retries)
|
|
406
|
+
if (state === "enabled")
|
|
407
|
+
await oweDeployedExtensionSync(this.outbox, db, name);
|
|
396
408
|
return { row, changed: true };
|
|
397
409
|
}
|
|
398
410
|
/**
|
|
@@ -503,7 +515,8 @@ ExtensionAdminOps = __decorate([
|
|
|
503
515
|
__param(9, Inject(KERNEL_BUS)),
|
|
504
516
|
__param(10, Inject(ExtensionLifecycle)),
|
|
505
517
|
__param(11, Inject(KERNEL_LOGGER)),
|
|
506
|
-
__param(12, Inject(SingleProviderGuard))
|
|
518
|
+
__param(12, Inject(SingleProviderGuard)),
|
|
519
|
+
__param(13, Inject(OutboxService))
|
|
507
520
|
], ExtensionAdminOps);
|
|
508
521
|
export { ExtensionAdminOps };
|
|
509
522
|
/**
|
|
@@ -2,6 +2,7 @@ import { SuperAdminLock } from "../identity/super-admin.js";
|
|
|
2
2
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
5
6
|
import type { KernelLogger } from "../log.js";
|
|
6
7
|
import { ExtensionApprovals } from "./approvals.js";
|
|
7
8
|
import { ExtensionBlobs } from "./blobs.js";
|
|
@@ -55,6 +56,8 @@ export declare class ExtensionAdmin {
|
|
|
55
56
|
private readonly singleProvider;
|
|
56
57
|
/** The plugins' icons (admin catalog routes). */
|
|
57
58
|
private readonly icons;
|
|
59
|
+
/** The plugin scope sync an approval of an enabled extension owes. */
|
|
60
|
+
private readonly outbox;
|
|
58
61
|
private readonly packageSets;
|
|
59
62
|
constructor(kdb: KernelDb, txHost: TransactionHost,
|
|
60
63
|
/** The super admin lock (identity/super-admin.ts): joins the transaction. */
|
|
@@ -70,7 +73,9 @@ export declare class ExtensionAdmin {
|
|
|
70
73
|
/** Which enabled extension keeps a disabled one from being enabled (`enableBlocked`). */
|
|
71
74
|
singleProvider: SingleProviderGuard,
|
|
72
75
|
/** The plugins' icons (admin catalog routes). */
|
|
73
|
-
icons: PluginIcons
|
|
76
|
+
icons: PluginIcons,
|
|
77
|
+
/** The plugin scope sync an approval of an enabled extension owes. */
|
|
78
|
+
outbox: Pick<OutboxService, "add">);
|
|
74
79
|
private get db();
|
|
75
80
|
/**
|
|
76
81
|
* Every extension (config-declared, then install records, each by name). With `names`, only
|
|
@@ -82,9 +87,7 @@ export declare class ExtensionAdmin {
|
|
|
82
87
|
* A single extension; unknown -> `extension.not_found`; package unreadable ->
|
|
83
88
|
* `extension.package_unavailable`. With `allowUnreadable` an unreadable package returns the same
|
|
84
89
|
* degraded item as {@link list} (status failed, with `error`): used after a write has committed, so
|
|
85
|
-
* an operation that took effect is not reported as failed.
|
|
86
|
-
* a state, not an error: it always returns the item with status `legacy_format` (so the admin can
|
|
87
|
-
* see it and uninstall it).
|
|
90
|
+
* an operation that took effect is not reported as failed.
|
|
88
91
|
*/
|
|
89
92
|
get(name: string, opts?: {
|
|
90
93
|
allowUnreadable?: boolean;
|