@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
|
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { randomUUID } from "node:crypto";
|
|
11
11
|
import { isDeepStrictEqual } from "node:util";
|
|
12
12
|
import { connectorToolKey, parseToolKey, validateAllowHost, } from "@capybara-hq/plugin-sdk";
|
|
13
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
13
|
+
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
14
14
|
import { sql } from "kysely";
|
|
15
15
|
import { normalizeStoredDefinition } from "../agents/definition.js";
|
|
16
16
|
import { EventLog } from "../conversations/event-log.js";
|
|
@@ -23,7 +23,7 @@ import { sha256Hex } from "../identity/hash.js";
|
|
|
23
23
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
24
24
|
import { afterCommit } from "../infra/database/after-commit.js";
|
|
25
25
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
26
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
26
|
+
import { TransactionHost, withOrderedLocks, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
|
|
27
27
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
28
28
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
29
29
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
@@ -33,6 +33,8 @@ import { pendingPolicyOpsOf } from "../local-devices/policy-summary.js";
|
|
|
33
33
|
import { ORG_ROLES, roleAtLeast } from "../orgs/roles.js";
|
|
34
34
|
import { RunResume } from "../runtime/run-jobs.js";
|
|
35
35
|
import { rootConversationOf } from "../runtime/subagents/child.js";
|
|
36
|
+
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
37
|
+
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
36
38
|
import { isSessionGrantableRule } from "../sandbox/review/types.js";
|
|
37
39
|
import { deviceNotFound, SandboxService } from "../sandbox/sandbox.service.js";
|
|
38
40
|
import { readScheduleSettings } from "../schedules/effective-settings.js";
|
|
@@ -121,6 +123,8 @@ function toRecord(r) {
|
|
|
121
123
|
requestedFor: r.requested_for,
|
|
122
124
|
approverRole: isRole(r.approver_role) ? r.approver_role : null,
|
|
123
125
|
status: r.status,
|
|
126
|
+
supersededRevision: r.superseded_revision,
|
|
127
|
+
supersededReason: r.superseded_reason,
|
|
124
128
|
scope: r.scope,
|
|
125
129
|
decidedBy: r.decided_by,
|
|
126
130
|
decidedAt: r.decided_at === null ? null : iso(r.decided_at),
|
|
@@ -168,6 +172,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
168
172
|
lockService;
|
|
169
173
|
sandbox;
|
|
170
174
|
resumes;
|
|
175
|
+
permissionLocks;
|
|
176
|
+
permissionGrants;
|
|
171
177
|
constructor(db, config, eventLog, events, txHost, schedules,
|
|
172
178
|
/** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
|
|
173
179
|
registry,
|
|
@@ -181,7 +187,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
181
187
|
/** A trial run's 「这次允许」 becomes a task grant only within the org's egress. */
|
|
182
188
|
sandbox,
|
|
183
189
|
/** A decision resumes its waiting run in the decision's transaction. */
|
|
184
|
-
resumes) {
|
|
190
|
+
resumes, permissionLocks, permissionGrants) {
|
|
185
191
|
this.db = db;
|
|
186
192
|
this.config = config;
|
|
187
193
|
this.eventLog = eventLog;
|
|
@@ -193,6 +199,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
193
199
|
this.lockService = lockService;
|
|
194
200
|
this.sandbox = sandbox;
|
|
195
201
|
this.resumes = resumes;
|
|
202
|
+
this.permissionLocks = permissionLocks;
|
|
203
|
+
this.permissionGrants = permissionGrants;
|
|
196
204
|
}
|
|
197
205
|
/**
|
|
198
206
|
* 新建 pending 审批(`expires_at` = 现在 + `tools.approvalTimeoutHours`)并写 `approval_requested`,同一事务。
|
|
@@ -294,7 +302,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
294
302
|
async requestNetworkIn(input) {
|
|
295
303
|
const hours = this.config.get().tools.approvalTimeoutHours;
|
|
296
304
|
const t = this.db.db;
|
|
297
|
-
// the conversation row
|
|
305
|
+
// Authority precedes the conversation row (as `requestIn`): it also serializes two asks of one call
|
|
298
306
|
await t
|
|
299
307
|
.selectFrom("conversations")
|
|
300
308
|
.select("id")
|
|
@@ -389,7 +397,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
389
397
|
async requestGitIn(input) {
|
|
390
398
|
const hours = this.config.get().tools.approvalTimeoutHours;
|
|
391
399
|
const t = this.db.db;
|
|
392
|
-
// the conversation row
|
|
400
|
+
// Authority precedes the conversation row (as `requestIn`): it also serializes two asks of one call
|
|
393
401
|
await t
|
|
394
402
|
.selectFrom("conversations")
|
|
395
403
|
.select("id")
|
|
@@ -480,15 +488,32 @@ let ApprovalsService = class ApprovalsService {
|
|
|
480
488
|
if (d.command.length === 0 || d.reason.length === 0) {
|
|
481
489
|
throw new Error("a command ask names the command and the review's reason");
|
|
482
490
|
}
|
|
483
|
-
const
|
|
491
|
+
const subject = await this.commandSubject(input.orgId, input.conversationId, input.detail.deviceId);
|
|
492
|
+
const permissionLocks = this.permissionLocks;
|
|
493
|
+
const { record, toSeq } = permissionLocks
|
|
494
|
+
? await withTransactionFencePrelude(() => permissionLocks.acquire(subject, { kind: "admit" }), () => this.requestCommandIn(input))
|
|
495
|
+
: await this.requestCommandIn(input);
|
|
484
496
|
if (toSeq !== null)
|
|
485
497
|
await this.eventLog.notify(record.conversationId, toSeq);
|
|
486
498
|
return record;
|
|
487
499
|
}
|
|
488
500
|
async requestCommandIn(input) {
|
|
501
|
+
if (input.detail.permissionCandidate) {
|
|
502
|
+
const b = input.detail.permissionCandidate.binding;
|
|
503
|
+
if (b.orgId !== input.orgId ||
|
|
504
|
+
b.conversationId !== input.conversationId ||
|
|
505
|
+
b.runId !== input.runId ||
|
|
506
|
+
b.callId !== input.callId ||
|
|
507
|
+
b.accountId !== input.requestedFor ||
|
|
508
|
+
b.deviceId !== input.detail.deviceId)
|
|
509
|
+
throw new ApiError("forbidden", "The approval does not match its exact permission candidate");
|
|
510
|
+
if (!this.permissionGrants)
|
|
511
|
+
throw new Error("Permission grants are unavailable");
|
|
512
|
+
await this.permissionGrants.assertCurrent(b);
|
|
513
|
+
}
|
|
489
514
|
const hours = this.config.get().tools.approvalTimeoutHours;
|
|
490
515
|
const t = this.db.db;
|
|
491
|
-
// the conversation row
|
|
516
|
+
// Authority precedes the conversation row (as `requestIn`): it also serializes two asks of one call
|
|
492
517
|
await t
|
|
493
518
|
.selectFrom("conversations")
|
|
494
519
|
.select("id")
|
|
@@ -501,7 +526,11 @@ let ApprovalsService = class ApprovalsService {
|
|
|
501
526
|
throw new Error(`a command ask is for the owner of a live device of the org (device ${input.detail.deviceId})`);
|
|
502
527
|
}
|
|
503
528
|
const existing = await this.commandForCall(input.runId, input.callId);
|
|
504
|
-
if (existing !== null
|
|
529
|
+
if (existing !== null &&
|
|
530
|
+
existing.status !== "superseded" &&
|
|
531
|
+
(!input.detail.permissionCandidate ||
|
|
532
|
+
existing.command?.permissionCandidate?.candidateHash ===
|
|
533
|
+
input.detail.permissionCandidate.candidateHash))
|
|
505
534
|
return { record: existing, toSeq: null };
|
|
506
535
|
const last = await t
|
|
507
536
|
.selectFrom("approvals")
|
|
@@ -509,7 +538,19 @@ let ApprovalsService = class ApprovalsService {
|
|
|
509
538
|
.where("run_id", "=", input.runId)
|
|
510
539
|
.where("call_id", "=", input.callId)
|
|
511
540
|
.executeTakeFirst();
|
|
512
|
-
const
|
|
541
|
+
const candidate = input.detail.permissionCandidate;
|
|
542
|
+
const detail = {
|
|
543
|
+
...input.detail,
|
|
544
|
+
...(candidate
|
|
545
|
+
? {
|
|
546
|
+
permissionScope: candidate.permissionScope,
|
|
547
|
+
candidateHash: candidate.candidateHash,
|
|
548
|
+
...(candidate.targetPath
|
|
549
|
+
? { targetPath: candidate.targetPath, path: candidate.targetPath }
|
|
550
|
+
: {}),
|
|
551
|
+
}
|
|
552
|
+
: {}),
|
|
553
|
+
};
|
|
513
554
|
const row = await t
|
|
514
555
|
.insertInto("approvals")
|
|
515
556
|
.values({
|
|
@@ -547,6 +588,15 @@ let ApprovalsService = class ApprovalsService {
|
|
|
547
588
|
toolKey: rec.toolKey,
|
|
548
589
|
expiresAt: rec.expiresAt,
|
|
549
590
|
command: {
|
|
591
|
+
...(detail.permissionCandidate
|
|
592
|
+
? {
|
|
593
|
+
permissionScope: detail.permissionCandidate.permissionScope,
|
|
594
|
+
candidateHash: detail.permissionCandidate.candidateHash,
|
|
595
|
+
...(detail.permissionCandidate.targetPath
|
|
596
|
+
? { targetPath: detail.permissionCandidate.targetPath }
|
|
597
|
+
: {}),
|
|
598
|
+
}
|
|
599
|
+
: {}),
|
|
550
600
|
kind: detail.kind,
|
|
551
601
|
// the approval's detail holds the whole command; the event is display only and clamped
|
|
552
602
|
command: clipText(detail.command, COMMAND_ASK_TEXT_MAX_CHARS),
|
|
@@ -823,10 +873,22 @@ let ApprovalsService = class ApprovalsService {
|
|
|
823
873
|
}
|
|
824
874
|
command = { scope, via };
|
|
825
875
|
}
|
|
826
|
-
const
|
|
876
|
+
const decide = () => this.decideIn(orgId, id, accountId, body, actorTokenId, undefined, undefined, command);
|
|
877
|
+
const subject = await this.commandSubject(orgId, ask.conversationId, ask.command.deviceId);
|
|
878
|
+
const permissionLocks = this.permissionLocks;
|
|
879
|
+
const decided = permissionLocks
|
|
880
|
+
? await withTransactionFencePrelude(() => permissionLocks.acquire(subject, { kind: "admit" }), decide)
|
|
881
|
+
: await decide();
|
|
827
882
|
await this.announceDecided(decided.record, decided.toSeq);
|
|
828
883
|
return decided.record;
|
|
829
884
|
}
|
|
885
|
+
async commandSubject(orgId, conversationId, deviceId) {
|
|
886
|
+
return {
|
|
887
|
+
orgId,
|
|
888
|
+
deviceId,
|
|
889
|
+
rootConversationId: await rootConversationOf(this.db.db, conversationId),
|
|
890
|
+
};
|
|
891
|
+
}
|
|
830
892
|
/**
|
|
831
893
|
* 「这台设备一直允许」 (transactional outbox spec §7): the intent of the device change (naming the
|
|
832
894
|
* ask) is recorded, the `policy` op sent (no transaction open), then {@link settleNetworkOp}
|
|
@@ -883,7 +945,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
883
945
|
? // the device's owner takes no remote grants: nothing is allowed, not even this run
|
|
884
946
|
{ wanted: granted, granted: [], outcome: "refused", fallback: "refused", via }
|
|
885
947
|
: { wanted: granted, granted, outcome: "once_fallback", fallback: "offline", via };
|
|
886
|
-
const settled = await this.
|
|
948
|
+
const settled = await this.settleNetworkOpOrdered(orgId, ask.id, accountId, body, network, {
|
|
887
949
|
machineId: intent.machineId,
|
|
888
950
|
opId: intent.opId,
|
|
889
951
|
result: sent.result,
|
|
@@ -922,6 +984,14 @@ let ApprovalsService = class ApprovalsService {
|
|
|
922
984
|
async settleOpOnly(op, result) {
|
|
923
985
|
await this.policies.settleIn(op, result);
|
|
924
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* {@link settleNetworkOp} with the device's permission authority lock as its ordered prelude
|
|
989
|
+
* (`DevicePolicyService.lockMachineDevice`): the global order puts it before the ask's
|
|
990
|
+
* conversation row, as a fenced device writer of the same tree takes it (device project writes).
|
|
991
|
+
*/
|
|
992
|
+
settleNetworkOpOrdered(orgId, id, accountId, body, network, op) {
|
|
993
|
+
return withOrderedLocks(() => this.policies.lockMachineDevice(op.machineId), () => this.settleNetworkOp(orgId, id, accountId, body, network, op));
|
|
994
|
+
}
|
|
925
995
|
/**
|
|
926
996
|
* The resolve transaction of a network ask's device change: the ask decided as `network` says
|
|
927
997
|
* ({@link decideTx}: lock order conversation → approval → run), then the op's outcome recorded
|
|
@@ -1006,7 +1076,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1006
1076
|
* late) and the ask left pending with `applied_undecided`. Not applied (refused, never received,
|
|
1007
1077
|
* interrupted) or still unknown → the op's outcome recorded and the ask left pending with the
|
|
1008
1078
|
* reason (`detail.attempt`) and an `approval_updated` event so the card shows it: no person is
|
|
1009
|
-
* there to fall back to a run grant (D2).
|
|
1079
|
+
* there to fall back to a run grant (D2). The caller locked the machine's device first
|
|
1080
|
+
* (`DevicePolicyService.lockMachineDevice`, before the ask's conversation row).
|
|
1010
1081
|
*/
|
|
1011
1082
|
async settleFromResolver(ref, result) {
|
|
1012
1083
|
const t = this.db.db;
|
|
@@ -1168,6 +1239,11 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1168
1239
|
(before.kind === "command") !== (command !== undefined)) {
|
|
1169
1240
|
throw new Error(`approval ${id} is of kind ${before.kind}`);
|
|
1170
1241
|
}
|
|
1242
|
+
if (before.command?.permissionCandidate) {
|
|
1243
|
+
if (!this.permissionGrants)
|
|
1244
|
+
throw new Error("Permission grants are unavailable");
|
|
1245
|
+
await this.permissionGrants.assertCurrent(before.command.permissionCandidate.binding);
|
|
1246
|
+
}
|
|
1171
1247
|
const approved = body.decision === "approve";
|
|
1172
1248
|
const reason = approved ? undefined : body.reason?.trim() || undefined;
|
|
1173
1249
|
const scope = !approved
|
|
@@ -1224,6 +1300,15 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1224
1300
|
.where("id", "=", id)
|
|
1225
1301
|
.returningAll()
|
|
1226
1302
|
.executeTakeFirstOrThrow();
|
|
1303
|
+
if (approved && before.command?.permissionCandidate) {
|
|
1304
|
+
if (!this.permissionGrants)
|
|
1305
|
+
throw new Error("Permission grants are unavailable");
|
|
1306
|
+
await this.permissionGrants.issueLocked(before.command.permissionCandidate, {
|
|
1307
|
+
source: "human",
|
|
1308
|
+
approvalId: id,
|
|
1309
|
+
decidedBy: accountId,
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1227
1312
|
// 授权绑定所批准的定义指纹与来源连接器(同 slug 重新安装的连接器 id 不同,不继承)
|
|
1228
1313
|
const hash = before.specHash;
|
|
1229
1314
|
const connectorId = before.connectorId;
|
|
@@ -1357,8 +1442,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1357
1442
|
...(reason !== undefined && { reason }),
|
|
1358
1443
|
},
|
|
1359
1444
|
});
|
|
1360
|
-
//
|
|
1361
|
-
|
|
1445
|
+
// The decision owes continuation in its own commit, even if this process dies immediately.
|
|
1446
|
+
await this.resumes.resumeIn(before.runId, id);
|
|
1362
1447
|
return { record: toRecord(updated), toSeq: Math.max(...written.map((e) => e.seq)) };
|
|
1363
1448
|
}
|
|
1364
1449
|
await audit(t, {
|
|
@@ -1392,14 +1477,6 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1392
1477
|
await this.resumes.resumeIn(before.runId, id);
|
|
1393
1478
|
return { record: toRecord(updated), toSeq: Math.max(...written.map((e) => e.seq)) };
|
|
1394
1479
|
}
|
|
1395
|
-
/**
|
|
1396
|
-
* Resumes the run of a decided command ask in its own transaction after the decision committed
|
|
1397
|
-
* (`afterCommit` runs outside any transaction; `RunResume.resumeIn` requires one). Its outcome
|
|
1398
|
-
* is the suspend's re-check if the run was still running.
|
|
1399
|
-
*/
|
|
1400
|
-
async resumeDecided(runId, approvalId) {
|
|
1401
|
-
await this.resumes.resumeIn(runId, approvalId);
|
|
1402
|
-
}
|
|
1403
1480
|
/**
|
|
1404
1481
|
* A trial run of a scheduled task (scheduled tasks spec §7): an approval its creator granted, in
|
|
1405
1482
|
* any scope, is also added to the task's grants with the approved definition's hash, so its
|
|
@@ -2041,9 +2118,6 @@ __decorate([
|
|
|
2041
2118
|
__decorate([
|
|
2042
2119
|
Transactional({ propagation: "mandatory" })
|
|
2043
2120
|
], ApprovalsService.prototype, "decideTx", null);
|
|
2044
|
-
__decorate([
|
|
2045
|
-
Transactional()
|
|
2046
|
-
], ApprovalsService.prototype, "resumeDecided", null);
|
|
2047
2121
|
__decorate([
|
|
2048
2122
|
Transactional({ propagation: "mandatory" })
|
|
2049
2123
|
], ApprovalsService.prototype, "keepTrialGrant", null);
|
|
@@ -2083,6 +2157,10 @@ ApprovalsService = __decorate([
|
|
|
2083
2157
|
__param(7, Inject(DevicePolicyService)),
|
|
2084
2158
|
__param(8, Inject(LockService)),
|
|
2085
2159
|
__param(9, Inject(SandboxService)),
|
|
2086
|
-
__param(10, Inject(RunResume))
|
|
2160
|
+
__param(10, Inject(RunResume)),
|
|
2161
|
+
__param(11, Optional()),
|
|
2162
|
+
__param(11, Inject(PermissionAuthorityLock)),
|
|
2163
|
+
__param(12, Optional()),
|
|
2164
|
+
__param(12, Inject(PermissionCallGrants))
|
|
2087
2165
|
], ApprovalsService);
|
|
2088
2166
|
export { ApprovalsService };
|
|
@@ -14,11 +14,14 @@ import { AgentDocs } from "../../platform/agent-docs.js";
|
|
|
14
14
|
import { PlatformOperations } from "../../platform/registry.js";
|
|
15
15
|
import type { HookRunner } from "../../runtime/hook-calls.js";
|
|
16
16
|
import { StepLog } from "../../runtime/step-log.js";
|
|
17
|
+
import { LegacyRetirementStore } from "../../sandbox/legacy-retirement.js";
|
|
18
|
+
import { type ManagedDeviceContextPort, ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
|
|
17
19
|
import { SandboxService } from "../../sandbox/sandbox.service.js";
|
|
18
20
|
import { ScheduledTaskStore } from "../../schedules/store.js";
|
|
19
21
|
import { StorageService } from "../../storage/storage.service.js";
|
|
20
22
|
import { ToolOutputs } from "../outputs.js";
|
|
21
23
|
import type { BuiltinTool } from "../registry.js";
|
|
24
|
+
import type { SandboxToolDeps } from "./sandbox/common.js";
|
|
22
25
|
import { ScheduleToolsPort, ScheduleUpdates } from "./schedules.js";
|
|
23
26
|
import { WebPages } from "./web/index.js";
|
|
24
27
|
/**
|
|
@@ -33,7 +36,9 @@ export declare class BuiltinTools {
|
|
|
33
36
|
/** The WebFetch extraction call: the `web_fetch` purpose, its hooks, usage and denials. */
|
|
34
37
|
purposes: ModelPurposesService, host: {
|
|
35
38
|
readonly hooks?: HookRunner;
|
|
36
|
-
} | undefined, stepLog: StepLog, log: Logger, background: BackgroundTaskStore, finisher: BackgroundTaskFinisher, stopper: BackgroundTaskStopper,
|
|
39
|
+
} | undefined, stepLog: StepLog, log: Logger, background: BackgroundTaskStore, finisher: BackgroundTaskFinisher, stopper: BackgroundTaskStopper,
|
|
40
|
+
/** The legacy-launch freeze every legacy background launch checks before dispatch (8.5). */
|
|
41
|
+
legacyLaunch: LegacyRetirementStore, platformOps: PlatformOperations, platformActor: PlatformActor, agentDocs: AgentDocs,
|
|
37
42
|
/** The schedule tools read tasks and grants; their writes go through the task service. */
|
|
38
43
|
scheduleStore: ScheduledTaskStore,
|
|
39
44
|
/** `ScheduleUpdate`'s write: its field change and grant changes in one transaction. */
|
|
@@ -41,7 +46,16 @@ export declare class BuiltinTools {
|
|
|
41
46
|
/** The task service, bound by `SchedulesModule` at start (a registration port: no cycle). */
|
|
42
47
|
schedulePort: ScheduleToolsPort,
|
|
43
48
|
/** The clock `CurrentTime` reads (the run context's clock seam; `Date.now` by default). */
|
|
44
|
-
|
|
49
|
+
/** The managed sandbox route's device context writer (permission context replay spec B3). */
|
|
50
|
+
managedDeviceContext: ManagedDeviceContextRecorder, now?: () => number,
|
|
51
|
+
/** The paired activation gate (one switch with the runtime's request boundary). */
|
|
52
|
+
activation?: boolean);
|
|
45
53
|
/** The builtin tools, in a fixed order. */
|
|
46
54
|
list(): readonly BuiltinTool[];
|
|
47
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The managed device context fields of the builtin sandbox tools' deps (spec B3): the injected
|
|
58
|
+
* writer, required, only when the one activation gate is on; otherwise no keys at all, and the
|
|
59
|
+
* legacy writer stays.
|
|
60
|
+
*/
|
|
61
|
+
export declare function managedSandboxDeps(recorder: ManagedDeviceContextPort, activation: boolean | undefined): Pick<SandboxToolDeps, "managedDeviceContext" | "managedDeviceContextRequired">;
|
|
@@ -28,6 +28,9 @@ import { AgentDocs } from "../../platform/agent-docs.js";
|
|
|
28
28
|
import { PlatformOperations } from "../../platform/registry.js";
|
|
29
29
|
import { conversationTimeZone, RUN_CONTEXT_CLOCK } from "../../runtime/run-context.service.js";
|
|
30
30
|
import { StepLog } from "../../runtime/step-log.js";
|
|
31
|
+
import { LegacyRetirementStore } from "../../sandbox/legacy-retirement.js";
|
|
32
|
+
import { ManagedDeviceContextRecorder, } from "../../sandbox/managed-device-context.js";
|
|
33
|
+
import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../../sandbox/permission-context-types.js";
|
|
31
34
|
import { SandboxService } from "../../sandbox/sandbox.service.js";
|
|
32
35
|
import { ScheduledTaskStore } from "../../schedules/store.js";
|
|
33
36
|
import { StorageService } from "../../storage/storage.service.js";
|
|
@@ -54,7 +57,9 @@ let BuiltinTools = class BuiltinTools {
|
|
|
54
57
|
tools;
|
|
55
58
|
constructor(db, config, outputs, storage, attachments, eventLog, sandbox, devices, points, webPages,
|
|
56
59
|
/** The WebFetch extraction call: the `web_fetch` purpose, its hooks, usage and denials. */
|
|
57
|
-
purposes, host, stepLog, log, background, finisher, stopper,
|
|
60
|
+
purposes, host, stepLog, log, background, finisher, stopper,
|
|
61
|
+
/** The legacy-launch freeze every legacy background launch checks before dispatch (8.5). */
|
|
62
|
+
legacyLaunch, platformOps, platformActor, agentDocs,
|
|
58
63
|
/** The schedule tools read tasks and grants; their writes go through the task service. */
|
|
59
64
|
scheduleStore,
|
|
60
65
|
/** `ScheduleUpdate`'s write: its field change and grant changes in one transaction. */
|
|
@@ -62,11 +67,18 @@ let BuiltinTools = class BuiltinTools {
|
|
|
62
67
|
/** The task service, bound by `SchedulesModule` at start (a registration port: no cycle). */
|
|
63
68
|
schedulePort,
|
|
64
69
|
/** The clock `CurrentTime` reads (the run context's clock seam; `Date.now` by default). */
|
|
65
|
-
|
|
70
|
+
/** The managed sandbox route's device context writer (permission context replay spec B3). */
|
|
71
|
+
managedDeviceContext, now,
|
|
72
|
+
/** The paired activation gate (one switch with the runtime's request boundary). */
|
|
73
|
+
activation) {
|
|
74
|
+
// dormant: the builtins keep the legacy route until the paired activation turns the gate on;
|
|
75
|
+
// then every builtin entering a device (the skill tool too) takes the managed route
|
|
76
|
+
const managed = managedSandboxDeps(managedDeviceContext, activation);
|
|
66
77
|
const sandboxDeps = {
|
|
67
78
|
sandbox,
|
|
68
79
|
devices,
|
|
69
80
|
background,
|
|
81
|
+
legacyLaunch,
|
|
70
82
|
tasks: { finisher, stopper },
|
|
71
83
|
subagents: {
|
|
72
84
|
inTree: async (root, id) => id !== root && (await conversationAncestors(db.db, id)).includes(root),
|
|
@@ -77,6 +89,7 @@ let BuiltinTools = class BuiltinTools {
|
|
|
77
89
|
eventLog,
|
|
78
90
|
config,
|
|
79
91
|
log,
|
|
92
|
+
...managed,
|
|
80
93
|
};
|
|
81
94
|
this.tools = [
|
|
82
95
|
askUserTool({ config }),
|
|
@@ -98,6 +111,7 @@ let BuiltinTools = class BuiltinTools {
|
|
|
98
111
|
attachments,
|
|
99
112
|
eventLog,
|
|
100
113
|
log,
|
|
114
|
+
...managed,
|
|
101
115
|
get db() {
|
|
102
116
|
return db.db;
|
|
103
117
|
},
|
|
@@ -159,13 +173,27 @@ BuiltinTools = __decorate([
|
|
|
159
173
|
__param(14, Inject(BackgroundTaskStore)),
|
|
160
174
|
__param(15, Inject(BackgroundTaskFinisher)),
|
|
161
175
|
__param(16, Inject(BackgroundTaskStopper)),
|
|
162
|
-
__param(17, Inject(
|
|
163
|
-
__param(18, Inject(
|
|
164
|
-
__param(19, Inject(
|
|
165
|
-
__param(20, Inject(
|
|
166
|
-
__param(21, Inject(
|
|
167
|
-
__param(22, Inject(
|
|
168
|
-
__param(23,
|
|
169
|
-
__param(
|
|
176
|
+
__param(17, Inject(LegacyRetirementStore)),
|
|
177
|
+
__param(18, Inject(PlatformOperations)),
|
|
178
|
+
__param(19, Inject(PlatformActor)),
|
|
179
|
+
__param(20, Inject(AgentDocs)),
|
|
180
|
+
__param(21, Inject(ScheduledTaskStore)),
|
|
181
|
+
__param(22, Inject(ScheduleUpdates)),
|
|
182
|
+
__param(23, Inject(ScheduleToolsPort)),
|
|
183
|
+
__param(24, Inject(ManagedDeviceContextRecorder)),
|
|
184
|
+
__param(25, Optional()),
|
|
185
|
+
__param(25, Inject(RUN_CONTEXT_CLOCK)),
|
|
186
|
+
__param(26, Optional()),
|
|
187
|
+
__param(26, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
170
188
|
], BuiltinTools);
|
|
171
189
|
export { BuiltinTools };
|
|
190
|
+
/**
|
|
191
|
+
* The managed device context fields of the builtin sandbox tools' deps (spec B3): the injected
|
|
192
|
+
* writer, required, only when the one activation gate is on; otherwise no keys at all, and the
|
|
193
|
+
* legacy writer stays.
|
|
194
|
+
*/
|
|
195
|
+
export function managedSandboxDeps(recorder, activation) {
|
|
196
|
+
if (!permissionContextActive(activation))
|
|
197
|
+
return {};
|
|
198
|
+
return { managedDeviceContext: recorder, managedDeviceContextRequired: true };
|
|
199
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ExecResult } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import type { BuiltinTool } from "../../registry.js";
|
|
2
|
+
import type { BuiltinCallContext, BuiltinResult, BuiltinTool } from "../../registry.js";
|
|
3
3
|
import { type SandboxToolDeps } from "./common.js";
|
|
4
4
|
/** The command timeout in seconds when `timeout` is not given, at most `sandbox.limits.maxCommandSeconds`. */
|
|
5
5
|
export declare const BASH_DEFAULT_TIMEOUT_SECONDS = 120;
|
|
@@ -7,10 +7,34 @@ export declare const BASH_DEFAULT_TIMEOUT_SECONDS = 120;
|
|
|
7
7
|
export declare const BASH_DESCRIPTION_MAX_CHARS = 120;
|
|
8
8
|
/** bash 结果超过这么多字符即转存(走现有输出存档,模型用 ReadToolOutput 分页读)。 */
|
|
9
9
|
export declare const BASH_SPILL_CHARS = 30000;
|
|
10
|
+
interface BashInput {
|
|
11
|
+
command: string;
|
|
12
|
+
/** Required since UI refresh B; calls recorded before it have none. */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Milliseconds. */
|
|
15
|
+
timeout?: number;
|
|
16
|
+
run_in_background?: boolean;
|
|
17
|
+
}
|
|
10
18
|
/**
|
|
11
19
|
* 命令结果 → 给模型的文本。`budgetClamped`:运行的时限把超时收紧到了 `seconds`(Ruling M20),超时说明改为
|
|
12
20
|
* 指向 `runtime.maxRunSeconds`,而不是让模型加大 timeout。`workspace`: the instance's workspace root.
|
|
13
21
|
*/
|
|
14
22
|
export declare function formatExec(r: ExecResult, seconds: number, budgetClamped?: boolean, workspace?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Managed `Bash` background launch (permission runtime cutover phase 8.2): the tool's background
|
|
25
|
+
* path once the one activation gate is on (B-17); while it is off the protocol-2 launch above
|
|
26
|
+
* stays the active path.
|
|
27
|
+
*
|
|
28
|
+
* Inside the held operation session it reserves the task (or, for a retry of the same run call,
|
|
29
|
+
* reuses the reservation it persisted before: the same task id, artifact, deadline and
|
|
30
|
+
* retention, so the start input and its hash are unchanged), with its artifact at
|
|
31
|
+
* `${workingRoot}/.capybara/tasks/${taskId}.out` under the trusted working root. The start then
|
|
32
|
+
* goes through the operation facade: admitted, bound to the reservation and dispatched under the
|
|
33
|
+
* stable operation id, and acknowledged with its exact typed ref. The output path is told to the
|
|
34
|
+
* model only after the acknowledgement. A refusal before dispatch settles the reservation; an
|
|
35
|
+
* unknown outcome leaves it dispatched for reconciliation under the same identity.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runInBackgroundManaged(deps: SandboxToolDeps, ctx: BuiltinCallContext, input: BashInput): Promise<BuiltinResult>;
|
|
15
38
|
/** 内置工具 `Bash`:在本对话的沙箱里执行命令。 */
|
|
16
39
|
export declare function sandboxBashTool(deps: SandboxToolDeps): BuiltinTool;
|
|
40
|
+
export {};
|