@capybara-hq/kernel 0.1.0-rc.41 → 0.1.0-rc.43
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 +3 -3
- package/dist/admin/admin.schemas.d.ts +6 -0
- package/dist/admin/org-network.service.d.ts +3 -1
- package/dist/admin/org-network.service.js +10 -2
- package/dist/app.d.ts +4 -0
- package/dist/app.js +2 -0
- package/dist/background/finish.d.ts +9 -1
- package/dist/background/finish.js +57 -4
- package/dist/background/launch.d.ts +23 -0
- package/dist/background/launch.js +55 -1
- package/dist/background/managed-output.d.ts +110 -0
- package/dist/background/managed-output.js +219 -0
- package/dist/background/managed.d.ts +52 -0
- package/dist/background/managed.js +128 -0
- package/dist/background/poll.job.d.ts +35 -1
- package/dist/background/poll.job.js +174 -9
- package/dist/background/render.js +1 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
- package/dist/background/retire-legacy-tasks.job.js +149 -0
- package/dist/background/session.d.ts +15 -5
- package/dist/background/session.js +22 -6
- package/dist/background/stop.d.ts +35 -5
- package/dist/background/stop.js +94 -8
- package/dist/background/store.d.ts +110 -3
- package/dist/background/store.js +205 -3
- package/dist/background/tasks.service.d.ts +18 -1
- package/dist/background/tasks.service.js +99 -9
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/cards.js +1 -1
- package/dist/channels/inbound.js +2 -0
- package/dist/channels/phrases.d.ts +4 -0
- package/dist/channels/phrases.js +4 -0
- package/dist/config/load.d.ts +18 -0
- package/dist/config/load.js +39 -1
- package/dist/config/permission-migration.d.ts +26 -0
- package/dist/config/permission-migration.js +64 -0
- package/dist/config/schema.d.ts +4 -1
- package/dist/config/schema.js +41 -10
- package/dist/conversations/conversations.controller.d.ts +1 -1
- package/dist/conversations/conversations.controller.js +1 -1
- package/dist/conversations/conversations.module.js +12 -0
- package/dist/conversations/conversations.service.d.ts +11 -2
- package/dist/conversations/conversations.service.js +97 -27
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +10 -2
- package/dist/conversations/events.d.ts +307 -4
- package/dist/conversations/events.js +286 -32
- package/dist/conversations/permission-profile-store.d.ts +50 -0
- package/dist/conversations/permission-profile-store.js +67 -0
- package/dist/conversations/permission-profile-store.module.d.ts +2 -0
- package/dist/conversations/permission-profile-store.module.js +19 -0
- package/dist/conversations/permission-profiles.controller.d.ts +84 -0
- package/dist/conversations/permission-profiles.controller.js +105 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
- package/dist/conversations/permission-profiles.schemas.js +23 -0
- package/dist/conversations/permission-profiles.service.d.ts +56 -0
- package/dist/conversations/permission-profiles.service.js +179 -0
- package/dist/ctx/create-ctx.d.ts +12 -5
- package/dist/ctx/create-ctx.js +21 -5
- package/dist/db/kernel-schema.d.ts +248 -3
- package/dist/devices/access.js +1 -1
- package/dist/devices/access.module.d.ts +2 -0
- package/dist/devices/access.module.js +19 -0
- package/dist/devices/conversation-devices.d.ts +8 -29
- package/dist/devices/conversation-devices.js +37 -73
- package/dist/devices/device-projects.service.d.ts +26 -28
- package/dist/devices/device-projects.service.js +123 -127
- package/dist/devices/devices.controller.js +3 -1
- package/dist/devices/devices.module.js +11 -9
- package/dist/devices/devices.service.d.ts +116 -8
- package/dist/devices/devices.service.js +252 -20
- package/dist/devices/dto.d.ts +16 -0
- package/dist/devices/dto.js +34 -6
- package/dist/devices/errors.d.ts +8 -0
- package/dist/devices/errors.js +10 -0
- package/dist/devices/project-rules.d.ts +44 -0
- package/dist/devices/project-rules.js +27 -0
- package/dist/devices/working-root.d.ts +6 -0
- package/dist/devices/working-root.js +12 -1
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +31 -0
- package/dist/evals/reconstruct.d.ts +19 -2
- package/dist/evals/reconstruct.js +40 -2
- package/dist/evals/recorded-permission-context.d.ts +77 -0
- package/dist/evals/recorded-permission-context.js +151 -0
- package/dist/evals/recorded-tools.d.ts +10 -1
- package/dist/evals/recorded-tools.js +27 -3
- package/dist/evals/run-replay.d.ts +8 -2
- package/dist/evals/run-replay.js +18 -2
- package/dist/evals/trajectory.d.ts +1 -1
- package/dist/evals/worker.d.ts +10 -1
- package/dist/evals/worker.js +23 -14
- package/dist/extensions/host.d.ts +4 -1
- package/dist/extensions/host.js +10 -6
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +14 -1
- package/dist/identity/accounts.js +61 -5
- package/dist/identity/identity.module.js +2 -0
- package/dist/identity/settings.d.ts +28 -12
- package/dist/identity/settings.js +89 -33
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
- package/dist/infra/cli/kernel-cli.module.js +5 -2
- package/dist/infra/cli/permission-cutover.d.ts +59 -0
- package/dist/infra/cli/permission-cutover.js +107 -0
- package/dist/infra/config/kernel-config.service.d.ts +2 -2
- package/dist/infra/config/kernel-config.service.js +35 -11
- package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
- package/dist/infra/database/startup-activation-transaction.js +242 -0
- package/dist/infra/database/transaction-host.d.ts +47 -0
- package/dist/infra/database/transaction-host.js +119 -0
- package/dist/infra/database/xact-lock.d.ts +1 -0
- package/dist/infra/database/xact-lock.js +6 -0
- package/dist/infra/outbox/registry.d.ts +39 -0
- package/dist/infra/outbox/registry.js +18 -0
- package/dist/kernel.module.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +55 -28
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +35 -5
- package/dist/local-devices/device-policy.service.js +188 -13
- package/dist/local-devices/instance-bindings.d.ts +82 -0
- package/dist/local-devices/instance-bindings.js +304 -0
- package/dist/local-devices/keys.d.ts +5 -0
- package/dist/local-devices/keys.js +5 -0
- package/dist/local-devices/local-device-gateway.d.ts +19 -4
- package/dist/local-devices/local-device-gateway.js +185 -17
- package/dist/local-devices/local-device-provider.d.ts +42 -7
- package/dist/local-devices/local-device-provider.js +185 -10
- package/dist/local-devices/local-devices.module.d.ts +17 -2
- package/dist/local-devices/local-devices.module.js +49 -8
- package/dist/local-devices/machines.d.ts +35 -12
- package/dist/local-devices/machines.js +203 -8
- package/dist/local-devices/network-grants.js +3 -3
- package/dist/local-devices/network-grants.module.d.ts +2 -0
- package/dist/local-devices/network-grants.module.js +14 -0
- package/dist/local-devices/owner-report.d.ts +79 -0
- package/dist/local-devices/owner-report.js +155 -0
- package/dist/local-devices/owner-reports.d.ts +48 -0
- package/dist/local-devices/owner-reports.js +190 -0
- package/dist/local-devices/policy-summary.d.ts +24 -1
- package/dist/local-devices/policy-summary.js +48 -0
- package/dist/local-devices/relay.d.ts +82 -6
- package/dist/local-devices/relay.js +187 -16
- package/dist/local-devices/targets.d.ts +16 -1
- package/dist/local-devices/targets.js +35 -2
- package/dist/models/image-usable.d.ts +22 -0
- package/dist/models/image-usable.js +29 -0
- package/dist/models/images.d.ts +125 -0
- package/dist/models/images.js +440 -0
- package/dist/models/models.module.d.ts +3 -2
- package/dist/models/models.module.js +16 -5
- package/dist/models/org-models.schemas.js +1 -0
- package/dist/models/purposes.controller.d.ts +7 -0
- package/dist/models/purposes.controller.js +9 -0
- package/dist/models/purposes.d.ts +28 -3
- package/dist/models/purposes.js +40 -13
- package/dist/orgs/cloud-network-setting.d.ts +33 -0
- package/dist/orgs/cloud-network-setting.js +47 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +8 -2
- package/dist/orgs/org-lock.d.ts +10 -4
- package/dist/orgs/org-lock.js +10 -4
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +8 -2
- package/dist/orgs/settings.controller.d.ts +4 -1
- package/dist/orgs/settings.controller.js +3 -3
- package/dist/orgs/settings.service.d.ts +48 -56
- package/dist/orgs/settings.service.js +144 -101
- package/dist/overrides.d.ts +6 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin.ops.js +14 -11
- package/dist/platform/ops/agent-skills.ops.js +2 -0
- package/dist/platform/ops/devices.ops.js +10 -2
- package/dist/platform/ops/models.ops.js +10 -0
- package/dist/platform/ops/org-settings.ops.js +6 -6
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/roles/worker.module.js +4 -0
- package/dist/runtime/context/build.d.ts +3 -1
- package/dist/runtime/context/build.js +19 -3
- package/dist/runtime/context/compaction.js +5 -0
- package/dist/runtime/context/device-paths.d.ts +9 -2
- package/dist/runtime/context/device-paths.js +20 -0
- package/dist/runtime/context/permission-profile.d.ts +46 -0
- package/dist/runtime/context/permission-profile.js +194 -0
- package/dist/runtime/hook-calls.d.ts +11 -1
- package/dist/runtime/hook-calls.js +24 -1
- package/dist/runtime/maintenance.d.ts +7 -1
- package/dist/runtime/maintenance.js +43 -15
- package/dist/runtime/model-call.d.ts +32 -0
- package/dist/runtime/model-call.js +67 -0
- package/dist/runtime/permission-context-errors.d.ts +39 -0
- package/dist/runtime/permission-context-errors.js +67 -0
- package/dist/runtime/permission-context.service.d.ts +60 -0
- package/dist/runtime/permission-context.service.js +286 -0
- package/dist/runtime/project/knowledge.d.ts +7 -2
- package/dist/runtime/project/knowledge.js +5 -2
- package/dist/runtime/project/knowledge.service.d.ts +17 -2
- package/dist/runtime/project/knowledge.service.js +76 -12
- package/dist/runtime/providers.d.ts +9 -5
- package/dist/runtime/providers.js +22 -3
- package/dist/runtime/run-execution.d.ts +4 -1
- package/dist/runtime/run-execution.js +14 -5
- package/dist/runtime/run-steps.d.ts +11 -3
- package/dist/runtime/run-steps.js +27 -4
- package/dist/runtime/runtime.module.js +11 -0
- package/dist/runtime/usage-report.d.ts +10 -6
- package/dist/runtime/usage-report.js +31 -11
- package/dist/sandbox/attachments-path.d.ts +15 -0
- package/dist/sandbox/attachments-path.js +15 -0
- package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
- package/dist/sandbox/cloud-permission-snapshot.js +407 -0
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
- package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
- package/dist/sandbox/held-operations.d.ts +39 -0
- package/dist/sandbox/held-operations.js +119 -0
- package/dist/sandbox/jobs.d.ts +14 -3
- package/dist/sandbox/jobs.js +20 -2
- package/dist/sandbox/kernel-read.d.ts +55 -0
- package/dist/sandbox/kernel-read.js +57 -0
- package/dist/sandbox/legacy-retirement.d.ts +336 -0
- package/dist/sandbox/legacy-retirement.js +1063 -0
- package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
- package/dist/sandbox/legacy-retirement.module.js +25 -0
- package/dist/sandbox/managed-device-context.d.ts +94 -0
- package/dist/sandbox/managed-device-context.js +308 -0
- package/dist/sandbox/managed-device-context.module.d.ts +6 -0
- package/dist/sandbox/managed-device-context.module.js +33 -0
- package/dist/sandbox/modes.d.ts +56 -8
- package/dist/sandbox/modes.js +92 -8
- package/dist/sandbox/operation-authority-types.d.ts +8 -0
- package/dist/sandbox/operation-authority-types.js +32 -0
- package/dist/sandbox/operation-authority.d.ts +145 -0
- package/dist/sandbox/operation-authority.js +783 -0
- package/dist/sandbox/operation-authority.module.d.ts +2 -0
- package/dist/sandbox/operation-authority.module.js +29 -0
- package/dist/sandbox/operation-intents.d.ts +206 -0
- package/dist/sandbox/operation-intents.js +1252 -0
- package/dist/sandbox/operation-intents.module.d.ts +2 -0
- package/dist/sandbox/operation-intents.module.js +21 -0
- package/dist/sandbox/operation-payloads.d.ts +33 -0
- package/dist/sandbox/operation-payloads.js +332 -0
- package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
- package/dist/sandbox/operation-reconcile.job.js +247 -0
- package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
- package/dist/sandbox/permission-authority-epochs.js +83 -0
- package/dist/sandbox/permission-authority-lock.d.ts +38 -0
- package/dist/sandbox/permission-authority-lock.js +147 -0
- package/dist/sandbox/permission-authority.module.d.ts +9 -0
- package/dist/sandbox/permission-authority.module.js +55 -0
- package/dist/sandbox/permission-availability.d.ts +18 -0
- package/dist/sandbox/permission-availability.js +19 -0
- package/dist/sandbox/permission-call-grants.d.ts +34 -0
- package/dist/sandbox/permission-call-grants.js +349 -0
- package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
- package/dist/sandbox/permission-call-grants.module.js +21 -0
- package/dist/sandbox/permission-call-types.d.ts +82 -0
- package/dist/sandbox/permission-call-types.js +1 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
- package/dist/sandbox/permission-ceiling-writes.js +223 -0
- package/dist/sandbox/permission-config-publication.d.ts +76 -0
- package/dist/sandbox/permission-config-publication.js +339 -0
- package/dist/sandbox/permission-context-types.d.ts +64 -0
- package/dist/sandbox/permission-context-types.js +24 -0
- package/dist/sandbox/permission-facts.d.ts +206 -0
- package/dist/sandbox/permission-facts.js +627 -0
- package/dist/sandbox/permission-facts.module.d.ts +2 -0
- package/dist/sandbox/permission-facts.module.js +20 -0
- package/dist/sandbox/permission-instance-writes.d.ts +90 -0
- package/dist/sandbox/permission-instance-writes.js +305 -0
- package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
- package/dist/sandbox/permission-runtime-reports.js +354 -0
- package/dist/sandbox/permission-transitions.d.ts +31 -0
- package/dist/sandbox/permission-transitions.js +155 -0
- package/dist/sandbox/platform-full-access.d.ts +128 -0
- package/dist/sandbox/platform-full-access.js +210 -0
- package/dist/sandbox/providers.d.ts +22 -0
- package/dist/sandbox/providers.js +10 -2
- package/dist/sandbox/providers.module.d.ts +2 -0
- package/dist/sandbox/providers.module.js +19 -0
- package/dist/sandbox/request-not-sent.d.ts +13 -0
- package/dist/sandbox/request-not-sent.js +13 -0
- package/dist/sandbox/review/classifier.d.ts +2 -0
- package/dist/sandbox/review/classifier.js +8 -0
- package/dist/sandbox/review/permission-candidate.d.ts +12 -0
- package/dist/sandbox/review/permission-candidate.js +145 -0
- package/dist/sandbox/review/review.service.d.ts +5 -2
- package/dist/sandbox/review/review.service.js +60 -15
- package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
- package/dist/sandbox/sandbox-file-reader.js +51 -7
- package/dist/sandbox/sandbox.module.js +26 -6
- package/dist/sandbox/sandbox.service.d.ts +230 -34
- package/dist/sandbox/sandbox.service.js +1368 -199
- package/dist/sandbox/unreachable.js +17 -3
- package/dist/sandbox/use-context.d.ts +17 -0
- package/dist/sandbox/use-context.js +1 -0
- package/dist/skills/invoke.d.ts +27 -4
- package/dist/skills/invoke.js +72 -7
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +23 -10
- package/dist/tools/approvals.service.js +104 -26
- package/dist/tools/builtin-names.d.ts +3 -1
- package/dist/tools/builtin-names.js +5 -1
- package/dist/tools/builtins/artifacts.d.ts +43 -0
- package/dist/tools/builtins/artifacts.js +67 -0
- package/dist/tools/builtins/builtin-tools.d.ts +20 -2
- package/dist/tools/builtins/builtin-tools.js +61 -10
- package/dist/tools/builtins/image/generate.d.ts +59 -0
- package/dist/tools/builtins/image/generate.js +535 -0
- package/dist/tools/builtins/image/index.d.ts +2 -0
- package/dist/tools/builtins/image/index.js +2 -0
- package/dist/tools/builtins/image/paths.d.ts +12 -0
- package/dist/tools/builtins/image/paths.js +26 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
- package/dist/tools/builtins/sandbox/bash.js +201 -5
- package/dist/tools/builtins/sandbox/common.d.ts +92 -20
- package/dist/tools/builtins/sandbox/common.js +201 -17
- package/dist/tools/builtins/sandbox/deliver.js +9 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +2 -2
- package/dist/tools/builtins/sandbox/task-list.js +7 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
- package/dist/tools/builtins/sandbox/task-output.js +172 -0
- package/dist/tools/builtins/sandbox/task-stop.js +25 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.js +9 -6
- package/dist/tools/device-op-resolver.d.ts +1 -1
- package/dist/tools/device-op-resolver.js +13 -3
- package/dist/tools/permission-approval-jobs.d.ts +18 -0
- package/dist/tools/permission-approval-jobs.js +92 -0
- package/dist/tools/pipeline.d.ts +17 -2
- package/dist/tools/pipeline.js +315 -26
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +15 -0
- package/package.json +4 -3
- package/src/migrations/0146_permission_authority_epochs.sql +6 -0
- package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
- package/src/migrations/0148_first_message_request_hash.sql +2 -0
- package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
- package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
- package/src/migrations/0151_starting_execution_grants.sql +8 -0
- package/src/migrations/0152_background_launch_identity.sql +66 -0
- package/src/migrations/0153_background_cancel_requester.sql +13 -0
- package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
- package/src/migrations/0155_device_instance_generations.sql +30 -0
- package/src/migrations/0156_device_owner_report.sql +7 -0
- package/src/migrations/0157_legacy_retirement.sql +116 -0
- package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
- package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
- package/src/migrations/0160_model_usage_image_kind.sql +10 -0
- package/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { PermissionProfileStoreModule } from "../conversations/permission-profile-store.module.js";
|
|
9
|
+
import { NetworkGrantsModule } from "../local-devices/network-grants.module.js";
|
|
10
|
+
import { SandboxOperationAuthority } from "./operation-authority.js";
|
|
11
|
+
import { PermissionAuthorityModule } from "./permission-authority.module.js";
|
|
12
|
+
import { PermissionCallGrantsModule } from "./permission-call-grants.module.js";
|
|
13
|
+
import { PermissionFactsModule } from "./permission-facts.module.js";
|
|
14
|
+
let OperationAuthorityModule = class OperationAuthorityModule {
|
|
15
|
+
};
|
|
16
|
+
OperationAuthorityModule = __decorate([
|
|
17
|
+
Module({
|
|
18
|
+
imports: [
|
|
19
|
+
PermissionFactsModule,
|
|
20
|
+
PermissionCallGrantsModule,
|
|
21
|
+
PermissionProfileStoreModule,
|
|
22
|
+
PermissionAuthorityModule,
|
|
23
|
+
NetworkGrantsModule,
|
|
24
|
+
],
|
|
25
|
+
providers: [SandboxOperationAuthority],
|
|
26
|
+
exports: [SandboxOperationAuthority],
|
|
27
|
+
})
|
|
28
|
+
], OperationAuthorityModule);
|
|
29
|
+
export { OperationAuthorityModule };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { type SandboxExecutionRef } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { Selectable } from "kysely";
|
|
3
|
+
import type { SandboxOperationIntentsTable } from "../db/kernel-schema.js";
|
|
4
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
|
+
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
7
|
+
import type { ExecutionClaim } from "../runtime/run-execution.js";
|
|
8
|
+
import type { KernelReadInvocation, KernelReadMethod } from "./kernel-read.js";
|
|
9
|
+
import type { SandboxAuthorityOperation } from "./operation-authority.js";
|
|
10
|
+
import { SandboxOperationAuthority } from "./operation-authority.js";
|
|
11
|
+
import { OperationPayloads } from "./operation-payloads.js";
|
|
12
|
+
import { PermissionAuthorityEpochStore } from "./permission-authority-epochs.js";
|
|
13
|
+
import { PermissionAuthorityLock } from "./permission-authority-lock.js";
|
|
14
|
+
import type { SandboxUseContext } from "./use-context.js";
|
|
15
|
+
export declare class PermissionAdmissionStale extends Error {
|
|
16
|
+
}
|
|
17
|
+
export declare const OPERATION_RECONCILE = "sandbox-operation-reconcile";
|
|
18
|
+
export declare const OPERATION_REVOKE = "sandbox-operation-revoke";
|
|
19
|
+
export type OperationIntent = Selectable<SandboxOperationIntentsTable>;
|
|
20
|
+
/** Supplied only by the executing tool worker, never tool/model arguments. */
|
|
21
|
+
export interface OperationInvocation {
|
|
22
|
+
claim: ExecutionClaim;
|
|
23
|
+
callId: string;
|
|
24
|
+
ordinal: number;
|
|
25
|
+
deadlineMs: number;
|
|
26
|
+
}
|
|
27
|
+
export interface OperationInstance {
|
|
28
|
+
provider: string;
|
|
29
|
+
providerVersion: string;
|
|
30
|
+
generation: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The task fields a backgroundStart's dispatch binds: the reservation persisted before dispatch
|
|
34
|
+
* must match the exact start input, so the stable input hash covers the artifact and deadlines.
|
|
35
|
+
*/
|
|
36
|
+
export interface BackgroundDispatchBinding {
|
|
37
|
+
taskId: string;
|
|
38
|
+
workingRoot: string;
|
|
39
|
+
outputPath: string;
|
|
40
|
+
retainUntilMs: number;
|
|
41
|
+
/** The held instance's handle id; the typed start result must name it. */
|
|
42
|
+
instanceId: string;
|
|
43
|
+
}
|
|
44
|
+
/** What acknowledging a start did: live running authority, or an owed exact cancellation. */
|
|
45
|
+
export type BackgroundAcknowledgement = "acknowledged" | "cancel-pending";
|
|
46
|
+
export declare function operationIdFor(i: Pick<OperationInvocation, "callId" | "ordinal"> & {
|
|
47
|
+
claim: Pick<ExecutionClaim, "runId">;
|
|
48
|
+
}): string;
|
|
49
|
+
/**
|
|
50
|
+
* A definite pre-effect failure recorded as an operation's result: `denied` and `unsupported`
|
|
51
|
+
* refusals, and `not_sent` (the request was refused before it was sent, its connection changed:
|
|
52
|
+
* `DeviceRequestNotSentError`), which is never an unknown outcome either.
|
|
53
|
+
*/
|
|
54
|
+
export type OperationFailureKind = "denied" | "unsupported" | "not_sent";
|
|
55
|
+
export interface OperationFailure {
|
|
56
|
+
kind: OperationFailureKind;
|
|
57
|
+
message: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Why a managed background start was refused, as `background_tasks.lost_reason` keeps it after
|
|
61
|
+
* `launch refused: ` (TaskOutput, TaskList, the HTTP task view and the Platform tool show it):
|
|
62
|
+
* kernel text by the failure's kind only, never the provider's own message, which stays in the
|
|
63
|
+
* operation's recorded result and the dispatcher's log.
|
|
64
|
+
*/
|
|
65
|
+
export declare function launchRefusedText(kind: OperationFailureKind | undefined): string;
|
|
66
|
+
export declare function operationResult(value: unknown): unknown;
|
|
67
|
+
/** No provider effects occur in this service. Each public mutation owns its transaction. */
|
|
68
|
+
export declare class SandboxOperationIntents {
|
|
69
|
+
private readonly db;
|
|
70
|
+
readonly txHost: TransactionHost;
|
|
71
|
+
private readonly locks;
|
|
72
|
+
private readonly epochs;
|
|
73
|
+
private readonly authority;
|
|
74
|
+
private readonly outbox;
|
|
75
|
+
private readonly payloads;
|
|
76
|
+
constructor(db: KernelDb, txHost: TransactionHost, locks: PermissionAuthorityLock, epochs: PermissionAuthorityEpochStore, authority: SandboxOperationAuthority, outbox: OutboxService, payloads: OperationPayloads);
|
|
77
|
+
/** Current run claim plus its actual tool_call_started row authorize an internal invocation identity. */
|
|
78
|
+
private assertClaim;
|
|
79
|
+
pending(ctx: SandboxUseContext, invocation: OperationInvocation, instance: OperationInstance, method: SandboxAuthorityOperation, input: unknown, holderTag: string, signal: AbortSignal): Promise<OperationIntent>;
|
|
80
|
+
/** Owner-native reads have their own admission, without a manufactured conversation or run. */
|
|
81
|
+
admitBrowse(ctx: {
|
|
82
|
+
orgId: string;
|
|
83
|
+
deviceId: string;
|
|
84
|
+
accountId: string;
|
|
85
|
+
}, instance: OperationInstance, method: "stat" | "list" | "scan", input: unknown, signal: AbortSignal): Promise<OperationIntent>;
|
|
86
|
+
/**
|
|
87
|
+
* The run start's kernel read (permission activation L2, Hook 1): the run must still be the
|
|
88
|
+
* claim's execution, triggered by the actor and `queued` (a run start reads before its run is
|
|
89
|
+
* running), checked in PG under the authority locks the caller already holds.
|
|
90
|
+
*/
|
|
91
|
+
private assertKernelReadRun;
|
|
92
|
+
/**
|
|
93
|
+
* Admits one kernel read (Hook 1), modelled on {@link admitBrowse}: a random operation id per
|
|
94
|
+
* read, so nothing is a consumed identity and a retried run start reads again; the run is
|
|
95
|
+
* recorded for audit (`run_id`, no `call_id`). The scope is the profile scope narrowed to the
|
|
96
|
+
* one path the read may reach (`SandboxOperationAuthority.resolveKernelRead`); the claim is
|
|
97
|
+
* re-checked under the admit lock ({@link assertKernelReadRun}). The read's `holderTag` is its
|
|
98
|
+
* lease token, so a dead holder's read is revoked with the holder.
|
|
99
|
+
*/
|
|
100
|
+
admitKernelRead(ctx: SandboxUseContext, read: KernelReadInvocation, instance: OperationInstance, method: KernelReadMethod, input: {
|
|
101
|
+
path: string;
|
|
102
|
+
}, holderTag: string, signal: AbortSignal): Promise<OperationIntent>;
|
|
103
|
+
/**
|
|
104
|
+
* Claims an admitted kernel read for dispatch: under the admit lock, the run claim is checked
|
|
105
|
+
* again, the row must be this read's (same actor, conversation, run and execution, no tool
|
|
106
|
+
* call) and still admitted before its deadline, and the authority is resolved again: a scope
|
|
107
|
+
* that changed since admission refuses.
|
|
108
|
+
*/
|
|
109
|
+
claimKernelRead(ctx: SandboxUseContext, read: KernelReadInvocation, id: string, method: KernelReadMethod, input: {
|
|
110
|
+
path: string;
|
|
111
|
+
}): Promise<OperationIntent>;
|
|
112
|
+
claimBrowse(ctx: {
|
|
113
|
+
orgId: string;
|
|
114
|
+
deviceId: string;
|
|
115
|
+
accountId: string;
|
|
116
|
+
}, id: string): Promise<OperationIntent>;
|
|
117
|
+
private assertIdentity;
|
|
118
|
+
read(id: string): Promise<OperationIntent>;
|
|
119
|
+
admit(ctx: SandboxUseContext, invocation: OperationInvocation): Promise<OperationIntent>;
|
|
120
|
+
claimDispatch(ctx: SandboxUseContext, invocation: OperationInvocation, holderTag: string, background?: BackgroundDispatchBinding): Promise<OperationIntent>;
|
|
121
|
+
/**
|
|
122
|
+
* Binds a managed task's reservation to its admitted start in the dispatch transaction: the
|
|
123
|
+
* operation, per-method input hash, run claim, task-owned tag, exact instance and generation,
|
|
124
|
+
* starting profile/ceiling revisions, grant locator and network authority. Conditional on the
|
|
125
|
+
* reservation still being `pending`, running and not claimed by a stop, and on the persisted
|
|
126
|
+
* working root, artifact and retention matching the start input. False: nothing dispatches; a
|
|
127
|
+
* stop's claim settles the reservation as `stopped`.
|
|
128
|
+
*/
|
|
129
|
+
private bindBackgroundDispatch;
|
|
130
|
+
/**
|
|
131
|
+
* Records a typed start result. A current dispatch (the same execution claim, or a recovery
|
|
132
|
+
* claim) moves the intent to `background-running` and the task to `acknowledged` together; the
|
|
133
|
+
* intent stays live revocable authority and is never completed like a foreground call. When a
|
|
134
|
+
* writer revoked the intent first, or a stop claimed the task, the ref is attached to the
|
|
135
|
+
* already owed cancellation (`cancel-pending`) and the exact revoke is enqueued; the revoked
|
|
136
|
+
* intent is never resurrected. The launching run need not still be running.
|
|
137
|
+
*/
|
|
138
|
+
acknowledgeBackground(id: string, executionId: string, result: SandboxExecutionRef, instanceId: string): Promise<BackgroundAcknowledgement>;
|
|
139
|
+
/**
|
|
140
|
+
* A task-specific recovery claim for a start whose acknowledgement was lost: a new durable
|
|
141
|
+
* execution identity (never a borrowed run or holder token) that may only ask the provider about
|
|
142
|
+
* the same operation and input. Only a start its dispatcher itself left `started-or-unknown` is
|
|
143
|
+
* taken over; a `dispatching` one still has a live (or not yet proven dead) holder. A task a stop
|
|
144
|
+
* claimed, or that is no longer a running dispatched task, is never started: the intent is
|
|
145
|
+
* revoked and the exact revoke (the operation tombstone) owed instead. Null: nothing to start.
|
|
146
|
+
*/
|
|
147
|
+
claimBackgroundRecovery(id: string): Promise<OperationIntent | null>;
|
|
148
|
+
/**
|
|
149
|
+
* Whether a possibly dispatched start (its task row locked by the caller) may still be sent to
|
|
150
|
+
* the provider: its task still runs `dispatched` and no stop asked for it. Otherwise nothing is
|
|
151
|
+
* started: the intent is revoked with an unknown outcome, the exact revoke (the operation
|
|
152
|
+
* tombstone) owed, and a running dispatched task becomes `cancel-pending`.
|
|
153
|
+
*/
|
|
154
|
+
private dispatchStillWanted;
|
|
155
|
+
/** Revokes a possibly dispatched start; its outcome stays unknown and the exact revoke owed. */
|
|
156
|
+
private revokeUnknownLocked;
|
|
157
|
+
/**
|
|
158
|
+
* The kernel refused a start before dispatching it (the artifact or runtime checks on the
|
|
159
|
+
* admitted scope): recorded as a pre-effect failure, the reservation settled `failed`. Only an
|
|
160
|
+
* `admitted` intent of the current claim; anything else is left as it is.
|
|
161
|
+
*/
|
|
162
|
+
refusePreDispatch(ctx: SandboxUseContext, invocation: OperationInvocation, failure: OperationFailure): Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* The provider refused a recovered start with a typed pre-effect error for this exact operation
|
|
165
|
+
* (it owns the identity, so a launched operation would have returned its ref): a failure.
|
|
166
|
+
*/
|
|
167
|
+
settleBackgroundRefusal(id: string, executionId: string, failure: OperationFailure): Promise<void>;
|
|
168
|
+
private settleFailureLocked;
|
|
169
|
+
/**
|
|
170
|
+
* Gives up on an unknown start (its retention ended, or the kernel would not send it again): the
|
|
171
|
+
* task becomes terminal `lost` (`launch_unknown`), freeing its slot of `maxTasks`, while the
|
|
172
|
+
* intent is revoked with an unknown outcome so the exact revoke (the operation tombstone) stays
|
|
173
|
+
* owed. A reservation that never dispatched settles as a pre-effect failure instead.
|
|
174
|
+
*/
|
|
175
|
+
abandonBackgroundLaunch(id: string, why: string): Promise<void>;
|
|
176
|
+
/** The recorded input of an operation (for a same-identity retry only). */
|
|
177
|
+
input(row: OperationIntent): Promise<unknown>;
|
|
178
|
+
/**
|
|
179
|
+
* A deferred recovery check: a new deterministic persisted attempt with exponential backoff
|
|
180
|
+
* (30 s doubling, at most an hour), while the start is still unresolved and retained. The
|
|
181
|
+
* retention expiry job settles what is never resolved.
|
|
182
|
+
*/
|
|
183
|
+
deferBackgroundRecovery(id: string): Promise<void>;
|
|
184
|
+
complete(id: string, executionId: string, result: unknown): Promise<void>;
|
|
185
|
+
result(row: OperationIntent): Promise<unknown>;
|
|
186
|
+
/**
|
|
187
|
+
* The dispatcher with `executionId` gave up on its dispatch: its outcome is unknown. Fenced by
|
|
188
|
+
* the execution, so a superseded dispatcher never clears a newer retry's `dispatching` marker
|
|
189
|
+
* (without `executionId`: the orphan cleanup of the reconcile job).
|
|
190
|
+
*/
|
|
191
|
+
unknown(id: string, executionId?: string): Promise<void>;
|
|
192
|
+
/** Recovery never borrows a holder token. Only a new live run claim can reconcile by ID. */
|
|
193
|
+
claimReconciliation(ctx: SandboxUseContext, invocation: OperationInvocation, instance: OperationInstance, method: SandboxAuthorityOperation, input: unknown, holderTag: string): Promise<OperationIntent>;
|
|
194
|
+
private scheduleExpiry;
|
|
195
|
+
/** Keep the consumed ID/hash and cleanup obligations; expired bytes cannot authorize replay. */
|
|
196
|
+
expirePayload(id: string): Promise<void>;
|
|
197
|
+
/** Cleanup association only: a claimed dead holder can never authorize dispatch. */
|
|
198
|
+
revokeHolders(deviceId: string, tokens: readonly string[]): Promise<void>;
|
|
199
|
+
/**
|
|
200
|
+
* A disconnected or still-pending revoke remains owed; every retry is a new deterministic
|
|
201
|
+
* persisted attempt, backing off (30 s doubling, at most an hour) so an obligation that only
|
|
202
|
+
* retirement can resolve (a lost or replaced instance) never spins.
|
|
203
|
+
*/
|
|
204
|
+
deferRevocation(id: string): Promise<void>;
|
|
205
|
+
acknowledgeRevocation(id: string): Promise<void>;
|
|
206
|
+
}
|