@capybara-hq/kernel 0.1.0-rc.146 → 0.1.0-rc.147
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/dist/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +2 -0
- package/dist/catalog/provenance.js +5 -1
- 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/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/extensions.module.js +9 -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 +5 -0
- package/dist/extensions/grant-epoch.js +9 -0
- package/dist/extensions/host.d.ts +71 -2
- package/dist/extensions/host.js +293 -27
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/isolated/admission.d.ts +17 -2
- package/dist/extensions/isolated/admission.js +15 -7
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -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 +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +23 -0
- 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/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation.js +3 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +25 -1
- package/dist/lifecycle/kernel-lifecycle.js +73 -18
- 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 +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +26 -1
- package/dist/packages/official-publisher.js +48 -1
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
|
@@ -8,6 +8,7 @@ import { HostServiceAccess } from "../device-access/host-services.js";
|
|
|
8
8
|
import { ErasureWorker } from "../erasure/worker.js";
|
|
9
9
|
import { BlobObjects } from "../files/blob-objects.js";
|
|
10
10
|
import { FileLibraryHashJob } from "../files/hash-job.js";
|
|
11
|
+
import { GitRunEnd } from "../git/run-end.js";
|
|
11
12
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
12
13
|
import { ScheduledRuns } from "../infra/schedule/scheduled-runs.js";
|
|
13
14
|
import type { KernelLogger } from "../log.js";
|
|
@@ -38,7 +39,7 @@ export declare const MAINTENANCE_CONCURRENCY = 5;
|
|
|
38
39
|
* `platform-icon-delete` →
|
|
39
40
|
* {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery},
|
|
40
41
|
* `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}, `device-host-services-stop` →
|
|
41
|
-
* {@link HostServiceAccess}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
42
|
+
* {@link HostServiceAccess}, `git-fetch-audit` → {@link GitRunEnd}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
42
43
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
43
44
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
44
45
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -69,7 +70,8 @@ export declare class MaintenanceProcessor extends WorkerHost<Worker> {
|
|
|
69
70
|
private readonly hostServices;
|
|
70
71
|
private readonly retention;
|
|
71
72
|
private readonly erasure;
|
|
72
|
-
|
|
73
|
+
private readonly gitRunEnd;
|
|
74
|
+
constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem" | "revokeDeadHolder">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, automations: Pick<AutomationFirer, "fire" | "settle">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke" | "settleResumeProof">, blobObjects: Pick<BlobObjects, "deleteBlob" | "deleteStaging" | "releaseFile">, hashing: Pick<FileLibraryHashJob, "dispatch" | "runOrgBatch">, platformIcons: Pick<PlatformIconObjects, "deleteObject">, notices: Pick<ConversationNoticeDelivery, "attempt">, triggers: Pick<TriggerDispatcher, "dispatch">, coalescer: Pick<EventCoalescer, "flush">, idleCompaction: Pick<IdleCompactionJob, "fire">, db: KernelDb, loopback: Pick<LoopbackGrants, "refresh">, hostServices: Pick<HostServiceAccess, "deliverOwedStops">, retention: Pick<RetentionWorker, "run">, erasure: Pick<ErasureWorker, "run">, gitRunEnd: Pick<GitRunEnd, "writeFetchSummaries">);
|
|
73
75
|
process(job: Job, token?: string): Promise<void>;
|
|
74
76
|
/** Starts consuming (worker role, after the extensions loaded; built with `autorun: false`). */
|
|
75
77
|
start(): void;
|
|
@@ -27,6 +27,8 @@ import { ErasureWorker, ErasureWorkerModule } from "../erasure/worker.js";
|
|
|
27
27
|
import { BLOB_DELETE_JOB, BlobObjects, BlobObjectsModule, FILE_RELEASE_JOB, FILE_STAGING_DELETE_JOB, } from "../files/blob-objects.js";
|
|
28
28
|
import { FILE_LIBRARY_HASH_JOB, FILE_LIBRARY_HASH_ORG_JOB, FileLibraryHashJob, } from "../files/hash-job.js";
|
|
29
29
|
import { FileLibraryJobsModule } from "../files/library-jobs.module.js";
|
|
30
|
+
import { GitModule } from "../git/git.module.js";
|
|
31
|
+
import { GIT_FETCH_AUDIT_JOB, GitRunEnd } from "../git/run-end.js";
|
|
30
32
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
31
33
|
import { asPlatform, withOrgScope } from "../infra/database/org-scope.js";
|
|
32
34
|
import { configuredProcessor } from "../infra/queue/configured-processor.js";
|
|
@@ -75,7 +77,7 @@ export const MAINTENANCE_CONCURRENCY = 5;
|
|
|
75
77
|
* `platform-icon-delete` →
|
|
76
78
|
* {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery},
|
|
77
79
|
* `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}, `device-host-services-stop` →
|
|
78
|
-
* {@link HostServiceAccess}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
80
|
+
* {@link HostServiceAccess}, `git-fetch-audit` → {@link GitRunEnd}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
79
81
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
80
82
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
81
83
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -106,7 +108,8 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
106
108
|
hostServices;
|
|
107
109
|
retention;
|
|
108
110
|
erasure;
|
|
109
|
-
|
|
111
|
+
gitRunEnd;
|
|
112
|
+
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, automations, scheduled, log, operations, blobObjects, hashing, platformIcons, notices, triggers, coalescer, idleCompaction, db, loopback, hostServices, retention, erasure, gitRunEnd) {
|
|
110
113
|
super();
|
|
111
114
|
this.permissionApprovals = permissionApprovals;
|
|
112
115
|
this.waits = waits;
|
|
@@ -132,6 +135,7 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
132
135
|
this.hostServices = hostServices;
|
|
133
136
|
this.retention = retention;
|
|
134
137
|
this.erasure = erasure;
|
|
138
|
+
this.gitRunEnd = gitRunEnd;
|
|
135
139
|
}
|
|
136
140
|
process(job, token) {
|
|
137
141
|
return runJob(MAINTENANCE_QUEUE_NAME, job, () => this.dispatch(job, token), {
|
|
@@ -322,6 +326,12 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
322
326
|
await this.inOwnerScope(job, resolveRunOrg(this.db.db, data.runId, data.conversationId), (orgId) => this.idleCompaction.fire({ ...data, orgId }));
|
|
323
327
|
return;
|
|
324
328
|
}
|
|
329
|
+
// a finished run's `git.fetch` summaries, owed by its terminal transaction (git spec §9)
|
|
330
|
+
case GIT_FETCH_AUDIT_JOB: {
|
|
331
|
+
const { runId } = job.data;
|
|
332
|
+
await this.inOwnerScope(job, resolveRunOrg(this.db.db, runId), () => this.gitRunEnd.writeFetchSummaries(runId));
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
325
335
|
default:
|
|
326
336
|
if (await this.scheduled.runNow(job.name))
|
|
327
337
|
return;
|
|
@@ -369,7 +379,8 @@ MaintenanceProcessor = __decorate([
|
|
|
369
379
|
__param(20, Inject(LoopbackGrants)),
|
|
370
380
|
__param(21, Inject(HostServiceAccess)),
|
|
371
381
|
__param(22, Inject(RetentionWorker)),
|
|
372
|
-
__param(23, Inject(ErasureWorker))
|
|
382
|
+
__param(23, Inject(ErasureWorker)),
|
|
383
|
+
__param(24, Inject(GitRunEnd))
|
|
373
384
|
], MaintenanceProcessor);
|
|
374
385
|
export { MaintenanceProcessor };
|
|
375
386
|
/**
|
|
@@ -408,6 +419,8 @@ MaintenanceModule = __decorate([
|
|
|
408
419
|
ConversationNoticesModule,
|
|
409
420
|
// a switched-off extension's host services stop
|
|
410
421
|
ExtensionDeviceAccessModule,
|
|
422
|
+
// a finished run's git fetch summaries
|
|
423
|
+
GitModule,
|
|
411
424
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
412
425
|
],
|
|
413
426
|
providers: [
|
|
@@ -54,7 +54,7 @@ export declare class RunFinish {
|
|
|
54
54
|
readonly txHost: TransactionHost;
|
|
55
55
|
/** An automation's run follows its kernel run's end in the same transaction (spec §6). */
|
|
56
56
|
private readonly taskRuns;
|
|
57
|
-
/** The run's git tickets are revoked
|
|
57
|
+
/** The run's git tickets are revoked after the commit (its fetch summaries are owed). */
|
|
58
58
|
private readonly gitRunEnd;
|
|
59
59
|
/** The run's end owes the conversation's ensure-run backstop (transactional outbox spec §6). */
|
|
60
60
|
private readonly outbox;
|
|
@@ -65,8 +65,8 @@ export declare class RunFinish {
|
|
|
65
65
|
constructor(kdb: KernelDb, eventLog: EventLog, txHost: TransactionHost,
|
|
66
66
|
/** An automation's run follows its kernel run's end in the same transaction (spec §6). */
|
|
67
67
|
taskRuns: Pick<AutomationRunTracker, "onRunFinished">,
|
|
68
|
-
/** The run's git tickets are revoked
|
|
69
|
-
gitRunEnd: Pick<GitRunEnd, "
|
|
68
|
+
/** The run's git tickets are revoked after the commit (its fetch summaries are owed). */
|
|
69
|
+
gitRunEnd: Pick<GitRunEnd, "revokeTickets" | "hasFetches">,
|
|
70
70
|
/** The run's end owes the conversation's ensure-run backstop (transactional outbox spec §6). */
|
|
71
71
|
outbox: Pick<OutboxService, "add">,
|
|
72
72
|
/** A finished run's pending approvals are cancelled in its terminal transaction. */
|
|
@@ -14,7 +14,7 @@ import { agentIdOf } from "../conversations/conversation-agent.js";
|
|
|
14
14
|
import { EventLog } from "../conversations/event-log.js";
|
|
15
15
|
import { pauseQueueIn } from "../conversations/queue.js";
|
|
16
16
|
import { oweRunLifecycleFor } from "../extensions/run-lifecycle-owe.js";
|
|
17
|
-
import { GitRunEnd } from "../git/run-end.js";
|
|
17
|
+
import { GitRunEnd, oweGitFetchAudit } from "../git/run-end.js";
|
|
18
18
|
import { afterCommit } from "../infra/database/after-commit.js";
|
|
19
19
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
20
20
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -44,7 +44,7 @@ let RunFinish = class RunFinish {
|
|
|
44
44
|
constructor(kdb, eventLog, txHost,
|
|
45
45
|
/** An automation's run follows its kernel run's end in the same transaction (spec §6). */
|
|
46
46
|
taskRuns,
|
|
47
|
-
/** The run's git tickets are revoked
|
|
47
|
+
/** The run's git tickets are revoked after the commit (its fetch summaries are owed). */
|
|
48
48
|
gitRunEnd,
|
|
49
49
|
/** The run's end owes the conversation's ensure-run backstop (transactional outbox spec §6). */
|
|
50
50
|
outbox,
|
|
@@ -166,7 +166,11 @@ let RunFinish = class RunFinish {
|
|
|
166
166
|
}
|
|
167
167
|
// the terminal status is committed first, then the tickets go (the one place runs end)
|
|
168
168
|
afterCommit(() => recordRun(a.status));
|
|
169
|
-
afterCommit(() => this.gitRunEnd.
|
|
169
|
+
afterCommit(() => this.gitRunEnd.revokeTickets(a.runId));
|
|
170
|
+
// the run's `git.fetch` summaries are audit: owed here, so a crash after the commit keeps them
|
|
171
|
+
if (conv && (await this.gitRunEnd.hasFetches(a.runId))) {
|
|
172
|
+
await oweGitFetchAudit(this.outbox, a.runId, conv.org_id);
|
|
173
|
+
}
|
|
170
174
|
// a failed or stopped run pauses the queued messages until the person resumes (spec §5.7);
|
|
171
175
|
// an idle compact run never does (idle compaction spec §5.2, S3): preempted by input, that
|
|
172
176
|
// input (a queued message among them) goes out next; failed or stopped, its end is not in the
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { type DeviceProvider, type SandboxPermissionSupport, SandboxPermissionUnsupportedError } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { type DeviceProjectReach, type DeviceProvider, type SandboxPermissionSupport, SandboxPermissionUnsupportedError } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
/**
|
|
3
3
|
* Why a device cannot run permission-scoped work, for people and for the kernel-rendered admission
|
|
4
|
-
* text (ruling R9): an outdated sandbox provider plugin,
|
|
4
|
+
* text (ruling R9): an outdated sandbox provider plugin, a device program too old to enforce the
|
|
5
|
+
* platform or org project reach ceiling (`device-update`), or a runtime that cannot enforce the
|
|
5
6
|
* sandbox. The recorded `permission_context` keeps only `{ state, reason }`.
|
|
6
7
|
*/
|
|
7
8
|
export type PermissionAvailabilityCause = {
|
|
8
9
|
kind: "provider-outdated";
|
|
9
10
|
plugin: string;
|
|
10
11
|
version: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "device-update";
|
|
14
|
+
projectReach: DeviceProjectReach;
|
|
11
15
|
} | {
|
|
12
16
|
kind: "runtime";
|
|
13
17
|
};
|
|
@@ -61,3 +65,14 @@ export declare function runtimeReportVerdict(report: SandboxPermissionSupport):
|
|
|
61
65
|
* the kernel read route).
|
|
62
66
|
*/
|
|
63
67
|
export declare function deviceWorkAvailability(availability: PermissionAvailability): PermissionAvailability;
|
|
68
|
+
/** The reason a device program too old for the project reach ceiling reads (issue #1240). */
|
|
69
|
+
export declare const DEVICE_UPDATE_REASON = "This device's program cannot enforce the project reach limit; update the device program on its computer and reconnect it";
|
|
70
|
+
/**
|
|
71
|
+
* Device work under the platform or org project reach `ceiling` on a device whose connected
|
|
72
|
+
* program cannot enforce it ({@link projectReachNeedsUpdate}), read from the connection facts the
|
|
73
|
+
* provider recorded with its support: unsupported with the `device-update` cause, so people see
|
|
74
|
+
* the upgrade before admission refuses. Null when the support names no facts (an earlier
|
|
75
|
+
* provider: its own admission still refuses), the ceiling is the default `machine`, or the program
|
|
76
|
+
* or the owner's own reach already keeps work within it.
|
|
77
|
+
*/
|
|
78
|
+
export declare function projectReachAvailability(support: SandboxPermissionSupport, ceiling: DeviceProjectReach | undefined): PermissionAvailability | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { instanceSupported, SandboxPermissionUnsupportedError, } from "@capybara-hq/plugin-sdk";
|
|
1
|
+
import { instanceSupported, projectReachNeedsUpdate, SandboxPermissionUnsupportedError, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
/**
|
|
3
3
|
* Admission's refusal of device work on a device that cannot run permission-scoped operations:
|
|
4
4
|
* nothing was sent. It extends {@link SandboxPermissionUnsupportedError} (and keeps its name), so
|
|
@@ -69,3 +69,24 @@ export function deviceWorkAvailability(availability) {
|
|
|
69
69
|
? availability
|
|
70
70
|
: { state: "unsupported", reason, cause: { kind: "runtime" } };
|
|
71
71
|
}
|
|
72
|
+
/** The reason a device program too old for the project reach ceiling reads (issue #1240). */
|
|
73
|
+
export const DEVICE_UPDATE_REASON = "This device's program cannot enforce the project reach limit; update the device program on its computer and reconnect it";
|
|
74
|
+
/**
|
|
75
|
+
* Device work under the platform or org project reach `ceiling` on a device whose connected
|
|
76
|
+
* program cannot enforce it ({@link projectReachNeedsUpdate}), read from the connection facts the
|
|
77
|
+
* provider recorded with its support: unsupported with the `device-update` cause, so people see
|
|
78
|
+
* the upgrade before admission refuses. Null when the support names no facts (an earlier
|
|
79
|
+
* provider: its own admission still refuses), the ceiling is the default `machine`, or the program
|
|
80
|
+
* or the owner's own reach already keeps work within it.
|
|
81
|
+
*/
|
|
82
|
+
export function projectReachAvailability(support, ceiling) {
|
|
83
|
+
if (ceiling === undefined || support.projectReach === undefined)
|
|
84
|
+
return null;
|
|
85
|
+
if (!projectReachNeedsUpdate(support.projectReach, ceiling))
|
|
86
|
+
return null;
|
|
87
|
+
return {
|
|
88
|
+
state: "unsupported",
|
|
89
|
+
reason: DEVICE_UPDATE_REASON,
|
|
90
|
+
cause: { kind: "device-update", projectReach: ceiling },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -25,7 +25,7 @@ import { canonicalHostCeiling, deviceListAddRefusal, effectiveDeviceSandbox, hos
|
|
|
25
25
|
import { DEFAULT_ALLOWED_PROFILES, effectiveAllowedProfiles, readDeviceSandboxSettings, } from "./device-sandbox-settings.js";
|
|
26
26
|
import { appliedOf, appliedWider, coversHost, effectiveDevicePolicy, readDeploymentDevicePolicy, readInstanceLimits, } from "./modes.js";
|
|
27
27
|
import { assertAuthorityHeld } from "./permission-authority-lock.js";
|
|
28
|
-
import { deviceWorkAvailability, permissionAvailabilityFor, } from "./permission-availability.js";
|
|
28
|
+
import { deviceWorkAvailability, permissionAvailabilityFor, projectReachAvailability, } from "./permission-availability.js";
|
|
29
29
|
import { reachNarrowed } from "./permission-ceiling-writes.js";
|
|
30
30
|
import { readCurrentReport } from "./permission-runtime-reports.js";
|
|
31
31
|
import { DeviceProviders, servesDialIn } from "./providers.js";
|
|
@@ -465,6 +465,12 @@ let PermissionFacts = class PermissionFacts {
|
|
|
465
465
|
async scope(orgId, deviceId, projectPath, project) {
|
|
466
466
|
const { sandbox } = await this.readDevice(orgId, deviceId);
|
|
467
467
|
let availability = await this.availability(orgId, deviceId);
|
|
468
|
+
if (sandbox.projectReach !== undefined && availability.state === "supported") {
|
|
469
|
+
// the current connection's program cannot enforce the ceiling (issue #1240)
|
|
470
|
+
const update = projectReachAvailability(availability.report, sandbox.projectReach);
|
|
471
|
+
if (update)
|
|
472
|
+
availability = update;
|
|
473
|
+
}
|
|
468
474
|
if (sandbox.projectReach !== undefined && availability.state === "supported") {
|
|
469
475
|
try {
|
|
470
476
|
await this.projectReachAuthority(orgId, deviceId, sandbox.projectReach);
|
|
@@ -294,6 +294,8 @@ export { PermissionAdmissionUnavailable };
|
|
|
294
294
|
export function admissionUnavailableText(cause) {
|
|
295
295
|
if (cause.kind === "provider-outdated")
|
|
296
296
|
return `This device's sandbox plugin (${cause.plugin} ${cause.version}) cannot run device tools under a permission profile, so nothing ran. A super admin updates the plugin on the Plugins page; until then, continue without the device, or ask the user to start a new conversation on another device.`;
|
|
297
|
+
if (cause.kind === "device-update")
|
|
298
|
+
return `This device's program is too old to keep work within the platform or organization's project reach limit (${cause.projectReach}), so nothing ran. Ask the device's owner to update the device program (capybara-device) on that computer and reconnect it; until then, continue without the device.`;
|
|
297
299
|
return "This device's runtime cannot enforce its sandbox, so nothing ran. Ask the device's owner to update its device program (or a super admin to update its device plugin), or continue without the device.";
|
|
298
300
|
}
|
|
299
301
|
/**
|
package/dist/tools/pipeline.d.ts
CHANGED
|
@@ -69,7 +69,8 @@ export type ReviewKind = "command" | "write" | "read";
|
|
|
69
69
|
export declare const commandDeniedText: (reason: string, kind: ReviewKind) => string;
|
|
70
70
|
/**
|
|
71
71
|
* A command (or write, or read) the review held in an unattended run: no one can answer, so it is a
|
|
72
|
-
* deny at once — no approval, no grant (P-D3)
|
|
72
|
+
* deny at once — no approval, no grant (P-D3); the task run records the held class
|
|
73
|
+
* (`reviewHoldKey`).
|
|
73
74
|
*/
|
|
74
75
|
export declare const commandUnattendedText: (reason: string, kind: ReviewKind) => string;
|
|
75
76
|
/**
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
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
12
|
import { sql } from "kysely";
|
|
13
|
-
import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../automations/unattended.js";
|
|
13
|
+
import { appendMissingGrant, connectionGrantKey, reviewHoldKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../automations/unattended.js";
|
|
14
14
|
import { backgroundMaxSeconds } from "../background/launch.js";
|
|
15
15
|
import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
|
|
16
16
|
import { AttachmentsService } from "../conversations/attachments.service.js";
|
|
@@ -118,7 +118,8 @@ export const commandDeniedText = (reason, kind) => kind === "write"
|
|
|
118
118
|
: `Command blocked by review: ${reason}. Do the work another way or ask the user to run it.`;
|
|
119
119
|
/**
|
|
120
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)
|
|
121
|
+
* deny at once — no approval, no grant (P-D3); the task run records the held class
|
|
122
|
+
* (`reviewHoldKey`).
|
|
122
123
|
*/
|
|
123
124
|
export const commandUnattendedText = (reason, kind) => kind === "command"
|
|
124
125
|
? `This command needs approval (${reason}), and no one can approve it now; do the work another way or leave it for the person.`
|
|
@@ -2149,6 +2150,10 @@ let ToolPipeline = class ToolPipeline {
|
|
|
2149
2150
|
const command = kind === "command" ? textField(input, "command") : tool.key;
|
|
2150
2151
|
if (!attended) {
|
|
2151
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
|
+
}
|
|
2152
2157
|
return {
|
|
2153
2158
|
kind: "result",
|
|
2154
2159
|
content: commandUnattendedText(reason, kind),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.147",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -70,10 +70,11 @@
|
|
|
70
70
|
"yaml": "^2.9.1",
|
|
71
71
|
"yauzl": "3.4.0",
|
|
72
72
|
"zod": "^4.6.7",
|
|
73
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
73
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.104"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
77
|
+
"@opentelemetry/exporter-prometheus": "0.223.0",
|
|
77
78
|
"@opentelemetry/sdk-metrics": "2.12.0",
|
|
78
79
|
"@types/pg": "^8.23.1",
|
|
79
80
|
"@types/pg-cursor": "^2.7.2",
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
"@types/yauzl": "3.4.0",
|
|
83
84
|
"pg-cursor": "^2.22.1",
|
|
84
85
|
"ws": "^8.22.0",
|
|
85
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
86
|
+
"@capybara-hq/testing": "0.1.0-rc.61"
|
|
86
87
|
},
|
|
87
88
|
"scripts": {
|
|
88
89
|
"build": "tsc -b"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
-- Isolated extension usage counters (isolation capacity spec 2026-12-04, §7 "Usage counters";
|
|
2
|
+
-- plan task 1.2c). Each replica counts invocations, busy lane time, stream frames, broker
|
|
3
|
+
-- callbacks by family and ctx.net bytes out and in per (org, plugin) in memory and flushes them every 10 s
|
|
4
|
+
-- as additive upserts into hourly buckets, so concurrent replicas never overwrite each other.
|
|
5
|
+
-- These are capacity and usage-trend counters, not a ledger: a crashed replica loses at most its
|
|
6
|
+
-- unflushed window. Model and storage usage keep their own records and are not repeated here.
|
|
7
|
+
--
|
|
8
|
+
-- One row per (org, plugin, hour, counter). Counter names: invocations, busy_lane_ms,
|
|
9
|
+
-- stream_frames, net_bytes_out, net_bytes_in and broker.<family> (broker.kv, broker.net, ...).
|
|
10
|
+
CREATE TABLE IF NOT EXISTS extension_usage (
|
|
11
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
12
|
+
plugin text NOT NULL,
|
|
13
|
+
hour timestamptz NOT NULL CHECK (hour = date_trunc('hour', hour)),
|
|
14
|
+
counter text NOT NULL CHECK (counter ~ '^[a-z_]{1,32}(\.[a-z]{1,16})?$'),
|
|
15
|
+
amount bigint NOT NULL CHECK (amount >= 0),
|
|
16
|
+
PRIMARY KEY (org_id, plugin, hour, counter)
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
-- Deployment-wide saturation views read by time range first.
|
|
20
|
+
CREATE INDEX IF NOT EXISTS extension_usage_hour_idx ON extension_usage (hour, plugin);
|
|
21
|
+
|
|
22
|
+
DROP POLICY IF EXISTS org_scope ON extension_usage;
|
|
23
|
+
CREATE POLICY org_scope ON extension_usage
|
|
24
|
+
USING (rls_admits(org_id, (SELECT rls_scope_unrestricted()),
|
|
25
|
+
(SELECT pg_catalog.current_setting('capybara.org_id', true))))
|
|
26
|
+
WITH CHECK (rls_admits(org_id, (SELECT rls_scope_unrestricted()),
|
|
27
|
+
(SELECT pg_catalog.current_setting('capybara.org_id', true))));
|
|
28
|
+
ALTER TABLE extension_usage ENABLE ROW LEVEL SECURITY, FORCE ROW LEVEL SECURITY;
|
|
29
|
+
|
|
30
|
+
-- Flush batches already applied. A flush whose outcome is unknown (the connection dropped around
|
|
31
|
+
-- the commit) is retried with the same id; the batch row makes the retry a no-op when the first
|
|
32
|
+
-- attempt committed, so a batch never counts twice. Deployment state with no org_id; replicas
|
|
33
|
+
-- delete rows older than a day.
|
|
34
|
+
CREATE TABLE IF NOT EXISTS extension_usage_batches (
|
|
35
|
+
id text PRIMARY KEY,
|
|
36
|
+
flushed_at timestamptz NOT NULL DEFAULT now()
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
CREATE INDEX IF NOT EXISTS extension_usage_batches_flushed_idx
|
|
40
|
+
ON extension_usage_batches (flushed_at);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Each replica's isolation supervisor readiness and shadow execution placements (extension
|
|
2
|
+
-- permission model plan task 1.4j). The supervisor probe and the 1.3b shadow placements run per
|
|
3
|
+
-- replica; the isolation status route and permission reviews read them deployment-wide, so each
|
|
4
|
+
-- replica writes its row after its probe and convergence, refreshes it with its heartbeat and
|
|
5
|
+
-- deletes it on a clean stop; rows of a replica whose heartbeat went stale are pruned like
|
|
6
|
+
-- extension_replica_status. Deployment-wide state: no org_id, so no row level security.
|
|
7
|
+
CREATE TABLE IF NOT EXISTS extension_replica_isolation (
|
|
8
|
+
replica_id text PRIMARY KEY,
|
|
9
|
+
-- 'available' or 'failing' as the replica's last probe saw it; 'not_configured' for a replica
|
|
10
|
+
-- without extensionHost.isolation (it probes nothing and still records its shadow placements)
|
|
11
|
+
state text NOT NULL CHECK (state IN ('available', 'failing', 'not_configured')),
|
|
12
|
+
-- the first supervisor check that failed, with the kernel's English message
|
|
13
|
+
failed_check text CHECK (
|
|
14
|
+
failed_check IS NULL
|
|
15
|
+
OR failed_check IN ('guard_reachability', 'engine_runtime', 'image', 'postgres_socket')
|
|
16
|
+
),
|
|
17
|
+
message text,
|
|
18
|
+
CHECK ((state = 'failing') = (failed_check IS NOT NULL)),
|
|
19
|
+
-- the replica's shadow execution placements of its last convergence (1.3b), a JSON array
|
|
20
|
+
shadow jsonb NOT NULL DEFAULT '[]'::jsonb CHECK (jsonb_typeof(shadow) = 'array'),
|
|
21
|
+
http_replica_id text,
|
|
22
|
+
-- when the last probe ran (null when not configured)
|
|
23
|
+
probed_at timestamptz,
|
|
24
|
+
heartbeat_at timestamptz NOT NULL DEFAULT now()
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
CREATE INDEX IF NOT EXISTS extension_replica_isolation_heartbeat_idx
|
|
28
|
+
ON extension_replica_isolation (heartbeat_at);
|