@capybara-hq/kernel 0.1.0-rc.67 → 0.1.0-rc.69

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.
Files changed (226) hide show
  1. package/bootstrap.json +9 -1
  2. package/dist/admin/admin.module.js +2 -0
  3. package/dist/admin/health.service.d.ts +11 -4
  4. package/dist/admin/health.service.js +33 -17
  5. package/dist/background/poll.job.js +2 -2
  6. package/dist/background/tasks.service.d.ts +5 -5
  7. package/dist/background/tasks.service.js +9 -8
  8. package/dist/catalog/credential-key.d.ts +10 -0
  9. package/dist/catalog/credential-key.js +28 -0
  10. package/dist/catalog/marketplaces.service.d.ts +1 -1
  11. package/dist/catalog/plugin-upgrade.js +1 -19
  12. package/dist/catalog/requests.service.js +1 -1
  13. package/dist/config/schema.d.ts +1 -1
  14. package/dist/config/schema.js +9 -9
  15. package/dist/conversations/conversations.controller.d.ts +8 -3
  16. package/dist/conversations/conversations.controller.js +8 -3
  17. package/dist/conversations/conversations.service.d.ts +33 -15
  18. package/dist/conversations/conversations.service.js +60 -10
  19. package/dist/conversations/events.d.ts +21 -41
  20. package/dist/conversations/events.js +57 -31
  21. package/dist/conversations/permission-profiles.controller.d.ts +6 -4
  22. package/dist/conversations/permission-profiles.service.d.ts +6 -4
  23. package/dist/ctx/create-ctx.d.ts +20 -1
  24. package/dist/ctx/create-ctx.js +77 -6
  25. package/dist/ctx/device-provider-check.d.ts +6 -2
  26. package/dist/ctx/device-provider-check.js +17 -2
  27. package/dist/db/kernel-schema.d.ts +10 -48
  28. package/dist/devices/access.d.ts +3 -4
  29. package/dist/devices/access.js +3 -4
  30. package/dist/devices/conversation-devices.d.ts +1 -3
  31. package/dist/devices/conversation-devices.js +2 -7
  32. package/dist/devices/device-projects.service.js +24 -29
  33. package/dist/devices/device-provider-selection.d.ts +5 -6
  34. package/dist/devices/device-provider-selection.js +8 -9
  35. package/dist/devices/devices.controller.d.ts +8 -21
  36. package/dist/devices/devices.controller.js +9 -34
  37. package/dist/devices/devices.module.js +6 -4
  38. package/dist/devices/devices.schemas.d.ts +1 -5
  39. package/dist/devices/devices.schemas.js +1 -5
  40. package/dist/devices/devices.service.d.ts +84 -147
  41. package/dist/devices/devices.service.js +134 -229
  42. package/dist/devices/dto.d.ts +5 -32
  43. package/dist/devices/dto.js +5 -37
  44. package/dist/devices/errors.d.ts +6 -5
  45. package/dist/devices/errors.js +7 -8
  46. package/dist/devices/project-rules.d.ts +9 -11
  47. package/dist/devices/project-rules.js +7 -7
  48. package/dist/devices/working-root.d.ts +3 -6
  49. package/dist/devices/working-root.js +3 -8
  50. package/dist/dial-in/access.d.ts +23 -0
  51. package/dist/dial-in/access.js +64 -0
  52. package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +12 -6
  53. package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +30 -15
  54. package/dist/dial-in/auth.module.d.ts +7 -0
  55. package/dist/dial-in/auth.module.js +27 -0
  56. package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +42 -13
  57. package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +83 -32
  58. package/dist/dial-in/dial-in.module.d.ts +9 -0
  59. package/dist/dial-in/dial-in.module.js +37 -0
  60. package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
  61. package/dist/{local-devices → dial-in}/dto.js +14 -2
  62. package/dist/dial-in/envelope.d.ts +95 -0
  63. package/dist/dial-in/envelope.js +89 -0
  64. package/dist/dial-in/gateway.d.ts +214 -0
  65. package/dist/{local-devices/local-device-gateway.js → dial-in/gateway.js} +337 -181
  66. package/dist/dial-in/handlers.d.ts +47 -0
  67. package/dist/dial-in/handlers.js +84 -0
  68. package/dist/dial-in/machines.d.ts +155 -0
  69. package/dist/dial-in/machines.js +383 -0
  70. package/dist/dial-in/relay.d.ts +135 -0
  71. package/dist/dial-in/relay.js +444 -0
  72. package/dist/dial-in/relay.module.d.ts +7 -0
  73. package/dist/dial-in/relay.module.js +24 -0
  74. package/dist/{local-devices/device-routes.d.ts → dial-in/routes.d.ts} +19 -11
  75. package/dist/{local-devices/device-routes.js → dial-in/routes.js} +45 -25
  76. package/dist/{local-devices → dial-in}/targets.d.ts +3 -18
  77. package/dist/{local-devices → dial-in}/targets.js +3 -48
  78. package/dist/errors.d.ts +8 -27
  79. package/dist/errors.js +8 -27
  80. package/dist/extensions/bootstrap.d.ts +5 -0
  81. package/dist/extensions/bootstrap.js +10 -1
  82. package/dist/extensions/extensions.module.js +6 -0
  83. package/dist/extensions/host.d.ts +6 -0
  84. package/dist/extensions/host.js +12 -2
  85. package/dist/extensions/permission-set.d.ts +15 -1
  86. package/dist/extensions/permission-set.js +11 -1
  87. package/dist/extensions/permission-view.d.ts +1 -1
  88. package/dist/extensions/permission-view.js +4 -1
  89. package/dist/http/api.module.js +4 -4
  90. package/dist/http/gateway-routes.d.ts +1 -1
  91. package/dist/http/gateway-routes.js +1 -1
  92. package/dist/http/meta.controller.js +1 -1
  93. package/dist/identity/settings.d.ts +1 -1
  94. package/dist/identity/settings.js +6 -8
  95. package/dist/infra/config/kernel-config.service.js +2 -2
  96. package/dist/infra/outbox/registry.d.ts +0 -14
  97. package/dist/infra/outbox/registry.js +0 -15
  98. package/dist/infra/throttler/named-throttlers.d.ts +1 -1
  99. package/dist/infra/throttler/named-throttlers.js +1 -1
  100. package/dist/kernel.module.js +0 -3
  101. package/dist/orgs/settings.service.js +5 -10
  102. package/dist/overrides.d.ts +0 -4
  103. package/dist/overrides.js +0 -2
  104. package/dist/platform/exclusions.js +5 -5
  105. package/dist/platform/ops/admin.ops.js +1 -1
  106. package/dist/platform/ops/conversations.ops.js +5 -2
  107. package/dist/platform/ops/devices.ops.js +11 -24
  108. package/dist/platform/ops/inbox.ops.js +1 -1
  109. package/dist/roles/gateway-role.d.ts +3 -3
  110. package/dist/roles/gateway-role.js +4 -4
  111. package/dist/roles/gateway.module.d.ts +1 -1
  112. package/dist/roles/gateway.module.js +5 -5
  113. package/dist/runtime/context/device-paths.d.ts +4 -1
  114. package/dist/runtime/context/permission-profile.js +5 -5
  115. package/dist/runtime/maintenance.d.ts +2 -5
  116. package/dist/runtime/maintenance.js +9 -19
  117. package/dist/runtime/project/knowledge.js +4 -5
  118. package/dist/runtime/project/knowledge.service.js +2 -1
  119. package/dist/sandbox/cloud-permission-snapshot.d.ts +1 -1
  120. package/dist/sandbox/cloud-permission-snapshot.js +1 -3
  121. package/dist/sandbox/device-reports.d.ts +74 -14
  122. package/dist/sandbox/device-reports.js +190 -33
  123. package/dist/sandbox/device-reports.module.d.ts +7 -0
  124. package/dist/sandbox/device-reports.module.js +25 -0
  125. package/dist/sandbox/device-sandbox.d.ts +39 -41
  126. package/dist/sandbox/device-sandbox.js +44 -83
  127. package/dist/sandbox/kernel-read.d.ts +2 -2
  128. package/dist/sandbox/legacy-retirement.d.ts +11 -59
  129. package/dist/sandbox/legacy-retirement.js +34 -186
  130. package/dist/sandbox/legacy-retirement.module.d.ts +2 -2
  131. package/dist/sandbox/legacy-retirement.module.js +2 -2
  132. package/dist/sandbox/managed-device-context.d.ts +16 -4
  133. package/dist/sandbox/managed-device-context.js +25 -8
  134. package/dist/sandbox/managed-device-context.module.js +4 -0
  135. package/dist/sandbox/modes.d.ts +3 -12
  136. package/dist/sandbox/modes.js +2 -14
  137. package/dist/{local-devices → sandbox}/network-grants.d.ts +2 -21
  138. package/dist/{local-devices → sandbox}/network-grants.js +4 -49
  139. package/dist/sandbox/operation-authority-types.d.ts +2 -1
  140. package/dist/sandbox/operation-authority.d.ts +6 -20
  141. package/dist/sandbox/operation-authority.js +43 -104
  142. package/dist/sandbox/operation-authority.module.js +1 -1
  143. package/dist/sandbox/operation-intents.d.ts +4 -1
  144. package/dist/sandbox/operation-intents.js +11 -2
  145. package/dist/sandbox/operation-reconcile.job.js +2 -4
  146. package/dist/sandbox/permission-availability.d.ts +6 -7
  147. package/dist/sandbox/permission-availability.js +7 -10
  148. package/dist/sandbox/permission-call-grants.d.ts +2 -1
  149. package/dist/sandbox/permission-call-grants.js +1 -7
  150. package/dist/sandbox/permission-call-types.d.ts +4 -4
  151. package/dist/sandbox/permission-ceiling-writes.d.ts +7 -23
  152. package/dist/sandbox/permission-ceiling-writes.js +8 -35
  153. package/dist/sandbox/permission-config-publication.d.ts +9 -1
  154. package/dist/sandbox/permission-config-publication.js +29 -21
  155. package/dist/sandbox/permission-context-types.d.ts +17 -10
  156. package/dist/sandbox/permission-facts.d.ts +98 -95
  157. package/dist/sandbox/permission-facts.js +160 -314
  158. package/dist/sandbox/permission-instance-writes.d.ts +23 -37
  159. package/dist/sandbox/permission-instance-writes.js +44 -121
  160. package/dist/sandbox/permission-runtime-reports.d.ts +38 -30
  161. package/dist/sandbox/permission-runtime-reports.js +105 -122
  162. package/dist/sandbox/providers.d.ts +26 -38
  163. package/dist/sandbox/providers.js +36 -18
  164. package/dist/sandbox/request-not-sent.d.ts +2 -13
  165. package/dist/sandbox/request-not-sent.js +2 -13
  166. package/dist/sandbox/review/permission-candidate.d.ts +13 -8
  167. package/dist/sandbox/review/permission-candidate.js +38 -48
  168. package/dist/sandbox/sandbox.module.js +7 -3
  169. package/dist/sandbox/sandbox.service.d.ts +49 -59
  170. package/dist/sandbox/sandbox.service.js +139 -259
  171. package/dist/schedules/fire.d.ts +15 -6
  172. package/dist/schedules/fire.js +27 -13
  173. package/dist/schedules/grant-rules.js +1 -1
  174. package/dist/schedules/scheduled-tasks.service.d.ts +0 -7
  175. package/dist/schedules/scheduled-tasks.service.js +1 -4
  176. package/dist/schedules/schedules.module.js +5 -3
  177. package/dist/skills/invoke.d.ts +1 -1
  178. package/dist/skills/invoke.js +2 -3
  179. package/dist/tools/approvals.service.d.ts +8 -5
  180. package/dist/tools/approvals.service.js +5 -5
  181. package/dist/tools/builtins/sandbox/bash.js +1 -2
  182. package/dist/tools/builtins/sandbox/common.d.ts +15 -9
  183. package/dist/tools/builtins/sandbox/common.js +37 -38
  184. package/dist/tools/connectors.controller.d.ts +2 -0
  185. package/dist/tools/connectors.schemas.d.ts +2 -0
  186. package/dist/tools/credentials.d.ts +2 -0
  187. package/dist/tools/network-asks.d.ts +19 -22
  188. package/dist/tools/network-asks.js +15 -21
  189. package/dist/tools/oauth/authorization-params.d.ts +7 -0
  190. package/dist/tools/oauth/authorization-params.js +19 -0
  191. package/dist/tools/oauth/flow.js +7 -0
  192. package/dist/tools/oauth/tokens.js +2 -1
  193. package/dist/tools/pipeline.d.ts +6 -7
  194. package/dist/tools/pipeline.js +17 -21
  195. package/dist/tools/tools.module.js +3 -7
  196. package/package.json +3 -4
  197. package/src/migrations/0177_dial_in_contract.sql +32 -0
  198. package/dist/local-devices/device-auth.module.d.ts +0 -7
  199. package/dist/local-devices/device-auth.module.js +0 -25
  200. package/dist/local-devices/device-policy.service.d.ts +0 -213
  201. package/dist/local-devices/device-policy.service.js +0 -605
  202. package/dist/local-devices/instance-bindings.d.ts +0 -82
  203. package/dist/local-devices/instance-bindings.js +0 -307
  204. package/dist/local-devices/local-device-gateway.d.ts +0 -153
  205. package/dist/local-devices/local-device-provider.d.ts +0 -122
  206. package/dist/local-devices/local-device-provider.js +0 -326
  207. package/dist/local-devices/local-devices.module.d.ts +0 -31
  208. package/dist/local-devices/local-devices.module.js +0 -100
  209. package/dist/local-devices/machines.d.ts +0 -211
  210. package/dist/local-devices/machines.js +0 -766
  211. package/dist/local-devices/owner-report.d.ts +0 -81
  212. package/dist/local-devices/owner-report.js +0 -150
  213. package/dist/local-devices/owner-reports.d.ts +0 -48
  214. package/dist/local-devices/owner-reports.js +0 -208
  215. package/dist/local-devices/policy-op-jobs.d.ts +0 -15
  216. package/dist/local-devices/policy-op-jobs.js +0 -12
  217. package/dist/local-devices/policy-summary.d.ts +0 -102
  218. package/dist/local-devices/policy-summary.js +0 -155
  219. package/dist/local-devices/relay.d.ts +0 -166
  220. package/dist/local-devices/relay.js +0 -559
  221. package/dist/tools/device-op-resolver.d.ts +0 -34
  222. package/dist/tools/device-op-resolver.js +0 -120
  223. /package/dist/{local-devices → dial-in}/keys.d.ts +0 -0
  224. /package/dist/{local-devices → dial-in}/keys.js +0 -0
  225. /package/dist/{local-devices → sandbox}/network-grants.module.d.ts +0 -0
  226. /package/dist/{local-devices → sandbox}/network-grants.module.js +0 -0
