@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
package/dist/ctx/secrets.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, createHash, hkdfSync, randomBytes } from "node:crypto";
|
|
2
|
+
import { sql } from "kysely";
|
|
2
3
|
import { assertNamespace } from "./namespace.js";
|
|
3
4
|
const IV_LEN = 12;
|
|
4
5
|
const TAG_LEN = 16;
|
|
@@ -142,38 +143,104 @@ export function createSecrets(db, keyring, namespace) {
|
|
|
142
143
|
},
|
|
143
144
|
};
|
|
144
145
|
}
|
|
146
|
+
/** Rows rewrapped per transaction by default. */
|
|
147
|
+
export const REWRAP_BATCH_SIZE = 500;
|
|
148
|
+
/** The AAD binding a sealed initial password to its account (a row moved to another one fails). */
|
|
149
|
+
export const initialPasswordAad = (accountId) => `capybara:initial-password:${accountId}`;
|
|
150
|
+
const MASTER_KEYED = [
|
|
151
|
+
{
|
|
152
|
+
table: "org_data_keys",
|
|
153
|
+
idColumn: "org_id",
|
|
154
|
+
dataColumn: "wrapped_key",
|
|
155
|
+
aad: dekAad,
|
|
156
|
+
hasExpiresAt: false,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
table: "account_initial_passwords",
|
|
160
|
+
idColumn: "account_id",
|
|
161
|
+
dataColumn: "ciphertext",
|
|
162
|
+
aad: initialPasswordAad,
|
|
163
|
+
hasExpiresAt: true,
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
function staleRows(db, t, keyring) {
|
|
167
|
+
let q = db
|
|
168
|
+
.withSchema("capybara")
|
|
169
|
+
.selectFrom(t.table)
|
|
170
|
+
.where("master_key_id", "!=", keyring.currentId);
|
|
171
|
+
if (t.hasExpiresAt)
|
|
172
|
+
q = q.where("expires_at", ">", sql `now()`);
|
|
173
|
+
return q;
|
|
174
|
+
}
|
|
175
|
+
function assertKnown(t, keyring, rows) {
|
|
176
|
+
const unknown = rows.filter((r) => !keyring.has(r.mk));
|
|
177
|
+
if (unknown.length === 0)
|
|
178
|
+
return;
|
|
179
|
+
const shown = unknown.slice(0, 20).map((r) => `${r.id}(master_key_id=${r.mk})`);
|
|
180
|
+
throw new Error(`secrets: master key not in keyring for ${t.table}.${t.idColumn}: ${shown.join(", ")}`);
|
|
181
|
+
}
|
|
145
182
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
183
|
+
* Rewraps everything sealed with a master key other than the keyring's current one (org data keys
|
|
184
|
+
* and unexpired initial passwords) with the current key, `batchSize` rows per transaction, until
|
|
185
|
+
* none is left. Checks first that the keyring holds every master key in use and throws (naming row
|
|
186
|
+
* ids and key ids, never key material) before writing anything when it does not. Idempotent: a
|
|
187
|
+
* second run finds nothing; concurrent runs lock the same rows and skip the ones already done.
|
|
148
188
|
*/
|
|
149
|
-
export async function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
.
|
|
158
|
-
.
|
|
189
|
+
export async function rewrapToCurrentMasterKey(handles, keyring, opts = {}) {
|
|
190
|
+
const batchSize = opts.batchSize ?? REWRAP_BATCH_SIZE;
|
|
191
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
192
|
+
throw new RangeError("rewrap batch size must be a positive integer");
|
|
193
|
+
}
|
|
194
|
+
const db = () => handles.db.db;
|
|
195
|
+
for (const t of MASTER_KEYED) {
|
|
196
|
+
const rows = await staleRows(db(), t, keyring)
|
|
197
|
+
.select([`${t.idColumn} as id`, "master_key_id as mk"])
|
|
198
|
+
.orderBy(t.idColumn)
|
|
159
199
|
.execute();
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
assertKnown(t, keyring, rows);
|
|
201
|
+
}
|
|
202
|
+
const counts = new Map();
|
|
203
|
+
for (const t of MASTER_KEYED) {
|
|
204
|
+
let total = 0;
|
|
205
|
+
for (;;) {
|
|
206
|
+
const done = await handles.txHost.run(async () => {
|
|
207
|
+
const trx = db();
|
|
208
|
+
const rows = await staleRows(trx, t, keyring)
|
|
209
|
+
.select([`${t.idColumn} as id`, "master_key_id as mk", `${t.dataColumn} as data`])
|
|
210
|
+
.orderBy(t.idColumn)
|
|
211
|
+
.limit(batchSize)
|
|
212
|
+
.forUpdate()
|
|
213
|
+
.execute();
|
|
214
|
+
// a row written meanwhile by a replica that runs an older config
|
|
215
|
+
assertKnown(t, keyring, rows);
|
|
216
|
+
for (const r of rows) {
|
|
217
|
+
let plain;
|
|
218
|
+
try {
|
|
219
|
+
plain = keyring.unwrap(r.mk, Buffer.from(r.data), t.aad(r.id));
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
const why = e instanceof Error ? e.message : String(e);
|
|
223
|
+
throw new Error(`secrets: cannot unwrap ${t.table}.${t.idColumn}=${r.id}: ${why}`);
|
|
224
|
+
}
|
|
225
|
+
const w = keyring.wrap(plain, t.aad(r.id));
|
|
226
|
+
plain.fill(0);
|
|
227
|
+
await trx
|
|
228
|
+
.withSchema("capybara")
|
|
229
|
+
.updateTable(t.table)
|
|
230
|
+
.set({ [t.dataColumn]: w.data, master_key_id: w.masterKeyId })
|
|
231
|
+
.where(t.idColumn, "=", r.id)
|
|
232
|
+
.execute();
|
|
233
|
+
}
|
|
234
|
+
return rows.length;
|
|
235
|
+
});
|
|
236
|
+
total += done;
|
|
237
|
+
if (done === 0)
|
|
238
|
+
break;
|
|
176
239
|
}
|
|
177
|
-
|
|
178
|
-
}
|
|
240
|
+
counts.set(t.table, total);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
dataKeys: counts.get("org_data_keys") ?? 0,
|
|
244
|
+
initialPasswords: counts.get("account_initial_passwords") ?? 0,
|
|
245
|
+
};
|
|
179
246
|
}
|
|
@@ -1294,8 +1294,16 @@ export interface ScheduledTaskGrantsTable {
|
|
|
1294
1294
|
connector_id: string | null;
|
|
1295
1295
|
created_at: Ts;
|
|
1296
1296
|
}
|
|
1297
|
+
/** 0001: the per-org data key, wrapped by the master key (ctx/secrets.ts reads it untyped). */
|
|
1298
|
+
export interface OrgDataKeysTable {
|
|
1299
|
+
org_id: string;
|
|
1300
|
+
wrapped_key: Buffer;
|
|
1301
|
+
master_key_id: string;
|
|
1302
|
+
created_at: Ts;
|
|
1303
|
+
}
|
|
1297
1304
|
export interface KernelDatabase {
|
|
1298
1305
|
accounts: AccountsTable;
|
|
1306
|
+
org_data_keys: OrgDataKeysTable;
|
|
1299
1307
|
account_initial_passwords: AccountInitialPasswordsTable;
|
|
1300
1308
|
identities: IdentitiesTable;
|
|
1301
1309
|
local_passwords: LocalPasswordsTable;
|
|
@@ -1531,7 +1539,7 @@ export interface CatalogItemsTable {
|
|
|
1531
1539
|
builtin: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1532
1540
|
/** 0075: switched off for every org by the super admin. */
|
|
1533
1541
|
disabled: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1534
|
-
/** 0075:
|
|
1542
|
+
/** 0075: unused since design review 2026-11-16; dropped by a later contract migration. */
|
|
1535
1543
|
scope_version: ColumnType<number, number | undefined, number>;
|
|
1536
1544
|
/** 0077: orgs outside a `named` item's list see it as requestable (never usable). */
|
|
1537
1545
|
shown_to_others: ColumnType<boolean, boolean | undefined, boolean>;
|
|
@@ -1572,6 +1580,7 @@ interface PlatformScopeColumns {
|
|
|
1572
1580
|
scope: Dflt<ComponentScope>;
|
|
1573
1581
|
disabled: Dflt<boolean>;
|
|
1574
1582
|
shown_to_others: Dflt<boolean>;
|
|
1583
|
+
/** Unused since design review 2026-11-16; dropped by a later contract migration. */
|
|
1575
1584
|
scope_version: Dflt<number>;
|
|
1576
1585
|
}
|
|
1577
1586
|
/** 0081: a skill owned by the deployment (ruling A2). */
|
|
@@ -1894,20 +1903,22 @@ export interface CatalogOrgGrantsTable {
|
|
|
1894
1903
|
granted_by: string | null;
|
|
1895
1904
|
granted_at: Generated<Date>;
|
|
1896
1905
|
}
|
|
1897
|
-
/**
|
|
1906
|
+
/** 0049 / 0138: the states of a plugin install (`LIVE_INSTALL_STATUSES` are the live ones). */
|
|
1907
|
+
export type PluginInstallStatus = "installing" | "installed" | "failed" | "uninstalling";
|
|
1908
|
+
/** 0037: a plugin's install in an org. */
|
|
1898
1909
|
export interface PluginInstallsTable {
|
|
1899
1910
|
id: string;
|
|
1900
1911
|
org_id: string;
|
|
1901
1912
|
item_id: string;
|
|
1902
1913
|
version: string;
|
|
1903
|
-
/** 0049
|
|
1904
|
-
status:
|
|
1914
|
+
/** 0138 dropped 0049's `upgrading` (no per-org upgrade since ruling F2). */
|
|
1915
|
+
status: PluginInstallStatus;
|
|
1905
1916
|
installed_by: string | null;
|
|
1906
1917
|
installed_at: Generated<Date>;
|
|
1907
1918
|
error: ColumnType<unknown, string | null | undefined, string | null>;
|
|
1908
1919
|
/**
|
|
1909
|
-
* 0049: the journal of
|
|
1910
|
-
*
|
|
1920
|
+
* 0049: the journal of a per-org upgrade. Unused since 0138 (no code reads or writes it, every
|
|
1921
|
+
* row null); kept for the replicas of the previous release, dropped by a later migration.
|
|
1911
1922
|
*/
|
|
1912
1923
|
upgrade: ColumnType<unknown, string | null | undefined, string | null>;
|
|
1913
1924
|
}
|
package/dist/errors.d.ts
CHANGED
|
@@ -61,7 +61,6 @@ export declare const ERROR_CODES: {
|
|
|
61
61
|
readonly "extension.has_dependents": 409;
|
|
62
62
|
readonly "extension.not_enabled": 409;
|
|
63
63
|
readonly "extension.package_invalid": 400;
|
|
64
|
-
readonly "extension.legacy_format": 422;
|
|
65
64
|
readonly "extension.no_extension": 400;
|
|
66
65
|
readonly "extension.package_too_large": 413;
|
|
67
66
|
readonly "extension.config_declared": 409;
|
|
@@ -89,7 +88,6 @@ export declare const ERROR_CODES: {
|
|
|
89
88
|
readonly "bootstrap.download_failed": 502;
|
|
90
89
|
readonly "bootstrap.missing_file": 500;
|
|
91
90
|
readonly "catalog.invalid_manifest": 422;
|
|
92
|
-
readonly "catalog.legacy_format": 422;
|
|
93
91
|
readonly "catalog.no_extension": 409;
|
|
94
92
|
readonly "catalog.dependency_unresolved": 409;
|
|
95
93
|
readonly "catalog.dependency_disabled": 409;
|
|
@@ -303,6 +301,11 @@ export declare const ERROR_CODES: {
|
|
|
303
301
|
readonly "connector.resources_disabled": 409;
|
|
304
302
|
/** Per-member tool policies on a connector with one org credential (decision 2026-11-09). */
|
|
305
303
|
readonly "connector.not_personal": 409;
|
|
304
|
+
/**
|
|
305
|
+
* Loosening a connector's default git push policy through the Platform tool or an API token:
|
|
306
|
+
* only a person in a session widens it.
|
|
307
|
+
*/
|
|
308
|
+
readonly "connector.git_push_widen_not_allowed": 400;
|
|
306
309
|
readonly "approval.not_found": 404;
|
|
307
310
|
readonly "approval.already_decided": 409;
|
|
308
311
|
readonly "approval.scope_not_allowed": 409;
|
package/dist/errors.js
CHANGED
|
@@ -61,7 +61,6 @@ export const ERROR_CODES = {
|
|
|
61
61
|
"extension.has_dependents": 409,
|
|
62
62
|
"extension.not_enabled": 409,
|
|
63
63
|
"extension.package_invalid": 400,
|
|
64
|
-
"extension.legacy_format": 422,
|
|
65
64
|
"extension.no_extension": 400,
|
|
66
65
|
"extension.package_too_large": 413,
|
|
67
66
|
"extension.config_declared": 409,
|
|
@@ -89,7 +88,6 @@ export const ERROR_CODES = {
|
|
|
89
88
|
"bootstrap.download_failed": 502,
|
|
90
89
|
"bootstrap.missing_file": 500,
|
|
91
90
|
"catalog.invalid_manifest": 422,
|
|
92
|
-
"catalog.legacy_format": 422,
|
|
93
91
|
"catalog.no_extension": 409,
|
|
94
92
|
"catalog.dependency_unresolved": 409,
|
|
95
93
|
"catalog.dependency_disabled": 409,
|
|
@@ -303,6 +301,11 @@ export const ERROR_CODES = {
|
|
|
303
301
|
"connector.resources_disabled": 409,
|
|
304
302
|
/** Per-member tool policies on a connector with one org credential (decision 2026-11-09). */
|
|
305
303
|
"connector.not_personal": 409,
|
|
304
|
+
/**
|
|
305
|
+
* Loosening a connector's default git push policy through the Platform tool or an API token:
|
|
306
|
+
* only a person in a session widens it.
|
|
307
|
+
*/
|
|
308
|
+
"connector.git_push_widen_not_allowed": 400,
|
|
306
309
|
"approval.not_found": 404,
|
|
307
310
|
"approval.already_decided": 409,
|
|
308
311
|
"approval.scope_not_allowed": 409,
|
|
@@ -13,17 +13,10 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
13
13
|
* - `system_hash` / `tools_changed`(只在基线判定):system 指纹、工具序列(tools 与 catalog)与记录不同;
|
|
14
14
|
* - `tool_spec_missing`:快照里缺某个工具定义(从请求里去掉);
|
|
15
15
|
* - `definition_missing`:快照里缺该 agent 版本的定义(用空指令);
|
|
16
|
-
* - `pinned_changed` (phase B, never for a baseline, not with `definition_missing`): the
|
|
17
|
-
* `skills_catalog` snapshot in effect at the call pinned skills (`pinned` non-empty). No candidate
|
|
18
|
-
* can pin any more (skills default-on spec §9), so any candidate differs from such a call; the
|
|
19
|
-
* request still renders the recorded pinned bodies (Decision 1);
|
|
20
16
|
* - `subagent_changed` (phase C, never for a baseline): a sub-agent's (child) case with a candidate
|
|
21
17
|
* whose effective definition differs from the one frozen in its `subagent_started` (see
|
|
22
18
|
* {@link subagentChanged}); the request still renders the logged definition and preamble. A child
|
|
23
|
-
* case never consults `definitions` (no `definition_missing`)
|
|
24
|
-
* logged child definition that pinned counts as `subagent_changed`);
|
|
25
|
-
* - `legacy_event`:记录缺 `tools` / `params` / `absorbedUpToSeq` / `maxOutputTokens`,或还原出媒体而记录里没有
|
|
26
|
-
* `media` / `mediaBudgetBytes`(较早的事件);
|
|
19
|
+
* case never consults `definitions` (no `definition_missing`);
|
|
27
20
|
* - `params_changed`:没给候选参数时,记录的参数按所用模型的声明清洗后有键被丢弃或值变了(换了模型或模型声明变了);
|
|
28
21
|
* - `media_missing`:某附件记录里不是「不再可用」,还原时却取不到;
|
|
29
22
|
* - `media_changed`(只在基线判定):其余任何媒体结果与记录不同(按附件 id 比 outcome 与 etag:预算省略、
|
|
@@ -34,13 +27,8 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
34
27
|
*/
|
|
35
28
|
/** 还原结果与原请求不一致的原因。 */
|
|
36
29
|
export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing" | "definition_missing"
|
|
37
|
-
/**
|
|
38
|
-
* The call rendered pinned skills (phase B), which no candidate has any more (skills default-on
|
|
39
|
-
* spec §9).
|
|
40
|
-
*/
|
|
41
|
-
| "pinned_changed"
|
|
42
30
|
/** A child case's candidate has another effective definition than the logged one (phase C). */
|
|
43
|
-
| "subagent_changed" | "
|
|
31
|
+
| "subagent_changed" | "params_changed"
|
|
44
32
|
/**
|
|
45
33
|
* UI refresh B: a non-baseline reconstruction whose run used a person's mid-conversation model
|
|
46
34
|
* switch (`model_switched`) and whose candidate model (`modelRef`) replaces it.
|
|
@@ -66,7 +54,7 @@ export interface ReconstructOptions {
|
|
|
66
54
|
/** 附件行信息与字节(调用方按 {@link snapshotMediaRefs} 取);缺省表示都取不到。 */
|
|
67
55
|
mediaInfo?: ReadonlyMap<string, MediaInfo>;
|
|
68
56
|
media?: ReadonlyMap<string, MediaBytes | null>;
|
|
69
|
-
/**
|
|
57
|
+
/** The request's media byte budget; defaults to the recorded `mediaBudgetBytes` (recorded only when the request had media). */
|
|
70
58
|
mediaBudgetBytes?: number;
|
|
71
59
|
/** The candidate's model (a non-baseline reconstruction): checked against the run's switch. */
|
|
72
60
|
modelRef?: ModelRef;
|
|
@@ -116,8 +104,7 @@ export interface SubagentTemplateRef {
|
|
|
116
104
|
* Does a candidate change what a sub-agent (child) case would run (`subagent_changed`, spec
|
|
117
105
|
* §15.1)? Pure, from the snapshot alone, comparing the model-visible parts of the effective
|
|
118
106
|
* definition (instructions, turned-off skills, tools) with the logged one (`logged`, from its
|
|
119
|
-
* `subagent_started`).
|
|
120
|
-
* differs from every candidate: none pins any more (skills default-on spec §9).
|
|
107
|
+
* `subagent_started`).
|
|
121
108
|
* - the same agent version (`sameVersion`): the candidate is the logged definition with
|
|
122
109
|
* overrides (instructions, model, params), compared field by field;
|
|
123
110
|
* - another version of the case's agent: for an org agent child (`source: "agent"`) that agent's
|
|
@@ -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<{
|