@capybara-hq/kernel 0.1.0-rc.5 → 0.1.0-rc.7
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 +27 -3
- package/dist/admin/admin.controller.d.ts +21 -74
- package/dist/admin/admin.controller.js +50 -50
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +16 -6
- package/dist/agents/agents.service.js +75 -19
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +23 -6
- package/dist/agents/models.controller.d.ts +33 -5
- package/dist/agents/models.controller.js +50 -6
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +24 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +13 -4
- package/dist/conversations/conversations.service.js +32 -26
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/ctx/create-ctx.d.ts +15 -1
- package/dist/ctx/create-ctx.js +23 -2
- package/dist/db/kernel-schema.d.ts +44 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +17 -2
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +8 -7
- package/dist/evals/runs.service.js +45 -30
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/evals/step-replay.d.ts +2 -1
- package/dist/evals/step-replay.js +3 -2
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +9 -12
- package/dist/extensions/host.d.ts +39 -12
- package/dist/extensions/host.js +129 -51
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +4 -0
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +14 -0
- package/dist/identity/me.controller.js +39 -1
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/infra/config/kernel-config.service.js +3 -0
- package/dist/infra/events/kernel-events.d.ts +8 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +101 -0
- package/dist/models/enablement.js +264 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +30 -6
- package/dist/models/purposes.js +68 -17
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +68 -831
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +62 -7
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +4 -4
- package/dist/platform/ops/platform.ops.js +23 -24
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +60 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/hook-calls.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -9
- package/dist/runtime/model-call.d.ts +8 -3
- package/dist/runtime/model-call.js +30 -6
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +328 -67
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +6 -1
- package/dist/runtime/run-worker.js +35 -10
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +49 -118
- package/dist/runtime/usage-report-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +152 -84
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +9 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -16,6 +16,25 @@ export interface AccountsTable {
|
|
|
16
16
|
updated_at: Ts;
|
|
17
17
|
/** 0064: the org the account last chose as current; a new session starts in it. */
|
|
18
18
|
last_org_id: ColumnType<string | null, string | null | undefined, string | null>;
|
|
19
|
+
/** 0091: the person's time zone (IANA); null follows the browser (run context spec §3.4). */
|
|
20
|
+
time_zone: ColumnType<string | null, string | null | undefined, string | null>;
|
|
21
|
+
/** 0090: the account must set its own password first (a generated initial password). */
|
|
22
|
+
must_change_password: Generated<boolean>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 0090: a generated initial password sealed for the person who approved the account's creation,
|
|
26
|
+
* read once on the web (Platform tool spec §14.5 item 2).
|
|
27
|
+
*/
|
|
28
|
+
export interface AccountInitialPasswordsTable {
|
|
29
|
+
account_id: string;
|
|
30
|
+
recipient_account_id: string;
|
|
31
|
+
conversation_id: string;
|
|
32
|
+
run_id: string;
|
|
33
|
+
call_id: string;
|
|
34
|
+
master_key_id: string;
|
|
35
|
+
ciphertext: Buffer;
|
|
36
|
+
expires_at: Date | string;
|
|
37
|
+
created_at: Ts;
|
|
19
38
|
}
|
|
20
39
|
export interface IdentitiesTable {
|
|
21
40
|
source: string;
|
|
@@ -1012,8 +1031,31 @@ export interface UsageReportSweepTable {
|
|
|
1012
1031
|
watermark: Ts;
|
|
1013
1032
|
updated_at: ColumnType<Date, Date | string | undefined, Date | string>;
|
|
1014
1033
|
}
|
|
1034
|
+
/** A model disabled on the platform (`org_id` null) or in one org (0089, spec B §5.3). */
|
|
1035
|
+
export interface ModelDisabledTable {
|
|
1036
|
+
org_id: string | null;
|
|
1037
|
+
provider: string;
|
|
1038
|
+
model: string;
|
|
1039
|
+
disabled_by: string | null;
|
|
1040
|
+
disabled_at: Ts;
|
|
1041
|
+
}
|
|
1042
|
+
/** One model call outside a conversation, e.g. an extension's embed call (0089, spec B §5.4). */
|
|
1043
|
+
export interface ModelUsageTable {
|
|
1044
|
+
id: Generated<string>;
|
|
1045
|
+
org_id: string;
|
|
1046
|
+
extension: string;
|
|
1047
|
+
purpose: string;
|
|
1048
|
+
provider: string;
|
|
1049
|
+
model: string;
|
|
1050
|
+
input_tokens: number;
|
|
1051
|
+
occurred_at: Ts;
|
|
1052
|
+
reported_at: TsNullable;
|
|
1053
|
+
/** Set when the row's `usage.report` job gave up after its last attempt (the sweep skips it). */
|
|
1054
|
+
report_failed_at: TsNullable;
|
|
1055
|
+
}
|
|
1015
1056
|
export interface KernelDatabase {
|
|
1016
1057
|
accounts: AccountsTable;
|
|
1058
|
+
account_initial_passwords: AccountInitialPasswordsTable;
|
|
1017
1059
|
identities: IdentitiesTable;
|
|
1018
1060
|
local_passwords: LocalPasswordsTable;
|
|
1019
1061
|
orgs: OrgsTable;
|
|
@@ -1071,6 +1113,8 @@ export interface KernelDatabase {
|
|
|
1071
1113
|
eval_runs: EvalRunsTable;
|
|
1072
1114
|
eval_results: EvalResultsTable;
|
|
1073
1115
|
model_purpose_mappings: ModelPurposeMappingsTable;
|
|
1116
|
+
model_disabled: ModelDisabledTable;
|
|
1117
|
+
model_usage: ModelUsageTable;
|
|
1074
1118
|
extension_packages: ExtensionPackagesTable;
|
|
1075
1119
|
extension_blobs: ExtensionBlobsTable;
|
|
1076
1120
|
extension_installs: ExtensionInstallsTable;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EnvironmentNameBody, EnvironmentParams } from "./dto.js";
|
|
2
|
+
/** The environments routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
3
|
+
export const ENVIRONMENT_ROUTES = [
|
|
4
|
+
{ route: "GET /api/v1/orgs/:orgId/environments" },
|
|
5
|
+
{ route: "POST /api/v1/orgs/:orgId/environments", body: EnvironmentNameBody },
|
|
6
|
+
{ route: "GET /api/v1/orgs/:orgId/environments/:id", params: EnvironmentParams },
|
|
7
|
+
{
|
|
8
|
+
route: "PATCH /api/v1/orgs/:orgId/environments/:id",
|
|
9
|
+
params: EnvironmentParams,
|
|
10
|
+
body: EnvironmentNameBody,
|
|
11
|
+
},
|
|
12
|
+
{ route: "DELETE /api/v1/orgs/:orgId/environments/:id", params: EnvironmentParams },
|
|
13
|
+
{ route: "POST /api/v1/orgs/:orgId/environments/:id/files/reset", params: EnvironmentParams },
|
|
14
|
+
];
|
|
@@ -72,10 +72,22 @@ export declare class EnvironmentsService {
|
|
|
72
72
|
*/
|
|
73
73
|
create(orgId: string, accountId: string, input: {
|
|
74
74
|
name: string;
|
|
75
|
-
}, actorTokenId?: string): Promise<EnvironmentView>;
|
|
75
|
+
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<EnvironmentView>;
|
|
76
76
|
private insert;
|
|
77
|
+
/**
|
|
78
|
+
* The refusals {@link create} would raise, read without locks or writes (a precheck before a
|
|
79
|
+
* confirmation card): no sandbox provider, the person's limit, a name already taken. Throws the
|
|
80
|
+
* same {@link ApiError}s; a race still ends in `create`'s own refusal.
|
|
81
|
+
*/
|
|
82
|
+
checkCreate(orgId: string, accountId: string, name: string): Promise<void>;
|
|
83
|
+
/** How many of the person's conversations work in the environment (read only). */
|
|
84
|
+
boundConversations(orgId: string, accountId: string, id: string): Promise<number>;
|
|
85
|
+
/** The refusals {@link resetFiles} would raise (not found, its provider not current), read only. */
|
|
86
|
+
checkReset(orgId: string, accountId: string, id: string): Promise<void>;
|
|
87
|
+
/** The refusals {@link rename} would raise, read without locks (see {@link checkCreate}). */
|
|
88
|
+
checkRename(orgId: string, accountId: string, id: string, name: string): Promise<void>;
|
|
77
89
|
/** Renames one of the person's live environments (the default too); see {@link create}. */
|
|
78
|
-
rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string): Promise<EnvironmentView>;
|
|
90
|
+
rename(orgId: string, accountId: string, id: string, name: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<EnvironmentView>;
|
|
79
91
|
private renameIn;
|
|
80
92
|
/**
|
|
81
93
|
* Deletes one of the person's live environments: soft delete, its IM default row cleared, and
|
|
@@ -83,7 +95,7 @@ export declare class EnvironmentsService {
|
|
|
83
95
|
* destroys the instance and the files). Conversations bound to it keep pointing at it; their
|
|
84
96
|
* sandbox tools then fail with `environment.not_found`.
|
|
85
97
|
*/
|
|
86
|
-
remove(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
|
|
98
|
+
remove(orgId: string, accountId: string, id: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
|
|
87
99
|
/**
|
|
88
100
|
* Starts one of the person's environments over with empty files (after
|
|
89
101
|
* `environment.files_lost`): records the request (audit), then, after the commit, enqueues the
|
|
@@ -92,7 +104,7 @@ export declare class EnvironmentsService {
|
|
|
92
104
|
* provider must be the current one (`environment.unavailable`). An enqueue failure is thrown
|
|
93
105
|
* (the request can be repeated: the reset is idempotent).
|
|
94
106
|
*/
|
|
95
|
-
resetFiles(orgId: string, accountId: string, id: string, actorTokenId?: string): Promise<void>;
|
|
107
|
+
resetFiles(orgId: string, accountId: string, id: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
|
|
96
108
|
/** The check and audit row of {@link resetFiles}, committed before the job is enqueued. */
|
|
97
109
|
private recordReset;
|
|
98
110
|
/**
|
|
@@ -94,11 +94,11 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
94
94
|
* (case-insensitive) → `environment.name_taken`; `environments.maxPersonal` live ones (the
|
|
95
95
|
* default counts) → `environment.limit_reached`. Serialized per person by their membership row.
|
|
96
96
|
*/
|
|
97
|
-
async create(orgId, accountId, input, actorTokenId) {
|
|
98
|
-
const id = await this.insert(orgId, accountId, input.name, actorTokenId);
|
|
97
|
+
async create(orgId, accountId, input, actorTokenId, auditDetail) {
|
|
98
|
+
const id = await this.insert(orgId, accountId, input.name, actorTokenId, auditDetail);
|
|
99
99
|
return this.get(orgId, accountId, id);
|
|
100
100
|
}
|
|
101
|
-
async insert(orgId, accountId, name, actorTokenId) {
|
|
101
|
+
async insert(orgId, accountId, name, actorTokenId, auditDetail) {
|
|
102
102
|
const current = this.providers.current();
|
|
103
103
|
if (!current)
|
|
104
104
|
throw environmentUnavailable(null);
|
|
@@ -142,16 +142,60 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
142
142
|
orgId,
|
|
143
143
|
action: "environment.created",
|
|
144
144
|
target: id,
|
|
145
|
-
detail: { name },
|
|
145
|
+
detail: { name, ...auditDetail },
|
|
146
146
|
});
|
|
147
147
|
return id;
|
|
148
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* The refusals {@link create} would raise, read without locks or writes (a precheck before a
|
|
151
|
+
* confirmation card): no sandbox provider, the person's limit, a name already taken. Throws the
|
|
152
|
+
* same {@link ApiError}s; a race still ends in `create`'s own refusal.
|
|
153
|
+
*/
|
|
154
|
+
async checkCreate(orgId, accountId, name) {
|
|
155
|
+
if (!this.providers.current())
|
|
156
|
+
throw environmentUnavailable(null);
|
|
157
|
+
const { n } = await this.db
|
|
158
|
+
.selectFrom("environments")
|
|
159
|
+
.select((eb) => eb.fn.countAll().as("n"))
|
|
160
|
+
.where("org_id", "=", orgId)
|
|
161
|
+
.where("owner_kind", "=", "personal")
|
|
162
|
+
.where("owner_account_id", "=", accountId)
|
|
163
|
+
.where("deleted_at", "is", null)
|
|
164
|
+
.executeTakeFirstOrThrow();
|
|
165
|
+
const max = this.config.get().environments.maxPersonal;
|
|
166
|
+
if (Number(n) >= max) {
|
|
167
|
+
throw new ApiError("environment.limit_reached", `You already have ${max} environments in this organization; delete one to create another`);
|
|
168
|
+
}
|
|
169
|
+
await this.assertNameFree(orgId, accountId, name);
|
|
170
|
+
}
|
|
171
|
+
/** How many of the person's conversations work in the environment (read only). */
|
|
172
|
+
async boundConversations(orgId, accountId, id) {
|
|
173
|
+
const { n } = await this.db
|
|
174
|
+
.selectFrom("conversations")
|
|
175
|
+
.select((eb) => eb.fn.countAll().as("n"))
|
|
176
|
+
.where("org_id", "=", orgId)
|
|
177
|
+
.where("account_id", "=", accountId)
|
|
178
|
+
.where("environment_id", "=", id)
|
|
179
|
+
.executeTakeFirstOrThrow();
|
|
180
|
+
return Number(n);
|
|
181
|
+
}
|
|
182
|
+
/** The refusals {@link resetFiles} would raise (not found, its provider not current), read only. */
|
|
183
|
+
async checkReset(orgId, accountId, id) {
|
|
184
|
+
await this.access.usable(orgId, accountId, id);
|
|
185
|
+
}
|
|
186
|
+
/** The refusals {@link rename} would raise, read without locks (see {@link checkCreate}). */
|
|
187
|
+
async checkRename(orgId, accountId, id, name) {
|
|
188
|
+
const before = await this.get(orgId, accountId, id);
|
|
189
|
+
if (before.name?.toLowerCase() !== name.toLowerCase()) {
|
|
190
|
+
await this.assertNameFree(orgId, accountId, name);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
149
193
|
/** Renames one of the person's live environments (the default too); see {@link create}. */
|
|
150
|
-
async rename(orgId, accountId, id, name, actorTokenId) {
|
|
151
|
-
await this.renameIn(orgId, accountId, id, name, actorTokenId);
|
|
194
|
+
async rename(orgId, accountId, id, name, actorTokenId, auditDetail) {
|
|
195
|
+
await this.renameIn(orgId, accountId, id, name, actorTokenId, auditDetail);
|
|
152
196
|
return this.get(orgId, accountId, id);
|
|
153
197
|
}
|
|
154
|
-
async renameIn(orgId, accountId, id, name, actorTokenId) {
|
|
198
|
+
async renameIn(orgId, accountId, id, name, actorTokenId, auditDetail) {
|
|
155
199
|
const before = await this.lockOwn(orgId, accountId, id);
|
|
156
200
|
if (before.name === name)
|
|
157
201
|
return;
|
|
@@ -177,7 +221,7 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
177
221
|
orgId,
|
|
178
222
|
action: "environment.renamed",
|
|
179
223
|
target: id,
|
|
180
|
-
detail: { from: before.name, to: name },
|
|
224
|
+
detail: { from: before.name, to: name, ...auditDetail },
|
|
181
225
|
});
|
|
182
226
|
}
|
|
183
227
|
/**
|
|
@@ -186,7 +230,7 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
186
230
|
* destroys the instance and the files). Conversations bound to it keep pointing at it; their
|
|
187
231
|
* sandbox tools then fail with `environment.not_found`.
|
|
188
232
|
*/
|
|
189
|
-
async remove(orgId, accountId, id, actorTokenId) {
|
|
233
|
+
async remove(orgId, accountId, id, actorTokenId, auditDetail) {
|
|
190
234
|
const before = await this.lockOwn(orgId, accountId, id);
|
|
191
235
|
await this.db
|
|
192
236
|
.updateTable("environments")
|
|
@@ -205,7 +249,7 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
205
249
|
orgId,
|
|
206
250
|
action: "environment.deleted",
|
|
207
251
|
target: id,
|
|
208
|
-
detail: { name: before.name, isDefault: before.is_default },
|
|
252
|
+
detail: { name: before.name, isDefault: before.is_default, ...auditDetail },
|
|
209
253
|
});
|
|
210
254
|
afterCommit(async () => {
|
|
211
255
|
try {
|
|
@@ -225,12 +269,12 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
225
269
|
* provider must be the current one (`environment.unavailable`). An enqueue failure is thrown
|
|
226
270
|
* (the request can be repeated: the reset is idempotent).
|
|
227
271
|
*/
|
|
228
|
-
async resetFiles(orgId, accountId, id, actorTokenId) {
|
|
229
|
-
await this.recordReset(orgId, accountId, id, actorTokenId);
|
|
272
|
+
async resetFiles(orgId, accountId, id, actorTokenId, auditDetail) {
|
|
273
|
+
await this.recordReset(orgId, accountId, id, actorTokenId, auditDetail);
|
|
230
274
|
await this.sandboxJobs.resetFiles(id);
|
|
231
275
|
}
|
|
232
276
|
/** The check and audit row of {@link resetFiles}, committed before the job is enqueued. */
|
|
233
|
-
async recordReset(orgId, accountId, id, actorTokenId) {
|
|
277
|
+
async recordReset(orgId, accountId, id, actorTokenId, auditDetail) {
|
|
234
278
|
await this.access.usable(orgId, accountId, id);
|
|
235
279
|
await audit(this.db.db, {
|
|
236
280
|
actorAccountId: accountId,
|
|
@@ -238,6 +282,7 @@ let EnvironmentsService = class EnvironmentsService {
|
|
|
238
282
|
orgId,
|
|
239
283
|
action: "environment.files_reset",
|
|
240
284
|
target: id,
|
|
285
|
+
...(auditDetail !== undefined && { detail: auditDetail }),
|
|
241
286
|
});
|
|
242
287
|
}
|
|
243
288
|
/**
|
package/dist/errors.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export declare const ERROR_CODES: {
|
|
|
15
15
|
readonly "account.login_taken": 409;
|
|
16
16
|
readonly "account.not_found": 404;
|
|
17
17
|
readonly "account.last_super_admin": 409;
|
|
18
|
+
readonly "account.initial_password_unavailable": 404;
|
|
19
|
+
readonly "account.create_needs_approval": 409;
|
|
18
20
|
readonly "auth.account_disabled": 403;
|
|
19
21
|
readonly "auth.required": 401;
|
|
20
22
|
readonly "auth.token_expired": 401;
|
|
@@ -25,6 +27,7 @@ export declare const ERROR_CODES: {
|
|
|
25
27
|
readonly "auth.csrf": 403;
|
|
26
28
|
readonly "auth.rate_limited": 429;
|
|
27
29
|
readonly "auth.session_required": 403;
|
|
30
|
+
readonly "auth.password_change_required": 403;
|
|
28
31
|
readonly "token.not_found": 404;
|
|
29
32
|
readonly "org.not_found": 404;
|
|
30
33
|
readonly "org.creation_disabled": 403;
|
|
@@ -280,6 +283,9 @@ export declare const ERROR_CODES: {
|
|
|
280
283
|
readonly "eval.candidate_invalid": 400;
|
|
281
284
|
readonly "model.unconfigured": 409;
|
|
282
285
|
readonly "model.purpose_unknown": 404;
|
|
286
|
+
readonly "model.provider_not_found": 404;
|
|
287
|
+
/** An extension's `ctx.models.embed` call was denied by a `model.request` policy hook. */
|
|
288
|
+
readonly "model.hook_denied": 403;
|
|
283
289
|
readonly "eval.result_not_found": 404;
|
|
284
290
|
};
|
|
285
291
|
export type ErrorCode = keyof typeof ERROR_CODES;
|
package/dist/errors.js
CHANGED
|
@@ -15,6 +15,8 @@ export const ERROR_CODES = {
|
|
|
15
15
|
"account.login_taken": 409,
|
|
16
16
|
"account.not_found": 404,
|
|
17
17
|
"account.last_super_admin": 409,
|
|
18
|
+
"account.initial_password_unavailable": 404,
|
|
19
|
+
"account.create_needs_approval": 409,
|
|
18
20
|
"auth.account_disabled": 403,
|
|
19
21
|
"auth.required": 401,
|
|
20
22
|
"auth.token_expired": 401,
|
|
@@ -25,6 +27,7 @@ export const ERROR_CODES = {
|
|
|
25
27
|
"auth.csrf": 403,
|
|
26
28
|
"auth.rate_limited": 429,
|
|
27
29
|
"auth.session_required": 403,
|
|
30
|
+
"auth.password_change_required": 403,
|
|
28
31
|
"token.not_found": 404,
|
|
29
32
|
"org.not_found": 404,
|
|
30
33
|
"org.creation_disabled": 403,
|
|
@@ -280,6 +283,9 @@ export const ERROR_CODES = {
|
|
|
280
283
|
"eval.candidate_invalid": 400,
|
|
281
284
|
"model.unconfigured": 409,
|
|
282
285
|
"model.purpose_unknown": 404,
|
|
286
|
+
"model.provider_not_found": 404,
|
|
287
|
+
/** An extension's `ctx.models.embed` call was denied by a `model.request` policy hook. */
|
|
288
|
+
"model.hook_denied": 403,
|
|
283
289
|
"eval.result_not_found": 404,
|
|
284
290
|
};
|
|
285
291
|
/** 业务代码抛出的 API 错误;由 HTTP 层的错误过滤器转成错误信封。 */
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const EvalSetCreateBody: z.ZodObject<{
|
|
4
|
+
agentId: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
description: z.ZodOptional<z.ZodString>;
|
|
7
|
+
rubric: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export declare const EvalSetPatchBody: z.ZodObject<{
|
|
10
|
+
name: z.ZodOptional<z.ZodString>;
|
|
11
|
+
description: z.ZodOptional<z.ZodString>;
|
|
12
|
+
rubric: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const EvalAddCaseBody: z.ZodObject<{
|
|
15
|
+
conversationId: z.ZodString;
|
|
16
|
+
runId: z.ZodString;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
export declare const EvalSampleBody: z.ZodObject<{
|
|
19
|
+
from: z.ZodOptional<z.ZodISODateTime>;
|
|
20
|
+
to: z.ZodOptional<z.ZodISODateTime>;
|
|
21
|
+
count: z.ZodNumber;
|
|
22
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
any: "any";
|
|
24
|
+
completed: "completed";
|
|
25
|
+
failed: "failed";
|
|
26
|
+
}>>;
|
|
27
|
+
minToolCalls: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
export declare const EvalCandidateSchema: z.ZodObject<{
|
|
30
|
+
agentVersion: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
32
|
+
provider: z.ZodString;
|
|
33
|
+
model: z.ZodString;
|
|
34
|
+
}, z.core.$strict>>;
|
|
35
|
+
modelParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
36
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strict>;
|
|
38
|
+
/** `tokenCap` is only type-checked here; the service judges the range (`eval.token_cap_invalid`). */
|
|
39
|
+
export declare const EvalRunEstimateBody: z.ZodObject<{
|
|
40
|
+
mode: z.ZodEnum<{
|
|
41
|
+
run: "run";
|
|
42
|
+
step: "step";
|
|
43
|
+
}>;
|
|
44
|
+
candidate: z.ZodObject<{
|
|
45
|
+
agentVersion: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
47
|
+
provider: z.ZodString;
|
|
48
|
+
model: z.ZodString;
|
|
49
|
+
}, z.core.$strict>>;
|
|
50
|
+
modelParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
51
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strict>;
|
|
53
|
+
judge: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
tokenCap: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
export declare const EvalRunStartBody: z.ZodObject<{
|
|
57
|
+
mode: z.ZodEnum<{
|
|
58
|
+
run: "run";
|
|
59
|
+
step: "step";
|
|
60
|
+
}>;
|
|
61
|
+
candidate: z.ZodObject<{
|
|
62
|
+
agentVersion: z.ZodOptional<z.ZodNumber>;
|
|
63
|
+
model: z.ZodOptional<z.ZodObject<{
|
|
64
|
+
provider: z.ZodString;
|
|
65
|
+
model: z.ZodString;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
modelParams: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
68
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$strict>;
|
|
70
|
+
judge: z.ZodDefault<z.ZodBoolean>;
|
|
71
|
+
tokenCap: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
/**
|
|
74
|
+
* `view=light`: no content blocks (result tables and polling; the response carries `asOf`);
|
|
75
|
+
* default `full`. `updatedSince` (ISO time) takes only what changed after it.
|
|
76
|
+
*/
|
|
77
|
+
export declare const EvalRunResultsQuery: z.ZodObject<{
|
|
78
|
+
after: z.ZodOptional<z.ZodString>;
|
|
79
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
80
|
+
view: z.ZodDefault<z.ZodEnum<{
|
|
81
|
+
full: "full";
|
|
82
|
+
light: "light";
|
|
83
|
+
}>>;
|
|
84
|
+
updatedSince: z.ZodOptional<z.ZodString>;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
export declare const EvalLabelBody: z.ZodObject<{
|
|
87
|
+
label: z.ZodNullable<z.ZodEnum<{
|
|
88
|
+
fail: "fail";
|
|
89
|
+
pass: "pass";
|
|
90
|
+
}>>;
|
|
91
|
+
note: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
export declare const EvalSetParams: z.ZodObject<{
|
|
94
|
+
setId: z.ZodString;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export declare const EvalCaseParams: z.ZodObject<{
|
|
97
|
+
setId: z.ZodString;
|
|
98
|
+
caseId: z.ZodString;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
export declare const EvalRunParams: z.ZodObject<{
|
|
101
|
+
runId: z.ZodString;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export declare const EvalResultParams: z.ZodObject<{
|
|
104
|
+
runId: z.ZodString;
|
|
105
|
+
resultId: z.ZodString;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
export declare const EvalLabelParams: z.ZodObject<{
|
|
108
|
+
resultId: z.ZodString;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
export declare const EVAL_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ModelRef } from "../agents/definition.js";
|
|
3
|
+
const NAME = z.string().trim().min(1).max(200);
|
|
4
|
+
const DESCRIPTION = z.string().max(2000);
|
|
5
|
+
const RUBRIC = z.string().min(1).max(20_000);
|
|
6
|
+
export const EvalSetCreateBody = z
|
|
7
|
+
.object({
|
|
8
|
+
agentId: z.string().min(1).max(100),
|
|
9
|
+
name: NAME,
|
|
10
|
+
description: DESCRIPTION.optional(),
|
|
11
|
+
rubric: RUBRIC.optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
export const EvalSetPatchBody = z
|
|
15
|
+
.object({
|
|
16
|
+
name: NAME.optional(),
|
|
17
|
+
description: DESCRIPTION.optional(),
|
|
18
|
+
rubric: RUBRIC.nullable().optional(),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
export const EvalAddCaseBody = z
|
|
22
|
+
.object({ conversationId: z.string().min(1).max(100), runId: z.string().min(1).max(100) })
|
|
23
|
+
.strict();
|
|
24
|
+
export const EvalSampleBody = z
|
|
25
|
+
.object({
|
|
26
|
+
from: z.iso.datetime({ offset: true }).optional(),
|
|
27
|
+
to: z.iso.datetime({ offset: true }).optional(),
|
|
28
|
+
count: z.number().int().min(1).max(50),
|
|
29
|
+
status: z.enum(["completed", "failed", "any"]).optional(),
|
|
30
|
+
minToolCalls: z.number().int().min(0).max(1000).optional(),
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export const EvalCandidateSchema = z
|
|
34
|
+
.object({
|
|
35
|
+
agentVersion: z.number().int().min(1).optional(),
|
|
36
|
+
model: ModelRef.strict().optional(),
|
|
37
|
+
modelParams: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
|
|
38
|
+
instructions: z.string().max(100_000).optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
/** `tokenCap` is only type-checked here; the service judges the range (`eval.token_cap_invalid`). */
|
|
42
|
+
export const EvalRunEstimateBody = z
|
|
43
|
+
.object({
|
|
44
|
+
mode: z.enum(["step", "run"]),
|
|
45
|
+
candidate: EvalCandidateSchema,
|
|
46
|
+
judge: z.boolean().default(false),
|
|
47
|
+
tokenCap: z.number().int().optional(),
|
|
48
|
+
})
|
|
49
|
+
.strict();
|
|
50
|
+
export const EvalRunStartBody = EvalRunEstimateBody;
|
|
51
|
+
/**
|
|
52
|
+
* `view=light`: no content blocks (result tables and polling; the response carries `asOf`);
|
|
53
|
+
* default `full`. `updatedSince` (ISO time) takes only what changed after it.
|
|
54
|
+
*/
|
|
55
|
+
export const EvalRunResultsQuery = z
|
|
56
|
+
.object({
|
|
57
|
+
after: z.string().max(100).optional(),
|
|
58
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
59
|
+
view: z.enum(["full", "light"]).default("full"),
|
|
60
|
+
updatedSince: z
|
|
61
|
+
.string()
|
|
62
|
+
.max(64)
|
|
63
|
+
.refine((v) => !Number.isNaN(Date.parse(v)), { message: "must be an ISO timestamp" })
|
|
64
|
+
.optional(),
|
|
65
|
+
})
|
|
66
|
+
.strict();
|
|
67
|
+
export const EvalLabelBody = z
|
|
68
|
+
.object({
|
|
69
|
+
label: z.enum(["pass", "fail"]).nullable(),
|
|
70
|
+
note: z.string().max(2000).optional(),
|
|
71
|
+
})
|
|
72
|
+
.strict();
|
|
73
|
+
/** The path params the eval routes read (`@Param`), bounded as the operations take them. */
|
|
74
|
+
const Id = z.string().min(1).max(100);
|
|
75
|
+
export const EvalSetParams = z.object({ setId: Id });
|
|
76
|
+
export const EvalCaseParams = z.object({ setId: Id, caseId: Id });
|
|
77
|
+
export const EvalRunParams = z.object({ runId: Id });
|
|
78
|
+
export const EvalResultParams = z.object({ runId: Id, resultId: Id });
|
|
79
|
+
export const EvalLabelParams = z.object({ resultId: Id });
|
|
80
|
+
const O = "/api/v1/orgs/:orgId";
|
|
81
|
+
export const EVAL_ROUTES = [
|
|
82
|
+
{ route: `POST ${O}/eval-sets`, body: EvalSetCreateBody },
|
|
83
|
+
{ route: `GET ${O}/eval-sets` },
|
|
84
|
+
{ route: `GET ${O}/eval-sets/:setId`, params: EvalSetParams },
|
|
85
|
+
{ route: `PATCH ${O}/eval-sets/:setId`, params: EvalSetParams, body: EvalSetPatchBody },
|
|
86
|
+
{ route: `DELETE ${O}/eval-sets/:setId`, params: EvalSetParams },
|
|
87
|
+
{ route: `POST ${O}/eval-sets/:setId/cases`, params: EvalSetParams, body: EvalAddCaseBody },
|
|
88
|
+
{
|
|
89
|
+
route: `POST ${O}/eval-sets/:setId/cases/sample`,
|
|
90
|
+
params: EvalSetParams,
|
|
91
|
+
body: EvalSampleBody,
|
|
92
|
+
},
|
|
93
|
+
{ route: `GET ${O}/eval-sets/:setId/cases/:caseId`, params: EvalCaseParams },
|
|
94
|
+
{ route: `DELETE ${O}/eval-sets/:setId/cases/:caseId`, params: EvalCaseParams },
|
|
95
|
+
{
|
|
96
|
+
route: `POST ${O}/eval-sets/:setId/runs/estimate`,
|
|
97
|
+
params: EvalSetParams,
|
|
98
|
+
body: EvalRunEstimateBody,
|
|
99
|
+
},
|
|
100
|
+
{ route: `POST ${O}/eval-sets/:setId/runs`, params: EvalSetParams, body: EvalRunStartBody },
|
|
101
|
+
{ route: `GET ${O}/eval-sets/:setId/runs`, params: EvalSetParams },
|
|
102
|
+
{ route: `GET ${O}/eval-runs/:runId`, params: EvalRunParams },
|
|
103
|
+
{ route: `GET ${O}/eval-runs/:runId/results`, params: EvalRunParams, query: EvalRunResultsQuery },
|
|
104
|
+
{ route: `GET ${O}/eval-runs/:runId/results/:resultId`, params: EvalResultParams },
|
|
105
|
+
{ route: `POST ${O}/eval-runs/:runId/cancel`, params: EvalRunParams },
|
|
106
|
+
{ route: `PUT ${O}/eval-results/:resultId/label`, params: EvalLabelParams, body: EvalLabelBody },
|
|
107
|
+
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sanitizeParams, } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import { AgentDefinitionSchema, normalizeStoredDefinition, } from "../agents/definition.js";
|
|
2
|
+
import { AgentDefinitionSchema, builtinDisabled, canonicalDisabledTools, normalizeStoredDefinition, } from "../agents/definition.js";
|
|
3
3
|
import { sameModel, selectionAt } from "../conversations/selection.js";
|
|
4
4
|
import { ApiError } from "../errors.js";
|
|
5
5
|
import { mediaRefs, planMedia, } from "../runtime/context/build.js";
|
|
@@ -217,18 +217,25 @@ const sameTemplate = (logged, t) => logged.source !== "plugin" ||
|
|
|
217
217
|
(logged.platformTemplateId ?? null) === (t.platformTemplateId ?? null));
|
|
218
218
|
const pinsOf = (d) => [...new Set(d.skills?.pinned ?? [])].slice(0, PINNED_SKILLS_LIMITS.count);
|
|
219
219
|
/**
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
220
|
+
* A sub-agent's tools without template narrowing (general and org agents), as compared: its
|
|
221
|
+
* turned-off tools (tools default-on spec §4) and its key filter's allowlist and `deny` keys,
|
|
222
|
+
* {@link CHILD_REMOVED_TOOLS} left out. `Agent` depends on the child's depth, not on the
|
|
223
|
+
* definition (agent map spec §4.1): a `deny` of it never counts, and a turned-off `Agent` counts
|
|
224
|
+
* only when the logged child had it (`keepAgent`), so a child logged without it (at the depth
|
|
225
|
+
* limit, or before nesting) compares equal to a candidate that offers it.
|
|
224
226
|
*/
|
|
225
|
-
const childToolsOf = (d, keepAgent) => canonicalJson(
|
|
226
|
-
(
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
const childToolsOf = (d, keepAgent) => canonicalJson({
|
|
228
|
+
disabled: canonicalDisabledTools((d.disabledTools ?? []).filter((r) => keepAgent || r.kind !== "builtin" || r.name !== AGENT_TOOL)),
|
|
229
|
+
allow: d.subagentTools?.allow ?? null,
|
|
230
|
+
deny: (d.subagentTools?.deny ?? []).filter((k) => !CHILD_REMOVED_TOOLS.includes(k) && k !== AGENT_TOOL),
|
|
231
|
+
});
|
|
232
|
+
/** Does the child have `Agent` by its definition (not turned off, not removed by its filter)? */
|
|
233
|
+
const hasAgent = (d) => !builtinDisabled(d.disabledTools, AGENT_TOOL) &&
|
|
234
|
+
!(d.subagentTools?.deny ?? []).includes(AGENT_TOOL) &&
|
|
235
|
+
(d.subagentTools?.allow === undefined || d.subagentTools.allow.includes(AGENT_TOOL));
|
|
229
236
|
/** The parent's selection a template child depends on: its tools, org skills and roster entry. */
|
|
230
237
|
const parentSide = (d, started) => canonicalJson({
|
|
231
|
-
|
|
238
|
+
disabledTools: canonicalDisabledTools(d.disabledTools ?? []),
|
|
232
239
|
orgSkills: d.skills?.orgSkills ?? [],
|
|
233
240
|
listed: started.template.source === "general"
|
|
234
241
|
? d.subagents?.general !== false
|
|
@@ -264,7 +271,7 @@ original) {
|
|
|
264
271
|
(pinned !== null && canonicalJson(pinned) !== canonicalJson(pinsOf(logged))) ||
|
|
265
272
|
(tools !== null && tools !== childTools(logged));
|
|
266
273
|
if (sameVersion) {
|
|
267
|
-
return differs(candidate.instructions, pinsOf(candidate),
|
|
274
|
+
return differs(candidate.instructions, pinsOf(candidate), childTools(candidate));
|
|
268
275
|
}
|
|
269
276
|
switch (started.template.source) {
|
|
270
277
|
case "agent":
|
|
@@ -31,7 +31,8 @@ export interface RecordedCall {
|
|
|
31
31
|
* - a connector: the tool definition the key was recorded with (`toolSpecs`, found by the specHash of
|
|
32
32
|
* its `tool_call_started` or its `model_call` tools / catalog entry) has `connectorData`;
|
|
33
33
|
* - an extension: that definition exists without `connectorData` and its name is the key's tool
|
|
34
|
-
* part, or an agent definition names exactly that tool as a `{ kind: "plugin", plugin: x, name }`
|
|
34
|
+
* part, or an rc-era agent definition names exactly that tool as a `{ kind: "plugin", plugin: x, name }`
|
|
35
|
+
* ref.
|
|
35
36
|
*/
|
|
36
37
|
export declare function legacyScopeOf(s: CaseSnapshot): LegacyScope;
|
|
37
38
|
/**
|
|
@@ -16,7 +16,8 @@ export const REPLAY_NO_RECORDING = "[replay] No recorded result matches this too
|
|
|
16
16
|
* - a connector: the tool definition the key was recorded with (`toolSpecs`, found by the specHash of
|
|
17
17
|
* its `tool_call_started` or its `model_call` tools / catalog entry) has `connectorData`;
|
|
18
18
|
* - an extension: that definition exists without `connectorData` and its name is the key's tool
|
|
19
|
-
* part, or an agent definition names exactly that tool as a `{ kind: "plugin", plugin: x, name }`
|
|
19
|
+
* part, or an rc-era agent definition names exactly that tool as a `{ kind: "plugin", plugin: x, name }`
|
|
20
|
+
* ref.
|
|
20
21
|
*/
|
|
21
22
|
export function legacyScopeOf(s) {
|
|
22
23
|
const hashes = new Map();
|
|
@@ -42,10 +43,17 @@ export function legacyScopeOf(s) {
|
|
|
42
43
|
const extensionNames = new Set();
|
|
43
44
|
const connectorSlugs = new Set();
|
|
44
45
|
const planted = new Set();
|
|
46
|
+
// rc-era snapshots hold definitions from before tools were on by default: an enabled `tools`
|
|
47
|
+
// list of refs (tools default-on spec §2)
|
|
45
48
|
for (const def of Object.values(s.definitions)) {
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const refs = def.tools;
|
|
50
|
+
if (!Array.isArray(refs))
|
|
51
|
+
continue;
|
|
52
|
+
for (const t of refs) {
|
|
53
|
+
if (t?.kind === "plugin" && typeof t.plugin === "string" && typeof t.name === "string") {
|
|
48
54
|
planted.add(`${t.plugin}__${t.name}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
for (const [key, set] of hashes) {
|
|
51
59
|
const i = key.indexOf("__");
|
|
@@ -18,7 +18,7 @@ import type { ResolvedCandidate } from "./step-replay.js";
|
|
|
18
18
|
* {@link RecordedToolPipeline}(只回放记录的结果,不执行任何工具、沙箱、连接器或审批)。
|
|
19
19
|
*
|
|
20
20
|
* - 种子:原运行 `run_started` 之前的事件按原 seq 插入(`last_seq` 停在其前一位,新的 `run_started` 因此与原来同 seq),
|
|
21
|
-
* 原运行开始时的 `skills_catalog` 照抄;然后写 `runs` 行与 `run_started`,`agent` 用候选定义。
|
|
21
|
+
* 原运行开始时的 `skills_catalog` 与 `run_context` 照抄;然后写 `runs` 行与 `run_started`,`agent` 用候选定义。
|
|
22
22
|
* - 插话:原运行中途吸收的可吸收事件(user_message, and finished background tasks: background Bash
|
|
23
23
|
* spec §4.4),在「原吸收步骤 ≤ 当前步骤」时追加进评测对话并交给 loop(a recorded finish is
|
|
24
24
|
* appended as recorded: no task starts, polls or stops; likewise a sub-agent's delivery, agent map
|
|
@@ -114,6 +114,13 @@ export interface ReplaySeed {
|
|
|
114
114
|
catalog: {
|
|
115
115
|
payload: unknown;
|
|
116
116
|
} | undefined;
|
|
117
|
+
/**
|
|
118
|
+
* The original run's `run_context` event (run context spec §8), copied as is: a candidate sees
|
|
119
|
+
* the original date, names and org, never the eval day's.
|
|
120
|
+
*/
|
|
121
|
+
runContext: {
|
|
122
|
+
payload: unknown;
|
|
123
|
+
} | undefined;
|
|
117
124
|
}
|
|
118
125
|
/**
|
|
119
126
|
* The seed of a full-run replay (C6): the `kind = 'eval'` conversation with the events before the
|