@kya-os/checkpoint-shared 1.3.1 → 1.5.0

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