@capybara-hq/kernel 0.1.0-rc.41 → 0.1.0-rc.42
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 +1 -1
- package/dist/config/schema.js +11 -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 +304 -4
- package/dist/conversations/events.js +279 -29
- 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/db/kernel-schema.d.ts +238 -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/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 +31 -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/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/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/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/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/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 +129 -0
- package/dist/sandbox/review/review.service.d.ts +4 -1
- package/dist/sandbox/review/review.service.js +19 -5
- 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/builtins/builtin-tools.d.ts +16 -2
- package/dist/tools/builtins/builtin-tools.js +38 -10
- 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 +2 -2
- 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 +300 -19
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +12 -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/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
|
@@ -7,8 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { isSandboxGoneError, rootsOf } from "@capybara-hq/plugin-sdk";
|
|
11
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
10
|
+
import { DeviceProtocolError, isSandboxGoneError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, rootsOf, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
11
|
+
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
12
|
import { ConversationAccess } from "../conversations/access.js";
|
|
13
13
|
import { EventLog } from "../conversations/event-log.js";
|
|
14
14
|
import { conversationTree } from "../conversations/tree.js";
|
|
@@ -17,13 +17,16 @@ import { ApiError } from "../errors.js";
|
|
|
17
17
|
import { audit } from "../identity/audit.js";
|
|
18
18
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
19
19
|
import { rootConversationOf } from "../runtime/subagents/child.js";
|
|
20
|
-
import {
|
|
20
|
+
import { PERMISSION_CONTEXT_ACTIVATION } from "../sandbox/permission-context-types.js";
|
|
21
|
+
import { retirementPending, SandboxService } from "../sandbox/sandbox.service.js";
|
|
21
22
|
import { UUID_RE } from "../ui/registry.js";
|
|
22
23
|
import { finishedEventKey } from "./finish.js";
|
|
23
24
|
import { TASK_ID_RE, TASKS_DIR } from "./launch.js";
|
|
24
|
-
import {
|
|
25
|
+
import { ManagedInstanceMismatchError, ManagedRefError, onManagedInstance, readerOf, } from "./managed.js";
|
|
26
|
+
import { assembleOutputSuffix, ManagedOutputCapacityError, ManagedOutputUnavailableError, } from "./managed-output.js";
|
|
27
|
+
import { actingAs, legacyBackgroundAllowed } from "./session.js";
|
|
25
28
|
import { BackgroundTaskStopper } from "./stop.js";
|
|
26
|
-
import { BackgroundTaskStore } from "./store.js";
|
|
29
|
+
import { BackgroundTaskStore, isManagedTask, } from "./store.js";
|
|
27
30
|
/** The most bytes of output one read returns. */
|
|
28
31
|
export const OUTPUT_TAIL_MAX_BYTES = 65_536;
|
|
29
32
|
/** The time limit of reading an output (the exec and the wait for the sandbox's lease). */
|
|
@@ -45,7 +48,13 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
45
48
|
eventLog;
|
|
46
49
|
db;
|
|
47
50
|
devices;
|
|
48
|
-
|
|
51
|
+
activation;
|
|
52
|
+
constructor(access, store, stopper, sandbox, eventLog, db, devices,
|
|
53
|
+
/**
|
|
54
|
+
* The paired activation gate: once on, a legacy (SID) task is never read or stopped by a raw
|
|
55
|
+
* exec (the retirement gate owns it); a managed task always goes by its exact ref.
|
|
56
|
+
*/
|
|
57
|
+
activation) {
|
|
49
58
|
this.access = access;
|
|
50
59
|
this.store = store;
|
|
51
60
|
this.stopper = stopper;
|
|
@@ -53,6 +62,7 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
53
62
|
this.eventLog = eventLog;
|
|
54
63
|
this.db = db;
|
|
55
64
|
this.devices = devices;
|
|
65
|
+
this.activation = activation;
|
|
56
66
|
}
|
|
57
67
|
/**
|
|
58
68
|
* The conversation and every sub-agent conversation below it (grandchildren too: their tasks run
|
|
@@ -78,7 +88,9 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
78
88
|
lostReason: task.lostReason,
|
|
79
89
|
startedAt: task.startedAt.toISOString(),
|
|
80
90
|
finishedAt: task.finishedAt === null ? null : task.finishedAt.toISOString(),
|
|
81
|
-
|
|
91
|
+
// a managed task's owed cancellation is a stop in progress too
|
|
92
|
+
stopping: task.status === "running" &&
|
|
93
|
+
(task.stoppingAt !== null || task.launchState === "cancel-pending"),
|
|
82
94
|
};
|
|
83
95
|
}
|
|
84
96
|
async owned(orgId, conversationId, accountId, taskId) {
|
|
@@ -102,6 +114,8 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
102
114
|
*/
|
|
103
115
|
async stop(orgId, conversationId, accountId, taskId, actorTokenId, auditDetail) {
|
|
104
116
|
const task = await this.owned(orgId, conversationId, accountId, taskId);
|
|
117
|
+
// once activated, the stopper refuses a legacy task's stop with the retirement refusal
|
|
118
|
+
// exactly when it would signal its session (BackgroundTaskStopper's paired gate)
|
|
105
119
|
const after = await this.stopper.stop(task, "person");
|
|
106
120
|
await audit(this.db.db, {
|
|
107
121
|
actorAccountId: accountId,
|
|
@@ -169,6 +183,15 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
169
183
|
}
|
|
170
184
|
/** Reads the output from the task's running instance, or says why it cannot. */
|
|
171
185
|
async readLive(orgId, accountId, task, tail) {
|
|
186
|
+
if (isManagedTask(task))
|
|
187
|
+
return this.readManaged(orgId, task, tail);
|
|
188
|
+
// once activated a legacy task's output is never read by a raw exec: a running one is the
|
|
189
|
+
// retirement gate's (its actionable refusal), a finished one answers with its finish summary
|
|
190
|
+
if (!legacyBackgroundAllowed(this.activation)) {
|
|
191
|
+
if (task.status === "running")
|
|
192
|
+
throw retirementPending();
|
|
193
|
+
return { kind: "unavailable", reason: "read_failed" };
|
|
194
|
+
}
|
|
172
195
|
if (task.sid === null || task.sandboxCreatedAt === null || task.deviceId === null) {
|
|
173
196
|
// a reservation the launch has not finished, or a launch that failed
|
|
174
197
|
return {
|
|
@@ -187,7 +210,7 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
187
210
|
const actor = { accountId, conversationId: task.conversationId };
|
|
188
211
|
try {
|
|
189
212
|
const r = await this.sandbox.ifRunning(task.deviceId, { createdAt }, async (p, h, signal) => {
|
|
190
|
-
const res = await actingAs(p, actor).exec(h, {
|
|
213
|
+
const res = await actingAs(p, actor, this.activation).exec(h, {
|
|
191
214
|
command: tailScript(task.id, tail),
|
|
192
215
|
cwd: rootsOf(h).workspace,
|
|
193
216
|
timeoutMs: OUTPUT_READ_TIMEOUT_MS,
|
|
@@ -221,6 +244,71 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
221
244
|
throw e;
|
|
222
245
|
}
|
|
223
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* A managed task's live suffix (permission runtime cutover phase 8.3): by its exact ref on its
|
|
249
|
+
* exact instance only (never resumed, no exec, no path), the metadata total N first, then every
|
|
250
|
+
* byte of the last `tail` bytes before N through bounded reads; N stays the end however the
|
|
251
|
+
* output grows meanwhile. The task's ref is loaded from its authorized row, never supplied.
|
|
252
|
+
*/
|
|
253
|
+
async readManaged(orgId, task, tail) {
|
|
254
|
+
if (task.executionRef === null || task.deviceId === null) {
|
|
255
|
+
return {
|
|
256
|
+
kind: "unavailable",
|
|
257
|
+
reason: task.status === "running" ? "starting" : "not_started",
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (!(await this.sandbox.availableFor(task.deviceId))) {
|
|
261
|
+
return { kind: "unavailable", reason: "unavailable" };
|
|
262
|
+
}
|
|
263
|
+
if (!(await this.deviceUsable(orgId, task.conversationId))) {
|
|
264
|
+
return { kind: "unavailable", reason: "no_access" };
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
const r = await onManagedInstance(this.sandbox.ifRunning.bind(this.sandbox), task, async (bg, h, ref, signal) => {
|
|
268
|
+
try {
|
|
269
|
+
return await assembleOutputSuffix(readerOf(bg, h, ref, signal), tail, signal);
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
if (e instanceof ManagedOutputUnavailableError)
|
|
273
|
+
return null;
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
276
|
+
}, AbortSignal.timeout(OUTPUT_READ_TIMEOUT_MS));
|
|
277
|
+
if (r.kind === "other_instance")
|
|
278
|
+
return { kind: "unavailable", reason: "rebuilt" };
|
|
279
|
+
if (r.kind === "not_running") {
|
|
280
|
+
return { kind: "unavailable", reason: r.status === "suspended" ? "suspended" : "rebuilt" };
|
|
281
|
+
}
|
|
282
|
+
if (r.value === null)
|
|
283
|
+
return { kind: "unavailable", reason: "output_missing" };
|
|
284
|
+
return { kind: "ok", value: { text: r.value.text, truncated: r.value.truncated } };
|
|
285
|
+
}
|
|
286
|
+
catch (e) {
|
|
287
|
+
if (isSandboxGoneError(e))
|
|
288
|
+
return { kind: "unavailable", reason: "rebuilt" };
|
|
289
|
+
if (e instanceof ApiError && e.code.startsWith("device.")) {
|
|
290
|
+
return {
|
|
291
|
+
kind: "unavailable",
|
|
292
|
+
reason: e.code === "device.offline" ? "device_offline" : "no_access",
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
// a provider's typed refusal is no access; the kernel's own instance check, a missing
|
|
296
|
+
// background capability, a protocol or transport failure, a bad ref, capacity or a timeout
|
|
297
|
+
// is a failed read: never a 500, and a finished task still gets its finish summary
|
|
298
|
+
if (isSandboxScopeDeniedError(e))
|
|
299
|
+
return { kind: "unavailable", reason: "no_access" };
|
|
300
|
+
if (e instanceof ManagedRefError ||
|
|
301
|
+
e instanceof ManagedInstanceMismatchError ||
|
|
302
|
+
e instanceof ManagedOutputCapacityError ||
|
|
303
|
+
isSandboxPermissionUnsupportedError(e) ||
|
|
304
|
+
e instanceof DeviceProtocolError ||
|
|
305
|
+
e instanceof ToolError ||
|
|
306
|
+
(e instanceof Error && (e.name === "TimeoutError" || e.name === "AbortError"))) {
|
|
307
|
+
return { kind: "unavailable", reason: "read_failed" };
|
|
308
|
+
}
|
|
309
|
+
throw e;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
224
312
|
};
|
|
225
313
|
BackgroundTasks = __decorate([
|
|
226
314
|
Injectable(),
|
|
@@ -230,7 +318,9 @@ BackgroundTasks = __decorate([
|
|
|
230
318
|
__param(3, Inject(SandboxService)),
|
|
231
319
|
__param(4, Inject(EventLog)),
|
|
232
320
|
__param(5, Inject(KernelDb)),
|
|
233
|
-
__param(6, Inject(ConversationDevices))
|
|
321
|
+
__param(6, Inject(ConversationDevices)),
|
|
322
|
+
__param(7, Optional()),
|
|
323
|
+
__param(7, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
234
324
|
], BackgroundTasks);
|
|
235
325
|
export { BackgroundTasks };
|
|
236
326
|
/**
|
|
@@ -188,7 +188,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
188
188
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
189
189
|
export declare const HOST_VERSIONS: {
|
|
190
190
|
readonly kernel: string;
|
|
191
|
-
readonly sdk: "0.1.0-rc.
|
|
191
|
+
readonly sdk: "0.1.0-rc.31";
|
|
192
192
|
};
|
|
193
193
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
194
194
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
package/dist/channels/cards.js
CHANGED
|
@@ -279,7 +279,7 @@ export async function approvalCard(d, approvalId, base, locale, redact) {
|
|
|
279
279
|
scopeLabels: Object.fromEntries(Object.entries(special.scopeLabels).filter(([k]) => v.scopes.includes(k))),
|
|
280
280
|
}),
|
|
281
281
|
expiresAt: v.expiresAt,
|
|
282
|
-
state: v.status,
|
|
282
|
+
state: v.status === "superseded" ? "cancelled" : v.status,
|
|
283
283
|
...(decidedBy !== undefined && { decidedBy }),
|
|
284
284
|
// a denial's reason, as the web shows it (UI refresh B); redacted like the input
|
|
285
285
|
...(v.status === "denied" &&
|
package/dist/channels/inbound.js
CHANGED
|
@@ -203,6 +203,10 @@ export declare const CHANNEL_PHRASES: {
|
|
|
203
203
|
readonly zh: "项目技能没有运行:这个项目已从设备的项目中移除。你的消息没有发送。";
|
|
204
204
|
readonly en: "The project skill was not run: the project was removed from the device's projects. Your message was not sent.";
|
|
205
205
|
};
|
|
206
|
+
readonly projectSkillToolOff: {
|
|
207
|
+
readonly zh: "项目技能没有运行:这个智能体不能加载项目技能,请为它打开 Skill 工具。你的消息没有发送。";
|
|
208
|
+
readonly en: "The project skill was not run: this agent cannot load project skills; turn on its Skill tool. Your message was not sent.";
|
|
209
|
+
};
|
|
206
210
|
/** 运行被中止(收尾挂着的草稿时附在已有文本之后)。 */
|
|
207
211
|
readonly runStopped: {
|
|
208
212
|
readonly zh: "已停止。";
|
package/dist/channels/phrases.js
CHANGED
|
@@ -165,6 +165,10 @@ export const CHANNEL_PHRASES = {
|
|
|
165
165
|
zh: "项目技能没有运行:这个项目已从设备的项目中移除。你的消息没有发送。",
|
|
166
166
|
en: "The project skill was not run: the project was removed from the device's projects. Your message was not sent.",
|
|
167
167
|
},
|
|
168
|
+
projectSkillToolOff: {
|
|
169
|
+
zh: "项目技能没有运行:这个智能体不能加载项目技能,请为它打开 Skill 工具。你的消息没有发送。",
|
|
170
|
+
en: "The project skill was not run: this agent cannot load project skills; turn on its Skill tool. Your message was not sent.",
|
|
171
|
+
},
|
|
168
172
|
/** 运行被中止(收尾挂着的草稿时附在已有文本之后)。 */
|
|
169
173
|
runStopped: { zh: "已停止。", en: "Stopped." },
|
|
170
174
|
/** 运行失败。 */
|
package/dist/config/load.d.ts
CHANGED
|
@@ -6,6 +6,24 @@ export { ConfigError, type ConfigSource };
|
|
|
6
6
|
export declare function selectConfigSource(env: NodeJS.ProcessEnv): ConfigSource;
|
|
7
7
|
/** 深合并:对象递归合并,其余(含数组)由 override 整体替换。 */
|
|
8
8
|
export declare function deepMerge(base: unknown, override: unknown): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* The permission keys B1 replaced, each with its replacement. Until the old public inputs are
|
|
11
|
+
* removed, {@link translateLegacyPermissionKeys} reads the old key of a source as the new one.
|
|
12
|
+
*/
|
|
13
|
+
export declare const LEGACY_PERMISSION_KEYS: readonly [{
|
|
14
|
+
readonly path: readonly ["devices", "autoMode"];
|
|
15
|
+
readonly replacement: readonly ["devices", "fullAccess"];
|
|
16
|
+
readonly env: "CAPYBARA_DEVICES__AUTO_MODE";
|
|
17
|
+
readonly replacementEnv: "CAPYBARA_DEVICES__FULL_ACCESS";
|
|
18
|
+
}];
|
|
19
|
+
/**
|
|
20
|
+
* Translates the old permission keys of ONE config source (the file / Nacos document, or the
|
|
21
|
+
* environment overrides) to their replacements, before the sources are merged: the old key keeps
|
|
22
|
+
* its source's place in the precedence (env > file / Nacos), never its own. An old and a new key
|
|
23
|
+
* in the same source must agree, else the config fails (never pick the wider one). The value is
|
|
24
|
+
* not checked here: the schema refuses an invalid one under the new key.
|
|
25
|
+
*/
|
|
26
|
+
export declare function translateLegacyPermissionKeys(source: Record<string, unknown>, label: "file" | "env"): Record<string, unknown>;
|
|
9
27
|
/** 原始配置深合并环境变量覆盖(优先级最高)后校验;热更新与启动共用。错误只列路径不列值。 */
|
|
10
28
|
export declare function resolveConfig(raw: unknown, env: NodeJS.ProcessEnv): KernelConfig;
|
|
11
29
|
/** 选来源 → 深合并环境变量覆盖(优先级最高)→ 校验。 */
|
package/dist/config/load.js
CHANGED
|
@@ -63,11 +63,49 @@ export function deepMerge(base, override) {
|
|
|
63
63
|
}
|
|
64
64
|
return out;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The permission keys B1 replaced, each with its replacement. Until the old public inputs are
|
|
68
|
+
* removed, {@link translateLegacyPermissionKeys} reads the old key of a source as the new one.
|
|
69
|
+
*/
|
|
70
|
+
export const LEGACY_PERMISSION_KEYS = [
|
|
71
|
+
{
|
|
72
|
+
path: ["devices", "autoMode"],
|
|
73
|
+
replacement: ["devices", "fullAccess"],
|
|
74
|
+
env: "CAPYBARA_DEVICES__AUTO_MODE",
|
|
75
|
+
replacementEnv: "CAPYBARA_DEVICES__FULL_ACCESS",
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Translates the old permission keys of ONE config source (the file / Nacos document, or the
|
|
80
|
+
* environment overrides) to their replacements, before the sources are merged: the old key keeps
|
|
81
|
+
* its source's place in the precedence (env > file / Nacos), never its own. An old and a new key
|
|
82
|
+
* in the same source must agree, else the config fails (never pick the wider one). The value is
|
|
83
|
+
* not checked here: the schema refuses an invalid one under the new key.
|
|
84
|
+
*/
|
|
85
|
+
export function translateLegacyPermissionKeys(source, label) {
|
|
86
|
+
let out = source;
|
|
87
|
+
for (const key of LEGACY_PERMISSION_KEYS) {
|
|
88
|
+
const [section, old] = key.path;
|
|
89
|
+
const [, next] = key.replacement;
|
|
90
|
+
const parent = out[section];
|
|
91
|
+
if (!isPlainObject(parent) || !(old in parent))
|
|
92
|
+
continue;
|
|
93
|
+
const { [old]: value, ...rest } = parent;
|
|
94
|
+
if (next in rest && rest[next] !== value) {
|
|
95
|
+
const [a, b] = label === "env"
|
|
96
|
+
? [key.env, key.replacementEnv]
|
|
97
|
+
: [key.path.join("."), key.replacement.join(".")];
|
|
98
|
+
throw new ConfigError(`invalid configuration:\n - ${a} and ${b} are both set and differ; remove ${a} (it is replaced by ${b})`);
|
|
99
|
+
}
|
|
100
|
+
out = { ...out, [section]: { ...rest, [next]: rest[next] ?? value } };
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
66
104
|
/** 原始配置深合并环境变量覆盖(优先级最高)后校验;热更新与启动共用。错误只列路径不列值。 */
|
|
67
105
|
export function resolveConfig(raw, env) {
|
|
68
106
|
if (!isPlainObject(raw))
|
|
69
107
|
throw new ConfigError("config file root must be a mapping");
|
|
70
|
-
const merged = deepMerge(raw, envOverrides(env));
|
|
108
|
+
const merged = deepMerge(translateLegacyPermissionKeys(raw, "file"), translateLegacyPermissionKeys(envOverrides(env), "env"));
|
|
71
109
|
const result = KernelConfigSchema.safeParse(merged);
|
|
72
110
|
if (!result.success) {
|
|
73
111
|
// The schema is strict: an unknown key (a typo, or a removed setting) is an error that names
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** What {@link migratePermissionConfigText} did: the converted text and the keys it renamed. */
|
|
2
|
+
export interface PermissionConfigMigration {
|
|
3
|
+
text: string;
|
|
4
|
+
/** `old -> new` per converted key; empty when the document has no old key. */
|
|
5
|
+
changed: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The offline conversion of one config document (a config file, or a Nacos data id's content) to
|
|
9
|
+
* the permission keys B1 introduced (`capybara config migrate-permissions`): every old key is
|
|
10
|
+
* renamed in place to its replacement, so unrelated keys, values, order and comments stay as they
|
|
11
|
+
* were. An old key equal to an already present new key is dropped; a different one, or an invalid
|
|
12
|
+
* old value, is refused (never pick the wider one, never guess). Nothing is read from or written
|
|
13
|
+
* to the environment, PG or Nacos here: applying the result is the operator's reviewed change.
|
|
14
|
+
*/
|
|
15
|
+
export declare function migratePermissionConfigText(text: string): PermissionConfigMigration;
|
|
16
|
+
/** One environment variable the operator must rename before the old one stops being read. */
|
|
17
|
+
export interface PermissionEnvRename {
|
|
18
|
+
from: string;
|
|
19
|
+
to: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The old permission environment variables set in `env`, each with its replacement. The values
|
|
23
|
+
* are never returned (the operator renames the variable and keeps its value). Both set with
|
|
24
|
+
* different values is refused, like the startup config does.
|
|
25
|
+
*/
|
|
26
|
+
export declare function legacyPermissionEnvRenames(env: NodeJS.ProcessEnv): PermissionEnvRename[];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isMap, isScalar, parseDocument } from "yaml";
|
|
2
|
+
import { LEGACY_PERMISSION_KEYS } from "./load.js";
|
|
3
|
+
import { ConfigError } from "./types.js";
|
|
4
|
+
const VALUES = ["allowed", "off"];
|
|
5
|
+
/**
|
|
6
|
+
* The offline conversion of one config document (a config file, or a Nacos data id's content) to
|
|
7
|
+
* the permission keys B1 introduced (`capybara config migrate-permissions`): every old key is
|
|
8
|
+
* renamed in place to its replacement, so unrelated keys, values, order and comments stay as they
|
|
9
|
+
* were. An old key equal to an already present new key is dropped; a different one, or an invalid
|
|
10
|
+
* old value, is refused (never pick the wider one, never guess). Nothing is read from or written
|
|
11
|
+
* to the environment, PG or Nacos here: applying the result is the operator's reviewed change.
|
|
12
|
+
*/
|
|
13
|
+
export function migratePermissionConfigText(text) {
|
|
14
|
+
const doc = parseDocument(text);
|
|
15
|
+
if (doc.errors.length > 0)
|
|
16
|
+
throw new ConfigError("invalid YAML in the config document");
|
|
17
|
+
const changed = [];
|
|
18
|
+
for (const key of LEGACY_PERMISSION_KEYS) {
|
|
19
|
+
const [section, old] = key.path;
|
|
20
|
+
const [, next] = key.replacement;
|
|
21
|
+
const parent = doc.get(section, true);
|
|
22
|
+
if (!isMap(parent) || !parent.has(old))
|
|
23
|
+
continue;
|
|
24
|
+
const from = key.path.join(".");
|
|
25
|
+
const to = key.replacement.join(".");
|
|
26
|
+
const value = parent.get(old);
|
|
27
|
+
if (typeof value !== "string" || !VALUES.includes(value))
|
|
28
|
+
throw new ConfigError(`${from} must be allowed or off; fix it before converting`);
|
|
29
|
+
if (parent.has(next)) {
|
|
30
|
+
if (parent.get(next) !== value)
|
|
31
|
+
throw new ConfigError(`${from} and ${to} are both set and differ; keep one of them before converting`);
|
|
32
|
+
parent.delete(old);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const pair = parent.items.find((p) => (isScalar(p.key) ? p.key.value : p.key) === old);
|
|
36
|
+
if (pair === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
if (isScalar(pair.key))
|
|
39
|
+
pair.key.value = next;
|
|
40
|
+
else
|
|
41
|
+
pair.key = doc.createNode(next);
|
|
42
|
+
}
|
|
43
|
+
changed.push(`${from} -> ${to}`);
|
|
44
|
+
}
|
|
45
|
+
return { text: changed.length === 0 ? text : doc.toString(), changed };
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The old permission environment variables set in `env`, each with its replacement. The values
|
|
49
|
+
* are never returned (the operator renames the variable and keeps its value). Both set with
|
|
50
|
+
* different values is refused, like the startup config does.
|
|
51
|
+
*/
|
|
52
|
+
export function legacyPermissionEnvRenames(env) {
|
|
53
|
+
const out = [];
|
|
54
|
+
for (const key of LEGACY_PERMISSION_KEYS) {
|
|
55
|
+
const old = env[key.env];
|
|
56
|
+
if (old === undefined)
|
|
57
|
+
continue;
|
|
58
|
+
const current = env[key.replacementEnv];
|
|
59
|
+
if (current !== undefined && current !== old)
|
|
60
|
+
throw new ConfigError(`${key.env} and ${key.replacementEnv} are both set and differ; keep one of them`);
|
|
61
|
+
out.push({ from: key.env, to: key.replacementEnv });
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -255,7 +255,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
255
255
|
}, z.core.$strict>>;
|
|
256
256
|
}, z.core.$strict>>;
|
|
257
257
|
devices: z.ZodPrefault<z.ZodObject<{
|
|
258
|
-
|
|
258
|
+
fullAccess: z.ZodOptional<z.ZodEnum<{
|
|
259
259
|
allowed: "allowed";
|
|
260
260
|
off: "off";
|
|
261
261
|
}>>;
|
package/dist/config/schema.js
CHANGED
|
@@ -1475,7 +1475,7 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
1475
1475
|
egress: z
|
|
1476
1476
|
.enum(["none", "allowlist"], {
|
|
1477
1477
|
error: (iss) => iss.input === "open"
|
|
1478
|
-
? 'sandbox.limits.egress does not take "open": the open public network is set by devices.
|
|
1478
|
+
? 'sandbox.limits.egress does not take "open": the open public network is set by devices.fullAccess and an organization\'s cloudNetwork; use "allowlist" or "none"'
|
|
1479
1479
|
: undefined,
|
|
1480
1480
|
})
|
|
1481
1481
|
.default("allowlist")
|
|
@@ -1499,7 +1499,7 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
1499
1499
|
.enum(["extend", "within"])
|
|
1500
1500
|
.default("extend")
|
|
1501
1501
|
.meta(meta({
|
|
1502
|
-
description: "Whether organizations may go beyond allowHosts in sandbox mode: extend (the default: an organization may use the open cloud network and add hosts, and its admins approve network requests) or within (allowHosts is the ceiling: an organization's cloud network in sandbox mode is the allowlist, and it may only keep or drop hosts the list covers; only a super admin adds others). Auto mode is not limited by it: devices.
|
|
1502
|
+
description: "Whether organizations may go beyond allowHosts in sandbox mode: extend (the default: an organization may use the open cloud network and add hosts, and its admins approve network requests) or within (allowHosts is the ceiling: an organization's cloud network in sandbox mode is the allowlist, and it may only keep or drop hosts the list covers; only a super admin adds others). Auto mode is not limited by it: devices.fullAccess governs Full permission's open network, so set devices.fullAccess off as well for a hard ceiling",
|
|
1503
1503
|
})),
|
|
1504
1504
|
})
|
|
1505
1505
|
.prefault({}),
|
|
@@ -1508,19 +1508,20 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
1508
1508
|
devices: z
|
|
1509
1509
|
.strictObject({
|
|
1510
1510
|
/**
|
|
1511
|
-
* The platform's
|
|
1512
|
-
*
|
|
1513
|
-
* in the admin console; the startup config wins over it, so this field
|
|
1514
|
-
* schema default (the default `allowed` is applied by
|
|
1515
|
-
* would be indistinguishable from a value the config
|
|
1516
|
-
*
|
|
1511
|
+
* The platform's Full permission switch (permission runtime cutover B1): whether a device's
|
|
1512
|
+
* owner ceiling may allow Full permission. Also a deployment setting the super admin changes
|
|
1513
|
+
* in the admin console (`devicesFullAccess`); the startup config wins over it, so this field
|
|
1514
|
+
* is optional with no schema default (the default `allowed` is applied by
|
|
1515
|
+
* `readDevicesFullAccess`: a schema default would be indistinguishable from a value the config
|
|
1516
|
+
* source set). The old key `devices.autoMode` (`CAPYBARA_DEVICES__AUTO_MODE`) is translated
|
|
1517
|
+
* per source by `translateLegacyPermissionKeys` until it is removed.
|
|
1517
1518
|
*/
|
|
1518
|
-
|
|
1519
|
+
fullAccess: z
|
|
1519
1520
|
.enum(["allowed", "off"])
|
|
1520
1521
|
.optional()
|
|
1521
1522
|
.meta(meta({
|
|
1522
1523
|
hot: true,
|
|
1523
|
-
description: "Whether devices may run
|
|
1524
|
+
description: "Whether devices may run with Full permission (default allowed): a device whose owner allows Full may then run a conversation with Full permission; a cloud device on Full reaches the open public network (private and internal addresses blocked) unless sandbox.limits.egress is none. When off, devices run restricted: local devices on their allowlist, cloud devices on their organization's cloud network (cloudNetwork). An organization may turn it off and follow the platform. Set here, it is read-only in the admin console. Replaces devices.autoMode (CAPYBARA_DEVICES__AUTO_MODE), which is still read with the same values; capybara config migrate-permissions converts a config file",
|
|
1524
1525
|
})),
|
|
1525
1526
|
maxPersonal: z
|
|
1526
1527
|
.number()
|
|
@@ -83,7 +83,7 @@ declare const MessageBody: z.ZodObject<{
|
|
|
83
83
|
* (project root design §4.3; the device's owner only, refused when the device's current mode
|
|
84
84
|
* cannot read it); without it the conversation runs in free mode.
|
|
85
85
|
*/
|
|
86
|
-
declare const CreateBody: z.ZodObject<{
|
|
86
|
+
export declare const CreateBody: z.ZodObject<{
|
|
87
87
|
agentId: z.ZodString;
|
|
88
88
|
deviceId: z.ZodOptional<z.ZodString>;
|
|
89
89
|
project: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
@@ -112,7 +112,7 @@ const MessageBody = MessageFields.strict().refine(...textRule);
|
|
|
112
112
|
* (project root design §4.3; the device's owner only, refused when the device's current mode
|
|
113
113
|
* cannot read it); without it the conversation runs in free mode.
|
|
114
114
|
*/
|
|
115
|
-
const CreateBody = z
|
|
115
|
+
export const CreateBody = z
|
|
116
116
|
.object({
|
|
117
117
|
agentId: z.string().min(1).max(100),
|
|
118
118
|
deviceId: z.string().min(1).max(100).optional(),
|
|
@@ -10,6 +10,9 @@ import { BackgroundModule } from "../background/background.module.js";
|
|
|
10
10
|
import { DevicesModule } from "../devices/devices.module.js";
|
|
11
11
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
12
12
|
import { RuntimeModule } from "../runtime/runtime.module.js";
|
|
13
|
+
import { OperationAuthorityModule } from "../sandbox/operation-authority.module.js";
|
|
14
|
+
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
15
|
+
import { PermissionFactsModule } from "../sandbox/permission-facts.module.js";
|
|
13
16
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
14
17
|
import { StorageModule } from "../storage/storage.module.js";
|
|
15
18
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
@@ -21,6 +24,8 @@ import { ConversationDeviceStatus } from "./device-status.js";
|
|
|
21
24
|
import { EventLogModule } from "./event-log.js";
|
|
22
25
|
import { ConversationFiles } from "./files.js";
|
|
23
26
|
import { ConversationOutputs } from "./outputs-read.js";
|
|
27
|
+
import { PermissionProfileStoreModule } from "./permission-profile-store.module.js";
|
|
28
|
+
import { PermissionProfilesService } from "./permission-profiles.service.js";
|
|
24
29
|
import { ConversationQueue } from "./queue.service.js";
|
|
25
30
|
/**
|
|
26
31
|
* Conversations: the one {@link ConversationsService} (messages, model switches, skill
|
|
@@ -33,6 +38,10 @@ let ConversationsModule = class ConversationsModule {
|
|
|
33
38
|
ConversationsModule = __decorate([
|
|
34
39
|
Module({
|
|
35
40
|
imports: [
|
|
41
|
+
OperationAuthorityModule,
|
|
42
|
+
PermissionFactsModule,
|
|
43
|
+
PermissionProfileStoreModule,
|
|
44
|
+
PermissionAuthorityModule,
|
|
36
45
|
EventLogModule,
|
|
37
46
|
ConversationAccessModule,
|
|
38
47
|
AttachmentsModule,
|
|
@@ -49,6 +58,7 @@ ConversationsModule = __decorate([
|
|
|
49
58
|
BackgroundModule,
|
|
50
59
|
],
|
|
51
60
|
providers: [
|
|
61
|
+
PermissionProfilesService,
|
|
52
62
|
ConversationsService,
|
|
53
63
|
ConversationQueue,
|
|
54
64
|
ConversationOutputs,
|
|
@@ -57,6 +67,8 @@ ConversationsModule = __decorate([
|
|
|
57
67
|
ConversationDeviceStatus,
|
|
58
68
|
],
|
|
59
69
|
exports: [
|
|
70
|
+
OperationAuthorityModule,
|
|
71
|
+
PermissionProfilesService,
|
|
60
72
|
EventLogModule,
|
|
61
73
|
ConversationAccessModule,
|
|
62
74
|
AttachmentsModule,
|
|
@@ -10,6 +10,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
10
10
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
11
11
|
import { ProviderRegistry } from "../runtime/providers.js";
|
|
12
12
|
import { RunDeletion } from "../runtime/run-deletion.js";
|
|
13
|
+
import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
|
|
13
14
|
import type { ScheduleMarker } from "../schedules/types.js";
|
|
14
15
|
import { type RenderedInvocation, SkillInvoker } from "../skills/invoke.js";
|
|
15
16
|
import { type ApprovalRecord, ApprovalsService } from "../tools/approvals.service.js";
|
|
@@ -21,6 +22,8 @@ import { AttachmentsService } from "./attachments.service.js";
|
|
|
21
22
|
import { EventLog } from "./event-log.js";
|
|
22
23
|
import type { ConversationEvent, LogContentBlock } from "./events.js";
|
|
23
24
|
import { type ImSenderContext } from "./message-context.js";
|
|
25
|
+
import type { PermissionSelection } from "./permission-profiles.schemas.js";
|
|
26
|
+
import { PermissionProfilesService } from "./permission-profiles.service.js";
|
|
24
27
|
import { type Selection } from "./selection.js";
|
|
25
28
|
/** 对外的会话视图。 */
|
|
26
29
|
export interface ConversationView {
|
|
@@ -257,6 +260,8 @@ export interface UserMessageInput {
|
|
|
257
260
|
* source of the message's `timeZone` (`readMessageContext`).
|
|
258
261
|
*/
|
|
259
262
|
export interface InternalMessageOptions {
|
|
263
|
+
initialPermission?: PermissionSelection;
|
|
264
|
+
createRequestHash?: string;
|
|
260
265
|
schedule?: ScheduleMarker;
|
|
261
266
|
timeZoneOverride?: string;
|
|
262
267
|
}
|
|
@@ -273,6 +278,7 @@ export interface NewConversationOptions {
|
|
|
273
278
|
* 不可用时会话也按不存在处理(`conversation.not_found`)。
|
|
274
279
|
*/
|
|
275
280
|
export declare class ConversationsService {
|
|
281
|
+
private readonly permissions;
|
|
276
282
|
private readonly db;
|
|
277
283
|
private readonly eventLog;
|
|
278
284
|
private readonly agents;
|
|
@@ -299,7 +305,8 @@ export declare class ConversationsService {
|
|
|
299
305
|
private readonly approvals;
|
|
300
306
|
private readonly events;
|
|
301
307
|
readonly txHost: TransactionHost;
|
|
302
|
-
|
|
308
|
+
private readonly ceilings;
|
|
309
|
+
constructor(permissions: Pick<PermissionProfilesService, "initialize" | "lockInitial">, db: KernelDb, eventLog: EventLog, agents: Pick<AgentLookup, "get">, access: Pick<ConversationAccess, "isAccessible">,
|
|
303
310
|
/** Starts and stops the conversation's runs. */
|
|
304
311
|
runs: RunControl,
|
|
305
312
|
/** Resolves a switched-to model and its declared parameters (UI refresh B). */
|
|
@@ -319,7 +326,7 @@ export declare class ConversationsService {
|
|
|
319
326
|
/** A starter's message skips the run's pending questions (reply-while-question spec §8.1). */
|
|
320
327
|
questions: Pick<QuestionsService, "skipPendingIn">,
|
|
321
328
|
/** ... and its pending network asks (network ask-to-allow spec §6.7). */
|
|
322
|
-
approvals: Pick<ApprovalsService, "skipNetworkIn">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost);
|
|
329
|
+
approvals: Pick<ApprovalsService, "skipNetworkIn">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost, ceilings: PermissionCeilingWrites);
|
|
323
330
|
/**
|
|
324
331
|
* Creates an empty conversation bound to its device (`pick`, see
|
|
325
332
|
* {@link ConversationDevices.forNew}); an agent the account cannot use →
|
|
@@ -395,6 +402,8 @@ export declare class ConversationsService {
|
|
|
395
402
|
* log, runs and trajectory stay (super admins still see them).
|
|
396
403
|
*/
|
|
397
404
|
remove(orgId: string, conversationId: string, accountId: string): Promise<void>;
|
|
405
|
+
/** The authority subject a deletion locks: the tree's root and its device, read without locks. */
|
|
406
|
+
private deletionSubject;
|
|
398
407
|
private markDeleted;
|
|
399
408
|
/** 读会话:非所有者、或 agent 已对所有者不可用 → `conversation.not_found`。 */
|
|
400
409
|
get(orgId: string, conversationId: string, viewerAccountId: string): Promise<ConversationView>;
|