@capybara-hq/kernel 0.1.0-rc.15 → 0.1.0-rc.150
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 +55 -28
- package/dist/admin/account-erasures.d.ts +37 -0
- package/dist/admin/account-erasures.js +119 -0
- package/dist/admin/admin-agents.controller.d.ts +26 -0
- package/dist/admin/admin-agents.controller.js +79 -0
- package/dist/admin/admin-connectors.controller.d.ts +27 -0
- package/dist/admin/admin-connectors.controller.js +79 -0
- package/dist/admin/admin-items.schemas.d.ts +42 -0
- package/dist/admin/admin-items.schemas.js +44 -0
- package/dist/admin/admin.controller.d.ts +74 -39
- package/dist/admin/admin.controller.js +134 -56
- package/dist/admin/admin.module.d.ts +6 -1
- package/dist/admin/admin.module.js +90 -4
- package/dist/admin/admin.schemas.d.ts +133 -3
- package/dist/admin/admin.schemas.js +43 -8
- package/dist/admin/audit-log.service.d.ts +136 -0
- package/dist/admin/audit-log.service.js +545 -0
- package/dist/admin/audit-targets.d.ts +17 -0
- package/dist/admin/audit-targets.js +84 -0
- package/dist/admin/audit.controller.d.ts +29 -0
- package/dist/admin/audit.controller.js +93 -0
- package/dist/admin/audit.schemas.d.ts +32 -0
- package/dist/admin/audit.schemas.js +62 -0
- package/dist/admin/erasure-dispositions.d.ts +23 -0
- package/dist/admin/erasure-dispositions.js +76 -0
- package/dist/admin/extensions.controller.d.ts +62 -23
- package/dist/admin/extensions.controller.js +132 -55
- package/dist/admin/extensions.schemas.d.ts +29 -0
- package/dist/admin/extensions.schemas.js +54 -0
- package/dist/admin/health.service.d.ts +141 -0
- package/dist/admin/health.service.js +352 -0
- package/dist/admin/login-sources.controller.d.ts +30 -0
- package/dist/admin/login-sources.controller.js +77 -0
- package/dist/admin/login-sources.schemas.d.ts +25 -0
- package/dist/admin/login-sources.schemas.js +49 -0
- package/dist/admin/org-network.controller.d.ts +30 -0
- package/dist/admin/org-network.controller.js +77 -0
- package/dist/admin/org-network.schemas.d.ts +16 -0
- package/dist/admin/org-network.schemas.js +27 -0
- package/dist/admin/org-network.service.d.ts +43 -0
- package/dist/admin/org-network.service.js +109 -0
- package/dist/admin/outbox-dead.controller.d.ts +21 -0
- package/dist/admin/outbox-dead.controller.js +65 -0
- package/dist/admin/outbox-dead.schemas.d.ts +24 -0
- package/dist/admin/outbox-dead.schemas.js +42 -0
- package/dist/admin/outbox-dead.service.d.ts +81 -0
- package/dist/admin/outbox-dead.service.js +264 -0
- package/dist/admin/overview.controller.d.ts +31 -0
- package/dist/admin/overview.controller.js +78 -0
- package/dist/admin/overview.schemas.d.ts +8 -0
- package/dist/admin/overview.schemas.js +13 -0
- package/dist/admin/overview.service.d.ts +147 -0
- package/dist/admin/overview.service.js +256 -0
- package/dist/admin/setup.service.js +6 -1
- package/dist/admin/usage.service.d.ts +139 -0
- package/dist/admin/usage.service.js +337 -0
- package/dist/agents/admin-agents.d.ts +125 -0
- package/dist/agents/admin-agents.js +269 -0
- package/dist/agents/agent-lookup.d.ts +5 -2
- package/dist/agents/agent-lookup.js +11 -11
- package/dist/agents/agent-profile.service.d.ts +5 -2
- package/dist/agents/agent-profile.service.js +16 -2
- package/dist/agents/agents.controller.d.ts +18 -14
- package/dist/agents/agents.controller.js +36 -21
- package/dist/agents/agents.module.d.ts +4 -3
- package/dist/agents/agents.module.js +23 -3
- package/dist/agents/agents.schemas.d.ts +79 -21
- package/dist/agents/agents.schemas.js +21 -1
- package/dist/agents/agents.service.d.ts +76 -9
- package/dist/agents/agents.service.js +238 -72
- package/dist/agents/avatar-view.d.ts +8 -0
- package/dist/agents/avatar-view.js +12 -0
- package/dist/agents/definition.d.ts +53 -37
- package/dist/agents/definition.js +96 -231
- package/dist/agents/from-template.d.ts +6 -3
- package/dist/agents/from-template.js +58 -45
- package/dist/agents/instruction-files.js +0 -3
- package/dist/agents/models.controller.d.ts +11 -4
- package/dist/agents/models.controller.js +35 -4
- package/dist/agents/onboarding-checklist.d.ts +31 -0
- package/dist/agents/onboarding-checklist.js +189 -0
- package/dist/agents/org-templates.d.ts +3 -1
- package/dist/agents/org-templates.js +103 -42
- package/dist/agents/pending-connector-requests.d.ts +10 -4
- package/dist/agents/pending-connector-requests.js +35 -7
- package/dist/agents/pending-connectors.service.js +2 -0
- package/dist/agents/profile.d.ts +38 -13
- package/dist/agents/profile.js +31 -20
- package/dist/agents/readiness.controller.d.ts +10 -19
- package/dist/agents/readiness.controller.js +24 -27
- package/dist/agents/readiness.service.d.ts +90 -0
- package/dist/agents/readiness.service.js +132 -0
- package/dist/agents/templates.js +10 -28
- package/dist/app.d.ts +9 -1
- package/dist/app.js +5 -0
- package/dist/attribution/platform-attribution.d.ts +113 -0
- package/dist/attribution/platform-attribution.js +166 -0
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/acceptance.controller.d.ts +29 -0
- package/dist/automations/acceptance.controller.js +87 -0
- package/dist/automations/automations.controller.d.ts +81 -0
- package/dist/automations/automations.controller.js +284 -0
- package/dist/automations/automations.module.d.ts +16 -0
- package/dist/automations/automations.module.js +69 -0
- package/dist/automations/automations.schemas.d.ts +517 -0
- package/dist/automations/automations.schemas.js +293 -0
- package/dist/automations/automations.service.d.ts +424 -0
- package/dist/automations/automations.service.js +1414 -0
- package/dist/automations/calendar.d.ts +134 -0
- package/dist/automations/calendar.js +412 -0
- package/dist/automations/effective-settings.d.ts +22 -0
- package/dist/automations/effective-settings.js +23 -0
- package/dist/automations/errors.d.ts +24 -0
- package/dist/automations/errors.js +24 -0
- package/dist/automations/events/acceptance.d.ts +217 -0
- package/dist/automations/events/acceptance.js +858 -0
- package/dist/automations/events/coalesce.d.ts +28 -0
- package/dist/automations/events/coalesce.js +131 -0
- package/dist/automations/events/deadline.d.ts +10 -0
- package/dist/automations/events/deadline.js +24 -0
- package/dist/automations/events/deliver.d.ts +39 -0
- package/dist/automations/events/deliver.js +112 -0
- package/dist/automations/events/dispatcher.d.ts +90 -0
- package/dist/automations/events/dispatcher.js +352 -0
- package/dist/automations/events/events.module.d.ts +7 -0
- package/dist/automations/events/events.module.js +26 -0
- package/dist/automations/events/guards.d.ts +32 -0
- package/dist/automations/events/guards.js +87 -0
- package/dist/automations/events/sweep.job.d.ts +102 -0
- package/dist/automations/events/sweep.job.js +347 -0
- package/dist/automations/events/token.d.ts +5 -0
- package/dist/automations/events/token.js +5 -0
- package/dist/automations/events/trigger-events.service.d.ts +88 -0
- package/dist/automations/events/trigger-events.service.js +350 -0
- package/dist/automations/fire.d.ts +189 -0
- package/dist/automations/fire.js +966 -0
- package/dist/automations/grant-rules.d.ts +104 -0
- package/dist/automations/grant-rules.js +166 -0
- package/dist/automations/job-ids.d.ts +113 -0
- package/dist/automations/job-ids.js +117 -0
- package/dist/automations/pause.d.ts +9 -0
- package/dist/automations/pause.js +35 -0
- package/dist/automations/run-tracker.d.ts +95 -0
- package/dist/automations/run-tracker.js +362 -0
- package/dist/automations/scan.job.d.ts +49 -0
- package/dist/automations/scan.job.js +211 -0
- package/dist/automations/schedule-math.d.ts +80 -0
- package/dist/automations/schedule-math.js +304 -0
- package/dist/automations/store.d.ts +137 -0
- package/dist/automations/store.js +512 -0
- package/dist/automations/store.module.d.ts +6 -0
- package/dist/automations/store.module.js +21 -0
- package/dist/automations/types.d.ts +183 -0
- package/dist/automations/types.js +1 -0
- package/dist/automations/unattended.d.ts +111 -0
- package/dist/automations/unattended.js +235 -0
- package/dist/background/finish.d.ts +21 -4
- package/dist/background/finish.js +88 -9
- package/dist/background/launch.d.ts +30 -23
- package/dist/background/launch.js +57 -46
- package/dist/background/managed-output.d.ts +110 -0
- package/dist/background/managed-output.js +219 -0
- package/dist/background/managed.d.ts +56 -0
- package/dist/background/managed.js +128 -0
- package/dist/background/poll.job.d.ts +29 -11
- package/dist/background/poll.job.js +141 -71
- package/dist/background/render.d.ts +3 -0
- package/dist/background/render.js +6 -0
- package/dist/background/session.d.ts +3 -44
- package/dist/background/session.js +3 -76
- package/dist/background/stop.d.ts +88 -27
- package/dist/background/stop.js +224 -112
- package/dist/background/store.d.ts +148 -71
- package/dist/background/store.js +348 -154
- package/dist/background/tasks.service.d.ts +56 -5
- package/dist/background/tasks.service.js +125 -67
- package/dist/background/wake-rules.d.ts +5 -0
- package/dist/background/wake-rules.js +22 -6
- package/dist/background/wake.js +3 -2
- package/dist/catalog/admin-catalog.controller.d.ts +106 -29
- package/dist/catalog/admin-catalog.controller.js +89 -44
- package/dist/catalog/admin-catalog.schemas.d.ts +18 -1
- package/dist/catalog/admin-catalog.schemas.js +23 -2
- package/dist/catalog/appearance.service.js +1 -3
- package/dist/catalog/catalog-content.d.ts +63 -28
- package/dist/catalog/catalog-content.js +40 -93
- package/dist/catalog/catalog-import.module.d.ts +1 -1
- package/dist/catalog/catalog-import.module.js +4 -5
- package/dist/catalog/catalog-items.d.ts +14 -20
- package/dist/catalog/catalog-items.js +42 -82
- package/dist/catalog/catalog-scope.service.d.ts +46 -122
- package/dist/catalog/catalog-scope.service.js +187 -702
- package/dist/catalog/catalog.module.d.ts +5 -5
- package/dist/catalog/catalog.module.js +46 -14
- package/dist/catalog/catalog.service.d.ts +45 -16
- package/dist/catalog/catalog.service.js +164 -47
- package/dist/catalog/claude/report.d.ts +9 -2
- package/dist/catalog/claude/report.js +1 -0
- package/dist/catalog/claude/translate.js +2 -2
- package/dist/catalog/cli.d.ts +10 -12
- package/dist/catalog/cli.js +48 -34
- package/dist/catalog/component-promotion.d.ts +3 -1
- package/dist/catalog/component-promotion.js +17 -8
- package/dist/catalog/component-scope.controller.d.ts +10 -15
- package/dist/catalog/component-scope.controller.js +18 -10
- package/dist/catalog/component-scope.schemas.js +2 -0
- package/dist/catalog/component-scope.service.d.ts +31 -2
- package/dist/catalog/component-scope.service.js +147 -140
- package/dist/catalog/component-state.d.ts +47 -8
- package/dist/catalog/component-state.js +92 -29
- package/dist/catalog/credential-key.d.ts +10 -0
- package/dist/catalog/credential-key.js +28 -0
- package/dist/catalog/dependency-edges.d.ts +25 -0
- package/dist/catalog/dependency-edges.js +125 -0
- package/dist/catalog/effect-work.d.ts +27 -0
- package/dist/catalog/effect-work.js +151 -0
- package/dist/catalog/enable-decision.d.ts +34 -0
- package/dist/catalog/enable-decision.js +17 -0
- package/dist/catalog/enable-requests.d.ts +188 -0
- package/dist/catalog/enable-requests.js +786 -0
- package/dist/catalog/enable-targets.d.ts +63 -0
- package/dist/catalog/enable-targets.js +94 -0
- package/dist/catalog/git-source.d.ts +21 -0
- package/dist/catalog/git-source.js +57 -11
- package/dist/catalog/job-ids.d.ts +26 -31
- package/dist/catalog/job-ids.js +26 -26
- package/dist/catalog/jobs.d.ts +15 -3
- package/dist/catalog/jobs.js +38 -7
- package/dist/catalog/marketplace-fetch.d.ts +19 -3
- package/dist/catalog/marketplace-fetch.js +34 -7
- package/dist/catalog/marketplaces.controller.d.ts +3 -2
- package/dist/catalog/marketplaces.controller.js +5 -2
- package/dist/catalog/marketplaces.schemas.d.ts +7 -0
- package/dist/catalog/marketplaces.schemas.js +13 -0
- package/dist/catalog/marketplaces.service.d.ts +73 -14
- package/dist/catalog/marketplaces.service.js +221 -35
- package/dist/catalog/org-catalog.controller.d.ts +34 -40
- package/dist/catalog/org-catalog.controller.js +74 -51
- package/dist/catalog/org-catalog.schemas.d.ts +81 -19
- package/dist/catalog/org-catalog.schemas.js +104 -7
- package/dist/catalog/org-catalog.service.d.ts +23 -2
- package/dist/catalog/org-catalog.service.js +224 -155
- package/dist/catalog/org-extension.controller.d.ts +12 -55
- package/dist/catalog/org-extension.controller.js +26 -110
- package/dist/catalog/org-extension.schemas.d.ts +29 -8
- package/dist/catalog/org-extension.schemas.js +56 -11
- package/dist/catalog/org-intent.d.ts +45 -0
- package/dist/catalog/org-intent.js +205 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
- package/dist/catalog/org-plugin-uploads.controller.js +6 -35
- package/dist/catalog/org-plugin-uploads.d.ts +9 -19
- package/dist/catalog/org-plugin-uploads.js +13 -33
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +0 -1
- package/dist/catalog/org-plugin-uploads.schemas.js +2 -3
- package/dist/catalog/owned-items.d.ts +18 -22
- package/dist/catalog/owned-items.js +71 -89
- package/dist/catalog/ownership.d.ts +5 -32
- package/dist/catalog/ownership.js +29 -93
- package/dist/catalog/platform-components.d.ts +59 -37
- package/dist/catalog/platform-components.js +98 -92
- package/dist/catalog/platform-import-update.d.ts +52 -0
- package/dist/catalog/platform-import-update.js +123 -0
- package/dist/catalog/plugin-connectors.d.ts +50 -0
- package/dist/catalog/plugin-connectors.js +120 -0
- package/dist/catalog/plugin-import.d.ts +135 -93
- package/dist/catalog/plugin-import.js +395 -385
- package/dist/catalog/plugin-install.d.ts +143 -182
- package/dist/catalog/plugin-install.js +537 -648
- package/dist/catalog/plugin-package.d.ts +16 -12
- package/dist/catalog/plugin-package.js +53 -40
- package/dist/catalog/plugin-upgrade.d.ts +118 -47
- package/dist/catalog/plugin-upgrade.js +431 -245
- package/dist/catalog/provenance.d.ts +71 -0
- package/dist/catalog/provenance.js +112 -0
- package/dist/catalog/publisher-policy.d.ts +9 -0
- package/dist/catalog/publisher-policy.js +12 -0
- package/dist/catalog/request-hints.d.ts +19 -0
- package/dist/catalog/request-hints.js +34 -0
- package/dist/catalog/request-rules.d.ts +15 -9
- package/dist/catalog/request-rules.js +96 -34
- package/dist/catalog/requests.service.d.ts +209 -12
- package/dist/catalog/requests.service.js +826 -40
- package/dist/catalog/reserved-names.js +3 -9
- package/dist/catalog/schema-path.d.ts +4 -6
- package/dist/catalog/schema-path.js +48 -21
- package/dist/catalog/scope-orgs.d.ts +3 -2
- package/dist/catalog/scope-orgs.js +6 -11
- package/dist/catalog/scope-state.d.ts +6 -6
- package/dist/catalog/scope-state.js +24 -43
- package/dist/catalog/scope-sync-workers.d.ts +19 -0
- package/dist/catalog/scope-sync-workers.js +58 -3
- package/dist/catalog/scope-sync.d.ts +35 -152
- package/dist/catalog/scope-sync.js +277 -380
- package/dist/catalog/scope-writer.d.ts +107 -0
- package/dist/catalog/scope-writer.js +286 -0
- package/dist/catalog/scope.d.ts +2 -5
- package/dist/catalog/template-connector-ensure.d.ts +97 -0
- package/dist/catalog/template-connector-ensure.js +281 -0
- package/dist/catalog/template-connector-jobs.d.ts +28 -0
- package/dist/catalog/template-connector-jobs.js +54 -0
- package/dist/catalog/template-connectors.processor.d.ts +32 -0
- package/dist/catalog/template-connectors.processor.js +101 -0
- package/dist/catalog/template-description.d.ts +17 -0
- package/dist/catalog/template-description.js +18 -0
- package/dist/catalog/unshare.d.ts +6 -6
- package/dist/catalog/unshare.js +49 -75
- package/dist/channels/actions.d.ts +2 -0
- package/dist/channels/actions.js +44 -5
- package/dist/channels/cards.d.ts +65 -3
- package/dist/channels/cards.js +224 -12
- package/dist/channels/channels.module.d.ts +13 -9
- package/dist/channels/channels.module.js +38 -11
- package/dist/channels/channels.schemas.d.ts +17 -0
- package/dist/channels/channels.schemas.js +17 -0
- package/dist/channels/connection-summary.d.ts +32 -0
- package/dist/channels/connection-summary.js +67 -0
- package/dist/channels/connections.controller.d.ts +5 -3
- package/dist/channels/connections.controller.js +6 -4
- package/dist/channels/connections.service.d.ts +72 -11
- package/dist/channels/connections.service.js +147 -28
- package/dist/channels/deliver-job.d.ts +32 -0
- package/dist/channels/deliver-job.js +29 -0
- package/dist/channels/features.d.ts +20 -1
- package/dist/channels/features.js +31 -5
- package/dist/channels/file-delivery.d.ts +91 -0
- package/dist/channels/file-delivery.js +197 -0
- package/dist/channels/inbound.d.ts +15 -31
- package/dist/channels/inbound.js +65 -26
- package/dist/channels/job-ids.d.ts +2 -6
- package/dist/channels/job-ids.js +2 -6
- package/dist/channels/jobs.d.ts +39 -22
- package/dist/channels/jobs.js +83 -29
- package/dist/channels/outbound.d.ts +57 -5
- package/dist/channels/outbound.js +907 -40
- package/dist/channels/phrases.d.ts +252 -11
- package/dist/channels/phrases.js +204 -12
- package/dist/channels/progress.d.ts +75 -0
- package/dist/channels/progress.js +216 -0
- package/dist/channels/supervisor.d.ts +9 -4
- package/dist/channels/supervisor.js +61 -31
- package/dist/channels/threads.d.ts +16 -3
- package/dist/channels/threads.js +39 -3
- package/dist/channels/webhook.d.ts +1 -0
- package/dist/channels/webhook.js +10 -5
- package/dist/client/client-access.service.d.ts +3 -2
- package/dist/client/client-access.service.js +48 -19
- package/dist/client/client-files.js +1 -1
- package/dist/client/client-reports.service.js +21 -5
- package/dist/client/client-sign-in.service.d.ts +21 -0
- package/dist/client/client-sign-in.service.js +49 -0
- package/dist/client/client.controller.d.ts +7 -3
- package/dist/client/client.controller.js +17 -9
- package/dist/client/client.module.d.ts +2 -1
- package/dist/client/client.module.js +5 -3
- package/dist/client/client.schemas.d.ts +6 -0
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/docs.js +1 -1
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +25 -2
- package/dist/config/fields.js +20 -4
- package/dist/config/load.d.ts +7 -2
- package/dist/config/load.js +63 -4
- package/dist/config/product-name.d.ts +8 -0
- package/dist/config/product-name.js +9 -0
- package/dist/config/schema.d.ts +240 -56
- package/dist/config/schema.js +1153 -136
- package/dist/conversations/access.d.ts +25 -8
- package/dist/conversations/access.js +85 -26
- package/dist/conversations/agent-tree.d.ts +16 -0
- package/dist/conversations/agent-tree.js +36 -0
- package/dist/conversations/approval-profile.d.ts +37 -0
- package/dist/conversations/approval-profile.js +82 -0
- package/dist/conversations/artifacts.d.ts +20 -17
- package/dist/conversations/artifacts.js +30 -37
- package/dist/conversations/attachments.controller.d.ts +12 -17
- package/dist/conversations/attachments.controller.js +19 -57
- package/dist/conversations/attachments.service.d.ts +174 -59
- package/dist/conversations/attachments.service.js +564 -260
- package/dist/conversations/conversation-agent.d.ts +18 -0
- package/dist/conversations/conversation-agent.js +23 -0
- package/dist/conversations/conversation-ref.d.ts +59 -0
- package/dist/conversations/conversation-ref.js +108 -0
- package/dist/conversations/conversations.controller.d.ts +122 -60
- package/dist/conversations/conversations.controller.js +265 -92
- package/dist/conversations/conversations.module.js +30 -0
- package/dist/conversations/conversations.schemas.d.ts +27 -0
- package/dist/conversations/conversations.schemas.js +41 -0
- package/dist/conversations/conversations.service.d.ts +599 -93
- package/dist/conversations/conversations.service.js +1463 -222
- package/dist/conversations/delivery-scope.d.ts +34 -0
- package/dist/conversations/delivery-scope.js +23 -0
- package/dist/conversations/event-log.d.ts +105 -18
- package/dist/conversations/event-log.js +280 -34
- package/dist/conversations/event-people.d.ts +12 -0
- package/dist/conversations/event-people.js +28 -0
- package/dist/conversations/events.d.ts +1244 -60
- package/dist/conversations/events.js +1371 -116
- package/dist/conversations/external/external-calls.d.ts +75 -0
- package/dist/conversations/external/external-calls.js +91 -0
- package/dist/conversations/external/external-calls.processor.d.ts +45 -0
- package/dist/conversations/external/external-calls.processor.js +144 -0
- package/dist/conversations/external/external-conversations.service.d.ts +272 -0
- package/dist/conversations/external/external-conversations.service.js +1196 -0
- package/dist/conversations/external/external.schemas.d.ts +63 -0
- package/dist/conversations/external/external.schemas.js +52 -0
- package/dist/conversations/external/token.d.ts +6 -0
- package/dist/conversations/external/token.js +6 -0
- package/dist/conversations/files.d.ts +98 -26
- package/dist/conversations/files.js +225 -87
- package/dist/conversations/inline-tokens.d.ts +87 -0
- package/dist/conversations/inline-tokens.js +154 -0
- package/dist/conversations/job-org.d.ts +5 -0
- package/dist/conversations/job-org.js +23 -0
- package/dist/conversations/leak-check.d.ts +26 -0
- package/dist/conversations/leak-check.js +70 -0
- package/dist/conversations/media-types.d.ts +25 -0
- package/dist/conversations/media-types.js +38 -0
- package/dist/conversations/message-context.d.ts +6 -3
- package/dist/conversations/message-context.js +14 -10
- package/dist/conversations/model-image.d.ts +39 -0
- package/dist/conversations/model-image.js +80 -0
- package/dist/conversations/permission-profile-store.d.ts +54 -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 +138 -0
- package/dist/conversations/permission-profiles.controller.js +186 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +36 -0
- package/dist/conversations/permission-profiles.schemas.js +31 -0
- package/dist/conversations/permission-profiles.service.d.ts +76 -0
- package/dist/conversations/permission-profiles.service.js +203 -0
- package/dist/conversations/prompt-suggestion-request.d.ts +95 -0
- package/dist/conversations/prompt-suggestion-request.js +215 -0
- package/dist/conversations/prompt-suggestion-store.d.ts +53 -0
- package/dist/conversations/prompt-suggestion-store.js +141 -0
- package/dist/conversations/prompt-suggestions.d.ts +148 -0
- package/dist/conversations/prompt-suggestions.js +572 -0
- package/dist/conversations/queue.d.ts +21 -5
- package/dist/conversations/queue.js +37 -4
- package/dist/conversations/queue.service.d.ts +20 -9
- package/dist/conversations/queue.service.js +117 -41
- package/dist/conversations/selection.js +1 -0
- package/dist/conversations/source.d.ts +10 -0
- package/dist/conversations/source.js +19 -0
- package/dist/conversations/titles.d.ts +24 -12
- package/dist/conversations/titles.js +89 -54
- package/dist/conversations/tree.d.ts +10 -0
- package/dist/conversations/tree.js +41 -0
- package/dist/ctx/bus.js +6 -3
- package/dist/ctx/create-ctx.d.ts +171 -34
- package/dist/ctx/create-ctx.js +865 -229
- package/dist/ctx/device-provider-check.d.ts +11 -0
- package/dist/ctx/device-provider-check.js +36 -0
- package/dist/ctx/durable-cancellation.d.ts +3 -0
- package/dist/ctx/durable-cancellation.js +8 -0
- package/dist/ctx/durable-effects.service.d.ts +81 -0
- package/dist/ctx/durable-effects.service.js +316 -0
- package/dist/ctx/durable-envelope.d.ts +24 -0
- package/dist/ctx/durable-envelope.js +80 -0
- package/dist/ctx/durable-failure.d.ts +7 -0
- package/dist/ctx/durable-failure.js +32 -0
- package/dist/ctx/durable-job.d.ts +9 -0
- package/dist/ctx/durable-job.js +2 -0
- package/dist/ctx/durable-keys.d.ts +27 -0
- package/dist/ctx/durable-keys.js +138 -0
- package/dist/ctx/durable-relay.d.ts +26 -0
- package/dist/ctx/durable-relay.js +277 -0
- package/dist/ctx/guard-db.d.ts +6 -0
- package/dist/ctx/guard-db.js +55 -0
- package/dist/ctx/net.d.ts +54 -0
- package/dist/ctx/net.js +117 -0
- package/dist/ctx/queue.d.ts +2 -0
- package/dist/ctx/queue.js +28 -16
- package/dist/ctx/secrets.d.ts +41 -5
- package/dist/ctx/secrets.js +140 -30
- package/dist/db/extension-db.d.ts +35 -0
- package/dist/db/extension-db.js +193 -0
- package/dist/db/extension-handoff-schema.d.ts +6 -0
- package/dist/db/extension-handoff-schema.js +115 -0
- package/dist/db/extension-rls-predicate.d.ts +1 -0
- package/dist/db/extension-rls-predicate.js +8 -0
- package/dist/db/extension-role-provision.d.ts +9 -0
- package/dist/db/extension-role-provision.js +89 -0
- package/dist/db/extension-schema-transfer.d.ts +7 -0
- package/dist/db/extension-schema-transfer.js +240 -0
- package/dist/db/kernel-schema.d.ts +1277 -125
- package/dist/db/migrator.d.ts +14 -0
- package/dist/db/migrator.js +89 -8
- package/dist/db/pool.d.ts +10 -0
- package/dist/db/pool.js +43 -2
- package/dist/db/sql-statements.d.ts +3 -0
- package/dist/db/sql-statements.js +15 -5
- package/dist/device-access/conversation-notice-delivery.d.ts +116 -0
- package/dist/device-access/conversation-notice-delivery.js +344 -0
- package/dist/device-access/conversation-notices.d.ts +27 -0
- package/dist/device-access/conversation-notices.js +42 -0
- package/dist/device-access/device-access.module.d.ts +7 -0
- package/dist/device-access/device-access.module.js +53 -0
- package/dist/device-access/device-access.service.d.ts +304 -0
- package/dist/device-access/device-access.service.js +1019 -0
- package/dist/device-access/host-gate.d.ts +45 -0
- package/dist/device-access/host-gate.js +92 -0
- package/dist/device-access/host-service-stop-sweep.d.ts +33 -0
- package/dist/device-access/host-service-stop-sweep.js +112 -0
- package/dist/device-access/host-service-stop.d.ts +78 -0
- package/dist/device-access/host-service-stop.js +144 -0
- package/dist/device-access/host-services.d.ts +217 -0
- package/dist/device-access/host-services.js +807 -0
- package/dist/device-access/person-handles.d.ts +19 -0
- package/dist/device-access/person-handles.js +30 -0
- package/dist/device-access/service-events.d.ts +199 -0
- package/dist/device-access/service-events.js +704 -0
- package/dist/device-access/site-access-request.d.ts +14 -0
- package/dist/device-access/site-access-request.js +35 -0
- package/dist/device-access/site-grants.d.ts +53 -0
- package/dist/device-access/site-grants.js +268 -0
- package/dist/device-access/site-grants.module.d.ts +2 -0
- package/dist/device-access/site-grants.module.js +14 -0
- package/dist/device-access/token.d.ts +11 -0
- package/dist/device-access/token.js +11 -0
- package/dist/device-access/viewer-routes.d.ts +45 -0
- package/dist/device-access/viewer-routes.js +81 -0
- package/dist/device-access/viewer.d.ts +249 -0
- package/dist/device-access/viewer.js +867 -0
- package/dist/devices/access.d.ts +15 -46
- package/dist/devices/access.js +26 -63
- package/dist/devices/access.module.d.ts +2 -0
- package/dist/devices/access.module.js +19 -0
- package/dist/devices/conversation-devices.d.ts +107 -19
- package/dist/devices/conversation-devices.js +194 -56
- package/dist/devices/default-provider-setting.d.ts +45 -0
- package/dist/devices/default-provider-setting.js +59 -0
- package/dist/devices/device-project-files.service.d.ts +88 -0
- package/dist/devices/device-project-files.service.js +249 -0
- package/dist/devices/device-projects.service.d.ts +188 -0
- package/dist/devices/device-projects.service.js +474 -0
- package/dist/devices/device-provider-selection.d.ts +36 -0
- package/dist/devices/device-provider-selection.js +85 -0
- package/dist/devices/device-provider-selection.module.d.ts +3 -0
- package/dist/devices/device-provider-selection.module.js +22 -0
- package/dist/devices/devices.controller.d.ts +36 -11
- package/dist/devices/devices.controller.js +101 -21
- package/dist/devices/devices.module.js +36 -6
- package/dist/devices/devices.schemas.d.ts +5 -1
- package/dist/devices/devices.schemas.js +21 -4
- package/dist/devices/devices.service.d.ts +372 -118
- package/dist/devices/devices.service.js +846 -322
- package/dist/devices/dto.d.ts +97 -3
- package/dist/devices/dto.js +102 -2
- package/dist/devices/errors.d.ts +14 -0
- package/dist/devices/errors.js +14 -0
- package/dist/devices/label.d.ts +3 -5
- package/dist/devices/label.js +3 -14
- package/dist/devices/project-paths.d.ts +29 -0
- package/dist/devices/project-paths.js +66 -0
- package/dist/devices/project-rules.d.ts +34 -0
- package/dist/devices/project-rules.js +20 -0
- package/dist/devices/public-suffix.d.ts +6 -0
- package/dist/devices/public-suffix.js +79 -0
- package/dist/devices/working-root.d.ts +43 -0
- package/dist/devices/working-root.js +56 -0
- package/dist/dial-in/access.d.ts +45 -0
- package/dist/dial-in/access.js +97 -0
- package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +13 -7
- package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +33 -17
- package/dist/dial-in/auth.module.d.ts +7 -0
- package/dist/dial-in/auth.module.js +27 -0
- package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +52 -13
- package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +108 -33
- package/dist/dial-in/dial-in.module.d.ts +9 -0
- package/dist/dial-in/dial-in.module.js +37 -0
- package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
- package/dist/{local-devices → dial-in}/dto.js +14 -2
- package/dist/dial-in/envelope.d.ts +95 -0
- package/dist/dial-in/envelope.js +89 -0
- package/dist/dial-in/gateway.d.ts +278 -0
- package/dist/dial-in/gateway.js +1083 -0
- package/dist/dial-in/handlers.d.ts +56 -0
- package/dist/dial-in/handlers.js +100 -0
- package/dist/{local-devices → dial-in}/keys.d.ts +12 -0
- package/dist/{local-devices → dial-in}/keys.js +12 -0
- package/dist/{local-devices → dial-in}/machines.d.ts +62 -29
- package/dist/{local-devices → dial-in}/machines.js +110 -116
- package/dist/dial-in/relay.d.ts +167 -0
- package/dist/dial-in/relay.js +517 -0
- package/dist/dial-in/relay.module.d.ts +7 -0
- package/dist/dial-in/relay.module.js +24 -0
- package/dist/dial-in/routes.d.ts +56 -0
- package/dist/dial-in/routes.js +133 -0
- package/dist/dial-in/streams.d.ts +66 -0
- package/dist/dial-in/streams.js +296 -0
- package/dist/dial-in/targets.d.ts +45 -0
- package/dist/dial-in/targets.js +91 -0
- package/dist/erasure/account-batches.d.ts +9 -0
- package/dist/erasure/account-batches.js +569 -0
- package/dist/erasure/account-files.d.ts +34 -0
- package/dist/erasure/account-files.js +217 -0
- package/dist/erasure/account-residual.d.ts +15 -0
- package/dist/erasure/account-residual.js +150 -0
- package/dist/erasure/account-worker.d.ts +32 -0
- package/dist/erasure/account-worker.js +392 -0
- package/dist/erasure/device-cleanup.d.ts +23 -0
- package/dist/erasure/device-cleanup.js +233 -0
- package/dist/erasure/erasure.module.d.ts +2 -0
- package/dist/erasure/erasure.module.js +14 -0
- package/dist/erasure/external-evidence.d.ts +4 -0
- package/dist/erasure/external-evidence.js +28 -0
- package/dist/erasure/jobs.d.ts +5 -0
- package/dist/erasure/jobs.js +20 -0
- package/dist/erasure/org-batches.d.ts +11 -0
- package/dist/erasure/org-batches.js +154 -0
- package/dist/erasure/org-catalog.d.ts +2 -0
- package/dist/erasure/org-catalog.js +45 -0
- package/dist/erasure/org-rules.d.ts +14 -0
- package/dist/erasure/org-rules.js +245 -0
- package/dist/erasure/org-worker.d.ts +38 -0
- package/dist/erasure/org-worker.js +488 -0
- package/dist/erasure/requests.d.ts +61 -0
- package/dist/erasure/requests.js +180 -0
- package/dist/erasure/sweep.job.d.ts +19 -0
- package/dist/erasure/sweep.job.js +130 -0
- package/dist/erasure/worker.d.ts +17 -0
- package/dist/erasure/worker.js +110 -0
- package/dist/errors.d.ts +438 -20
- package/dist/errors.js +439 -21
- package/dist/evals/budget.js +14 -1
- package/dist/evals/canonical-json.d.ts +7 -0
- package/dist/evals/canonical-json.js +21 -0
- package/dist/evals/evals.module.js +16 -3
- package/dist/evals/evals.schemas.d.ts +15 -5
- package/dist/evals/evals.schemas.js +17 -10
- package/dist/evals/jobs.d.ts +14 -6
- package/dist/evals/jobs.js +21 -19
- package/dist/evals/judge.d.ts +8 -0
- package/dist/evals/judge.js +16 -1
- package/dist/evals/plan.d.ts +23 -16
- package/dist/evals/plan.js +54 -11
- package/dist/evals/reconstruct.d.ts +103 -23
- package/dist/evals/reconstruct.js +203 -74
- package/dist/evals/recorded-permission-context.d.ts +79 -0
- package/dist/evals/recorded-permission-context.js +155 -0
- package/dist/evals/recorded-tools.d.ts +22 -36
- package/dist/evals/recorded-tools.js +32 -111
- package/dist/evals/run-replay.d.ts +34 -9
- package/dist/evals/run-replay.js +139 -62
- package/dist/evals/runs.controller.d.ts +4 -12
- package/dist/evals/runs.controller.js +14 -11
- package/dist/evals/runs.service.d.ts +34 -31
- package/dist/evals/runs.service.js +100 -103
- package/dist/evals/sets.service.d.ts +18 -11
- package/dist/evals/sets.service.js +71 -30
- package/dist/evals/snapshot.d.ts +34 -6
- package/dist/evals/snapshot.js +121 -74
- package/dist/evals/step-replay.d.ts +14 -4
- package/dist/evals/step-replay.js +26 -8
- package/dist/evals/trajectory.controller.d.ts +10 -6
- package/dist/evals/trajectory.controller.js +11 -4
- package/dist/evals/trajectory.d.ts +26 -13
- package/dist/evals/trajectory.js +46 -24
- package/dist/evals/trajectory.service.d.ts +24 -19
- package/dist/evals/trajectory.service.js +76 -61
- package/dist/evals/worker.d.ts +17 -1
- package/dist/evals/worker.js +162 -51
- package/dist/extensions/admin-ops.d.ts +36 -7
- package/dist/extensions/admin-ops.js +178 -39
- package/dist/extensions/admin-view.d.ts +37 -8
- package/dist/extensions/admin-view.js +125 -46
- package/dist/extensions/blobs.d.ts +2 -0
- package/dist/extensions/blobs.js +11 -0
- package/dist/extensions/bootstrap-defaults.d.ts +24 -0
- package/dist/extensions/bootstrap-defaults.js +78 -0
- package/dist/extensions/bootstrap-extra.d.ts +84 -0
- package/dist/extensions/bootstrap-extra.js +151 -0
- package/dist/extensions/bootstrap-manifest.d.ts +14 -0
- package/dist/extensions/bootstrap-manifest.js +23 -0
- package/dist/extensions/bootstrap-packages.d.ts +103 -0
- package/dist/extensions/bootstrap-packages.js +303 -0
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +182 -52
- package/dist/extensions/bootstrap.js +544 -258
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +5 -1
- package/dist/extensions/config-hash.d.ts +2 -0
- package/dist/extensions/config-hash.js +1 -1
- package/dist/extensions/config-json-schema.d.ts +12 -8
- package/dist/extensions/config-json-schema.js +13 -11
- package/dist/extensions/deployed-snapshots.d.ts +22 -0
- package/dist/extensions/deployed-snapshots.js +64 -0
- package/dist/extensions/deployment-config-store.d.ts +2 -0
- package/dist/extensions/deployment-config-store.js +18 -14
- package/dist/extensions/deployment-config.d.ts +18 -7
- package/dist/extensions/deployment-config.js +56 -30
- package/dist/extensions/effective-config.d.ts +6 -9
- package/dist/extensions/effective-config.js +7 -13
- package/dist/extensions/enabled.d.ts +203 -21
- package/dist/extensions/enabled.js +163 -39
- package/dist/extensions/execution-realm.d.ts +96 -0
- package/dist/extensions/execution-realm.js +141 -0
- package/dist/extensions/extensions.module.js +46 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +124 -0
- package/dist/extensions/grant-epoch.js +248 -0
- package/dist/extensions/guide-places.d.ts +18 -2
- package/dist/extensions/guide-places.js +46 -23
- package/dist/extensions/hooks.d.ts +30 -6
- package/dist/extensions/hooks.js +24 -4
- package/dist/extensions/host.d.ts +268 -62
- package/dist/extensions/host.js +1168 -207
- package/dist/extensions/installs.d.ts +34 -17
- package/dist/extensions/installs.js +68 -33
- package/dist/extensions/instance.d.ts +17 -7
- package/dist/extensions/instance.js +22 -6
- package/dist/extensions/isolated/admission.d.ts +31 -0
- package/dist/extensions/isolated/admission.js +233 -0
- package/dist/extensions/isolated/authorization.d.ts +103 -0
- package/dist/extensions/isolated/authorization.js +312 -0
- package/dist/extensions/isolated/broker.d.ts +18 -0
- package/dist/extensions/isolated/broker.js +507 -0
- package/dist/extensions/isolated/child-protocol.d.ts +84 -0
- package/dist/extensions/isolated/child-protocol.js +21 -0
- package/dist/extensions/isolated/child-registration.d.ts +22 -0
- package/dist/extensions/isolated/child-registration.js +152 -0
- package/dist/extensions/isolated/child-session.d.ts +6 -0
- package/dist/extensions/isolated/child-session.js +342 -0
- package/dist/extensions/isolated/child-streams.d.ts +4 -0
- package/dist/extensions/isolated/child-streams.js +142 -0
- package/dist/extensions/isolated/child.d.ts +1 -0
- package/dist/extensions/isolated/child.js +10 -0
- package/dist/extensions/isolated/configured-package.d.ts +20 -0
- package/dist/extensions/isolated/configured-package.js +75 -0
- package/dist/extensions/isolated/engine-binds.d.ts +9 -0
- package/dist/extensions/isolated/engine-binds.js +82 -0
- package/dist/extensions/isolated/engine-policy.d.ts +85 -0
- package/dist/extensions/isolated/engine-policy.js +75 -0
- package/dist/extensions/isolated/engine-proxy-main.d.ts +1 -0
- package/dist/extensions/isolated/engine-proxy-main.js +20 -0
- package/dist/extensions/isolated/engine-proxy.d.ts +7 -0
- package/dist/extensions/isolated/engine-proxy.js +408 -0
- package/dist/extensions/isolated/engine-vaults.d.ts +12 -0
- package/dist/extensions/isolated/engine-vaults.js +93 -0
- package/dist/extensions/isolated/lanes.d.ts +149 -0
- package/dist/extensions/isolated/lanes.js +909 -0
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/postgres-gate.d.ts +15 -0
- package/dist/extensions/isolated/postgres-gate.js +255 -0
- package/dist/extensions/isolated/revision.d.ts +38 -0
- package/dist/extensions/isolated/revision.js +380 -0
- package/dist/extensions/isolated/rpc-frame.d.ts +50 -0
- package/dist/extensions/isolated/rpc-frame.js +193 -0
- package/dist/extensions/isolated/rpc.d.ts +71 -0
- package/dist/extensions/isolated/rpc.js +319 -0
- package/dist/extensions/isolated/sandbox.d.ts +62 -0
- package/dist/extensions/isolated/sandbox.js +406 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +145 -0
- package/dist/extensions/isolated/tier.js +331 -0
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/ledger.d.ts +6 -1
- package/dist/extensions/ledger.js +16 -0
- package/dist/extensions/lifecycle-hooks.d.ts +113 -0
- package/dist/extensions/lifecycle-hooks.js +308 -0
- package/dist/extensions/lifecycle-topics.d.ts +2 -0
- package/dist/extensions/lifecycle-topics.js +2 -0
- package/dist/extensions/lifecycle.d.ts +49 -2
- package/dist/extensions/lifecycle.js +158 -7
- package/dist/extensions/locks.d.ts +3 -1
- package/dist/extensions/locks.js +8 -1
- package/dist/extensions/migrate-lock.d.ts +4 -1
- package/dist/extensions/migrate-lock.js +20 -2
- package/dist/extensions/org-config.d.ts +90 -88
- package/dist/extensions/org-config.js +228 -371
- package/dist/extensions/org-levels.d.ts +22 -9
- package/dist/extensions/org-levels.js +100 -20
- package/dist/extensions/org-overrides.d.ts +22 -16
- package/dist/extensions/org-overrides.js +37 -25
- package/dist/extensions/package-digest.job.d.ts +34 -0
- package/dist/extensions/package-digest.job.js +121 -0
- package/dist/extensions/package.d.ts +20 -6
- package/dist/extensions/package.js +36 -15
- package/dist/extensions/permission-set.d.ts +72 -32
- package/dist/extensions/permission-set.js +40 -77
- package/dist/extensions/permission-view.d.ts +66 -19
- package/dist/extensions/permission-view.js +141 -24
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/plugin-guides.d.ts +45 -13
- package/dist/extensions/plugin-guides.js +113 -52
- package/dist/extensions/plugin-icons.d.ts +87 -20
- package/dist/extensions/plugin-icons.js +216 -37
- package/dist/extensions/plugin-items.d.ts +24 -0
- package/dist/extensions/plugin-items.js +52 -22
- package/dist/extensions/point-defaults.d.ts +43 -11
- package/dist/extensions/point-defaults.js +62 -51
- package/dist/extensions/point-serving.d.ts +56 -0
- package/dist/extensions/point-serving.js +120 -0
- package/dist/extensions/publisher-proof.job.d.ts +39 -0
- package/dist/extensions/publisher-proof.job.js +160 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/registry.d.ts +6 -0
- package/dist/extensions/registry.js +13 -1
- package/dist/extensions/resolve.d.ts +7 -8
- package/dist/extensions/resolve.js +14 -10
- package/dist/extensions/review-hash.d.ts +114 -0
- package/dist/extensions/review-hash.js +145 -0
- package/dist/extensions/revision-approvals.d.ts +222 -0
- package/dist/extensions/revision-approvals.js +474 -0
- package/dist/extensions/revision-grants.d.ts +207 -0
- package/dist/extensions/revision-grants.js +584 -0
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation-leases.d.ts +273 -0
- package/dist/extensions/revocation-leases.js +533 -0
- package/dist/extensions/revocation.d.ts +78 -0
- package/dist/extensions/revocation.js +205 -0
- package/dist/extensions/run-lifecycle-owe.d.ts +70 -0
- package/dist/extensions/run-lifecycle-owe.js +88 -0
- package/dist/extensions/source-intent.d.ts +14 -0
- package/dist/extensions/source-intent.js +77 -0
- package/dist/extensions/sources.d.ts +1 -0
- package/dist/extensions/sources.js +9 -0
- package/dist/extensions/state.module.js +24 -1
- package/dist/extensions/sync.d.ts +9 -5
- package/dist/extensions/sync.js +33 -32
- package/dist/extensions/unavailable.js +0 -1
- package/dist/extensions/usage-subscribers.d.ts +43 -0
- package/dist/extensions/usage-subscribers.js +108 -0
- package/dist/files/blob-objects.d.ts +128 -0
- package/dist/files/blob-objects.js +358 -0
- package/dist/files/blob-references.d.ts +8 -0
- package/dist/files/blob-references.js +19 -0
- package/dist/files/blob-sweep.job.d.ts +124 -0
- package/dist/files/blob-sweep.job.js +418 -0
- package/dist/files/blobs.service.d.ts +135 -0
- package/dist/files/blobs.service.js +300 -0
- package/dist/files/conversation-media.d.ts +41 -0
- package/dist/files/conversation-media.js +124 -0
- package/dist/files/deliveries.d.ts +64 -0
- package/dist/files/deliveries.js +156 -0
- package/dist/files/deliveries.module.d.ts +6 -0
- package/dist/files/deliveries.module.js +24 -0
- package/dist/files/draft-cleanup.job.d.ts +26 -0
- package/dist/files/draft-cleanup.job.js +93 -0
- package/dist/files/files.module.d.ts +4 -1
- package/dist/files/files.module.js +7 -2
- package/dist/files/hash-job.d.ts +117 -0
- package/dist/files/hash-job.js +428 -0
- package/dist/files/library-files.service.d.ts +268 -0
- package/dist/files/library-files.service.js +914 -0
- package/dist/files/library-jobs.module.d.ts +3 -0
- package/dist/files/library-jobs.module.js +21 -0
- package/dist/files/library-query.d.ts +127 -0
- package/dist/files/library-query.js +322 -0
- package/dist/files/library-read.module.d.ts +9 -0
- package/dist/files/library-read.module.js +30 -0
- package/dist/files/library.controller.d.ts +77 -0
- package/dist/files/library.controller.js +235 -0
- package/dist/files/library.module.d.ts +9 -0
- package/dist/files/library.module.js +29 -0
- package/dist/files/library.schemas.d.ts +46 -0
- package/dist/files/library.schemas.js +49 -0
- package/dist/files/previewers.controller.d.ts +32 -0
- package/dist/files/previewers.controller.js +99 -0
- package/dist/files/previewers.d.ts +112 -11
- package/dist/files/previewers.js +215 -43
- package/dist/files/referenced-files.d.ts +150 -0
- package/dist/files/referenced-files.js +234 -0
- package/dist/git/gateway.d.ts +109 -0
- package/dist/git/gateway.js +828 -0
- package/dist/git/gateway.route.d.ts +16 -0
- package/dist/git/gateway.route.js +39 -0
- package/dist/git/git.module.d.ts +9 -0
- package/dist/git/git.module.js +31 -0
- package/dist/git/identity.d.ts +80 -0
- package/dist/git/identity.js +209 -0
- package/dist/git/pkt-line.d.ts +53 -0
- package/dist/git/pkt-line.js +146 -0
- package/dist/git/run-end.d.ts +57 -0
- package/dist/git/run-end.js +170 -0
- package/dist/git/sources.d.ts +42 -0
- package/dist/git/sources.js +134 -0
- package/dist/git/tickets.d.ts +69 -0
- package/dist/git/tickets.js +199 -0
- package/dist/handoff/app-schemes.d.ts +28 -0
- package/dist/handoff/app-schemes.js +41 -0
- package/dist/handoff/handoff-paths.d.ts +26 -0
- package/dist/handoff/handoff-paths.js +25 -0
- package/dist/handoff/handoff-tickets.d.ts +28 -0
- package/dist/handoff/handoff-tickets.js +111 -0
- package/dist/handoff/handoff.controller.d.ts +24 -0
- package/dist/handoff/handoff.controller.js +74 -0
- package/dist/handoff/handoff.module.d.ts +7 -0
- package/dist/handoff/handoff.module.js +26 -0
- package/dist/handoff/handoff.schemas.d.ts +13 -0
- package/dist/handoff/handoff.schemas.js +3 -0
- package/dist/handoff/handoff.service.d.ts +49 -0
- package/dist/handoff/handoff.service.js +96 -0
- package/dist/html/csp.d.ts +13 -0
- package/dist/html/csp.js +33 -0
- package/dist/html/html-document.controller.d.ts +38 -0
- package/dist/html/html-document.controller.js +96 -0
- package/dist/html/html-document.service.d.ts +64 -0
- package/dist/html/html-document.service.js +166 -0
- package/dist/html/html-token.d.ts +67 -0
- package/dist/html/html-token.js +168 -0
- package/dist/html/html-type.d.ts +15 -0
- package/dist/html/html-type.js +44 -0
- package/dist/html/html.module.d.ts +6 -0
- package/dist/html/html.module.js +33 -0
- package/dist/http/api.module.js +104 -9
- package/dist/http/app.d.ts +14 -2
- package/dist/http/app.js +31 -5
- package/dist/http/error.filter.d.ts +2 -0
- package/dist/http/error.filter.js +11 -2
- package/dist/http/gateway-routes.d.ts +9 -5
- package/dist/http/gateway-routes.js +5 -4
- package/dist/http/meta.controller.d.ts +50 -0
- package/dist/http/meta.controller.js +121 -0
- package/dist/http/plugin-dispatch.d.ts +55 -18
- package/dist/http/plugin-dispatch.js +132 -29
- package/dist/http/plugin-route-access.d.ts +57 -0
- package/dist/http/plugin-route-access.js +213 -0
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/identity/account-avatar.controller.d.ts +30 -0
- package/dist/identity/account-avatar.controller.js +119 -0
- package/dist/identity/account-avatar.d.ts +67 -0
- package/dist/identity/account-avatar.js +136 -0
- package/dist/identity/account-avatars.service.d.ts +77 -0
- package/dist/identity/account-avatars.service.js +321 -0
- package/dist/identity/accounts.d.ts +63 -14
- package/dist/identity/accounts.js +191 -29
- package/dist/identity/api-tokens.d.ts +2 -0
- package/dist/identity/api-tokens.js +68 -36
- package/dist/identity/app-auth.controller.d.ts +26 -0
- package/dist/identity/app-auth.controller.js +65 -0
- package/dist/identity/app-auth.d.ts +84 -0
- package/dist/identity/app-auth.js +212 -0
- package/dist/identity/app-auth.schemas.d.ts +60 -0
- package/dist/identity/app-auth.schemas.js +46 -0
- package/dist/identity/audit.d.ts +2 -13
- package/dist/identity/audit.js +4 -39
- package/dist/identity/auth.controller.d.ts +2 -0
- package/dist/identity/auth.controller.js +6 -10
- package/dist/identity/auth.guard.d.ts +27 -12
- package/dist/identity/auth.guard.js +75 -35
- package/dist/identity/binding.d.ts +1 -1
- package/dist/identity/binding.js +19 -10
- package/dist/identity/cookies.d.ts +4 -9
- package/dist/identity/cookies.js +8 -32
- package/dist/identity/erasure-admission.d.ts +3 -0
- package/dist/identity/erasure-admission.js +14 -0
- package/dist/identity/external.d.ts +78 -40
- package/dist/identity/external.js +169 -73
- package/dist/identity/identity.module.d.ts +2 -1
- package/dist/identity/identity.module.js +21 -1
- package/dist/identity/initial-passwords.controller.d.ts +8 -6
- package/dist/identity/initial-passwords.controller.js +13 -7
- package/dist/identity/initial-passwords.d.ts +23 -14
- package/dist/identity/initial-passwords.job.d.ts +3 -2
- package/dist/identity/initial-passwords.job.js +11 -5
- package/dist/identity/initial-passwords.js +26 -31
- package/dist/identity/linked-accounts.d.ts +42 -0
- package/dist/identity/linked-accounts.js +78 -0
- package/dist/identity/login-sources.d.ts +160 -0
- package/dist/identity/login-sources.js +403 -0
- package/dist/identity/me.controller.d.ts +33 -7
- package/dist/identity/me.controller.js +61 -8
- package/dist/identity/me.schemas.d.ts +39 -0
- package/dist/identity/me.schemas.js +35 -0
- package/dist/identity/principal.d.ts +2 -2
- package/dist/identity/principal.js +2 -2
- package/dist/identity/sessions.d.ts +7 -6
- package/dist/identity/sessions.js +38 -25
- package/dist/identity/settings.d.ts +361 -3
- package/dist/identity/settings.js +651 -20
- package/dist/identity/sso-decisions.d.ts +75 -0
- package/dist/identity/sso-decisions.js +42 -0
- package/dist/identity/sso-link.d.ts +61 -0
- package/dist/identity/sso-link.js +157 -0
- package/dist/identity/sso-paths.d.ts +7 -0
- package/dist/identity/sso-paths.js +13 -0
- package/dist/identity/sso.controller.d.ts +122 -14
- package/dist/identity/sso.controller.js +261 -33
- package/dist/identity/sso.d.ts +87 -28
- package/dist/identity/sso.js +155 -69
- package/dist/identity/write-actor.d.ts +11 -0
- package/dist/identity/write-actor.js +7 -0
- package/dist/inbox/inbox-item-actions.d.ts +37 -0
- package/dist/inbox/inbox-item-actions.js +69 -0
- package/dist/inbox/inbox-items.controller.d.ts +27 -0
- package/dist/inbox/inbox-items.controller.js +80 -0
- package/dist/inbox/inbox-items.service.d.ts +133 -0
- package/dist/inbox/inbox-items.service.js +414 -0
- package/dist/inbox/inbox.module.d.ts +2 -1
- package/dist/inbox/inbox.module.js +19 -4
- package/dist/inbox/inbox.schemas.d.ts +20 -1
- package/dist/inbox/inbox.schemas.js +16 -1
- package/dist/inbox/inbox.service.d.ts +57 -32
- package/dist/inbox/inbox.service.js +47 -11
- package/dist/inbox/org-notices.d.ts +5 -18
- package/dist/inbox/org-notices.js +11 -7
- package/dist/inbox/platform-inbox.service.d.ts +57 -43
- package/dist/inbox/platform-inbox.service.js +122 -95
- package/dist/inbox/platform-notices.d.ts +20 -5
- package/dist/inbox/platform-notices.js +27 -1
- package/dist/inbox/token.d.ts +5 -0
- package/dist/inbox/token.js +5 -0
- package/dist/index.d.ts +31 -7
- package/dist/index.js +31 -7
- package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
- package/dist/infra/cli/kernel-cli.module.js +10 -2
- package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
- package/dist/infra/cli/master-key-rewrap.js +24 -0
- package/dist/infra/config/kernel-config.service.d.ts +14 -1
- package/dist/infra/config/kernel-config.service.js +127 -25
- package/dist/infra/database/database.module.js +8 -1
- package/dist/infra/database/extension-effect-key-lock.d.ts +10 -0
- package/dist/infra/database/extension-effect-key-lock.js +76 -0
- package/dist/infra/database/extension-handoff.d.ts +27 -0
- package/dist/infra/database/extension-handoff.js +113 -0
- package/dist/infra/database/kernel-db.d.ts +3 -1
- package/dist/infra/database/kernel-db.js +4 -0
- package/dist/infra/database/org-scope.d.ts +61 -0
- package/dist/infra/database/org-scope.js +74 -0
- package/dist/infra/database/rls-role.d.ts +4 -0
- package/dist/infra/database/rls-role.js +77 -0
- package/dist/infra/database/scoped-dialect.d.ts +21 -0
- package/dist/infra/database/scoped-dialect.js +445 -0
- package/dist/infra/database/startup-activation-transaction.d.ts +38 -0
- package/dist/infra/database/startup-activation-transaction.js +243 -0
- package/dist/infra/database/transaction-host.d.ts +79 -0
- package/dist/infra/database/transaction-host.js +159 -3
- package/dist/infra/database/xact-lock.d.ts +17 -0
- package/dist/infra/database/xact-lock.js +34 -1
- package/dist/infra/events/kernel-events.d.ts +23 -36
- package/dist/infra/health/health.controller.js +8 -0
- package/dist/infra/health/process-fault.d.ts +16 -0
- package/dist/infra/health/process-fault.js +49 -0
- package/dist/infra/lifecycle/process-guards.d.ts +8 -2
- package/dist/infra/lifecycle/process-guards.js +12 -3
- package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
- package/dist/infra/lifecycle/shutdown-signals.js +28 -13
- package/dist/infra/lock/lock.service.d.ts +5 -1
- package/dist/infra/lock/lock.service.js +10 -4
- package/dist/infra/metrics/kernel-metrics.d.ts +18 -0
- package/dist/infra/metrics/kernel-metrics.js +54 -0
- package/dist/infra/metrics/operational-metrics.d.ts +31 -0
- package/dist/infra/metrics/operational-metrics.js +188 -0
- package/dist/infra/outbox/outbox-relay.module.d.ts +6 -0
- package/dist/infra/outbox/outbox-relay.module.js +18 -0
- package/dist/infra/outbox/outbox.dispatcher.d.ts +108 -0
- package/dist/infra/outbox/outbox.dispatcher.js +385 -0
- package/dist/infra/outbox/outbox.module.d.ts +24 -0
- package/dist/infra/outbox/outbox.module.js +52 -0
- package/dist/infra/outbox/outbox.relay.d.ts +31 -0
- package/dist/infra/outbox/outbox.relay.js +76 -0
- package/dist/infra/outbox/outbox.service.d.ts +62 -0
- package/dist/infra/outbox/outbox.service.js +176 -0
- package/dist/infra/outbox/registry.d.ts +700 -0
- package/dist/infra/outbox/registry.js +600 -0
- package/dist/infra/paging/paged-read.d.ts +86 -0
- package/dist/infra/paging/paged-read.js +115 -0
- package/dist/infra/presence/presence.module.d.ts +6 -0
- package/dist/infra/presence/presence.module.js +22 -0
- package/dist/infra/presence/replica-presence.d.ts +87 -0
- package/dist/infra/presence/replica-presence.js +189 -0
- package/dist/infra/queue/queue-names.d.ts +8 -0
- package/dist/infra/queue/queue-names.js +24 -0
- package/dist/infra/queue/run-job.d.ts +11 -2
- package/dist/infra/queue/run-job.js +26 -3
- package/dist/infra/schedule/locked-tick.js +12 -4
- package/dist/infra/schedule/scheduled-runs.js +3 -1
- package/dist/infra/throttler/credential-throttler.d.ts +4 -1
- package/dist/infra/throttler/credential-throttler.js +13 -3
- package/dist/infra/throttler/named-throttlers.d.ts +20 -4
- package/dist/infra/throttler/named-throttlers.js +82 -4
- package/dist/infra/throttler/principal-throttler.guard.d.ts +10 -0
- package/dist/infra/throttler/principal-throttler.guard.js +50 -0
- package/dist/infra/throttler/redis-throttler-storage.d.ts +1 -0
- package/dist/infra/throttler/redis-throttler-storage.js +27 -5
- package/dist/infra/throttler/throttler.guard.d.ts +2 -2
- package/dist/infra/throttler/throttler.guard.js +2 -2
- package/dist/infra/throttler/throttler.module.js +3 -2
- package/dist/invalidation/audiences.d.ts +32 -0
- package/dist/invalidation/audiences.js +43 -0
- package/dist/invalidation/hints.d.ts +62 -0
- package/dist/invalidation/hints.js +73 -0
- package/dist/invalidation/invalidation-hints.d.ts +35 -0
- package/dist/invalidation/invalidation-hints.js +100 -0
- package/dist/invalidation/invalidation-hints.module.d.ts +10 -0
- package/dist/invalidation/invalidation-hints.module.js +26 -0
- package/dist/invalidation/me-stream.controller.d.ts +30 -0
- package/dist/invalidation/me-stream.controller.js +100 -0
- package/dist/invalidation/me-stream.d.ts +57 -0
- package/dist/invalidation/me-stream.js +322 -0
- package/dist/invalidation/me-stream.module.d.ts +7 -0
- package/dist/invalidation/me-stream.module.js +22 -0
- package/dist/invalidation/org-intent-bridge.d.ts +18 -0
- package/dist/invalidation/org-intent-bridge.js +46 -0
- package/dist/kernel.d.ts +10 -1
- package/dist/kernel.js +65 -2
- package/dist/kernel.module.js +41 -4
- package/dist/lifecycle/kernel-lifecycle.d.ts +51 -2
- package/dist/lifecycle/kernel-lifecycle.js +263 -56
- package/dist/lifecycle/tokens.d.ts +8 -0
- package/dist/lifecycle/tokens.js +2 -0
- package/dist/log.d.ts +6 -0
- package/dist/log.js +47 -19
- package/dist/media/image-header.d.ts +10 -0
- package/dist/media/image-header.js +87 -0
- package/dist/models/budget-admission.d.ts +31 -0
- package/dist/models/budget-admission.js +149 -0
- package/dist/models/budget-counters.d.ts +28 -0
- package/dist/models/budget-counters.js +117 -0
- package/dist/models/budget-policy.d.ts +88 -0
- package/dist/models/budget-policy.js +78 -0
- package/dist/models/cache-write-usage.d.ts +3 -0
- package/dist/models/cache-write-usage.js +26 -0
- package/dist/models/embeddings.d.ts +10 -14
- package/dist/models/embeddings.js +59 -54
- package/dist/models/enablement.d.ts +20 -7
- package/dist/models/enablement.js +62 -17
- package/dist/models/image-usable.d.ts +46 -0
- package/dist/models/image-usable.js +60 -0
- package/dist/models/images.d.ts +123 -0
- package/dist/models/images.js +448 -0
- package/dist/models/models.module.d.ts +3 -2
- package/dist/models/models.module.js +18 -4
- package/dist/models/org-models.schemas.js +1 -0
- package/dist/models/price-snapshot.d.ts +43 -0
- package/dist/models/price-snapshot.js +145 -0
- package/dist/models/prices.d.ts +8 -6
- package/dist/models/prices.js +28 -3
- package/dist/models/purposes.controller.d.ts +7 -0
- package/dist/models/purposes.controller.js +9 -0
- package/dist/models/purposes.d.ts +73 -52
- package/dist/models/purposes.js +236 -38
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +52 -8
- package/dist/net/public-address.js +97 -24
- package/dist/net/safe-fetch.d.ts +30 -7
- package/dist/net/safe-fetch.js +113 -9
- package/dist/orgs/device-network-setting.d.ts +38 -0
- package/dist/orgs/device-network-setting.js +59 -0
- package/dist/orgs/directory-sync-state.d.ts +125 -0
- package/dist/orgs/directory-sync-state.js +259 -0
- package/dist/orgs/directory-sync.controller.d.ts +16 -3
- package/dist/orgs/directory-sync.controller.js +29 -5
- package/dist/orgs/directory-sync.d.ts +36 -18
- package/dist/orgs/directory-sync.js +265 -129
- package/dist/orgs/directory-sync.schemas.d.ts +26 -0
- package/dist/orgs/directory-sync.schemas.js +50 -0
- package/dist/orgs/invitations.controller.d.ts +6 -17
- package/dist/orgs/invitations.controller.js +15 -13
- package/dist/orgs/invitations.service.d.ts +30 -6
- package/dist/orgs/invitations.service.js +84 -49
- package/dist/orgs/members.service.d.ts +78 -4
- package/dist/orgs/members.service.js +153 -25
- package/dist/orgs/network-allowances.service.d.ts +79 -0
- package/dist/orgs/network-allowances.service.js +371 -0
- package/dist/orgs/offboarding.d.ts +60 -57
- package/dist/orgs/offboarding.js +187 -178
- package/dist/orgs/org-lock.d.ts +36 -2
- package/dist/orgs/org-lock.js +67 -4
- package/dist/orgs/org-owner.d.ts +9 -0
- package/dist/orgs/org-owner.js +31 -0
- package/dist/orgs/org.guard.js +4 -0
- package/dist/orgs/orgs.controller.d.ts +46 -16
- package/dist/orgs/orgs.controller.js +75 -15
- package/dist/orgs/orgs.module.d.ts +3 -2
- package/dist/orgs/orgs.module.js +27 -5
- package/dist/orgs/orgs.schemas.d.ts +52 -0
- package/dist/orgs/orgs.schemas.js +55 -1
- package/dist/orgs/orgs.service.d.ts +47 -9
- package/dist/orgs/orgs.service.js +169 -31
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +7 -0
- package/dist/orgs/security-settings.service.d.ts +102 -0
- package/dist/orgs/security-settings.service.js +228 -0
- package/dist/orgs/settings.controller.d.ts +40 -14
- package/dist/orgs/settings.controller.js +56 -10
- package/dist/orgs/settings.service.d.ts +564 -63
- package/dist/orgs/settings.service.js +790 -88
- package/dist/overrides.d.ts +71 -5
- package/dist/overrides.js +38 -2
- package/dist/packages/npm-publish-keys.json +27 -0
- package/dist/packages/npm.d.ts +37 -10
- package/dist/packages/npm.js +67 -24
- package/dist/packages/official-publisher.d.ts +88 -0
- package/dist/packages/official-publisher.js +298 -0
- package/dist/packages/provenance.d.ts +27 -1
- package/dist/packages/provenance.js +70 -22
- package/dist/packages/sigstore-trusted-root.json +126 -0
- package/dist/packages/tgz.d.ts +0 -2
- package/dist/packages/tgz.js +0 -2
- package/dist/platform/availability.d.ts +5 -0
- package/dist/platform/availability.js +7 -3
- package/dist/platform/connector-person-fields.d.ts +67 -0
- package/dist/platform/connector-person-fields.js +129 -0
- package/dist/platform/exclusions.js +341 -195
- package/dist/platform/file-ref.d.ts +105 -0
- package/dist/platform/file-ref.js +173 -0
- package/dist/platform/method.js +1 -0
- package/dist/platform/operation.d.ts +98 -4
- package/dist/platform/operation.js +23 -7
- package/dist/platform/ops/accounts.ops.d.ts +1 -1
- package/dist/platform/ops/accounts.ops.js +68 -19
- package/dist/platform/ops/admin-items.ops.d.ts +37 -0
- package/dist/platform/ops/admin-items.ops.js +279 -0
- package/dist/platform/ops/admin.ops.d.ts +12 -10
- package/dist/platform/ops/admin.ops.js +349 -56
- package/dist/platform/ops/agent-skills.ops.d.ts +31 -3
- package/dist/platform/ops/agent-skills.ops.js +454 -12
- package/dist/platform/ops/agent-templates.ops.js +2 -2
- package/dist/platform/ops/agents.ops.d.ts +10 -3
- package/dist/platform/ops/agents.ops.js +128 -49
- package/dist/platform/ops/approvals.ops.d.ts +1 -1
- package/dist/platform/ops/approvals.ops.js +7 -2
- package/dist/platform/ops/automations.ops.d.ts +23 -0
- package/dist/platform/ops/automations.ops.js +604 -0
- package/dist/platform/ops/background.ops.js +5 -2
- package/dist/platform/ops/catalog-admin.ops.d.ts +11 -1
- package/dist/platform/ops/catalog-admin.ops.js +143 -19
- package/dist/platform/ops/channels.ops.d.ts +10 -3
- package/dist/platform/ops/channels.ops.js +246 -9
- package/dist/platform/ops/components.ops.d.ts +3 -1
- package/dist/platform/ops/components.ops.js +61 -2
- package/dist/platform/ops/connectors.ops.d.ts +22 -4
- package/dist/platform/ops/connectors.ops.js +738 -13
- package/dist/platform/ops/conversations.ops.d.ts +8 -1
- package/dist/platform/ops/conversations.ops.js +94 -18
- package/dist/platform/ops/devices.ops.d.ts +5 -1
- package/dist/platform/ops/devices.ops.js +312 -36
- package/dist/platform/ops/evals.ops.js +35 -72
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +49 -4
- package/dist/platform/ops/extensions-admin.ops.js +475 -16
- package/dist/platform/ops/extensions.ops.d.ts +25 -7
- package/dist/platform/ops/extensions.ops.js +301 -102
- package/dist/platform/ops/files.ops.d.ts +18 -0
- package/dist/platform/ops/files.ops.js +267 -0
- package/dist/platform/ops/inbox.ops.d.ts +4 -2
- package/dist/platform/ops/inbox.ops.js +144 -55
- package/dist/platform/ops/list-handoff.d.ts +10 -0
- package/dist/platform/ops/list-handoff.js +11 -0
- package/dist/platform/ops/marketplaces.ops.js +29 -5
- package/dist/platform/ops/models.ops.js +13 -3
- package/dist/platform/ops/org-plugins.ops.d.ts +13 -5
- package/dist/platform/ops/org-plugins.ops.js +170 -74
- package/dist/platform/ops/org-settings.ops.d.ts +5 -1
- package/dist/platform/ops/org-settings.ops.js +128 -19
- package/dist/platform/ops/orgs.ops.d.ts +48 -3
- package/dist/platform/ops/orgs.ops.js +512 -29
- package/dist/platform/ops/outbox.ops.d.ts +21 -0
- package/dist/platform/ops/outbox.ops.js +126 -0
- package/dist/platform/ops/person-inputs.d.ts +61 -0
- package/dist/platform/ops/person-inputs.js +121 -0
- package/dist/platform/ops/platform-icons.ops.d.ts +14 -0
- package/dist/platform/ops/platform-icons.ops.js +117 -0
- package/dist/platform/ops/platform.ops.d.ts +15 -2
- package/dist/platform/ops/platform.ops.js +111 -21
- package/dist/platform/ops/plugins.ops.d.ts +5 -1
- package/dist/platform/ops/plugins.ops.js +27 -48
- package/dist/platform/ops/requests.ops.js +68 -4
- package/dist/platform/ops/retention.d.ts +16 -0
- package/dist/platform/ops/retention.js +21 -0
- package/dist/platform/ops/setup.ops.js +1 -1
- package/dist/platform/ops/shares.ops.d.ts +16 -0
- package/dist/platform/ops/shares.ops.js +107 -0
- package/dist/platform/ops/skills.ops.d.ts +7 -1
- package/dist/platform/ops/skills.ops.js +111 -48
- package/dist/platform/ops/summary.d.ts +5 -0
- package/dist/platform/ops/summary.js +10 -0
- package/dist/platform/ops/themes.ops.js +1 -1
- package/dist/platform/ops/unavailable.js +2 -2
- package/dist/platform/parity.d.ts +13 -6
- package/dist/platform/parity.js +139 -51
- package/dist/platform/person-fields.d.ts +120 -0
- package/dist/platform/person-fields.js +404 -0
- package/dist/platform/platform-ops.module.d.ts +8 -1
- package/dist/platform/platform-ops.module.js +30 -0
- package/dist/platform/platform.module.d.ts +4 -3
- package/dist/platform/platform.module.js +8 -5
- package/dist/platform/route-schemas.js +38 -0
- package/dist/platform/sealed-inputs.d.ts +44 -0
- package/dist/platform/sealed-inputs.js +116 -0
- package/dist/platform/sealed-reveals.controller.d.ts +17 -0
- package/dist/platform/sealed-reveals.controller.js +48 -0
- package/dist/platform/sealed-reveals.d.ts +54 -0
- package/dist/platform/sealed-reveals.js +155 -0
- package/dist/plugin-reads/plugin-reads.service.d.ts +29 -0
- package/dist/plugin-reads/plugin-reads.service.js +214 -0
- package/dist/plugin-reads/token.d.ts +5 -0
- package/dist/plugin-reads/token.js +5 -0
- package/dist/push/delivery.d.ts +90 -0
- package/dist/push/delivery.js +273 -0
- package/dist/push/fanout.d.ts +30 -0
- package/dist/push/fanout.js +102 -0
- package/dist/push/jobs.d.ts +48 -0
- package/dist/push/jobs.js +21 -0
- package/dist/push/preferences.service.d.ts +18 -0
- package/dist/push/preferences.service.js +88 -0
- package/dist/push/provider-host.d.ts +34 -0
- package/dist/push/provider-host.js +94 -0
- package/dist/push/push-owed.d.ts +35 -0
- package/dist/push/push-owed.js +102 -0
- package/dist/push/push-processor.d.ts +40 -0
- package/dist/push/push-processor.js +121 -0
- package/dist/push/push.controller.d.ts +28 -0
- package/dist/push/push.controller.js +92 -0
- package/dist/push/push.module.d.ts +6 -0
- package/dist/push/push.module.js +29 -0
- package/dist/push/push.schemas.d.ts +91 -0
- package/dist/push/push.schemas.js +54 -0
- package/dist/push/recipients.d.ts +33 -0
- package/dist/push/recipients.js +324 -0
- package/dist/push/registration-cleanup.d.ts +9 -0
- package/dist/push/registration-cleanup.js +16 -0
- package/dist/push/registrations.service.d.ts +55 -0
- package/dist/push/registrations.service.js +254 -0
- package/dist/push/stale.job.d.ts +25 -0
- package/dist/push/stale.job.js +76 -0
- package/dist/push/texts.d.ts +46 -0
- package/dist/push/texts.js +50 -0
- package/dist/push/token-store.d.ts +31 -0
- package/dist/push/token-store.js +52 -0
- package/dist/push/triggers.d.ts +19 -0
- package/dist/push/triggers.js +30 -0
- package/dist/retention/jobs.d.ts +21 -0
- package/dist/retention/jobs.js +48 -0
- package/dist/retention/policy.d.ts +70 -0
- package/dist/retention/policy.js +103 -0
- package/dist/retention/purge-batch.d.ts +17 -0
- package/dist/retention/purge-batch.js +351 -0
- package/dist/retention/report-obligations.d.ts +12 -0
- package/dist/retention/report-obligations.js +71 -0
- package/dist/retention/sweep.job.d.ts +17 -0
- package/dist/retention/sweep.job.js +95 -0
- package/dist/retention/worker.d.ts +29 -0
- package/dist/retention/worker.js +307 -0
- package/dist/roles/gateway-role.d.ts +18 -7
- package/dist/roles/gateway-role.js +37 -11
- package/dist/roles/gateway.module.d.ts +3 -2
- package/dist/roles/gateway.module.js +16 -6
- package/dist/roles/worker-role.d.ts +31 -9
- package/dist/roles/worker-role.js +80 -31
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +90 -11
- package/dist/runtime/abort.d.ts +22 -3
- package/dist/runtime/abort.js +37 -17
- package/dist/runtime/checkpointer.d.ts +3 -0
- package/dist/runtime/checkpointer.js +9 -3
- package/dist/runtime/compaction-model.d.ts +57 -0
- package/dist/runtime/compaction-model.js +87 -0
- package/dist/runtime/compaction-progress.d.ts +62 -0
- package/dist/runtime/compaction-progress.js +82 -0
- package/dist/runtime/compaction-settings.service.d.ts +36 -0
- package/dist/runtime/compaction-settings.service.js +63 -0
- package/dist/runtime/compaction.service.d.ts +101 -0
- package/dist/runtime/compaction.service.js +127 -0
- package/dist/runtime/context/build.d.ts +210 -45
- package/dist/runtime/context/build.js +561 -107
- package/dist/runtime/context/cache-expiry.d.ts +31 -0
- package/dist/runtime/context/cache-expiry.js +60 -0
- package/dist/runtime/context/cache-ttl.d.ts +18 -0
- package/dist/runtime/context/cache-ttl.js +30 -0
- package/dist/runtime/context/compaction.d.ts +175 -16
- package/dist/runtime/context/compaction.js +639 -70
- package/dist/runtime/context/device-paths.d.ts +7 -32
- package/dist/runtime/context/device-paths.js +6 -40
- package/dist/runtime/context/fit.d.ts +111 -0
- package/dist/runtime/context/fit.js +278 -0
- package/dist/runtime/context/idle-compaction-rules.d.ts +109 -0
- package/dist/runtime/context/idle-compaction-rules.js +99 -0
- package/dist/runtime/context/in-context-compaction.d.ts +156 -0
- package/dist/runtime/context/in-context-compaction.js +310 -0
- package/dist/runtime/context/output-truncated.d.ts +16 -0
- package/dist/runtime/context/output-truncated.js +19 -0
- package/dist/runtime/context/permission-profile.d.ts +45 -0
- package/dist/runtime/context/permission-profile.js +264 -0
- package/dist/runtime/context/plugin-context.d.ts +20 -0
- package/dist/runtime/context/plugin-context.js +30 -0
- package/dist/runtime/context/project-root.d.ts +43 -0
- package/dist/runtime/context/project-root.js +85 -0
- package/dist/runtime/context/run-context.d.ts +61 -0
- package/dist/runtime/context/run-context.js +134 -0
- package/dist/runtime/context/run-outcome.d.ts +10 -0
- package/dist/runtime/context/run-outcome.js +92 -0
- package/dist/runtime/context/skills.d.ts +38 -54
- package/dist/runtime/context/skills.js +76 -117
- package/dist/runtime/context/tool-changes.d.ts +3 -3
- package/dist/runtime/context/tool-changes.js +6 -16
- package/dist/runtime/conversation-lock.d.ts +4 -11
- package/dist/runtime/conversation-lock.js +14 -18
- package/dist/runtime/hook-calls.d.ts +31 -13
- package/dist/runtime/hook-calls.js +61 -13
- package/dist/runtime/idle-arm.d.ts +48 -0
- package/dist/runtime/idle-arm.js +322 -0
- package/dist/runtime/idle-compaction-jobs.d.ts +46 -0
- package/dist/runtime/idle-compaction-jobs.js +21 -0
- package/dist/runtime/idle-compaction.d.ts +51 -0
- package/dist/runtime/idle-compaction.js +352 -0
- package/dist/runtime/idle-return.d.ts +62 -0
- package/dist/runtime/idle-return.js +173 -0
- package/dist/runtime/langgraph-loop.js +48 -9
- package/dist/runtime/limits.d.ts +15 -0
- package/dist/runtime/limits.js +25 -0
- package/dist/runtime/loop.d.ts +21 -5
- package/dist/runtime/loop.js +2 -1
- package/dist/runtime/maintenance.d.ts +50 -16
- package/dist/runtime/maintenance.js +300 -42
- package/dist/runtime/model-call.d.ts +403 -27
- package/dist/runtime/model-call.js +1472 -393
- 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 +289 -0
- package/dist/runtime/plugin-context.service.d.ts +75 -0
- package/dist/runtime/plugin-context.service.js +211 -0
- package/dist/runtime/project/knowledge.d.ts +135 -0
- package/dist/runtime/project/knowledge.js +256 -0
- package/dist/runtime/project/knowledge.service.d.ts +103 -0
- package/dist/runtime/project/knowledge.service.js +367 -0
- package/dist/runtime/providers.d.ts +116 -47
- package/dist/runtime/providers.js +266 -131
- package/dist/runtime/queue-lost-jobs.d.ts +24 -0
- package/dist/runtime/queue-lost-jobs.js +51 -0
- package/dist/runtime/quota.d.ts +12 -12
- package/dist/runtime/quota.js +42 -37
- package/dist/runtime/run-context.service.d.ts +21 -4
- package/dist/runtime/run-context.service.js +55 -31
- package/dist/runtime/run-control.d.ts +52 -5
- package/dist/runtime/run-control.js +86 -12
- package/dist/runtime/run-deletion.d.ts +30 -0
- package/dist/runtime/run-deletion.js +161 -0
- package/dist/runtime/run-drafts.d.ts +68 -4
- package/dist/runtime/run-drafts.js +174 -9
- package/dist/runtime/run-execution.d.ts +80 -0
- package/dist/runtime/run-execution.js +191 -0
- package/dist/runtime/run-finish.d.ts +71 -10
- package/dist/runtime/run-finish.js +201 -18
- package/dist/runtime/run-jobs.d.ts +123 -14
- package/dist/runtime/run-jobs.js +277 -29
- package/dist/runtime/run-liveness.d.ts +11 -0
- package/dist/runtime/run-liveness.js +19 -0
- package/dist/runtime/run-orphan-check.job.d.ts +146 -0
- package/dist/runtime/run-orphan-check.job.js +427 -0
- package/dist/runtime/run-principal.d.ts +9 -0
- package/dist/runtime/run-principal.js +18 -0
- package/dist/runtime/run-processors.d.ts +33 -24
- package/dist/runtime/run-processors.js +44 -9
- package/dist/runtime/run-queue.d.ts +155 -70
- package/dist/runtime/run-queue.js +615 -300
- package/dist/runtime/run-status.d.ts +12 -0
- package/dist/runtime/run-status.js +21 -0
- package/dist/runtime/run-steps.d.ts +18 -5
- package/dist/runtime/run-steps.js +51 -16
- package/dist/runtime/run-worker.d.ts +85 -25
- package/dist/runtime/run-worker.js +577 -154
- package/dist/runtime/runtime.module.d.ts +3 -4
- package/dist/runtime/runtime.module.js +74 -7
- package/dist/runtime/step-log.d.ts +24 -6
- package/dist/runtime/step-log.js +42 -14
- package/dist/runtime/stream-limit.d.ts +13 -0
- package/dist/runtime/stream-limit.js +40 -0
- package/dist/runtime/stream.controller.d.ts +11 -9
- package/dist/runtime/stream.controller.js +17 -17
- package/dist/runtime/stream.d.ts +8 -1
- package/dist/runtime/stream.js +115 -15
- package/dist/runtime/subagents/child.js +3 -1
- package/dist/runtime/subagents/definition.d.ts +38 -23
- package/dist/runtime/subagents/definition.js +118 -114
- package/dist/runtime/subagents/deliveries.d.ts +6 -3
- package/dist/runtime/subagents/deliveries.js +26 -8
- package/dist/runtime/subagents/dispatch.d.ts +23 -16
- package/dist/runtime/subagents/dispatch.js +48 -43
- package/dist/runtime/subagents/messages.d.ts +8 -2
- package/dist/runtime/subagents/messages.js +22 -9
- package/dist/runtime/subagents/org-agents.d.ts +1 -1
- package/dist/runtime/subagents/org-agents.js +3 -3
- package/dist/runtime/subagents/preamble.d.ts +3 -1
- package/dist/runtime/subagents/preamble.js +3 -1
- package/dist/runtime/subagents/progress.js +1 -0
- package/dist/runtime/subagents/render.d.ts +1 -2
- package/dist/runtime/subagents/render.js +1 -2
- package/dist/runtime/subagents/skill-fork.d.ts +5 -7
- package/dist/runtime/subagents/skill-fork.js +11 -5
- package/dist/runtime/subagents/status.js +2 -0
- package/dist/runtime/subagents/subagents.service.js +1 -1
- package/dist/runtime/subagents/template-skills.d.ts +47 -0
- package/dist/runtime/subagents/template-skills.js +77 -0
- package/dist/runtime/subagents/tree-jobs.d.ts +62 -0
- package/dist/runtime/subagents/tree-jobs.js +86 -0
- package/dist/runtime/usage-report-jobs.d.ts +24 -46
- package/dist/runtime/usage-report-jobs.js +86 -114
- package/dist/runtime/usage-report.d.ts +47 -84
- package/dist/runtime/usage-report.js +137 -242
- package/dist/runtime/waits.d.ts +65 -205
- package/dist/runtime/waits.js +210 -830
- package/dist/runtime/write-base.d.ts +178 -0
- package/dist/runtime/write-base.js +540 -0
- package/dist/runtime/write-base.service.d.ts +75 -0
- package/dist/runtime/write-base.service.js +216 -0
- package/dist/sandbox/attachments-path.d.ts +15 -0
- package/dist/sandbox/attachments-path.js +15 -0
- package/dist/sandbox/browse-roots.d.ts +8 -0
- package/dist/sandbox/browse-roots.js +22 -0
- package/dist/sandbox/device-reports.d.ts +110 -0
- package/dist/sandbox/device-reports.js +327 -0
- package/dist/sandbox/device-reports.module.d.ts +7 -0
- package/dist/sandbox/device-reports.module.js +25 -0
- package/dist/sandbox/device-sandbox-settings.d.ts +230 -0
- package/dist/sandbox/device-sandbox-settings.js +227 -0
- package/dist/sandbox/device-sandbox.d.ts +230 -0
- package/dist/sandbox/device-sandbox.js +251 -0
- package/dist/sandbox/device-services.d.ts +147 -0
- package/dist/sandbox/device-services.js +377 -0
- package/dist/sandbox/held-operations.d.ts +43 -0
- package/dist/sandbox/held-operations.js +137 -0
- package/dist/sandbox/jobs.d.ts +21 -11
- package/dist/sandbox/jobs.js +24 -18
- package/dist/sandbox/kernel-read.d.ts +85 -0
- package/dist/sandbox/kernel-read.js +87 -0
- package/dist/sandbox/leases.d.ts +25 -5
- package/dist/sandbox/leases.js +92 -12
- package/dist/sandbox/loopback-expiry.job.d.ts +23 -0
- package/dist/sandbox/loopback-expiry.job.js +56 -0
- package/dist/sandbox/loopback-grant-records.d.ts +144 -0
- package/dist/sandbox/loopback-grant-records.js +266 -0
- package/dist/sandbox/loopback-grants.d.ts +119 -0
- package/dist/sandbox/loopback-grants.js +454 -0
- package/dist/sandbox/loopback-live-ports.d.ts +12 -0
- package/dist/sandbox/loopback-live-ports.js +43 -0
- package/dist/sandbox/managed-device-context.d.ts +118 -0
- package/dist/sandbox/managed-device-context.js +375 -0
- package/dist/sandbox/managed-device-context.module.d.ts +6 -0
- package/dist/sandbox/managed-device-context.module.js +37 -0
- package/dist/sandbox/modes.d.ts +170 -0
- package/dist/sandbox/modes.js +196 -0
- package/dist/sandbox/network-grants.d.ts +69 -0
- package/dist/sandbox/network-grants.js +227 -0
- package/dist/sandbox/network-grants.module.d.ts +2 -0
- package/dist/sandbox/network-grants.module.js +14 -0
- package/dist/sandbox/operation-authority-types.d.ts +27 -0
- package/dist/sandbox/operation-authority-types.js +50 -0
- package/dist/sandbox/operation-authority.d.ts +174 -0
- package/dist/sandbox/operation-authority.js +952 -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 +288 -0
- package/dist/sandbox/operation-intents.js +1685 -0
- package/dist/sandbox/operation-intents.module.d.ts +2 -0
- package/dist/sandbox/operation-intents.module.js +22 -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 +71 -0
- package/dist/sandbox/operation-reconcile.job.js +418 -0
- package/dist/sandbox/operation-revoke.d.ts +20 -0
- package/dist/sandbox/operation-revoke.js +3 -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 +44 -0
- package/dist/sandbox/permission-authority-lock.js +167 -0
- package/dist/sandbox/permission-authority.module.d.ts +9 -0
- package/dist/sandbox/permission-authority.module.js +60 -0
- package/dist/sandbox/permission-auto-grants.d.ts +42 -0
- package/dist/sandbox/permission-auto-grants.js +145 -0
- package/dist/sandbox/permission-availability.d.ts +78 -0
- package/dist/sandbox/permission-availability.js +92 -0
- package/dist/sandbox/permission-call-grants.d.ts +47 -0
- package/dist/sandbox/permission-call-grants.js +429 -0
- package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
- package/dist/sandbox/permission-call-grants.module.js +28 -0
- package/dist/sandbox/permission-call-types.d.ts +151 -0
- package/dist/sandbox/permission-call-types.js +1 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +73 -0
- package/dist/sandbox/permission-ceiling-writes.js +375 -0
- package/dist/sandbox/permission-config-publication.d.ts +109 -0
- package/dist/sandbox/permission-config-publication.js +358 -0
- package/dist/sandbox/permission-context-types.d.ts +60 -0
- package/dist/sandbox/permission-context-types.js +11 -0
- package/dist/sandbox/permission-facts.d.ts +396 -0
- package/dist/sandbox/permission-facts.js +796 -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 +76 -0
- package/dist/sandbox/permission-instance-writes.js +232 -0
- package/dist/sandbox/permission-runtime-reports.d.ts +92 -0
- package/dist/sandbox/permission-runtime-reports.js +337 -0
- package/dist/sandbox/permission-transitions.d.ts +33 -0
- package/dist/sandbox/permission-transitions.js +173 -0
- package/dist/sandbox/providers.d.ts +48 -32
- package/dist/sandbox/providers.js +68 -48
- 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 +15 -0
- package/dist/sandbox/request-not-sent.js +20 -0
- package/dist/sandbox/review/classifier.d.ts +252 -0
- package/dist/sandbox/review/classifier.js +635 -0
- package/dist/sandbox/review/index.d.ts +13 -0
- package/dist/sandbox/review/index.js +10 -0
- package/dist/sandbox/review/permission-candidate.d.ts +143 -0
- package/dist/sandbox/review/permission-candidate.js +449 -0
- package/dist/sandbox/review/review.service.d.ts +260 -0
- package/dist/sandbox/review/review.service.js +761 -0
- package/dist/sandbox/review/rules.d.ts +96 -0
- package/dist/sandbox/review/rules.js +5427 -0
- package/dist/sandbox/review/types.d.ts +122 -0
- package/dist/sandbox/review/types.js +48 -0
- package/dist/sandbox/sandbox-file-reader.d.ts +47 -0
- package/dist/sandbox/sandbox-file-reader.js +125 -0
- package/dist/sandbox/sandbox.module.d.ts +3 -2
- package/dist/sandbox/sandbox.module.js +57 -7
- package/dist/sandbox/sandbox.service.d.ts +647 -160
- package/dist/sandbox/sandbox.service.js +2197 -470
- package/dist/sandbox/unreachable.js +20 -3
- package/dist/sandbox/use-context.d.ts +20 -0
- package/dist/sandbox/use-context.js +1 -0
- package/dist/setup/kernel-checks.d.ts +3 -3
- package/dist/setup/kernel-checks.js +7 -6
- package/dist/setup/oauth-token-probe.d.ts +1 -8
- package/dist/setup/oauth-token-probe.js +8 -20
- package/dist/setup/setup-check-registry.d.ts +16 -5
- package/dist/setup/setup-check-registry.js +11 -3
- package/dist/setup/setup-checks.schemas.d.ts +29 -0
- package/dist/setup/setup-checks.schemas.js +32 -0
- package/dist/setup/setup-checks.service.d.ts +35 -12
- package/dist/setup/setup-checks.service.js +159 -59
- package/dist/setup/setup-guides.service.d.ts +19 -4
- package/dist/setup/setup-guides.service.js +44 -11
- package/dist/shares/liveness.d.ts +73 -0
- package/dist/shares/liveness.js +236 -0
- package/dist/shares/revoke.d.ts +31 -0
- package/dist/shares/revoke.js +47 -0
- package/dist/shares/settings.d.ts +76 -0
- package/dist/shares/settings.js +117 -0
- package/dist/shares/share-code.d.ts +4 -0
- package/dist/shares/share-code.js +28 -0
- package/dist/shares/share-open.controller.d.ts +35 -0
- package/dist/shares/share-open.controller.js +107 -0
- package/dist/shares/share-open.service.d.ts +111 -0
- package/dist/shares/share-open.service.js +293 -0
- package/dist/shares/share-previews.controller.d.ts +50 -0
- package/dist/shares/share-previews.controller.js +115 -0
- package/dist/shares/shares.controller.d.ts +45 -0
- package/dist/shares/shares.controller.js +148 -0
- package/dist/shares/shares.module.d.ts +7 -0
- package/dist/shares/shares.module.js +39 -0
- package/dist/shares/shares.schemas.d.ts +35 -0
- package/dist/shares/shares.schemas.js +27 -0
- package/dist/shares/shares.service.d.ts +222 -0
- package/dist/shares/shares.service.js +721 -0
- package/dist/shares/sweep.job.d.ts +53 -0
- package/dist/shares/sweep.job.js +173 -0
- package/dist/skills/agent-skills.controller.d.ts +48 -0
- package/dist/skills/agent-skills.controller.js +131 -0
- package/dist/skills/agent-skills.service.d.ts +263 -0
- package/dist/skills/agent-skills.service.js +980 -0
- package/dist/skills/catalog.d.ts +83 -71
- package/dist/skills/catalog.js +148 -215
- package/dist/skills/changes.controller.d.ts +6 -23
- package/dist/skills/changes.controller.js +8 -56
- package/dist/skills/changes.service.d.ts +75 -115
- package/dist/skills/changes.service.js +269 -606
- package/dist/skills/conversation-catalog.d.ts +55 -0
- package/dist/skills/conversation-catalog.js +144 -0
- package/dist/skills/invocable.controller.d.ts +4 -0
- package/dist/skills/invocable.controller.js +5 -1
- package/dist/skills/invocation-keys.d.ts +1 -1
- package/dist/skills/invocation-keys.js +1 -1
- package/dist/skills/invoke.d.ts +153 -5
- package/dist/skills/invoke.js +288 -6
- package/dist/skills/package.d.ts +0 -5
- package/dist/skills/package.js +0 -14
- package/dist/skills/skill-files.d.ts +91 -0
- package/dist/skills/skill-files.js +144 -0
- package/dist/skills/skills.controller.d.ts +28 -10
- package/dist/skills/skills.controller.js +77 -31
- package/dist/skills/skills.module.js +26 -2
- package/dist/skills/skills.schemas.d.ts +69 -15
- package/dist/skills/skills.schemas.js +117 -18
- package/dist/skills/skills.service.d.ts +108 -71
- package/dist/skills/skills.service.js +335 -205
- package/dist/skills/usable.d.ts +59 -7
- package/dist/skills/usable.js +252 -43
- package/dist/storage/purge.d.ts +1 -1
- package/dist/storage/purge.js +7 -3
- package/dist/storage/storage.service.d.ts +19 -1
- package/dist/storage/storage.service.js +87 -5
- package/dist/themes/avatar-preset-key.d.ts +6 -0
- package/dist/themes/avatar-preset-key.js +9 -0
- package/dist/themes/platform-icon-objects.d.ts +51 -0
- package/dist/themes/platform-icon-objects.js +113 -0
- package/dist/themes/platform-icon-public.controller.d.ts +17 -0
- package/dist/themes/platform-icon-public.controller.js +58 -0
- package/dist/themes/platform-icon.controller.d.ts +22 -0
- package/dist/themes/platform-icon.controller.js +65 -0
- package/dist/themes/platform-icon.schemas.d.ts +48 -0
- package/dist/themes/platform-icon.schemas.js +53 -0
- package/dist/themes/platform-icon.service.d.ts +83 -0
- package/dist/themes/platform-icon.service.js +301 -0
- package/dist/themes/render-css.js +9 -2
- package/dist/themes/theme-delivery.service.d.ts +10 -2
- package/dist/themes/theme-delivery.service.js +26 -11
- package/dist/themes/theme-state.d.ts +43 -2
- package/dist/themes/theme-state.js +88 -20
- package/dist/themes/themes-public.controller.d.ts +3 -3
- package/dist/themes/themes-public.controller.js +3 -3
- package/dist/themes/themes.module.d.ts +4 -1
- package/dist/themes/themes.module.js +9 -4
- package/dist/themes/themes.service.d.ts +28 -1
- package/dist/themes/themes.service.js +36 -2
- package/dist/tools/admin-connectors.d.ts +73 -0
- package/dist/tools/admin-connectors.js +141 -0
- package/dist/tools/approvals.controller.d.ts +6 -2
- package/dist/tools/approvals.controller.js +36 -2
- package/dist/tools/approvals.schemas.d.ts +2 -0
- package/dist/tools/approvals.schemas.js +5 -1
- package/dist/tools/approvals.service.d.ts +680 -18
- package/dist/tools/approvals.service.js +2004 -56
- package/dist/tools/builtin-names.d.ts +29 -20
- package/dist/tools/builtin-names.js +60 -31
- package/dist/tools/builtins/agent.js +13 -5
- package/dist/tools/builtins/artifacts.d.ts +77 -0
- package/dist/tools/builtins/artifacts.js +173 -0
- package/dist/tools/builtins/ask-user.js +3 -2
- package/dist/tools/builtins/automations.d.ts +111 -0
- package/dist/tools/builtins/automations.js +1083 -0
- package/dist/tools/builtins/builtin-tools.d.ts +38 -7
- package/dist/tools/builtins/builtin-tools.js +191 -32
- package/dist/tools/builtins/conversation-files.d.ts +58 -0
- package/dist/tools/builtins/conversation-files.js +141 -0
- package/dist/tools/builtins/image/generate.d.ts +71 -0
- package/dist/tools/builtins/image/generate.js +586 -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/image/size.d.ts +12 -0
- package/dist/tools/builtins/image/size.js +36 -0
- package/dist/tools/builtins/platform.d.ts +47 -2
- package/dist/tools/builtins/platform.js +355 -39
- package/dist/tools/builtins/sandbox/bash.d.ts +53 -1
- package/dist/tools/builtins/sandbox/bash.js +372 -206
- package/dist/tools/builtins/sandbox/common.d.ts +218 -61
- package/dist/tools/builtins/sandbox/common.js +390 -187
- package/dist/tools/builtins/sandbox/deliver.d.ts +3 -0
- package/dist/tools/builtins/sandbox/deliver.js +112 -71
- package/dist/tools/builtins/sandbox/device-code.d.ts +40 -0
- package/dist/tools/builtins/sandbox/device-code.js +57 -0
- package/dist/tools/builtins/sandbox/device-owner.d.ts +12 -0
- package/dist/tools/builtins/sandbox/device-owner.js +13 -0
- package/dist/tools/builtins/sandbox/edit.js +14 -7
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +11 -0
- package/dist/tools/builtins/sandbox/fetch-attachment.js +133 -0
- package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
- package/dist/tools/builtins/sandbox/file-state.js +33 -3
- package/dist/tools/builtins/sandbox/glob.js +15 -10
- package/dist/tools/builtins/sandbox/grep.d.ts +8 -1
- package/dist/tools/builtins/sandbox/grep.js +35 -40
- package/dist/tools/builtins/sandbox/index.d.ts +9 -7
- package/dist/tools/builtins/sandbox/index.js +13 -7
- package/dist/tools/builtins/sandbox/read.d.ts +56 -2
- package/dist/tools/builtins/sandbox/read.js +272 -50
- package/dist/tools/builtins/sandbox/search-command.d.ts +44 -0
- package/dist/tools/builtins/sandbox/search-command.js +94 -0
- package/dist/tools/builtins/sandbox/task-list.d.ts +12 -0
- package/dist/tools/builtins/sandbox/task-list.js +136 -0
- package/dist/tools/builtins/sandbox/task-output.d.ts +22 -41
- package/dist/tools/builtins/sandbox/task-output.js +255 -201
- package/dist/tools/builtins/sandbox/task-stop.d.ts +4 -3
- package/dist/tools/builtins/sandbox/task-stop.js +51 -26
- package/dist/tools/builtins/sandbox/write.js +17 -9
- package/dist/tools/builtins/send-message.d.ts +1 -1
- package/dist/tools/builtins/send-message.js +4 -3
- package/dist/tools/builtins/size-text.d.ts +2 -0
- package/dist/tools/builtins/size-text.js +8 -0
- package/dist/tools/builtins/skill-load.d.ts +57 -5
- package/dist/tools/builtins/skill-load.js +249 -15
- package/dist/tools/builtins/tool-search.d.ts +4 -7
- package/dist/tools/builtins/tool-search.js +10 -13
- package/dist/tools/builtins/vision/read-image.d.ts +59 -0
- package/dist/tools/builtins/vision/read-image.js +222 -0
- package/dist/tools/builtins/web/extract.d.ts +2 -4
- package/dist/tools/builtins/web/extract.js +15 -16
- package/dist/tools/builtins/web/fetch.js +1 -1
- package/dist/tools/builtins/web/search.js +3 -5
- package/dist/tools/call-scope.d.ts +122 -0
- package/dist/tools/call-scope.js +104 -0
- package/dist/tools/connector-account-policies.d.ts +36 -1
- package/dist/tools/connector-account-policies.js +67 -6
- package/dist/tools/connector-content.controller.d.ts +6 -2
- package/dist/tools/connector-content.controller.js +13 -3
- package/dist/tools/connector-content.d.ts +55 -15
- package/dist/tools/connector-content.js +113 -54
- package/dist/tools/connector-setup.d.ts +32 -0
- package/dist/tools/connector-setup.js +47 -0
- package/dist/tools/connector-tools-jobs.d.ts +36 -0
- package/dist/tools/connector-tools-jobs.js +40 -0
- package/dist/tools/connector-tools.processor.d.ts +32 -0
- package/dist/tools/connector-tools.processor.js +97 -0
- package/dist/tools/connectors.controller.d.ts +85 -35
- package/dist/tools/connectors.controller.js +116 -61
- package/dist/tools/connectors.schemas.d.ts +184 -2
- package/dist/tools/connectors.schemas.js +110 -5
- package/dist/tools/connectors.service.d.ts +271 -35
- package/dist/tools/connectors.service.js +827 -142
- package/dist/tools/credentials.d.ts +60 -0
- package/dist/tools/credentials.js +159 -1
- package/dist/tools/credentials.module.d.ts +7 -0
- package/dist/tools/credentials.module.js +22 -0
- package/dist/tools/drift.d.ts +12 -3
- package/dist/tools/drift.js +85 -47
- package/dist/tools/editable-endpoint.d.ts +23 -0
- package/dist/tools/editable-endpoint.js +92 -0
- package/dist/tools/elicitation.d.ts +2 -0
- package/dist/tools/elicitation.js +1 -1
- package/dist/tools/fixed-ask.d.ts +7 -0
- package/dist/tools/fixed-ask.js +9 -0
- package/dist/tools/git-asks.d.ts +113 -0
- package/dist/tools/git-asks.js +174 -0
- package/dist/tools/git-push-policy.d.ts +89 -0
- package/dist/tools/git-push-policy.js +179 -0
- package/dist/tools/info.d.ts +28 -13
- package/dist/tools/info.js +60 -30
- package/dist/tools/job-ids.d.ts +0 -4
- package/dist/tools/job-ids.js +1 -6
- package/dist/tools/loopback-asks.d.ts +52 -0
- package/dist/tools/loopback-asks.js +70 -0
- package/dist/tools/mentionable-connectors.d.ts +88 -0
- package/dist/tools/mentionable-connectors.js +218 -0
- package/dist/tools/network-asks.d.ts +276 -0
- package/dist/tools/network-asks.js +427 -0
- package/dist/tools/oauth/authorization-params.d.ts +7 -0
- package/dist/tools/oauth/authorization-params.js +19 -0
- package/dist/tools/oauth/discovery.d.ts +40 -16
- package/dist/tools/oauth/discovery.js +62 -34
- package/dist/tools/oauth/flow.d.ts +18 -3
- package/dist/tools/oauth/flow.js +42 -9
- package/dist/tools/oauth/oauth.controller.d.ts +20 -11
- package/dist/tools/oauth/oauth.controller.js +44 -23
- package/dist/tools/oauth/oauth.schemas.d.ts +27 -0
- package/dist/tools/oauth/oauth.schemas.js +30 -0
- package/dist/tools/oauth/tokens.js +2 -1
- package/dist/tools/org-tool-policies.d.ts +24 -0
- package/dist/tools/org-tool-policies.js +113 -0
- package/dist/tools/org-tool-switches.d.ts +5 -69
- package/dist/tools/org-tool-switches.js +13 -141
- package/dist/tools/outputs.d.ts +6 -4
- package/dist/tools/outputs.js +33 -29
- package/dist/tools/permission-approval-jobs.d.ts +18 -0
- package/dist/tools/permission-approval-jobs.js +95 -0
- package/dist/tools/pipeline.d.ts +575 -28
- package/dist/tools/pipeline.js +3177 -171
- package/dist/tools/policy.d.ts +31 -15
- package/dist/tools/policy.js +91 -54
- package/dist/tools/questions.controller.js +2 -2
- package/dist/tools/questions.service.d.ts +128 -12
- package/dist/tools/questions.service.js +284 -18
- package/dist/tools/registry.d.ts +180 -21
- package/dist/tools/registry.js +153 -40
- package/dist/tools/result-images.d.ts +91 -0
- package/dist/tools/result-images.js +195 -0
- package/dist/tools/specs.d.ts +13 -4
- package/dist/tools/specs.js +22 -8
- package/dist/tools/tool-review.d.ts +113 -0
- package/dist/tools/tool-review.js +303 -0
- package/dist/tools/tool-watch-queue.d.ts +45 -0
- package/dist/tools/tool-watch-queue.js +28 -0
- package/dist/tools/tool-watch-queue.module.d.ts +7 -0
- package/dist/tools/tool-watch-queue.module.js +24 -0
- package/dist/tools/tool-watch.processor.d.ts +35 -0
- package/dist/tools/tool-watch.processor.js +114 -0
- package/dist/tools/tool-watch.service.d.ts +46 -0
- package/dist/tools/tool-watch.service.js +216 -0
- package/dist/tools/tools.module.js +79 -6
- package/dist/tools/watched-waits-lock.d.ts +15 -0
- package/dist/tools/watched-waits-lock.js +40 -0
- package/dist/ui/admin-ui.controller.d.ts +8 -3
- package/dist/ui/admin-ui.controller.js +17 -2
- package/dist/ui/call-extension.d.ts +6 -4
- package/dist/ui/call-extension.js +5 -4
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +83 -6
- package/dist/ui/registry.d.ts +21 -5
- package/dist/ui/registry.js +24 -6
- package/dist/ui/ui-stream.d.ts +2 -0
- package/dist/ui/ui-stream.js +20 -6
- package/dist/ui/ui.schemas.d.ts +34 -0
- package/dist/ui/ui.schemas.js +32 -4
- package/dist/ui/views.controller.d.ts +22 -8
- package/dist/ui/views.controller.js +58 -7
- package/dist/ui/views.d.ts +64 -7
- package/dist/ui/views.js +238 -31
- package/dist/until-aborted.d.ts +5 -0
- package/dist/until-aborted.js +16 -0
- package/package.json +13 -4
- package/src/migrations/0108_question_skipped.sql +6 -0
- package/src/migrations/0109_audit_platform_idx.sql +5 -0
- package/src/migrations/0110_usage_time_idx.sql +8 -0
- package/src/migrations/0111_agent_skill_sharing.sql +22 -0
- package/src/migrations/0112_skill_share_requests.sql +4 -0
- package/src/migrations/0113_scheduled_tasks.sql +108 -0
- package/src/migrations/0114_network_asks.sql +23 -0
- package/src/migrations/0115_network_requests.sql +28 -0
- package/src/migrations/0116_skills_default_on.sql +37 -0
- package/src/migrations/0117_sandbox_tiers.sql +11 -0
- package/src/migrations/0118_device_policy_ops.sql +6 -0
- package/src/migrations/0119_outbox.sql +22 -0
- package/src/migrations/0120_drop_usage_report_sweep.sql +7 -0
- package/src/migrations/0121_drop_platform_migration_runs.sql +12 -0
- package/src/migrations/0122_drop_scheduled_task_runs_rechecked_at.sql +5 -0
- package/src/migrations/0123_pgvector.sql +27 -0
- package/src/migrations/0124_conversation_source.sql +36 -0
- package/src/migrations/0125_conversation_tree_stopped_at.sql +5 -0
- package/src/migrations/0126_git_gateway.sql +10 -0
- package/src/migrations/0127_git_push_policy.sql +12 -0
- package/src/migrations/0128_scheduled_task_plugin_disabled.sql +10 -0
- package/src/migrations/0129_connector_plugin_disabled.sql +5 -0
- package/src/migrations/0130_auto_mode.sql +48 -0
- package/src/migrations/0131_device_mode.sql +9 -0
- package/src/migrations/0132_compact_runs.sql +6 -0
- package/src/migrations/0133_project_root.sql +30 -0
- package/src/migrations/0134_org_cloud_network_delta.sql +38 -0
- package/src/migrations/0135_run_execution_claim.sql +2 -0
- package/src/migrations/0136_run_recovery_cursor.sql +6 -0
- package/src/migrations/0137_audit_org_idx.sql +5 -0
- package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
- package/src/migrations/0139_retire_legacy_forms.sql +183 -0
- package/src/migrations/0140_retire_history_forms.sql +148 -0
- package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
- package/src/migrations/0142_backfill_event_fields.sql +74 -0
- package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
- package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
- package/src/migrations/0145_org_network_allowances.sql +12 -0
- 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/src/migrations/0161_file_shares.sql +35 -0
- package/src/migrations/0162_permission_call_escalation.sql +9 -0
- package/src/migrations/0163_read_attachments.sql +10 -0
- package/src/migrations/0164_platform_icons.sql +10 -0
- package/src/migrations/0165_device_network_columns.sql +50 -0
- package/src/migrations/0166_permission_grant_full_access.sql +17 -0
- package/src/migrations/0167_device_network_backfill.sql +32 -0
- package/src/migrations/0168_binding_installed_connection.sql +6 -0
- package/src/migrations/0169_platform_sealed_inputs.sql +23 -0
- package/src/migrations/0170_platform_sealed_reveals.sql +27 -0
- package/src/migrations/0171_account_avatar.sql +26 -0
- package/src/migrations/0172_push.sql +40 -0
- package/src/migrations/0173_push_auth_notice.sql +10 -0
- package/src/migrations/0174_marketplace_managed_username.sql +4 -0
- package/src/migrations/0175_secure_input_kind.sql +8 -0
- package/src/migrations/0176_device_report.sql +6 -0
- package/src/migrations/0177_dial_in_contract.sql +32 -0
- package/src/migrations/0178_bootstrap_run_extra.sql +17 -0
- package/src/migrations/0179_device_report_limit_text.sql +28 -0
- package/src/migrations/0180_device_instance_abandoned.sql +6 -0
- package/src/migrations/0181_connector_description.sql +3 -0
- package/src/migrations/0182_rls_policies.sql +202 -0
- package/src/migrations/0183_connectors_created_by_nullable.sql +5 -0
- package/src/migrations/0184_background_cancel_failure.sql +10 -0
- package/src/migrations/0185_channel_process_display.sql +13 -0
- package/src/migrations/0186_question_woken.sql +5 -0
- package/src/migrations/0187_device_conversation_notices.sql +35 -0
- package/src/migrations/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -0
- package/src/migrations/0190_file_library.sql +285 -0
- package/src/migrations/0191_file_library_copy.sql +4 -0
- package/src/migrations/0192_inbox_items.sql +50 -0
- package/src/migrations/0193_trigger_cause_handles.sql +49 -0
- package/src/migrations/0194_automation_acceptance.sql +83 -0
- package/src/migrations/0195_idle_compaction.sql +7 -0
- package/src/migrations/0196_conversation_events_compaction_summary_idx.sql +8 -0
- package/src/migrations/0197_inbox_item_localized_text.sql +8 -0
- package/src/migrations/0198_acceptance_prompt.sql +10 -0
- package/src/migrations/0199_device_loopback_grants.sql +59 -0
- package/src/migrations/0200_runs_idle_mode.sql +4 -0
- package/src/migrations/0201_tool_specs_text.sql +8 -0
- package/src/migrations/0202_connector_endpoint_changed_at.sql +1 -0
- package/src/migrations/0203_model_cache_write_pricing.sql +5 -0
- package/src/migrations/0204_device_instance_retirement_identities.sql +46 -0
- package/src/migrations/0205_device_site_grants.sql +30 -0
- package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
- package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
- package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
- package/src/migrations/0209_onboarding_checklist.sql +5 -0
- package/src/migrations/0210_normalize_conversation_history.sql +1012 -0
- package/src/migrations/0211_pre_release_cleanup.sql +154 -0
- package/src/migrations/0212_org_security_policy.sql +234 -0
- package/src/migrations/0213_contract_org_security_policy.sql +43 -0
- package/src/migrations/0214_model_usage_price_snapshot.sql +2 -0
- package/src/migrations/0215_conversation_events_org_id.sql +48 -0
- package/src/migrations/0216_model_budget_counters.sql +24 -0
- package/src/migrations/0217_retention.sql +44 -0
- package/src/migrations/0218_data_erasure.sql +41 -0
- package/src/migrations/0219_event_org_constraint_check.sql +29 -0
- package/src/migrations/0220_require_event_org.sql +18 -0
- package/src/migrations/0221_drop_connector_declaration_policy.sql +2 -0
- package/src/migrations/0222_device_host_services.sql +27 -0
- package/src/migrations/0223_device_service_events.sql +54 -0
- package/src/migrations/0224_cache_conversation_rls_settings.sql +33 -0
- package/src/migrations/0225_extension_effect_receipts.sql +25 -0
- package/src/migrations/0226_enable_kernel_rls.sql +30 -0
- package/src/migrations/0227_external_conversations.sql +33 -0
- package/src/migrations/0228_extension_org_switches.sql +56 -0
- package/src/migrations/0229_catalog_dependency_edges.sql +17 -0
- package/src/migrations/0230_audit_filter_idx.sql +18 -0
- package/src/migrations/0231_plugin_effect_work.sql +171 -0
- package/src/migrations/0232_contract_plugin_effect_schema.sql +49 -0
- package/src/migrations/0233_enable_request_targets.sql +64 -0
- package/src/migrations/0234_extension_grant_epoch.sql +141 -0
- package/src/migrations/0235_extension_revision_grants.sql +166 -0
- package/src/migrations/0236_paged_table_idx.sql +33 -0
- package/src/migrations/0237_extension_handoff_health.sql +18 -0
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
- package/src/migrations/0240_directory_sync_state.sql +34 -0
- package/dist/background/status.d.ts +0 -35
- package/dist/background/status.js +0 -57
- package/dist/catalog/org-extension-switch.d.ts +0 -41
- package/dist/catalog/org-extension-switch.js +0 -115
- package/dist/catalog/owned-plugin-cleanup.d.ts +0 -56
- package/dist/catalog/owned-plugin-cleanup.js +0 -194
- package/dist/catalog/platform-migration.d.ts +0 -115
- package/dist/catalog/platform-migration.js +0 -583
- package/dist/conversations/job-ids.d.ts +0 -6
- package/dist/conversations/job-ids.js +0 -6
- package/dist/devices/legacy-cleanup.job.d.ts +0 -34
- package/dist/devices/legacy-cleanup.job.js +0 -141
- package/dist/extensions/job-ids.d.ts +0 -6
- package/dist/extensions/job-ids.js +0 -6
- package/dist/infra/queue/add-job-once.d.ts +0 -14
- package/dist/infra/queue/add-job-once.js +0 -16
- package/dist/infra/queue/retired-schedulers.d.ts +0 -7
- package/dist/infra/queue/retired-schedulers.js +0 -9
- package/dist/local-devices/device-auth.module.d.ts +0 -7
- package/dist/local-devices/device-auth.module.js +0 -25
- package/dist/local-devices/device-routes.d.ts +0 -36
- package/dist/local-devices/device-routes.js +0 -90
- package/dist/local-devices/local-device-gateway.d.ts +0 -128
- package/dist/local-devices/local-device-gateway.js +0 -530
- package/dist/local-devices/local-device-provider.d.ts +0 -89
- package/dist/local-devices/local-device-provider.js +0 -151
- package/dist/local-devices/local-devices.module.d.ts +0 -16
- package/dist/local-devices/local-devices.module.js +0 -44
- package/dist/local-devices/relay.d.ts +0 -100
- package/dist/local-devices/relay.js +0 -373
- package/dist/local-devices/targets.d.ts +0 -28
- package/dist/local-devices/targets.js +0 -73
- package/dist/orgs/job-ids.d.ts +0 -8
- package/dist/orgs/job-ids.js +0 -8
- package/dist/runtime/context/legacy-text.d.ts +0 -22
- package/dist/runtime/context/legacy-text.js +0 -37
- package/dist/runtime/job-ids.d.ts +0 -10
- package/dist/runtime/job-ids.js +0 -10
- package/dist/runtime/retired-schedulers.d.ts +0 -7
- package/dist/runtime/retired-schedulers.js +0 -31
- package/dist/storage/job-ids.d.ts +0 -6
- package/dist/storage/job-ids.js +0 -6
- package/dist/tools/builtins/skill-write.d.ts +0 -59
- package/dist/tools/builtins/skill-write.js +0 -244
- package/dist/tools/legacy-data.d.ts +0 -34
- package/dist/tools/legacy-data.js +0 -76
- package/dist/tools/legacy-keys.d.ts +0 -51
- package/dist/tools/legacy-keys.js +0 -115
package/dist/tools/pipeline.js
CHANGED
|
@@ -7,89 +7,229 @@ 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 {
|
|
10
|
+
import { CARD_BADGE_MAX, CARD_TEXT_MAX, DeviceAccessError, ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
|
+
import { sql } from "kysely";
|
|
13
|
+
import { appendMissingGrant, connectionGrantKey, reviewHoldKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../automations/unattended.js";
|
|
14
|
+
import { backgroundMaxSeconds } from "../background/launch.js";
|
|
15
|
+
import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
|
|
16
|
+
import { AttachmentsService } from "../conversations/attachments.service.js";
|
|
12
17
|
import { EventLog } from "../conversations/event-log.js";
|
|
13
|
-
import { ToolViewSchema } from "../conversations/events.js";
|
|
18
|
+
import { COMMAND_ASK_MAX_CHARS, COMMAND_ASK_TEXT_MAX_CHARS, ToolViewSchema, } from "../conversations/events.js";
|
|
19
|
+
import { siteAccessDetailHash, siteAccessInstallActive, } from "../device-access/site-access-request.js";
|
|
20
|
+
import { DeviceSiteGrants } from "../device-access/site-grants.js";
|
|
21
|
+
import { ConversationDevices } from "../devices/conversation-devices.js";
|
|
22
|
+
import { pathAgainstWorkingRoot } from "../devices/working-root.js";
|
|
14
23
|
import { ApiError } from "../errors.js";
|
|
15
24
|
import { EffectiveConfigs, NEEDS_CONFIG_REASON } from "../extensions/effective-config.js";
|
|
25
|
+
import { isExtensionEnabled } from "../extensions/enabled.js";
|
|
16
26
|
import { clipText } from "../extensions/hooks.js";
|
|
17
27
|
import { ExtensionHost } from "../extensions/host.js";
|
|
18
28
|
import { ExtensionUnloadedError, PLUGIN_UNLOADED_TOOL_ERROR } from "../extensions/inflight.js";
|
|
29
|
+
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
19
30
|
import { audit } from "../identity/audit.js";
|
|
31
|
+
import { sha256Hex } from "../identity/hash.js";
|
|
20
32
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
21
33
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
22
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
34
|
+
import { TransactionHost, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
|
|
23
35
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
24
36
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
37
|
+
import { roleAtLeast } from "../orgs/roles.js";
|
|
25
38
|
import { UNKNOWN_RESULT_TEXT } from "../runtime/context/pairing.js";
|
|
26
39
|
import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookScope, } from "../runtime/hook-calls.js";
|
|
27
40
|
import { subagentWaitingIdemKey } from "../runtime/loop.js";
|
|
28
|
-
import { assistantIdemKey,
|
|
41
|
+
import { assistantIdemKey, MAX_STEP_MODEL_CALLS, modelCallIdemKey } from "../runtime/model-call.js";
|
|
42
|
+
import { currentExecutionClaim } from "../runtime/run-execution.js";
|
|
29
43
|
import { rootSurfaceOf } from "../runtime/subagents/child.js";
|
|
30
44
|
import { SubagentMessages } from "../runtime/subagents/messages.js";
|
|
31
45
|
import { pairStoppedForks } from "../runtime/subagents/skill-fork.js";
|
|
32
46
|
import { SubagentsService } from "../runtime/subagents/subagents.service.js";
|
|
47
|
+
import { LoopbackGrants, LoopbackLimitError, loopbackRefusal, } from "../sandbox/loopback-grants.js";
|
|
48
|
+
import { orgHostOutsideCeiling } from "../sandbox/modes.js";
|
|
49
|
+
import { NetworkGrants } from "../sandbox/network-grants.js";
|
|
50
|
+
import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
|
|
51
|
+
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
52
|
+
import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
|
|
53
|
+
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
54
|
+
import { PermissionFacts, permissionScopeHash } from "../sandbox/permission-facts.js";
|
|
55
|
+
import { isSessionGrantableRule, } from "../sandbox/review/index.js";
|
|
56
|
+
import { approverForCrossing, buildPermissionCandidate, crossingOfCandidate, ESCALATION_RETRY_HINT, ESCALATION_UNATTENDED_WHY, escalationRefusedText, isEscalatedCall, } from "../sandbox/review/permission-candidate.js";
|
|
57
|
+
import { CommandReviewService, LOOPBACK_FULL_ACCESS_REASON, } from "../sandbox/review/review.service.js";
|
|
58
|
+
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
33
59
|
import { skillLoadOfferedIn } from "../skills/catalog.js";
|
|
34
|
-
import { ApprovalsService } from "./approvals.service.js";
|
|
60
|
+
import { ApprovalsService, } from "./approvals.service.js";
|
|
35
61
|
import { Breaker, breakerOpenMessage } from "./breaker.js";
|
|
36
|
-
import { SEND_MESSAGE, SUBAGENT_HANDBACK, TOOL_SEARCH } from "./builtin-names.js";
|
|
62
|
+
import { BUILTIN, SEND_MESSAGE, SUBAGENT_HANDBACK, TOOL_SEARCH } from "./builtin-names.js";
|
|
37
63
|
import { AGENT_TOOL, AgentToolInput } from "./builtins/agent.js";
|
|
38
64
|
import { HandbackInput } from "./builtins/handback.js";
|
|
65
|
+
import { generateImagePaths } from "./builtins/image/paths.js";
|
|
66
|
+
import { admissionUnavailableText } from "./builtins/sandbox/common.js";
|
|
67
|
+
import { DEVICE_CODE_PATTERN, deviceCodeIdemKey, GITHUB_DEVICE_LOGIN_URL, } from "./builtins/sandbox/device-code.js";
|
|
68
|
+
import { DEVICE_OF_ANOTHER_ACCOUNT_TEXT } from "./builtins/sandbox/device-owner.js";
|
|
39
69
|
import { SendMessageInput } from "./builtins/send-message.js";
|
|
40
70
|
import { isAlwaysLoaded, notLoadedText } from "./builtins/tool-search.js";
|
|
71
|
+
import { attachCallScope, mergeServiceHosts, serviceHostKey, stillStartingUnsent, } from "./call-scope.js";
|
|
41
72
|
import { canonicalJson } from "./canonical-json.js";
|
|
42
73
|
import { CredentialMissing, Credentials } from "./credentials.js";
|
|
43
74
|
import { ToolDrift } from "./drift.js";
|
|
44
75
|
import { ElicitationSession } from "./elicitation.js";
|
|
45
|
-
import {
|
|
76
|
+
import { loopbackGrantedNote, loopbackNotAppliedNote, loopbackPendingNote, loopbackReviewDeniedNote, planLoopbackAsk, } from "./loopback-asks.js";
|
|
77
|
+
import { addressEscalationHint, blockedEventHosts, clipKept, denialHintFor, deviceAskTerms, MAX_NETWORK_ASKS_PER_RUN, NETWORK_ASK_KEPT_MAX_BYTES, networkBlockedIdemKey, otherAskPendingNote, planNetworkAsk, serviceAskedNote, serviceAskTerms, settledNetworkNotes, tooManyNote, withNetworkNotes, } from "./network-asks.js";
|
|
78
|
+
import { readOrgToolPolicy, } from "./org-tool-policies.js";
|
|
46
79
|
import { OrgToolSwitches, toolTurnedOffReason } from "./org-tool-switches.js";
|
|
47
80
|
import { renderResult, resolveOutputRefs, spillIfLarge, ToolOutputs } from "./outputs.js";
|
|
48
81
|
import { createDecidePolicy } from "./policy.js";
|
|
49
|
-
import { QuestionsService } from "./questions.service.js";
|
|
82
|
+
import { QuestionsService, TooManyWatchedWaitsError, } from "./questions.service.js";
|
|
50
83
|
import { redactDeep, redactorFor } from "./redact.js";
|
|
51
84
|
import { ToolRegistry, } from "./registry.js";
|
|
52
85
|
import { runResourceTool } from "./resources.js";
|
|
86
|
+
import { storeResultImages } from "./result-images.js";
|
|
87
|
+
import { ToolAskReview } from "./tool-review.js";
|
|
53
88
|
import { validateInput } from "./validate.js";
|
|
54
89
|
// ---- 模型可见文案(英文) ----
|
|
55
90
|
/** 审批被拒绝。 */
|
|
56
91
|
export const APPROVAL_DENIED_TEXT = "The user denied this tool call.";
|
|
57
92
|
/**
|
|
58
93
|
* The denied call's result when the approver gave a reason (model-visible, in the log). "An
|
|
59
|
-
* approver": under role escalation an admin, not the requester, decides.
|
|
60
|
-
* they recorded ("The user denied this tool call. Reason: …"); only new denials use this one.
|
|
94
|
+
* approver": under role escalation an admin, not the requester, decides.
|
|
61
95
|
*/
|
|
62
96
|
export const approvalDeniedText = (reason) => reason === null ? APPROVAL_DENIED_TEXT : `An approver denied this tool call. Reason: ${reason}`;
|
|
63
97
|
/** 审批超时(按拒绝)。 */
|
|
64
98
|
export const approvalExpiredText = (hours) => `Approval timed out after ${hours}h; treated as denied.`;
|
|
65
99
|
/** 等待审批期间 run 被中止。 */
|
|
66
100
|
export const APPROVAL_CANCELLED_TEXT = "The run was stopped while waiting for approval.";
|
|
101
|
+
/** A person field refused on the approval card as leaked, for a call that then did not run. */
|
|
102
|
+
export const leakedOnCardText = (path) => `The person's \`${path}\` appeared in the conversation earlier and was refused as leaked; ask them to rotate it.`;
|
|
103
|
+
/**
|
|
104
|
+
* A call that ended without running: its text, then the leaked-on-card line per person field the
|
|
105
|
+
* approval card refused as leaked (`detail.leakedFields`), so the agent has the key rotated.
|
|
106
|
+
*/
|
|
107
|
+
export const withLeakedOnCard = (text, leakedFields) => leakedFields === undefined || leakedFields.length === 0
|
|
108
|
+
? text
|
|
109
|
+
: [text, ...leakedFields.map(leakedOnCardText)].join("\n");
|
|
110
|
+
/**
|
|
111
|
+
* The command review's deny text (auto mode spec §5.4, P-D12): the model-visible reason and what it
|
|
112
|
+
* can do instead. `kind` says whether a shell command, a file write or a file read was held.
|
|
113
|
+
*/
|
|
114
|
+
export const commandDeniedText = (reason, kind) => kind === "write"
|
|
115
|
+
? `This write is blocked by review: ${reason}. Write it another way or ask the user to allow it.`
|
|
116
|
+
: kind === "read"
|
|
117
|
+
? `This read is blocked by review: ${reason}. Read another file or ask the user to allow it.`
|
|
118
|
+
: `Command blocked by review: ${reason}. Do the work another way or ask the user to run it.`;
|
|
119
|
+
/**
|
|
120
|
+
* A command (or write, or read) the review held in an unattended run: no one can answer, so it is a
|
|
121
|
+
* deny at once — no approval, no grant (P-D3); the task run records the held class
|
|
122
|
+
* (`reviewHoldKey`).
|
|
123
|
+
*/
|
|
124
|
+
export const commandUnattendedText = (reason, kind) => kind === "command"
|
|
125
|
+
? `This command needs approval (${reason}), and no one can approve it now; do the work another way or leave it for the person.`
|
|
126
|
+
: `This ${kind} needs approval (${reason}), and no one can approve it now; do it another way or leave it for the person.`;
|
|
127
|
+
/**
|
|
128
|
+
* A command longer than the ask ceiling (`COMMAND_ASK_MAX_CHARS`): it cannot be shown for approval,
|
|
129
|
+
* and an approval must bind the whole text, so the call is refused before any approval exists.
|
|
130
|
+
*/
|
|
131
|
+
export const commandTooLongReason = (chars) => `The command is ${chars} characters long; commands over ${COMMAND_ASK_MAX_CHARS} are too long to review and approve.`;
|
|
132
|
+
/** The model-visible result of a command over the ask ceiling (actionable, English). */
|
|
133
|
+
export const commandTooLongText = (chars) => `This command is too long to review (${chars} characters; the limit is ${COMMAND_ASK_MAX_CHARS}). Split it into shorter commands; long inline scripts are reviewed as code the review cannot read.`;
|
|
134
|
+
/** The person declined a held command, write or read (P-D12); `reason` is what they said, if any. */
|
|
135
|
+
export const commandDeclinedText = (reason, kind) => {
|
|
136
|
+
const what = kind === "write" ? "this write" : kind === "read" ? "this read" : "to run this command";
|
|
137
|
+
return reason === null
|
|
138
|
+
? `The user declined ${what}. Continue without it or ask the user.`
|
|
139
|
+
: `The user declined ${what}: ${reason}. Continue without it or ask the user.`;
|
|
140
|
+
};
|
|
67
141
|
/** 等待用户输入期间 run 被中止。 */
|
|
68
142
|
export const INPUT_CANCELLED_TEXT = "The run was stopped while waiting for user input.";
|
|
143
|
+
/**
|
|
144
|
+
* The result of an `AskUserQuestion` call whose question the user skipped by sending a message
|
|
145
|
+
* (reply-while-question spec §7.1): the message follows in the log as an ordinary user message.
|
|
146
|
+
*/
|
|
147
|
+
export const QUESTION_SKIPPED_TEXT = "The user did not answer this question and sent a message instead; read it below and continue.";
|
|
148
|
+
/** The result of any other tool's input request (extension `input_required`, MCP elicitation) skipped by a message. */
|
|
149
|
+
export const INPUT_SKIPPED_TEXT = "The user did not provide the requested input and sent a message instead; read it below and continue. Call the tool again only if it is still needed.";
|
|
150
|
+
/**
|
|
151
|
+
* The result of a watched wait (`InputRequired.watch`) ended by the person's message (browser long
|
|
152
|
+
* waits spec §5.2): ending a wait by writing is not a tool failure.
|
|
153
|
+
*/
|
|
154
|
+
export const WAIT_SKIPPED_TEXT = "The user sent a message while this wait was running, which ended it; read the message below and continue. Call the tool again only if the wait is still needed.";
|
|
155
|
+
/** A watched ask over `tools.maxWatchedWaitsPerAccount` (spec §5.2). */
|
|
156
|
+
export const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let an automation check later.";
|
|
157
|
+
/** A tool asked for a watched wait without a registered watcher (spec §5.2). */
|
|
158
|
+
export const watchWithoutWatcherText = (key) => `Tool ${key} asked for a watched wait but registers no watcher.`;
|
|
69
159
|
/** 同一调用连续请求输入超过上限。 */
|
|
70
160
|
export const TOO_MANY_INPUT_REQUESTS_TEXT = "Tool requested user input too many times.";
|
|
71
161
|
/** run 已被中止 / 到达截止时间,调用尚未开始执行。 */
|
|
72
162
|
export const RUN_STOPPED_TEXT = "The run was stopped before this tool call was executed.";
|
|
163
|
+
/**
|
|
164
|
+
* A call with person fields in an unattended run (ruling R6): no person is there to type the
|
|
165
|
+
* values on the card.
|
|
166
|
+
*/
|
|
167
|
+
export const PERSON_FIELDS_UNATTENDED_TEXT = "This write needs the person to enter values on the web; it cannot run unattended.";
|
|
168
|
+
/**
|
|
169
|
+
* A call with person fields whose ask would go to a role instead of the person (ruling R5): only the
|
|
170
|
+
* person the run works for may type the values, and they lack the role.
|
|
171
|
+
*/
|
|
172
|
+
export const PERSON_FIELDS_ROLE_TEXT = "This write needs the person you work for to enter values; they lack the role. Ask an admin to do it on the web.";
|
|
173
|
+
/**
|
|
174
|
+
* A call only the person may confirm (`CallPolicy.personOnly`: its result is shown once to the
|
|
175
|
+
* run's person) in an unattended run: nobody is there to read it.
|
|
176
|
+
*/
|
|
177
|
+
export const PERSON_ONLY_UNATTENDED_TEXT = "This write shows its result once, on the web, to the person you work for, and no one is there to read it; it cannot run unattended.";
|
|
178
|
+
/**
|
|
179
|
+
* A call that changes what the person consents to (`CallPolicy.personDecides`) in an unattended
|
|
180
|
+
* run: only that person decides it, and nobody is there.
|
|
181
|
+
*/
|
|
182
|
+
export const PERSON_DECIDES_UNATTENDED_TEXT = "This write changes what the person you work for consents to, so only they can confirm it, and no one is there; it cannot run unattended. Ask them to make the change on the web.";
|
|
183
|
+
/** A call only the person may confirm whose ask would go to a role instead of the person. */
|
|
184
|
+
export const PERSON_ONLY_ROLE_TEXT = "This write shows its result once to the person you work for, so it runs only for them, and they lack the role. Ask an admin to do it on the web.";
|
|
185
|
+
/**
|
|
186
|
+
* The review model declined, under Approve for me, a call whose approval would have gone to the
|
|
187
|
+
* person (profiles govern every approval, R3): nothing ran.
|
|
188
|
+
*/
|
|
189
|
+
export const toolReviewDeniedText = (reason) => `The review model declined this call for the person (Approve for me): ${reason} Nothing ran. Tell the person what you wanted to do and why; they can do it themselves, or switch this conversation to Request approval and approve it when you call again.`;
|
|
190
|
+
/** The reason recorded when Auto runs an approval addressed to the person (R2). */
|
|
191
|
+
export const TOOL_AUTO_REASON = "Auto runs approvals addressed to the person without asking.";
|
|
192
|
+
/** The person cancelled the secure input request of a call with person fields (R4): nothing ran. */
|
|
193
|
+
export const secureInputCancelledText = (id) => `The person cancelled secure input ${id}, so nothing ran. Never ask for the value in the conversation; call the operation again only if the person asks for it.`;
|
|
194
|
+
/** A secure input request expired unanswered (R4): nothing ran. */
|
|
195
|
+
export const secureInputExpiredText = (id, hours) => `Secure input ${id} expired after ${hours} h without the person submitting it, so nothing ran. Call the operation again if it is still needed.`;
|
|
73
196
|
/** 调用执行中 run 被中止 / 到达截止时间。 */
|
|
74
197
|
export const RUN_STOPPED_DURING_TEXT = "The run was stopped while this tool call was running; its outcome is unknown. Verify before retrying.";
|
|
198
|
+
/** The fixed result of a call whose input request was skipped by a message (spec §7.1). */
|
|
199
|
+
const skippedResult = (toolKey, watch = false) => watch
|
|
200
|
+
? {
|
|
201
|
+
content: WAIT_SKIPPED_TEXT,
|
|
202
|
+
isError: false,
|
|
203
|
+
display: { summary: { zh: "等待因新消息结束", en: "Wait ended by your message" } },
|
|
204
|
+
}
|
|
205
|
+
: toolKey === "AskUserQuestion"
|
|
206
|
+
? {
|
|
207
|
+
content: QUESTION_SKIPPED_TEXT,
|
|
208
|
+
isError: false,
|
|
209
|
+
display: {
|
|
210
|
+
summary: {
|
|
211
|
+
zh: "用户没有回答,直接发了消息",
|
|
212
|
+
en: "User sent a message instead of answering",
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
: {
|
|
217
|
+
content: INPUT_SKIPPED_TEXT,
|
|
218
|
+
isError: true,
|
|
219
|
+
display: {
|
|
220
|
+
summary: { zh: "用户没有提供输入,直接发了消息", en: "User sent a message instead" },
|
|
221
|
+
},
|
|
222
|
+
};
|
|
75
223
|
const timeoutText = (key, ms) => `Tool ${key} timed out after ${ms / 1000}s. The operation may or may not have completed; verify before retrying.`;
|
|
224
|
+
/**
|
|
225
|
+
* The timeout of a call whose device was still starting (its instance being created or resumed,
|
|
226
|
+
* or the device service being launched) and that had sent nothing to a device service: its
|
|
227
|
+
* target was not reached. The start was stopped with the call, so a retry starts it again.
|
|
228
|
+
*/
|
|
229
|
+
export const deviceStartingTimeoutText = (key, ms) => `Tool ${key} timed out after ${ms / 1000}s while the device was still starting (its sandbox or the device service), before the call sent anything to its target. The start was stopped with the call; a retry starts the device again, and if it times out the same way the tool's time limit is too short for this device's first start: tell the user.`;
|
|
76
230
|
const failedText = (key, errName) => `Tool ${key} failed (${errName}). The operation may not have completed; check before retrying or try another approach.`;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const connectorSlugs = new Set();
|
|
80
|
-
const extensionNames = new Set();
|
|
81
|
-
for (const t of tools) {
|
|
82
|
-
const p = parseToolKey(t.key);
|
|
83
|
-
if (p?.kind === "connector")
|
|
84
|
-
connectorSlugs.add(p.slug);
|
|
85
|
-
else if (p?.kind === "extension")
|
|
86
|
-
extensionNames.add(p.plugin);
|
|
87
|
-
}
|
|
88
|
-
return { connectorSlugs, extensionNames };
|
|
89
|
-
};
|
|
90
|
-
const unknownToolText = (name, keys, toolSearch, hint = null) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
|
|
91
|
-
(toolSearch ? " Use ToolSearch to load other tools." : "") +
|
|
92
|
-
(hint === null ? "" : ` ${hint}`);
|
|
231
|
+
const unknownToolText = (name, keys, toolSearch) => `Unknown tool "${name}". Available tools: ${keys.length === 0 ? "(none)" : keys.join(", ")}.` +
|
|
232
|
+
(toolSearch ? " Use ToolSearch to load other tools." : "");
|
|
93
233
|
const unavailableText = (name, reason) => `Tool "${name}" is unavailable: ${reason}.`;
|
|
94
234
|
/** With a per-call policy key (`Platform:<operation>`), the text names it. */
|
|
95
235
|
const deniedText = (key, policyKey) => policyKey === undefined || policyKey === key
|
|
@@ -105,9 +245,151 @@ export const hookDeniedText = (plugin, reason) => `Tool call blocked by the "${p
|
|
|
105
245
|
const invalidFormText = (key, problems) => `Tool ${key} returned an invalid input form: ${problems.join("; ")}.`;
|
|
106
246
|
const stateTooLargeText = (key) => `Tool ${key} returned input state larger than ${MAX_INPUT_STATE_BYTES / 1024} KB.`;
|
|
107
247
|
const personalMissingText = (connectorName) => `The user has not connected ${connectorName}. A connect card was shown; ask the user to connect, then retry.`;
|
|
108
|
-
|
|
248
|
+
/**
|
|
249
|
+
* A connector lacking its org input (`needs_config`, plugin pages spec §5.2.1): `Credentials`
|
|
250
|
+
* throws an org `CredentialMissing` before any credential is presented, so the call never opens.
|
|
251
|
+
*/
|
|
252
|
+
const ORG_MISSING_TEXT = "This connector needs to be configured by an organization admin before it can be used.";
|
|
253
|
+
const sameOrgAsk = (a, b) => canonicalJson(a ?? []) === canonicalJson(b ?? []);
|
|
254
|
+
class OrgToolPolicyChanged extends Error {
|
|
255
|
+
}
|
|
256
|
+
class OrgToolDenied extends Error {
|
|
257
|
+
}
|
|
109
258
|
/** Optional provider: the pipeline's {@link ToolPipelineHooks} (tests). */
|
|
110
259
|
export const TOOL_PIPELINE_HOOKS = Symbol("TOOL_PIPELINE_HOOKS");
|
|
260
|
+
/** Review usage and hooks retain the same tree ancestry on both review routes. */
|
|
261
|
+
function reviewParentOf(parent) {
|
|
262
|
+
return parent === undefined
|
|
263
|
+
? {}
|
|
264
|
+
: {
|
|
265
|
+
parentRunId: parent.runId,
|
|
266
|
+
...(parent.budgetRunId !== undefined && { budgetRunId: parent.budgetRunId }),
|
|
267
|
+
parent: {
|
|
268
|
+
conversationId: parent.conversationId,
|
|
269
|
+
runId: parent.runId,
|
|
270
|
+
callId: parent.callId,
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The tools the command review covers (auto mode spec §5.1): the shell and the file tools whose
|
|
276
|
+
* writes may leave the workspace, and `GenerateImage` when it writes its images into the device
|
|
277
|
+
* (`file_path`; image generation spec §5.3, reviewed as a `Write`). Any other tool call is not
|
|
278
|
+
* reviewed (the review service answers `allow` for it too; the pipeline skips the facts read).
|
|
279
|
+
*/
|
|
280
|
+
const REVIEWED_TOOL_KEYS = new Set(["Bash", "Write", "Edit", "GenerateImage"]);
|
|
281
|
+
/** Whether the review covers this call ({@link REVIEWED_TOOL_KEYS}; `GenerateImage` with a path). */
|
|
282
|
+
const isReviewedCall = (toolKey, input) => REVIEWED_TOOL_KEYS.has(toolKey) &&
|
|
283
|
+
(toolKey !== "GenerateImage" || generateImagePaths(input).length > 0);
|
|
284
|
+
/** The paths a reviewed write writes: `file_path`, or every path of a `GenerateImage` call. */
|
|
285
|
+
const writePathsOf = (toolKey, input) => toolKey === "GenerateImage" ? generateImagePaths(input) : [textField(input, "file_path")];
|
|
286
|
+
/**
|
|
287
|
+
* A call that needs reach beyond the working directory on a device whose permission support is
|
|
288
|
+
* not verified: no approval could let admission run it, so nothing is offered.
|
|
289
|
+
*/
|
|
290
|
+
export const PERMISSION_SUPPORT_UNVERIFIED_TEXT = "This call needs access outside the working directory, but this device's permission support is not verified yet, so only paths inside the working directory work now. Keep the call inside the working directory, or retry once the device is ready.";
|
|
291
|
+
/**
|
|
292
|
+
* The managed builtins whose review depends on the device's facts (a proposed reach or a
|
|
293
|
+
* sensitive command): their first call starts the device before it is reviewed. The others start
|
|
294
|
+
* it only when they run (a Skill without scripts never does).
|
|
295
|
+
*/
|
|
296
|
+
const REVIEWED_ON_FACTS = new Set([
|
|
297
|
+
BUILTIN.Bash,
|
|
298
|
+
BUILTIN.Read,
|
|
299
|
+
BUILTIN.Write,
|
|
300
|
+
BUILTIN.Edit,
|
|
301
|
+
BUILTIN.GenerateImage,
|
|
302
|
+
]);
|
|
303
|
+
/** The refusals of a permission review that end the call (fail closed), not the run. */
|
|
304
|
+
const FAIL_CLOSED_CODES = new Set([
|
|
305
|
+
"forbidden",
|
|
306
|
+
"conflict",
|
|
307
|
+
"conversation.not_found",
|
|
308
|
+
]);
|
|
309
|
+
/** What the model gets when the permission check of its call refused (fail closed). */
|
|
310
|
+
export const permissionCheckFailedText = (why) => `The permission check for this call could not be completed (${why.replace(/\.$/, "")}), so it did not run. Retry the call once; if it fails again, ask the user to check the conversation's permission profile or to approve the call again.`;
|
|
311
|
+
/** The builtins whose device entry is the managed operation route. */
|
|
312
|
+
const MANAGED_OPERATION_TOOLS = new Set([
|
|
313
|
+
BUILTIN.Bash,
|
|
314
|
+
BUILTIN.Read,
|
|
315
|
+
BUILTIN.Write,
|
|
316
|
+
BUILTIN.Edit,
|
|
317
|
+
BUILTIN.Glob,
|
|
318
|
+
BUILTIN.Grep,
|
|
319
|
+
BUILTIN.Deliver,
|
|
320
|
+
BUILTIN.FetchAttachment,
|
|
321
|
+
BUILTIN.Skill,
|
|
322
|
+
BUILTIN.GenerateImage,
|
|
323
|
+
]);
|
|
324
|
+
/**
|
|
325
|
+
* Whether a managed builtin's call enters the device: every call of the device tools, a
|
|
326
|
+
* `GenerateImage` call only with `file_path` (one without writes nothing into the device, so it
|
|
327
|
+
* takes neither the device-owner guard nor the permission review: image generation spec §5.3),
|
|
328
|
+
* and a `Read` only with `file_path` (a `file_id` read comes from the object store: vision-read
|
|
329
|
+
* design §1.1).
|
|
330
|
+
*/
|
|
331
|
+
const entersDevice = (toolKey, input) => {
|
|
332
|
+
if (toolKey === BUILTIN.Read) {
|
|
333
|
+
return typeof input?.file_path === "string";
|
|
334
|
+
}
|
|
335
|
+
return toolKey !== BUILTIN.GenerateImage || generateImagePaths(input).length > 0;
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* What the review holds, for the texts and the ask's detail: a shell command, a file read (a read
|
|
339
|
+
* tool's crossing asks to read, never to write) or a file write.
|
|
340
|
+
*/
|
|
341
|
+
const reviewKindOf = (toolKey) => toolKey === BUILTIN.Bash
|
|
342
|
+
? "command"
|
|
343
|
+
: toolKey === BUILTIN.Read || toolKey === BUILTIN.Glob || toolKey === BUILTIN.Grep
|
|
344
|
+
? "read"
|
|
345
|
+
: "write";
|
|
346
|
+
/**
|
|
347
|
+
* The working root a reviewed call carries to its tool: a project root only. In free mode the
|
|
348
|
+
* reviewed root is the recorded workspace, which may be stale; the tool then maps it to the held
|
|
349
|
+
* instance's own workspace as it always has.
|
|
350
|
+
*/
|
|
351
|
+
const carriedRoot = (facts) => facts.workingRoot !== undefined && facts.workingRoot !== facts.workspace
|
|
352
|
+
? facts.workingRoot
|
|
353
|
+
: undefined;
|
|
354
|
+
/** The review record of an allowed call. */
|
|
355
|
+
const allowRecord = (v) => ({
|
|
356
|
+
decision: "allow",
|
|
357
|
+
by: v.by,
|
|
358
|
+
rule: v.rule,
|
|
359
|
+
reason: v.reason,
|
|
360
|
+
});
|
|
361
|
+
/** The review record of a denied call (the rule table's, the classifier's or a person's). */
|
|
362
|
+
const denyRecord = (by, rule, reason) => ({
|
|
363
|
+
decision: "deny",
|
|
364
|
+
by,
|
|
365
|
+
rule,
|
|
366
|
+
reason,
|
|
367
|
+
});
|
|
368
|
+
/** A string field of a validated tool input, or "" (never another type). */
|
|
369
|
+
const textField = (input, field) => {
|
|
370
|
+
const v = input?.[field];
|
|
371
|
+
return typeof v === "string" ? v : "";
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* The binding of an automatic decision (R2): the first 16 hex chars of the sha256 of the policy
|
|
375
|
+
* key, the definition and the raw input, as an approval binds them.
|
|
376
|
+
*/
|
|
377
|
+
const askBindingHash = (policyKey, specHash, rawInput) => sha256Hex(canonicalJson([policyKey, specHash, rawInput ?? {}])).slice(0, 16);
|
|
378
|
+
/** The profile step's outcome from a recorded automatic decision. */
|
|
379
|
+
const askDecisionOf = (event) => {
|
|
380
|
+
const p = event.payload;
|
|
381
|
+
return p.outcome === "deny"
|
|
382
|
+
? { kind: "deny", reason: p.reason }
|
|
383
|
+
: {
|
|
384
|
+
kind: "allow",
|
|
385
|
+
decision: {
|
|
386
|
+
source: p.decisionSource,
|
|
387
|
+
revision: p.profileRevision,
|
|
388
|
+
seq: event.seq,
|
|
389
|
+
...(p.fileSha256 !== undefined && { fileSha256: p.fileSha256 }),
|
|
390
|
+
},
|
|
391
|
+
};
|
|
392
|
+
};
|
|
111
393
|
const approvalAuthorization = (a) => ({
|
|
112
394
|
approvalId: a.id,
|
|
113
395
|
approvedByAccountId: a.decidedBy,
|
|
@@ -124,6 +406,56 @@ const idem = {
|
|
|
124
406
|
connection: (runId, callId) => `connection_required:${runId}:${callId}`,
|
|
125
407
|
hookDenied: (runId, callId) => `hook_denied:${runId}:${callId}`,
|
|
126
408
|
};
|
|
409
|
+
/**
|
|
410
|
+
* `ToolCallContext.idempotencyKey`: one logical call's key (a call id is unique only within its
|
|
411
|
+
* run), the same for every `InputRequired` round of the call.
|
|
412
|
+
*/
|
|
413
|
+
/**
|
|
414
|
+
* The SDK context fields of an extension tool's call (memory plugin spec §6.2: `accountId` stays
|
|
415
|
+
* the trigger account), shared by the pipeline's handler call and a watched wait's watcher call
|
|
416
|
+
* (browser long waits spec §5.3), so a watcher sees the call exactly as its handler did.
|
|
417
|
+
*/
|
|
418
|
+
export function extensionCallContext(f) {
|
|
419
|
+
return {
|
|
420
|
+
orgId: f.orgId,
|
|
421
|
+
accountId: f.accountId,
|
|
422
|
+
agentId: f.agentId,
|
|
423
|
+
conversationId: f.conversationId,
|
|
424
|
+
rootConversationId: f.rootConversationId,
|
|
425
|
+
callId: f.callId,
|
|
426
|
+
idempotencyKey: toolIdempotencyKey(f.conversationId, f.runId, f.callId),
|
|
427
|
+
source: f.source,
|
|
428
|
+
ownerAccountId: f.ownerAccountId,
|
|
429
|
+
role: f.role,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* The pre-call gate of an extension tool's call, one function for the pipeline's handler call and
|
|
434
|
+
* a watched wait's watcher call (browser long waits spec §5.3, R17): the org's single-tool switch
|
|
435
|
+
* not off, the extension loaded on this replica and its effective config for the org valid
|
|
436
|
+
* (`needsConfig` otherwise), and with `checkEnabled` the extension enabled in the org (the
|
|
437
|
+
* pipeline's step already resolved its tools with the org's enablement).
|
|
438
|
+
*/
|
|
439
|
+
export async function extensionCallGate(deps, orgId, toolKey, source, opts = {}) {
|
|
440
|
+
if (opts.checkEnabled !== undefined && !(await opts.checkEnabled(orgId, source.plugin)))
|
|
441
|
+
return { ok: false, message: PLUGIN_UNLOADED_TOOL_ERROR, transient: false };
|
|
442
|
+
// turned off in the org since the step resolved its tools (spec A §7)
|
|
443
|
+
if (await deps.switches.isToolOff(orgId, source.plugin, source.name))
|
|
444
|
+
return { ok: false, message: `${toolTurnedOffReason(toolKey)}.`, transient: false };
|
|
445
|
+
const effective = await deps.effective.get(orgId, source.plugin);
|
|
446
|
+
if (!effective.ok) {
|
|
447
|
+
// unloaded or disabled since the step resolved its tools: the documented unloaded error
|
|
448
|
+
if (effective.notRunning)
|
|
449
|
+
return { ok: false, message: PLUGIN_UNLOADED_TOOL_ERROR, transient: true };
|
|
450
|
+
return {
|
|
451
|
+
ok: false,
|
|
452
|
+
message: unavailableText(toolKey, NEEDS_CONFIG_REASON),
|
|
453
|
+
transient: false,
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
return { ok: true, config: effective.config };
|
|
457
|
+
}
|
|
458
|
+
export const toolIdempotencyKey = (conversationId, runId, callId) => sha256Hex(`capybara:tool-call:${conversationId}:${runId}:${callId}`);
|
|
127
459
|
/** 同一调用最多连续请求用户输入的次数。 */
|
|
128
460
|
const MAX_INPUT_ROUNDS = 3;
|
|
129
461
|
/** 输入请求 state 的上限(JSON 序列化后的字节数)。 */
|
|
@@ -142,6 +474,11 @@ function loadedFrom(result, tools) {
|
|
|
142
474
|
const known = new Set(tools.filter((t) => !isAlwaysLoaded(t.key)).map((t) => t.key));
|
|
143
475
|
return [...new Set(raw.filter((k) => typeof k === "string" && known.has(k)))];
|
|
144
476
|
}
|
|
477
|
+
/** A builtin result's `media` (see `BuiltinResult`): a non-empty array, else nothing. */
|
|
478
|
+
function mediaFrom(result) {
|
|
479
|
+
const raw = result?.media;
|
|
480
|
+
return Array.isArray(raw) && raw.length > 0 ? raw : undefined;
|
|
481
|
+
}
|
|
145
482
|
class Stopped extends Error {
|
|
146
483
|
}
|
|
147
484
|
/** 在工具结果末尾附上说明(如被拒绝的 elicitation);结果不是 `{ content: [] }` 形状时原样返回。 */
|
|
@@ -156,6 +493,229 @@ function withNotes(result, notes) {
|
|
|
156
493
|
content: [...content, ...notes.map((text) => ({ type: "text", text }))],
|
|
157
494
|
};
|
|
158
495
|
}
|
|
496
|
+
/** A network ask's kept display fields, written with its result when the ask settles. */
|
|
497
|
+
export const keptExtras = (kept) => ({
|
|
498
|
+
...(kept?.outputId !== undefined && { outputId: kept.outputId }),
|
|
499
|
+
...(kept?.contentTypes !== undefined && { contentTypes: kept.contentTypes }),
|
|
500
|
+
...(kept?.display !== undefined && { display: kept.display }),
|
|
501
|
+
...(kept?.view !== undefined && { view: kept.view }),
|
|
502
|
+
...(kept?.media !== undefined && { media: kept.media }),
|
|
503
|
+
});
|
|
504
|
+
function withBlocked(outcome, scope) {
|
|
505
|
+
if (outcome.kind === "connection_required")
|
|
506
|
+
return outcome;
|
|
507
|
+
const blocked = scope?.blocked;
|
|
508
|
+
const review = scope?.review ?? null;
|
|
509
|
+
return {
|
|
510
|
+
...outcome,
|
|
511
|
+
...(blocked != null &&
|
|
512
|
+
blocked.hosts.size > 0 && {
|
|
513
|
+
blocked: {
|
|
514
|
+
deviceId: blocked.deviceId,
|
|
515
|
+
hosts: [...blocked.hosts].map(([host, layer]) => ({ host, layer })),
|
|
516
|
+
url: blocked.url,
|
|
517
|
+
...(blocked.loopback !== null && { loopback: { ...blocked.loopback } }),
|
|
518
|
+
},
|
|
519
|
+
}),
|
|
520
|
+
// a device service launch's review (ctx.deviceAccess), recorded with the call's result
|
|
521
|
+
...(review !== null && { review }),
|
|
522
|
+
...((outcome.kind === "result" || outcome.kind === "error") &&
|
|
523
|
+
scope?.siteAccess != null && { siteAccess: scope.siteAccess }),
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* What a call's earlier input rounds carried for its result ({@link QuestionCarried}): the latest
|
|
528
|
+
* launch review, and every refused host (the latest device and page) in one report.
|
|
529
|
+
*/
|
|
530
|
+
function carriedOf(rounds) {
|
|
531
|
+
let review;
|
|
532
|
+
let blocked;
|
|
533
|
+
for (const r of rounds) {
|
|
534
|
+
if (r.carried?.review !== undefined)
|
|
535
|
+
review = r.carried.review;
|
|
536
|
+
const b = r.carried?.blocked;
|
|
537
|
+
if (b !== undefined)
|
|
538
|
+
blocked = mergeBlocked(blocked, b);
|
|
539
|
+
}
|
|
540
|
+
return {
|
|
541
|
+
...(review !== undefined && { review }),
|
|
542
|
+
...(blocked !== undefined && { blocked }),
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Two refused-host reports of one call as one: the hosts of both (a host in both keeps the more
|
|
547
|
+
* restrictive layer), the later device and page. A malformed host entry (a record written by
|
|
548
|
+
* another kernel version) is dropped.
|
|
549
|
+
*/
|
|
550
|
+
function mergeBlocked(a, b) {
|
|
551
|
+
const loopback = validLoopback(b.loopback) ?? validLoopback(a?.loopback);
|
|
552
|
+
return {
|
|
553
|
+
deviceId: b.deviceId ?? a?.deviceId ?? null,
|
|
554
|
+
hosts: mergeServiceHosts(validServiceHosts(a?.hosts), validServiceHosts(b.hosts)),
|
|
555
|
+
url: b.url ?? a?.url ?? null,
|
|
556
|
+
...(loopback !== undefined && { loopback }),
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
/** A well-formed loopback refusal ({@link ServiceBlocked.loopback}); a malformed one is dropped. */
|
|
560
|
+
function validLoopback(l) {
|
|
561
|
+
const v = l;
|
|
562
|
+
return v != null &&
|
|
563
|
+
typeof v.serviceId === "string" &&
|
|
564
|
+
typeof v.host === "string" &&
|
|
565
|
+
Number.isInteger(v.port) &&
|
|
566
|
+
v.port >= 1 &&
|
|
567
|
+
v.port <= 65535
|
|
568
|
+
? { serviceId: v.serviceId, host: v.host, port: v.port }
|
|
569
|
+
: undefined;
|
|
570
|
+
}
|
|
571
|
+
/** The well-formed entries of a refused-host list ({@link ServiceBlocked.hosts}). */
|
|
572
|
+
function validServiceHosts(hosts) {
|
|
573
|
+
if (!Array.isArray(hosts))
|
|
574
|
+
return [];
|
|
575
|
+
return hosts.filter((h) => typeof h === "object" &&
|
|
576
|
+
h !== null &&
|
|
577
|
+
typeof h.host === "string" &&
|
|
578
|
+
h.host !== "" &&
|
|
579
|
+
["device", "org", "address", "unknown"].includes(h.layer));
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* The outcome with what earlier input rounds carried: their launch review when this round
|
|
583
|
+
* reviewed none, their refused hosts merged before this round's.
|
|
584
|
+
*/
|
|
585
|
+
function withCarried(outcome, carried) {
|
|
586
|
+
if (outcome.kind === "connection_required")
|
|
587
|
+
return outcome;
|
|
588
|
+
if (carried.review === undefined && carried.blocked === undefined)
|
|
589
|
+
return outcome;
|
|
590
|
+
const blocked = carried.blocked === undefined
|
|
591
|
+
? outcome.blocked
|
|
592
|
+
: outcome.blocked === undefined
|
|
593
|
+
? carried.blocked
|
|
594
|
+
: mergeBlocked(carried.blocked, outcome.blocked);
|
|
595
|
+
const review = outcome.review ?? carried.review;
|
|
596
|
+
return {
|
|
597
|
+
...outcome,
|
|
598
|
+
...(blocked !== undefined && { blocked }),
|
|
599
|
+
...(review !== undefined && { review }),
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* The attempt of a device service's call whose network ask was approved (the person added its
|
|
604
|
+
* hosts to the device's list, browser use spec §7.1) with hosts in force from the next command:
|
|
605
|
+
* the call runs again in the next attempt. Null for any other ask, or none.
|
|
606
|
+
*/
|
|
607
|
+
function serviceRerunAfter(ask) {
|
|
608
|
+
const d = ask?.detail;
|
|
609
|
+
if (ask?.status !== "approved" || ask.scope !== "always" || d?.kind !== "service")
|
|
610
|
+
return null;
|
|
611
|
+
// hosts that apply only at the device's next use or after a files reset are not in force for
|
|
612
|
+
// a re-run now: the kept result is written with the outcome's note instead, as for a command
|
|
613
|
+
if (d.appliesAt !== "next-command")
|
|
614
|
+
return null;
|
|
615
|
+
return d.attempt;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* The attempt of an approved loopback port ask: the call runs again after it whatever became of
|
|
619
|
+
* the grant (the approval is the person's decision; a grant the panel made first, or one that
|
|
620
|
+
* ended since, leaves the re-run to meet the port as it is and report it).
|
|
621
|
+
*/
|
|
622
|
+
function loopbackAskRerunAfter(ask) {
|
|
623
|
+
const d = ask?.detail;
|
|
624
|
+
return ask?.status === "approved" && d?.kind === "loopback" ? d.attempt : null;
|
|
625
|
+
}
|
|
626
|
+
function approvedSiteAsk(ask) {
|
|
627
|
+
const detail = ask?.detail;
|
|
628
|
+
if (ask?.status !== "approved" || detail?.kind !== "site")
|
|
629
|
+
return null;
|
|
630
|
+
return {
|
|
631
|
+
attempt: detail.attempt,
|
|
632
|
+
toolSpecHash: detail.toolSpecHash,
|
|
633
|
+
callInputHash: detail.callInputHash,
|
|
634
|
+
deviceId: detail.deviceId,
|
|
635
|
+
approval: {
|
|
636
|
+
action: detail.action,
|
|
637
|
+
origin: detail.origin,
|
|
638
|
+
detailSha256: siteAccessDetailHash(detail.detail),
|
|
639
|
+
source: "human",
|
|
640
|
+
},
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
const siteReviewIdemKey = (runId, callId) => `permission_reviewed:site_access:${runId}:${callId}`;
|
|
644
|
+
/**
|
|
645
|
+
* Every attempt after which the call ran again: a device service's approved network ask
|
|
646
|
+
* ({@link serviceRerunAfter}), an approved loopback port ask ({@link loopbackAskRerunAfter}), or
|
|
647
|
+
* the call's live loopback port grant (Full access or the review model granted the port to the
|
|
648
|
+
* attempt that was refused it).
|
|
649
|
+
*/
|
|
650
|
+
/** The idempotency key of the `permission_reviewed` event tying a ready-grant rerun to a call. */
|
|
651
|
+
const loopbackReadyRerunIdemKey = (runId, callId) => `permission_reviewed:loopback_ready:${runId}:${callId}`;
|
|
652
|
+
function rerunPoints(ask, grant, readyRerun = null, site = null) {
|
|
653
|
+
const points = [
|
|
654
|
+
serviceRerunAfter(ask),
|
|
655
|
+
loopbackAskRerunAfter(ask),
|
|
656
|
+
grant?.attempt ?? null,
|
|
657
|
+
readyRerun,
|
|
658
|
+
site?.attempt ?? null,
|
|
659
|
+
];
|
|
660
|
+
return new Set(points.filter((p) => p !== null));
|
|
661
|
+
}
|
|
662
|
+
/** An ask whose approval runs the call again: it belongs to the attempt that asked. */
|
|
663
|
+
const asksPerAttempt = (ask) => ask.detail?.kind === "service" || ask.detail?.kind === "loopback" || ask.detail?.kind === "site";
|
|
664
|
+
/** A builtin result's kernel-internal network report (see `BuiltinResult.networkReport`). */
|
|
665
|
+
function networkReportOf(result) {
|
|
666
|
+
const r = result?.networkReport;
|
|
667
|
+
if (r === undefined || typeof r.deviceId !== "string" || !Array.isArray(r.blocked)) {
|
|
668
|
+
return undefined;
|
|
669
|
+
}
|
|
670
|
+
const blocked = r.blocked.filter((b) => typeof b === "object" &&
|
|
671
|
+
b !== null &&
|
|
672
|
+
typeof b.host === "string" &&
|
|
673
|
+
typeof b.port === "number" &&
|
|
674
|
+
["device", "org", "address", "unknown"].includes(b.layer));
|
|
675
|
+
return blocked.length === 0 ? undefined : { deviceId: r.deviceId, blocked };
|
|
676
|
+
}
|
|
677
|
+
/** A builtin result's kernel-internal sandbox denial line (`BuiltinResult.networkReport.denialHint`). */
|
|
678
|
+
function denialHintOf(result) {
|
|
679
|
+
const h = result?.networkReport
|
|
680
|
+
?.denialHint;
|
|
681
|
+
if (h === undefined || typeof h.full !== "string" || typeof h.afterAddressFact !== "string") {
|
|
682
|
+
return undefined;
|
|
683
|
+
}
|
|
684
|
+
return { full: h.full, afterAddressFact: h.afterAddressFact };
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* A kernel-internal device code (see `BuiltinResult.loginCode` and `KeptToolResult.loginCode`):
|
|
688
|
+
* the shape is checked again here so a malformed value never reaches the log (the event schema
|
|
689
|
+
* would throw).
|
|
690
|
+
*/
|
|
691
|
+
function validLoginCode(v) {
|
|
692
|
+
const r = v;
|
|
693
|
+
if (r == null ||
|
|
694
|
+
typeof r.url !== "string" ||
|
|
695
|
+
typeof r.code !== "string" ||
|
|
696
|
+
r.url !== GITHUB_DEVICE_LOGIN_URL ||
|
|
697
|
+
!DEVICE_CODE_PATTERN.test(r.code)) {
|
|
698
|
+
return undefined;
|
|
699
|
+
}
|
|
700
|
+
return { url: r.url, code: r.code };
|
|
701
|
+
}
|
|
702
|
+
/** A builtin result's kernel-internal device code (`{ loginCode: { url, code } }`). */
|
|
703
|
+
function loginCodeOf(result) {
|
|
704
|
+
return validLoginCode(result?.loginCode);
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* The display-only `device_code` event of the call whose output carried the code (auto mode spec
|
|
708
|
+
* §6, P-D13). The key is per (run, call), so a retry of that call appends it once; a different
|
|
709
|
+
* call with the same code is deduplicated by value (`EventLog.deviceCodeShown`).
|
|
710
|
+
*/
|
|
711
|
+
function deviceCodeEvent(runId, step, callId, code) {
|
|
712
|
+
return {
|
|
713
|
+
type: "device_code",
|
|
714
|
+
runId,
|
|
715
|
+
idemKey: deviceCodeIdemKey(runId, callId),
|
|
716
|
+
payload: { step, callId, ...code },
|
|
717
|
+
};
|
|
718
|
+
}
|
|
159
719
|
/** 审批的等待时长(小时,四舍五入,至少 1)。 */
|
|
160
720
|
const approvalHours = (a) => Math.max(1, Math.round((new Date(a.expiresAt).getTime() - new Date(a.createdAt).getTime()) / 3_600_000));
|
|
161
721
|
const approvalWait = (a) => ({
|
|
@@ -178,6 +738,18 @@ const inputWait = (q) => ({
|
|
|
178
738
|
let ToolPipeline = class ToolPipeline {
|
|
179
739
|
config;
|
|
180
740
|
txHost;
|
|
741
|
+
permissionAuthority;
|
|
742
|
+
permissionGrants;
|
|
743
|
+
autoGrants;
|
|
744
|
+
permissionLocks;
|
|
745
|
+
sandboxes;
|
|
746
|
+
approvalProfile;
|
|
747
|
+
toolReview;
|
|
748
|
+
resultImages;
|
|
749
|
+
loopbackGrants;
|
|
750
|
+
permissionFacts;
|
|
751
|
+
siteGrants;
|
|
752
|
+
extensions;
|
|
181
753
|
decide;
|
|
182
754
|
deps;
|
|
183
755
|
constructor(kdb, eventLog,
|
|
@@ -186,10 +758,53 @@ let ToolPipeline = class ToolPipeline {
|
|
|
186
758
|
/** The message tools between agents; absent (tests): their calls are refused. */
|
|
187
759
|
messages, registry, credentials, breaker, outputs, approvals, questions, config, log,
|
|
188
760
|
/** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
|
|
189
|
-
host, drift, effective, switches, txHost, hooks
|
|
761
|
+
host, drift, effective, switches, txHost, hooks, networkGrants,
|
|
762
|
+
/** The command review (auto mode spec §5.4); absent in hand-built pipelines. */
|
|
763
|
+
review,
|
|
764
|
+
/** The reviewed call's device facts; absent in hand-built pipelines. */
|
|
765
|
+
devices, permissionAuthority, permissionGrants,
|
|
766
|
+
/** Full access auto-grants, recorded exactly once (absent in hand-built pipelines). */
|
|
767
|
+
autoGrants, permissionLocks,
|
|
768
|
+
/** Starts a cloud device before its first managed call is reviewed (absent: never). */
|
|
769
|
+
sandboxes,
|
|
770
|
+
/**
|
|
771
|
+
* The profile of an ask addressed to the conversation's person (profiles govern every
|
|
772
|
+
* approval, R1); absent with {@link toolReview} (hand-built pipelines): every ask asks.
|
|
773
|
+
*/
|
|
774
|
+
approvalProfile,
|
|
775
|
+
/** The review model's judgment of an ask under Approve for me (R3); absent: every ask asks. */
|
|
776
|
+
toolReview,
|
|
777
|
+
/**
|
|
778
|
+
* Stores the images a tool result carries as `read` copies of the calling conversation (tool
|
|
779
|
+
* result images design §2); absent (hand-built pipelines): images are named as not stored.
|
|
780
|
+
*/
|
|
781
|
+
resultImages,
|
|
782
|
+
/**
|
|
783
|
+
* A device service's loopback port grants (browser loopback port grants); absent (hand-built
|
|
784
|
+
* pipelines): a loopback refusal keeps the address note.
|
|
785
|
+
*/
|
|
786
|
+
loopbackGrants,
|
|
787
|
+
/** The device's sandbox and its provider's support a loopback grant is checked against. */
|
|
788
|
+
permissionFacts, siteGrants, extensions) {
|
|
190
789
|
this.config = config;
|
|
191
790
|
this.txHost = txHost;
|
|
791
|
+
this.permissionAuthority = permissionAuthority;
|
|
792
|
+
this.permissionGrants = permissionGrants;
|
|
793
|
+
this.autoGrants = autoGrants;
|
|
794
|
+
this.permissionLocks = permissionLocks;
|
|
795
|
+
this.sandboxes = sandboxes;
|
|
796
|
+
this.approvalProfile = approvalProfile;
|
|
797
|
+
this.toolReview = toolReview;
|
|
798
|
+
this.resultImages = resultImages;
|
|
799
|
+
this.loopbackGrants = loopbackGrants;
|
|
800
|
+
this.permissionFacts = permissionFacts;
|
|
801
|
+
this.siteGrants = siteGrants;
|
|
802
|
+
this.extensions = extensions;
|
|
192
803
|
this.deps = {
|
|
804
|
+
// the builtins that enter a device on the managed operation route (common.ts
|
|
805
|
+
// `inToolSandbox`, `inSandboxPreparation`): their review is the permission review, whose
|
|
806
|
+
// approvals issue the exact call grants admission reads
|
|
807
|
+
permissionOperations: MANAGED_OPERATION_TOOLS,
|
|
193
808
|
get db() {
|
|
194
809
|
return kdb.db;
|
|
195
810
|
},
|
|
@@ -208,8 +823,10 @@ let ToolPipeline = class ToolPipeline {
|
|
|
208
823
|
effective,
|
|
209
824
|
switches,
|
|
210
825
|
inlineViews: (plugin) => new Set((host?.current(plugin)?.ui ?? [])
|
|
211
|
-
.filter((r) => r.slot.id === "conversation.tool-result.card"
|
|
212
|
-
r.contribution.
|
|
826
|
+
.filter((r) => r.slot.id === "conversation.tool-result.card")
|
|
827
|
+
.map((r) => r.contribution.id)),
|
|
828
|
+
panels: (plugin) => new Set((host?.current(plugin)?.ui ?? [])
|
|
829
|
+
.filter((r) => r.slot.id === "conversation.panel")
|
|
213
830
|
.map((r) => r.contribution.id)),
|
|
214
831
|
onToolsChanged: (orgId, connectorId) => {
|
|
215
832
|
void drift?.onToolsChanged(orgId, connectorId);
|
|
@@ -218,6 +835,14 @@ let ToolPipeline = class ToolPipeline {
|
|
|
218
835
|
return subagents ? { dispatch: (a) => subagents.dispatch(a) } : undefined;
|
|
219
836
|
},
|
|
220
837
|
messages,
|
|
838
|
+
review,
|
|
839
|
+
devices,
|
|
840
|
+
network: networkGrants
|
|
841
|
+
? {
|
|
842
|
+
grants: networkGrants,
|
|
843
|
+
...(this.sandboxes !== undefined && { sandbox: this.sandboxes }),
|
|
844
|
+
}
|
|
845
|
+
: undefined,
|
|
221
846
|
};
|
|
222
847
|
const decide = hooks?.decidePolicy;
|
|
223
848
|
// the default policy reads live, on the context's handle
|
|
@@ -230,12 +855,21 @@ let ToolPipeline = class ToolPipeline {
|
|
|
230
855
|
* 某个调用需要等人处理(审批 / 用户输入)→ 返回 `suspended`,之后的调用留到续跑时处理;
|
|
231
856
|
* 续跑时重新进入本函数,按 PG 里的审批 / 输入请求结果继续。
|
|
232
857
|
*/
|
|
233
|
-
async runStep(
|
|
858
|
+
async runStep(given) {
|
|
859
|
+
let ctx = given;
|
|
234
860
|
const { eventLog } = this.deps;
|
|
235
861
|
const msg = await eventLog.findByIdem(ctx.conversationId, assistantIdemKey(ctx.runId, ctx.step));
|
|
236
862
|
if (msg?.type !== "assistant_message")
|
|
237
863
|
return { kind: "done" };
|
|
238
864
|
const calls = msg.payload.content.flatMap((b) => b.type === "tool_call" ? [{ id: b.id, name: b.name, input: b.input }] : []);
|
|
865
|
+
// scheduled tasks spec §7: read live for each step (a person's message absorbed since makes the
|
|
866
|
+
// rest of the run attended)
|
|
867
|
+
if (calls.length > 0 && ctx.unattended === undefined) {
|
|
868
|
+
ctx = {
|
|
869
|
+
...ctx,
|
|
870
|
+
unattended: await unattendedRunOf(this.deps.db, this.config, ctx.orgId, ctx.runId),
|
|
871
|
+
};
|
|
872
|
+
}
|
|
239
873
|
let resolved;
|
|
240
874
|
const resolve = async () => {
|
|
241
875
|
// 每步实时解析(连接器 / 插件状态可能在模型调用之后变化)
|
|
@@ -252,6 +886,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
252
886
|
forkChild: ctx.parent?.forSkill === true,
|
|
253
887
|
sandboxConversationId: ctx.parent?.rootConversationId ?? ctx.conversationId,
|
|
254
888
|
replay: ctx.conversationKind === "eval",
|
|
889
|
+
source: ctx.source,
|
|
255
890
|
});
|
|
256
891
|
}
|
|
257
892
|
return resolved;
|
|
@@ -269,7 +904,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
269
904
|
}
|
|
270
905
|
/**
|
|
271
906
|
* Writes, in the caller's transaction (`mandatory`), what a run that is being stopped (a person,
|
|
272
|
-
* its deadline, a failure,
|
|
907
|
+
* its deadline, a failure, an orphan repair) still owes its log: the report of its fork invocation
|
|
273
908
|
* (phase D, `pairStoppedForks`; a still active fork child is stopped by the caller after its
|
|
274
909
|
* commit). An `Agent` call has its result from its dispatch (agent map spec §4.1), so there is
|
|
275
910
|
* nothing to write for it. Returns the fork's call id (the caller must not write a "not executed"
|
|
@@ -289,24 +924,143 @@ let ToolPipeline = class ToolPipeline {
|
|
|
289
924
|
const last = rounds.at(-1);
|
|
290
925
|
if (last?.status === "pending")
|
|
291
926
|
return inputWait(last);
|
|
292
|
-
|
|
293
|
-
|
|
927
|
+
// skipped by the starter's message: the kernel writes the result, the tool is not called again
|
|
928
|
+
// (spec D6: an extension would only see `answer: null`, an MCP call would be re-sent)
|
|
929
|
+
if (last?.status === "skipped") {
|
|
930
|
+
await this.writeResult(ctx, call.id, last.toolKey, skippedResult(last.toolKey, last.watch === true));
|
|
931
|
+
return undefined;
|
|
932
|
+
}
|
|
933
|
+
// a cancelled round is cancelled only by its run's stop, which writes the stopped result
|
|
934
|
+
// itself: it never resumes (browser long waits spec §5.1, R24)
|
|
935
|
+
if (last?.status === "cancelled") {
|
|
936
|
+
this.deps.log.error("a cancelled input round reached a resume; writing the stopped result", {
|
|
937
|
+
runId: ctx.runId,
|
|
938
|
+
callId: call.id,
|
|
939
|
+
questionId: last.id,
|
|
940
|
+
});
|
|
941
|
+
await this.writeResult(ctx, call.id, last.toolKey, {
|
|
942
|
+
content: INPUT_CANCELLED_TEXT,
|
|
943
|
+
isError: true,
|
|
944
|
+
});
|
|
945
|
+
return undefined;
|
|
946
|
+
}
|
|
947
|
+
// the call's network ask (one per call) and its live loopback port grant
|
|
948
|
+
const ask = await this.deps.approvals.networkForCall(ctx.runId, call.id);
|
|
949
|
+
const grant = await this.loopbackGrantOf(ctx.runId, call.id);
|
|
950
|
+
const readyRerun = await this.readyLoopbackRerunOf(ctx.conversationId, ctx.runId, call.id);
|
|
951
|
+
const site = approvedSiteAsk(ask) ?? (await this.siteRerunOf(ctx, call.id));
|
|
952
|
+
let attempt = rounds.length + 1;
|
|
953
|
+
// each time the call ran again (after its network ask, browser use spec §7.1, or a loopback
|
|
954
|
+
// grant or ask) took one attempt more: input rounds asked after a re-run come after it, so
|
|
955
|
+
// every re-run point the count has passed adds one, in order
|
|
956
|
+
const reruns = rerunPoints(ask, grant, readyRerun, site);
|
|
957
|
+
if (rounds.length > 0) {
|
|
958
|
+
for (const p of [...reruns].sort((a, b) => a - b))
|
|
959
|
+
if (attempt > p)
|
|
960
|
+
attempt += 1;
|
|
961
|
+
}
|
|
962
|
+
const resume = last
|
|
963
|
+
? {
|
|
964
|
+
state: last.state,
|
|
965
|
+
answer: last.status === "answered" ? last.answer : null,
|
|
966
|
+
outcome: last.status === "answered" ? "answered" : last.status === "woken" ? "woken" : "expired",
|
|
967
|
+
}
|
|
968
|
+
: undefined;
|
|
969
|
+
let started = await this.deps.eventLog.findByIdem(ctx.conversationId, idem.started(ctx.runId, call.id, attempt));
|
|
970
|
+
// a call that ran again (after a loopback grant or an approved ask) is looked at in its latest
|
|
971
|
+
// attempt: a re-run that asked a network ask of its own resumes from that ask
|
|
972
|
+
while (started?.type === "tool_call_started" && reruns.has(attempt)) {
|
|
973
|
+
const next = await this.deps.eventLog.findByIdem(ctx.conversationId, idem.started(ctx.runId, call.id, attempt + 1));
|
|
974
|
+
if (next?.type !== "tool_call_started")
|
|
975
|
+
break;
|
|
976
|
+
attempt += 1;
|
|
977
|
+
started = next;
|
|
978
|
+
}
|
|
294
979
|
if (started?.type === "tool_call_started") {
|
|
980
|
+
// a command that ran and was refused a network host waits for the device owner (network
|
|
981
|
+
// ask-to-allow spec §6.2, P-D2): pending → wait on; settled → its kept result and the
|
|
982
|
+
// outcome's note (the command is never run again; its tool.called was audited when it ran).
|
|
983
|
+
// A device service's ask (browser use spec §7.1) belongs to the attempt that asked; once
|
|
984
|
+
// the person added its hosts to the device's list the call runs again in the next attempt
|
|
985
|
+
// A loopback port ask (browser loopback port grants) too; a port that Full access or the
|
|
986
|
+
// review model granted to this attempt has no ask: its grant row names the attempt, so the
|
|
987
|
+
// call runs again in the next one, also after a crash between the grant and the re-run
|
|
988
|
+
const askedHere = ask !== null &&
|
|
989
|
+
(!asksPerAttempt(ask) ||
|
|
990
|
+
ask.detail?.attempt === attempt);
|
|
991
|
+
const grantedHere = !askedHere && grant !== null && grant.attempt === attempt;
|
|
992
|
+
const readyRerunHere = !askedHere && !grantedHere && readyRerun === attempt;
|
|
993
|
+
const siteRerunHere = site !== null && site.attempt === attempt;
|
|
994
|
+
if (askedHere || grantedHere || readyRerunHere || siteRerunHere) {
|
|
995
|
+
const notes = askedHere && ask !== null
|
|
996
|
+
? settledNetworkNotes(ask, approvalHours(ask))
|
|
997
|
+
: grantedHere
|
|
998
|
+
? [loopbackGrantedNote(grant.port)]
|
|
999
|
+
: [];
|
|
1000
|
+
if (notes === null)
|
|
1001
|
+
return approvalWait(ask);
|
|
1002
|
+
const rerunsHere = !askedHere ||
|
|
1003
|
+
serviceRerunAfter(ask) !== null ||
|
|
1004
|
+
loopbackAskRerunAfter(ask) !== null ||
|
|
1005
|
+
siteRerunHere ||
|
|
1006
|
+
grant?.attempt === attempt;
|
|
1007
|
+
if (askedHere && ask !== null && !rerunsHere) {
|
|
1008
|
+
const kept = ask.detail?.result;
|
|
1009
|
+
// the device code the command printed is carried in the kept result: write its
|
|
1010
|
+
// display-only event here too (a crash before the ask's first write, or an older kept
|
|
1011
|
+
// result; the event's ids and the per-conversation code check keep it to one)
|
|
1012
|
+
const keptCode = validLoginCode(kept?.loginCode);
|
|
1013
|
+
const pre = keptCode !== undefined &&
|
|
1014
|
+
!(await this.deps.eventLog.deviceCodeShown(ctx.conversationId, keptCode.code))
|
|
1015
|
+
? [deviceCodeEvent(ctx.runId, ctx.step, call.id, keptCode)]
|
|
1016
|
+
: [];
|
|
1017
|
+
await this.writeResult(ctx, call.id, call.name, {
|
|
1018
|
+
...keptExtras(kept),
|
|
1019
|
+
content: withNetworkNotes(kept?.content ?? UNKNOWN_RESULT_TEXT, notes),
|
|
1020
|
+
isError: kept?.isError ?? true,
|
|
1021
|
+
...(kept?.review !== undefined && { review: kept.review }),
|
|
1022
|
+
}, pre);
|
|
1023
|
+
return undefined;
|
|
1024
|
+
}
|
|
1025
|
+
const rerun = await this.deps.eventLog.findByIdem(ctx.conversationId, idem.started(ctx.runId, call.id, attempt + 1));
|
|
1026
|
+
if (rerun?.type !== "tool_call_started") {
|
|
1027
|
+
// the asked hosts are settled: only an earlier round's launch review is carried; a
|
|
1028
|
+
// granted loopback port's note goes with the re-run's result
|
|
1029
|
+
const { review: carriedReview } = carriedOf(rounds);
|
|
1030
|
+
const loopback = !siteRerunHere && (!askedHere || ask?.detail?.kind === "loopback");
|
|
1031
|
+
return this.runCall(ctx, call, await resolve(), attempt + 1, resume, { ...(carriedReview !== undefined && { review: carriedReview }) }, siteRerunHere ? { site } : loopback ? { notes, loopbackRerun: true } : {});
|
|
1032
|
+
}
|
|
1033
|
+
// the re-run started and its result was lost: the result is unknown, as below
|
|
1034
|
+
started = rerun;
|
|
1035
|
+
}
|
|
295
1036
|
// 确实开始执行过:照样审计 tool.called(耗时未知);放行依据只认批准了所执行定义的审批记录
|
|
296
1037
|
const key = started.payload.toolKey;
|
|
297
1038
|
const approval = await this.deps.approvals.forCall(ctx.runId, call.id);
|
|
298
1039
|
const approved = approval?.status === "approved" && approval.specHash === started.payload.specHash
|
|
299
1040
|
? approval
|
|
300
1041
|
: null;
|
|
1042
|
+
// a command that ran under the person's `command` approval: its review record and
|
|
1043
|
+
// authorization survive the lost result too (the ask is the whole truth on a resume)
|
|
1044
|
+
const commandAsk = await this.deps.approvals.commandForCall(ctx.runId, call.id);
|
|
1045
|
+
const command = commandAsk?.status === "approved" ? commandAsk : null;
|
|
1046
|
+
const authorization = approved !== null
|
|
1047
|
+
? approvalAuthorization(approved)
|
|
1048
|
+
: command !== null
|
|
1049
|
+
? approvalAuthorization(command)
|
|
1050
|
+
: null;
|
|
301
1051
|
const source = approved ? null : (await resolve()).tools.find((t) => t.key === key)?.source;
|
|
302
|
-
await this.writeResult(ctx, call.id, key, {
|
|
1052
|
+
await this.writeResult(ctx, call.id, key, {
|
|
1053
|
+
content: UNKNOWN_RESULT_TEXT,
|
|
1054
|
+
isError: true,
|
|
1055
|
+
...(command !== null && { review: this.personAllowRecord(command) }),
|
|
1056
|
+
}, [], {
|
|
303
1057
|
durationMs: null,
|
|
304
1058
|
connectorId: approved
|
|
305
1059
|
? approved.connectorId
|
|
306
1060
|
: source?.kind === "connector"
|
|
307
1061
|
? source.connectorId
|
|
308
1062
|
: null,
|
|
309
|
-
...(
|
|
1063
|
+
...(authorization !== null && { authorization }),
|
|
310
1064
|
});
|
|
311
1065
|
return undefined;
|
|
312
1066
|
}
|
|
@@ -317,31 +1071,34 @@ let ToolPipeline = class ToolPipeline {
|
|
|
317
1071
|
});
|
|
318
1072
|
return undefined;
|
|
319
1073
|
}
|
|
320
|
-
|
|
321
|
-
? { state: last.state, answer: last.status === "answered" ? last.answer : null }
|
|
322
|
-
: undefined;
|
|
323
|
-
return this.runCall(ctx, call, await resolve(), attempt, resume);
|
|
1074
|
+
return this.runCall(ctx, call, await resolve(), attempt, resume, carriedOf(rounds));
|
|
324
1075
|
}
|
|
325
|
-
async runCall(ctx, call, resolved, attempt, resume
|
|
326
|
-
|
|
327
|
-
|
|
1076
|
+
async runCall(ctx, call, resolved, attempt, resume,
|
|
1077
|
+
/** What earlier input rounds of the call collected for its result ({@link carriedOf}). */
|
|
1078
|
+
carried = {},
|
|
1079
|
+
/**
|
|
1080
|
+
* A re-run after a granted loopback port: the notes written after its result, and that it is
|
|
1081
|
+
* the re-run (a port still refused is not asked about again in it).
|
|
1082
|
+
*/
|
|
1083
|
+
rerun = {}) {
|
|
1084
|
+
// the command review's record for this call's result (absent: not reviewed, or no device)
|
|
1085
|
+
let review;
|
|
1086
|
+
const fail = async (content, key = call.name, view) => {
|
|
1087
|
+
await this.writeResult(ctx, call.id, key, {
|
|
1088
|
+
content,
|
|
1089
|
+
isError: true,
|
|
1090
|
+
...(view !== undefined && { view }),
|
|
1091
|
+
...(review !== undefined && { review }),
|
|
1092
|
+
});
|
|
328
1093
|
return undefined;
|
|
329
1094
|
};
|
|
330
|
-
|
|
331
|
-
// A call logged before the tool keys were renamed (spec 8.1): the request that issued it offered
|
|
332
|
-
// the old key. It runs as the current tool with translated input; the result keeps the logged key.
|
|
333
|
-
let legacy = false;
|
|
334
|
-
if (!tool) {
|
|
335
|
-
const next = legacyToolKey(call.name, legacyScopeOf(resolved.tools));
|
|
336
|
-
const current = next === null ? undefined : resolved.tools.find((t) => t.key === next);
|
|
337
|
-
if (current && (await this.requestToolKeys(ctx))?.has(call.name) === true) {
|
|
338
|
-
tool = current;
|
|
339
|
-
legacy = true;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
1095
|
+
const tool = resolved.tools.find((t) => t.key === call.name);
|
|
342
1096
|
if (!tool) {
|
|
1097
|
+
// a hidden `<prefix>__*` ref covers every tool of that source (a disabled or needs_config
|
|
1098
|
+
// connector), so a call of one of them gets the reason, not "unknown tool"
|
|
1099
|
+
const covers = (ref) => ref === call.name || (ref.endsWith("__*") && call.name.startsWith(ref.slice(0, -1)));
|
|
343
1100
|
const why = resolved.unavailable.find((u) => u.ref === call.name) ??
|
|
344
|
-
resolved.hidden?.find((u) => u.ref
|
|
1101
|
+
resolved.hidden?.find((u) => covers(u.ref));
|
|
345
1102
|
if (why)
|
|
346
1103
|
return fail(unavailableText(call.name, why.reason));
|
|
347
1104
|
let keys = resolved.tools.map((t) => t.key);
|
|
@@ -352,20 +1109,22 @@ let ToolPipeline = class ToolPipeline {
|
|
|
352
1109
|
keys = keys.filter((k) => isAlwaysLoaded(k) || sent.has(k));
|
|
353
1110
|
}
|
|
354
1111
|
keys.sort();
|
|
355
|
-
|
|
1112
|
+
// In ToolSearch mode a name the model has not loaded (a catalog tool, or one it misspelled) is
|
|
1113
|
+
// the protocol asking it to search, not a failure: the row reads neutral like `not_loaded`.
|
|
1114
|
+
return fail(unknownToolText(call.name, keys, keys.includes(TOOL_SEARCH)), call.name, resolved.toolSearch === true ? { kind: "not_loaded" } : undefined);
|
|
356
1115
|
}
|
|
357
|
-
const outKey =
|
|
1116
|
+
const outKey = tool.key;
|
|
358
1117
|
// ToolSearch 模式下,模型只能调用请求里带了完整定义的工具:目录里有、但发出本次调用的请求没加载 →
|
|
359
1118
|
// 明确错误,不自动加载(spec 5.5 / 6.3)。同一步里先 ToolSearch 再调用刚加载的工具同样报错。
|
|
360
|
-
|
|
1119
|
+
// This is the protocol working, not a failure: the `not_loaded` view lets the row read neutral.
|
|
1120
|
+
if (resolved.toolSearch === true && !isAlwaysLoaded(tool.key)) {
|
|
361
1121
|
const sent = await this.sentTools(ctx);
|
|
362
1122
|
if (sent !== null && !sent.has(tool.key))
|
|
363
|
-
return fail(notLoadedText(tool.key), outKey);
|
|
1123
|
+
return fail(notLoadedText(tool.key), outKey, { kind: "not_loaded" });
|
|
364
1124
|
}
|
|
365
|
-
const rawInput = legacy ? legacyToolInput(call.name, call.input) : call.input;
|
|
366
1125
|
let input;
|
|
367
1126
|
try {
|
|
368
|
-
input = await resolveOutputRefs(
|
|
1127
|
+
input = await resolveOutputRefs(call.input, (id) => this.deps.outputs.load({ orgId: ctx.orgId, conversationId: ctx.conversationId }, id));
|
|
369
1128
|
}
|
|
370
1129
|
catch (e) {
|
|
371
1130
|
if (e instanceof ToolError)
|
|
@@ -386,8 +1145,10 @@ let ToolPipeline = class ToolPipeline {
|
|
|
386
1145
|
accountId: ctx.accountId,
|
|
387
1146
|
agentId: ctx.agentId,
|
|
388
1147
|
conversationId: ctx.conversationId,
|
|
1148
|
+
rootConversationId: ctx.parent?.rootConversationId ?? ctx.conversationId,
|
|
389
1149
|
runId: ctx.runId,
|
|
390
|
-
|
|
1150
|
+
callId: call.id,
|
|
1151
|
+
rawInput: call.input,
|
|
391
1152
|
signal: ctx.signal,
|
|
392
1153
|
})) ?? null;
|
|
393
1154
|
// a deny with a reason (e.g. an unavailable operation): the reason is the tool error
|
|
@@ -395,7 +1156,20 @@ let ToolPipeline = class ToolPipeline {
|
|
|
395
1156
|
return fail(callPolicy.denyReason, outKey);
|
|
396
1157
|
}
|
|
397
1158
|
const policyKey = callPolicy?.key ?? tool.key;
|
|
398
|
-
|
|
1159
|
+
// person fields (platform web parity spec §4.2; profiles govern every approval R4, R5): the
|
|
1160
|
+
// person types the values in a secure input request, so an unattended run (a trial run has its
|
|
1161
|
+
// creator there) cannot make the call at all
|
|
1162
|
+
const personFields = callPolicy?.personFields;
|
|
1163
|
+
// a call whose result is shown once to the run's person is refused there the same way
|
|
1164
|
+
const personOnly = callPolicy?.personOnly === true;
|
|
1165
|
+
if ((personFields !== undefined || personOnly) && unattendedRules(ctx.unattended)) {
|
|
1166
|
+
return fail(personFields !== undefined
|
|
1167
|
+
? PERSON_FIELDS_UNATTENDED_TEXT
|
|
1168
|
+
: callPolicy?.personDecides === true
|
|
1169
|
+
? PERSON_DECIDES_UNATTENDED_TEXT
|
|
1170
|
+
: PERSON_ONLY_UNATTENDED_TEXT, outKey);
|
|
1171
|
+
}
|
|
1172
|
+
let decision = await this.decide(tool, ctx.agent, {
|
|
399
1173
|
orgId: ctx.orgId,
|
|
400
1174
|
accountId: ctx.accountId,
|
|
401
1175
|
agentId: ctx.agentId,
|
|
@@ -407,28 +1181,85 @@ let ToolPipeline = class ToolPipeline {
|
|
|
407
1181
|
...(ctx.parent.otherAgent !== undefined && { parentAgentDiffers: ctx.parent.otherAgent }),
|
|
408
1182
|
}),
|
|
409
1183
|
callPolicy,
|
|
1184
|
+
...(ctx.unattended != null && { unattended: ctx.unattended }),
|
|
410
1185
|
});
|
|
411
1186
|
if (decision === "deny")
|
|
412
1187
|
return fail(deniedText(tool.key, callPolicy?.key), outKey);
|
|
1188
|
+
if (typeof decision === "object" && "refused" in decision) {
|
|
1189
|
+
if (decision.missingGrant !== undefined && ctx.unattended != null) {
|
|
1190
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, decision.missingGrant);
|
|
1191
|
+
}
|
|
1192
|
+
return fail(decision.refused, outKey);
|
|
1193
|
+
}
|
|
413
1194
|
if (typeof decision === "object" && "unavailable" in decision) {
|
|
414
1195
|
return fail(unavailableText(tool.key, decision.unavailable), outKey);
|
|
415
1196
|
}
|
|
1197
|
+
if (personOnly || personFields !== undefined) {
|
|
1198
|
+
// R6: a call only the person may confirm is always their own ask, never a grant or an
|
|
1199
|
+
// `allow` (the default policy already asks for them; this holds for any decision). Person
|
|
1200
|
+
// fields no longer force the consent (R5): it follows the call's policy, grants and profile
|
|
1201
|
+
if (personOnly && (decision === "allow" || "grant" in decision)) {
|
|
1202
|
+
decision = {
|
|
1203
|
+
ask: {
|
|
1204
|
+
toolKey: policyKey,
|
|
1205
|
+
specHash: tool.specHash,
|
|
1206
|
+
connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
|
|
1207
|
+
requestedFor: ctx.accountId,
|
|
1208
|
+
approverRole: null,
|
|
1209
|
+
policy: "fixed",
|
|
1210
|
+
},
|
|
1211
|
+
};
|
|
1212
|
+
}
|
|
1213
|
+
// R5: only the person the run works for types the values or reads the result; a role
|
|
1214
|
+
// escalation cannot ask them
|
|
1215
|
+
if (typeof decision === "object" && "ask" in decision && decision.ask.requestedFor === null) {
|
|
1216
|
+
return fail(personFields !== undefined ? PERSON_FIELDS_ROLE_TEXT : PERSON_ONLY_ROLE_TEXT, outKey);
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
416
1219
|
// 该调用已有审批(续跑)→ 按审批结果;没有且策略为 ask → 建审批并等待
|
|
417
1220
|
// (不写 tool_call_started:此时尚未开始执行)。
|
|
418
1221
|
let approval = await this.deps.approvals.forCall(ctx.runId, call.id);
|
|
419
1222
|
// 批准的是旧定义(等待期间工具定义变了):原批准不适用于当前定义,策略仍需审批时按新定义重新审批。
|
|
420
|
-
// An in-flight rc call (spec §9) is the exception: its approval was asked under the rc definition
|
|
421
|
-
// of the same call, and the rename changed every builtin's definition; the person approved this
|
|
422
|
-
// very call, so the approval stands.
|
|
423
1223
|
// An approval binds the exact input it showed (Platform tool spec §6.3): an approved record
|
|
424
1224
|
// whose stored input differs from the call's is not used.
|
|
1225
|
+
const liveAsk = typeof decision === "object" && "ask" in decision ? decision.ask : undefined;
|
|
1226
|
+
const orgAskChanged = approval !== null &&
|
|
1227
|
+
(!sameOrgAsk(approval.orgAskRevisions, liveAsk?.orgAskRevisions) ||
|
|
1228
|
+
(liveAsk?.orgAskRevisions !== undefined &&
|
|
1229
|
+
(approval.toolKey !== policyKey ||
|
|
1230
|
+
approval.specHash !== tool.specHash ||
|
|
1231
|
+
approval.requestedFor !== liveAsk.requestedFor ||
|
|
1232
|
+
approval.approverRole !== liveAsk.approverRole ||
|
|
1233
|
+
canonicalJson(approval.input) !== canonicalJson(call.input ?? {}))));
|
|
1234
|
+
const supersedesOrgAsk = orgAskChanged ? approval?.id : undefined;
|
|
1235
|
+
if (orgAskChanged || approval?.status === "superseded")
|
|
1236
|
+
approval = null;
|
|
425
1237
|
const approvedHere = approval?.status === "approved" &&
|
|
426
|
-
|
|
1238
|
+
approval.specHash === tool.specHash &&
|
|
1239
|
+
(liveAsk?.orgAskRevisions === undefined ||
|
|
1240
|
+
(approval.scope === "once" && approval.decidedBy !== null)) &&
|
|
427
1241
|
canonicalJson(approval.input) === canonicalJson(call.input ?? {});
|
|
428
1242
|
const stale = approval?.status === "approved" && !approvedHere;
|
|
1243
|
+
// the profile step (profiles govern every approval, R1-R3): an ask addressed to the person
|
|
1244
|
+
// with no approval governing the call yet is decided by the conversation's profile
|
|
1245
|
+
let auto;
|
|
1246
|
+
let reviewUnsure = false;
|
|
429
1247
|
if ((!approval || stale) && typeof decision === "object" && "ask" in decision) {
|
|
1248
|
+
const step = await this.profileStep(ctx, call, tool, input, decision.ask, callPolicy);
|
|
1249
|
+
if (step.kind === "deny")
|
|
1250
|
+
return fail(toolReviewDeniedText(step.reason), outKey);
|
|
1251
|
+
if (step.kind === "allow")
|
|
1252
|
+
auto = step.decision;
|
|
1253
|
+
else
|
|
1254
|
+
reviewUnsure = step.unsure;
|
|
1255
|
+
}
|
|
1256
|
+
if ((!approval || stale) &&
|
|
1257
|
+
auto === undefined &&
|
|
1258
|
+
typeof decision === "object" &&
|
|
1259
|
+
"ask" in decision) {
|
|
430
1260
|
approval = await this.deps.approvals.request({
|
|
431
|
-
|
|
1261
|
+
// after every earlier request of the call, whatever its kind (attempts share one key)
|
|
1262
|
+
attempt: (await this.lastAttempt(ctx.runId, call.id)) + 1,
|
|
432
1263
|
orgId: ctx.orgId,
|
|
433
1264
|
conversationId: ctx.conversationId,
|
|
434
1265
|
runId: ctx.runId,
|
|
@@ -442,7 +1273,20 @@ let ToolPipeline = class ToolPipeline {
|
|
|
442
1273
|
approverRole: decision.ask.approverRole,
|
|
443
1274
|
policy: decision.ask.policy,
|
|
444
1275
|
...(callPolicy?.summary !== undefined && { summary: callPolicy.summary }),
|
|
445
|
-
...(
|
|
1276
|
+
...(supersedesOrgAsk !== undefined && { supersedesOrgAsk }),
|
|
1277
|
+
...((decision.ask.orgAskRevisions !== undefined ||
|
|
1278
|
+
(callPolicy !== null && !callPolicy.remember)) && { scopes: ["once"] }),
|
|
1279
|
+
...((callPolicy?.file !== undefined ||
|
|
1280
|
+
reviewUnsure ||
|
|
1281
|
+
decision.ask.orgAskRevisions !== undefined) && {
|
|
1282
|
+
detail: {
|
|
1283
|
+
...(callPolicy?.file !== undefined && { file: callPolicy.file }),
|
|
1284
|
+
...(reviewUnsure && { reviewUnsure: true }),
|
|
1285
|
+
...(decision.ask.orgAskRevisions !== undefined && {
|
|
1286
|
+
orgAskRevisions: decision.ask.orgAskRevisions,
|
|
1287
|
+
}),
|
|
1288
|
+
},
|
|
1289
|
+
}),
|
|
446
1290
|
});
|
|
447
1291
|
}
|
|
448
1292
|
if (approval && approval.status !== "approved") {
|
|
@@ -450,16 +1294,52 @@ let ToolPipeline = class ToolPipeline {
|
|
|
450
1294
|
return refused === null ? approvalWait(approval) : fail(refused, outKey);
|
|
451
1295
|
}
|
|
452
1296
|
// 走到这里即放行:在(与当前定义一致的)审批下执行,否则是授权或策略放行
|
|
453
|
-
|
|
1297
|
+
let authorization = approval?.status === "approved" && approvedHere
|
|
454
1298
|
? approvalAuthorization(approval)
|
|
455
|
-
:
|
|
456
|
-
? {
|
|
457
|
-
:
|
|
1299
|
+
: auto !== undefined
|
|
1300
|
+
? { decisionSource: auto.source, profileRevision: auto.revision, decisionSeq: auto.seq }
|
|
1301
|
+
: typeof decision === "object" && "grant" in decision
|
|
1302
|
+
? { grant: decision.grant }
|
|
1303
|
+
: { policy: "allow" };
|
|
1304
|
+
// the secure input (profiles govern every approval, R4): once the call's consent is settled
|
|
1305
|
+
// (approved here, a grant, an allow or the profile's decision), the person enters the call's
|
|
1306
|
+
// secret fields under every profile, before the command review
|
|
1307
|
+
let secureInputId;
|
|
1308
|
+
if (personFields !== undefined) {
|
|
1309
|
+
const secured = await this.secureInput(ctx, call, tool, policyKey, personFields);
|
|
1310
|
+
if (secured.kind === "wait")
|
|
1311
|
+
return secured.wait;
|
|
1312
|
+
if (secured.kind === "refused")
|
|
1313
|
+
return fail(secured.text, outKey);
|
|
1314
|
+
secureInputId = secured.id;
|
|
1315
|
+
}
|
|
1316
|
+
// Auto mode spec §5.1: the command review, after argument validation and the tool policy (and
|
|
1317
|
+
// its approval), before the plugin hooks and `tool_call_started`. A deny ends the call here; an
|
|
1318
|
+
// ask parks the run on the command approval (attended) or is a deny at once (unattended). An
|
|
1319
|
+
// already decided command approval resumes the call without re-reviewing.
|
|
1320
|
+
const reviewed = await this.reviewCall(ctx, call, tool, input);
|
|
1321
|
+
if (reviewed.kind === "wait")
|
|
1322
|
+
return reviewed.wait;
|
|
1323
|
+
if (reviewed.kind === "result") {
|
|
1324
|
+
review = reviewed.review;
|
|
1325
|
+
return fail(reviewed.content, outKey);
|
|
1326
|
+
}
|
|
1327
|
+
review = reviewed.review;
|
|
1328
|
+
const reviewedRoots = {
|
|
1329
|
+
workingRoot: reviewed.workingRoot,
|
|
1330
|
+
against: reviewed.reviewedAgainst,
|
|
1331
|
+
...(reviewed.sandboxEscalation !== undefined && { escalation: reviewed.sandboxEscalation }),
|
|
1332
|
+
...(reviewed.sandboxEscalationRefusal !== undefined && {
|
|
1333
|
+
escalationRefusal: reviewed.sandboxEscalationRefusal,
|
|
1334
|
+
}),
|
|
1335
|
+
};
|
|
1336
|
+
if (reviewed.commandAsk !== undefined)
|
|
1337
|
+
authorization = approvalAuthorization(reviewed.commandAsk);
|
|
458
1338
|
// tool.preExecute after policy and approval, before tool_call_started (F10)
|
|
459
1339
|
const hooks = this.deps.pluginHooks;
|
|
460
1340
|
const scope = hookScope(hooks, ctx);
|
|
461
1341
|
if (scope && hooks?.has("tool.preExecute")) {
|
|
462
|
-
// sticky: a denial already logged for this call (e.g.
|
|
1342
|
+
// sticky: a denial already logged for this call (e.g. a crash right after it)
|
|
463
1343
|
// is final: fail with the recorded reason, never re-run the hooks or execute the tool. Only
|
|
464
1344
|
// looked up when a tool.preExecute hook could run (M-2: no query without hooks); a denial is
|
|
465
1345
|
// written with the call's tool_result, so a call with a logged denial never runs again anyway.
|
|
@@ -505,10 +1385,27 @@ let ToolPipeline = class ToolPipeline {
|
|
|
505
1385
|
step: ctx.step,
|
|
506
1386
|
callId: call.id,
|
|
507
1387
|
});
|
|
508
|
-
await this.writeResult(ctx, call.id, outKey, {
|
|
1388
|
+
await this.writeResult(ctx, call.id, outKey, {
|
|
1389
|
+
content: hookDeniedText(verdict.plugin, verdict.reason),
|
|
1390
|
+
isError: true,
|
|
1391
|
+
...(review !== undefined && { review }),
|
|
1392
|
+
}, [event], undefined, [hookDeniedAudit(site, event.payload, verdict)]);
|
|
509
1393
|
return undefined;
|
|
510
1394
|
}
|
|
511
1395
|
}
|
|
1396
|
+
const admit = (commit) => this.withOrgToolAdmission(ctx, tool, policyKey, call.input, approvedHere ? approval : null, auto, commit);
|
|
1397
|
+
const admissionError = (error) => {
|
|
1398
|
+
if (error instanceof OrgToolDenied || error instanceof OrgToolPolicyChanged)
|
|
1399
|
+
return error;
|
|
1400
|
+
throw error;
|
|
1401
|
+
};
|
|
1402
|
+
const changedPolicy = (error) => {
|
|
1403
|
+
if (error instanceof OrgToolDenied)
|
|
1404
|
+
return fail(deniedText(tool.key, callPolicy?.key), outKey);
|
|
1405
|
+
if (error instanceof OrgToolPolicyChanged)
|
|
1406
|
+
return this.runCall(ctx, call, resolved, attempt, resume, carried, rerun);
|
|
1407
|
+
throw error;
|
|
1408
|
+
};
|
|
512
1409
|
// `Agent` (sub-agents spec §7.1, agent map spec §4.1): no tool_call_started; one transaction
|
|
513
1410
|
// makes the dispatch durable (its marker is the subagent_dispatches row) and writes the call's
|
|
514
1411
|
// immediate result, while the sub-agent runs in the background
|
|
@@ -518,12 +1415,17 @@ let ToolPipeline = class ToolPipeline {
|
|
|
518
1415
|
if (!parsed.success) {
|
|
519
1416
|
return fail("Invalid agent call: pass description and prompt, and optionally subagent_type and model.", outKey);
|
|
520
1417
|
}
|
|
521
|
-
const r = await dispatcher
|
|
1418
|
+
const r = await dispatcher
|
|
1419
|
+
.dispatch({
|
|
522
1420
|
ctx,
|
|
523
1421
|
callId: call.id,
|
|
524
1422
|
input: parsed.data,
|
|
525
1423
|
call: { toolKey: outKey, authorization, startedAt: Date.now() },
|
|
526
|
-
|
|
1424
|
+
admit,
|
|
1425
|
+
})
|
|
1426
|
+
.catch(admissionError);
|
|
1427
|
+
if (r instanceof Error)
|
|
1428
|
+
return changedPolicy(r);
|
|
527
1429
|
if (r.kind === "refused")
|
|
528
1430
|
return fail(r.content, outKey);
|
|
529
1431
|
if (hooks && hookBase) {
|
|
@@ -551,16 +1453,23 @@ let ToolPipeline = class ToolPipeline {
|
|
|
551
1453
|
if (!parsed.success) {
|
|
552
1454
|
return fail("Invalid SendMessage call: pass to and message.", outKey);
|
|
553
1455
|
}
|
|
554
|
-
r = await messenger
|
|
1456
|
+
r = await messenger
|
|
1457
|
+
.toChild(ctx, call.id, parsed.data.to, parsed.data.message, {
|
|
555
1458
|
authorization,
|
|
556
|
-
|
|
1459
|
+
admit,
|
|
1460
|
+
})
|
|
1461
|
+
.catch(admissionError);
|
|
557
1462
|
}
|
|
558
1463
|
else {
|
|
559
1464
|
const parsed = HandbackInput.safeParse(input);
|
|
560
1465
|
if (!parsed.success)
|
|
561
1466
|
return fail("Invalid SubagentHandback call: pass message.", outKey);
|
|
562
|
-
r = await messenger
|
|
1467
|
+
r = await messenger
|
|
1468
|
+
.toParent(ctx, "report", parsed.data.message, call.id, admit)
|
|
1469
|
+
.catch(admissionError);
|
|
563
1470
|
}
|
|
1471
|
+
if (r instanceof Error)
|
|
1472
|
+
return changedPolicy(r);
|
|
564
1473
|
if (r.isError)
|
|
565
1474
|
return fail(r.content, outKey);
|
|
566
1475
|
const durationMs = Date.now() - t0;
|
|
@@ -576,31 +1485,128 @@ let ToolPipeline = class ToolPipeline {
|
|
|
576
1485
|
}
|
|
577
1486
|
return undefined;
|
|
578
1487
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
1488
|
+
if (rerun.site !== undefined &&
|
|
1489
|
+
(rerun.site.toolSpecHash !== tool.specHash ||
|
|
1490
|
+
rerun.site.callInputHash !== permissionScopeHash(call.input) ||
|
|
1491
|
+
!(await this.siteRetryAllowed(ctx, call.id, tool, input, rerun.site)))) {
|
|
1492
|
+
return fail("This site approval is no longer valid. The action did not run.", outKey);
|
|
1493
|
+
}
|
|
1494
|
+
try {
|
|
1495
|
+
await admit(() => this.deps.eventLog.append(ctx.conversationId, [
|
|
1496
|
+
{
|
|
1497
|
+
type: "tool_call_started",
|
|
1498
|
+
runId: ctx.runId,
|
|
1499
|
+
idemKey: idem.started(ctx.runId, call.id, attempt),
|
|
1500
|
+
payload: {
|
|
1501
|
+
step: ctx.step,
|
|
1502
|
+
callId: call.id,
|
|
1503
|
+
toolKey: tool.key,
|
|
1504
|
+
specHash: tool.specHash,
|
|
1505
|
+
...(this.operationScoped(tool, input)
|
|
1506
|
+
? {
|
|
1507
|
+
permissionInput: {
|
|
1508
|
+
callInputHash: permissionScopeHash(call.input),
|
|
1509
|
+
resolvedInputHash: permissionScopeHash(input),
|
|
1510
|
+
...(isEscalatedCall(tool.key, input)
|
|
1511
|
+
? { sandbox: "escalated" }
|
|
1512
|
+
: {}),
|
|
1513
|
+
},
|
|
1514
|
+
}
|
|
1515
|
+
: {}),
|
|
1516
|
+
},
|
|
1517
|
+
},
|
|
1518
|
+
]));
|
|
1519
|
+
}
|
|
1520
|
+
catch (error) {
|
|
1521
|
+
return changedPolicy(error);
|
|
1522
|
+
}
|
|
587
1523
|
const t0 = Date.now();
|
|
588
|
-
let outcome = await this.execute(tool, input, ctx, call.id, resume, resolved.tools
|
|
1524
|
+
let outcome = await this.execute(tool, input, ctx, call.id, resume, resolved.tools, reviewedRoots,
|
|
1525
|
+
// the approval the call runs under (a Platform write reads the person's values by it)
|
|
1526
|
+
approval?.status === "approved" && approvedHere ? approval.id : undefined,
|
|
1527
|
+
// or the automatic decision and the file bytes it was bound to (R7)
|
|
1528
|
+
auto === undefined
|
|
1529
|
+
? undefined
|
|
1530
|
+
: {
|
|
1531
|
+
source: auto.source,
|
|
1532
|
+
...(auto.fileSha256 !== undefined && { fileSha256: auto.fileSha256 }),
|
|
1533
|
+
},
|
|
1534
|
+
// and the submitted secure input holding the person's values
|
|
1535
|
+
secureInputId, rerun.site?.approval);
|
|
589
1536
|
const durationMs = Date.now() - t0;
|
|
590
1537
|
await this.deps.hooks?.afterExecute?.(ctx.runId, call.id);
|
|
1538
|
+
// what earlier input rounds collected: a launch reviewed in a round that asked, the hosts a
|
|
1539
|
+
// service reported refused there (this round, a resume, finds the service running)
|
|
1540
|
+
outcome = withCarried(outcome, carried);
|
|
1541
|
+
// a device service launch's review during the call (ctx.deviceAccess, the call scope)
|
|
1542
|
+
if (review === undefined && outcome.kind !== "connection_required")
|
|
1543
|
+
review = outcome.review;
|
|
1544
|
+
// the record says a call ran outside the sandbox only when admission gave it that scope
|
|
1545
|
+
if (review !== undefined && isEscalatedCall(tool.key, input)) {
|
|
1546
|
+
const { sandbox: _asked, ...rest } = review;
|
|
1547
|
+
review = (await this.admittedOutsideSandbox(ctx.runId, call.id))
|
|
1548
|
+
? { ...rest, sandbox: "escalated" }
|
|
1549
|
+
: rest;
|
|
1550
|
+
}
|
|
1551
|
+
// scheduled tasks spec §7, `fail` mode: no one answers an input request or connects an app
|
|
1552
|
+
if (unattendedFails(ctx.unattended) && ctx.unattended != null) {
|
|
1553
|
+
// a watched wait needs nobody: it stays allowed (browser long waits spec §5.2, R8)
|
|
1554
|
+
if (outcome.kind === "input_required" && outcome.watch === undefined) {
|
|
1555
|
+
outcome = {
|
|
1556
|
+
kind: "error",
|
|
1557
|
+
message: UNATTENDED_QUESTION_ERROR,
|
|
1558
|
+
...(outcome.blocked !== undefined && { blocked: outcome.blocked }),
|
|
1559
|
+
...(outcome.review !== undefined && { review: outcome.review }),
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
else if (outcome.kind === "connection_required") {
|
|
1563
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, connectionGrantKey(outcome.connectorSlug));
|
|
1564
|
+
outcome = { kind: "error", message: UNATTENDED_CONNECTION_ERROR(outcome.connectorName) };
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
591
1567
|
if (outcome.kind === "input_required") {
|
|
592
|
-
const
|
|
1568
|
+
const open = tool.source.kind === "plugin" && outcome.open !== undefined
|
|
1569
|
+
? this.openOf(outcome.open, tool.source.plugin, tool.key)
|
|
1570
|
+
: undefined;
|
|
1571
|
+
const { open: _raw, ...asking } = outcome;
|
|
1572
|
+
const asked = await this.askInput(ctx, call.id, tool.key, attempt, {
|
|
1573
|
+
...asking,
|
|
1574
|
+
...(open !== undefined && { open }),
|
|
1575
|
+
source: tool.source,
|
|
1576
|
+
});
|
|
593
1577
|
if (typeof asked !== "string")
|
|
594
1578
|
return asked;
|
|
595
|
-
outcome = {
|
|
1579
|
+
outcome = {
|
|
1580
|
+
kind: "error",
|
|
1581
|
+
message: asked,
|
|
1582
|
+
...(outcome.blocked !== undefined && { blocked: outcome.blocked }),
|
|
1583
|
+
...(outcome.review !== undefined && { review: outcome.review }),
|
|
1584
|
+
};
|
|
596
1585
|
}
|
|
1586
|
+
// the images of the result (any tool): stored as `read` copies of the calling conversation,
|
|
1587
|
+
// named in the text and in `tool_result.media`, so a model with vision sees them after the
|
|
1588
|
+
// step's results and the person sees them on the call's row (tool result images design §2)
|
|
1589
|
+
const images = outcome.kind === "result"
|
|
1590
|
+
? await storeResultImages(outcome.result, tool.key, this.storeResultImage(ctx), (err) => this.deps.log.warn("cannot store an image of a tool result", {
|
|
1591
|
+
toolKey: tool.key,
|
|
1592
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1593
|
+
}), ctx.signal)
|
|
1594
|
+
: undefined;
|
|
597
1595
|
const rendered = outcome.kind === "result"
|
|
598
|
-
? renderResult(outcome.result)
|
|
1596
|
+
? renderResult(outcome.result, images?.texts)
|
|
599
1597
|
: { text: outcome.message, contentTypes: [], isError: true };
|
|
600
|
-
//
|
|
1598
|
+
// the tools a builtin (ToolSearch) reports as loaded: only keys available in this step and not
|
|
1599
|
+
// builtin, written to tool_result (the log is the source of truth)
|
|
601
1600
|
const loadedTools = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
602
1601
|
? loadedFrom(outcome.result, resolved.tools)
|
|
603
1602
|
: [];
|
|
1603
|
+
// the images the builtin Read stored for the call (vision-read design §1.2): builtins only,
|
|
1604
|
+
// so a plugin can never name an attachment for request building
|
|
1605
|
+
const builtinMedia = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
1606
|
+
? mediaFrom(outcome.result)
|
|
1607
|
+
: undefined;
|
|
1608
|
+
const allMedia = [...(builtinMedia ?? []), ...(images?.media ?? [])];
|
|
1609
|
+
const media = allMedia.length > 0 ? allMedia : undefined;
|
|
604
1610
|
// 显示摘要:只认插件 / 内置工具与内核的 resources 工具给的(连接器结果来自外部服务,不采信),
|
|
605
1611
|
// 校验不过就丢弃并告警
|
|
606
1612
|
const display = outcome.kind === "result" && (tool.source.kind !== "connector" || tool.source.resources)
|
|
@@ -614,6 +1620,11 @@ let ToolPipeline = class ToolPipeline {
|
|
|
614
1620
|
const card = outcome.kind === "result" && tool.source.kind === "plugin"
|
|
615
1621
|
? this.cardOf(outcome.result, tool.source.plugin, tool.key)
|
|
616
1622
|
: undefined;
|
|
1623
|
+
// a `gh auth login --web` device code (`Bash`; auto mode spec §6): display only, written under
|
|
1624
|
+
// this call before its result, never part of the result or the request the model sees
|
|
1625
|
+
const loginCode = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
1626
|
+
? loginCodeOf(outcome.result)
|
|
1627
|
+
: undefined;
|
|
617
1628
|
const cfg = this.config.get().tools;
|
|
618
1629
|
const spilled = await spillIfLarge(rendered.text, {
|
|
619
1630
|
// 内置工具可给更低的转存阈值(沙箱 bash 30000 字符)
|
|
@@ -641,20 +1652,140 @@ let ToolPipeline = class ToolPipeline {
|
|
|
641
1652
|
},
|
|
642
1653
|
]
|
|
643
1654
|
: [];
|
|
644
|
-
|
|
1655
|
+
if (loginCode !== undefined &&
|
|
1656
|
+
!(await this.deps.eventLog.deviceCodeShown(ctx.conversationId, loginCode.code))) {
|
|
1657
|
+
// the per-call id makes a retry or a resumed run append it once; a second call (a task read
|
|
1658
|
+
// again, another command printing the same code) does not show the same code twice (P-D13)
|
|
1659
|
+
pre.push(deviceCodeEvent(ctx.runId, ctx.step, call.id, loginCode));
|
|
1660
|
+
}
|
|
1661
|
+
const callAudit = {
|
|
1662
|
+
durationMs,
|
|
1663
|
+
connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
|
|
1664
|
+
authorization,
|
|
1665
|
+
};
|
|
1666
|
+
// a foreground command refused network hosts (network ask-to-allow spec §6.2): display-only
|
|
1667
|
+
// `network_blocked` before the result, then an ask to the device owner (the run waits; the
|
|
1668
|
+
// result is written when the ask settles) or notes after the output
|
|
1669
|
+
const commandReport = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
1670
|
+
? networkReportOf(outcome.result)
|
|
1671
|
+
: undefined;
|
|
1672
|
+
// the denial line `Bash` left out of its content: appended here in the form that goes with
|
|
1673
|
+
// the network notes (`denialHintFor`), after the output (and its truncation line)
|
|
1674
|
+
const denialHint = outcome.kind === "result" && tool.source.kind === "builtin"
|
|
1675
|
+
? denialHintOf(outcome.result)
|
|
1676
|
+
: undefined;
|
|
1677
|
+
// a device service's refusals reported in the call scope (browser use spec §7.1), any source:
|
|
1678
|
+
// asked as "always" only, the call runs again once approved
|
|
1679
|
+
// a report about another device than the conversation's is ignored: only the device the call
|
|
1680
|
+
// works in may be asked about, and only its owner
|
|
1681
|
+
const scoped = commandReport === undefined && (outcome.kind === "result" || outcome.kind === "error")
|
|
1682
|
+
? await this.ownDeviceReport(ctx, outKey, outcome.blocked)
|
|
1683
|
+
: undefined;
|
|
1684
|
+
// the formatted result and its display-only fields, kept by an ask until it settles
|
|
1685
|
+
const keptResult = {
|
|
1686
|
+
text: rendered.text,
|
|
645
1687
|
content: spilled.content,
|
|
646
1688
|
isError: rendered.isError,
|
|
647
1689
|
...(spilled.outputId !== undefined && { outputId: spilled.outputId }),
|
|
648
1690
|
...(rendered.contentTypes.length > 0 && { contentTypes: rendered.contentTypes }),
|
|
1691
|
+
...(display !== undefined && { display }),
|
|
1692
|
+
...(view !== undefined && { view }),
|
|
1693
|
+
...(media !== undefined && { media }),
|
|
1694
|
+
...(review !== undefined && { review }),
|
|
1695
|
+
// carried into the kept result so a resumed run writes the event too (it was written
|
|
1696
|
+
// with `network_blocked` below when the ask was created)
|
|
1697
|
+
...(loginCode !== undefined && { loginCode }),
|
|
1698
|
+
...(denialHint !== undefined && { denialHint }),
|
|
1699
|
+
};
|
|
1700
|
+
const site = outcome.kind === "result" || outcome.kind === "error" ? outcome.siteAccess : undefined;
|
|
1701
|
+
if (site !== undefined) {
|
|
1702
|
+
const handled = await this.handleSiteAccess(ctx, call, tool, input, site, attempt, keptResult, pre, callAudit, rerun.site);
|
|
1703
|
+
if (handled.kind === "wait")
|
|
1704
|
+
return handled.wait;
|
|
1705
|
+
if (handled.kind === "rerun") {
|
|
1706
|
+
return this.runCall(ctx, call, resolved, attempt + 1, resume, carried, {
|
|
1707
|
+
site: handled.site,
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
await this.writeResult(ctx, call.id, outKey, {
|
|
1711
|
+
...keptResult,
|
|
1712
|
+
content: withNetworkNotes(keptResult.content, [handled.note]),
|
|
1713
|
+
isError: true,
|
|
1714
|
+
}, pre, callAudit);
|
|
1715
|
+
return undefined;
|
|
1716
|
+
}
|
|
1717
|
+
// a device service's loopback refusal (browser loopback port grants), decided before the other
|
|
1718
|
+
// hosts: the conversation's permission profile grants the port (the call runs again now),
|
|
1719
|
+
// the run waits for the device owner, or a note says why the port stays closed; its host is
|
|
1720
|
+
// then not one of the address hosts below
|
|
1721
|
+
let serviceHosts = scoped?.hosts;
|
|
1722
|
+
let loopbackNotes = [];
|
|
1723
|
+
if (scoped?.loopback !== undefined) {
|
|
1724
|
+
const lb = scoped.loopback;
|
|
1725
|
+
const otherHosts = scoped.hosts.filter((h) => serviceHostKey(h.host) !== serviceHostKey(lb.host));
|
|
1726
|
+
const handled = await this.loopbackBlocked(ctx, call, tool, input, outKey, { deviceId: scoped.deviceId, loopback: lb, url: scoped.url, otherHosts }, attempt, keptResult, rerun.loopbackRerun === true, pre, callAudit);
|
|
1727
|
+
if (handled.kind !== "none") {
|
|
1728
|
+
serviceHosts = otherHosts;
|
|
1729
|
+
if (handled.kind === "wait") {
|
|
1730
|
+
if (hooks && hookBase) {
|
|
1731
|
+
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: handled.content, durationMs }, ctx.signal, this.deps.log);
|
|
1732
|
+
}
|
|
1733
|
+
return handled.wait;
|
|
1734
|
+
}
|
|
1735
|
+
if (handled.kind === "rerun") {
|
|
1736
|
+
return this.runCall(ctx, call, resolved, attempt + 1, resume, { ...(carried.review !== undefined && { review: carried.review }) }, { notes: handled.notes, loopbackRerun: true });
|
|
1737
|
+
}
|
|
1738
|
+
loopbackNotes = handled.notes;
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
const report = commandReport ??
|
|
1742
|
+
(scoped === undefined || serviceHosts === undefined || serviceHosts.length === 0
|
|
1743
|
+
? undefined
|
|
1744
|
+
: {
|
|
1745
|
+
deviceId: scoped.deviceId,
|
|
1746
|
+
// a service reports host names with their layers only: the event carries the HTTPS
|
|
1747
|
+
// port. The layer is the service's word: it only chooses the note or the ask, and the
|
|
1748
|
+
// plan still refuses to ask about a host the device list cannot take (an IP literal
|
|
1749
|
+
// or other invalid name is always `address`)
|
|
1750
|
+
blocked: serviceHosts.map(({ host, layer }) => ({ host, port: 443, layer })),
|
|
1751
|
+
});
|
|
1752
|
+
let content = spilled.content;
|
|
1753
|
+
if (report !== undefined) {
|
|
1754
|
+
const handled = await this.networkBlocked(ctx, call.id, outKey, input, report, pre, callAudit, loopbackNotes.length === 0
|
|
1755
|
+
? keptResult
|
|
1756
|
+
: { ...keptResult, content: withNetworkNotes(keptResult.content, loopbackNotes) }, reviewedRoots.escalation, reviewedRoots.escalationRefusal, scoped === undefined
|
|
1757
|
+
? undefined
|
|
1758
|
+
: {
|
|
1759
|
+
name: tool.source.kind === "plugin" ? tool.source.plugin : tool.key,
|
|
1760
|
+
attempt,
|
|
1761
|
+
url: scoped.url,
|
|
1762
|
+
});
|
|
1763
|
+
if (handled.kind === "wait") {
|
|
1764
|
+
if (hooks && hookBase) {
|
|
1765
|
+
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content: handled.content, durationMs }, ctx.signal, this.deps.log);
|
|
1766
|
+
}
|
|
1767
|
+
return handled.wait;
|
|
1768
|
+
}
|
|
1769
|
+
if (handled.event !== null)
|
|
1770
|
+
pre.push(handled.event);
|
|
1771
|
+
content = withNetworkNotes(withNetworkNotes(content, loopbackNotes) + denialHintFor(denialHint, handled.addressNote), handled.notes);
|
|
1772
|
+
}
|
|
1773
|
+
else
|
|
1774
|
+
content = withNetworkNotes(content, loopbackNotes) + denialHintFor(denialHint, undefined);
|
|
1775
|
+
// a re-run after a granted loopback port: its note after the result
|
|
1776
|
+
content = withNetworkNotes(content, rerun.notes ?? []);
|
|
1777
|
+
await this.writeResult(ctx, call.id, outKey, {
|
|
1778
|
+
content,
|
|
1779
|
+
isError: rendered.isError,
|
|
1780
|
+
...(spilled.outputId !== undefined && { outputId: spilled.outputId }),
|
|
1781
|
+
...(rendered.contentTypes.length > 0 && { contentTypes: rendered.contentTypes }),
|
|
649
1782
|
...(loadedTools.length > 0 && { loadedTools }),
|
|
1783
|
+
...(media !== undefined && { media }),
|
|
650
1784
|
...(display !== undefined && { display }),
|
|
651
1785
|
...(view !== undefined && { view }),
|
|
652
1786
|
...(card !== undefined && { card }),
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
|
|
656
|
-
authorization,
|
|
657
|
-
});
|
|
1787
|
+
...(review !== undefined && { review }),
|
|
1788
|
+
}, pre, callAudit);
|
|
658
1789
|
// a sub-agent that needs a personal connection: mirrored in the root conversation of its tree
|
|
659
1790
|
// for display (sub-agents spec §9, agent map spec §7; not a wait, the child got the connect
|
|
660
1791
|
// text as its result)
|
|
@@ -665,14 +1796,1562 @@ let ToolPipeline = class ToolPipeline {
|
|
|
665
1796
|
}));
|
|
666
1797
|
}
|
|
667
1798
|
if (hooks && hookBase) {
|
|
668
|
-
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content
|
|
1799
|
+
fireObserve(hooks, "tool.postExecute", { ...hookBase, isError: rendered.isError, content, durationMs }, ctx.signal, this.deps.log);
|
|
669
1800
|
}
|
|
670
1801
|
return undefined;
|
|
671
1802
|
}
|
|
672
|
-
/**
|
|
673
|
-
|
|
674
|
-
const
|
|
675
|
-
|
|
1803
|
+
/** Take the organization authority before the transaction's durable start. */
|
|
1804
|
+
withOrgToolAdmission(ctx, tool, policyKey, input, approval, automatic, commit) {
|
|
1805
|
+
const locks = this.permissionLocks;
|
|
1806
|
+
const recheck = async () => {
|
|
1807
|
+
const db = this.deps.db;
|
|
1808
|
+
// Stabilize the recorded approver's membership before taking the authority lock.
|
|
1809
|
+
const member = approval?.status === "approved" &&
|
|
1810
|
+
approval.orgAskRevisions !== undefined &&
|
|
1811
|
+
approval.decidedBy !== null
|
|
1812
|
+
? await db
|
|
1813
|
+
.selectFrom("memberships")
|
|
1814
|
+
.select("role")
|
|
1815
|
+
.where("org_id", "=", ctx.orgId)
|
|
1816
|
+
.where("account_id", "=", approval.decidedBy)
|
|
1817
|
+
.$if(locks !== undefined, (query) => query.forShare())
|
|
1818
|
+
.executeTakeFirst()
|
|
1819
|
+
: undefined;
|
|
1820
|
+
await locks?.acquire({ orgId: ctx.orgId }, { kind: "admit" });
|
|
1821
|
+
const unattended = unattendedRules(ctx.unattended);
|
|
1822
|
+
const current = await readOrgToolPolicy(db, ctx.orgId, tool.key, policyKey, unattended);
|
|
1823
|
+
if (current.policy === "deny")
|
|
1824
|
+
throw new OrgToolDenied();
|
|
1825
|
+
if (automatic !== undefined && !(await this.canAdmitRecordedProfile(ctx, automatic)))
|
|
1826
|
+
throw new OrgToolPolicyChanged();
|
|
1827
|
+
if (current.policy !== "ask")
|
|
1828
|
+
return;
|
|
1829
|
+
if (approval?.status !== "approved" ||
|
|
1830
|
+
approval.toolKey !== policyKey ||
|
|
1831
|
+
approval.specHash !== tool.specHash ||
|
|
1832
|
+
approval.scope !== "once" ||
|
|
1833
|
+
approval.decidedBy === null ||
|
|
1834
|
+
!sameOrgAsk(approval.orgAskRevisions, current.revisions) ||
|
|
1835
|
+
canonicalJson(approval.input) !== canonicalJson(input ?? {}))
|
|
1836
|
+
throw new OrgToolPolicyChanged();
|
|
1837
|
+
if (!member)
|
|
1838
|
+
throw new OrgToolDenied();
|
|
1839
|
+
if (approval.requestedFor === null) {
|
|
1840
|
+
if (approval.approverRole === null ||
|
|
1841
|
+
approval.decidedBy === ctx.accountId ||
|
|
1842
|
+
!roleAtLeast(member.role, approval.approverRole))
|
|
1843
|
+
throw new OrgToolDenied();
|
|
1844
|
+
}
|
|
1845
|
+
else {
|
|
1846
|
+
if (approval.decidedBy !== approval.requestedFor)
|
|
1847
|
+
throw new OrgToolDenied();
|
|
1848
|
+
if (tool.requiredRole !== undefined && !roleAtLeast(member.role, tool.requiredRole))
|
|
1849
|
+
throw new OrgToolPolicyChanged();
|
|
1850
|
+
}
|
|
1851
|
+
};
|
|
1852
|
+
return locks === undefined
|
|
1853
|
+
? recheck().then(commit)
|
|
1854
|
+
: withTransactionFencePrelude(recheck, commit);
|
|
1855
|
+
}
|
|
1856
|
+
async canAdmitRecordedProfile(ctx, decision) {
|
|
1857
|
+
const profiles = this.approvalProfile;
|
|
1858
|
+
if (profiles?.canAdmitRecorded === undefined)
|
|
1859
|
+
return true;
|
|
1860
|
+
try {
|
|
1861
|
+
return await profiles.canAdmitRecorded({
|
|
1862
|
+
orgId: ctx.orgId,
|
|
1863
|
+
rootConversationId: ctx.parent?.rootConversationId ?? ctx.conversationId,
|
|
1864
|
+
profile: decision.source === "full-access" ? "full-access" : "approve-for-me",
|
|
1865
|
+
revision: decision.revision,
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
catch (error) {
|
|
1869
|
+
this.deps.log.warn("cannot check a recorded profile decision; asking the person", {
|
|
1870
|
+
conversationId: ctx.conversationId,
|
|
1871
|
+
error,
|
|
1872
|
+
});
|
|
1873
|
+
return false;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1877
|
+
* The profile step (profiles govern every approval, R1-R3) of an ask `decide` returned for a call
|
|
1878
|
+
* no approval governs yet. It applies only to an ask addressed to the person (no role, the root
|
|
1879
|
+
* conversation's own owner), in an attended interactive chat, and for a tool that does not
|
|
1880
|
+
* itself require the person's interaction (D3); a call's secret fields are asked afterwards in a
|
|
1881
|
+
* secure input request whatever it decides (R4). Request approval asks; Auto allows; Approve for
|
|
1882
|
+
* me asks the review model, whose unsure answer asks the person. An `allow` or `deny` is recorded
|
|
1883
|
+
* once (`tool_ask_decided` and its audit row). A resumed call reuses an eligible allow or the
|
|
1884
|
+
* recorded deny. If the ceiling invalidates an allow, the person decides instead.
|
|
1885
|
+
*/
|
|
1886
|
+
async profileStep(ctx, call, tool, input, ask, callPolicy) {
|
|
1887
|
+
const asks = { kind: "ask", unsure: false };
|
|
1888
|
+
const profiles = this.approvalProfile;
|
|
1889
|
+
const reviewer = this.toolReview;
|
|
1890
|
+
if (profiles === undefined || reviewer === undefined)
|
|
1891
|
+
return asks;
|
|
1892
|
+
if (ask.orgAskRevisions !== undefined)
|
|
1893
|
+
return asks;
|
|
1894
|
+
if (ask.approverRole !== null || ask.requestedFor === null)
|
|
1895
|
+
return asks;
|
|
1896
|
+
if (ctx.unattended != null)
|
|
1897
|
+
return asks;
|
|
1898
|
+
// a change of what the person consents to: they answer it themself, never their profile
|
|
1899
|
+
if (callPolicy?.personDecides === true)
|
|
1900
|
+
return asks;
|
|
1901
|
+
if (tool.spec.annotations?.requiresUserInteraction === true)
|
|
1902
|
+
return asks;
|
|
1903
|
+
// Reuse the decision if its profile is still eligible. A ceiling change leaves started work alone.
|
|
1904
|
+
const bindingHash = askBindingHash(ask.toolKey, ask.specHash, call.input);
|
|
1905
|
+
const idemKey = `tool_ask_decided:${ctx.runId}:${call.id}:${bindingHash}`;
|
|
1906
|
+
const recorded = await this.deps.eventLog.findByIdem(ctx.conversationId, idemKey);
|
|
1907
|
+
if (recorded?.type === "tool_ask_decided") {
|
|
1908
|
+
const outcome = askDecisionOf(recorded);
|
|
1909
|
+
if (outcome.kind === "allow" && !(await this.canAdmitRecordedProfile(ctx, outcome.decision)))
|
|
1910
|
+
return asks;
|
|
1911
|
+
return outcome;
|
|
1912
|
+
}
|
|
1913
|
+
const rootConversationId = ctx.parent?.rootConversationId ?? ctx.conversationId;
|
|
1914
|
+
let resolved;
|
|
1915
|
+
try {
|
|
1916
|
+
resolved = await profiles.resolve({
|
|
1917
|
+
orgId: ctx.orgId,
|
|
1918
|
+
rootConversationId,
|
|
1919
|
+
requestedFor: ask.requestedFor,
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1922
|
+
catch (err) {
|
|
1923
|
+
this.deps.log.warn("cannot read the conversation's permission profile; asking the person", {
|
|
1924
|
+
conversationId: ctx.conversationId,
|
|
1925
|
+
callId: call.id,
|
|
1926
|
+
err,
|
|
1927
|
+
});
|
|
1928
|
+
return asks;
|
|
1929
|
+
}
|
|
1930
|
+
if (resolved === null || resolved.profile === "request-approval")
|
|
1931
|
+
return asks;
|
|
1932
|
+
let decision;
|
|
1933
|
+
if (resolved.profile === "full-access") {
|
|
1934
|
+
decision = { outcome: "allow", reason: TOOL_AUTO_REASON, source: "full-access" };
|
|
1935
|
+
}
|
|
1936
|
+
else {
|
|
1937
|
+
const parent = ctx.parent;
|
|
1938
|
+
const verdict = await reviewer.review({
|
|
1939
|
+
orgId: ctx.orgId,
|
|
1940
|
+
rootConversationId,
|
|
1941
|
+
conversationId: ctx.conversationId,
|
|
1942
|
+
runId: ctx.runId,
|
|
1943
|
+
step: ctx.step,
|
|
1944
|
+
callId: call.id,
|
|
1945
|
+
accountId: ctx.accountId,
|
|
1946
|
+
signal: ctx.signal,
|
|
1947
|
+
toolKey: ask.toolKey,
|
|
1948
|
+
title: tool.spec.title ?? null,
|
|
1949
|
+
summary: callPolicy?.summary ?? null,
|
|
1950
|
+
input,
|
|
1951
|
+
inputSchema: tool.spec.inputSchema,
|
|
1952
|
+
// a sub-agent's review counts on its parent run, as the command review's does
|
|
1953
|
+
...(parent !== undefined && {
|
|
1954
|
+
parentRunId: parent.runId,
|
|
1955
|
+
...(parent.budgetRunId !== undefined && { budgetRunId: parent.budgetRunId }),
|
|
1956
|
+
}),
|
|
1957
|
+
hookFacts: {
|
|
1958
|
+
accountId: ctx.accountId,
|
|
1959
|
+
agentId: ctx.agentId,
|
|
1960
|
+
agentVersion: ctx.agentVersion,
|
|
1961
|
+
conversationKind: ctx.conversationKind,
|
|
1962
|
+
parent: parent === undefined
|
|
1963
|
+
? undefined
|
|
1964
|
+
: {
|
|
1965
|
+
conversationId: parent.conversationId,
|
|
1966
|
+
runId: parent.runId,
|
|
1967
|
+
callId: parent.callId,
|
|
1968
|
+
},
|
|
1969
|
+
},
|
|
1970
|
+
});
|
|
1971
|
+
if (verdict.decision === "ask")
|
|
1972
|
+
return { kind: "ask", unsure: true };
|
|
1973
|
+
decision = { outcome: verdict.decision, reason: verdict.reason, source: "review-model" };
|
|
1974
|
+
}
|
|
1975
|
+
const fileSha256 = callPolicy?.file?.sha256;
|
|
1976
|
+
const event = await this.recordAskDecision(ctx, idemKey, {
|
|
1977
|
+
step: ctx.step,
|
|
1978
|
+
callId: call.id,
|
|
1979
|
+
toolKey: ask.toolKey,
|
|
1980
|
+
specHash: ask.specHash,
|
|
1981
|
+
bindingHash,
|
|
1982
|
+
outcome: decision.outcome,
|
|
1983
|
+
decisionSource: decision.source,
|
|
1984
|
+
reason: decision.reason,
|
|
1985
|
+
profileRevision: resolved.revision,
|
|
1986
|
+
...(fileSha256 !== undefined && { fileSha256 }),
|
|
1987
|
+
});
|
|
1988
|
+
return askDecisionOf(event);
|
|
1989
|
+
}
|
|
1990
|
+
/** Records an automatic decision once (R2) and announces it after the commit. */
|
|
1991
|
+
async recordAskDecision(ctx, idemKey, payload) {
|
|
1992
|
+
const { event, fresh } = await this.recordAskDecisionIn(ctx, idemKey, payload);
|
|
1993
|
+
if (fresh)
|
|
1994
|
+
await this.deps.eventLog.notify(ctx.conversationId, event.seq);
|
|
1995
|
+
return event;
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* The `tool_ask_decided` event and, when this call wrote it, its audit row
|
|
1999
|
+
* `tool.ask_auto_decided`, in one transaction: a retry or another replica returns the recorded
|
|
2000
|
+
* event and audits nothing (every automatic decision is audited exactly once).
|
|
2001
|
+
*/
|
|
2002
|
+
async recordAskDecisionIn(ctx, idemKey, payload) {
|
|
2003
|
+
const report = await this.deps.eventLog.appendInReport(ctx.conversationId, [
|
|
2004
|
+
{ type: "tool_ask_decided", runId: ctx.runId, idemKey, payload },
|
|
2005
|
+
]);
|
|
2006
|
+
const event = report.events[0];
|
|
2007
|
+
if (event?.type !== "tool_ask_decided")
|
|
2008
|
+
throw new Error("The ask decision was not recorded");
|
|
2009
|
+
const fresh = report.fresh[0] === true;
|
|
2010
|
+
if (fresh) {
|
|
2011
|
+
await audit(this.deps.db, {
|
|
2012
|
+
actorAccountId: ctx.accountId,
|
|
2013
|
+
orgId: ctx.orgId,
|
|
2014
|
+
action: "tool.ask_auto_decided",
|
|
2015
|
+
target: ctx.conversationId,
|
|
2016
|
+
detail: {
|
|
2017
|
+
callId: payload.callId,
|
|
2018
|
+
runId: ctx.runId,
|
|
2019
|
+
toolKey: payload.toolKey,
|
|
2020
|
+
outcome: payload.outcome,
|
|
2021
|
+
decisionSource: payload.decisionSource,
|
|
2022
|
+
profileRevision: payload.profileRevision,
|
|
2023
|
+
reason: payload.reason,
|
|
2024
|
+
},
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
return { event, fresh };
|
|
2028
|
+
}
|
|
2029
|
+
/**
|
|
2030
|
+
* The command review of one call (auto mode spec §5.1, §5.4), after argument validation and the
|
|
2031
|
+
* tool policy (and its approval), before the plugin hooks and execution. The device facts come
|
|
2032
|
+
* from the same `ConversationDevices.forTool` the tool enters; with no device (or a deployment
|
|
2033
|
+
* without a review service) the call runs unreviewed and fails on its own if it cannot. A deny is
|
|
2034
|
+
* final whatever the mode and approvals; an `ask` waits for the device owner's `command` approval
|
|
2035
|
+
* when the run is attended, and is a deny at once when it is not. A command approval already
|
|
2036
|
+
* asked is the whole truth on a resume: the call is never reviewed twice.
|
|
2037
|
+
*/
|
|
2038
|
+
async reviewCall(ctx, call, tool, input) {
|
|
2039
|
+
// a device tool of a run another account triggered never uses the owner's device: refused
|
|
2040
|
+
// here, with no review and no review model call (the tools refuse it the same way)
|
|
2041
|
+
if (this.operationScoped(tool, input) && ctx.ownerAccountId !== ctx.accountId)
|
|
2042
|
+
return {
|
|
2043
|
+
kind: "result",
|
|
2044
|
+
content: DEVICE_OF_ANOTHER_ACCOUNT_TEXT,
|
|
2045
|
+
review: denyRecord("rule", null, "The run's account is not the conversation's owner"),
|
|
2046
|
+
};
|
|
2047
|
+
if (this.operationScoped(tool, input)) {
|
|
2048
|
+
let scoped;
|
|
2049
|
+
try {
|
|
2050
|
+
scoped = await this.reviewPermissionCall(ctx, call, tool, input);
|
|
2051
|
+
}
|
|
2052
|
+
catch (error) {
|
|
2053
|
+
// fail closed: a permission evidence conflict or an owner check that refuses while the
|
|
2054
|
+
// call is asked about, reviewed or matched to its grant is a refusal of this call, never a
|
|
2055
|
+
// run error and never a run of it
|
|
2056
|
+
if (!(error instanceof ApiError) || !FAIL_CLOSED_CODES.has(error.code))
|
|
2057
|
+
throw error;
|
|
2058
|
+
this.deps.log.warn("permission review refused the call", {
|
|
2059
|
+
conversationId: ctx.conversationId,
|
|
2060
|
+
callId: call.id,
|
|
2061
|
+
err: error,
|
|
2062
|
+
});
|
|
2063
|
+
const content = permissionCheckFailedText(error.message);
|
|
2064
|
+
return { kind: "result", content, review: denyRecord("rule", null, error.message) };
|
|
2065
|
+
}
|
|
2066
|
+
if (scoped)
|
|
2067
|
+
return scoped;
|
|
2068
|
+
}
|
|
2069
|
+
const review = this.deps.review;
|
|
2070
|
+
const devices = this.deps.devices;
|
|
2071
|
+
if (review === undefined || devices === undefined)
|
|
2072
|
+
return { kind: "continue" };
|
|
2073
|
+
if (!isReviewedCall(tool.key, input))
|
|
2074
|
+
return { kind: "continue" };
|
|
2075
|
+
const asked = await this.deps.approvals.commandForCall(ctx.runId, call.id);
|
|
2076
|
+
const rootConversationId = ctx.parent?.rootConversationId ?? ctx.conversationId;
|
|
2077
|
+
if (asked !== null && asked.status !== "superseded") {
|
|
2078
|
+
const settled = this.settledCommandAsk(asked, tool.key);
|
|
2079
|
+
// an approved call runs in the root it was reviewed against only while the device still runs
|
|
2080
|
+
// in the mode recorded with the ask; otherwise the tool decides its working root afresh. A
|
|
2081
|
+
// judged root that is the recorded workspace (free mode) is not carried either
|
|
2082
|
+
// ({@link carriedRoot}): the tool maps it to the held instance's workspace as always
|
|
2083
|
+
if (settled.kind === "continue" && settled.workingRoot !== undefined) {
|
|
2084
|
+
const now = await devices.reviewFacts(ctx.orgId, rootConversationId, ctx.conversationId);
|
|
2085
|
+
if (now === null ||
|
|
2086
|
+
now.mode !== asked.command?.mode ||
|
|
2087
|
+
carriedRoot({ workspace: now.workspace, workingRoot: settled.workingRoot }) === undefined) {
|
|
2088
|
+
// the root the person approved stays the one judged (B-18): only the carried root goes
|
|
2089
|
+
return { ...settled, workingRoot: undefined };
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
return settled;
|
|
2093
|
+
}
|
|
2094
|
+
const facts = await devices.reviewFacts(ctx.orgId, rootConversationId, ctx.conversationId);
|
|
2095
|
+
if (facts === null)
|
|
2096
|
+
return { kind: "continue" }; // no device: the tool fails on its own
|
|
2097
|
+
const kind = reviewKindOf(tool.key);
|
|
2098
|
+
const attended = ctx.unattended == null && ctx.accountId === facts.ownerAccountId;
|
|
2099
|
+
// a command over the ceiling is refused before any review: no stage reads it in full, and no
|
|
2100
|
+
// approval could bind a text the person cannot see (hardening spec R8)
|
|
2101
|
+
if (kind === "command") {
|
|
2102
|
+
const text = textField(input, "command");
|
|
2103
|
+
if (text.length > COMMAND_ASK_MAX_CHARS) {
|
|
2104
|
+
return {
|
|
2105
|
+
kind: "result",
|
|
2106
|
+
content: commandTooLongText(text.length),
|
|
2107
|
+
review: denyRecord("rule", null, commandTooLongReason(text.length)),
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
const verdict = await review.review({
|
|
2112
|
+
orgId: ctx.orgId,
|
|
2113
|
+
conversationId: rootConversationId,
|
|
2114
|
+
runId: ctx.runId,
|
|
2115
|
+
accountId: ctx.accountId,
|
|
2116
|
+
toolKey: tool.key,
|
|
2117
|
+
input,
|
|
2118
|
+
mode: facts.mode,
|
|
2119
|
+
// the working root: a bound project's root, where commands start and writes need no ask
|
|
2120
|
+
workspace: facts.workingRoot,
|
|
2121
|
+
// the owner's home, never the project root: the home-level rules stay where they were
|
|
2122
|
+
home: facts.home,
|
|
2123
|
+
// and the device workspace's home, so a project outside every home still protects it
|
|
2124
|
+
deviceHome: facts.deviceHome,
|
|
2125
|
+
attended,
|
|
2126
|
+
step: ctx.step,
|
|
2127
|
+
callId: call.id,
|
|
2128
|
+
signal: ctx.signal,
|
|
2129
|
+
...reviewParentOf(ctx.parent),
|
|
2130
|
+
agentId: ctx.agentId,
|
|
2131
|
+
agentVersion: ctx.agentVersion,
|
|
2132
|
+
...(ctx.conversationKind !== undefined && { conversationKind: ctx.conversationKind }),
|
|
2133
|
+
});
|
|
2134
|
+
if (verdict.decision === "allow") {
|
|
2135
|
+
return {
|
|
2136
|
+
kind: "continue",
|
|
2137
|
+
review: allowRecord(verdict),
|
|
2138
|
+
workingRoot: carriedRoot(facts),
|
|
2139
|
+
reviewedAgainst: facts.workingRoot,
|
|
2140
|
+
};
|
|
2141
|
+
}
|
|
2142
|
+
if (verdict.decision === "deny") {
|
|
2143
|
+
return {
|
|
2144
|
+
kind: "result",
|
|
2145
|
+
content: commandDeniedText(verdict.reason, kind),
|
|
2146
|
+
review: denyRecord(verdict.by, verdict.rule, verdict.reason),
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
// ask
|
|
2150
|
+
const command = kind === "command" ? textField(input, "command") : tool.key;
|
|
2151
|
+
if (!attended) {
|
|
2152
|
+
const reason = verdict.reason;
|
|
2153
|
+
// an automation's run records the held class on its task run (shown there, never a grant)
|
|
2154
|
+
if (ctx.unattended != null) {
|
|
2155
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, reviewHoldKey(kind));
|
|
2156
|
+
}
|
|
2157
|
+
return {
|
|
2158
|
+
kind: "result",
|
|
2159
|
+
content: commandUnattendedText(reason, kind),
|
|
2160
|
+
review: denyRecord(verdict.by, verdict.rule, reason),
|
|
2161
|
+
};
|
|
2162
|
+
}
|
|
2163
|
+
const detail = {
|
|
2164
|
+
deviceId: facts.deviceId,
|
|
2165
|
+
deviceName: facts.deviceName,
|
|
2166
|
+
mode: facts.mode,
|
|
2167
|
+
kind,
|
|
2168
|
+
// the whole command the approval covers (the event keeps a clamped copy for display)
|
|
2169
|
+
command,
|
|
2170
|
+
// a relative path as it will be written: resolved against the working root
|
|
2171
|
+
// (every path a GenerateImage call writes, comma-separated)
|
|
2172
|
+
...(kind === "write" && {
|
|
2173
|
+
path: clipText(writePathsOf(tool.key, input)
|
|
2174
|
+
.map((p) => facts.workingRoot === undefined ? p : pathAgainstWorkingRoot(p, facts.workingRoot))
|
|
2175
|
+
.join(", "), 4096),
|
|
2176
|
+
}),
|
|
2177
|
+
rule: verdict.rule,
|
|
2178
|
+
reason: clipText(verdict.reason, COMMAND_ASK_TEXT_MAX_CHARS),
|
|
2179
|
+
// the root the review judged, always (the workspace in free mode): the approved call runs
|
|
2180
|
+
// against what the person approved, not a later snapshot
|
|
2181
|
+
...(facts.workingRoot !== undefined && { workingRoot: facts.workingRoot }),
|
|
2182
|
+
};
|
|
2183
|
+
let ask;
|
|
2184
|
+
try {
|
|
2185
|
+
ask = await this.deps.approvals.requestCommand({
|
|
2186
|
+
orgId: ctx.orgId,
|
|
2187
|
+
conversationId: ctx.conversationId,
|
|
2188
|
+
runId: ctx.runId,
|
|
2189
|
+
step: ctx.step,
|
|
2190
|
+
callId: call.id,
|
|
2191
|
+
requestedFor: facts.ownerAccountId,
|
|
2192
|
+
detail,
|
|
2193
|
+
// `once` always; `session` only for a concrete rule class, never an `unsure.*` catch-all (P-D2)
|
|
2194
|
+
scopes: isSessionGrantableRule(verdict.rule) ? ["once", "session"] : ["once"],
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
catch (err) {
|
|
2198
|
+
// fail closed: an ask that cannot be created is a deny, never a run of the held call
|
|
2199
|
+
this.deps.log.warn("command ask could not be created; denying the call", {
|
|
2200
|
+
conversationId: ctx.conversationId,
|
|
2201
|
+
callId: call.id,
|
|
2202
|
+
err,
|
|
2203
|
+
});
|
|
2204
|
+
const reason = "The approval could not be created";
|
|
2205
|
+
return {
|
|
2206
|
+
kind: "result",
|
|
2207
|
+
content: commandDeniedText(reason, kind),
|
|
2208
|
+
review: denyRecord(verdict.by, verdict.rule, reason),
|
|
2209
|
+
};
|
|
2210
|
+
}
|
|
2211
|
+
return { kind: "wait", wait: approvalWait(ask) };
|
|
2212
|
+
}
|
|
2213
|
+
/**
|
|
2214
|
+
* Whether this call takes the managed route's permission review: a managed builtin once
|
|
2215
|
+
* activated ({@link MANAGED_OPERATION_TOOLS}) whose call enters the device ({@link entersDevice}).
|
|
2216
|
+
*/
|
|
2217
|
+
operationScoped(tool, input) {
|
|
2218
|
+
return (tool.source.kind === "builtin" &&
|
|
2219
|
+
this.deps.permissionOperations?.has(tool.key) === true &&
|
|
2220
|
+
entersDevice(tool.key, input));
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* The permission review of a managed call, with the escalation state a continued restricted
|
|
2224
|
+
* `Bash` call carries to its tool (its sandbox hints: retry with `sandbox: "escalated"` only
|
|
2225
|
+
* where this device and org allow it).
|
|
2226
|
+
*/
|
|
2227
|
+
async reviewPermissionCall(ctx, call, tool, input) {
|
|
2228
|
+
const note = {};
|
|
2229
|
+
const outcome = await this.reviewPermissionCallWith(ctx, call, tool, input, note);
|
|
2230
|
+
if (outcome?.kind !== "continue")
|
|
2231
|
+
return outcome;
|
|
2232
|
+
return {
|
|
2233
|
+
...outcome,
|
|
2234
|
+
...(note.escalation !== undefined && { sandboxEscalation: note.escalation }),
|
|
2235
|
+
...(note.refusal !== undefined && { sandboxEscalationRefusal: note.refusal }),
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
async reviewPermissionCallWith(ctx, call, tool, input, note) {
|
|
2239
|
+
if (!this.permissionAuthority ||
|
|
2240
|
+
!this.permissionGrants ||
|
|
2241
|
+
!this.permissionLocks ||
|
|
2242
|
+
!this.deps.devices ||
|
|
2243
|
+
!this.deps.review)
|
|
2244
|
+
return null;
|
|
2245
|
+
const permissionLocks = this.permissionLocks;
|
|
2246
|
+
const previous = await this.deps.approvals.commandForCall(ctx.runId, call.id);
|
|
2247
|
+
// A settled refusal belongs to this call, not to a replaceable permission revision.
|
|
2248
|
+
if (previous && !["pending", "approved", "superseded"].includes(previous.status))
|
|
2249
|
+
return this.settledCommandAsk(previous, tool.key);
|
|
2250
|
+
const device = await this.deps.devices.reviewFacts(ctx.orgId, ctx.parent?.rootConversationId ?? ctx.conversationId, ctx.conversationId);
|
|
2251
|
+
if (!device)
|
|
2252
|
+
return null;
|
|
2253
|
+
// a run another account triggered never uses the owner's device (the tool refuses it): there
|
|
2254
|
+
// is no permission authority of that account here to review against
|
|
2255
|
+
if (ctx.accountId !== device.ownerAccountId)
|
|
2256
|
+
return null;
|
|
2257
|
+
const use = {
|
|
2258
|
+
orgId: ctx.orgId,
|
|
2259
|
+
deviceId: device.deviceId,
|
|
2260
|
+
holderConversationId: ctx.conversationId,
|
|
2261
|
+
actor: { accountId: ctx.accountId, conversationId: ctx.conversationId, runId: ctx.runId },
|
|
2262
|
+
};
|
|
2263
|
+
const preview = () => this.permissionAuthority.previewCall(use, { runId: ctx.runId, callId: call.id }, ctx.signal);
|
|
2264
|
+
let facts = await preview();
|
|
2265
|
+
// the facts first: a device not yet started (or not yet probed) whose review depends on them
|
|
2266
|
+
// is started under the normal lifecycle lease, which records a cloud instance's permission
|
|
2267
|
+
// evidence or a local one's installed binding, and read again
|
|
2268
|
+
if (facts.availability.state === "unprobed" &&
|
|
2269
|
+
!facts.unattended &&
|
|
2270
|
+
this.sandboxes &&
|
|
2271
|
+
REVIEWED_ON_FACTS.has(tool.key)) {
|
|
2272
|
+
try {
|
|
2273
|
+
await this.sandboxes.ensureRunning(use, ctx.signal);
|
|
2274
|
+
facts = await preview();
|
|
2275
|
+
}
|
|
2276
|
+
catch (err) {
|
|
2277
|
+
// a start that fails leaves the facts unverified (the conservative branch below); the
|
|
2278
|
+
// tool's own entry reports the device's state
|
|
2279
|
+
ctx.signal.throwIfAborted();
|
|
2280
|
+
this.deps.log.warn("cannot start the device before its review; reviewing unverified", {
|
|
2281
|
+
conversationId: ctx.conversationId,
|
|
2282
|
+
deviceId: device.deviceId,
|
|
2283
|
+
err,
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
if (facts.unattended) {
|
|
2288
|
+
// an unattended run never runs a call outside the sandbox: no one could approve it
|
|
2289
|
+
if (isEscalatedCall(tool.key, input)) {
|
|
2290
|
+
const content = escalationRefusedText(ESCALATION_UNATTENDED_WHY, facts.workingRoot);
|
|
2291
|
+
return { kind: "result", content, review: denyRecord("rule", null, content) };
|
|
2292
|
+
}
|
|
2293
|
+
return null;
|
|
2294
|
+
}
|
|
2295
|
+
if (facts.availability.state !== "supported") {
|
|
2296
|
+
// still unverified: the conservative command review decides (every profile), but a call
|
|
2297
|
+
// that needs more reach is refused now: admission could never run what an approval allowed
|
|
2298
|
+
const unverified = buildPermissionCandidate({ toolKey: tool.key, specHash: tool.specHash, rawInput: call.input, validatedInput: input }, facts, [device.home, device.deviceHome], { backgroundMaxSeconds: backgroundMaxSeconds(this.config.get()) });
|
|
2299
|
+
if (unverified.kind === "in-scope")
|
|
2300
|
+
return null;
|
|
2301
|
+
// a device that cannot run scoped work at all says why (R9); one not checked yet says that
|
|
2302
|
+
const content = unverified.kind !== "proposal"
|
|
2303
|
+
? unverified.message
|
|
2304
|
+
: facts.availability.state === "unsupported"
|
|
2305
|
+
? admissionUnavailableText(facts.availability.cause ?? { kind: "runtime" })
|
|
2306
|
+
: PERMISSION_SUPPORT_UNVERIFIED_TEXT;
|
|
2307
|
+
return { kind: "result", content, review: denyRecord("rule", null, content) };
|
|
2308
|
+
}
|
|
2309
|
+
if (tool.key === "Bash" && textField(input, "command").length > COMMAND_ASK_MAX_CHARS)
|
|
2310
|
+
return {
|
|
2311
|
+
kind: "result",
|
|
2312
|
+
content: commandTooLongText(textField(input, "command").length),
|
|
2313
|
+
review: denyRecord("rule", null, "The command exceeds the review limit"),
|
|
2314
|
+
};
|
|
2315
|
+
const escalated = isEscalatedCall(tool.key, input);
|
|
2316
|
+
// the escalation state the tool's hints read: a Bash call (every profile runs it in the
|
|
2317
|
+
// sandbox) on a device and org whose ceiling allows running outside the sandbox
|
|
2318
|
+
if (tool.key === "Bash" && !facts.escalationRefusal)
|
|
2319
|
+
note.escalation = escalated ? "escalated" : "available";
|
|
2320
|
+
// where it cannot (a layer's outside-sandbox setting is off, the runtime cannot), the hints
|
|
2321
|
+
// say why and who changes it, in the escalation refusal's per-layer words
|
|
2322
|
+
else if (tool.key === "Bash" && facts.escalationRefusal && !escalated)
|
|
2323
|
+
note.refusal = facts.escalationRefusal;
|
|
2324
|
+
// candidate building runs for every profile: the profile only chooses who approves
|
|
2325
|
+
const built = buildPermissionCandidate({
|
|
2326
|
+
toolKey: tool.key,
|
|
2327
|
+
specHash: tool.specHash,
|
|
2328
|
+
rawInput: call.input,
|
|
2329
|
+
validatedInput: input,
|
|
2330
|
+
}, facts, [device.home, device.deviceHome], { backgroundMaxSeconds: backgroundMaxSeconds(this.config.get()) });
|
|
2331
|
+
if (built.kind === "unsupported") {
|
|
2332
|
+
// a Bash reach the restricted scope cannot grant: retrying outside the sandbox may (a
|
|
2333
|
+
// protected location's text names the escalation itself)
|
|
2334
|
+
const content = note.escalation === "available" && built.code === "unbounded-scope"
|
|
2335
|
+
? `${built.message}${ESCALATION_RETRY_HINT}`
|
|
2336
|
+
: built.message;
|
|
2337
|
+
return { kind: "result", content, review: denyRecord("rule", null, content) };
|
|
2338
|
+
}
|
|
2339
|
+
const candidate = built.kind === "proposal" ? built.candidate : undefined;
|
|
2340
|
+
// who approves this call's crossing: the person, the review model, or nobody (Full access
|
|
2341
|
+
// grants it within the device's ceilings); a sub-agent's escalation never goes to nobody
|
|
2342
|
+
const approver = approverForCrossing({
|
|
2343
|
+
profile: facts.profile,
|
|
2344
|
+
crossing: candidate ? crossingOfCandidate(candidate) : "sensitive",
|
|
2345
|
+
subAgent: ctx.parent !== undefined,
|
|
2346
|
+
});
|
|
2347
|
+
// a sensitive-command consent the person settled (no proposed reach): the call runs under
|
|
2348
|
+
// the base scope it was asked under; the approval adds nothing
|
|
2349
|
+
if (previous &&
|
|
2350
|
+
previous.status !== "superseded" &&
|
|
2351
|
+
!candidate &&
|
|
2352
|
+
!previous.command?.permissionCandidate) {
|
|
2353
|
+
const settled = this.settledCommandAsk(previous, tool.key);
|
|
2354
|
+
// the root the person approved is carried only while the device still runs in the mode
|
|
2355
|
+
// recorded with the ask (B-18: the judged root stays the one recorded)
|
|
2356
|
+
if (settled.kind === "continue" &&
|
|
2357
|
+
settled.workingRoot !== undefined &&
|
|
2358
|
+
(device.mode !== previous.command?.mode ||
|
|
2359
|
+
carriedRoot({ workspace: device.workspace, workingRoot: settled.workingRoot }) ===
|
|
2360
|
+
undefined))
|
|
2361
|
+
return { ...settled, workingRoot: undefined };
|
|
2362
|
+
return settled;
|
|
2363
|
+
}
|
|
2364
|
+
if (previous &&
|
|
2365
|
+
previous.status !== "superseded" &&
|
|
2366
|
+
candidate &&
|
|
2367
|
+
previous.command?.permissionCandidate?.candidateHash === candidate.candidateHash) {
|
|
2368
|
+
if (previous.status !== "approved")
|
|
2369
|
+
return this.settledCommandAsk(previous, tool.key);
|
|
2370
|
+
const grant = await withTransactionFencePrelude(() => permissionLocks.acquire({
|
|
2371
|
+
orgId: facts.orgId,
|
|
2372
|
+
deviceId: facts.deviceId,
|
|
2373
|
+
rootConversationId: facts.rootConversationId,
|
|
2374
|
+
}, { kind: "admit" }), () => this.findPermissionGrant(candidate));
|
|
2375
|
+
if (grant)
|
|
2376
|
+
return this.settledCommandAsk(previous, tool.key);
|
|
2377
|
+
}
|
|
2378
|
+
if (candidate) {
|
|
2379
|
+
const existingGrant = await withTransactionFencePrelude(() => permissionLocks.acquire({
|
|
2380
|
+
orgId: facts.orgId,
|
|
2381
|
+
deviceId: facts.deviceId,
|
|
2382
|
+
rootConversationId: facts.rootConversationId,
|
|
2383
|
+
}, { kind: "admit" }), () => this.findPermissionGrant(candidate));
|
|
2384
|
+
if (existingGrant) {
|
|
2385
|
+
if (existingGrant.scopeKind !== candidate.scopeKind ||
|
|
2386
|
+
permissionScopeHash(existingGrant.expansion) !==
|
|
2387
|
+
permissionScopeHash(candidate.permissionScope))
|
|
2388
|
+
return {
|
|
2389
|
+
kind: "result",
|
|
2390
|
+
content: "This call already has different permission evidence; submit a new call with the intended directory scope.",
|
|
2391
|
+
review: denyRecord("rule", null, "Conflicting permission evidence"),
|
|
2392
|
+
};
|
|
2393
|
+
return {
|
|
2394
|
+
kind: "continue",
|
|
2395
|
+
workingRoot: carriedRoot(device),
|
|
2396
|
+
reviewedAgainst: facts.workingRoot,
|
|
2397
|
+
// the evidence's real source: the person's approval, the review model's allow or the
|
|
2398
|
+
// Full access auto-grant
|
|
2399
|
+
review: {
|
|
2400
|
+
decision: "allow",
|
|
2401
|
+
by: existingGrant.source === "human"
|
|
2402
|
+
? "person"
|
|
2403
|
+
: existingGrant.source === "review-model"
|
|
2404
|
+
? "classifier"
|
|
2405
|
+
: "rule",
|
|
2406
|
+
rule: null,
|
|
2407
|
+
reason: "The exact current call already has approved permission evidence.",
|
|
2408
|
+
profile: facts.profile,
|
|
2409
|
+
profileRevision: facts.profileRevision,
|
|
2410
|
+
scopeRevision: facts.scopeRevision,
|
|
2411
|
+
decisionSource: existingGrant.source,
|
|
2412
|
+
crossing: crossingOfCandidate(candidate),
|
|
2413
|
+
...(candidate.escalation ? { sandbox: "escalated" } : {}),
|
|
2414
|
+
},
|
|
2415
|
+
};
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
const verdict = await this.deps.review.review({
|
|
2419
|
+
orgId: ctx.orgId,
|
|
2420
|
+
conversationId: facts.rootConversationId,
|
|
2421
|
+
runId: ctx.runId,
|
|
2422
|
+
accountId: ctx.accountId,
|
|
2423
|
+
toolKey: tool.key,
|
|
2424
|
+
input,
|
|
2425
|
+
mode: device.mode,
|
|
2426
|
+
workspace: facts.workingRoot,
|
|
2427
|
+
home: device.home,
|
|
2428
|
+
deviceHome: device.deviceHome,
|
|
2429
|
+
attended: true,
|
|
2430
|
+
step: ctx.step,
|
|
2431
|
+
callId: call.id,
|
|
2432
|
+
signal: ctx.signal,
|
|
2433
|
+
...reviewParentOf(ctx.parent),
|
|
2434
|
+
agentId: ctx.agentId,
|
|
2435
|
+
agentVersion: ctx.agentVersion,
|
|
2436
|
+
...(ctx.conversationKind ? { conversationKind: ctx.conversationKind } : {}),
|
|
2437
|
+
permissionProfile: facts.profile,
|
|
2438
|
+
...(candidate ? { permissionCandidate: candidate } : {}),
|
|
2439
|
+
...(note.escalation === "available" ? { escalationAvailable: true } : {}),
|
|
2440
|
+
});
|
|
2441
|
+
// who decided: the review knows the call's consents (a credential consent sends a Full access
|
|
2442
|
+
// escalation to the review model); without its answer, the profile's approver
|
|
2443
|
+
const decidedBy = verdict.approver ?? approver;
|
|
2444
|
+
if (candidate && decidedBy === "review-model") {
|
|
2445
|
+
await withTransactionFencePrelude(() => permissionLocks.acquire({
|
|
2446
|
+
orgId: facts.orgId,
|
|
2447
|
+
deviceId: facts.deviceId,
|
|
2448
|
+
rootConversationId: facts.rootConversationId,
|
|
2449
|
+
}, { kind: "admit" }), () => this.recordPermissionReview(candidate, verdict));
|
|
2450
|
+
}
|
|
2451
|
+
// Full access: the crossing is granted for this call, recorded exactly once (its event, the
|
|
2452
|
+
// audit row and the grant in one fenced transaction); a fixed deny never reaches this
|
|
2453
|
+
if (candidate && decidedBy === "none" && verdict.decision === "allow") {
|
|
2454
|
+
if (!this.autoGrants)
|
|
2455
|
+
throw new Error("Permission auto-grants are unavailable");
|
|
2456
|
+
await this.autoGrants.record(candidate, verdict.sensitive ?? []);
|
|
2457
|
+
}
|
|
2458
|
+
const provenance = {
|
|
2459
|
+
profile: facts.profile,
|
|
2460
|
+
profileRevision: facts.profileRevision,
|
|
2461
|
+
scopeRevision: facts.scopeRevision,
|
|
2462
|
+
};
|
|
2463
|
+
if (verdict.decision === "deny")
|
|
2464
|
+
return {
|
|
2465
|
+
kind: "result",
|
|
2466
|
+
content: commandDeniedText(verdict.reason, reviewKindOf(tool.key)),
|
|
2467
|
+
review: { ...denyRecord(verdict.by, verdict.rule, verdict.reason), ...provenance },
|
|
2468
|
+
};
|
|
2469
|
+
if (verdict.decision === "allow")
|
|
2470
|
+
return {
|
|
2471
|
+
kind: "continue",
|
|
2472
|
+
workingRoot: carriedRoot(device),
|
|
2473
|
+
reviewedAgainst: facts.workingRoot,
|
|
2474
|
+
review: {
|
|
2475
|
+
...allowRecord(verdict),
|
|
2476
|
+
...provenance,
|
|
2477
|
+
decisionSource: verdict.by === "classifier"
|
|
2478
|
+
? "review-model"
|
|
2479
|
+
: facts.profile === "full-access"
|
|
2480
|
+
? "full-access"
|
|
2481
|
+
: "scope",
|
|
2482
|
+
...(candidate
|
|
2483
|
+
? { crossing: crossingOfCandidate(candidate) }
|
|
2484
|
+
: verdict.crossing
|
|
2485
|
+
? { crossing: verdict.crossing }
|
|
2486
|
+
: {}),
|
|
2487
|
+
// the review model's allow or Full access issued this call's escalation grant: it runs
|
|
2488
|
+
// outside the sandbox
|
|
2489
|
+
...(candidate?.escalation && (verdict.by === "classifier" || decidedBy === "none")
|
|
2490
|
+
? { sandbox: "escalated" }
|
|
2491
|
+
: {}),
|
|
2492
|
+
},
|
|
2493
|
+
};
|
|
2494
|
+
// an ask: the sensitive-command consent (no proposed reach: approved, the call runs under the
|
|
2495
|
+
// base scope) or the displayed expansion (approved, the call's grant is issued)
|
|
2496
|
+
const kind = reviewKindOf(tool.key);
|
|
2497
|
+
// every path the call writes (a GenerateImage call's suffixed paths, comma-separated)
|
|
2498
|
+
const filePaths = kind === "write" ? writePathsOf(tool.key, input).filter(Boolean) : [];
|
|
2499
|
+
const ask = await this.deps.approvals.requestCommand({
|
|
2500
|
+
orgId: ctx.orgId,
|
|
2501
|
+
conversationId: ctx.conversationId,
|
|
2502
|
+
runId: ctx.runId,
|
|
2503
|
+
step: ctx.step,
|
|
2504
|
+
callId: call.id,
|
|
2505
|
+
requestedFor: ctx.accountId,
|
|
2506
|
+
// `session` only for a consent rule class with no expansion (a grant is per call)
|
|
2507
|
+
scopes: !candidate && isSessionGrantableRule(verdict.rule) ? ["once", "session"] : ["once"],
|
|
2508
|
+
detail: {
|
|
2509
|
+
deviceId: device.deviceId,
|
|
2510
|
+
deviceName: device.deviceName,
|
|
2511
|
+
mode: device.mode,
|
|
2512
|
+
kind,
|
|
2513
|
+
command: tool.key === "Bash" ? textField(input, "command") : tool.key,
|
|
2514
|
+
rule: verdict.rule,
|
|
2515
|
+
reason: clipText(verdict.reason, COMMAND_ASK_TEXT_MAX_CHARS),
|
|
2516
|
+
workingRoot: facts.workingRoot,
|
|
2517
|
+
...(candidate
|
|
2518
|
+
? {
|
|
2519
|
+
permissionCandidate: candidate,
|
|
2520
|
+
permissionScope: candidate.permissionScope,
|
|
2521
|
+
candidateHash: candidate.candidateHash,
|
|
2522
|
+
...(candidate.targetPath
|
|
2523
|
+
? { targetPath: candidate.targetPath, path: candidate.targetPath }
|
|
2524
|
+
: {}),
|
|
2525
|
+
...(candidate.escalation ? { escalation: candidate.escalation } : {}),
|
|
2526
|
+
}
|
|
2527
|
+
: filePaths.length > 0
|
|
2528
|
+
? {
|
|
2529
|
+
path: clipText(filePaths.map((p) => pathAgainstWorkingRoot(p, facts.workingRoot)).join(", "), 4096),
|
|
2530
|
+
}
|
|
2531
|
+
: {}),
|
|
2532
|
+
},
|
|
2533
|
+
});
|
|
2534
|
+
return { kind: "wait", wait: approvalWait(ask) };
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Whether an execution of this call was admitted outside the sandbox (a per-call escalation's
|
|
2538
|
+
* full reach, under any profile): an intent past admission, or one revoked after dispatch, whose
|
|
2539
|
+
* device-wide scope came from the call's escalation grant.
|
|
2540
|
+
*/
|
|
2541
|
+
// org-filter: runId is the call context's own run (ctx.runId), a runtime uuid, never caller input
|
|
2542
|
+
async admittedOutsideSandbox(runId, callId) {
|
|
2543
|
+
const rows = await this.deps.db
|
|
2544
|
+
.selectFrom("sandbox_operation_intents as i")
|
|
2545
|
+
.innerJoin("permission_call_grants as g", "g.id", "i.permission_grant_id")
|
|
2546
|
+
.select(["i.scope", "i.state", "i.outcome_unknown"])
|
|
2547
|
+
.where("i.run_id", "=", runId)
|
|
2548
|
+
.where("i.call_id", "=", callId)
|
|
2549
|
+
.where("i.method", "in", ["exec", "backgroundStart"])
|
|
2550
|
+
.where("g.scope_kind", "=", "sandbox-escalation")
|
|
2551
|
+
.execute();
|
|
2552
|
+
return rows.some((r) => {
|
|
2553
|
+
const scope = r.scope;
|
|
2554
|
+
const admitted = r.state === "revoked" ? r.outcome_unknown : r.state !== "pending";
|
|
2555
|
+
return admitted && scope.filesystem?.kind === "device";
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
findPermissionGrant(candidate) {
|
|
2559
|
+
if (!this.permissionGrants)
|
|
2560
|
+
throw new Error("Permission grants are unavailable");
|
|
2561
|
+
return this.permissionGrants.findForAdmission(candidate.binding);
|
|
2562
|
+
}
|
|
2563
|
+
async recordPermissionReview(candidate, verdict) {
|
|
2564
|
+
if (!this.permissionGrants)
|
|
2565
|
+
throw new Error("Permission grants are unavailable");
|
|
2566
|
+
await this.permissionGrants.assertCurrent(candidate.binding);
|
|
2567
|
+
const events = await this.deps.eventLog.appendIn(candidate.binding.conversationId, [
|
|
2568
|
+
{
|
|
2569
|
+
type: "permission_reviewed",
|
|
2570
|
+
runId: candidate.binding.runId,
|
|
2571
|
+
payload: {
|
|
2572
|
+
...candidate,
|
|
2573
|
+
outcome: verdict.decision,
|
|
2574
|
+
reason: verdict.reason,
|
|
2575
|
+
// the review model only for its own verdict: a fixed rule's deny, a rule ask (the review
|
|
2576
|
+
// model unmapped or not consulted) and the fail-closed ask are the rules'
|
|
2577
|
+
decisionSource: verdict.by === "classifier" ? "review-model" : "rule",
|
|
2578
|
+
},
|
|
2579
|
+
},
|
|
2580
|
+
]);
|
|
2581
|
+
const event = events[0];
|
|
2582
|
+
if (!event)
|
|
2583
|
+
throw new Error("The review event was not recorded");
|
|
2584
|
+
if (verdict.decision === "allow" && verdict.by === "classifier")
|
|
2585
|
+
await this.permissionGrants.issueLocked(candidate, {
|
|
2586
|
+
source: "review-model",
|
|
2587
|
+
reviewEventSeq: event.seq,
|
|
2588
|
+
decidedBy: null,
|
|
2589
|
+
});
|
|
2590
|
+
}
|
|
2591
|
+
/** The outcome of a call whose `command` approval was already asked (a resume). */
|
|
2592
|
+
settledCommandAsk(ask, toolKey) {
|
|
2593
|
+
const kind = reviewKindOf(toolKey);
|
|
2594
|
+
const rule = ask.command?.rule ?? null;
|
|
2595
|
+
if (ask.status === "pending")
|
|
2596
|
+
return { kind: "wait", wait: approvalWait(ask) };
|
|
2597
|
+
if (ask.status === "approved") {
|
|
2598
|
+
return {
|
|
2599
|
+
kind: "continue",
|
|
2600
|
+
commandAsk: ask,
|
|
2601
|
+
review: this.personAllowRecord(ask),
|
|
2602
|
+
workingRoot: ask.command?.workingRoot,
|
|
2603
|
+
reviewedAgainst: ask.command?.workingRoot,
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
if (ask.status === "denied") {
|
|
2607
|
+
const reason = ask.denyReason;
|
|
2608
|
+
return {
|
|
2609
|
+
kind: "result",
|
|
2610
|
+
content: commandDeclinedText(reason, kind),
|
|
2611
|
+
review: denyRecord("person", rule, reason ?? "The user declined."),
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
const text = ask.status === "expired" ? approvalExpiredText(approvalHours(ask)) : APPROVAL_CANCELLED_TEXT;
|
|
2615
|
+
return { kind: "result", content: text, review: denyRecord("person", rule, text) };
|
|
2616
|
+
}
|
|
2617
|
+
/**
|
|
2618
|
+
* The review record of a command (or write) the person allowed: its scope, and for a shell
|
|
2619
|
+
* command the SHA-256 of the text the ask holds in full, so an audit can match record and text.
|
|
2620
|
+
*/
|
|
2621
|
+
personAllowRecord(ask) {
|
|
2622
|
+
const binding = ask.command?.permissionCandidate?.binding;
|
|
2623
|
+
const escalated = ask.command?.permissionCandidate?.scopeKind === "sandbox-escalation";
|
|
2624
|
+
return {
|
|
2625
|
+
...(escalated ? { sandbox: "escalated" } : {}),
|
|
2626
|
+
...(binding
|
|
2627
|
+
? {
|
|
2628
|
+
profile: binding.profile,
|
|
2629
|
+
profileRevision: binding.profileRevision,
|
|
2630
|
+
scopeRevision: binding.scopeRevision,
|
|
2631
|
+
decisionSource: "human",
|
|
2632
|
+
}
|
|
2633
|
+
: {}),
|
|
2634
|
+
decision: "allow",
|
|
2635
|
+
by: "person",
|
|
2636
|
+
rule: ask.command?.rule ?? null,
|
|
2637
|
+
reason: ask.command?.reason ?? "The user allowed this call.",
|
|
2638
|
+
...((ask.scope === "once" || ask.scope === "session") && { scope: ask.scope }),
|
|
2639
|
+
...(ask.command !== null &&
|
|
2640
|
+
ask.command.kind === "command" && {
|
|
2641
|
+
commandHash: sha256Hex(ask.command.command),
|
|
2642
|
+
}),
|
|
2643
|
+
};
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* A foreground command's refused network hosts (network ask-to-allow spec §6.2, §6.8, §8.3):
|
|
2647
|
+
* the `network_blocked` event, the missing grants of an unattended run, and either notes for the
|
|
2648
|
+
* result written now, or (device-layer hosts worth asking) `network_blocked` and the call's
|
|
2649
|
+
* `tool.called` audit written now, the result kept in a network ask to the device's owner and
|
|
2650
|
+
* the run's wait. The kept result is the formatted one (≤ 16 KB: larger output is archived)
|
|
2651
|
+
* followed by the notes written now; it is written with the decision's note when the ask
|
|
2652
|
+
* settles (P-D2).
|
|
2653
|
+
*/
|
|
2654
|
+
async networkBlocked(ctx, callId, toolKey, input, report, pre, callAudit, result,
|
|
2655
|
+
/** Admission's verdict for this call: `available` when it may run outside the sandbox. */
|
|
2656
|
+
escalation,
|
|
2657
|
+
/** Why this call could not run outside the sandbox here (absent when it could). */
|
|
2658
|
+
escalationRefusal,
|
|
2659
|
+
/**
|
|
2660
|
+
* A device service's refusals (browser use spec §7.1): the extension whose service asked and
|
|
2661
|
+
* the call's attempt. Only "always" is offered; once approved the call runs again.
|
|
2662
|
+
*/
|
|
2663
|
+
service,
|
|
2664
|
+
/**
|
|
2665
|
+
* Plan-only pass: compute the `network_blocked` event and every refused host's note without
|
|
2666
|
+
* opening a second network ask (used when a loopback ask already takes this call's ask slot).
|
|
2667
|
+
*/
|
|
2668
|
+
planOnly) {
|
|
2669
|
+
const hosts = blockedEventHosts(report.blocked);
|
|
2670
|
+
if (hosts.length === 0)
|
|
2671
|
+
return { kind: "write", event: null, notes: [] };
|
|
2672
|
+
const event = {
|
|
2673
|
+
type: "network_blocked",
|
|
2674
|
+
runId: ctx.runId,
|
|
2675
|
+
idemKey: networkBlockedIdemKey(ctx.runId, callId),
|
|
2676
|
+
payload: { step: ctx.step, callId, hosts },
|
|
2677
|
+
};
|
|
2678
|
+
const network = this.deps.network;
|
|
2679
|
+
if (network === undefined)
|
|
2680
|
+
return { kind: "write", event, notes: [] };
|
|
2681
|
+
const run = hosts.some((h) => h.layer === "device")
|
|
2682
|
+
? await network.grants.runState(ctx.runId, report.deviceId)
|
|
2683
|
+
: null;
|
|
2684
|
+
const limits = this.config.get().sandbox.limits;
|
|
2685
|
+
// the ask offers what the device's provider enforces (device-provider spec §6.3): a run grant
|
|
2686
|
+
// only with per-operation hosts, "add to this device's list" only for hosts its own list can
|
|
2687
|
+
// take; a host neither reaches is unavailable, never asked about
|
|
2688
|
+
const sandbox = await network.sandbox?.hostRefusal({
|
|
2689
|
+
orgId: ctx.orgId,
|
|
2690
|
+
deviceId: report.deviceId,
|
|
2691
|
+
});
|
|
2692
|
+
const plan = planNetworkAsk(hosts, run, {
|
|
2693
|
+
unattended: ctx.unattended,
|
|
2694
|
+
outsideCeiling: (h) => orgHostOutsideCeiling(limits, h),
|
|
2695
|
+
...(sandbox !== undefined &&
|
|
2696
|
+
(service !== undefined
|
|
2697
|
+
? serviceAskTerms(sandbox)
|
|
2698
|
+
: {
|
|
2699
|
+
...deviceAskTerms(sandbox),
|
|
2700
|
+
// the hint follows admission's verdict for this call (never a recomputation), and
|
|
2701
|
+
// only the open network makes a private address the one thing escalation adds
|
|
2702
|
+
escalation: addressEscalationHint(escalation, sandbox.box.networkMode),
|
|
2703
|
+
})),
|
|
2704
|
+
...(service === undefined && escalationRefusal !== undefined && { escalationRefusal }),
|
|
2705
|
+
});
|
|
2706
|
+
if (ctx.unattended != null) {
|
|
2707
|
+
for (const key of plan.missingGrants) {
|
|
2708
|
+
await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, key);
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
const offer = plan.offer;
|
|
2712
|
+
const addressNote = plan.addressNote;
|
|
2713
|
+
if (plan.ask.length === 0 || offer === undefined)
|
|
2714
|
+
return { kind: "write", event, notes: plan.notes, addressNote };
|
|
2715
|
+
// plan-only pass (loopback ask takes this call's ask slot): keep every other refused host's
|
|
2716
|
+
// note without opening a second ask
|
|
2717
|
+
if (planOnly === true) {
|
|
2718
|
+
return {
|
|
2719
|
+
kind: "write",
|
|
2720
|
+
event,
|
|
2721
|
+
notes: [...plan.notes, serviceAskedNote(plan.ask.map((h) => h.host))],
|
|
2722
|
+
addressNote,
|
|
2723
|
+
};
|
|
2724
|
+
}
|
|
2725
|
+
// one ask per call: a service call that ran again after its ask is not asked again; only a
|
|
2726
|
+
// would-be ask is replaced, the plan's other notes (a host on the list, not yet applied) stay
|
|
2727
|
+
if (service !== undefined &&
|
|
2728
|
+
(await this.deps.approvals.networkForCall(ctx.runId, callId)) !== null) {
|
|
2729
|
+
return {
|
|
2730
|
+
kind: "write",
|
|
2731
|
+
event,
|
|
2732
|
+
notes: [...plan.notes, serviceAskedNote(plan.ask.map((h) => h.host))],
|
|
2733
|
+
addressNote,
|
|
2734
|
+
};
|
|
2735
|
+
}
|
|
2736
|
+
// the device's owner is the only person who may decide (spec §5.2)
|
|
2737
|
+
const owner = await this.deps.db
|
|
2738
|
+
.selectFrom("devices")
|
|
2739
|
+
.select("owner_account_id")
|
|
2740
|
+
.where("id", "=", report.deviceId)
|
|
2741
|
+
.where("org_id", "=", ctx.orgId)
|
|
2742
|
+
.where("deleted_at", "is", null)
|
|
2743
|
+
.executeTakeFirst();
|
|
2744
|
+
if (owner === undefined)
|
|
2745
|
+
return { kind: "write", event, notes: plan.notes, addressNote };
|
|
2746
|
+
let { content, outputId } = result;
|
|
2747
|
+
if (Buffer.byteLength(content, "utf8") > NETWORK_ASK_KEPT_MAX_BYTES && outputId === undefined) {
|
|
2748
|
+
// output under the spill threshold but over what an ask keeps: archive it after all
|
|
2749
|
+
const spilled = await spillIfLarge(result.text, { spillChars: 0, previewChars: this.config.get().tools.outputPreviewChars }, (c) => this.deps.outputs.save({
|
|
2750
|
+
orgId: ctx.orgId,
|
|
2751
|
+
conversationId: ctx.conversationId,
|
|
2752
|
+
callId,
|
|
2753
|
+
content: c,
|
|
2754
|
+
}));
|
|
2755
|
+
content = spilled.content;
|
|
2756
|
+
outputId = spilled.outputId;
|
|
2757
|
+
}
|
|
2758
|
+
const { text: _text, denialHint, ...rest } = result;
|
|
2759
|
+
const kept = {
|
|
2760
|
+
...rest,
|
|
2761
|
+
content: withNetworkNotes(clipKept(content) + denialHintFor(denialHint, addressNote), plan.notes),
|
|
2762
|
+
...(outputId !== undefined && { outputId }),
|
|
2763
|
+
};
|
|
2764
|
+
// the command ran: the call's display-only events (a `device_code`) and network_blocked with
|
|
2765
|
+
// its tool.called now, the result once the ask settles
|
|
2766
|
+
const written = await this.writeResultIn(ctx, callId, toolKey, { isError: result.isError }, [...pre, event], callAudit, []);
|
|
2767
|
+
await this.deps.eventLog.notify(ctx.conversationId, Math.max(...written.map((e) => e.seq)));
|
|
2768
|
+
const given = (input ?? {});
|
|
2769
|
+
const ask = await this.deps.approvals.requestNetwork({
|
|
2770
|
+
orgId: ctx.orgId,
|
|
2771
|
+
conversationId: ctx.conversationId,
|
|
2772
|
+
runId: ctx.runId,
|
|
2773
|
+
step: ctx.step,
|
|
2774
|
+
callId,
|
|
2775
|
+
requestedFor: owner.owner_account_id,
|
|
2776
|
+
toolKey,
|
|
2777
|
+
detail: service === undefined
|
|
2778
|
+
? {
|
|
2779
|
+
kind: "command",
|
|
2780
|
+
deviceId: report.deviceId,
|
|
2781
|
+
hosts: plan.ask,
|
|
2782
|
+
command: typeof given.command === "string" ? clipText(given.command, 2000) : "",
|
|
2783
|
+
description: typeof given.description === "string" ? given.description : null,
|
|
2784
|
+
appliesAt: offer.appliesAt,
|
|
2785
|
+
result: kept,
|
|
2786
|
+
}
|
|
2787
|
+
: {
|
|
2788
|
+
kind: "service",
|
|
2789
|
+
deviceId: report.deviceId,
|
|
2790
|
+
service: service.name,
|
|
2791
|
+
url: service.url,
|
|
2792
|
+
hosts: plan.ask.map((h) => h.host),
|
|
2793
|
+
attempt: service.attempt,
|
|
2794
|
+
appliesAt: offer.appliesAt,
|
|
2795
|
+
result: kept,
|
|
2796
|
+
},
|
|
2797
|
+
scopes: offer.scopes,
|
|
2798
|
+
});
|
|
2799
|
+
return { kind: "wait", wait: approvalWait(ask), content: kept.content };
|
|
2800
|
+
}
|
|
2801
|
+
/** The call's live loopback port grant (null: none, ended, or no grants service). */
|
|
2802
|
+
async loopbackGrantOf(runId, callId) {
|
|
2803
|
+
return (await this.loopbackGrants?.forCall(runId, callId)) ?? null;
|
|
2804
|
+
}
|
|
2805
|
+
/**
|
|
2806
|
+
* The attempt that recorded a ready-grant loopback rerun for this call, or null when none did.
|
|
2807
|
+
*/
|
|
2808
|
+
async readyLoopbackRerunOf(conversationId, runId, callId) {
|
|
2809
|
+
const ev = await this.deps.eventLog.findByIdem(conversationId, loopbackReadyRerunIdemKey(runId, callId));
|
|
2810
|
+
return ev?.type === "permission_reviewed"
|
|
2811
|
+
? (ev.payload.loopback?.readyRerunAttempt ?? null)
|
|
2812
|
+
: null;
|
|
2813
|
+
}
|
|
2814
|
+
/**
|
|
2815
|
+
* A device service's loopback refusal (browser loopback port grants): the port of the person's
|
|
2816
|
+
* own device a service of an extension declaring `permissions.deviceAccess.loopbackPorts` was
|
|
2817
|
+
* refused. Refused by the device's ceilings, its provider or an unattended run → a note
|
|
2818
|
+
* (`write`). A live grant the service had not applied yet → the call runs again, once. Else the
|
|
2819
|
+
* conversation's permission profile decides (`approverForCrossing`, crossing `loopback-port`):
|
|
2820
|
+
* Full access grants it, the review model reviews it (allow grants, deny is a note, an unsure
|
|
2821
|
+
* answer asks), the person is asked (the run waits, the result kept in the ask). A grant is
|
|
2822
|
+
* written with its `permission_reviewed`, the call's display events and its `tool.called` in one
|
|
2823
|
+
* transaction, naming this attempt: the call then runs again in the next one (`rerun`), also
|
|
2824
|
+
* after a crash. `none`: not decidable here (no device of the call's account, a hand-built
|
|
2825
|
+
* pipeline, no facts): the host stays an address host with its note.
|
|
2826
|
+
*/
|
|
2827
|
+
async loopbackBlocked(ctx, call, tool, input, toolKey, report, attempt, kept, rerunning, pre, callAudit) {
|
|
2828
|
+
const grants = this.loopbackGrants;
|
|
2829
|
+
const sandboxFacts = this.permissionFacts;
|
|
2830
|
+
const authority = this.permissionAuthority;
|
|
2831
|
+
const devices = this.deps.devices;
|
|
2832
|
+
if (!grants || !sandboxFacts || !authority || !devices)
|
|
2833
|
+
return { kind: "none" };
|
|
2834
|
+
// only the device the call works in, and only its owner's own run
|
|
2835
|
+
const device = await devices.reviewFacts(ctx.orgId, ctx.parent?.rootConversationId ?? ctx.conversationId, ctx.conversationId);
|
|
2836
|
+
if (!device || device.deviceId !== report.deviceId || device.ownerAccountId !== ctx.accountId)
|
|
2837
|
+
return { kind: "none" };
|
|
2838
|
+
const use = {
|
|
2839
|
+
orgId: ctx.orgId,
|
|
2840
|
+
deviceId: device.deviceId,
|
|
2841
|
+
holderConversationId: ctx.conversationId,
|
|
2842
|
+
actor: { accountId: ctx.accountId, conversationId: ctx.conversationId, runId: ctx.runId },
|
|
2843
|
+
};
|
|
2844
|
+
let facts;
|
|
2845
|
+
try {
|
|
2846
|
+
facts = await authority.previewCall(use, { runId: ctx.runId, callId: call.id }, ctx.signal);
|
|
2847
|
+
}
|
|
2848
|
+
catch (err) {
|
|
2849
|
+
ctx.signal.throwIfAborted();
|
|
2850
|
+
this.deps.log.warn("cannot read the facts of a loopback refusal; noted as an address", {
|
|
2851
|
+
runId: ctx.runId,
|
|
2852
|
+
callId: call.id,
|
|
2853
|
+
err,
|
|
2854
|
+
});
|
|
2855
|
+
return { kind: "none" };
|
|
2856
|
+
}
|
|
2857
|
+
const { serviceId, host, port } = report.loopback;
|
|
2858
|
+
const hp = host.includes(":") ? `[${host}]:${port}` : `${host}:${port}`;
|
|
2859
|
+
// the effective profile's facts: an unattended run's escalation refusal names it
|
|
2860
|
+
const sandbox = await sandboxFacts.deviceSandboxFacts(ctx.orgId, device.deviceId);
|
|
2861
|
+
const plan = planLoopbackAsk({ host, port }, loopbackRefusal(sandbox.box, sandbox.support, facts.escalationRefusal), facts.escalationRefusal == null);
|
|
2862
|
+
if (plan.kind === "none")
|
|
2863
|
+
return { kind: "none" };
|
|
2864
|
+
// refused before the live grants are read: an unattended run is never approved by a grant
|
|
2865
|
+
// the person made earlier in the tree (no grant, no rerun). The device's carve-out stays the
|
|
2866
|
+
// union of the service's live grants; refusing an unattended tab is the browser's check
|
|
2867
|
+
if (plan.kind === "refused")
|
|
2868
|
+
return { kind: "write", notes: [plan.note] };
|
|
2869
|
+
const key = {
|
|
2870
|
+
orgId: ctx.orgId,
|
|
2871
|
+
deviceId: device.deviceId,
|
|
2872
|
+
serviceId,
|
|
2873
|
+
rootConversationId: facts.rootConversationId,
|
|
2874
|
+
port,
|
|
2875
|
+
};
|
|
2876
|
+
const live = await grants.liveForRoot(ctx.orgId, device.deviceId, serviceId, facts.rootConversationId);
|
|
2877
|
+
const binding = {
|
|
2878
|
+
orgId: facts.orgId,
|
|
2879
|
+
rootConversationId: facts.rootConversationId,
|
|
2880
|
+
conversationId: facts.conversationId,
|
|
2881
|
+
deviceId: facts.deviceId,
|
|
2882
|
+
accountId: facts.accountId,
|
|
2883
|
+
runId: facts.runId,
|
|
2884
|
+
callId: facts.callId,
|
|
2885
|
+
toolKey: tool.key,
|
|
2886
|
+
specHash: tool.specHash,
|
|
2887
|
+
callInputHash: permissionScopeHash(call.input),
|
|
2888
|
+
resolvedInputHash: permissionScopeHash(input),
|
|
2889
|
+
profile: facts.profile,
|
|
2890
|
+
profileRevision: facts.profileRevision,
|
|
2891
|
+
scopeRevision: facts.scopeRevision,
|
|
2892
|
+
authorityRevision: facts.authorityRevision,
|
|
2893
|
+
};
|
|
2894
|
+
if (live.some((g) => g.port === port)) {
|
|
2895
|
+
// granted already (the panel, an earlier call): the service had not applied it yet, so the
|
|
2896
|
+
// call runs again once; refused again (or granted to this call), its result stands
|
|
2897
|
+
if (rerunning || (await grants.forCall(ctx.runId, call.id)) !== null)
|
|
2898
|
+
return { kind: "write", notes: [loopbackNotAppliedNote(port)] };
|
|
2899
|
+
const readyCandidate = {
|
|
2900
|
+
binding,
|
|
2901
|
+
permissionScope: { writeDirectories: [], hosts: [] },
|
|
2902
|
+
scopeKind: "loopback-port",
|
|
2903
|
+
loopback: { service: serviceId, port, readyRerunAttempt: attempt },
|
|
2904
|
+
};
|
|
2905
|
+
const readyEvent = {
|
|
2906
|
+
type: "permission_reviewed",
|
|
2907
|
+
runId: ctx.runId,
|
|
2908
|
+
idemKey: loopbackReadyRerunIdemKey(ctx.runId, call.id),
|
|
2909
|
+
payload: {
|
|
2910
|
+
...readyCandidate,
|
|
2911
|
+
candidateHash: permissionScopeHash(readyCandidate),
|
|
2912
|
+
outcome: "allow",
|
|
2913
|
+
reason: "Loopback port already granted for this conversation; retrying after the device applies it.",
|
|
2914
|
+
decisionSource: "rule",
|
|
2915
|
+
crossing: "loopback-port",
|
|
2916
|
+
},
|
|
2917
|
+
};
|
|
2918
|
+
await this.writeResultIn(ctx, call.id, toolKey, kept, [readyEvent, ...pre], callAudit, []);
|
|
2919
|
+
return { kind: "rerun", notes: [] };
|
|
2920
|
+
}
|
|
2921
|
+
// a call that ran again after its grant is not decided again (the port was closed meanwhile)
|
|
2922
|
+
if (rerunning)
|
|
2923
|
+
return { kind: "write", notes: [serviceAskedNote([hp])] };
|
|
2924
|
+
const reviewed = (outcome, reason, decisionSource) => {
|
|
2925
|
+
const candidate = {
|
|
2926
|
+
binding,
|
|
2927
|
+
permissionScope: { writeDirectories: [], hosts: [] },
|
|
2928
|
+
scopeKind: "loopback-port",
|
|
2929
|
+
loopback: { service: serviceId, port },
|
|
2930
|
+
};
|
|
2931
|
+
return {
|
|
2932
|
+
type: "permission_reviewed",
|
|
2933
|
+
runId: ctx.runId,
|
|
2934
|
+
idemKey: `permission_reviewed:loopback:${ctx.runId}:${call.id}:${attempt}`,
|
|
2935
|
+
payload: {
|
|
2936
|
+
...candidate,
|
|
2937
|
+
candidateHash: permissionScopeHash(candidate),
|
|
2938
|
+
outcome,
|
|
2939
|
+
reason,
|
|
2940
|
+
decisionSource,
|
|
2941
|
+
crossing: "loopback-port",
|
|
2942
|
+
},
|
|
2943
|
+
};
|
|
2944
|
+
};
|
|
2945
|
+
const grant = async (source, reason, decisionSource = source) => {
|
|
2946
|
+
try {
|
|
2947
|
+
await this.grantLoopbackIn(ctx, call.id, toolKey, kept, key, { runId: ctx.runId, callId: call.id, attempt }, source, [reviewed("allow", reason, decisionSource), ...pre], callAudit);
|
|
2948
|
+
}
|
|
2949
|
+
catch (e) {
|
|
2950
|
+
// the service holds the most ports it may: the note says so, nothing was granted
|
|
2951
|
+
if (e instanceof LoopbackLimitError)
|
|
2952
|
+
return {
|
|
2953
|
+
kind: "write",
|
|
2954
|
+
notes: [`[network] ${hp} is a local port on the device. ${e.message}`],
|
|
2955
|
+
};
|
|
2956
|
+
throw e;
|
|
2957
|
+
}
|
|
2958
|
+
return { kind: "rerun", notes: [loopbackGrantedNote(port)] };
|
|
2959
|
+
};
|
|
2960
|
+
const approver = approverForCrossing({
|
|
2961
|
+
profile: facts.profile,
|
|
2962
|
+
crossing: "loopback-port",
|
|
2963
|
+
subAgent: ctx.parent !== undefined,
|
|
2964
|
+
});
|
|
2965
|
+
if (approver === "none")
|
|
2966
|
+
return grant("full-access", LOOPBACK_FULL_ACCESS_REASON);
|
|
2967
|
+
if (approver === "review-model" && this.deps.review?.reviewLoopbackPort) {
|
|
2968
|
+
const verdict = await this.deps.review.reviewLoopbackPort({
|
|
2969
|
+
orgId: ctx.orgId,
|
|
2970
|
+
conversationId: ctx.conversationId,
|
|
2971
|
+
runId: ctx.runId,
|
|
2972
|
+
step: ctx.step,
|
|
2973
|
+
callId: call.id,
|
|
2974
|
+
signal: ctx.signal,
|
|
2975
|
+
accountId: ctx.accountId,
|
|
2976
|
+
agentId: ctx.agentId,
|
|
2977
|
+
agentVersion: ctx.agentVersion,
|
|
2978
|
+
conversationKind: ctx.conversationKind,
|
|
2979
|
+
...reviewParentOf(ctx.parent),
|
|
2980
|
+
profile: facts.profile,
|
|
2981
|
+
attended: !facts.unattended,
|
|
2982
|
+
refusal: null,
|
|
2983
|
+
service: serviceId,
|
|
2984
|
+
port,
|
|
2985
|
+
url: report.url,
|
|
2986
|
+
database: plan.database,
|
|
2987
|
+
});
|
|
2988
|
+
const source = verdict.by === "classifier" ? "review-model" : "rule";
|
|
2989
|
+
// the review path's grant; its record names who allowed it (a rule allows only under Full
|
|
2990
|
+
// access, decided above, so a rule's allow here is not expected but recorded as one)
|
|
2991
|
+
if (verdict.decision === "allow")
|
|
2992
|
+
return grant("review-model", verdict.reason, source);
|
|
2993
|
+
if (verdict.decision === "deny") {
|
|
2994
|
+
await this.recordLoopbackReview(ctx, reviewed("deny", verdict.reason, source));
|
|
2995
|
+
return { kind: "write", notes: [loopbackReviewDeniedNote(port, verdict.reason)] };
|
|
2996
|
+
}
|
|
2997
|
+
await this.recordLoopbackReview(ctx, reviewed("ask", verdict.reason, source));
|
|
2998
|
+
}
|
|
2999
|
+
// the person: the device's owner, within the run's network asks; one ask per call (a call
|
|
3000
|
+
// that ran again after its network ask is not asked again)
|
|
3001
|
+
if ((await this.deps.approvals.networkForCall(ctx.runId, call.id)) !== null)
|
|
3002
|
+
return { kind: "write", notes: [serviceAskedNote([hp])] };
|
|
3003
|
+
const run = await this.deps.network?.grants.runState(ctx.runId, device.deviceId);
|
|
3004
|
+
if (run?.pending === true)
|
|
3005
|
+
return { kind: "write", notes: [otherAskPendingNote([hp])] };
|
|
3006
|
+
if ((run?.asks ?? 0) >= MAX_NETWORK_ASKS_PER_RUN)
|
|
3007
|
+
return { kind: "write", notes: [tooManyNote([hp])] };
|
|
3008
|
+
// plan-only pass for other refused hosts reported alongside the loopback port, so their notes
|
|
3009
|
+
// and `network_blocked` event are kept when the loopback ask settles
|
|
3010
|
+
let otherEvent = null;
|
|
3011
|
+
let otherNotes = [];
|
|
3012
|
+
if (report.otherHosts.length > 0) {
|
|
3013
|
+
const other = await this.networkBlocked(ctx, call.id, toolKey, input, {
|
|
3014
|
+
deviceId: report.deviceId,
|
|
3015
|
+
blocked: report.otherHosts.map(({ host, layer }) => ({ host, port: 443, layer })),
|
|
3016
|
+
}, pre, callAudit, kept, undefined, undefined, {
|
|
3017
|
+
name: tool.source.kind === "plugin" ? tool.source.plugin : tool.key,
|
|
3018
|
+
attempt,
|
|
3019
|
+
url: report.url,
|
|
3020
|
+
}, true);
|
|
3021
|
+
if (other.kind === "write") {
|
|
3022
|
+
otherEvent = other.event;
|
|
3023
|
+
otherNotes = other.notes;
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
const keptWithOther = otherNotes.length === 0
|
|
3027
|
+
? kept
|
|
3028
|
+
: { ...kept, content: withNetworkNotes(kept.content, otherNotes) };
|
|
3029
|
+
const { content, outputId } = await this.keptContent(ctx, call.id, keptWithOther);
|
|
3030
|
+
const { text: _text, denialHint: _hint, ...rest } = keptWithOther;
|
|
3031
|
+
const result = {
|
|
3032
|
+
...rest,
|
|
3033
|
+
content: clipKept(content),
|
|
3034
|
+
...(outputId !== undefined && { outputId }),
|
|
3035
|
+
};
|
|
3036
|
+
// the service's call ran: its display-only events and tool.called now, the result once the
|
|
3037
|
+
// ask settles
|
|
3038
|
+
const written = await this.writeResultIn(ctx, call.id, toolKey, keptWithOther, otherEvent !== null ? [...pre, otherEvent] : [...pre], callAudit, []);
|
|
3039
|
+
if (written.length > 0)
|
|
3040
|
+
await this.deps.eventLog.notify(ctx.conversationId, Math.max(...written.map((e) => e.seq)));
|
|
3041
|
+
const ask = await this.deps.approvals.requestLoopback({
|
|
3042
|
+
orgId: ctx.orgId,
|
|
3043
|
+
conversationId: ctx.conversationId,
|
|
3044
|
+
runId: ctx.runId,
|
|
3045
|
+
step: ctx.step,
|
|
3046
|
+
callId: call.id,
|
|
3047
|
+
requestedFor: device.ownerAccountId,
|
|
3048
|
+
toolKey,
|
|
3049
|
+
detail: {
|
|
3050
|
+
kind: "loopback",
|
|
3051
|
+
deviceId: device.deviceId,
|
|
3052
|
+
service: serviceId,
|
|
3053
|
+
url: report.url,
|
|
3054
|
+
port,
|
|
3055
|
+
database: plan.database,
|
|
3056
|
+
attempt,
|
|
3057
|
+
result,
|
|
3058
|
+
},
|
|
3059
|
+
});
|
|
3060
|
+
return { kind: "wait", wait: approvalWait(ask), content: loopbackPendingNote(host, port) };
|
|
3061
|
+
}
|
|
3062
|
+
async siteRetryAllowed(ctx, callId, tool, input, site) {
|
|
3063
|
+
if (tool.source.kind !== "plugin" ||
|
|
3064
|
+
ctx.ownerAccountId !== ctx.accountId ||
|
|
3065
|
+
unattendedRules(ctx.unattended))
|
|
3066
|
+
return false;
|
|
3067
|
+
const plugin = tool.source.plugin;
|
|
3068
|
+
const instance = this.extensions?.current(plugin);
|
|
3069
|
+
if (instance?.manifest.permissions?.deviceAccess?.siteAccess !== true ||
|
|
3070
|
+
!(await siteAccessInstallActive(this.deps.db, plugin, instance.sha256)))
|
|
3071
|
+
return false;
|
|
3072
|
+
const device = await this.deps.devices?.reviewFacts(ctx.orgId, ctx.parent?.rootConversationId ?? ctx.conversationId, ctx.conversationId);
|
|
3073
|
+
if (device?.deviceId !== site.deviceId || device.ownerAccountId !== ctx.accountId)
|
|
3074
|
+
return false;
|
|
3075
|
+
const facts = await this.siteReviewFacts(ctx, callId, site.deviceId);
|
|
3076
|
+
if (facts === null || facts.unattended)
|
|
3077
|
+
return false;
|
|
3078
|
+
const binding = site.binding;
|
|
3079
|
+
if (binding === undefined)
|
|
3080
|
+
return site.approval.source === "human";
|
|
3081
|
+
return (binding.resolvedInputHash === permissionScopeHash(input) &&
|
|
3082
|
+
facts.rootConversationId === binding.rootConversationId &&
|
|
3083
|
+
facts.profile === binding.profile &&
|
|
3084
|
+
facts.profileRevision === binding.profileRevision &&
|
|
3085
|
+
facts.scopeRevision === binding.scopeRevision &&
|
|
3086
|
+
facts.authorityRevision === binding.authorityRevision);
|
|
3087
|
+
}
|
|
3088
|
+
async siteReviewFacts(ctx, callId, deviceId) {
|
|
3089
|
+
const authority = this.permissionAuthority;
|
|
3090
|
+
if (!authority)
|
|
3091
|
+
return null;
|
|
3092
|
+
return authority
|
|
3093
|
+
.previewCall({
|
|
3094
|
+
orgId: ctx.orgId,
|
|
3095
|
+
deviceId,
|
|
3096
|
+
holderConversationId: ctx.conversationId,
|
|
3097
|
+
actor: { accountId: ctx.accountId, conversationId: ctx.conversationId, runId: ctx.runId },
|
|
3098
|
+
}, { runId: ctx.runId, callId }, ctx.signal, "site-access")
|
|
3099
|
+
.catch((err) => {
|
|
3100
|
+
ctx.signal.throwIfAborted();
|
|
3101
|
+
this.deps.log.warn("Site access facts unavailable", { runId: ctx.runId, callId, err });
|
|
3102
|
+
return null;
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
async siteRerunOf(ctx, callId) {
|
|
3106
|
+
const event = await this.deps.eventLog.findByIdem(ctx.conversationId, siteReviewIdemKey(ctx.runId, callId));
|
|
3107
|
+
if (event?.type !== "permission_reviewed")
|
|
3108
|
+
return null;
|
|
3109
|
+
const { site, outcome, decisionSource, binding } = event.payload;
|
|
3110
|
+
if (outcome !== "allow" || site === undefined || decisionSource === "rule")
|
|
3111
|
+
return null;
|
|
3112
|
+
return {
|
|
3113
|
+
attempt: site.attempt,
|
|
3114
|
+
toolSpecHash: binding.specHash,
|
|
3115
|
+
callInputHash: binding.callInputHash,
|
|
3116
|
+
deviceId: binding.deviceId,
|
|
3117
|
+
binding,
|
|
3118
|
+
approval: {
|
|
3119
|
+
action: site.action,
|
|
3120
|
+
origin: site.origin,
|
|
3121
|
+
detailSha256: site.detailSha256,
|
|
3122
|
+
source: decisionSource,
|
|
3123
|
+
},
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
async handleSiteAccess(ctx, call, tool, input, report, attempt, kept, pre, callAudit, rerunning) {
|
|
3127
|
+
const write = (note) => ({ kind: "write", note });
|
|
3128
|
+
if (rerunning !== undefined ||
|
|
3129
|
+
(await this.deps.eventLog.findByIdem(ctx.conversationId, siteReviewIdemKey(ctx.runId, call.id))))
|
|
3130
|
+
return write("The approved site action no longer matches the active page. It did not run. Call the tool again to review the current page.");
|
|
3131
|
+
if (ctx.ownerAccountId !== ctx.accountId ||
|
|
3132
|
+
tool.source.kind !== "plugin" ||
|
|
3133
|
+
tool.source.plugin !== report.extension ||
|
|
3134
|
+
!this.siteGrants) {
|
|
3135
|
+
return write("Site access is available only to the conversation's owner on their device.");
|
|
3136
|
+
}
|
|
3137
|
+
const facts = await this.siteReviewFacts(ctx, call.id, report.deviceId);
|
|
3138
|
+
if (facts === null)
|
|
3139
|
+
return write("Site access could not be verified. It did not run.");
|
|
3140
|
+
if (facts.unattended) {
|
|
3141
|
+
return write("This site action needs the user's approval, which an unattended run cannot get. It did not run. Use browser_snapshot or browser_network to read the page.");
|
|
3142
|
+
}
|
|
3143
|
+
const verdict = await this.deps.review?.reviewSiteAccess?.({
|
|
3144
|
+
orgId: ctx.orgId,
|
|
3145
|
+
conversationId: ctx.conversationId,
|
|
3146
|
+
runId: ctx.runId,
|
|
3147
|
+
step: ctx.step,
|
|
3148
|
+
callId: call.id,
|
|
3149
|
+
signal: ctx.signal,
|
|
3150
|
+
accountId: ctx.accountId,
|
|
3151
|
+
agentId: ctx.agentId,
|
|
3152
|
+
agentVersion: ctx.agentVersion,
|
|
3153
|
+
conversationKind: ctx.conversationKind,
|
|
3154
|
+
...reviewParentOf(ctx.parent),
|
|
3155
|
+
profile: facts.profile,
|
|
3156
|
+
attended: true,
|
|
3157
|
+
refusal: null,
|
|
3158
|
+
service: report.serviceId,
|
|
3159
|
+
origin: report.origin,
|
|
3160
|
+
action: report.action,
|
|
3161
|
+
detail: report.detail,
|
|
3162
|
+
});
|
|
3163
|
+
if (!verdict)
|
|
3164
|
+
return write("Site approval is unavailable. The action did not run.");
|
|
3165
|
+
const detailSha256 = siteAccessDetailHash(report.detail);
|
|
3166
|
+
const source = verdict.approver === "none"
|
|
3167
|
+
? "full-access"
|
|
3168
|
+
: verdict.by === "classifier"
|
|
3169
|
+
? "review-model"
|
|
3170
|
+
: "rule";
|
|
3171
|
+
const candidate = {
|
|
3172
|
+
binding: {
|
|
3173
|
+
orgId: facts.orgId,
|
|
3174
|
+
rootConversationId: facts.rootConversationId,
|
|
3175
|
+
conversationId: facts.conversationId,
|
|
3176
|
+
deviceId: facts.deviceId,
|
|
3177
|
+
accountId: facts.accountId,
|
|
3178
|
+
runId: facts.runId,
|
|
3179
|
+
callId: facts.callId,
|
|
3180
|
+
toolKey: tool.key,
|
|
3181
|
+
specHash: tool.specHash,
|
|
3182
|
+
callInputHash: permissionScopeHash(call.input),
|
|
3183
|
+
resolvedInputHash: permissionScopeHash(input),
|
|
3184
|
+
profile: facts.profile,
|
|
3185
|
+
profileRevision: facts.profileRevision,
|
|
3186
|
+
scopeRevision: facts.scopeRevision,
|
|
3187
|
+
authorityRevision: facts.authorityRevision,
|
|
3188
|
+
},
|
|
3189
|
+
permissionScope: { writeDirectories: [], hosts: [] },
|
|
3190
|
+
scopeKind: "site-access",
|
|
3191
|
+
site: {
|
|
3192
|
+
service: report.serviceId,
|
|
3193
|
+
action: report.action,
|
|
3194
|
+
origin: report.origin,
|
|
3195
|
+
detailSha256,
|
|
3196
|
+
attempt,
|
|
3197
|
+
},
|
|
3198
|
+
};
|
|
3199
|
+
const review = {
|
|
3200
|
+
type: "permission_reviewed",
|
|
3201
|
+
runId: ctx.runId,
|
|
3202
|
+
idemKey: siteReviewIdemKey(ctx.runId, call.id),
|
|
3203
|
+
payload: {
|
|
3204
|
+
...candidate,
|
|
3205
|
+
candidateHash: permissionScopeHash(candidate),
|
|
3206
|
+
outcome: verdict.decision,
|
|
3207
|
+
reason: verdict.reason,
|
|
3208
|
+
decisionSource: source,
|
|
3209
|
+
crossing: "site-access",
|
|
3210
|
+
},
|
|
3211
|
+
};
|
|
3212
|
+
if (verdict.decision === "deny") {
|
|
3213
|
+
await this.recordLoopbackReview(ctx, review);
|
|
3214
|
+
return write(`The site action on ${report.origin} was denied. ${verdict.reason}`);
|
|
3215
|
+
}
|
|
3216
|
+
if (verdict.decision === "allow" && source !== "rule") {
|
|
3217
|
+
await this.writeResultIn(ctx, call.id, tool.key, kept, [review, ...pre], callAudit, [
|
|
3218
|
+
{
|
|
3219
|
+
orgId: ctx.orgId,
|
|
3220
|
+
actorAccountId: ctx.accountId,
|
|
3221
|
+
action: "device.site_access_decided",
|
|
3222
|
+
target: report.deviceId,
|
|
3223
|
+
detail: {
|
|
3224
|
+
action: report.action,
|
|
3225
|
+
origin: report.origin,
|
|
3226
|
+
detailSha256,
|
|
3227
|
+
source,
|
|
3228
|
+
outcome: "once",
|
|
3229
|
+
},
|
|
3230
|
+
},
|
|
3231
|
+
]);
|
|
3232
|
+
return {
|
|
3233
|
+
kind: "rerun",
|
|
3234
|
+
site: {
|
|
3235
|
+
attempt,
|
|
3236
|
+
toolSpecHash: tool.specHash,
|
|
3237
|
+
callInputHash: permissionScopeHash(call.input),
|
|
3238
|
+
deviceId: report.deviceId,
|
|
3239
|
+
binding: candidate.binding,
|
|
3240
|
+
approval: { action: report.action, origin: report.origin, detailSha256, source },
|
|
3241
|
+
},
|
|
3242
|
+
};
|
|
3243
|
+
}
|
|
3244
|
+
const prior = await this.deps.approvals.networkForCall(ctx.runId, call.id);
|
|
3245
|
+
const run = await this.deps.network?.grants.runState(ctx.runId, report.deviceId);
|
|
3246
|
+
if (prior !== null || run?.pending || (run?.asks ?? 0) >= MAX_NETWORK_ASKS_PER_RUN)
|
|
3247
|
+
return write("The action did not run. This call cannot request another approval.");
|
|
3248
|
+
const canRemember = verdict.approver === "person" &&
|
|
3249
|
+
ctx.parent === undefined &&
|
|
3250
|
+
(await this.siteGrants.canGrant({
|
|
3251
|
+
orgId: ctx.orgId,
|
|
3252
|
+
deviceId: report.deviceId,
|
|
3253
|
+
serviceId: report.serviceId,
|
|
3254
|
+
rootConversationId: facts.rootConversationId,
|
|
3255
|
+
origin: report.origin,
|
|
3256
|
+
action: report.action,
|
|
3257
|
+
}));
|
|
3258
|
+
const { content, outputId } = await this.keptContent(ctx, call.id, kept);
|
|
3259
|
+
const { text: _text, ...result } = kept;
|
|
3260
|
+
const ask = await this.deps.approvals.requestSiteAccess({
|
|
3261
|
+
orgId: ctx.orgId,
|
|
3262
|
+
conversationId: ctx.conversationId,
|
|
3263
|
+
runId: ctx.runId,
|
|
3264
|
+
step: ctx.step,
|
|
3265
|
+
callId: call.id,
|
|
3266
|
+
requestedFor: ctx.accountId,
|
|
3267
|
+
toolKey: tool.key,
|
|
3268
|
+
scopes: canRemember ? ["once", "session"] : ["once"],
|
|
3269
|
+
detail: {
|
|
3270
|
+
kind: "site",
|
|
3271
|
+
deviceId: report.deviceId,
|
|
3272
|
+
extension: report.extension,
|
|
3273
|
+
service: report.serviceId,
|
|
3274
|
+
rootConversationId: facts.rootConversationId,
|
|
3275
|
+
origin: report.origin,
|
|
3276
|
+
action: report.action,
|
|
3277
|
+
detail: report.detail,
|
|
3278
|
+
attempt,
|
|
3279
|
+
toolSpecHash: tool.specHash,
|
|
3280
|
+
callInputHash: permissionScopeHash(call.input),
|
|
3281
|
+
result: {
|
|
3282
|
+
...result,
|
|
3283
|
+
content: clipKept(content),
|
|
3284
|
+
...(outputId !== undefined && { outputId }),
|
|
3285
|
+
},
|
|
3286
|
+
},
|
|
3287
|
+
}, async () => {
|
|
3288
|
+
await this.writeResultIn(ctx, call.id, tool.key, kept, [review, ...pre], callAudit, []);
|
|
3289
|
+
});
|
|
3290
|
+
return { kind: "wait", wait: approvalWait(ask) };
|
|
3291
|
+
}
|
|
3292
|
+
/**
|
|
3293
|
+
* A loopback port grant to this call's attempt and what goes with it, in one transaction: the
|
|
3294
|
+
* grant first (it reads the root conversation `FOR SHARE`, before the conversation row the
|
|
3295
|
+
* appends lock), then `permission_reviewed`, the call's display-only events and its
|
|
3296
|
+
* `tool.called`. The call then runs again in the next attempt.
|
|
3297
|
+
*/
|
|
3298
|
+
async grantLoopbackIn(ctx, callId, toolKey, r, key, call, source, events, callAudit) {
|
|
3299
|
+
const grants = this.loopbackGrants;
|
|
3300
|
+
if (!grants)
|
|
3301
|
+
throw new Error("Loopback grants are unavailable");
|
|
3302
|
+
await grants.grantIn(key, { source, actorAccountId: null, call });
|
|
3303
|
+
await this.writeResultIn(ctx, callId, toolKey, r, events, callAudit, []);
|
|
3304
|
+
}
|
|
3305
|
+
/** A review model's loopback verdict that grants nothing (a deny, an unsure answer). */
|
|
3306
|
+
async recordLoopbackReview(ctx, event) {
|
|
3307
|
+
await this.deps.eventLog.appendIn(ctx.conversationId, [event]);
|
|
3308
|
+
}
|
|
3309
|
+
/**
|
|
3310
|
+
* A kept result's content within what an ask keeps: output under the spill threshold but over
|
|
3311
|
+
* {@link NETWORK_ASK_KEPT_MAX_BYTES} is archived after all.
|
|
3312
|
+
*/
|
|
3313
|
+
async keptContent(ctx, callId, result) {
|
|
3314
|
+
const { content, outputId } = result;
|
|
3315
|
+
if (Buffer.byteLength(content, "utf8") <= NETWORK_ASK_KEPT_MAX_BYTES || outputId !== undefined)
|
|
3316
|
+
return { content, outputId };
|
|
3317
|
+
const spilled = await spillIfLarge(result.text, { spillChars: 0, previewChars: this.config.get().tools.outputPreviewChars }, (c) => this.deps.outputs.save({
|
|
3318
|
+
orgId: ctx.orgId,
|
|
3319
|
+
conversationId: ctx.conversationId,
|
|
3320
|
+
callId,
|
|
3321
|
+
content: c,
|
|
3322
|
+
}));
|
|
3323
|
+
return { content: spilled.content, outputId: spilled.outputId };
|
|
3324
|
+
}
|
|
3325
|
+
/**
|
|
3326
|
+
* A device service's report (the call scope, browser use spec §7.1) on the device the call's
|
|
3327
|
+
* conversation works in (the root conversation's for a sub-agent, as the sandbox tools resolve
|
|
3328
|
+
* it): a report that names no device is about that one; a report naming another device id (the
|
|
3329
|
+
* conversation moved to another device during the call) is ignored with a warning, never asked
|
|
3330
|
+
* about.
|
|
3331
|
+
*/
|
|
3332
|
+
async ownDeviceReport(ctx, toolKey, blocked) {
|
|
3333
|
+
if (blocked === undefined)
|
|
3334
|
+
return undefined;
|
|
3335
|
+
const conv = await this.deps.db
|
|
3336
|
+
.selectFrom("conversations")
|
|
3337
|
+
.select("device_id")
|
|
3338
|
+
.where("id", "=", ctx.parent?.rootConversationId ?? ctx.conversationId)
|
|
3339
|
+
.where("org_id", "=", ctx.orgId)
|
|
3340
|
+
.executeTakeFirst();
|
|
3341
|
+
const deviceId = conv?.device_id ?? null;
|
|
3342
|
+
if (deviceId !== null && (blocked.deviceId === null || blocked.deviceId === deviceId))
|
|
3343
|
+
return { ...blocked, deviceId };
|
|
3344
|
+
this.deps.log.warn("ignored refused hosts reported for another device than the call's", {
|
|
3345
|
+
runId: ctx.runId,
|
|
3346
|
+
toolKey,
|
|
3347
|
+
deviceId: blocked.deviceId,
|
|
3348
|
+
});
|
|
3349
|
+
return undefined;
|
|
3350
|
+
}
|
|
3351
|
+
/** Appends a sub-agent's connect card to its root conversation ({@link rootSurfaceOf}). */
|
|
3352
|
+
async surfaceConnectInRoot(ctx, parent, callId, toolKey) {
|
|
3353
|
+
const target = await rootSurfaceOf(this.deps.db, ctx.conversationId, ctx.runId, parent);
|
|
3354
|
+
if (!target)
|
|
676
3355
|
return;
|
|
677
3356
|
await this.deps.eventLog.append(target.conversationId, [
|
|
678
3357
|
{
|
|
@@ -690,19 +3369,15 @@ let ToolPipeline = class ToolPipeline {
|
|
|
690
3369
|
]);
|
|
691
3370
|
}
|
|
692
3371
|
/**
|
|
693
|
-
*
|
|
694
|
-
*
|
|
695
|
-
*
|
|
3372
|
+
* How a call's result images are stored: a `read` copy bound to the calling conversation (a
|
|
3373
|
+
* sub-agent's own, never its root), owned by the run's trigger account; absent without the
|
|
3374
|
+
* attachments service.
|
|
696
3375
|
*/
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
const { tools, catalog } = e.payload.request;
|
|
703
|
-
return new Set([...(tools ?? []), ...(catalog ?? [])].map((t) => t.key));
|
|
704
|
-
}
|
|
705
|
-
return null;
|
|
3376
|
+
storeResultImage(ctx) {
|
|
3377
|
+
const attachments = this.resultImages;
|
|
3378
|
+
if (attachments === undefined)
|
|
3379
|
+
return undefined;
|
|
3380
|
+
return (file) => attachments.storeRead(ctx.orgId, ctx.conversationId, ctx.accountId || null, file);
|
|
706
3381
|
}
|
|
707
3382
|
/**
|
|
708
3383
|
* 发出本步调用的请求里带了完整定义的工具 key:本步最后一次尝试的 `model_call.request.tools`
|
|
@@ -710,7 +3385,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
710
3385
|
* 或找不到 model_call 时返回 null(不做加载检查)。已加载集合由此从日志得出,不放进程内存。
|
|
711
3386
|
*/
|
|
712
3387
|
async sentTools(ctx) {
|
|
713
|
-
|
|
3388
|
+
// attempts can reach MAX_STEP_MODEL_CALLS after reactive overflow fix-ups; the assistant_message
|
|
3389
|
+
// comes from the last attempt, so scan from the top
|
|
3390
|
+
for (let attempt = MAX_STEP_MODEL_CALLS; attempt >= 1; attempt--) {
|
|
714
3391
|
const e = await this.deps.eventLog.findByIdem(ctx.conversationId, modelCallIdemKey(ctx.runId, ctx.step, attempt));
|
|
715
3392
|
if (e?.type !== "model_call")
|
|
716
3393
|
continue;
|
|
@@ -719,13 +3396,82 @@ let ToolPipeline = class ToolPipeline {
|
|
|
719
3396
|
}
|
|
720
3397
|
return null;
|
|
721
3398
|
}
|
|
722
|
-
/**
|
|
3399
|
+
/**
|
|
3400
|
+
* The secure input of a call with person fields (R4): the latest request of the call, bound like
|
|
3401
|
+
* an approval to the definition and the raw input it was made for. None, or a submitted one made
|
|
3402
|
+
* for another definition or input, asks again; a pending one waits. A cancel, an expiry or a
|
|
3403
|
+
* stopped run ends the call with nothing run; a submitted one returns its id, which the tool
|
|
3404
|
+
* reads the sealed values by. The request goes to the run's person, who alone may submit it.
|
|
3405
|
+
*/
|
|
3406
|
+
async secureInput(ctx, call, tool, policyKey, personFields) {
|
|
3407
|
+
let si = await this.deps.approvals.secureInputForCall(ctx.runId, call.id);
|
|
3408
|
+
const current = si !== null &&
|
|
3409
|
+
si.specHash === tool.specHash &&
|
|
3410
|
+
canonicalJson(si.input) === canonicalJson(call.input ?? {});
|
|
3411
|
+
// only a submitted request is re-asked when stale: a pending one keeps waiting (the person
|
|
3412
|
+
// still sees and may submit it; the stale check then asks again), and a cancelled or expired
|
|
3413
|
+
// one ends the call, as a decided approval keeps governing its call
|
|
3414
|
+
if (si === null || (si.status === "approved" && !current)) {
|
|
3415
|
+
si = await this.deps.approvals.requestSecureInput({
|
|
3416
|
+
attempt: (await this.lastAttempt(ctx.runId, call.id)) + 1,
|
|
3417
|
+
orgId: ctx.orgId,
|
|
3418
|
+
conversationId: ctx.conversationId,
|
|
3419
|
+
runId: ctx.runId,
|
|
3420
|
+
step: ctx.step,
|
|
3421
|
+
callId: call.id,
|
|
3422
|
+
toolKey: policyKey,
|
|
3423
|
+
specHash: tool.specHash,
|
|
3424
|
+
connectorId: tool.source.kind === "connector" ? tool.source.connectorId : null,
|
|
3425
|
+
input: call.input,
|
|
3426
|
+
requestedFor: ctx.accountId,
|
|
3427
|
+
target: personFields.target,
|
|
3428
|
+
personFields: personFields.fields,
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
switch (si.status) {
|
|
3432
|
+
case "pending":
|
|
3433
|
+
return { kind: "wait", wait: approvalWait(si) };
|
|
3434
|
+
case "approved":
|
|
3435
|
+
return { kind: "submitted", id: si.id };
|
|
3436
|
+
case "denied":
|
|
3437
|
+
return {
|
|
3438
|
+
kind: "refused",
|
|
3439
|
+
text: withLeakedOnCard(secureInputCancelledText(si.id), si.leakedFields),
|
|
3440
|
+
};
|
|
3441
|
+
case "expired":
|
|
3442
|
+
// the request's own wait (creation to expiry), not the current config
|
|
3443
|
+
return {
|
|
3444
|
+
kind: "refused",
|
|
3445
|
+
text: withLeakedOnCard(secureInputExpiredText(si.id, approvalHours(si)), si.leakedFields),
|
|
3446
|
+
};
|
|
3447
|
+
default:
|
|
3448
|
+
return {
|
|
3449
|
+
kind: "refused",
|
|
3450
|
+
text: withLeakedOnCard(APPROVAL_CANCELLED_TEXT, si.leakedFields),
|
|
3451
|
+
};
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
/** The highest attempt of any approval of the call, of every kind (0: none yet). */
|
|
3455
|
+
// org-filter: runId is the call context's own run (ctx.runId), a runtime uuid, never caller input
|
|
3456
|
+
async lastAttempt(runId, callId) {
|
|
3457
|
+
const row = await this.deps.db
|
|
3458
|
+
.selectFrom("approvals")
|
|
3459
|
+
.select(sql `max(attempt)`.as("attempt"))
|
|
3460
|
+
.where("run_id", "=", runId)
|
|
3461
|
+
.where("call_id", "=", callId)
|
|
3462
|
+
.executeTakeFirst();
|
|
3463
|
+
return Number(row?.attempt ?? 0);
|
|
3464
|
+
}
|
|
3465
|
+
/**
|
|
3466
|
+
* A decided tool approval other than approved → the model's text; still pending → null (wait).
|
|
3467
|
+
* A tool approval takes no values (a secure input does), so it never names leaked fields.
|
|
3468
|
+
*/
|
|
723
3469
|
refusalText(a) {
|
|
724
3470
|
switch (a.status) {
|
|
725
3471
|
case "denied":
|
|
726
3472
|
return approvalDeniedText(a.denyReason);
|
|
727
3473
|
case "expired":
|
|
728
|
-
//
|
|
3474
|
+
// Use the approval's own wait (creation to expiry), not the current config: it can be hot-reloaded
|
|
729
3475
|
return approvalExpiredText(approvalHours(a));
|
|
730
3476
|
case "cancelled":
|
|
731
3477
|
return APPROVAL_CANCELLED_TEXT;
|
|
@@ -734,8 +3480,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
734
3480
|
}
|
|
735
3481
|
}
|
|
736
3482
|
/**
|
|
737
|
-
*
|
|
738
|
-
*
|
|
3483
|
+
* A handler returned `input_required`: past the round limit, an invalid form
|
|
3484
|
+
* (`validateInputForm`) or an oversized state is an error text for the model; otherwise an
|
|
3485
|
+
* input request is made (writing `question_asked`) and its wait returned.
|
|
739
3486
|
*/
|
|
740
3487
|
async askInput(ctx, callId, toolKey, attempt, req) {
|
|
741
3488
|
if (attempt > MAX_INPUT_ROUNDS)
|
|
@@ -743,6 +3490,27 @@ let ToolPipeline = class ToolPipeline {
|
|
|
743
3490
|
const problems = validateInputForm(req.form);
|
|
744
3491
|
if (problems.length > 0)
|
|
745
3492
|
return invalidFormText(toolKey, problems);
|
|
3493
|
+
let watch;
|
|
3494
|
+
if (req.watch !== undefined) {
|
|
3495
|
+
const source = req.source;
|
|
3496
|
+
if (source === undefined || this.deps.registry.watcher(source) === undefined)
|
|
3497
|
+
return watchWithoutWatcherText(toolKey);
|
|
3498
|
+
const deadlineMs = req.watch?.deadlineMs;
|
|
3499
|
+
if (typeof deadlineMs !== "number" || !Number.isSafeInteger(deadlineMs) || deadlineMs <= 0)
|
|
3500
|
+
return invalidFormText(toolKey, [
|
|
3501
|
+
"watch.deadlineMs must be a positive integer number of milliseconds",
|
|
3502
|
+
]);
|
|
3503
|
+
watch = {
|
|
3504
|
+
deadlineMs,
|
|
3505
|
+
accountId: ctx.accountId,
|
|
3506
|
+
// fixed for the wait: each poll builds the watcher's context with them
|
|
3507
|
+
facts: {
|
|
3508
|
+
role: ctx.role,
|
|
3509
|
+
rootConversationId: ctx.parent?.rootConversationId ?? ctx.conversationId,
|
|
3510
|
+
unattended: ctx.unattended != null,
|
|
3511
|
+
},
|
|
3512
|
+
};
|
|
3513
|
+
}
|
|
746
3514
|
let stateJson;
|
|
747
3515
|
try {
|
|
748
3516
|
stateJson = JSON.stringify(req.state ?? null);
|
|
@@ -755,17 +3523,34 @@ let ToolPipeline = class ToolPipeline {
|
|
|
755
3523
|
if (Buffer.byteLength(stateJson, "utf8") > MAX_INPUT_STATE_BYTES) {
|
|
756
3524
|
return stateTooLargeText(toolKey);
|
|
757
3525
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
3526
|
+
let q;
|
|
3527
|
+
try {
|
|
3528
|
+
q = await this.deps.questions.ask({
|
|
3529
|
+
orgId: ctx.orgId,
|
|
3530
|
+
conversationId: ctx.conversationId,
|
|
3531
|
+
runId: ctx.runId,
|
|
3532
|
+
step: ctx.step,
|
|
3533
|
+
callId,
|
|
3534
|
+
attempt,
|
|
3535
|
+
toolKey,
|
|
3536
|
+
form: req.form,
|
|
3537
|
+
state: JSON.parse(stateJson),
|
|
3538
|
+
...(req.open !== undefined && { open: req.open }),
|
|
3539
|
+
// kept for the call's result, which a later round writes
|
|
3540
|
+
...((req.review !== undefined || req.blocked !== undefined) && {
|
|
3541
|
+
carried: {
|
|
3542
|
+
...(req.review !== undefined && { review: req.review }),
|
|
3543
|
+
...(req.blocked !== undefined && { blocked: req.blocked }),
|
|
3544
|
+
},
|
|
3545
|
+
}),
|
|
3546
|
+
...(watch !== undefined && { watch }),
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3549
|
+
catch (e) {
|
|
3550
|
+
if (e instanceof TooManyWatchedWaitsError)
|
|
3551
|
+
return TOO_MANY_WATCHED_WAITS_TEXT;
|
|
3552
|
+
throw e;
|
|
3553
|
+
}
|
|
769
3554
|
return inputWait(q);
|
|
770
3555
|
}
|
|
771
3556
|
/**
|
|
@@ -773,28 +3558,71 @@ let ToolPipeline = class ToolPipeline {
|
|
|
773
3558
|
* 带 `tools.timeoutMs` 超时与 run 的中止信号(合并后传给处理函数 / 连接器,不响应信号的也按时结束)。
|
|
774
3559
|
* 熔断只作用于连接器工具(键为组织 × 连接器)。
|
|
775
3560
|
*/
|
|
776
|
-
async execute(tool, input, ctx, callId, resume, stepTools
|
|
3561
|
+
async execute(tool, input, ctx, callId, resume, stepTools, reviewed,
|
|
3562
|
+
/** The approved approval of this call, matching its definition and input (builtins only). */
|
|
3563
|
+
approvalId,
|
|
3564
|
+
/** The automatic decision the call runs under instead of an approval (builtins only, R2). */
|
|
3565
|
+
decision,
|
|
3566
|
+
/** The submitted secure input request of this call (builtins only, R4). */
|
|
3567
|
+
secureInputId, siteAccess) {
|
|
3568
|
+
const reviewedWorkingRoot = reviewed?.workingRoot;
|
|
3569
|
+
const reviewedAgainstRoot = reviewed?.against;
|
|
777
3570
|
if (tool.source.kind === "connector") {
|
|
778
3571
|
return this.executeConnector(tool, tool.source, input, ctx, resume);
|
|
779
3572
|
}
|
|
780
3573
|
const handler = this.deps.registry.handler(tool.source);
|
|
781
3574
|
if (!handler)
|
|
782
3575
|
return { kind: "error", message: `Tool ${tool.key} is no longer available.` };
|
|
783
|
-
|
|
3576
|
+
if (siteAccess !== undefined &&
|
|
3577
|
+
(tool.source.kind !== "plugin" ||
|
|
3578
|
+
this.extensions?.current(tool.source.plugin)?.manifest.permissions?.deviceAccess
|
|
3579
|
+
?.siteAccess !== true)) {
|
|
3580
|
+
return {
|
|
3581
|
+
kind: "error",
|
|
3582
|
+
message: "This site approval is no longer valid. The action did not run.",
|
|
3583
|
+
};
|
|
3584
|
+
}
|
|
3585
|
+
// an extension handler gets only the SDK ToolCallContext; a builtin also gets the step's resolved
|
|
3586
|
+
// tools (ToolSearch)
|
|
3587
|
+
// the tree root the person looks at; every sub-agent run carries it from its start
|
|
3588
|
+
const rootConversationId = ctx.parent?.rootConversationId ?? ctx.conversationId;
|
|
784
3589
|
const base = {
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
3590
|
+
...extensionCallContext({
|
|
3591
|
+
orgId: ctx.orgId,
|
|
3592
|
+
accountId: ctx.accountId,
|
|
3593
|
+
agentId: ctx.agentId,
|
|
3594
|
+
conversationId: ctx.conversationId,
|
|
3595
|
+
rootConversationId,
|
|
3596
|
+
runId: ctx.runId,
|
|
3597
|
+
callId,
|
|
3598
|
+
source: ctx.source,
|
|
3599
|
+
ownerAccountId: ctx.ownerAccountId,
|
|
3600
|
+
role: ctx.role,
|
|
3601
|
+
}),
|
|
790
3602
|
...(resume !== undefined && { resume }),
|
|
3603
|
+
...(siteAccess !== undefined && { siteAccess }),
|
|
791
3604
|
...(tool.source.kind === "builtin" && stepTools !== undefined && { tools: stepTools }),
|
|
792
|
-
...(tool.source.kind === "builtin" && {
|
|
3605
|
+
...(tool.source.kind === "builtin" && {
|
|
3606
|
+
runId: ctx.runId,
|
|
3607
|
+
executionClaim: currentExecutionClaim(),
|
|
3608
|
+
}),
|
|
793
3609
|
...(tool.source.kind === "builtin" &&
|
|
794
3610
|
ctx.deadline !== undefined && { runDeadline: ctx.deadline }),
|
|
795
|
-
|
|
3611
|
+
...(tool.source.kind === "builtin" && approvalId !== undefined && { approvalId }),
|
|
3612
|
+
...(tool.source.kind === "builtin" && decision !== undefined && { decision }),
|
|
3613
|
+
...(tool.source.kind === "builtin" && secureInputId !== undefined && { secureInputId }),
|
|
3614
|
+
// a reviewed call runs in the working root its review judged (project root spec §4.3)
|
|
3615
|
+
...(tool.source.kind === "builtin" &&
|
|
3616
|
+
reviewedWorkingRoot !== undefined && { reviewedWorkingRoot }),
|
|
3617
|
+
// and the root it was judged against, workspace included (B-18, the managed route)
|
|
3618
|
+
...(tool.source.kind === "builtin" &&
|
|
3619
|
+
reviewedAgainstRoot !== undefined && { reviewedAgainstRoot }),
|
|
3620
|
+
...(tool.source.kind === "builtin" &&
|
|
3621
|
+
reviewed?.escalation !== undefined && { sandboxEscalation: reviewed.escalation }),
|
|
796
3622
|
...(tool.source.kind === "builtin" &&
|
|
797
|
-
|
|
3623
|
+
reviewed?.escalationRefusal !== undefined && {
|
|
3624
|
+
sandboxEscalationRefusal: reviewed.escalationRefusal,
|
|
3625
|
+
}),
|
|
798
3626
|
...(tool.source.kind === "builtin" &&
|
|
799
3627
|
ctx.parent !== undefined && { parentRunId: ctx.parent.runId }),
|
|
800
3628
|
...(tool.source.kind === "builtin" &&
|
|
@@ -814,38 +3642,84 @@ let ToolPipeline = class ToolPipeline {
|
|
|
814
3642
|
}),
|
|
815
3643
|
};
|
|
816
3644
|
// 内置工具可按输入给自己的时限(沙箱 bash 按命令超时加余量);缺省 tools.timeoutMs
|
|
817
|
-
const
|
|
3645
|
+
const toolsCfg = this.config.get().tools;
|
|
3646
|
+
const ownMs = tool.timeoutMs?.(input);
|
|
3647
|
+
// an extension tool's declared limit never exceeds the deployment's ceiling
|
|
3648
|
+
const timeoutMs = ownMs === undefined
|
|
3649
|
+
? toolsCfg.timeoutMs
|
|
3650
|
+
: tool.source.kind === "plugin"
|
|
3651
|
+
? Math.min(ownMs, toolsCfg.maxTimeoutMs)
|
|
3652
|
+
: ownMs;
|
|
3653
|
+
let scope;
|
|
818
3654
|
try {
|
|
819
3655
|
// a plugin tool runs with the extension's effective config for the org, never without it
|
|
820
3656
|
// (layering spec A §6): one read per call, cached by EffectiveConfigs
|
|
821
3657
|
let config = {};
|
|
822
3658
|
if (tool.source.kind === "plugin") {
|
|
823
|
-
//
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
return { kind: "error", message: unavailableText(tool.key, NEEDS_CONFIG_REASON) };
|
|
833
|
-
}
|
|
834
|
-
config = { config: effective.config };
|
|
3659
|
+
// the step resolved its tools with the org's enablement; the rest is checked per call
|
|
3660
|
+
const gate = await extensionCallGate(this.deps, ctx.orgId, tool.key, tool.source, {
|
|
3661
|
+
...(siteAccess !== undefined && {
|
|
3662
|
+
checkEnabled: (orgId, plugin) => isExtensionEnabled(this.deps.db, orgId, plugin),
|
|
3663
|
+
}),
|
|
3664
|
+
});
|
|
3665
|
+
if (!gate.ok)
|
|
3666
|
+
return { kind: "error", message: gate.message };
|
|
3667
|
+
config = { config: gate.config };
|
|
835
3668
|
}
|
|
836
|
-
const r = await this.bounded(ctx.signal, (signal) =>
|
|
3669
|
+
const r = await this.bounded(ctx.signal, async (signal) => {
|
|
3670
|
+
await this.txHost.run(async () => { });
|
|
3671
|
+
signal.throwIfAborted();
|
|
3672
|
+
// the call scope lives on this call's own context object (never a module map)
|
|
3673
|
+
const call = { ...base, ...config, signal };
|
|
3674
|
+
scope = attachCallScope(call, {
|
|
3675
|
+
runId: ctx.runId,
|
|
3676
|
+
step: ctx.step,
|
|
3677
|
+
rootConversationId,
|
|
3678
|
+
unattended: ctx.unattended != null,
|
|
3679
|
+
agentVersion: ctx.agentVersion,
|
|
3680
|
+
...(ctx.conversationKind !== undefined && { conversationKind: ctx.conversationKind }),
|
|
3681
|
+
...(ctx.parent !== undefined && {
|
|
3682
|
+
parent: {
|
|
3683
|
+
conversationId: ctx.parent.conversationId,
|
|
3684
|
+
runId: ctx.parent.runId,
|
|
3685
|
+
callId: ctx.parent.callId,
|
|
3686
|
+
...(ctx.parent.budgetRunId !== undefined && {
|
|
3687
|
+
budgetRunId: ctx.parent.budgetRunId,
|
|
3688
|
+
}),
|
|
3689
|
+
},
|
|
3690
|
+
}),
|
|
3691
|
+
});
|
|
3692
|
+
return handler(input, call);
|
|
3693
|
+
}, undefined, timeoutMs);
|
|
837
3694
|
if (r === "timeout") {
|
|
838
|
-
|
|
3695
|
+
const starting = stillStartingUnsent(scope);
|
|
3696
|
+
if (starting)
|
|
3697
|
+
this.deps.log.info("tool call timed out while its device was still starting", {
|
|
3698
|
+
toolKey: tool.key,
|
|
3699
|
+
timeoutMs,
|
|
3700
|
+
});
|
|
3701
|
+
const message = starting
|
|
3702
|
+
? deviceStartingTimeoutText(tool.key, timeoutMs)
|
|
3703
|
+
: timeoutText(tool.key, timeoutMs);
|
|
3704
|
+
return withBlocked({ kind: "error", message }, scope);
|
|
839
3705
|
}
|
|
3706
|
+
// a launch reviewed before the call stopped or asked is kept with its result
|
|
840
3707
|
if (r === "aborted")
|
|
841
|
-
return { kind: "error", message: RUN_STOPPED_DURING_TEXT };
|
|
3708
|
+
return withBlocked({ kind: "error", message: RUN_STOPPED_DURING_TEXT }, scope);
|
|
842
3709
|
if (isInputRequired(r.value)) {
|
|
843
|
-
return {
|
|
3710
|
+
return withBlocked({
|
|
3711
|
+
kind: "input_required",
|
|
3712
|
+
form: r.value.form,
|
|
3713
|
+
state: r.value.state ?? null,
|
|
3714
|
+
...(r.value.open !== undefined && { open: r.value.open }),
|
|
3715
|
+
...(tool.source.kind === "plugin" &&
|
|
3716
|
+
r.value.watch !== undefined && { watch: r.value.watch }),
|
|
3717
|
+
}, scope);
|
|
844
3718
|
}
|
|
845
|
-
return { kind: "result", result: r.value };
|
|
3719
|
+
return withBlocked({ kind: "result", result: r.value }, scope);
|
|
846
3720
|
}
|
|
847
3721
|
catch (e) {
|
|
848
|
-
return this.thrown(tool.key, e);
|
|
3722
|
+
return withBlocked(this.thrown(tool.key, e), scope);
|
|
849
3723
|
}
|
|
850
3724
|
}
|
|
851
3725
|
async executeConnector(tool, source, input, ctx, resume) {
|
|
@@ -854,7 +3728,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
854
3728
|
const connectorId = source.connectorId;
|
|
855
3729
|
const app = await db
|
|
856
3730
|
.selectFrom("connectors")
|
|
857
|
-
.select(["name", "connector", "endpoint", "auth", "status"])
|
|
3731
|
+
.select(["name", "slug", "connector", "endpoint", "auth", "status"])
|
|
858
3732
|
.where("id", "=", connectorId)
|
|
859
3733
|
.where("org_id", "=", orgId)
|
|
860
3734
|
.where("deleted_at", "is", null)
|
|
@@ -890,10 +3764,13 @@ let ToolPipeline = class ToolPipeline {
|
|
|
890
3764
|
// 远端在调用途中向用户要输入(MCP elicitation,见 elicitation.ts):需要问用户时中止本次调用、按 input_required
|
|
891
3765
|
// 处理;续跑时用 ctx.resume 的答案答复远端再次发起的同一请求。resources 工具不续跑,一律拒绝。
|
|
892
3766
|
const suspend = new AbortController();
|
|
3767
|
+
// an unattended run in `fail` mode declines every elicitation: no one is there to answer
|
|
3768
|
+
const unattended = unattendedFails(ctx.unattended);
|
|
893
3769
|
const elicit = new ElicitationSession({
|
|
894
3770
|
resume,
|
|
895
3771
|
onSuspend: () => suspend.abort(),
|
|
896
|
-
declineAll: source.resources === true,
|
|
3772
|
+
declineAll: source.resources === true || unattended,
|
|
3773
|
+
...(unattended && { declineNote: UNATTENDED_ELICITATION_NOTE }),
|
|
897
3774
|
});
|
|
898
3775
|
// 远端可能把收到的凭据回显在结果 / 错误 / elicitation 表单里:写入事件之前按本次注入的值打码(见 redact.ts)
|
|
899
3776
|
const clean = (o) => {
|
|
@@ -929,17 +3806,20 @@ let ToolPipeline = class ToolPipeline {
|
|
|
929
3806
|
kind: "connection_required",
|
|
930
3807
|
connectorId,
|
|
931
3808
|
connectorName: app.name,
|
|
3809
|
+
connectorSlug: app.slug,
|
|
932
3810
|
message: personalMissingText(app.name),
|
|
933
3811
|
}
|
|
934
|
-
: { kind: "error", message:
|
|
935
|
-
//
|
|
3812
|
+
: { kind: "error", message: ORG_MISSING_TEXT };
|
|
3813
|
+
// Read the credential once first: a missing one (or a needs_config connector) is settled before
|
|
3814
|
+
// any session opens, without relying on the connector to rethrow CredentialMissing.
|
|
936
3815
|
try {
|
|
937
3816
|
await getAuth();
|
|
938
3817
|
}
|
|
939
3818
|
catch (e) {
|
|
940
3819
|
if (e instanceof CredentialMissing)
|
|
941
3820
|
return missing(e);
|
|
942
|
-
//
|
|
3821
|
+
// the authorization server is briefly unavailable for the token (OAuth): an actionable
|
|
3822
|
+
// message for the model instead of failing the whole turn
|
|
943
3823
|
if (e instanceof ToolError)
|
|
944
3824
|
return { kind: "error", message: e.message };
|
|
945
3825
|
throw e;
|
|
@@ -959,6 +3839,7 @@ let ToolPipeline = class ToolPipeline {
|
|
|
959
3839
|
await credentials.onUnauthorized(orgId, connectorId, auth, ctx.accountId, stale);
|
|
960
3840
|
},
|
|
961
3841
|
signal,
|
|
3842
|
+
orgId,
|
|
962
3843
|
onElicit: elicit.handle,
|
|
963
3844
|
onToolsChanged: () => {
|
|
964
3845
|
try {
|
|
@@ -974,6 +3855,8 @@ let ToolPipeline = class ToolPipeline {
|
|
|
974
3855
|
},
|
|
975
3856
|
});
|
|
976
3857
|
const session = await opened;
|
|
3858
|
+
await this.txHost.run(async () => { });
|
|
3859
|
+
signal.throwIfAborted();
|
|
977
3860
|
return source.resources
|
|
978
3861
|
? runResourceTool(session, source.name, input)
|
|
979
3862
|
: // 交回已复核的定义(connector_tools.spec,含 connectorData):连接器按它路由,远端变化须先经漂移复核
|
|
@@ -1018,9 +3901,16 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1018
3901
|
thrown(key, e) {
|
|
1019
3902
|
if (e instanceof ToolError)
|
|
1020
3903
|
return { kind: "error", message: e.message };
|
|
3904
|
+
// a ctx.deviceAccess refusal the handler let through: its message is actionable English
|
|
3905
|
+
if (e instanceof DeviceAccessError)
|
|
3906
|
+
return { kind: "error", message: e.message };
|
|
1021
3907
|
// an extension tool's ctx.models.embed denied by a policy hook (spec B §5.4): the model sees the
|
|
1022
3908
|
// deny text (sanitized reason), as for a denied tool call, not a generic failure
|
|
1023
|
-
if (e instanceof ApiError &&
|
|
3909
|
+
if (e instanceof ApiError &&
|
|
3910
|
+
(e.code === "model.hook_denied" ||
|
|
3911
|
+
e.code === "model.budget_exceeded" ||
|
|
3912
|
+
e.code === "model.budget_currency_mismatch" ||
|
|
3913
|
+
e.code === "model.budget_unavailable")) {
|
|
1024
3914
|
return { kind: "error", message: e.message };
|
|
1025
3915
|
}
|
|
1026
3916
|
// 提供工具的插件实例在调用进行中被撤销(停用 / 升级),排空时限到后中止(C17)
|
|
@@ -1106,7 +3996,9 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1106
3996
|
/**
|
|
1107
3997
|
* A plugin tool's inline card (`ToolResult.card` → `tool_result.card`, display only): `view` must
|
|
1108
3998
|
* be an `inline` ui contribution of the same extension and `key` at most 200 characters; anything
|
|
1109
|
-
* else is dropped with a warning and the result is written as usual.
|
|
3999
|
+
* else is dropped with a warning and the result is written as usual. `placement` is kept when
|
|
4000
|
+
* `pinned` or `process` (an unknown value means `output`); `text` only with `pinned`, 1 to
|
|
4001
|
+
* {@link CARD_TEXT_MAX} characters; `badge` only with `pinned`, 1 to {@link CARD_BADGE_MAX}.
|
|
1110
4002
|
*/
|
|
1111
4003
|
cardOf(result, plugin, toolKey) {
|
|
1112
4004
|
const c = result?.card;
|
|
@@ -1122,7 +4014,76 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1122
4014
|
});
|
|
1123
4015
|
return undefined;
|
|
1124
4016
|
}
|
|
1125
|
-
|
|
4017
|
+
// placement: an unknown value falls back to `output` (recorded as absent)
|
|
4018
|
+
let placement;
|
|
4019
|
+
if (x.placement === "pinned" || x.placement === "process")
|
|
4020
|
+
placement = x.placement;
|
|
4021
|
+
else if (x.placement !== undefined && x.placement !== "output") {
|
|
4022
|
+
this.deps.log.warn("tool returned an inline card with an unknown placement; using output", {
|
|
4023
|
+
toolKey,
|
|
4024
|
+
placement: typeof x.placement === "string" ? x.placement.slice(0, 50) : undefined,
|
|
4025
|
+
});
|
|
4026
|
+
}
|
|
4027
|
+
// text: only a pinned card carries it, at most CARD_TEXT_MAX characters
|
|
4028
|
+
let text;
|
|
4029
|
+
if (x.text !== undefined) {
|
|
4030
|
+
if (placement !== "pinned") {
|
|
4031
|
+
this.deps.log.warn("tool returned inline card text without a pinned placement; text dropped", {
|
|
4032
|
+
toolKey,
|
|
4033
|
+
});
|
|
4034
|
+
}
|
|
4035
|
+
else if (typeof x.text !== "string" || x.text === "" || x.text.length > CARD_TEXT_MAX) {
|
|
4036
|
+
this.deps.log.warn("tool returned inline card text that is empty or too long; text dropped", {
|
|
4037
|
+
toolKey,
|
|
4038
|
+
});
|
|
4039
|
+
}
|
|
4040
|
+
else
|
|
4041
|
+
text = x.text;
|
|
4042
|
+
}
|
|
4043
|
+
// badge: only a pinned card carries it, at most CARD_BADGE_MAX characters
|
|
4044
|
+
let badge;
|
|
4045
|
+
if (x.badge !== undefined) {
|
|
4046
|
+
if (placement !== "pinned") {
|
|
4047
|
+
this.deps.log.warn("tool returned an inline card badge without a pinned placement; badge dropped", { toolKey });
|
|
4048
|
+
}
|
|
4049
|
+
else if (typeof x.badge !== "string" || x.badge === "" || x.badge.length > CARD_BADGE_MAX) {
|
|
4050
|
+
this.deps.log.warn("tool returned an inline card badge that is empty or too long; badge dropped", { toolKey });
|
|
4051
|
+
}
|
|
4052
|
+
else
|
|
4053
|
+
badge = x.badge;
|
|
4054
|
+
}
|
|
4055
|
+
return {
|
|
4056
|
+
plugin,
|
|
4057
|
+
view: x.view,
|
|
4058
|
+
...(x.key !== undefined && { key: x.key }),
|
|
4059
|
+
...(placement !== undefined && { placement }),
|
|
4060
|
+
...(text !== undefined && { text }),
|
|
4061
|
+
...(badge !== undefined && { badge }),
|
|
4062
|
+
};
|
|
4063
|
+
}
|
|
4064
|
+
/**
|
|
4065
|
+
* A plugin tool's `InputRequired.open` (display only): `contribution` must be a
|
|
4066
|
+
* `conversation.panel` of the same extension and `item` at most 200 characters; anything else is
|
|
4067
|
+
* dropped with a warning and the form is asked as usual. The plugin is the tool's, never the
|
|
4068
|
+
* extension's word.
|
|
4069
|
+
*/
|
|
4070
|
+
openOf(open, plugin, toolKey) {
|
|
4071
|
+
const x = (typeof open === "object" && open !== null ? open : {});
|
|
4072
|
+
const itemOk = x.item === undefined || (typeof x.item === "string" && x.item !== "" && x.item.length <= 200);
|
|
4073
|
+
if (typeof x.contribution !== "string" ||
|
|
4074
|
+
!this.deps.panels(plugin).has(x.contribution) ||
|
|
4075
|
+
!itemOk) {
|
|
4076
|
+
this.deps.log.warn("tool asked for input with an open target that is not a panel of its extension; dropped", {
|
|
4077
|
+
toolKey,
|
|
4078
|
+
contribution: typeof x.contribution === "string" ? x.contribution.slice(0, 100) : undefined,
|
|
4079
|
+
});
|
|
4080
|
+
return undefined;
|
|
4081
|
+
}
|
|
4082
|
+
return {
|
|
4083
|
+
plugin,
|
|
4084
|
+
contribution: x.contribution,
|
|
4085
|
+
...(x.item !== undefined && { item: x.item }),
|
|
4086
|
+
};
|
|
1126
4087
|
}
|
|
1127
4088
|
/**
|
|
1128
4089
|
* A builtin's structured view (`tool_result.view`, display only): checked against
|
|
@@ -1196,6 +4157,21 @@ let ToolPipeline = class ToolPipeline {
|
|
|
1196
4157
|
__decorate([
|
|
1197
4158
|
Transactional({ propagation: "mandatory" })
|
|
1198
4159
|
], ToolPipeline.prototype, "stopOpenAgentCalls", null);
|
|
4160
|
+
__decorate([
|
|
4161
|
+
Transactional()
|
|
4162
|
+
], ToolPipeline.prototype, "recordAskDecisionIn", null);
|
|
4163
|
+
__decorate([
|
|
4164
|
+
Transactional()
|
|
4165
|
+
], ToolPipeline.prototype, "findPermissionGrant", null);
|
|
4166
|
+
__decorate([
|
|
4167
|
+
Transactional()
|
|
4168
|
+
], ToolPipeline.prototype, "recordPermissionReview", null);
|
|
4169
|
+
__decorate([
|
|
4170
|
+
Transactional()
|
|
4171
|
+
], ToolPipeline.prototype, "grantLoopbackIn", null);
|
|
4172
|
+
__decorate([
|
|
4173
|
+
Transactional()
|
|
4174
|
+
], ToolPipeline.prototype, "recordLoopbackReview", null);
|
|
1199
4175
|
__decorate([
|
|
1200
4176
|
Transactional()
|
|
1201
4177
|
], ToolPipeline.prototype, "writeResultIn", null);
|
|
@@ -1219,6 +4195,36 @@ ToolPipeline = __decorate([
|
|
|
1219
4195
|
__param(15, Inject(OrgToolSwitches)),
|
|
1220
4196
|
__param(16, Inject(TransactionHost)),
|
|
1221
4197
|
__param(17, Optional()),
|
|
1222
|
-
__param(17, Inject(TOOL_PIPELINE_HOOKS))
|
|
4198
|
+
__param(17, Inject(TOOL_PIPELINE_HOOKS)),
|
|
4199
|
+
__param(18, Optional()),
|
|
4200
|
+
__param(18, Inject(NetworkGrants)),
|
|
4201
|
+
__param(19, Optional()),
|
|
4202
|
+
__param(19, Inject(CommandReviewService)),
|
|
4203
|
+
__param(20, Optional()),
|
|
4204
|
+
__param(20, Inject(ConversationDevices)),
|
|
4205
|
+
__param(21, Optional()),
|
|
4206
|
+
__param(21, Inject(SandboxOperationAuthority)),
|
|
4207
|
+
__param(22, Optional()),
|
|
4208
|
+
__param(22, Inject(PermissionCallGrants)),
|
|
4209
|
+
__param(23, Optional()),
|
|
4210
|
+
__param(23, Inject(PermissionAutoGrants)),
|
|
4211
|
+
__param(24, Optional()),
|
|
4212
|
+
__param(24, Inject(PermissionAuthorityLock)),
|
|
4213
|
+
__param(25, Optional()),
|
|
4214
|
+
__param(25, Inject(SandboxService)),
|
|
4215
|
+
__param(26, Optional()),
|
|
4216
|
+
__param(26, Inject(ConversationApprovalProfile)),
|
|
4217
|
+
__param(27, Optional()),
|
|
4218
|
+
__param(27, Inject(ToolAskReview)),
|
|
4219
|
+
__param(28, Optional()),
|
|
4220
|
+
__param(28, Inject(AttachmentsService)),
|
|
4221
|
+
__param(29, Optional()),
|
|
4222
|
+
__param(29, Inject(LoopbackGrants)),
|
|
4223
|
+
__param(30, Optional()),
|
|
4224
|
+
__param(30, Inject(PermissionFacts)),
|
|
4225
|
+
__param(31, Optional()),
|
|
4226
|
+
__param(31, Inject(DeviceSiteGrants)),
|
|
4227
|
+
__param(32, Optional()),
|
|
4228
|
+
__param(32, Inject(ExtensionRegistry))
|
|
1223
4229
|
], ToolPipeline);
|
|
1224
4230
|
export { ToolPipeline };
|