@@ -1,120 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __param = (this && this.__param) || function (paramIndex, decorator) {
8
- return function (target, key) { decorator(target, key, paramIndex); }
9
- };
10
- import { Inject, Injectable } from "@nestjs/common";
11
- import { KernelDb } from "../infra/database/kernel-db.js";
12
- import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
13
- import { Transactional } from "../infra/database/transactional.decorator.js";
14
- import { DevicePolicyService, } from "../local-devices/device-policy.service.js";
15
- import { opVisibleIn, pendingPolicyOpsOf, } from "../local-devices/policy-summary.js";
16
- /**
17
- * The `device-op-resolve` job (transactional outbox spec §7): records what became of a device
18
- * policy op whose outcome its caller did not record (a crash between the call and the resolve
19
- * transaction, an answer that never came). Owed by the op's intent for when the op can no longer
20
- * reach the machine, and by a hello that reported the op (`device-op-reported-<opId>`).
21
- *
22
- * An op without an entry any more is resolved already: a no-op. Otherwise the outcome is the one
23
- * the hello reported, else the machine's answer to a read-only `policyStatus`: `applied` →
24
- * recorded applied; `refused`, never received (`unknown` to the machine, or `absent` from its
25
- * hello, once the op can no longer reach it) → failed; `started` (the machine stopped between
26
- * its log and its answer), once the op can no longer reach it → applied when the policy it
27
- * reports holds the change, else failed (`interrupted`); no answer (`offline`) → `unknown`, left
28
- * for the machine's next hello. It never sends the change
29
- * again. No op answers a network ask any more: the deployment never adds a host to a local device
30
- * (device protocol 4), so a network ask is only ever a run grant and an op only records its outcome.
31
- */
32
- let DeviceOpResolver = class DeviceOpResolver {
33
- db;
34
- txHost;
35
- policies;
36
- constructor(db, txHost, policies) {
37
- this.db = db;
38
- this.txHost = txHost;
39
- this.policies = policies;
40
- }
41
- async resolve(data) {
42
- const row = await this.db
43
- .selectFrom("device_machines")
44
- .select(["device_id", "pending_policy_ops"])
45
- .where("id", "=", data.machineId)
46
- .executeTakeFirst();
47
- const op = pendingPolicyOpsOf(row?.pending_policy_ops).find((o) => o.id === data.opId);
48
- if (row === undefined || op === undefined)
49
- return;
50
- const result = op.reported !== undefined
51
- ? await this.reportedResult(row.device_id, op, op.reported.outcome)
52
- : statusResult(op, await this.policies.outcomeOf(row.device_id, op.id));
53
- // the machine's device lock is the ordered prelude: the settle locks the ask's conversation,
54
- // approval and run after it (the global order: permission locks before conversation rows)
55
- await withOrderedLocks(() => this.policies.lockMachineDevice(data.machineId), () => this.settle(data, result));
56
- }
57
- /**
58
- * The outcome a hello reported; a refusal's message (a hello carries none) is the machine's
59
- * answer to `policyStatus` when it is connected.
60
- */
61
- async reportedResult(deviceId, op, outcome) {
62
- if (outcome === "applied")
63
- return { outcome: "applied" };
64
- if (outcome === "absent")
65
- return { outcome: "not_received" };
66
- if (outcome === "interrupted")
67
- return { outcome: "interrupted" };
68
- const s = await this.policies.outcomeOf(deviceId, op.id);
69
- const message = s.outcome === "refused" ? s.message : undefined;
70
- return { outcome: "refused", message: (message ?? REFUSED_MESSAGE).slice(0, MAX_MESSAGE) };
71
- }
72
- /** The resolve transaction: the op's outcome. */
73
- async settle(data, result) {
74
- await this.policies.settleIn(data, result);
75
- }
76
- };
77
- __decorate([
78
- Transactional()
79
- ], DeviceOpResolver.prototype, "settle", null);
80
- DeviceOpResolver = __decorate([
81
- Injectable(),
82
- __param(0, Inject(KernelDb)),
83
- __param(1, Inject(TransactionHost)),
84
- __param(2, Inject(DevicePolicyService))
85
- ], DeviceOpResolver);
86
- export { DeviceOpResolver };
87
- const REFUSED_MESSAGE = "The device's machine refused the policy change.";
88
- /** The longest refusal message kept from the machine (as its own op log keeps it). */
89
- const MAX_MESSAGE = 500;
90
- function statusResult(op, s) {
91
- switch (s.outcome) {
92
- case "applied":
93
- return {
94
- outcome: "applied",
95
- ...(s.policy !== undefined && { policy: s.policy }),
96
- // a staged (v3) applied status carries the owner report (B2)
97
- ...(s.ownerCeiling !== undefined && {
98
- ownerCeiling: s.ownerCeiling,
99
- connectionId: s.connectionId ?? null,
100
- }),
101
- };
102
- case "refused":
103
- return { outcome: "refused", message: (s.message ?? REFUSED_MESSAGE).slice(0, MAX_MESSAGE) };
104
- case "started":
105
- // logged `started` only: once the op can no longer reach the machine, the policy it reports
106
- // tells whether the change was written before it stopped
107
- if (Date.now() < op.resolveAt || s.policy === undefined)
108
- return { outcome: "unknown" };
109
- return opVisibleIn(op, s.policy)
110
- ? { outcome: "applied", policy: s.policy }
111
- : { outcome: "interrupted" };
112
- case "unknown":
113
- // unknown to the machine: never received, once the op can no longer reach it (a job run
114
- // early, on a clock running ahead, cannot tell yet)
115
- return Date.now() >= op.resolveAt ? { outcome: "not_received" } : { outcome: "unknown" };
116
- default:
117
- // offline: its next hello tells
118
- return { outcome: "unknown" };
119
- }
120
- }
File without changes
File without changes