@kya-os/checkpoint-shared 1.4.0 → 1.5.1

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 (161) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/beacon-types/index.d.mts +448 -432
  3. package/dist/beacon-types/index.d.mts.map +1 -0
  4. package/dist/beacon-types/index.d.ts +448 -432
  5. package/dist/beacon-types/index.d.ts.map +1 -0
  6. package/dist/beacon-types/index.js +286 -182
  7. package/dist/beacon-types/index.mjs +284 -180
  8. package/dist/beacon-types/index.mjs.map +1 -0
  9. package/dist/browser-posture-cookie-Dmq9Brf_.d.mts +5 -0
  10. package/dist/browser-posture-cookie-Dmq9Brf_.d.mts.map +1 -0
  11. package/dist/browser-posture-cookie-Dmq9Brf_.d.ts +5 -0
  12. package/dist/browser-posture-cookie-Dmq9Brf_.d.ts.map +1 -0
  13. package/dist/browser-posture-cookie.d.mts +2 -0
  14. package/dist/browser-posture-cookie.d.ts +2 -0
  15. package/dist/browser-posture-cookie.js +1 -0
  16. package/dist/browser-posture-cookie.mjs +2 -0
  17. package/dist/browser-posture-cookie.mjs.map +1 -0
  18. package/dist/browser-posture-report.d.mts +48 -44
  19. package/dist/browser-posture-report.d.mts.map +1 -0
  20. package/dist/browser-posture-report.d.ts +48 -44
  21. package/dist/browser-posture-report.d.ts.map +1 -0
  22. package/dist/browser-posture-report.js +1 -1
  23. package/dist/browser-posture-report.mjs +2 -1
  24. package/dist/browser-posture-report.mjs.map +1 -0
  25. package/dist/browser-posture.d.mts +82 -75
  26. package/dist/browser-posture.d.mts.map +1 -0
  27. package/dist/browser-posture.d.ts +82 -75
  28. package/dist/browser-posture.d.ts.map +1 -0
  29. package/dist/browser-posture.js +167 -18993
  30. package/dist/browser-posture.mjs +166 -18990
  31. package/dist/browser-posture.mjs.map +1 -0
  32. package/dist/browser.d.mts +323 -316
  33. package/dist/browser.d.mts.map +1 -0
  34. package/dist/browser.d.ts +323 -316
  35. package/dist/browser.d.ts.map +1 -0
  36. package/dist/browser.js +1 -1
  37. package/dist/browser.mjs +2 -1
  38. package/dist/browser.mjs.map +1 -0
  39. package/dist/canonical-signer/index.d.mts +38 -33
  40. package/dist/canonical-signer/index.d.mts.map +1 -0
  41. package/dist/canonical-signer/index.d.ts +38 -33
  42. package/dist/canonical-signer/index.d.ts.map +1 -0
  43. package/dist/canonical-signer/index.js +411 -181
  44. package/dist/canonical-signer/index.mjs +383 -175
  45. package/dist/canonical-signer/index.mjs.map +1 -0
  46. package/dist/clearance.d.mts +30 -0
  47. package/dist/clearance.d.mts.map +1 -0
  48. package/dist/clearance.d.ts +30 -0
  49. package/dist/clearance.d.ts.map +1 -0
  50. package/dist/clearance.js +120 -0
  51. package/dist/clearance.mjs +112 -0
  52. package/dist/clearance.mjs.map +1 -0
  53. package/dist/client-ip-1y2iXAYW.js +237 -0
  54. package/dist/client-ip-HOfe6ucV.mjs +215 -0
  55. package/dist/client-ip-HOfe6ucV.mjs.map +1 -0
  56. package/dist/deploy/index.d.mts +339 -339
  57. package/dist/deploy/index.d.mts.map +1 -0
  58. package/dist/deploy/index.d.ts +339 -339
  59. package/dist/deploy/index.d.ts.map +1 -0
  60. package/dist/deploy/index.js +505 -413
  61. package/dist/deploy/index.mjs +504 -410
  62. package/dist/deploy/index.mjs.map +1 -0
  63. package/dist/errors/index.d.mts +101 -101
  64. package/dist/errors/index.d.mts.map +1 -0
  65. package/dist/errors/index.d.ts +101 -101
  66. package/dist/errors/index.d.ts.map +1 -0
  67. package/dist/errors/index.js +341 -314
  68. package/dist/errors/index.mjs +340 -311
  69. package/dist/errors/index.mjs.map +1 -0
  70. package/dist/external-jr_S4iSS.d.mts +4187 -0
  71. package/dist/external-jr_S4iSS.d.mts.map +1 -0
  72. package/dist/external-jr_S4iSS.d.ts +4187 -0
  73. package/dist/external-jr_S4iSS.d.ts.map +1 -0
  74. package/dist/gateway/index.d.mts +138 -132
  75. package/dist/gateway/index.d.mts.map +1 -0
  76. package/dist/gateway/index.d.ts +138 -132
  77. package/dist/gateway/index.d.ts.map +1 -0
  78. package/dist/gateway/index.js +117 -81
  79. package/dist/gateway/index.mjs +116 -78
  80. package/dist/gateway/index.mjs.map +1 -0
  81. package/dist/gateway-client-ip.d.mts +59 -0
  82. package/dist/gateway-client-ip.d.mts.map +1 -0
  83. package/dist/gateway-client-ip.d.ts +59 -0
  84. package/dist/gateway-client-ip.d.ts.map +1 -0
  85. package/dist/gateway-client-ip.js +149 -0
  86. package/dist/gateway-client-ip.mjs +139 -0
  87. package/dist/gateway-client-ip.mjs.map +1 -0
  88. package/dist/index.d.mts +14901 -14246
  89. package/dist/index.d.mts.map +1 -0
  90. package/dist/index.d.ts +14901 -14246
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/index.js +15180 -31025
  93. package/dist/index.mjs +15065 -30942
  94. package/dist/index.mjs.map +1 -0
  95. package/dist/mcpi/agentshield-api/index.d.mts +45 -44
  96. package/dist/mcpi/agentshield-api/index.d.mts.map +1 -0
  97. package/dist/mcpi/agentshield-api/index.d.ts +45 -44
  98. package/dist/mcpi/agentshield-api/index.d.ts.map +1 -0
  99. package/dist/mcpi/agentshield-api/index.js +0 -2
  100. package/dist/mcpi/agentshield-api/index.mjs +1 -1
  101. package/dist/mcpi/approval-grant/index.d.mts +63 -61
  102. package/dist/mcpi/approval-grant/index.d.mts.map +1 -0
  103. package/dist/mcpi/approval-grant/index.d.ts +63 -61
  104. package/dist/mcpi/approval-grant/index.d.ts.map +1 -0
  105. package/dist/mcpi/approval-grant/index.js +220 -140
  106. package/dist/mcpi/approval-grant/index.mjs +219 -137
  107. package/dist/mcpi/approval-grant/index.mjs.map +1 -0
  108. package/dist/mcpi/dashboard-config/index.d.mts +2323 -2318
  109. package/dist/mcpi/dashboard-config/index.d.mts.map +1 -0
  110. package/dist/mcpi/dashboard-config/index.d.ts +2323 -2318
  111. package/dist/mcpi/dashboard-config/index.d.ts.map +1 -0
  112. package/dist/mcpi/dashboard-config/index.js +605 -458
  113. package/dist/mcpi/dashboard-config/index.mjs +604 -455
  114. package/dist/mcpi/dashboard-config/index.mjs.map +1 -0
  115. package/dist/mcpi/multibase-ed25519.d.mts +10 -8
  116. package/dist/mcpi/multibase-ed25519.d.mts.map +1 -0
  117. package/dist/mcpi/multibase-ed25519.d.ts +10 -8
  118. package/dist/mcpi/multibase-ed25519.d.ts.map +1 -0
  119. package/dist/mcpi/multibase-ed25519.js +182 -106
  120. package/dist/mcpi/multibase-ed25519.mjs +181 -103
  121. package/dist/mcpi/multibase-ed25519.mjs.map +1 -0
  122. package/dist/patterns-CkRVOdtV.js +243 -0
  123. package/dist/patterns-DzkGy_qk.mjs +173 -0
  124. package/dist/patterns-DzkGy_qk.mjs.map +1 -0
  125. package/dist/project-verification-key-C3L5rd8a.js +41 -0
  126. package/dist/project-verification-key-CgSVX9_m.mjs +37 -0
  127. package/dist/project-verification-key-CgSVX9_m.mjs.map +1 -0
  128. package/dist/rolldown-runtime-iY2fYEqi.mjs +19 -0
  129. package/dist/schemas-BmjNLAE7.js +5677 -0
  130. package/dist/schemas-DxY-dk9y.mjs +5511 -0
  131. package/dist/schemas-DxY-dk9y.mjs.map +1 -0
  132. package/dist/signals/index.d.mts +125 -115
  133. package/dist/signals/index.d.mts.map +1 -0
  134. package/dist/signals/index.d.ts +125 -115
  135. package/dist/signals/index.d.ts.map +1 -0
  136. package/dist/signals/index.js +1693 -1536
  137. package/dist/signals/index.mjs +1692 -1533
  138. package/dist/signals/index.mjs.map +1 -0
  139. package/dist/test-fixtures/index.d.mts +124 -119
  140. package/dist/test-fixtures/index.d.mts.map +1 -0
  141. package/dist/test-fixtures/index.d.ts +124 -119
  142. package/dist/test-fixtures/index.d.ts.map +1 -0
  143. package/dist/test-fixtures/index.js +460 -228
  144. package/dist/test-fixtures/index.mjs +459 -225
  145. package/dist/test-fixtures/index.mjs.map +1 -0
  146. package/dist/tool-protection/index.d.mts +343 -343
  147. package/dist/tool-protection/index.d.mts.map +1 -0
  148. package/dist/tool-protection/index.d.ts +343 -343
  149. package/dist/tool-protection/index.d.ts.map +1 -0
  150. package/dist/tool-protection/index.js +366 -285
  151. package/dist/tool-protection/index.mjs +365 -282
  152. package/dist/tool-protection/index.mjs.map +1 -0
  153. package/fixtures/bot-signal-resolution.json +142 -0
  154. package/fixtures/browser-posture-claims.json +421 -0
  155. package/fixtures/browser-posture-headers.json +46 -0
  156. package/fixtures/detection/reason-codes.json +10 -1
  157. package/fixtures/kya-http/challenge.delegation.fetcher-200.json +9 -3
  158. package/fixtures/kya-http/challenge.delegation.full.json +9 -3
  159. package/fixtures/kya-http/challenge.delegation.minimal.json +9 -3
  160. package/fixtures/kya-http/error-codes.json +7 -2
  161. package/package.json +20 -6
