@capybara-hq/kernel 0.1.0-rc.41 → 0.1.0-rc.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +3 -3
- package/dist/admin/admin.schemas.d.ts +6 -0
- package/dist/admin/org-network.service.d.ts +3 -1
- package/dist/admin/org-network.service.js +10 -2
- package/dist/app.d.ts +4 -0
- package/dist/app.js +2 -0
- package/dist/background/finish.d.ts +9 -1
- package/dist/background/finish.js +57 -4
- package/dist/background/launch.d.ts +23 -0
- package/dist/background/launch.js +55 -1
- package/dist/background/managed-output.d.ts +110 -0
- package/dist/background/managed-output.js +219 -0
- package/dist/background/managed.d.ts +52 -0
- package/dist/background/managed.js +128 -0
- package/dist/background/poll.job.d.ts +35 -1
- package/dist/background/poll.job.js +174 -9
- package/dist/background/render.js +1 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
- package/dist/background/retire-legacy-tasks.job.js +149 -0
- package/dist/background/session.d.ts +15 -5
- package/dist/background/session.js +22 -6
- package/dist/background/stop.d.ts +35 -5
- package/dist/background/stop.js +94 -8
- package/dist/background/store.d.ts +110 -3
- package/dist/background/store.js +205 -3
- package/dist/background/tasks.service.d.ts +18 -1
- package/dist/background/tasks.service.js +99 -9
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/cards.js +1 -1
- package/dist/channels/inbound.js +2 -0
- package/dist/channels/phrases.d.ts +4 -0
- package/dist/channels/phrases.js +4 -0
- package/dist/config/load.d.ts +18 -0
- package/dist/config/load.js +39 -1
- package/dist/config/permission-migration.d.ts +26 -0
- package/dist/config/permission-migration.js +64 -0
- package/dist/config/schema.d.ts +4 -1
- package/dist/config/schema.js +41 -10
- package/dist/conversations/conversations.controller.d.ts +1 -1
- package/dist/conversations/conversations.controller.js +1 -1
- package/dist/conversations/conversations.module.js +12 -0
- package/dist/conversations/conversations.service.d.ts +11 -2
- package/dist/conversations/conversations.service.js +97 -27
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +10 -2
- package/dist/conversations/events.d.ts +307 -4
- package/dist/conversations/events.js +286 -32
- package/dist/conversations/permission-profile-store.d.ts +50 -0
- package/dist/conversations/permission-profile-store.js +67 -0
- package/dist/conversations/permission-profile-store.module.d.ts +2 -0
- package/dist/conversations/permission-profile-store.module.js +19 -0
- package/dist/conversations/permission-profiles.controller.d.ts +84 -0
- package/dist/conversations/permission-profiles.controller.js +105 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
- package/dist/conversations/permission-profiles.schemas.js +23 -0
- package/dist/conversations/permission-profiles.service.d.ts +56 -0
- package/dist/conversations/permission-profiles.service.js +179 -0
- package/dist/ctx/create-ctx.d.ts +12 -5
- package/dist/ctx/create-ctx.js +21 -5
- package/dist/db/kernel-schema.d.ts +248 -3
- package/dist/devices/access.js +1 -1
- package/dist/devices/access.module.d.ts +2 -0
- package/dist/devices/access.module.js +19 -0
- package/dist/devices/conversation-devices.d.ts +8 -29
- package/dist/devices/conversation-devices.js +37 -73
- package/dist/devices/device-projects.service.d.ts +26 -28
- package/dist/devices/device-projects.service.js +123 -127
- package/dist/devices/devices.controller.js +3 -1
- package/dist/devices/devices.module.js +11 -9
- package/dist/devices/devices.service.d.ts +116 -8
- package/dist/devices/devices.service.js +252 -20
- package/dist/devices/dto.d.ts +16 -0
- package/dist/devices/dto.js +34 -6
- package/dist/devices/errors.d.ts +8 -0
- package/dist/devices/errors.js +10 -0
- package/dist/devices/project-rules.d.ts +44 -0
- package/dist/devices/project-rules.js +27 -0
- package/dist/devices/working-root.d.ts +6 -0
- package/dist/devices/working-root.js +12 -1
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +31 -0
- package/dist/evals/reconstruct.d.ts +19 -2
- package/dist/evals/reconstruct.js +40 -2
- package/dist/evals/recorded-permission-context.d.ts +77 -0
- package/dist/evals/recorded-permission-context.js +151 -0
- package/dist/evals/recorded-tools.d.ts +10 -1
- package/dist/evals/recorded-tools.js +27 -3
- package/dist/evals/run-replay.d.ts +8 -2
- package/dist/evals/run-replay.js +18 -2
- package/dist/evals/trajectory.d.ts +1 -1
- package/dist/evals/worker.d.ts +10 -1
- package/dist/evals/worker.js +23 -14
- package/dist/extensions/host.d.ts +4 -1
- package/dist/extensions/host.js +10 -6
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +14 -1
- package/dist/identity/accounts.js +61 -5
- package/dist/identity/identity.module.js +2 -0
- package/dist/identity/settings.d.ts +28 -12
- package/dist/identity/settings.js +89 -33
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
- package/dist/infra/cli/kernel-cli.module.js +5 -2
- package/dist/infra/cli/permission-cutover.d.ts +59 -0
- package/dist/infra/cli/permission-cutover.js +107 -0
- package/dist/infra/config/kernel-config.service.d.ts +2 -2
- package/dist/infra/config/kernel-config.service.js +35 -11
- package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
- package/dist/infra/database/startup-activation-transaction.js +242 -0
- package/dist/infra/database/transaction-host.d.ts +47 -0
- package/dist/infra/database/transaction-host.js +119 -0
- package/dist/infra/database/xact-lock.d.ts +1 -0
- package/dist/infra/database/xact-lock.js +6 -0
- package/dist/infra/outbox/registry.d.ts +39 -0
- package/dist/infra/outbox/registry.js +18 -0
- package/dist/kernel.module.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +55 -28
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +35 -5
- package/dist/local-devices/device-policy.service.js +188 -13
- package/dist/local-devices/instance-bindings.d.ts +82 -0
- package/dist/local-devices/instance-bindings.js +304 -0
- package/dist/local-devices/keys.d.ts +5 -0
- package/dist/local-devices/keys.js +5 -0
- package/dist/local-devices/local-device-gateway.d.ts +19 -4
- package/dist/local-devices/local-device-gateway.js +185 -17
- package/dist/local-devices/local-device-provider.d.ts +42 -7
- package/dist/local-devices/local-device-provider.js +185 -10
- package/dist/local-devices/local-devices.module.d.ts +17 -2
- package/dist/local-devices/local-devices.module.js +49 -8
- package/dist/local-devices/machines.d.ts +35 -12
- package/dist/local-devices/machines.js +203 -8
- package/dist/local-devices/network-grants.js +3 -3
- package/dist/local-devices/network-grants.module.d.ts +2 -0
- package/dist/local-devices/network-grants.module.js +14 -0
- package/dist/local-devices/owner-report.d.ts +79 -0
- package/dist/local-devices/owner-report.js +155 -0
- package/dist/local-devices/owner-reports.d.ts +48 -0
- package/dist/local-devices/owner-reports.js +190 -0
- package/dist/local-devices/policy-summary.d.ts +24 -1
- package/dist/local-devices/policy-summary.js +48 -0
- package/dist/local-devices/relay.d.ts +82 -6
- package/dist/local-devices/relay.js +187 -16
- package/dist/local-devices/targets.d.ts +16 -1
- package/dist/local-devices/targets.js +35 -2
- package/dist/models/image-usable.d.ts +22 -0
- package/dist/models/image-usable.js +29 -0
- package/dist/models/images.d.ts +125 -0
- package/dist/models/images.js +440 -0
- package/dist/models/models.module.d.ts +3 -2
- package/dist/models/models.module.js +16 -5
- package/dist/models/org-models.schemas.js +1 -0
- package/dist/models/purposes.controller.d.ts +7 -0
- package/dist/models/purposes.controller.js +9 -0
- package/dist/models/purposes.d.ts +28 -3
- package/dist/models/purposes.js +40 -13
- package/dist/orgs/cloud-network-setting.d.ts +33 -0
- package/dist/orgs/cloud-network-setting.js +47 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +8 -2
- package/dist/orgs/org-lock.d.ts +10 -4
- package/dist/orgs/org-lock.js +10 -4
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +8 -2
- package/dist/orgs/settings.controller.d.ts +4 -1
- package/dist/orgs/settings.controller.js +3 -3
- package/dist/orgs/settings.service.d.ts +48 -56
- package/dist/orgs/settings.service.js +144 -101
- package/dist/overrides.d.ts +6 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin.ops.js +14 -11
- package/dist/platform/ops/agent-skills.ops.js +2 -0
- package/dist/platform/ops/devices.ops.js +10 -2
- package/dist/platform/ops/models.ops.js +10 -0
- package/dist/platform/ops/org-settings.ops.js +6 -6
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/roles/worker.module.js +4 -0
- package/dist/runtime/context/build.d.ts +3 -1
- package/dist/runtime/context/build.js +19 -3
- package/dist/runtime/context/compaction.js +5 -0
- package/dist/runtime/context/device-paths.d.ts +9 -2
- package/dist/runtime/context/device-paths.js +20 -0
- package/dist/runtime/context/permission-profile.d.ts +46 -0
- package/dist/runtime/context/permission-profile.js +194 -0
- package/dist/runtime/hook-calls.d.ts +11 -1
- package/dist/runtime/hook-calls.js +24 -1
- package/dist/runtime/maintenance.d.ts +7 -1
- package/dist/runtime/maintenance.js +43 -15
- package/dist/runtime/model-call.d.ts +32 -0
- package/dist/runtime/model-call.js +67 -0
- package/dist/runtime/permission-context-errors.d.ts +39 -0
- package/dist/runtime/permission-context-errors.js +67 -0
- package/dist/runtime/permission-context.service.d.ts +60 -0
- package/dist/runtime/permission-context.service.js +286 -0
- package/dist/runtime/project/knowledge.d.ts +7 -2
- package/dist/runtime/project/knowledge.js +5 -2
- package/dist/runtime/project/knowledge.service.d.ts +17 -2
- package/dist/runtime/project/knowledge.service.js +76 -12
- package/dist/runtime/providers.d.ts +9 -5
- package/dist/runtime/providers.js +22 -3
- package/dist/runtime/run-execution.d.ts +4 -1
- package/dist/runtime/run-execution.js +14 -5
- package/dist/runtime/run-steps.d.ts +11 -3
- package/dist/runtime/run-steps.js +27 -4
- package/dist/runtime/runtime.module.js +11 -0
- package/dist/runtime/usage-report.d.ts +10 -6
- package/dist/runtime/usage-report.js +31 -11
- package/dist/sandbox/attachments-path.d.ts +15 -0
- package/dist/sandbox/attachments-path.js +15 -0
- package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
- package/dist/sandbox/cloud-permission-snapshot.js +407 -0
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
- package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
- package/dist/sandbox/held-operations.d.ts +39 -0
- package/dist/sandbox/held-operations.js +119 -0
- package/dist/sandbox/jobs.d.ts +14 -3
- package/dist/sandbox/jobs.js +20 -2
- package/dist/sandbox/kernel-read.d.ts +55 -0
- package/dist/sandbox/kernel-read.js +57 -0
- package/dist/sandbox/legacy-retirement.d.ts +336 -0
- package/dist/sandbox/legacy-retirement.js +1063 -0
- package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
- package/dist/sandbox/legacy-retirement.module.js +25 -0
- package/dist/sandbox/managed-device-context.d.ts +94 -0
- package/dist/sandbox/managed-device-context.js +308 -0
- package/dist/sandbox/managed-device-context.module.d.ts +6 -0
- package/dist/sandbox/managed-device-context.module.js +33 -0
- package/dist/sandbox/modes.d.ts +56 -8
- package/dist/sandbox/modes.js +92 -8
- package/dist/sandbox/operation-authority-types.d.ts +8 -0
- package/dist/sandbox/operation-authority-types.js +32 -0
- package/dist/sandbox/operation-authority.d.ts +145 -0
- package/dist/sandbox/operation-authority.js +783 -0
- package/dist/sandbox/operation-authority.module.d.ts +2 -0
- package/dist/sandbox/operation-authority.module.js +29 -0
- package/dist/sandbox/operation-intents.d.ts +206 -0
- package/dist/sandbox/operation-intents.js +1252 -0
- package/dist/sandbox/operation-intents.module.d.ts +2 -0
- package/dist/sandbox/operation-intents.module.js +21 -0
- package/dist/sandbox/operation-payloads.d.ts +33 -0
- package/dist/sandbox/operation-payloads.js +332 -0
- package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
- package/dist/sandbox/operation-reconcile.job.js +247 -0
- package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
- package/dist/sandbox/permission-authority-epochs.js +83 -0
- package/dist/sandbox/permission-authority-lock.d.ts +38 -0
- package/dist/sandbox/permission-authority-lock.js +147 -0
- package/dist/sandbox/permission-authority.module.d.ts +9 -0
- package/dist/sandbox/permission-authority.module.js +55 -0
- package/dist/sandbox/permission-availability.d.ts +18 -0
- package/dist/sandbox/permission-availability.js +19 -0
- package/dist/sandbox/permission-call-grants.d.ts +34 -0
- package/dist/sandbox/permission-call-grants.js +349 -0
- package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
- package/dist/sandbox/permission-call-grants.module.js +21 -0
- package/dist/sandbox/permission-call-types.d.ts +82 -0
- package/dist/sandbox/permission-call-types.js +1 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
- package/dist/sandbox/permission-ceiling-writes.js +223 -0
- package/dist/sandbox/permission-config-publication.d.ts +76 -0
- package/dist/sandbox/permission-config-publication.js +339 -0
- package/dist/sandbox/permission-context-types.d.ts +64 -0
- package/dist/sandbox/permission-context-types.js +24 -0
- package/dist/sandbox/permission-facts.d.ts +206 -0
- package/dist/sandbox/permission-facts.js +627 -0
- package/dist/sandbox/permission-facts.module.d.ts +2 -0
- package/dist/sandbox/permission-facts.module.js +20 -0
- package/dist/sandbox/permission-instance-writes.d.ts +90 -0
- package/dist/sandbox/permission-instance-writes.js +305 -0
- package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
- package/dist/sandbox/permission-runtime-reports.js +354 -0
- package/dist/sandbox/permission-transitions.d.ts +31 -0
- package/dist/sandbox/permission-transitions.js +155 -0
- package/dist/sandbox/platform-full-access.d.ts +128 -0
- package/dist/sandbox/platform-full-access.js +210 -0
- package/dist/sandbox/providers.d.ts +22 -0
- package/dist/sandbox/providers.js +10 -2
- package/dist/sandbox/providers.module.d.ts +2 -0
- package/dist/sandbox/providers.module.js +19 -0
- package/dist/sandbox/request-not-sent.d.ts +13 -0
- package/dist/sandbox/request-not-sent.js +13 -0
- package/dist/sandbox/review/classifier.d.ts +2 -0
- package/dist/sandbox/review/classifier.js +8 -0
- package/dist/sandbox/review/permission-candidate.d.ts +12 -0
- package/dist/sandbox/review/permission-candidate.js +145 -0
- package/dist/sandbox/review/review.service.d.ts +5 -2
- package/dist/sandbox/review/review.service.js +60 -15
- package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
- package/dist/sandbox/sandbox-file-reader.js +51 -7
- package/dist/sandbox/sandbox.module.js +26 -6
- package/dist/sandbox/sandbox.service.d.ts +230 -34
- package/dist/sandbox/sandbox.service.js +1368 -199
- package/dist/sandbox/unreachable.js +17 -3
- package/dist/sandbox/use-context.d.ts +17 -0
- package/dist/sandbox/use-context.js +1 -0
- package/dist/skills/invoke.d.ts +27 -4
- package/dist/skills/invoke.js +72 -7
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +23 -10
- package/dist/tools/approvals.service.js +104 -26
- package/dist/tools/builtin-names.d.ts +3 -1
- package/dist/tools/builtin-names.js +5 -1
- package/dist/tools/builtins/artifacts.d.ts +43 -0
- package/dist/tools/builtins/artifacts.js +67 -0
- package/dist/tools/builtins/builtin-tools.d.ts +20 -2
- package/dist/tools/builtins/builtin-tools.js +61 -10
- package/dist/tools/builtins/image/generate.d.ts +59 -0
- package/dist/tools/builtins/image/generate.js +535 -0
- package/dist/tools/builtins/image/index.d.ts +2 -0
- package/dist/tools/builtins/image/index.js +2 -0
- package/dist/tools/builtins/image/paths.d.ts +12 -0
- package/dist/tools/builtins/image/paths.js +26 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
- package/dist/tools/builtins/sandbox/bash.js +201 -5
- package/dist/tools/builtins/sandbox/common.d.ts +92 -20
- package/dist/tools/builtins/sandbox/common.js +201 -17
- package/dist/tools/builtins/sandbox/deliver.js +9 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +2 -2
- package/dist/tools/builtins/sandbox/task-list.js +7 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
- package/dist/tools/builtins/sandbox/task-output.js +172 -0
- package/dist/tools/builtins/sandbox/task-stop.js +25 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.js +9 -6
- package/dist/tools/device-op-resolver.d.ts +1 -1
- package/dist/tools/device-op-resolver.js +13 -3
- package/dist/tools/permission-approval-jobs.d.ts +18 -0
- package/dist/tools/permission-approval-jobs.js +92 -0
- package/dist/tools/pipeline.d.ts +17 -2
- package/dist/tools/pipeline.js +315 -26
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +15 -0
- package/package.json +4 -3
- package/src/migrations/0146_permission_authority_epochs.sql +6 -0
- package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
- package/src/migrations/0148_first_message_request_hash.sql +2 -0
- package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
- package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
- package/src/migrations/0151_starting_execution_grants.sql +8 -0
- package/src/migrations/0152_background_launch_identity.sql +66 -0
- package/src/migrations/0153_background_cancel_requester.sql +13 -0
- package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
- package/src/migrations/0155_device_instance_generations.sql +30 -0
- package/src/migrations/0156_device_owner_report.sql +7 -0
- package/src/migrations/0157_legacy_retirement.sql +116 -0
- package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
- package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
- package/src/migrations/0160_model_usage_image_kind.sql +10 -0
- package/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isFileSystemGoneError, isSandboxGoneError } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { isFileSystemGoneError, isSandboxGoneError, isSandboxOperationOutcomeUnknownError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
/** Codes of a connection that was never made (node `net` / `dns`, undici). */
|
|
3
3
|
const CONNECT_CODES = new Set([
|
|
4
4
|
"ECONNREFUSED",
|
|
@@ -32,7 +32,11 @@ const MAX_DEPTH = 5;
|
|
|
32
32
|
export function providerConnectionFailure(e, depth = 0) {
|
|
33
33
|
if (depth > MAX_DEPTH || typeof e !== "object" || e === null)
|
|
34
34
|
return undefined;
|
|
35
|
-
if (isSandboxGoneError(e) ||
|
|
35
|
+
if (isSandboxGoneError(e) ||
|
|
36
|
+
isFileSystemGoneError(e) ||
|
|
37
|
+
isSandboxScopeDeniedError(e) ||
|
|
38
|
+
isSandboxPermissionUnsupportedError(e) ||
|
|
39
|
+
isSandboxOperationOutcomeUnknownError(e))
|
|
36
40
|
return undefined;
|
|
37
41
|
const { code, syscall, message, cause, errors } = e;
|
|
38
42
|
if (typeof code === "string") {
|
|
@@ -86,6 +90,8 @@ export function guardProviderConnection(impl) {
|
|
|
86
90
|
return new Proxy(impl, {
|
|
87
91
|
get(target, prop) {
|
|
88
92
|
const value = Reflect.get(target, prop, target);
|
|
93
|
+
if (prop === "background" && value !== null && typeof value === "object")
|
|
94
|
+
return guardProviderConnection(value);
|
|
89
95
|
if (typeof value !== "function")
|
|
90
96
|
return value;
|
|
91
97
|
return (...args) => {
|
|
@@ -97,7 +103,15 @@ export function guardProviderConnection(impl) {
|
|
|
97
103
|
throw converted(e);
|
|
98
104
|
}
|
|
99
105
|
if (r instanceof Promise) {
|
|
100
|
-
return r
|
|
106
|
+
return r
|
|
107
|
+
.then((result) => {
|
|
108
|
+
if (["operation", "prepare", "browse"].includes(String(prop)) &&
|
|
109
|
+
result !== null &&
|
|
110
|
+
typeof result === "object")
|
|
111
|
+
return guardProviderConnection(result);
|
|
112
|
+
return result;
|
|
113
|
+
})
|
|
114
|
+
.catch((e) => {
|
|
101
115
|
throw converted(e);
|
|
102
116
|
});
|
|
103
117
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SandboxActor } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
/** Who uses the sandbox in {@link SandboxService.withSandbox}. */
|
|
3
|
+
export interface SandboxUseContext {
|
|
4
|
+
orgId: string;
|
|
5
|
+
deviceId: string;
|
|
6
|
+
/** The agent conversation using it (a sub-agent's own for a child): what it last saw is tracked. */
|
|
7
|
+
holderConversationId: string;
|
|
8
|
+
/** Passed with every `exec` (audit and attribution). */
|
|
9
|
+
actor: SandboxActor;
|
|
10
|
+
/**
|
|
11
|
+
* A use that tells the model nothing (the run-start read of a bound project): it does not mark
|
|
12
|
+
* the holder as having seen the instance, so the holder's next ordinary use still learns that
|
|
13
|
+
* the instance started, restarted or had its files reset ({@link SandboxUseInfo}); what this use
|
|
14
|
+
* itself caused (a creation, a rebuild) is kept for that next use.
|
|
15
|
+
*/
|
|
16
|
+
silent?: true;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/skills/invoke.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare const parseSlashCommand: (text: string) => {
|
|
|
67
67
|
export type NotInvocableReason = "not_found" | "not_user_invocable";
|
|
68
68
|
export declare const notInvocable: (reason: NotInvocableReason, name: string) => ApiError;
|
|
69
69
|
/** Why a listed project skill cannot be used now (`skill.project_unavailable` details). */
|
|
70
|
-
export type ProjectUnavailableReason = "gone" | "outside_mode" | "unreadable" | "unparsable" | "unsupported" | "removed";
|
|
70
|
+
export type ProjectUnavailableReason = "gone" | "outside_mode" | "unreadable" | "unparsable" | "unsupported" | "removed" | "skill_tool_off";
|
|
71
71
|
/** Where an effective skill comes from, for the `/` menu ({@link InvocableSource}). */
|
|
72
72
|
export declare const invocableSource: (r: {
|
|
73
73
|
scope: ResolvedSkill["scope"];
|
|
@@ -102,6 +102,18 @@ export declare function recordedSkillBlocked(db: KernelSchemaDb, a: {
|
|
|
102
102
|
}): Promise<NotInvocableReason | null>;
|
|
103
103
|
/** The model-visible text of a fork invocation in the parent's log (spec §6.3, frozen). */
|
|
104
104
|
export declare const forkLeadText: (name: string, agentType: string, args: string) => string;
|
|
105
|
+
/**
|
|
106
|
+
* A person's `/project:<name>` invocation once the activation gate is on (permission activation
|
|
107
|
+
* L2, Hook 2): no device read at send time (a person's send has no run, so nothing could admit
|
|
108
|
+
* it). The message is a stub rendered from the conversation's latest `project_root` (the skill's
|
|
109
|
+
* name, its recorded digest, its directory in the project and the person's arguments) telling the
|
|
110
|
+
* agent to load `project:<name>` with its `Skill` tool, which reads it under the run's admission.
|
|
111
|
+
* Model-visible, so English; tags in the arguments stay inert. Always inline, as before.
|
|
112
|
+
*/
|
|
113
|
+
export declare function projectSkillStub(a: {
|
|
114
|
+
name: string;
|
|
115
|
+
args: string;
|
|
116
|
+
}, latest: ProjectRootPayload, bare: string): RenderedInvocation;
|
|
105
117
|
/** The warning recorded when a forked skill's `agent` does not resolve (spec §6.2). */
|
|
106
118
|
export declare const forkAgentUnknownText: (name: string, agent: string) => string;
|
|
107
119
|
/**
|
|
@@ -119,11 +131,15 @@ export declare class SkillInvoker {
|
|
|
119
131
|
/** A project skill's SKILL.md is read through the conversation's device. */
|
|
120
132
|
private readonly sandbox;
|
|
121
133
|
private readonly devices;
|
|
134
|
+
/** The paired activation gate: once on, no raw device use reads a project skill. */
|
|
135
|
+
private readonly activation?;
|
|
122
136
|
constructor(db: KernelDb, storage: StorageService, agents: Pick<AgentLookup, "get">, log: KernelLogger,
|
|
123
137
|
/** A bound conversation's latest `project_root` (its project skills). */
|
|
124
138
|
eventLog: Pick<EventLog, "latestOfType">,
|
|
125
139
|
/** A project skill's SKILL.md is read through the conversation's device. */
|
|
126
|
-
sandbox: Pick<SandboxService, "withSandbox">, devices: Pick<ConversationDevices, "forTool" | "modeLevel" | "workingFacts"
|
|
140
|
+
sandbox: Pick<SandboxService, "withSandbox">, devices: Pick<ConversationDevices, "forTool" | "modeLevel" | "workingFacts" | "projectReach">,
|
|
141
|
+
/** The paired activation gate: once on, no raw device use reads a project skill. */
|
|
142
|
+
activation?: boolean | undefined);
|
|
127
143
|
/**
|
|
128
144
|
* The `/` menu for `accountId`: the agent must be usable by them (`agent.not_found`), and with
|
|
129
145
|
* `conversationId` the conversation must be theirs and the agent's (`conversation.not_found`);
|
|
@@ -168,10 +184,17 @@ export declare class SkillInvoker {
|
|
|
168
184
|
* `skill.not_invocable` `not_found` (no conversation yet, no project, a name it does not list),
|
|
169
185
|
* `skill.project_unavailable` with its reason (the latest project is unavailable, or its file
|
|
170
186
|
* cannot be used), the device's own refusals as they are (`device.offline`, ...),
|
|
171
|
-
* `device.projects_unavailable` when the device cannot be asked.
|
|
187
|
+
* `device.projects_unavailable` when the device cannot be asked. Once the activation gate is on
|
|
188
|
+
* the device is not read at send time: the invocation is the recorded stub
|
|
189
|
+
* ({@link projectSkillStub}) and only the first two refusals remain, plus
|
|
190
|
+
* `skill.project_unavailable` `skill_tool_off` for an agent without the `Skill` tool.
|
|
172
191
|
*/
|
|
173
192
|
private prepareProject;
|
|
174
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* {@link readProjectSkill} in a silent use of the conversation's device, as its owner (gate off
|
|
195
|
+
* only: once activated a person's invocation renders {@link projectSkillStub} and never reads
|
|
196
|
+
* the device at send time).
|
|
197
|
+
*/
|
|
175
198
|
private readProjectFile;
|
|
176
199
|
/**
|
|
177
200
|
* The task of a fork invocation's sub-agent (spec §6.2), rendered at dispatch from the version
|
package/dist/skills/invoke.js
CHANGED
|
@@ -8,7 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { escapeSkillInvocationTags, hasShellInjection, parseSkillMd, renderSkillBody, renderSkillInvocation, SKILL_ENTRY_FILE, SKILL_INVOCATION_LIMITS, skillDigest, skillSandboxDir, } from "@capybara-hq/plugin-sdk";
|
|
11
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
12
|
import { AgentLookup } from "../agents/agent-lookup.js";
|
|
13
13
|
import { builtinDisabled } from "../agents/definition.js";
|
|
14
14
|
import { EventLog } from "../conversations/event-log.js";
|
|
@@ -19,6 +19,8 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
19
19
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
20
20
|
import { callableProjectSkills, projectSkillName, projectSkillOf, } from "../runtime/context/project-root.js";
|
|
21
21
|
import { isGeneralAlias, resolveSkillForkType } from "../runtime/subagents/roster.js";
|
|
22
|
+
import { PROJECT_SKILLS_DIR } from "../sandbox/kernel-read.js";
|
|
23
|
+
import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
|
|
22
24
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
23
25
|
import { SandboxProviderUnreachableError } from "../sandbox/unreachable.js";
|
|
24
26
|
import { StorageService } from "../storage/storage.service.js";
|
|
@@ -127,6 +129,46 @@ export async function recordedSkillBlocked(db, a) {
|
|
|
127
129
|
}
|
|
128
130
|
/** The model-visible text of a fork invocation in the parent's log (spec §6.3, frozen). */
|
|
129
131
|
export const forkLeadText = (name, agentType, args) => escapeSkillInvocationTags(`The user ran the skill "${name}" in a sub-agent (${agentType}) with /${name}${args === "" ? "" : ` ${args}`}. The sub-agent gets the skill's instructions as its task; its report follows. Do not do the task yourself.`);
|
|
132
|
+
/**
|
|
133
|
+
* A person's `/project:<name>` invocation once the activation gate is on (permission activation
|
|
134
|
+
* L2, Hook 2): no device read at send time (a person's send has no run, so nothing could admit
|
|
135
|
+
* it). The message is a stub rendered from the conversation's latest `project_root` (the skill's
|
|
136
|
+
* name, its recorded digest, its directory in the project and the person's arguments) telling the
|
|
137
|
+
* agent to load `project:<name>` with its `Skill` tool, which reads it under the run's admission.
|
|
138
|
+
* Model-visible, so English; tags in the arguments stay inert. Always inline, as before.
|
|
139
|
+
*/
|
|
140
|
+
export function projectSkillStub(a, latest, bare) {
|
|
141
|
+
const skill = latest.skills.find((s) => s.name === bare);
|
|
142
|
+
if (skill === undefined)
|
|
143
|
+
throw notInvocable("not_found", a.name);
|
|
144
|
+
const args = a.args.trim();
|
|
145
|
+
if ([...args].length > SKILL_INVOCATION_LIMITS.argumentsMaxChars) {
|
|
146
|
+
throw new ApiError("validation_failed", "Request validation failed", [
|
|
147
|
+
{
|
|
148
|
+
path: "text",
|
|
149
|
+
message: `skill arguments must be at most ${SKILL_INVOCATION_LIMITS.argumentsMaxChars} characters; shorten the arguments`,
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
const root = latest.root.length > 1 && latest.root.endsWith("/") ? latest.root.slice(0, -1) : latest.root;
|
|
154
|
+
const dir = `${root === "/" ? "" : root}/${PROJECT_SKILLS_DIR}/${bare}`;
|
|
155
|
+
const text = escapeSkillInvocationTags([
|
|
156
|
+
`The user invoked the project skill "${a.name}" with /${a.name}${args === "" ? "" : ` ${args}`}.`,
|
|
157
|
+
`Its instructions are not included in this message: call ${BUILTIN.Skill} with the name "${a.name}" to load them from the project (its directory is ${dir}; the SKILL.md recorded at the run start has the digest ${skill.digest}), then follow them${args === "" ? "." : " with the user's arguments:"}`,
|
|
158
|
+
...(args === "" ? [] : [args]),
|
|
159
|
+
].join("\n\n"));
|
|
160
|
+
return {
|
|
161
|
+
text,
|
|
162
|
+
skill: {
|
|
163
|
+
id: a.name,
|
|
164
|
+
version: 0,
|
|
165
|
+
source: "project",
|
|
166
|
+
name: a.name,
|
|
167
|
+
arguments: args,
|
|
168
|
+
mode: "inline",
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
}
|
|
130
172
|
/** The warning recorded when a forked skill's `agent` does not resolve (spec §6.2). */
|
|
131
173
|
export const forkAgentUnknownText = (name, agent) => `Skill "${name}" asked for sub-agent type "${agent}", which this agent does not have; it ran as general-purpose.`;
|
|
132
174
|
/**
|
|
@@ -142,11 +184,14 @@ let SkillInvoker = class SkillInvoker {
|
|
|
142
184
|
eventLog;
|
|
143
185
|
sandbox;
|
|
144
186
|
devices;
|
|
187
|
+
activation;
|
|
145
188
|
constructor(db, storage, agents, log,
|
|
146
189
|
/** A bound conversation's latest `project_root` (its project skills). */
|
|
147
190
|
eventLog,
|
|
148
191
|
/** A project skill's SKILL.md is read through the conversation's device. */
|
|
149
|
-
sandbox, devices
|
|
192
|
+
sandbox, devices,
|
|
193
|
+
/** The paired activation gate: once on, no raw device use reads a project skill. */
|
|
194
|
+
activation) {
|
|
150
195
|
this.db = db;
|
|
151
196
|
this.storage = storage;
|
|
152
197
|
this.agents = agents;
|
|
@@ -154,6 +199,7 @@ let SkillInvoker = class SkillInvoker {
|
|
|
154
199
|
this.eventLog = eventLog;
|
|
155
200
|
this.sandbox = sandbox;
|
|
156
201
|
this.devices = devices;
|
|
202
|
+
this.activation = activation;
|
|
157
203
|
}
|
|
158
204
|
/**
|
|
159
205
|
* The `/` menu for `accountId`: the agent must be usable by them (`agent.not_found`), and with
|
|
@@ -184,6 +230,9 @@ let SkillInvoker = class SkillInvoker {
|
|
|
184
230
|
});
|
|
185
231
|
if (conversationId === undefined)
|
|
186
232
|
return skills;
|
|
233
|
+
// once activated a project skill is loaded by the agent's Skill tool: none without it
|
|
234
|
+
if (permissionContextActive(this.activation) && !hasBuiltin(agent.definition, BUILTIN.Skill))
|
|
235
|
+
return skills;
|
|
187
236
|
const latest = await this.eventLog.latestOfType(conversationId, "project_root");
|
|
188
237
|
return [...skills, ...projectInvocables(latest?.payload)];
|
|
189
238
|
}
|
|
@@ -285,7 +334,10 @@ let SkillInvoker = class SkillInvoker {
|
|
|
285
334
|
* `skill.not_invocable` `not_found` (no conversation yet, no project, a name it does not list),
|
|
286
335
|
* `skill.project_unavailable` with its reason (the latest project is unavailable, or its file
|
|
287
336
|
* cannot be used), the device's own refusals as they are (`device.offline`, ...),
|
|
288
|
-
* `device.projects_unavailable` when the device cannot be asked.
|
|
337
|
+
* `device.projects_unavailable` when the device cannot be asked. Once the activation gate is on
|
|
338
|
+
* the device is not read at send time: the invocation is the recorded stub
|
|
339
|
+
* ({@link projectSkillStub}) and only the first two refusals remain, plus
|
|
340
|
+
* `skill.project_unavailable` `skill_tool_off` for an agent without the `Skill` tool.
|
|
289
341
|
*/
|
|
290
342
|
async prepareProject(a, bare) {
|
|
291
343
|
const { conversationId } = a;
|
|
@@ -298,6 +350,12 @@ let SkillInvoker = class SkillInvoker {
|
|
|
298
350
|
if (projectSkillBlocked(latest, a.name) !== null || latest === undefined) {
|
|
299
351
|
throw notInvocable("not_found", a.name);
|
|
300
352
|
}
|
|
353
|
+
// once activated: no device read at send time, the agent loads the skill with Skill
|
|
354
|
+
if (permissionContextActive(this.activation)) {
|
|
355
|
+
if (!hasBuiltin(a.agent, BUILTIN.Skill))
|
|
356
|
+
throw projectUnavailable("skill_tool_off", `Skill "${a.name}" cannot be invoked: this agent cannot load project skills; turn on its ${BUILTIN.Skill} tool`);
|
|
357
|
+
return projectSkillStub(a, latest, bare);
|
|
358
|
+
}
|
|
301
359
|
const file = await this.readProjectFile({ ...a, conversationId }, latest.root, bare);
|
|
302
360
|
const args = a.args.trim();
|
|
303
361
|
// the renderer's skills-root directory becomes the skill's directory in the project (a closing
|
|
@@ -346,13 +404,18 @@ let SkillInvoker = class SkillInvoker {
|
|
|
346
404
|
},
|
|
347
405
|
};
|
|
348
406
|
}
|
|
349
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* {@link readProjectSkill} in a silent use of the conversation's device, as its owner (gate off
|
|
409
|
+
* only: once activated a person's invocation renders {@link projectSkillStub} and never reads
|
|
410
|
+
* the device at send time).
|
|
411
|
+
*/
|
|
350
412
|
async readProjectFile(a, root, bare) {
|
|
351
413
|
try {
|
|
352
414
|
const deviceId = await this.devices.forTool(a.orgId, a.conversationId);
|
|
353
415
|
// a person invokes in a root conversation: it is its own sandbox conversation
|
|
354
|
-
const [level, working] = await Promise.all([
|
|
416
|
+
const [level, reach, working] = await Promise.all([
|
|
355
417
|
this.devices.modeLevel(a.orgId, deviceId),
|
|
418
|
+
this.devices.projectReach(a.orgId, deviceId),
|
|
356
419
|
this.devices.workingFacts(a.orgId, a.conversationId, a.conversationId, deviceId),
|
|
357
420
|
]);
|
|
358
421
|
// unknown mode: the strict (sandbox) path checks stay (fail closed), as in a tool call
|
|
@@ -370,7 +433,7 @@ let SkillInvoker = class SkillInvoker {
|
|
|
370
433
|
h,
|
|
371
434
|
roots: info.roots,
|
|
372
435
|
// the working root a tool call of this conversation would get (one rule)
|
|
373
|
-
workingRoot: sessionWorkingRoot(working, mode, info.roots.workspace),
|
|
436
|
+
workingRoot: sessionWorkingRoot(working, mode, info.roots.workspace, reach),
|
|
374
437
|
p,
|
|
375
438
|
signal,
|
|
376
439
|
}, root, bare), AbortSignal.timeout(PROJECT_SKILL_READ_TIMEOUT_MS));
|
|
@@ -495,7 +558,9 @@ SkillInvoker = __decorate([
|
|
|
495
558
|
__param(3, Inject(KERNEL_LOGGER)),
|
|
496
559
|
__param(4, Inject(EventLog)),
|
|
497
560
|
__param(5, Inject(SandboxService)),
|
|
498
|
-
__param(6, Inject(ConversationDevices))
|
|
561
|
+
__param(6, Inject(ConversationDevices)),
|
|
562
|
+
__param(7, Optional()),
|
|
563
|
+
__param(7, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
499
564
|
], SkillInvoker);
|
|
500
565
|
export { SkillInvoker };
|
|
501
566
|
/**
|
|
@@ -2,7 +2,9 @@ import { z } from "zod";
|
|
|
2
2
|
/** `GET /approvals?status=`: absent lists every status. */
|
|
3
3
|
export const ApprovalsListQuerySchema = z
|
|
4
4
|
.object({
|
|
5
|
-
status: z
|
|
5
|
+
status: z
|
|
6
|
+
.enum(["pending", "approved", "denied", "expired", "cancelled", "skipped", "superseded"])
|
|
7
|
+
.optional(),
|
|
6
8
|
})
|
|
7
9
|
.strict();
|
|
8
10
|
/** `:id` of `GET /approvals/:id`, as the route takes it (`@Param`). */
|
|
@@ -9,6 +9,9 @@ import { LockService } from "../infra/lock/lock.service.js";
|
|
|
9
9
|
import { DevicePolicyService, type PolicyOpResult } from "../local-devices/device-policy.service.js";
|
|
10
10
|
import { type OrgRole } from "../orgs/roles.js";
|
|
11
11
|
import { RunResume } from "../runtime/run-jobs.js";
|
|
12
|
+
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
13
|
+
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
14
|
+
import type { PermissionCandidate, PermissionExpansion } from "../sandbox/permission-call-types.js";
|
|
12
15
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
13
16
|
import { ScheduledTaskStore } from "../schedules/store.js";
|
|
14
17
|
import type { ApprovalPolicySource } from "./pipeline.js";
|
|
@@ -16,7 +19,7 @@ import { ToolRegistry } from "./registry.js";
|
|
|
16
19
|
export { APPROVAL_DENY_REASON_MAX_CHARS } from "../conversations/events.js";
|
|
17
20
|
/** `list` 一次最多返回的审批数(收件箱据此判断这个来源是否取满)。 */
|
|
18
21
|
export declare const APPROVALS_LIST_MAX = 100;
|
|
19
|
-
export type ApprovalStatus = "pending" | "approved" | "denied" | "expired" | "cancelled" | "skipped";
|
|
22
|
+
export type ApprovalStatus = "pending" | "approved" | "denied" | "expired" | "cancelled" | "skipped" | "superseded";
|
|
20
23
|
export type ApprovalScope = "once" | "session" | "always";
|
|
21
24
|
/**
|
|
22
25
|
* What an approval asks: a tool call, the device owner about refused network hosts, the actor about
|
|
@@ -115,6 +118,10 @@ export type GitAskView = Omit<GitAskDetail, "result">;
|
|
|
115
118
|
* gave. Display only; the run waits for the decision.
|
|
116
119
|
*/
|
|
117
120
|
export interface CommandAskDetail {
|
|
121
|
+
permissionCandidate?: PermissionCandidate;
|
|
122
|
+
permissionScope?: PermissionExpansion;
|
|
123
|
+
targetPath?: string;
|
|
124
|
+
candidateHash?: string;
|
|
118
125
|
deviceId: string;
|
|
119
126
|
deviceName: string;
|
|
120
127
|
mode: "auto" | "sandbox";
|
|
@@ -165,6 +172,8 @@ export interface ApprovalRecord {
|
|
|
165
172
|
requestedFor: string | null;
|
|
166
173
|
approverRole: OrgRole | null;
|
|
167
174
|
status: ApprovalStatus;
|
|
175
|
+
supersededRevision?: number | null;
|
|
176
|
+
supersededReason?: string | null;
|
|
168
177
|
scope: ApprovalScope | null;
|
|
169
178
|
decidedBy: string | null;
|
|
170
179
|
decidedAt: string | null;
|
|
@@ -355,6 +364,8 @@ export declare class ApprovalsService {
|
|
|
355
364
|
private readonly sandbox;
|
|
356
365
|
/** A decision resumes its waiting run in the decision's transaction. */
|
|
357
366
|
private readonly resumes;
|
|
367
|
+
private readonly permissionLocks?;
|
|
368
|
+
private readonly permissionGrants?;
|
|
358
369
|
constructor(db: KernelDb, config: Pick<KernelConfigService, "get">, eventLog: Pick<EventLog, "appendIn" | "notify">, events: Pick<KernelEvents, "emit">, txHost: TransactionHost, schedules: Pick<ScheduledTaskStore, "addGrant">,
|
|
359
370
|
/** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
|
|
360
371
|
registry: Pick<ToolRegistry, "forAgent">,
|
|
@@ -362,13 +373,13 @@ export declare class ApprovalsService {
|
|
|
362
373
|
* 「这台设备一直允许」 records the device change's intent, sends the `policy` op, then records
|
|
363
374
|
* its outcome with the decision.
|
|
364
375
|
*/
|
|
365
|
-
policies: Pick<DevicePolicyService, "begin" | "send" | "settleIn" | "summary">,
|
|
376
|
+
policies: Pick<DevicePolicyService, "begin" | "send" | "settleIn" | "summary" | "lockMachineDevice">,
|
|
366
377
|
/** One decision of a network ask at a time, across replicas (the op is sent before the transaction). */
|
|
367
378
|
lockService: LockService,
|
|
368
379
|
/** A trial run's 「这次允许」 becomes a task grant only within the org's egress. */
|
|
369
380
|
sandbox: Pick<SandboxService, "ceilingLimits">,
|
|
370
381
|
/** A decision resumes its waiting run in the decision's transaction. */
|
|
371
|
-
resumes: Pick<RunResume, "resumeIn"
|
|
382
|
+
resumes: Pick<RunResume, "resumeIn">, permissionLocks?: PermissionAuthorityLock | undefined, permissionGrants?: PermissionCallGrants | undefined);
|
|
372
383
|
/**
|
|
373
384
|
* 新建 pending 审批(`expires_at` = 现在 + `tools.approvalTimeoutHours`)并写 `approval_requested`,同一事务。
|
|
374
385
|
* 按 (run_id, call_id, attempt) 幂等:已存在则返回已有记录(不覆盖),事件按 `approval_requested:<approvalId>` 幂等。
|
|
@@ -444,6 +455,7 @@ export declare class ApprovalsService {
|
|
|
444
455
|
* deny). The decision is written in its transaction; the run resumes after the commit.
|
|
445
456
|
*/
|
|
446
457
|
private decideCommand;
|
|
458
|
+
private commandSubject;
|
|
447
459
|
/**
|
|
448
460
|
* 「这台设备一直允许」 (transactional outbox spec §7): the intent of the device change (naming the
|
|
449
461
|
* ask) is recorded, the `policy` op sent (no transaction open), then {@link settleNetworkOp}
|
|
@@ -461,6 +473,12 @@ export declare class ApprovalsService {
|
|
|
461
473
|
private decideAlways;
|
|
462
474
|
/** Records only the op's outcome, in its own transaction (the ask is left as it is). */
|
|
463
475
|
private settleOpOnly;
|
|
476
|
+
/**
|
|
477
|
+
* {@link settleNetworkOp} with the device's permission authority lock as its ordered prelude
|
|
478
|
+
* (`DevicePolicyService.lockMachineDevice`): the global order puts it before the ask's
|
|
479
|
+
* conversation row, as a fenced device writer of the same tree takes it (device project writes).
|
|
480
|
+
*/
|
|
481
|
+
private settleNetworkOpOrdered;
|
|
464
482
|
/**
|
|
465
483
|
* The resolve transaction of a network ask's device change: the ask decided as `network` says
|
|
466
484
|
* ({@link decideTx}: lock order conversation → approval → run), then the op's outcome recorded
|
|
@@ -489,7 +507,8 @@ export declare class ApprovalsService {
|
|
|
489
507
|
* late) and the ask left pending with `applied_undecided`. Not applied (refused, never received,
|
|
490
508
|
* interrupted) or still unknown → the op's outcome recorded and the ask left pending with the
|
|
491
509
|
* reason (`detail.attempt`) and an `approval_updated` event so the card shows it: no person is
|
|
492
|
-
* there to fall back to a run grant (D2).
|
|
510
|
+
* there to fall back to a run grant (D2). The caller locked the machine's device first
|
|
511
|
+
* (`DevicePolicyService.lockMachineDevice`, before the ask's conversation row).
|
|
493
512
|
*/
|
|
494
513
|
settleFromResolver(ref: {
|
|
495
514
|
machineId: string;
|
|
@@ -513,12 +532,6 @@ export declare class ApprovalsService {
|
|
|
513
532
|
* Refuses (`approval.already_decided`, `approval.not_found`, …) before any write.
|
|
514
533
|
*/
|
|
515
534
|
private decideTx;
|
|
516
|
-
/**
|
|
517
|
-
* Resumes the run of a decided command ask in its own transaction after the decision committed
|
|
518
|
-
* (`afterCommit` runs outside any transaction; `RunResume.resumeIn` requires one). Its outcome
|
|
519
|
-
* is the suspend's re-check if the run was still running.
|
|
520
|
-
*/
|
|
521
|
-
private resumeDecided;
|
|
522
535
|
/**
|
|
523
536
|
* A trial run of a scheduled task (scheduled tasks spec §7): an approval its creator granted, in
|
|
524
537
|
* any scope, is also added to the task's grants with the approved definition's hash, so its
|