@@ -1,437 +1,529 @@
1
- 'use strict';
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ let zod = require("zod");
2
3
 
3
- var zod = require('zod');
4
-
5
- // src/deploy/index.ts
6
- var KYA_OS_EVENTS_PATH = "/api/v1/kya-os/events";
7
- var DidStringSchema = zod.z.string().min(8, "DID must be at least 8 characters").regex(/^did:[a-z0-9]+:\S+$/, "DID must match format did:<method>:<method-specific-id>");
8
- var FlyRegionSchema = zod.z.enum([
9
- "ams",
10
- // Amsterdam, Netherlands
11
- "arn",
12
- // Stockholm, Sweden
13
- "atl",
14
- // Atlanta, Georgia (US)
15
- "bog",
16
- // Bogotá, Colombia
17
- "bos",
18
- // Boston, Massachusetts (US)
19
- "cdg",
20
- // Paris, France
21
- "den",
22
- // Denver, Colorado (US)
23
- "dfw",
24
- // Dallas, Texas (US)
25
- "ewr",
26
- // Secaucus, NJ (US)
27
- "eze",
28
- // Ezeiza, Argentina
29
- "fra",
30
- // Frankfurt, Germany
31
- "gdl",
32
- // Guadalajara, Mexico
33
- "gig",
34
- // Rio de Janeiro, Brazil
35
- "gru",
36
- // São Paulo, Brazil
37
- "hkg",
38
- // Hong Kong
39
- "iad",
40
- // Ashburn, Virginia (US)
41
- "jnb",
42
- // Johannesburg, South Africa
43
- "lax",
44
- // Los Angeles, California (US)
45
- "lhr",
46
- // London, United Kingdom
47
- "mad",
48
- // Madrid, Spain
49
- "mia",
50
- // Miami, Florida (US)
51
- "nrt",
52
- // Tokyo, Japan
53
- "ord",
54
- // Chicago, Illinois (US)
55
- "otp",
56
- // Bucharest, Romania
57
- "phx",
58
- // Phoenix, Arizona (US)
59
- "qro",
60
- // Querétaro, Mexico
61
- "scl",
62
- // Santiago, Chile
63
- "sea",
64
- // Seattle, Washington (US)
65
- "sin",
66
- // Singapore
67
- "sjc",
68
- // San Jose, California (US)
69
- "syd",
70
- // Sydney, Australia
71
- "waw",
72
- // Warsaw, Poland
73
- "yul",
74
- // Montreal, Canada
75
- "yyz"
76
- // Toronto, Canada
4
+ //#region src/deploy/index.ts
5
+ /**
6
+ * Managed Agent Deployment + Compute Process Contracts (checkpoint-owned subset)
7
+ *
8
+ * Schemas for the managed hosting tier (agents on Fly.io) and the
9
+ * `@kya-os/compute` ⇄ Checkpoint heartbeat/config/control protocol.
10
+ *
11
+ * Ported into checkpoint-shared from `@kya-os/contracts/agent-deployment` +
12
+ * `@kya-os/contracts/compute` as part of the E6 / C-series decommission
13
+ * (#2914 / #2917). Only the symbols re-exported by
14
+ * `apps/web/lib/types/molti-deploy-contracts.ts` (plus their transitive deps —
15
+ * `DidStringSchema`, the compute command sub-schemas) are ported.
16
+ *
17
+ * @module @kya-os/checkpoint-shared/deploy
18
+ */
19
+ /**
20
+ * The KYA-OS activity-events ingest path (SPEC-EVENTS v0.1 batch endpoint).
21
+ *
22
+ * This is a CROSS-REPO CONTRACT. The Tier 2 worker runtime
23
+ * (`@kya-os/mcp-i-cloudflare`) POSTs `tool.invoked` (and the other SPEC-EVENTS
24
+ * types) to `${AGENTSHIELD_API_URL}${KYA_OS_EVENTS_PATH}`, authenticated by the
25
+ * project API key. Checkpoint serves the batch ingest at this exact path
26
+ * (`apps/web/app${KYA_OS_EVENTS_PATH}/route.ts`) and fans events out into the
27
+ * `detections` table behind `/activity`.
28
+ *
29
+ * Managed deploy deliberately injects NO `KYA_OS_EVENTS_*` secret and relies on
30
+ * this derivation instead, so the two sides agree only by matching this literal.
31
+ * Changing it on either side silently drops all managed activity — it is pinned
32
+ * by a contract test. Keep this value and the worker's derivation in sync.
33
+ */
34
+ const KYA_OS_EVENTS_PATH = "/api/v1/kya-os/events";
35
+ /**
36
+ * Validated DID string schema.
37
+ * Reusable across all contract files that reference agent DIDs.
38
+ *
39
+ * Format: `did:<method>:<method-specific-id>`
40
+ * - method: 1+ lowercase alphanumeric chars
41
+ * - method-specific-id: 1+ non-whitespace chars
42
+ *
43
+ * Examples: `did:key:z6Mk...`, `did:web:example.com`
44
+ */
45
+ const DidStringSchema = zod.z.string().min(8, "DID must be at least 8 characters").regex(/^did:[a-z0-9]+:\S+$/, "DID must match format did:<method>:<method-specific-id>");
46
+ /**
47
+ * Fly.io deployment regions.
48
+ * Enumerated to prevent arbitrary strings from being accepted.
49
+ * @see https://fly.io/docs/reference/regions/
50
+ */
51
+ const FlyRegionSchema = zod.z.enum([
52
+ "ams",
53
+ "arn",
54
+ "atl",
55
+ "bog",
56
+ "bos",
57
+ "cdg",
58
+ "den",
59
+ "dfw",
60
+ "ewr",
61
+ "eze",
62
+ "fra",
63
+ "gdl",
64
+ "gig",
65
+ "gru",
66
+ "hkg",
67
+ "iad",
68
+ "jnb",
69
+ "lax",
70
+ "lhr",
71
+ "mad",
72
+ "mia",
73
+ "nrt",
74
+ "ord",
75
+ "otp",
76
+ "phx",
77
+ "qro",
78
+ "scl",
79
+ "sea",
80
+ "sin",
81
+ "sjc",
82
+ "syd",
83
+ "waw",
84
+ "yul",
85
+ "yyz"
86
+ ]);
87
+ /**
88
+ * Hosting mode discriminator — differentiates between deploy backends:
89
+ * - `byok`: self-managed deploy in the customer's own Cloudflare account
90
+ * (customer runs the deploy themselves).
91
+ * - `managed`: platform-managed deploy in our Cloudflare account via Workers
92
+ * for Platforms (dispatch namespace).
93
+ * - `managed-byoa`: platform-managed deploy that lands in the customer's own
94
+ * ("bring your own account") Cloudflare account via the standard Workers API,
95
+ * after the org connects Cloudflare over OAuth/token (KYA-906-C).
96
+ */
97
+ const HostingModeSchema = zod.z.enum([
98
+ "byok",
99
+ "managed",
100
+ "managed-byoa"
101
+ ]);
102
+ const AuditAssuranceProfileSchema = zod.z.enum([
103
+ "AAP-0",
104
+ "AAP-1",
105
+ "AAP-2",
106
+ "AAP-3",
107
+ "AAP-4"
108
+ ]);
109
+ const AuditDeliveryModeSchema = zod.z.enum([
110
+ "best-effort",
111
+ "buffered",
112
+ "required"
77
113
  ]);
78
- var HostingModeSchema = zod.z.enum(["byok", "managed", "managed-byoa"]);
79
- var AuditAssuranceProfileSchema = zod.z.enum(["AAP-0", "AAP-1", "AAP-2", "AAP-3", "AAP-4"]);
80
- var AuditDeliveryModeSchema = zod.z.enum(["best-effort", "buffered", "required"]);
81
- var AuditDeploymentConfigSchema = zod.z.object({
82
- enabled: zod.z.boolean(),
83
- requestedProfile: AuditAssuranceProfileSchema,
84
- delivery: AuditDeliveryModeSchema,
85
- evidenceMode: zod.z.enum(["none", "encrypted-separate", "encrypted-inline"]),
86
- retentionClass: zod.z.string().min(1).max(128),
87
- retentionDays: zod.z.number().int().min(0).max(3650),
88
- residency: zod.z.enum(["inherit-project", "us", "eu", "global"]),
89
- keyCustody: zod.z.enum(["none", "checkpoint-managed", "customer-managed-kms"]),
90
- recorderTopology: zod.z.enum(["none", "self-hosted", "managed", "verified-mirror"])
114
+ /**
115
+ * Serializable request contract shared by the wizard and every deploy lane.
116
+ * `requestedProfile` is intent, never an assurance claim. Only readiness
117
+ * evaluation against observed runtime capabilities yields `effectiveProfile`.
118
+ */
119
+ const AuditDeploymentConfigSchema = zod.z.object({
120
+ enabled: zod.z.boolean(),
121
+ requestedProfile: AuditAssuranceProfileSchema,
122
+ delivery: AuditDeliveryModeSchema,
123
+ evidenceMode: zod.z.enum([
124
+ "none",
125
+ "encrypted-separate",
126
+ "encrypted-inline"
127
+ ]),
128
+ retentionClass: zod.z.string().min(1).max(128),
129
+ retentionDays: zod.z.number().int().min(0).max(3650),
130
+ residency: zod.z.enum([
131
+ "inherit-project",
132
+ "us",
133
+ "eu",
134
+ "global"
135
+ ]),
136
+ keyCustody: zod.z.enum([
137
+ "none",
138
+ "checkpoint-managed",
139
+ "customer-managed-kms"
140
+ ]),
141
+ recorderTopology: zod.z.enum([
142
+ "none",
143
+ "self-hosted",
144
+ "managed",
145
+ "verified-mirror"
146
+ ])
91
147
  }).strict().superRefine((value, context) => {
92
- if (!value.enabled && value.requestedProfile !== "AAP-0") {
93
- context.addIssue({
94
- code: zod.z.ZodIssueCode.custom,
95
- path: ["requestedProfile"],
96
- message: "Disabled audit configuration must request AAP-0"
97
- });
98
- }
99
- if (value.enabled && value.requestedProfile === "AAP-0") {
100
- context.addIssue({
101
- code: zod.z.ZodIssueCode.custom,
102
- path: ["requestedProfile"],
103
- message: "Enabled audit configuration must request AAP-1 or higher"
104
- });
105
- }
106
- if (Number(value.requestedProfile.slice(-1)) >= 2 && value.delivery === "best-effort") {
107
- context.addIssue({
108
- code: zod.z.ZodIssueCode.custom,
109
- path: ["delivery"],
110
- message: "AAP-2 or higher cannot use best-effort delivery"
111
- });
112
- }
113
- if (!value.enabled && (value.keyCustody !== "none" || value.recorderTopology !== "none")) {
114
- context.addIssue({
115
- code: zod.z.ZodIssueCode.custom,
116
- message: "Disabled audit configuration cannot claim key custody or recorder topology"
117
- });
118
- }
148
+ if (!value.enabled && value.requestedProfile !== "AAP-0") context.addIssue({
149
+ code: zod.z.ZodIssueCode.custom,
150
+ path: ["requestedProfile"],
151
+ message: "Disabled audit configuration must request AAP-0"
152
+ });
153
+ if (value.enabled && value.requestedProfile === "AAP-0") context.addIssue({
154
+ code: zod.z.ZodIssueCode.custom,
155
+ path: ["requestedProfile"],
156
+ message: "Enabled audit configuration must request AAP-1 or higher"
157
+ });
158
+ if (Number(value.requestedProfile.slice(-1)) >= 2 && value.delivery === "best-effort") context.addIssue({
159
+ code: zod.z.ZodIssueCode.custom,
160
+ path: ["delivery"],
161
+ message: "AAP-2 or higher cannot use best-effort delivery"
162
+ });
163
+ if (!value.enabled && (value.keyCustody !== "none" || value.recorderTopology !== "none")) context.addIssue({
164
+ code: zod.z.ZodIssueCode.custom,
165
+ message: "Disabled audit configuration cannot claim key custody or recorder topology"
166
+ });
119
167
  });
120
- var NEW_MANAGED_AUDIT_DEPLOYMENT_DEFAULT = Object.freeze({
121
- enabled: true,
122
- requestedProfile: "AAP-2",
123
- delivery: "buffered",
124
- evidenceMode: "encrypted-separate",
125
- retentionClass: "integrity-ledger",
126
- retentionDays: 365,
127
- residency: "inherit-project",
128
- keyCustody: "checkpoint-managed",
129
- recorderTopology: "managed"
168
+ /** Applied only when a user starts a new platform-managed deployment. */
169
+ const NEW_MANAGED_AUDIT_DEPLOYMENT_DEFAULT = Object.freeze({
170
+ enabled: true,
171
+ requestedProfile: "AAP-2",
172
+ delivery: "buffered",
173
+ evidenceMode: "encrypted-separate",
174
+ retentionClass: "integrity-ledger",
175
+ retentionDays: 365,
176
+ residency: "inherit-project",
177
+ keyCustody: "checkpoint-managed",
178
+ recorderTopology: "managed"
130
179
  });
131
- var ABSENT_AUDIT_DEPLOYMENT_CONFIG = Object.freeze({
132
- enabled: false,
133
- requestedProfile: "AAP-0",
134
- delivery: "best-effort",
135
- evidenceMode: "none",
136
- retentionClass: "none",
137
- retentionDays: 0,
138
- residency: "inherit-project",
139
- keyCustody: "none",
140
- recorderTopology: "none"
180
+ /**
181
+ * Missing audit config in an already persisted manifest is always AAP-0.
182
+ * This prevents a dashboard or redeploy from silently upgrading old workers.
183
+ */
184
+ const ABSENT_AUDIT_DEPLOYMENT_CONFIG = Object.freeze({
185
+ enabled: false,
186
+ requestedProfile: "AAP-0",
187
+ delivery: "best-effort",
188
+ evidenceMode: "none",
189
+ retentionClass: "none",
190
+ retentionDays: 0,
191
+ residency: "inherit-project",
192
+ keyCustody: "none",
193
+ recorderTopology: "none"
141
194
  });
142
- var AuditRuntimeCapabilitiesSchema = zod.z.object({
143
- recorderTopology: zod.z.enum(["none", "self-hosted", "managed", "verified-mirror"]),
144
- delivery: AuditDeliveryModeSchema,
145
- journalDurability: zod.z.enum(["none", "ephemeral", "durable"]),
146
- atomicAppend: zod.z.boolean(),
147
- sourceHighWater: zod.z.boolean(),
148
- merkleCheckpoints: zod.z.boolean(),
149
- independentObservation: zod.z.boolean(),
150
- supportingAnchors: zod.z.array(zod.z.enum(["worm", "rfc3161", "scitt"])),
151
- evidenceRetention: zod.z.enum(["none", "inline", "separate"])
195
+ const AuditRuntimeCapabilitiesSchema = zod.z.object({
196
+ recorderTopology: zod.z.enum([
197
+ "none",
198
+ "self-hosted",
199
+ "managed",
200
+ "verified-mirror"
201
+ ]),
202
+ delivery: AuditDeliveryModeSchema,
203
+ journalDurability: zod.z.enum([
204
+ "none",
205
+ "ephemeral",
206
+ "durable"
207
+ ]),
208
+ atomicAppend: zod.z.boolean(),
209
+ sourceHighWater: zod.z.boolean(),
210
+ merkleCheckpoints: zod.z.boolean(),
211
+ independentObservation: zod.z.boolean(),
212
+ supportingAnchors: zod.z.array(zod.z.enum([
213
+ "worm",
214
+ "rfc3161",
215
+ "scitt"
216
+ ])),
217
+ evidenceRetention: zod.z.enum([
218
+ "none",
219
+ "inline",
220
+ "separate"
221
+ ])
152
222
  }).strict();
153
- var AuditRuntimeCanaryResultSchema = zod.z.object({
154
- passed: zod.z.boolean(),
155
- observedAt: zod.z.number().int().nonnegative(),
156
- capabilities: AuditRuntimeCapabilitiesSchema,
157
- checks: zod.z.array(
158
- zod.z.object({
159
- id: zod.z.string().min(1).max(128),
160
- passed: zod.z.boolean()
161
- }).strict()
162
- ).min(1),
163
- bundleHash: zod.z.string().min(1).max(256).optional()
223
+ const AuditRuntimeCanaryResultSchema = zod.z.object({
224
+ passed: zod.z.boolean(),
225
+ observedAt: zod.z.number().int().nonnegative(),
226
+ capabilities: AuditRuntimeCapabilitiesSchema,
227
+ checks: zod.z.array(zod.z.object({
228
+ id: zod.z.string().min(1).max(128),
229
+ passed: zod.z.boolean()
230
+ }).strict()).min(1),
231
+ bundleHash: zod.z.string().min(1).max(256).optional()
164
232
  }).strict().superRefine((value, context) => {
165
- if (value.passed !== value.checks.every((check) => check.passed)) {
166
- context.addIssue({
167
- code: zod.z.ZodIssueCode.custom,
168
- path: ["passed"],
169
- message: "Canary result must equal the aggregate of its mechanical checks"
170
- });
171
- }
233
+ if (value.passed !== value.checks.every((check) => check.passed)) context.addIssue({
234
+ code: zod.z.ZodIssueCode.custom,
235
+ path: ["passed"],
236
+ message: "Canary result must equal the aggregate of its mechanical checks"
237
+ });
172
238
  });
173
239
  function requiredAuditRuntimeCanaryChecks(capabilities) {
174
- const checks = [
175
- "recorder_round_trip",
176
- "verified_receipt",
177
- "idempotent_retry",
178
- "event_identity_conflict",
179
- "source_state"
180
- ];
181
- if (capabilities.delivery === "buffered") checks.push("buffered_outbox");
182
- if (capabilities.evidenceRetention !== "none") checks.push("evidence_write_verified");
183
- return checks;
240
+ const checks = [
241
+ "recorder_round_trip",
242
+ "verified_receipt",
243
+ "idempotent_retry",
244
+ "event_identity_conflict",
245
+ "source_state"
246
+ ];
247
+ if (capabilities.delivery === "buffered") checks.push("buffered_outbox");
248
+ if (capabilities.evidenceRetention !== "none") checks.push("evidence_write_verified");
249
+ return checks;
184
250
  }
185
- var AuditDeploymentReadinessSchema = zod.z.object({
186
- requestedProfile: AuditAssuranceProfileSchema,
187
- effectiveProfile: AuditAssuranceProfileSchema,
188
- status: zod.z.enum(["disabled", "ready", "degraded"]),
189
- capabilities: AuditRuntimeCapabilitiesSchema.nullable(),
190
- canary: AuditRuntimeCanaryResultSchema.nullable(),
191
- reasonCodes: zod.z.array(zod.z.string().min(1).max(128))
251
+ const AuditDeploymentReadinessSchema = zod.z.object({
252
+ requestedProfile: AuditAssuranceProfileSchema,
253
+ effectiveProfile: AuditAssuranceProfileSchema,
254
+ status: zod.z.enum([
255
+ "disabled",
256
+ "ready",
257
+ "degraded"
258
+ ]),
259
+ capabilities: AuditRuntimeCapabilitiesSchema.nullable(),
260
+ canary: AuditRuntimeCanaryResultSchema.nullable(),
261
+ reasonCodes: zod.z.array(zod.z.string().min(1).max(128))
192
262
  }).strict();
193
- var PROFILE_BY_LEVEL = ["AAP-0", "AAP-1", "AAP-2", "AAP-3", "AAP-4"];
263
+ const PROFILE_BY_LEVEL = [
264
+ "AAP-0",
265
+ "AAP-1",
266
+ "AAP-2",
267
+ "AAP-3",
268
+ "AAP-4"
269
+ ];
194
270
  function resolveAuditDeploymentReadiness(config, capabilities, canary) {
195
- const requested = AuditDeploymentConfigSchema.parse(config ?? ABSENT_AUDIT_DEPLOYMENT_CONFIG);
196
- const observedCanary = canary ? AuditRuntimeCanaryResultSchema.parse(canary) : null;
197
- if (!requested.enabled) {
198
- return {
199
- requestedProfile: "AAP-0",
200
- effectiveProfile: "AAP-0",
201
- status: "disabled",
202
- capabilities: capabilities ?? null,
203
- canary: observedCanary,
204
- reasonCodes: ["audit_not_configured"]
205
- };
206
- }
207
- const observedCapabilities = capabilities ?? observedCanary?.capabilities;
208
- if (!observedCapabilities) {
209
- return {
210
- requestedProfile: requested.requestedProfile,
211
- effectiveProfile: "AAP-0",
212
- status: "degraded",
213
- capabilities: null,
214
- canary: observedCanary,
215
- reasonCodes: ["runtime_capabilities_unavailable"]
216
- };
217
- }
218
- const observed = AuditRuntimeCapabilitiesSchema.parse(observedCapabilities);
219
- if (!observedCanary) {
220
- return {
221
- requestedProfile: requested.requestedProfile,
222
- effectiveProfile: "AAP-0",
223
- status: "degraded",
224
- capabilities: observed,
225
- canary: null,
226
- reasonCodes: ["runtime_canary_required"]
227
- };
228
- }
229
- if (!observedCanary.passed || JSON.stringify(observedCanary.capabilities) !== JSON.stringify(observed)) {
230
- return {
231
- requestedProfile: requested.requestedProfile,
232
- effectiveProfile: "AAP-0",
233
- status: "degraded",
234
- capabilities: observed,
235
- canary: observedCanary,
236
- reasonCodes: [
237
- observedCanary.passed ? "runtime_canary_capability_mismatch" : "runtime_canary_failed"
238
- ]
239
- };
240
- }
241
- const passedChecks = new Set(
242
- observedCanary.checks.filter((check) => check.passed).map((check) => check.id)
243
- );
244
- if (requiredAuditRuntimeCanaryChecks(observed).some((check) => !passedChecks.has(check))) {
245
- return {
246
- requestedProfile: requested.requestedProfile,
247
- effectiveProfile: "AAP-0",
248
- status: "degraded",
249
- capabilities: observed,
250
- canary: observedCanary,
251
- reasonCodes: ["runtime_canary_incomplete"]
252
- };
253
- }
254
- let maximum = 0;
255
- const reasons = [];
256
- if (observed.recorderTopology !== requested.recorderTopology) {
257
- reasons.push("recorder_topology_mismatch");
258
- }
259
- const deliveryRank = { "best-effort": 0, buffered: 1, required: 2 };
260
- if (deliveryRank[observed.delivery] < deliveryRank[requested.delivery]) {
261
- reasons.push("delivery_mode_mismatch");
262
- }
263
- const expectedEvidence = requested.evidenceMode === "none" ? "none" : requested.evidenceMode === "encrypted-inline" ? "inline" : "separate";
264
- if (expectedEvidence !== observed.evidenceRetention) {
265
- reasons.push("evidence_retention_mismatch");
266
- }
267
- if (reasons.length > 0) {
268
- return {
269
- requestedProfile: requested.requestedProfile,
270
- effectiveProfile: "AAP-0",
271
- status: "degraded",
272
- capabilities: observed,
273
- canary: observedCanary,
274
- reasonCodes: reasons
275
- };
276
- }
277
- if (observed.recorderTopology !== "none" && observed.journalDurability !== "none") maximum = 1;
278
- else reasons.push("recorder_or_journal_unavailable");
279
- if (maximum >= 1 && observed.journalDurability === "durable" && observed.atomicAppend && observed.delivery !== "best-effort") {
280
- maximum = 2;
281
- } else if (Number(requested.requestedProfile.slice(-1)) >= 2) {
282
- reasons.push("durable_atomic_buffered_append_unavailable");
283
- }
284
- if (maximum >= 2 && observed.merkleCheckpoints && observed.sourceHighWater) maximum = 3;
285
- else if (Number(requested.requestedProfile.slice(-1)) >= 3) {
286
- reasons.push("checkpoint_or_source_high_water_unavailable");
287
- }
288
- if (maximum >= 3 && observed.independentObservation && observed.supportingAnchors.length > 0) {
289
- maximum = 4;
290
- } else if (Number(requested.requestedProfile.slice(-1)) >= 4) {
291
- reasons.push("independent_observation_or_anchor_unavailable");
292
- }
293
- const requestedLevel = Number(requested.requestedProfile.slice(-1));
294
- const effectiveLevel = Math.min(requestedLevel, maximum);
295
- return {
296
- requestedProfile: requested.requestedProfile,
297
- effectiveProfile: PROFILE_BY_LEVEL[effectiveLevel],
298
- status: effectiveLevel === requestedLevel && reasons.length === 0 ? "ready" : "degraded",
299
- capabilities: observed,
300
- canary: observedCanary,
301
- reasonCodes: reasons
302
- };
271
+ const requested = AuditDeploymentConfigSchema.parse(config ?? ABSENT_AUDIT_DEPLOYMENT_CONFIG);
272
+ const observedCanary = canary ? AuditRuntimeCanaryResultSchema.parse(canary) : null;
273
+ if (!requested.enabled) return {
274
+ requestedProfile: "AAP-0",
275
+ effectiveProfile: "AAP-0",
276
+ status: "disabled",
277
+ capabilities: capabilities ?? null,
278
+ canary: observedCanary,
279
+ reasonCodes: ["audit_not_configured"]
280
+ };
281
+ const observedCapabilities = capabilities ?? observedCanary?.capabilities;
282
+ if (!observedCapabilities) return {
283
+ requestedProfile: requested.requestedProfile,
284
+ effectiveProfile: "AAP-0",
285
+ status: "degraded",
286
+ capabilities: null,
287
+ canary: observedCanary,
288
+ reasonCodes: ["runtime_capabilities_unavailable"]
289
+ };
290
+ const observed = AuditRuntimeCapabilitiesSchema.parse(observedCapabilities);
291
+ if (!observedCanary) return {
292
+ requestedProfile: requested.requestedProfile,
293
+ effectiveProfile: "AAP-0",
294
+ status: "degraded",
295
+ capabilities: observed,
296
+ canary: null,
297
+ reasonCodes: ["runtime_canary_required"]
298
+ };
299
+ if (!observedCanary.passed || JSON.stringify(observedCanary.capabilities) !== JSON.stringify(observed)) return {
300
+ requestedProfile: requested.requestedProfile,
301
+ effectiveProfile: "AAP-0",
302
+ status: "degraded",
303
+ capabilities: observed,
304
+ canary: observedCanary,
305
+ reasonCodes: [observedCanary.passed ? "runtime_canary_capability_mismatch" : "runtime_canary_failed"]
306
+ };
307
+ const passedChecks = new Set(observedCanary.checks.filter((check) => check.passed).map((check) => check.id));
308
+ if (requiredAuditRuntimeCanaryChecks(observed).some((check) => !passedChecks.has(check))) return {
309
+ requestedProfile: requested.requestedProfile,
310
+ effectiveProfile: "AAP-0",
311
+ status: "degraded",
312
+ capabilities: observed,
313
+ canary: observedCanary,
314
+ reasonCodes: ["runtime_canary_incomplete"]
315
+ };
316
+ let maximum = 0;
317
+ const reasons = [];
318
+ if (observed.recorderTopology !== requested.recorderTopology) reasons.push("recorder_topology_mismatch");
319
+ const deliveryRank = {
320
+ "best-effort": 0,
321
+ buffered: 1,
322
+ required: 2
323
+ };
324
+ if (deliveryRank[observed.delivery] < deliveryRank[requested.delivery]) reasons.push("delivery_mode_mismatch");
325
+ if ((requested.evidenceMode === "none" ? "none" : requested.evidenceMode === "encrypted-inline" ? "inline" : "separate") !== observed.evidenceRetention) reasons.push("evidence_retention_mismatch");
326
+ if (reasons.length > 0) return {
327
+ requestedProfile: requested.requestedProfile,
328
+ effectiveProfile: "AAP-0",
329
+ status: "degraded",
330
+ capabilities: observed,
331
+ canary: observedCanary,
332
+ reasonCodes: reasons
333
+ };
334
+ if (observed.recorderTopology !== "none" && observed.journalDurability !== "none") maximum = 1;
335
+ else reasons.push("recorder_or_journal_unavailable");
336
+ if (maximum >= 1 && observed.journalDurability === "durable" && observed.atomicAppend && observed.delivery !== "best-effort") maximum = 2;
337
+ else if (Number(requested.requestedProfile.slice(-1)) >= 2) reasons.push("durable_atomic_buffered_append_unavailable");
338
+ if (maximum >= 2 && observed.merkleCheckpoints && observed.sourceHighWater) maximum = 3;
339
+ else if (Number(requested.requestedProfile.slice(-1)) >= 3) reasons.push("checkpoint_or_source_high_water_unavailable");
340
+ if (maximum >= 3 && observed.independentObservation && observed.supportingAnchors.length > 0) maximum = 4;
341
+ else if (Number(requested.requestedProfile.slice(-1)) >= 4) reasons.push("independent_observation_or_anchor_unavailable");
342
+ const requestedLevel = Number(requested.requestedProfile.slice(-1));
343
+ const effectiveLevel = Math.min(requestedLevel, maximum);
344
+ return {
345
+ requestedProfile: requested.requestedProfile,
346
+ effectiveProfile: PROFILE_BY_LEVEL[effectiveLevel],
347
+ status: effectiveLevel === requestedLevel && reasons.length === 0 ? "ready" : "degraded",
348
+ capabilities: observed,
349
+ canary: observedCanary,
350
+ reasonCodes: reasons
351
+ };
303
352
  }
304
- var ManagedDeployStepStatusSchema = zod.z.enum([
305
- "pending",
306
- "in_progress",
307
- "completed",
308
- "failed",
309
- "skipped"
353
+ /**
354
+ * Deploy step status — reuses same status enum as BYOK.
355
+ */
356
+ const ManagedDeployStepStatusSchema = zod.z.enum([
357
+ "pending",
358
+ "in_progress",
359
+ "completed",
360
+ "failed",
361
+ "skipped"
310
362
  ]);
311
- var HeartbeatRequestSchema = zod.z.object({
312
- /** Agent DID this heartbeat is for */
313
- agentDid: DidStringSchema,
314
- /** Current compute process status */
315
- status: zod.z.enum(["starting", "running", "error", "stopping"]),
316
- /** @kya-os/compute package version (from package.json) */
317
- computeVersion: zod.z.string().min(1).max(50),
318
- /** Installed OpenClaw version (from npm ls) */
319
- openclawVersion: zod.z.string().max(50).optional(),
320
- /** Fly machine ID (from FLY_MACHINE_ID env var) */
321
- machineId: zod.z.string().max(255).optional(),
322
- /** Seconds since compute process started */
323
- uptimeSeconds: zod.z.number().nonnegative().optional(),
324
- /** Current RSS memory in MB */
325
- memoryMb: zod.z.number().nonnegative().optional()
363
+ /**
364
+ * Heartbeat request body.
365
+ * Sent by compute process: POST /api/v1/molti/agents/{did}/heartbeat
366
+ * Auth: X-Heartbeat-Token header
367
+ */
368
+ const HeartbeatRequestSchema = zod.z.object({
369
+ /** Agent DID this heartbeat is for */
370
+ agentDid: DidStringSchema,
371
+ /** Current compute process status */
372
+ status: zod.z.enum([
373
+ "starting",
374
+ "running",
375
+ "error",
376
+ "stopping"
377
+ ]),
378
+ /** @kya-os/compute package version (from package.json) */
379
+ computeVersion: zod.z.string().min(1).max(50),
380
+ /** Installed OpenClaw version (from npm ls) */
381
+ openclawVersion: zod.z.string().max(50).optional(),
382
+ /** Fly machine ID (from FLY_MACHINE_ID env var) */
383
+ machineId: zod.z.string().max(255).optional(),
384
+ /** Seconds since compute process started */
385
+ uptimeSeconds: zod.z.number().nonnegative().optional(),
386
+ /** Current RSS memory in MB */
387
+ memoryMb: zod.z.number().nonnegative().optional()
326
388
  });
327
- var StopCommandSchema = zod.z.object({
328
- type: zod.z.literal("stop")
329
- }).strict();
330
- var RestartCommandSchema = zod.z.object({
331
- type: zod.z.literal("restart")
332
- }).strict();
333
- var UpdateConfigCommandSchema = zod.z.object({
334
- type: zod.z.literal("update_config")
335
- }).strict();
336
- var UpdateVersionCommandSchema = zod.z.object({
337
- type: zod.z.literal("update_version"),
338
- payload: zod.z.object({
339
- /** Target OpenClaw version to install */
340
- version: zod.z.string().min(1).max(50)
341
- })
389
+ /**
390
+ * Stop command — graceful shutdown, no payload accepted.
391
+ */
392
+ const StopCommandSchema = zod.z.object({ type: zod.z.literal("stop") }).strict();
393
+ /**
394
+ * Restart command — restart the compute process, no payload accepted.
395
+ */
396
+ const RestartCommandSchema = zod.z.object({ type: zod.z.literal("restart") }).strict();
397
+ /**
398
+ * Update config command — triggers config re-fetch, no payload accepted.
399
+ */
400
+ const UpdateConfigCommandSchema = zod.z.object({ type: zod.z.literal("update_config") }).strict();
401
+ /**
402
+ * Update version command — requires target version in payload.
403
+ */
404
+ const UpdateVersionCommandSchema = zod.z.object({
405
+ type: zod.z.literal("update_version"),
406
+ payload: zod.z.object({
407
+ /** Target OpenClaw version to install */
408
+ version: zod.z.string().min(1).max(50) })
342
409
  }).strict();
343
- var ComputeCommandSchema = zod.z.discriminatedUnion("type", [
344
- StopCommandSchema,
345
- RestartCommandSchema,
346
- UpdateConfigCommandSchema,
347
- UpdateVersionCommandSchema
410
+ /**
411
+ * Command that Agent Shield can send to the compute process
412
+ * via the heartbeat response.
413
+ *
414
+ * Discriminated union by `type` field:
415
+ * - `stop` / `restart` / `update_config` — no payload
416
+ * - `update_version` — requires `{ version: string }` payload
417
+ */
418
+ const ComputeCommandSchema = zod.z.discriminatedUnion("type", [
419
+ StopCommandSchema,
420
+ RestartCommandSchema,
421
+ UpdateConfigCommandSchema,
422
+ UpdateVersionCommandSchema
348
423
  ]);
349
- var HeartbeatResponseSchema = zod.z.object({
350
- /** Always true for successful heartbeats */
351
- ack: zod.z.literal(true),
352
- /** Pending commands for the compute process to execute */
353
- commands: zod.z.array(ComputeCommandSchema).default([]),
354
- /** ISO timestamp of last config change (compute compares to detect updates) */
355
- configUpdatedAt: zod.z.string().datetime().optional()
424
+ /**
425
+ * Heartbeat response from Agent Shield.
426
+ * Returned by: POST /api/v1/molti/agents/{did}/heartbeat
427
+ */
428
+ const HeartbeatResponseSchema = zod.z.object({
429
+ /** Always true for successful heartbeats */
430
+ ack: zod.z.literal(true),
431
+ /** Pending commands for the compute process to execute */
432
+ commands: zod.z.array(ComputeCommandSchema).default([]),
433
+ /** ISO timestamp of last config change (compute compares to detect updates) */
434
+ configUpdatedAt: zod.z.string().datetime().optional()
356
435
  });
357
- var ConfigBundleSchema = zod.z.object({
358
- /** Schema version — 2 for managed bundles */
359
- version: zod.z.number().int().positive(),
360
- /** Kill switch — if true, compute must exit immediately */
361
- killed: zod.z.boolean(),
362
- /** Target OpenClaw version to install */
363
- openclawVersion: zod.z.string().min(1).max(50),
364
- /** Agent personality/system prompt file contents (max 100KB) */
365
- soulFile: zod.z.string().max(1e5).nullable(),
366
- /** Gateway auth token for OpenClaw */
367
- gatewayToken: zod.z.string().min(1).max(500),
368
- /** Channel configurations */
369
- channels: zod.z.object({
370
- telegram: zod.z.object({
371
- enabled: zod.z.boolean(),
372
- token: zod.z.string().optional()
373
- }).optional(),
374
- discord: zod.z.object({
375
- enabled: zod.z.boolean(),
376
- token: zod.z.string().optional()
377
- }).optional(),
378
- slack: zod.z.object({
379
- enabled: zod.z.boolean(),
380
- token: zod.z.string().optional(),
381
- appToken: zod.z.string().optional()
382
- }).optional(),
383
- whatsapp: zod.z.object({
384
- enabled: zod.z.boolean()
385
- }).strict().optional()
386
- }),
387
- /** AI provider configuration — key is decrypted, sent over TLS */
388
- aiProvider: zod.z.object({
389
- type: zod.z.enum(["anthropic", "openai"]),
390
- apiKey: zod.z.string().min(1).max(500),
391
- /**
392
- * Optional base URL override. When set, OpenClaw routes all provider
393
- * traffic through this URL instead of the provider's default endpoint.
394
- * Used by managed deployments where AgentShield issues a per-deployment
395
- * gateway token and proxies to the upstream provider with budget tracking.
396
- */
397
- baseUrl: zod.z.string().url().optional()
398
- }),
399
- /**
400
- * Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).
401
- * Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —
402
- * the primary token-cost lever. Examples: "30m" (active), "6h" (idle),
403
- * "off" (dormant — heartbeat disabled entirely). When absent, the patcher
404
- * preserves whatever value already lives in openclaw.json (OpenClaw's
405
- * built-in default of "30m").
406
- */
407
- heartbeatEvery: zod.z.string().min(1).max(20).optional(),
408
- /**
409
- * Optional override for `agents.defaults.model.primary` (e.g.
410
- * "anthropic/claude-haiku-4-5" for idle agents). When absent, the patcher
411
- * derives the model from `aiProvider.type` as before. Format must be
412
- * "<provider>/<model-id>".
413
- */
414
- modelOverride: zod.z.string().min(1).max(100).optional(),
415
- /** ISO timestamp of last config modification */
416
- updatedAt: zod.z.string().datetime()
436
+ /**
437
+ * Config bundle returned by Agent Shield to the compute process.
438
+ * Fetched on boot: GET /api/v1/molti/deployments/{did}/config-bundle
439
+ * Auth: X-Heartbeat-Token header (for managed) or X-API-Key (for BYOK)
440
+ *
441
+ * **Private Key Delivery**: The agent's private key is NOT included in the config bundle.
442
+ * It is delivered as the `AGENT_PRIVATE_KEY` environment variable at Fly machine creation
443
+ * time and persists in the machine's env. This avoids transmitting the key on every
444
+ * config fetch and keeps it out of the config-bundle response surface.
445
+ */
446
+ const ConfigBundleSchema = zod.z.object({
447
+ /** Schema version — 2 for managed bundles */
448
+ version: zod.z.number().int().positive(),
449
+ /** Kill switch — if true, compute must exit immediately */
450
+ killed: zod.z.boolean(),
451
+ /** Target OpenClaw version to install */
452
+ openclawVersion: zod.z.string().min(1).max(50),
453
+ /** Agent personality/system prompt file contents (max 100KB) */
454
+ soulFile: zod.z.string().max(1e5).nullable(),
455
+ /** Gateway auth token for OpenClaw */
456
+ gatewayToken: zod.z.string().min(1).max(500),
457
+ /** Channel configurations */
458
+ channels: zod.z.object({
459
+ telegram: zod.z.object({
460
+ enabled: zod.z.boolean(),
461
+ token: zod.z.string().optional()
462
+ }).optional(),
463
+ discord: zod.z.object({
464
+ enabled: zod.z.boolean(),
465
+ token: zod.z.string().optional()
466
+ }).optional(),
467
+ slack: zod.z.object({
468
+ enabled: zod.z.boolean(),
469
+ token: zod.z.string().optional(),
470
+ appToken: zod.z.string().optional()
471
+ }).optional(),
472
+ whatsapp: zod.z.object({ enabled: zod.z.boolean() }).strict().optional()
473
+ }),
474
+ /** AI provider configuration — key is decrypted, sent over TLS */
475
+ aiProvider: zod.z.object({
476
+ type: zod.z.enum(["anthropic", "openai"]),
477
+ apiKey: zod.z.string().min(1).max(500),
478
+ /**
479
+ * Optional base URL override. When set, OpenClaw routes all provider
480
+ * traffic through this URL instead of the provider's default endpoint.
481
+ * Used by managed deployments where AgentShield issues a per-deployment
482
+ * gateway token and proxies to the upstream provider with budget tracking.
483
+ */
484
+ baseUrl: zod.z.string().url().optional()
485
+ }),
486
+ /**
487
+ * Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).
488
+ * Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —
489
+ * the primary token-cost lever. Examples: "30m" (active), "6h" (idle),
490
+ * "off" (dormant — heartbeat disabled entirely). When absent, the patcher
491
+ * preserves whatever value already lives in openclaw.json (OpenClaw's
492
+ * built-in default of "30m").
493
+ */
494
+ heartbeatEvery: zod.z.string().min(1).max(20).optional(),
495
+ /**
496
+ * Optional override for `agents.defaults.model.primary` (e.g.
497
+ * "anthropic/claude-haiku-4-5" for idle agents). When absent, the patcher
498
+ * derives the model from `aiProvider.type` as before. Format must be
499
+ * "<provider>/<model-id>".
500
+ */
501
+ modelOverride: zod.z.string().min(1).max(100).optional(),
502
+ /** ISO timestamp of last config modification */
503
+ updatedAt: zod.z.string().datetime()
417
504
  });
418
- var ControlStatusSchema = zod.z.object({
419
- /** Whether the agent runtime is healthy */
420
- healthy: zod.z.boolean(),
421
- /** Seconds since compute process started */
422
- uptimeSeconds: zod.z.number().nonnegative(),
423
- /** Installed OpenClaw version */
424
- openclawVersion: zod.z.string().min(1).max(50),
425
- /** @kya-os/compute version */
426
- computeVersion: zod.z.string().min(1).max(50),
427
- /** Number of active WS connections to control server */
428
- activeConnections: zod.z.number().int().nonnegative(),
429
- /** Current RSS memory in MB */
430
- memoryMb: zod.z.number().nonnegative(),
431
- /** CPU usage percentage (0-100) */
432
- cpuPercent: zod.z.number().nonnegative().max(100)
505
+ /**
506
+ * Status frame pushed from compute control server to dashboard.
507
+ * Sent on connect + every 5 seconds.
508
+ */
509
+ const ControlStatusSchema = zod.z.object({
510
+ /** Whether the agent runtime is healthy */
511
+ healthy: zod.z.boolean(),
512
+ /** Seconds since compute process started */
513
+ uptimeSeconds: zod.z.number().nonnegative(),
514
+ /** Installed OpenClaw version */
515
+ openclawVersion: zod.z.string().min(1).max(50),
516
+ /** @kya-os/compute version */
517
+ computeVersion: zod.z.string().min(1).max(50),
518
+ /** Number of active WS connections to control server */
519
+ activeConnections: zod.z.number().int().nonnegative(),
520
+ /** Current RSS memory in MB */
521
+ memoryMb: zod.z.number().nonnegative(),
522
+ /** CPU usage percentage (0-100) */
523
+ cpuPercent: zod.z.number().nonnegative().max(100)
433
524
  });
434
525
 
526
+ //#endregion
435
527
  exports.ABSENT_AUDIT_DEPLOYMENT_CONFIG = ABSENT_AUDIT_DEPLOYMENT_CONFIG;
436
528
  exports.AuditAssuranceProfileSchema = AuditAssuranceProfileSchema;
437
529
  exports.AuditDeliveryModeSchema = AuditDeliveryModeSchema;
@@ -455,4 +547,4 @@ exports.StopCommandSchema = StopCommandSchema;
455
547
  exports.UpdateConfigCommandSchema = UpdateConfigCommandSchema;
456
548
  exports.UpdateVersionCommandSchema = UpdateVersionCommandSchema;
457
549
  exports.requiredAuditRuntimeCanaryChecks = requiredAuditRuntimeCanaryChecks;
458
- exports.resolveAuditDeploymentReadiness = resolveAuditDeploymentReadiness;
550
+ exports.resolveAuditDeploymentReadiness = resolveAuditDeploymentReadiness;