@kya-os/checkpoint-shared 1.8.0 → 1.10.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 (155) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +1 -1
  3. package/dist/agent-catalog.d.mts +12 -0
  4. package/dist/agent-catalog.d.mts.map +1 -0
  5. package/dist/agent-catalog.d.ts +12 -0
  6. package/dist/agent-catalog.d.ts.map +1 -0
  7. package/dist/agent-catalog.js +105 -0
  8. package/dist/agent-catalog.mjs +105 -0
  9. package/dist/agent-catalog.mjs.map +1 -0
  10. package/dist/beacon-types/index.d.mts +18 -0
  11. package/dist/beacon-types/index.d.mts.map +1 -1
  12. package/dist/beacon-types/index.d.ts +18 -0
  13. package/dist/beacon-types/index.d.ts.map +1 -1
  14. package/dist/beacon-types/index.js +116 -12
  15. package/dist/beacon-types/index.mjs +105 -13
  16. package/dist/beacon-types/index.mjs.map +1 -1
  17. package/dist/browser-posture-5fPrsxx7.d.mts.map +1 -1
  18. package/dist/browser-posture-CCR1kh5e.d.ts.map +1 -1
  19. package/dist/browser-posture-cookie.js +1 -1
  20. package/dist/browser-posture-cookie.mjs +1 -1
  21. package/dist/browser-posture-cookie.mjs.map +1 -1
  22. package/dist/browser-posture-proof-verifier-DvsOmFrM.js +202 -0
  23. package/dist/browser-posture-proof-verifier-I0HP2Ics.mjs +180 -0
  24. package/dist/browser-posture-proof-verifier-I0HP2Ics.mjs.map +1 -0
  25. package/dist/browser-posture-proof-verifier.d.mts +25 -0
  26. package/dist/browser-posture-proof-verifier.d.mts.map +1 -0
  27. package/dist/browser-posture-proof-verifier.d.ts +25 -0
  28. package/dist/browser-posture-proof-verifier.d.ts.map +1 -0
  29. package/dist/browser-posture-proof-verifier.js +7 -0
  30. package/dist/browser-posture-proof-verifier.mjs +3 -0
  31. package/dist/browser-posture-proof.d.mts +3 -18
  32. package/dist/browser-posture-proof.d.mts.map +1 -1
  33. package/dist/browser-posture-proof.d.ts +3 -18
  34. package/dist/browser-posture-proof.d.ts.map +1 -1
  35. package/dist/browser-posture-proof.js +6 -131
  36. package/dist/browser-posture-proof.mjs +1 -126
  37. package/dist/browser-posture-proof.mjs.map +1 -1
  38. package/dist/browser-posture.js +36 -5
  39. package/dist/browser-posture.mjs +36 -5
  40. package/dist/browser-posture.mjs.map +1 -1
  41. package/dist/browser.d.mts +0 -282
  42. package/dist/browser.d.mts.map +1 -1
  43. package/dist/browser.d.ts +0 -282
  44. package/dist/browser.d.ts.map +1 -1
  45. package/dist/browser.js +1 -1
  46. package/dist/browser.mjs +1 -1
  47. package/dist/browser.mjs.map +1 -1
  48. package/dist/canonical-signer/index.mjs.map +1 -1
  49. package/dist/consent-handoff.d.mts +0 -3
  50. package/dist/consent-handoff.d.mts.map +1 -1
  51. package/dist/consent-handoff.d.ts +0 -3
  52. package/dist/consent-handoff.d.ts.map +1 -1
  53. package/dist/consent-handoff.mjs.map +1 -1
  54. package/dist/default-sign-in-host.d.mts +10 -0
  55. package/dist/default-sign-in-host.d.mts.map +1 -0
  56. package/dist/default-sign-in-host.d.ts +10 -0
  57. package/dist/default-sign-in-host.d.ts.map +1 -0
  58. package/dist/default-sign-in-host.js +72 -0
  59. package/dist/default-sign-in-host.mjs +66 -0
  60. package/dist/default-sign-in-host.mjs.map +1 -0
  61. package/dist/deploy/index.d.mts +1 -0
  62. package/dist/deploy/index.d.mts.map +1 -1
  63. package/dist/deploy/index.d.ts +1 -0
  64. package/dist/deploy/index.d.ts.map +1 -1
  65. package/dist/deploy/index.js +9 -1
  66. package/dist/deploy/index.mjs +9 -1
  67. package/dist/deploy/index.mjs.map +1 -1
  68. package/dist/errors/index.d.mts +1 -0
  69. package/dist/errors/index.d.mts.map +1 -1
  70. package/dist/errors/index.d.ts +1 -0
  71. package/dist/errors/index.d.ts.map +1 -1
  72. package/dist/errors/index.js +5 -2
  73. package/dist/errors/index.mjs +5 -2
  74. package/dist/errors/index.mjs.map +1 -1
  75. package/dist/{fetcher-CivUCbhL.d.ts → fetcher-CCw4Q95g.d.ts} +2 -2
  76. package/dist/{fetcher-CivUCbhL.d.ts.map → fetcher-CCw4Q95g.d.ts.map} +1 -1
  77. package/dist/{fetcher-cXQsbm6s.d.mts → fetcher-CZfLcbRZ.d.mts} +2 -2
  78. package/dist/{fetcher-cXQsbm6s.d.mts.map → fetcher-CZfLcbRZ.d.mts.map} +1 -1
  79. package/dist/gateway-client-ip.d.mts +0 -2
  80. package/dist/gateway-client-ip.d.mts.map +1 -1
  81. package/dist/gateway-client-ip.d.ts +0 -2
  82. package/dist/gateway-client-ip.d.ts.map +1 -1
  83. package/dist/gateway-client-ip.mjs.map +1 -1
  84. package/dist/host-adapter/index.d.mts +1 -1
  85. package/dist/host-adapter/index.d.ts +1 -1
  86. package/dist/host-adapter/index.js +1 -1
  87. package/dist/host-adapter/index.mjs +1 -1
  88. package/dist/{host-adapter-DHyISsIf.mjs → host-adapter-BKdQHwbi.mjs} +2 -2
  89. package/dist/{host-adapter-DHyISsIf.mjs.map → host-adapter-BKdQHwbi.mjs.map} +1 -1
  90. package/dist/{host-adapter-0F8EpbD6.js → host-adapter-bWftXA9T.js} +1 -1
  91. package/dist/{index-CXbOY7gB.d.ts → index-Cdv_FH0H.d.ts} +3 -3
  92. package/dist/{index-CXbOY7gB.d.ts.map → index-Cdv_FH0H.d.ts.map} +1 -1
  93. package/dist/{index-B3cHxr3O.d.mts → index-DL_dmQBY.d.mts} +3 -3
  94. package/dist/{index-B3cHxr3O.d.mts.map → index-DL_dmQBY.d.mts.map} +1 -1
  95. package/dist/index.d.mts +124 -463
  96. package/dist/index.d.mts.map +1 -1
  97. package/dist/index.d.ts +124 -463
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +52 -468
  100. package/dist/index.mjs +40 -435
  101. package/dist/index.mjs.map +1 -1
  102. package/dist/{kya-http-error-codes-UYb1zpGM.js → kya-http-error-codes-B4rUmUEI.js} +2 -0
  103. package/dist/{kya-http-error-codes-7ewV5RuK.d.ts → kya-http-error-codes-C14E4gi3.d.mts} +2 -1
  104. package/dist/kya-http-error-codes-C14E4gi3.d.mts.map +1 -0
  105. package/dist/{kya-http-error-codes-7ewV5RuK.d.mts → kya-http-error-codes-C14E4gi3.d.ts} +2 -1
  106. package/dist/kya-http-error-codes-C14E4gi3.d.ts.map +1 -0
  107. package/dist/{kya-http-error-codes-C2JiWPsi.mjs → kya-http-error-codes-DSBrxNry.mjs} +3 -1
  108. package/dist/kya-http-error-codes-DSBrxNry.mjs.map +1 -0
  109. package/dist/kya-http.d.mts +3 -3
  110. package/dist/kya-http.d.ts +3 -3
  111. package/dist/kya-http.js +7 -3
  112. package/dist/kya-http.mjs +3 -3
  113. package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
  114. package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
  115. package/dist/mcpi/dashboard-config/index.mjs.map +1 -1
  116. package/dist/{patterns-B2r7M9wR.js → patterns-CiMpbdAF.js} +1 -1
  117. package/dist/{patterns-B7dQoeE3.mjs → patterns-D4OAsNQY.mjs} +2 -2
  118. package/dist/{patterns-B7dQoeE3.mjs.map → patterns-D4OAsNQY.mjs.map} +1 -1
  119. package/dist/patterns.js +1 -1
  120. package/dist/patterns.mjs +1 -1
  121. package/dist/policy/fetcher.d.mts +1 -1
  122. package/dist/policy/fetcher.d.ts +1 -1
  123. package/dist/policy/schemas.d.mts +1 -1
  124. package/dist/policy/schemas.d.ts +1 -1
  125. package/dist/{registered-sid-DVGTSH0L.js → registered-sid-BZfDOfXy.js} +107 -4
  126. package/dist/{registered-sid-26hNxp6t.mjs → registered-sid-CS9V8nPr.mjs} +85 -6
  127. package/dist/registered-sid-CS9V8nPr.mjs.map +1 -0
  128. package/dist/{registered-sid-D6KCaT1E.d.ts → registered-sid-CnWIU_l1.d.mts} +13 -2
  129. package/dist/registered-sid-CnWIU_l1.d.mts.map +1 -0
  130. package/dist/{registered-sid-D6KCaT1E.d.mts → registered-sid-CnWIU_l1.d.ts} +13 -2
  131. package/dist/registered-sid-CnWIU_l1.d.ts.map +1 -0
  132. package/dist/{schemas-02CI7jgm.d.mts → schemas-BhC88D1-.d.mts} +17 -17
  133. package/dist/{schemas-02CI7jgm.d.mts.map → schemas-BhC88D1-.d.mts.map} +1 -1
  134. package/dist/{schemas-C_3C72SR.d.ts → schemas-DZa1ouGs.d.ts} +17 -17
  135. package/dist/{schemas-C_3C72SR.d.ts.map → schemas-DZa1ouGs.d.ts.map} +1 -1
  136. package/dist/signals/index.d.mts.map +1 -1
  137. package/dist/signals/index.d.ts.map +1 -1
  138. package/dist/signals/index.js +4 -0
  139. package/dist/signals/index.mjs +4 -0
  140. package/dist/signals/index.mjs.map +1 -1
  141. package/dist/tool-protection/index.d.mts +12 -0
  142. package/dist/tool-protection/index.d.mts.map +1 -1
  143. package/dist/tool-protection/index.d.ts +12 -0
  144. package/dist/tool-protection/index.d.ts.map +1 -1
  145. package/dist/tool-protection/index.js +46 -0
  146. package/dist/tool-protection/index.mjs +44 -1
  147. package/dist/tool-protection/index.mjs.map +1 -1
  148. package/fixtures/kya-http/error-codes.json +2 -1
  149. package/package.json +19 -3
  150. package/dist/kya-http-error-codes-7ewV5RuK.d.mts.map +0 -1
  151. package/dist/kya-http-error-codes-7ewV5RuK.d.ts.map +0 -1
  152. package/dist/kya-http-error-codes-C2JiWPsi.mjs.map +0 -1
  153. package/dist/registered-sid-26hNxp6t.mjs.map +0 -1
  154. package/dist/registered-sid-D6KCaT1E.d.mts.map +0 -1
  155. package/dist/registered-sid-D6KCaT1E.d.ts.map +0 -1
@@ -0,0 +1,72 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region src/default-sign-in-host.ts
3
+ /**
4
+ * Default sign-in hosts (F5): an org without its own verified authorization
5
+ * domain signs in at `<label>.auth.knowthat.ai`, one host per org.
6
+ *
7
+ * The platform names the host (`defaultIssuerHost`, apps/web) and the gateway
8
+ * routes it; both read the domain and the host's shape from here, so the two
9
+ * can't drift apart. Which labels an org may hold (reserved names, the slug
10
+ * rule) is the platform's call, not this module's.
11
+ */
12
+ /** The parent of every default sign-in host. */
13
+ const AUTH_DOMAIN = "auth.knowthat.ai";
14
+ /** One DNS label: 1-63 of lowercase a-z, 0-9 and hyphen, no leading or trailing hyphen. */
15
+ const DNS_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
16
+ /** Whether `value` is exactly one lowercase DNS label. */
17
+ function isDnsLabel(value) {
18
+ return value.length <= 63 && DNS_LABEL.test(value);
19
+ }
20
+ /**
21
+ * Whether `label` can name a default sign-in host: one DNS label, and not a
22
+ * reserved one. A label with `--` in its third and fourth places is reserved
23
+ * (RFC 5891 §4.2.3.1), and `xn--` is one: an IDNA label, which a browser shows
24
+ * as Unicode that can pass for another name.
25
+ */
26
+ function isDefaultSignInHostLabel(label) {
27
+ return isDnsLabel(label) && label.slice(2, 4) !== "--";
28
+ }
29
+ /** The default sign-in host for `label`, or null when it can't name one. */
30
+ function defaultSignInHost(label) {
31
+ return isDefaultSignInHostLabel(label) ? `${label}.${AUTH_DOMAIN}` : null;
32
+ }
33
+ /**
34
+ * The label of a default sign-in host: exactly one label before
35
+ * `.auth.knowthat.ai` that can name one. Null for any other host, the bare
36
+ * domain, or a deeper name. Hosts are compared as given; pass them lowercase,
37
+ * as an attested host is.
38
+ */
39
+ function defaultSignInHostLabel(host) {
40
+ const suffix = `.${AUTH_DOMAIN}`;
41
+ if (!host.endsWith(suffix)) return null;
42
+ const label = host.slice(0, -suffix.length);
43
+ return isDefaultSignInHostLabel(label) ? label : null;
44
+ }
45
+ /**
46
+ * Whether `host` is the auth domain or any name under it, valid default host
47
+ * or not. No project may add one as its own domain: every name there is an
48
+ * org's default sign-in host, or one an org could come to hold.
49
+ */
50
+ function isUnderAuthDomain(host) {
51
+ const name = withoutTrailingDots(host.toLowerCase());
52
+ return name === "auth.knowthat.ai" || name.endsWith(`.${"auth.knowthat.ai"}`);
53
+ }
54
+ /**
55
+ * `host` with any trailing dots dropped. A plain scan, not a regex: the host
56
+ * is uncontrolled input, and an anchored `\.+$` backtracks on a long run of
57
+ * dots.
58
+ */
59
+ function withoutTrailingDots(host) {
60
+ let end = host.length;
61
+ while (end > 0 && host.charCodeAt(end - 1) === 46) end -= 1;
62
+ return host.slice(0, end);
63
+ }
64
+
65
+ //#endregion
66
+ exports.AUTH_DOMAIN = AUTH_DOMAIN;
67
+ exports.defaultSignInHost = defaultSignInHost;
68
+ exports.defaultSignInHostLabel = defaultSignInHostLabel;
69
+ exports.isDefaultSignInHostLabel = isDefaultSignInHostLabel;
70
+ exports.isDnsLabel = isDnsLabel;
71
+ exports.isUnderAuthDomain = isUnderAuthDomain;
72
+ exports.withoutTrailingDots = withoutTrailingDots;
@@ -0,0 +1,66 @@
1
+ //#region src/default-sign-in-host.ts
2
+ /**
3
+ * Default sign-in hosts (F5): an org without its own verified authorization
4
+ * domain signs in at `<label>.auth.knowthat.ai`, one host per org.
5
+ *
6
+ * The platform names the host (`defaultIssuerHost`, apps/web) and the gateway
7
+ * routes it; both read the domain and the host's shape from here, so the two
8
+ * can't drift apart. Which labels an org may hold (reserved names, the slug
9
+ * rule) is the platform's call, not this module's.
10
+ */
11
+ /** The parent of every default sign-in host. */
12
+ const AUTH_DOMAIN = "auth.knowthat.ai";
13
+ /** One DNS label: 1-63 of lowercase a-z, 0-9 and hyphen, no leading or trailing hyphen. */
14
+ const DNS_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
15
+ /** Whether `value` is exactly one lowercase DNS label. */
16
+ function isDnsLabel(value) {
17
+ return value.length <= 63 && DNS_LABEL.test(value);
18
+ }
19
+ /**
20
+ * Whether `label` can name a default sign-in host: one DNS label, and not a
21
+ * reserved one. A label with `--` in its third and fourth places is reserved
22
+ * (RFC 5891 §4.2.3.1), and `xn--` is one: an IDNA label, which a browser shows
23
+ * as Unicode that can pass for another name.
24
+ */
25
+ function isDefaultSignInHostLabel(label) {
26
+ return isDnsLabel(label) && label.slice(2, 4) !== "--";
27
+ }
28
+ /** The default sign-in host for `label`, or null when it can't name one. */
29
+ function defaultSignInHost(label) {
30
+ return isDefaultSignInHostLabel(label) ? `${label}.${AUTH_DOMAIN}` : null;
31
+ }
32
+ /**
33
+ * The label of a default sign-in host: exactly one label before
34
+ * `.auth.knowthat.ai` that can name one. Null for any other host, the bare
35
+ * domain, or a deeper name. Hosts are compared as given; pass them lowercase,
36
+ * as an attested host is.
37
+ */
38
+ function defaultSignInHostLabel(host) {
39
+ const suffix = `.${AUTH_DOMAIN}`;
40
+ if (!host.endsWith(suffix)) return null;
41
+ const label = host.slice(0, -suffix.length);
42
+ return isDefaultSignInHostLabel(label) ? label : null;
43
+ }
44
+ /**
45
+ * Whether `host` is the auth domain or any name under it, valid default host
46
+ * or not. No project may add one as its own domain: every name there is an
47
+ * org's default sign-in host, or one an org could come to hold.
48
+ */
49
+ function isUnderAuthDomain(host) {
50
+ const name = withoutTrailingDots(host.toLowerCase());
51
+ return name === "auth.knowthat.ai" || name.endsWith(`.${"auth.knowthat.ai"}`);
52
+ }
53
+ /**
54
+ * `host` with any trailing dots dropped. A plain scan, not a regex: the host
55
+ * is uncontrolled input, and an anchored `\.+$` backtracks on a long run of
56
+ * dots.
57
+ */
58
+ function withoutTrailingDots(host) {
59
+ let end = host.length;
60
+ while (end > 0 && host.charCodeAt(end - 1) === 46) end -= 1;
61
+ return host.slice(0, end);
62
+ }
63
+
64
+ //#endregion
65
+ export { AUTH_DOMAIN, defaultSignInHost, defaultSignInHostLabel, isDefaultSignInHostLabel, isDnsLabel, isUnderAuthDomain, withoutTrailingDots };
66
+ //# sourceMappingURL=default-sign-in-host.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-sign-in-host.mjs","names":[],"sources":["../src/default-sign-in-host.ts"],"sourcesContent":["/**\n * Default sign-in hosts (F5): an org without its own verified authorization\n * domain signs in at `<label>.auth.knowthat.ai`, one host per org.\n *\n * The platform names the host (`defaultIssuerHost`, apps/web) and the gateway\n * routes it; both read the domain and the host's shape from here, so the two\n * can't drift apart. Which labels an org may hold (reserved names, the slug\n * rule) is the platform's call, not this module's.\n */\n\n/** The parent of every default sign-in host. */\nexport const AUTH_DOMAIN = 'auth.knowthat.ai';\n\n/** One DNS label: 1-63 of lowercase a-z, 0-9 and hyphen, no leading or trailing hyphen. */\nconst DNS_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;\n\n/** Whether `value` is exactly one lowercase DNS label. */\nexport function isDnsLabel(value: string): boolean {\n return value.length <= 63 && DNS_LABEL.test(value);\n}\n\n/**\n * Whether `label` can name a default sign-in host: one DNS label, and not a\n * reserved one. A label with `--` in its third and fourth places is reserved\n * (RFC 5891 §4.2.3.1), and `xn--` is one: an IDNA label, which a browser shows\n * as Unicode that can pass for another name.\n */\nexport function isDefaultSignInHostLabel(label: string): boolean {\n return isDnsLabel(label) && label.slice(2, 4) !== '--';\n}\n\n/** The default sign-in host for `label`, or null when it can't name one. */\nexport function defaultSignInHost(label: string): string | null {\n return isDefaultSignInHostLabel(label) ? `${label}.${AUTH_DOMAIN}` : null;\n}\n\n/**\n * The label of a default sign-in host: exactly one label before\n * `.auth.knowthat.ai` that can name one. Null for any other host, the bare\n * domain, or a deeper name. Hosts are compared as given; pass them lowercase,\n * as an attested host is.\n */\nexport function defaultSignInHostLabel(host: string): string | null {\n const suffix = `.${AUTH_DOMAIN}`;\n if (!host.endsWith(suffix)) return null;\n const label = host.slice(0, -suffix.length);\n return isDefaultSignInHostLabel(label) ? label : null;\n}\n\n/**\n * Whether `host` is the auth domain or any name under it, valid default host\n * or not. No project may add one as its own domain: every name there is an\n * org's default sign-in host, or one an org could come to hold.\n */\nexport function isUnderAuthDomain(host: string): boolean {\n const name = withoutTrailingDots(host.toLowerCase());\n return name === AUTH_DOMAIN || name.endsWith(`.${AUTH_DOMAIN}`);\n}\n\n/**\n * `host` with any trailing dots dropped. A plain scan, not a regex: the host\n * is uncontrolled input, and an anchored `\\.+$` backtracks on a long run of\n * dots.\n */\nexport function withoutTrailingDots(host: string): string {\n let end = host.length;\n while (end > 0 && host.charCodeAt(end - 1) === 46 /* '.' */) end -= 1;\n return host.slice(0, end);\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,cAAc;;AAG3B,MAAM,YAAY;;AAGlB,SAAgB,WAAW,OAAwB;CACjD,OAAO,MAAM,UAAU,MAAM,UAAU,KAAK,KAAK;AACnD;;;;;;;AAQA,SAAgB,yBAAyB,OAAwB;CAC/D,OAAO,WAAW,KAAK,KAAK,MAAM,MAAM,GAAG,CAAC,MAAM;AACpD;;AAGA,SAAgB,kBAAkB,OAA8B;CAC9D,OAAO,yBAAyB,KAAK,IAAI,GAAG,MAAM,GAAG,gBAAgB;AACvE;;;;;;;AAQA,SAAgB,uBAAuB,MAA6B;CAClE,MAAM,SAAS,IAAI;CACnB,IAAI,CAAC,KAAK,SAAS,MAAM,GAAG,OAAO;CACnC,MAAM,QAAQ,KAAK,MAAM,GAAG,CAAC,OAAO,MAAM;CAC1C,OAAO,yBAAyB,KAAK,IAAI,QAAQ;AACnD;;;;;;AAOA,SAAgB,kBAAkB,MAAuB;CACvD,MAAM,OAAO,oBAAoB,KAAK,YAAY,CAAC;CACnD,OAAO,+BAAwB,KAAK,SAAS,wBAAiB;AAChE;;;;;;AAOA,SAAgB,oBAAoB,MAAsB;CACxD,IAAI,MAAM,KAAK;CACf,OAAO,MAAM,KAAK,KAAK,WAAW,MAAM,CAAC,MAAM,IAAc,OAAO;CACpE,OAAO,KAAK,MAAM,GAAG,GAAG;AAC1B"}
@@ -294,6 +294,7 @@ export declare const HeartbeatRequestSchema: z.ZodObject<{
294
294
  machineId: z.ZodOptional<z.ZodString>;
295
295
  uptimeSeconds: z.ZodOptional<z.ZodNumber>;
296
296
  memoryMb: z.ZodOptional<z.ZodNumber>;
297
+ lastUserActivityAt: z.ZodCatch<z.ZodOptional<z.ZodString>>;
297
298
  }, z.core.$strip>;
298
299
  export type HeartbeatRequest = z.infer<typeof HeartbeatRequestSchema>;
299
300
  export declare const StopCommandSchema: z.ZodObject<{
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/deploy/index.ts"],"mappings":";;qBAoCa;qBAgBA,iBAAe,EAAA;qBAUf,iBAAe,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqChB,YAAY,EAAE,aAAa;qBAY1B,mBAAiB,EAAA;;;;;YAElB,cAAc,EAAE,aAAa;qBAM5B,6BAA2B,EAAA;;;;;;;qBAC3B,yBAAuB,EAAA;;;;;qBAOvB,6BAA2B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCpC,EAAA,KAAA;YAEQ,wBAAwB,EAAE,aAAa;YACvC,wBAAwB,EAAE,aAAa;qBAGtC,sCAAsC,SAAS;qBAgB/C,gCAAgC,SAAS;qBAYzC,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYhC,EAAA,KAAA;YAEC,2BAA2B,EAAE,aAAa;qBAEzC,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BvC,EAAA,KAAA;YAEQ,2BAA2B,EAAE,aAAa;wBAEtC,iCAAiC,cAAc;qBAalD,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAShC,EAAA,KAAA;YAEC,2BAA2B,EAAE,aAAa;wBAItC,gCACd,QAAQ,mCACR,cAAc,sCACd,SAAS,2BACR;qBAkIU,+BAA6B,EAAA;;;;;;;YAQ9B,0BAA0B,EAAE,aAAa;qBAWxC,wBAAsB,EAAA;;;;;;;;;;;;;GAejC,EAAA,KAAA;YAEU,mBAAmB,EAAE,aAAa;qBASjC,mBAAiB,EAAA;;GAInB,EAAA,KAAA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A8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAShC,EAAA,KAAA;YAEC,2BAA2B,EAAE,aAAa;wBAItC,gCACd,QAAQ,mCACR,cAAc,sCACd,SAAS,2BACR;qBAkIU,+BAA6B,EAAA;;;;;;;YAQ9B,0BAA0B,EAAE,aAAa;qBAWxC,wBAAsB,EAAA;;;;;;;;;;;;;;GAuBjC,EAAA,KAAA;YAEU,mBAAmB,EAAE,aAAa;qBASjC,mBAAiB,EAAA;;GAInB,EAAA,KAAA;qBAKE,sBAAoB,EAAA;;GAItB,EAAA,KAAA;qBAKE,2BAAyB,EAAA;;GAI3B,EAAA,KAAA;qBAKE,4BAA0B,EAAA;;;;;GAQ5B,EAAA,KAAA;qBAUE,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;GAK/B,EAAA,KAAA;YAEU,iBAAiB,EAAE,aAAa;qBAM/B,yBAAuB,EAAA;;;;;;;;;;;;;;;GAOlC,EAAA,KAAA;YAEU,oBAAoB,EAAE,aAAa;qBAgBlC,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqE7B,EAAA,KAAA;YAEU,eAAe,EAAE,aAAa;qBAU7B,qBAAmB,EAAA;;;;;;;;GAe9B,EAAA,KAAA;YAEU,gBAAgB,EAAE,aAAa"}
@@ -294,6 +294,7 @@ export declare const HeartbeatRequestSchema: z.ZodObject<{
294
294
  machineId: z.ZodOptional<z.ZodString>;
295
295
  uptimeSeconds: z.ZodOptional<z.ZodNumber>;
296
296
  memoryMb: z.ZodOptional<z.ZodNumber>;
297
+ lastUserActivityAt: z.ZodCatch<z.ZodOptional<z.ZodString>>;
297
298
  }, z.core.$strip>;
298
299
  export type HeartbeatRequest = z.infer<typeof HeartbeatRequestSchema>;
299
300
  export declare const StopCommandSchema: z.ZodObject<{
@@ -1 +1 @@
1
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;;;;;;;;;;;;;;;;GAShC,EAAA,KAAA;YAEC,2BAA2B,EAAE,aAAa;wBAItC,gCACd,QAAQ,mCACR,cAAc,sCACd,SAAS,2BACR;qBAkIU,+BAA6B,EAAA;;;;;;;YAQ9B,0BAA0B,EAAE,aAAa;qBAWxC,wBAAsB,EAAA;;;;;;;;;;;;;;GAuBjC,EAAA,KAAA;YAEU,mBAAmB,EAAE,aAAa;qBASjC,mBAAiB,EAAA;;GAInB,EAAA,KAAA;qBAKE,sBAAoB,EAAA;;GAItB,EAAA,KAAA;qBAKE,2BAAyB,EAAA;;GAI3B,EAAA,KAAA;qBAKE,4BAA0B,EAAA;;;;;GAQ5B,EAAA,KAAA;qBAUE,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;GAK/B,EAAA,KAAA;YAEU,iBAAiB,EAAE,aAAa;qBAM/B,yBAAuB,EAAA;;;;;;;;;;;;;;;GAOlC,EAAA,KAAA;YAEU,oBAAoB,EAAE,aAAa;qBAgBlC,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqE7B,EAAA,KAAA;YAEU,eAAe,EAAE,aAAa;qBAU7B,qBAAmB,EAAA;;;;;;;;GAe9B,EAAA,KAAA;YAEU,gBAAgB,EAAE,aAAa"}
@@ -384,7 +384,15 @@ const HeartbeatRequestSchema = zod.z.object({
384
384
  /** Seconds since compute process started */
385
385
  uptimeSeconds: zod.z.number().nonnegative().optional(),
386
386
  /** Current RSS memory in MB */
387
- memoryMb: zod.z.number().nonnegative().optional()
387
+ memoryMb: zod.z.number().nonnegative().optional(),
388
+ /**
389
+ * ISO 8601 time (UTC, or with an offset) of the agent's last real user or channel message: the
390
+ * newest `lastInteractionAt` across its OpenClaw session stores. Omitted while no session has
391
+ * one. Checkpoint records it as user activity for the agent's tier. A value that isn't such a
392
+ * time parses as absent instead of failing the heartbeat, which also carries `stop` and
393
+ * `update_config`.
394
+ */
395
+ lastUserActivityAt: zod.z.string().datetime({ offset: true }).optional().catch(void 0)
388
396
  });
389
397
  /**
390
398
  * Stop command — graceful shutdown, no payload accepted.
@@ -383,7 +383,15 @@ const HeartbeatRequestSchema = z.object({
383
383
  /** Seconds since compute process started */
384
384
  uptimeSeconds: z.number().nonnegative().optional(),
385
385
  /** Current RSS memory in MB */
386
- memoryMb: z.number().nonnegative().optional()
386
+ memoryMb: z.number().nonnegative().optional(),
387
+ /**
388
+ * ISO 8601 time (UTC, or with an offset) of the agent's last real user or channel message: the
389
+ * newest `lastInteractionAt` across its OpenClaw session stores. Omitted while no session has
390
+ * one. Checkpoint records it as user activity for the agent's tier. A value that isn't such a
391
+ * time parses as absent instead of failing the heartbeat, which also carries `stop` and
392
+ * `update_config`.
393
+ */
394
+ lastUserActivityAt: z.string().datetime({ offset: true }).optional().catch(void 0)
387
395
  });
388
396
  /**
389
397
  * Stop command — graceful shutdown, no payload accepted.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/deploy/index.ts"],"sourcesContent":["/**\n * Managed Agent Deployment + Compute Process Contracts (checkpoint-owned subset)\n *\n * Schemas for the managed hosting tier (agents on Fly.io) and the\n * `@kya-os/compute` ⇄ Checkpoint heartbeat/config/control protocol.\n *\n * Ported into checkpoint-shared from `@kya-os/contracts/agent-deployment` +\n * `@kya-os/contracts/compute` as part of the E6 / C-series decommission\n * (#2914 / #2917). Only the symbols re-exported by\n * `apps/web/lib/types/molti-deploy-contracts.ts` (plus their transitive deps —\n * `DidStringSchema`, the compute command sub-schemas) are ported.\n *\n * @module @kya-os/checkpoint-shared/deploy\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Cross-repo endpoint contract\n// ============================================================================\n\n/**\n * The KYA-OS activity-events ingest path (SPEC-EVENTS v0.1 batch endpoint).\n *\n * This is a CROSS-REPO CONTRACT. The Tier 2 worker runtime\n * (`@kya-os/mcp-i-cloudflare`) POSTs `tool.invoked` (and the other SPEC-EVENTS\n * types) to `${AGENTSHIELD_API_URL}${KYA_OS_EVENTS_PATH}`, authenticated by the\n * project API key. Checkpoint serves the batch ingest at this exact path\n * (`apps/web/app${KYA_OS_EVENTS_PATH}/route.ts`) and fans events out into the\n * `detections` table behind `/activity`.\n *\n * Managed deploy deliberately injects NO `KYA_OS_EVENTS_*` secret and relies on\n * this derivation instead, so the two sides agree only by matching this literal.\n * Changing it on either side silently drops all managed activity — it is pinned\n * by a contract test. Keep this value and the worker's derivation in sync.\n */\nexport const KYA_OS_EVENTS_PATH = '/api/v1/kya-os/events';\n\n// ============================================================================\n// Shared Schemas\n// ============================================================================\n\n/**\n * Validated DID string schema.\n * Reusable across all contract files that reference agent DIDs.\n *\n * Format: `did:<method>:<method-specific-id>`\n * - method: 1+ lowercase alphanumeric chars\n * - method-specific-id: 1+ non-whitespace chars\n *\n * Examples: `did:key:z6Mk...`, `did:web:example.com`\n */\nexport const DidStringSchema = z\n .string()\n .min(8, 'DID must be at least 8 characters')\n .regex(/^did:[a-z0-9]+:\\S+$/, 'DID must match format did:<method>:<method-specific-id>');\n\n/**\n * Fly.io deployment regions.\n * Enumerated to prevent arbitrary strings from being accepted.\n * @see https://fly.io/docs/reference/regions/\n */\nexport const FlyRegionSchema = z.enum([\n 'ams', // Amsterdam, Netherlands\n 'arn', // Stockholm, Sweden\n 'atl', // Atlanta, Georgia (US)\n 'bog', // Bogotá, Colombia\n 'bos', // Boston, Massachusetts (US)\n 'cdg', // Paris, France\n 'den', // Denver, Colorado (US)\n 'dfw', // Dallas, Texas (US)\n 'ewr', // Secaucus, NJ (US)\n 'eze', // Ezeiza, Argentina\n 'fra', // Frankfurt, Germany\n 'gdl', // Guadalajara, Mexico\n 'gig', // Rio de Janeiro, Brazil\n 'gru', // São Paulo, Brazil\n 'hkg', // Hong Kong\n 'iad', // Ashburn, Virginia (US)\n 'jnb', // Johannesburg, South Africa\n 'lax', // Los Angeles, California (US)\n 'lhr', // London, United Kingdom\n 'mad', // Madrid, Spain\n 'mia', // Miami, Florida (US)\n 'nrt', // Tokyo, Japan\n 'ord', // Chicago, Illinois (US)\n 'otp', // Bucharest, Romania\n 'phx', // Phoenix, Arizona (US)\n 'qro', // Querétaro, Mexico\n 'scl', // Santiago, Chile\n 'sea', // Seattle, Washington (US)\n 'sin', // Singapore\n 'sjc', // San Jose, California (US)\n 'syd', // Sydney, Australia\n 'waw', // Warsaw, Poland\n 'yul', // Montreal, Canada\n 'yyz', // Toronto, Canada\n]);\n\nexport type FlyRegion = z.infer<typeof FlyRegionSchema>;\n\n/**\n * Hosting mode discriminator — differentiates between deploy backends:\n * - `byok`: self-managed deploy in the customer's own Cloudflare account\n * (customer runs the deploy themselves).\n * - `managed`: platform-managed deploy in our Cloudflare account via Workers\n * for Platforms (dispatch namespace).\n * - `managed-byoa`: platform-managed deploy that lands in the customer's own\n * (\"bring your own account\") Cloudflare account via the standard Workers API,\n * after the org connects Cloudflare over OAuth/token (KYA-906-C).\n */\nexport const HostingModeSchema = z.enum(['byok', 'managed', 'managed-byoa']);\n\nexport type HostingMode = z.infer<typeof HostingModeSchema>;\n\n// ============================================================================\n// Protocol audit deployment contract\n// ============================================================================\n\nexport const AuditAssuranceProfileSchema = z.enum(['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4']);\nexport const AuditDeliveryModeSchema = z.enum(['best-effort', 'buffered', 'required']);\n\n/**\n * Serializable request contract shared by the wizard and every deploy lane.\n * `requestedProfile` is intent, never an assurance claim. Only readiness\n * evaluation against observed runtime capabilities yields `effectiveProfile`.\n */\nexport const AuditDeploymentConfigSchema = z\n .object({\n enabled: z.boolean(),\n requestedProfile: AuditAssuranceProfileSchema,\n delivery: AuditDeliveryModeSchema,\n evidenceMode: z.enum(['none', 'encrypted-separate', 'encrypted-inline']),\n retentionClass: z.string().min(1).max(128),\n retentionDays: z.number().int().min(0).max(3650),\n residency: z.enum(['inherit-project', 'us', 'eu', 'global']),\n keyCustody: z.enum(['none', 'checkpoint-managed', 'customer-managed-kms']),\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n })\n .strict()\n .superRefine((value, context) => {\n if (!value.enabled && value.requestedProfile !== 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Disabled audit configuration must request AAP-0',\n });\n }\n if (value.enabled && value.requestedProfile === 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Enabled audit configuration must request AAP-1 or higher',\n });\n }\n if (Number(value.requestedProfile.slice(-1)) >= 2 && value.delivery === 'best-effort') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['delivery'],\n message: 'AAP-2 or higher cannot use best-effort delivery',\n });\n }\n if (!value.enabled && (value.keyCustody !== 'none' || value.recorderTopology !== 'none')) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Disabled audit configuration cannot claim key custody or recorder topology',\n });\n }\n });\n\nexport type AuditDeploymentConfig = z.infer<typeof AuditDeploymentConfigSchema>;\nexport type AuditAssuranceProfile = z.infer<typeof AuditAssuranceProfileSchema>;\n\n/** Applied only when a user starts a new platform-managed deployment. */\nexport const NEW_MANAGED_AUDIT_DEPLOYMENT_DEFAULT: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: true,\n requestedProfile: 'AAP-2',\n delivery: 'buffered',\n evidenceMode: 'encrypted-separate',\n retentionClass: 'integrity-ledger',\n retentionDays: 365,\n residency: 'inherit-project',\n keyCustody: 'checkpoint-managed',\n recorderTopology: 'managed',\n});\n\n/**\n * Missing audit config in an already persisted manifest is always AAP-0.\n * This prevents a dashboard or redeploy from silently upgrading old workers.\n */\nexport const ABSENT_AUDIT_DEPLOYMENT_CONFIG: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: false,\n requestedProfile: 'AAP-0',\n delivery: 'best-effort',\n evidenceMode: 'none',\n retentionClass: 'none',\n retentionDays: 0,\n residency: 'inherit-project',\n keyCustody: 'none',\n recorderTopology: 'none',\n});\n\nexport const AuditRuntimeCapabilitiesSchema = z\n .object({\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n delivery: AuditDeliveryModeSchema,\n journalDurability: z.enum(['none', 'ephemeral', 'durable']),\n atomicAppend: z.boolean(),\n sourceHighWater: z.boolean(),\n merkleCheckpoints: z.boolean(),\n independentObservation: z.boolean(),\n supportingAnchors: z.array(z.enum(['worm', 'rfc3161', 'scitt'])),\n evidenceRetention: z.enum(['none', 'inline', 'separate']),\n })\n .strict();\n\nexport type AuditRuntimeCapabilities = z.infer<typeof AuditRuntimeCapabilitiesSchema>;\n\nexport const AuditRuntimeCanaryResultSchema = z\n .object({\n passed: z.boolean(),\n observedAt: z.number().int().nonnegative(),\n capabilities: AuditRuntimeCapabilitiesSchema,\n checks: z\n .array(\n z\n .object({\n id: z.string().min(1).max(128),\n passed: z.boolean(),\n })\n .strict()\n )\n .min(1),\n bundleHash: z.string().min(1).max(256).optional(),\n })\n .strict()\n .superRefine((value, context) => {\n if (value.passed !== value.checks.every((check) => check.passed)) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['passed'],\n message: 'Canary result must equal the aggregate of its mechanical checks',\n });\n }\n });\n\nexport type AuditRuntimeCanaryResult = z.infer<typeof AuditRuntimeCanaryResultSchema>;\n\nexport function requiredAuditRuntimeCanaryChecks(capabilities: AuditRuntimeCapabilities): string[] {\n const checks = [\n 'recorder_round_trip',\n 'verified_receipt',\n 'idempotent_retry',\n 'event_identity_conflict',\n 'source_state',\n ];\n if (capabilities.delivery === 'buffered') checks.push('buffered_outbox');\n if (capabilities.evidenceRetention !== 'none') checks.push('evidence_write_verified');\n return checks;\n}\n\nexport const AuditDeploymentReadinessSchema = z\n .object({\n requestedProfile: AuditAssuranceProfileSchema,\n effectiveProfile: AuditAssuranceProfileSchema,\n status: z.enum(['disabled', 'ready', 'degraded']),\n capabilities: AuditRuntimeCapabilitiesSchema.nullable(),\n canary: AuditRuntimeCanaryResultSchema.nullable(),\n reasonCodes: z.array(z.string().min(1).max(128)),\n })\n .strict();\n\nexport type AuditDeploymentReadiness = z.infer<typeof AuditDeploymentReadinessSchema>;\n\nconst PROFILE_BY_LEVEL = ['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4'] as const;\n\nexport function resolveAuditDeploymentReadiness(\n config: AuditDeploymentConfig | undefined,\n capabilities: AuditRuntimeCapabilities | undefined,\n canary?: AuditRuntimeCanaryResult\n): AuditDeploymentReadiness {\n const requested = AuditDeploymentConfigSchema.parse(config ?? ABSENT_AUDIT_DEPLOYMENT_CONFIG);\n const observedCanary = canary ? AuditRuntimeCanaryResultSchema.parse(canary) : null;\n if (!requested.enabled) {\n return {\n requestedProfile: 'AAP-0',\n effectiveProfile: 'AAP-0',\n status: 'disabled',\n capabilities: capabilities ?? null,\n canary: observedCanary,\n reasonCodes: ['audit_not_configured'],\n };\n }\n const observedCapabilities = capabilities ?? observedCanary?.capabilities;\n if (!observedCapabilities) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: null,\n canary: observedCanary,\n reasonCodes: ['runtime_capabilities_unavailable'],\n };\n }\n const observed = AuditRuntimeCapabilitiesSchema.parse(observedCapabilities);\n if (!observedCanary) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: null,\n reasonCodes: ['runtime_canary_required'],\n };\n }\n if (\n !observedCanary.passed ||\n JSON.stringify(observedCanary.capabilities) !== JSON.stringify(observed)\n ) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: [\n observedCanary.passed ? 'runtime_canary_capability_mismatch' : 'runtime_canary_failed',\n ],\n };\n }\n const passedChecks = new Set(\n observedCanary.checks.filter((check) => check.passed).map((check) => check.id)\n );\n if (requiredAuditRuntimeCanaryChecks(observed).some((check) => !passedChecks.has(check))) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: ['runtime_canary_incomplete'],\n };\n }\n let maximum = 0;\n const reasons: string[] = [];\n if (observed.recorderTopology !== requested.recorderTopology) {\n reasons.push('recorder_topology_mismatch');\n }\n const deliveryRank = { 'best-effort': 0, buffered: 1, required: 2 } as const;\n if (deliveryRank[observed.delivery] < deliveryRank[requested.delivery]) {\n reasons.push('delivery_mode_mismatch');\n }\n const expectedEvidence =\n requested.evidenceMode === 'none'\n ? 'none'\n : requested.evidenceMode === 'encrypted-inline'\n ? 'inline'\n : 'separate';\n if (expectedEvidence !== observed.evidenceRetention) {\n reasons.push('evidence_retention_mismatch');\n }\n // These are explicit deployment-contract mismatches, not merely unavailable\n // higher-assurance services. Never activate a recorder against mechanics\n // weaker than (or topologically different from) the binding it was given.\n if (reasons.length > 0) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n }\n if (observed.recorderTopology !== 'none' && observed.journalDurability !== 'none') maximum = 1;\n else reasons.push('recorder_or_journal_unavailable');\n if (\n maximum >= 1 &&\n observed.journalDurability === 'durable' &&\n observed.atomicAppend &&\n observed.delivery !== 'best-effort'\n ) {\n maximum = 2;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 2) {\n reasons.push('durable_atomic_buffered_append_unavailable');\n }\n if (maximum >= 2 && observed.merkleCheckpoints && observed.sourceHighWater) maximum = 3;\n else if (Number(requested.requestedProfile.slice(-1)) >= 3) {\n reasons.push('checkpoint_or_source_high_water_unavailable');\n }\n if (maximum >= 3 && observed.independentObservation && observed.supportingAnchors.length > 0) {\n maximum = 4;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 4) {\n reasons.push('independent_observation_or_anchor_unavailable');\n }\n const requestedLevel = Number(requested.requestedProfile.slice(-1));\n const effectiveLevel = Math.min(requestedLevel, maximum);\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: PROFILE_BY_LEVEL[effectiveLevel]!,\n status: effectiveLevel === requestedLevel && reasons.length === 0 ? 'ready' : 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n}\n\n/**\n * Deploy step status — reuses same status enum as BYOK.\n */\nexport const ManagedDeployStepStatusSchema = z.enum([\n 'pending',\n 'in_progress',\n 'completed',\n 'failed',\n 'skipped',\n]);\n\nexport type ManagedDeployStepStatus = z.infer<typeof ManagedDeployStepStatusSchema>;\n\n// ============================================================================\n// Heartbeat Protocol (@kya-os/compute ⇄ AgentShield)\n// ============================================================================\n\n/**\n * Heartbeat request body.\n * Sent by compute process: POST /api/v1/molti/agents/{did}/heartbeat\n * Auth: X-Heartbeat-Token header\n */\nexport const HeartbeatRequestSchema = z.object({\n /** Agent DID this heartbeat is for */\n agentDid: DidStringSchema,\n /** Current compute process status */\n status: z.enum(['starting', 'running', 'error', 'stopping']),\n /** @kya-os/compute package version (from package.json) */\n computeVersion: z.string().min(1).max(50),\n /** Installed OpenClaw version (from npm ls) */\n openclawVersion: z.string().max(50).optional(),\n /** Fly machine ID (from FLY_MACHINE_ID env var) */\n machineId: z.string().max(255).optional(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative().optional(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative().optional(),\n});\n\nexport type HeartbeatRequest = z.infer<typeof HeartbeatRequestSchema>;\n\n// ============================================================================\n// Compute Commands (Discriminated Union)\n// ============================================================================\n\n/**\n * Stop command — graceful shutdown, no payload accepted.\n */\nexport const StopCommandSchema = z\n .object({\n type: z.literal('stop'),\n })\n .strict();\n\n/**\n * Restart command — restart the compute process, no payload accepted.\n */\nexport const RestartCommandSchema = z\n .object({\n type: z.literal('restart'),\n })\n .strict();\n\n/**\n * Update config command — triggers config re-fetch, no payload accepted.\n */\nexport const UpdateConfigCommandSchema = z\n .object({\n type: z.literal('update_config'),\n })\n .strict();\n\n/**\n * Update version command — requires target version in payload.\n */\nexport const UpdateVersionCommandSchema = z\n .object({\n type: z.literal('update_version'),\n payload: z.object({\n /** Target OpenClaw version to install */\n version: z.string().min(1).max(50),\n }),\n })\n .strict();\n\n/**\n * Command that Agent Shield can send to the compute process\n * via the heartbeat response.\n *\n * Discriminated union by `type` field:\n * - `stop` / `restart` / `update_config` — no payload\n * - `update_version` — requires `{ version: string }` payload\n */\nexport const ComputeCommandSchema = z.discriminatedUnion('type', [\n StopCommandSchema,\n RestartCommandSchema,\n UpdateConfigCommandSchema,\n UpdateVersionCommandSchema,\n]);\n\nexport type ComputeCommand = z.infer<typeof ComputeCommandSchema>;\n\n/**\n * Heartbeat response from Agent Shield.\n * Returned by: POST /api/v1/molti/agents/{did}/heartbeat\n */\nexport const HeartbeatResponseSchema = z.object({\n /** Always true for successful heartbeats */\n ack: z.literal(true),\n /** Pending commands for the compute process to execute */\n commands: z.array(ComputeCommandSchema).default([]),\n /** ISO timestamp of last config change (compute compares to detect updates) */\n configUpdatedAt: z.string().datetime().optional(),\n});\n\nexport type HeartbeatResponse = z.infer<typeof HeartbeatResponseSchema>;\n\n// ============================================================================\n// Config Bundle\n// ============================================================================\n\n/**\n * Config bundle returned by Agent Shield to the compute process.\n * Fetched on boot: GET /api/v1/molti/deployments/{did}/config-bundle\n * Auth: X-Heartbeat-Token header (for managed) or X-API-Key (for BYOK)\n *\n * **Private Key Delivery**: The agent's private key is NOT included in the config bundle.\n * It is delivered as the `AGENT_PRIVATE_KEY` environment variable at Fly machine creation\n * time and persists in the machine's env. This avoids transmitting the key on every\n * config fetch and keeps it out of the config-bundle response surface.\n */\nexport const ConfigBundleSchema = z.object({\n /** Schema version — 2 for managed bundles */\n version: z.number().int().positive(),\n /** Kill switch — if true, compute must exit immediately */\n killed: z.boolean(),\n /** Target OpenClaw version to install */\n openclawVersion: z.string().min(1).max(50),\n /** Agent personality/system prompt file contents (max 100KB) */\n soulFile: z.string().max(100_000).nullable(),\n /** Gateway auth token for OpenClaw */\n gatewayToken: z.string().min(1).max(500),\n /** Channel configurations */\n channels: z.object({\n telegram: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n discord: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n slack: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n appToken: z.string().optional(),\n })\n .optional(),\n whatsapp: z\n .object({\n enabled: z.boolean(),\n })\n .strict()\n .optional(),\n }),\n /** AI provider configuration — key is decrypted, sent over TLS */\n aiProvider: z.object({\n type: z.enum(['anthropic', 'openai']),\n apiKey: z.string().min(1).max(500),\n /**\n * Optional base URL override. When set, OpenClaw routes all provider\n * traffic through this URL instead of the provider's default endpoint.\n * Used by managed deployments where AgentShield issues a per-deployment\n * gateway token and proxies to the upstream provider with budget tracking.\n */\n baseUrl: z.string().url().optional(),\n }),\n /**\n * Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).\n * Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —\n * the primary token-cost lever. Examples: \"30m\" (active), \"6h\" (idle),\n * \"off\" (dormant — heartbeat disabled entirely). When absent, the patcher\n * preserves whatever value already lives in openclaw.json (OpenClaw's\n * built-in default of \"30m\").\n */\n heartbeatEvery: z.string().min(1).max(20).optional(),\n /**\n * Optional override for `agents.defaults.model.primary` (e.g.\n * \"anthropic/claude-haiku-4-5\" for idle agents). When absent, the patcher\n * derives the model from `aiProvider.type` as before. Format must be\n * \"<provider>/<model-id>\".\n */\n modelOverride: z.string().min(1).max(100).optional(),\n /** ISO timestamp of last config modification */\n updatedAt: z.string().datetime(),\n});\n\nexport type ConfigBundle = z.infer<typeof ConfigBundleSchema>;\n\n// ============================================================================\n// Control Server (WebSocket :18790)\n// ============================================================================\n\n/**\n * Status frame pushed from compute control server to dashboard.\n * Sent on connect + every 5 seconds.\n */\nexport const ControlStatusSchema = z.object({\n /** Whether the agent runtime is healthy */\n healthy: z.boolean(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative(),\n /** Installed OpenClaw version */\n openclawVersion: z.string().min(1).max(50),\n /** @kya-os/compute version */\n computeVersion: z.string().min(1).max(50),\n /** Number of active WS connections to control server */\n activeConnections: z.number().int().nonnegative(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative(),\n /** CPU usage percentage (0-100) */\n cpuPercent: z.number().nonnegative().max(100),\n});\n\nexport type ControlStatus = z.infer<typeof ControlStatusSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,qBAAqB;;;;;;;;;;;AAgBlC,MAAa,kBAAkB,EAC5B,OAAO,CAAC,CACR,IAAI,GAAG,mCAAmC,CAAC,CAC3C,MAAM,uBAAuB,yDAAyD;;;;;;AAOzF,MAAa,kBAAkB,EAAE,KAAK;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;;AAcD,MAAa,oBAAoB,EAAE,KAAK;CAAC;CAAQ;CAAW;AAAc,CAAC;AAQ3E,MAAa,8BAA8B,EAAE,KAAK;CAAC;CAAS;CAAS;CAAS;CAAS;AAAO,CAAC;AAC/F,MAAa,0BAA0B,EAAE,KAAK;CAAC;CAAe;CAAY;AAAU,CAAC;;;;;;AAOrF,MAAa,8BAA8B,EACxC,OAAO;CACN,SAAS,EAAE,QAAQ;CACnB,kBAAkB;CAClB,UAAU;CACV,cAAc,EAAE,KAAK;EAAC;EAAQ;EAAsB;CAAkB,CAAC;CACvE,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CACzC,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;CAC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;CAED,YAAY,EAAE,OAAO;EACnB,MAAM,EAAE,KAAK,CAAC,aAAa,QAAQ,CAAC;EACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;;;;;;;EAOjC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CACrC,CAAC;;;;;;;;;CASD,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;;;;;;;CAOnD,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS;;CAEnD,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;AACjC,CAAC;;;;;AAYD,MAAa,sBAAsB,EAAE,OAAO;;CAE1C,SAAS,EAAE,QAAQ;;CAEnB,eAAe,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEtC,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAEzC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAExC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;;CAEhD,UAAU,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEjC,YAAY,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG;AAC9C,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/deploy/index.ts"],"sourcesContent":["/**\n * Managed Agent Deployment + Compute Process Contracts (checkpoint-owned subset)\n *\n * Schemas for the managed hosting tier (agents on Fly.io) and the\n * `@kya-os/compute` ⇄ Checkpoint heartbeat/config/control protocol.\n *\n * Ported into checkpoint-shared from `@kya-os/contracts/agent-deployment` +\n * `@kya-os/contracts/compute` as part of the E6 / C-series decommission\n * (#2914 / #2917). Only the symbols re-exported by\n * `apps/web/lib/types/molti-deploy-contracts.ts` (plus their transitive deps —\n * `DidStringSchema`, the compute command sub-schemas) are ported.\n *\n * @module @kya-os/checkpoint-shared/deploy\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Cross-repo endpoint contract\n// ============================================================================\n\n/**\n * The KYA-OS activity-events ingest path (SPEC-EVENTS v0.1 batch endpoint).\n *\n * This is a CROSS-REPO CONTRACT. The Tier 2 worker runtime\n * (`@kya-os/mcp-i-cloudflare`) POSTs `tool.invoked` (and the other SPEC-EVENTS\n * types) to `${AGENTSHIELD_API_URL}${KYA_OS_EVENTS_PATH}`, authenticated by the\n * project API key. Checkpoint serves the batch ingest at this exact path\n * (`apps/web/app${KYA_OS_EVENTS_PATH}/route.ts`) and fans events out into the\n * `detections` table behind `/activity`.\n *\n * Managed deploy deliberately injects NO `KYA_OS_EVENTS_*` secret and relies on\n * this derivation instead, so the two sides agree only by matching this literal.\n * Changing it on either side silently drops all managed activity — it is pinned\n * by a contract test. Keep this value and the worker's derivation in sync.\n */\nexport const KYA_OS_EVENTS_PATH = '/api/v1/kya-os/events';\n\n// ============================================================================\n// Shared Schemas\n// ============================================================================\n\n/**\n * Validated DID string schema.\n * Reusable across all contract files that reference agent DIDs.\n *\n * Format: `did:<method>:<method-specific-id>`\n * - method: 1+ lowercase alphanumeric chars\n * - method-specific-id: 1+ non-whitespace chars\n *\n * Examples: `did:key:z6Mk...`, `did:web:example.com`\n */\nexport const DidStringSchema = z\n .string()\n .min(8, 'DID must be at least 8 characters')\n .regex(/^did:[a-z0-9]+:\\S+$/, 'DID must match format did:<method>:<method-specific-id>');\n\n/**\n * Fly.io deployment regions.\n * Enumerated to prevent arbitrary strings from being accepted.\n * @see https://fly.io/docs/reference/regions/\n */\nexport const FlyRegionSchema = z.enum([\n 'ams', // Amsterdam, Netherlands\n 'arn', // Stockholm, Sweden\n 'atl', // Atlanta, Georgia (US)\n 'bog', // Bogotá, Colombia\n 'bos', // Boston, Massachusetts (US)\n 'cdg', // Paris, France\n 'den', // Denver, Colorado (US)\n 'dfw', // Dallas, Texas (US)\n 'ewr', // Secaucus, NJ (US)\n 'eze', // Ezeiza, Argentina\n 'fra', // Frankfurt, Germany\n 'gdl', // Guadalajara, Mexico\n 'gig', // Rio de Janeiro, Brazil\n 'gru', // São Paulo, Brazil\n 'hkg', // Hong Kong\n 'iad', // Ashburn, Virginia (US)\n 'jnb', // Johannesburg, South Africa\n 'lax', // Los Angeles, California (US)\n 'lhr', // London, United Kingdom\n 'mad', // Madrid, Spain\n 'mia', // Miami, Florida (US)\n 'nrt', // Tokyo, Japan\n 'ord', // Chicago, Illinois (US)\n 'otp', // Bucharest, Romania\n 'phx', // Phoenix, Arizona (US)\n 'qro', // Querétaro, Mexico\n 'scl', // Santiago, Chile\n 'sea', // Seattle, Washington (US)\n 'sin', // Singapore\n 'sjc', // San Jose, California (US)\n 'syd', // Sydney, Australia\n 'waw', // Warsaw, Poland\n 'yul', // Montreal, Canada\n 'yyz', // Toronto, Canada\n]);\n\nexport type FlyRegion = z.infer<typeof FlyRegionSchema>;\n\n/**\n * Hosting mode discriminator — differentiates between deploy backends:\n * - `byok`: self-managed deploy in the customer's own Cloudflare account\n * (customer runs the deploy themselves).\n * - `managed`: platform-managed deploy in our Cloudflare account via Workers\n * for Platforms (dispatch namespace).\n * - `managed-byoa`: platform-managed deploy that lands in the customer's own\n * (\"bring your own account\") Cloudflare account via the standard Workers API,\n * after the org connects Cloudflare over OAuth/token (KYA-906-C).\n */\nexport const HostingModeSchema = z.enum(['byok', 'managed', 'managed-byoa']);\n\nexport type HostingMode = z.infer<typeof HostingModeSchema>;\n\n// ============================================================================\n// Protocol audit deployment contract\n// ============================================================================\n\nexport const AuditAssuranceProfileSchema = z.enum(['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4']);\nexport const AuditDeliveryModeSchema = z.enum(['best-effort', 'buffered', 'required']);\n\n/**\n * Serializable request contract shared by the wizard and every deploy lane.\n * `requestedProfile` is intent, never an assurance claim. Only readiness\n * evaluation against observed runtime capabilities yields `effectiveProfile`.\n */\nexport const AuditDeploymentConfigSchema = z\n .object({\n enabled: z.boolean(),\n requestedProfile: AuditAssuranceProfileSchema,\n delivery: AuditDeliveryModeSchema,\n evidenceMode: z.enum(['none', 'encrypted-separate', 'encrypted-inline']),\n retentionClass: z.string().min(1).max(128),\n retentionDays: z.number().int().min(0).max(3650),\n residency: z.enum(['inherit-project', 'us', 'eu', 'global']),\n keyCustody: z.enum(['none', 'checkpoint-managed', 'customer-managed-kms']),\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n })\n .strict()\n .superRefine((value, context) => {\n if (!value.enabled && value.requestedProfile !== 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Disabled audit configuration must request AAP-0',\n });\n }\n if (value.enabled && value.requestedProfile === 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Enabled audit configuration must request AAP-1 or higher',\n });\n }\n if (Number(value.requestedProfile.slice(-1)) >= 2 && value.delivery === 'best-effort') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['delivery'],\n message: 'AAP-2 or higher cannot use best-effort delivery',\n });\n }\n if (!value.enabled && (value.keyCustody !== 'none' || value.recorderTopology !== 'none')) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Disabled audit configuration cannot claim key custody or recorder topology',\n });\n }\n });\n\nexport type AuditDeploymentConfig = z.infer<typeof AuditDeploymentConfigSchema>;\nexport type AuditAssuranceProfile = z.infer<typeof AuditAssuranceProfileSchema>;\n\n/** Applied only when a user starts a new platform-managed deployment. */\nexport const NEW_MANAGED_AUDIT_DEPLOYMENT_DEFAULT: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: true,\n requestedProfile: 'AAP-2',\n delivery: 'buffered',\n evidenceMode: 'encrypted-separate',\n retentionClass: 'integrity-ledger',\n retentionDays: 365,\n residency: 'inherit-project',\n keyCustody: 'checkpoint-managed',\n recorderTopology: 'managed',\n});\n\n/**\n * Missing audit config in an already persisted manifest is always AAP-0.\n * This prevents a dashboard or redeploy from silently upgrading old workers.\n */\nexport const ABSENT_AUDIT_DEPLOYMENT_CONFIG: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: false,\n requestedProfile: 'AAP-0',\n delivery: 'best-effort',\n evidenceMode: 'none',\n retentionClass: 'none',\n retentionDays: 0,\n residency: 'inherit-project',\n keyCustody: 'none',\n recorderTopology: 'none',\n});\n\nexport const AuditRuntimeCapabilitiesSchema = z\n .object({\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n delivery: AuditDeliveryModeSchema,\n journalDurability: z.enum(['none', 'ephemeral', 'durable']),\n atomicAppend: z.boolean(),\n sourceHighWater: z.boolean(),\n merkleCheckpoints: z.boolean(),\n independentObservation: z.boolean(),\n supportingAnchors: z.array(z.enum(['worm', 'rfc3161', 'scitt'])),\n evidenceRetention: z.enum(['none', 'inline', 'separate']),\n })\n .strict();\n\nexport type AuditRuntimeCapabilities = z.infer<typeof AuditRuntimeCapabilitiesSchema>;\n\nexport const AuditRuntimeCanaryResultSchema = z\n .object({\n passed: z.boolean(),\n observedAt: z.number().int().nonnegative(),\n capabilities: AuditRuntimeCapabilitiesSchema,\n checks: z\n .array(\n z\n .object({\n id: z.string().min(1).max(128),\n passed: z.boolean(),\n })\n .strict()\n )\n .min(1),\n bundleHash: z.string().min(1).max(256).optional(),\n })\n .strict()\n .superRefine((value, context) => {\n if (value.passed !== value.checks.every((check) => check.passed)) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['passed'],\n message: 'Canary result must equal the aggregate of its mechanical checks',\n });\n }\n });\n\nexport type AuditRuntimeCanaryResult = z.infer<typeof AuditRuntimeCanaryResultSchema>;\n\nexport function requiredAuditRuntimeCanaryChecks(capabilities: AuditRuntimeCapabilities): string[] {\n const checks = [\n 'recorder_round_trip',\n 'verified_receipt',\n 'idempotent_retry',\n 'event_identity_conflict',\n 'source_state',\n ];\n if (capabilities.delivery === 'buffered') checks.push('buffered_outbox');\n if (capabilities.evidenceRetention !== 'none') checks.push('evidence_write_verified');\n return checks;\n}\n\nexport const AuditDeploymentReadinessSchema = z\n .object({\n requestedProfile: AuditAssuranceProfileSchema,\n effectiveProfile: AuditAssuranceProfileSchema,\n status: z.enum(['disabled', 'ready', 'degraded']),\n capabilities: AuditRuntimeCapabilitiesSchema.nullable(),\n canary: AuditRuntimeCanaryResultSchema.nullable(),\n reasonCodes: z.array(z.string().min(1).max(128)),\n })\n .strict();\n\nexport type AuditDeploymentReadiness = z.infer<typeof AuditDeploymentReadinessSchema>;\n\nconst PROFILE_BY_LEVEL = ['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4'] as const;\n\nexport function resolveAuditDeploymentReadiness(\n config: AuditDeploymentConfig | undefined,\n capabilities: AuditRuntimeCapabilities | undefined,\n canary?: AuditRuntimeCanaryResult\n): AuditDeploymentReadiness {\n const requested = AuditDeploymentConfigSchema.parse(config ?? ABSENT_AUDIT_DEPLOYMENT_CONFIG);\n const observedCanary = canary ? AuditRuntimeCanaryResultSchema.parse(canary) : null;\n if (!requested.enabled) {\n return {\n requestedProfile: 'AAP-0',\n effectiveProfile: 'AAP-0',\n status: 'disabled',\n capabilities: capabilities ?? null,\n canary: observedCanary,\n reasonCodes: ['audit_not_configured'],\n };\n }\n const observedCapabilities = capabilities ?? observedCanary?.capabilities;\n if (!observedCapabilities) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: null,\n canary: observedCanary,\n reasonCodes: ['runtime_capabilities_unavailable'],\n };\n }\n const observed = AuditRuntimeCapabilitiesSchema.parse(observedCapabilities);\n if (!observedCanary) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: null,\n reasonCodes: ['runtime_canary_required'],\n };\n }\n if (\n !observedCanary.passed ||\n JSON.stringify(observedCanary.capabilities) !== JSON.stringify(observed)\n ) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: [\n observedCanary.passed ? 'runtime_canary_capability_mismatch' : 'runtime_canary_failed',\n ],\n };\n }\n const passedChecks = new Set(\n observedCanary.checks.filter((check) => check.passed).map((check) => check.id)\n );\n if (requiredAuditRuntimeCanaryChecks(observed).some((check) => !passedChecks.has(check))) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: ['runtime_canary_incomplete'],\n };\n }\n let maximum = 0;\n const reasons: string[] = [];\n if (observed.recorderTopology !== requested.recorderTopology) {\n reasons.push('recorder_topology_mismatch');\n }\n const deliveryRank = { 'best-effort': 0, buffered: 1, required: 2 } as const;\n if (deliveryRank[observed.delivery] < deliveryRank[requested.delivery]) {\n reasons.push('delivery_mode_mismatch');\n }\n const expectedEvidence =\n requested.evidenceMode === 'none'\n ? 'none'\n : requested.evidenceMode === 'encrypted-inline'\n ? 'inline'\n : 'separate';\n if (expectedEvidence !== observed.evidenceRetention) {\n reasons.push('evidence_retention_mismatch');\n }\n // These are explicit deployment-contract mismatches, not merely unavailable\n // higher-assurance services. Never activate a recorder against mechanics\n // weaker than (or topologically different from) the binding it was given.\n if (reasons.length > 0) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n }\n if (observed.recorderTopology !== 'none' && observed.journalDurability !== 'none') maximum = 1;\n else reasons.push('recorder_or_journal_unavailable');\n if (\n maximum >= 1 &&\n observed.journalDurability === 'durable' &&\n observed.atomicAppend &&\n observed.delivery !== 'best-effort'\n ) {\n maximum = 2;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 2) {\n reasons.push('durable_atomic_buffered_append_unavailable');\n }\n if (maximum >= 2 && observed.merkleCheckpoints && observed.sourceHighWater) maximum = 3;\n else if (Number(requested.requestedProfile.slice(-1)) >= 3) {\n reasons.push('checkpoint_or_source_high_water_unavailable');\n }\n if (maximum >= 3 && observed.independentObservation && observed.supportingAnchors.length > 0) {\n maximum = 4;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 4) {\n reasons.push('independent_observation_or_anchor_unavailable');\n }\n const requestedLevel = Number(requested.requestedProfile.slice(-1));\n const effectiveLevel = Math.min(requestedLevel, maximum);\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: PROFILE_BY_LEVEL[effectiveLevel]!,\n status: effectiveLevel === requestedLevel && reasons.length === 0 ? 'ready' : 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n}\n\n/**\n * Deploy step status — reuses same status enum as BYOK.\n */\nexport const ManagedDeployStepStatusSchema = z.enum([\n 'pending',\n 'in_progress',\n 'completed',\n 'failed',\n 'skipped',\n]);\n\nexport type ManagedDeployStepStatus = z.infer<typeof ManagedDeployStepStatusSchema>;\n\n// ============================================================================\n// Heartbeat Protocol (@kya-os/compute ⇄ AgentShield)\n// ============================================================================\n\n/**\n * Heartbeat request body.\n * Sent by compute process: POST /api/v1/molti/agents/{did}/heartbeat\n * Auth: X-Heartbeat-Token header\n */\nexport const HeartbeatRequestSchema = z.object({\n /** Agent DID this heartbeat is for */\n agentDid: DidStringSchema,\n /** Current compute process status */\n status: z.enum(['starting', 'running', 'error', 'stopping']),\n /** @kya-os/compute package version (from package.json) */\n computeVersion: z.string().min(1).max(50),\n /** Installed OpenClaw version (from npm ls) */\n openclawVersion: z.string().max(50).optional(),\n /** Fly machine ID (from FLY_MACHINE_ID env var) */\n machineId: z.string().max(255).optional(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative().optional(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative().optional(),\n /**\n * ISO 8601 time (UTC, or with an offset) of the agent's last real user or channel message: the\n * newest `lastInteractionAt` across its OpenClaw session stores. Omitted while no session has\n * one. Checkpoint records it as user activity for the agent's tier. A value that isn't such a\n * time parses as absent instead of failing the heartbeat, which also carries `stop` and\n * `update_config`.\n */\n lastUserActivityAt: z.string().datetime({ offset: true }).optional().catch(undefined),\n});\n\nexport type HeartbeatRequest = z.infer<typeof HeartbeatRequestSchema>;\n\n// ============================================================================\n// Compute Commands (Discriminated Union)\n// ============================================================================\n\n/**\n * Stop command — graceful shutdown, no payload accepted.\n */\nexport const StopCommandSchema = z\n .object({\n type: z.literal('stop'),\n })\n .strict();\n\n/**\n * Restart command — restart the compute process, no payload accepted.\n */\nexport const RestartCommandSchema = z\n .object({\n type: z.literal('restart'),\n })\n .strict();\n\n/**\n * Update config command — triggers config re-fetch, no payload accepted.\n */\nexport const UpdateConfigCommandSchema = z\n .object({\n type: z.literal('update_config'),\n })\n .strict();\n\n/**\n * Update version command — requires target version in payload.\n */\nexport const UpdateVersionCommandSchema = z\n .object({\n type: z.literal('update_version'),\n payload: z.object({\n /** Target OpenClaw version to install */\n version: z.string().min(1).max(50),\n }),\n })\n .strict();\n\n/**\n * Command that Agent Shield can send to the compute process\n * via the heartbeat response.\n *\n * Discriminated union by `type` field:\n * - `stop` / `restart` / `update_config` — no payload\n * - `update_version` — requires `{ version: string }` payload\n */\nexport const ComputeCommandSchema = z.discriminatedUnion('type', [\n StopCommandSchema,\n RestartCommandSchema,\n UpdateConfigCommandSchema,\n UpdateVersionCommandSchema,\n]);\n\nexport type ComputeCommand = z.infer<typeof ComputeCommandSchema>;\n\n/**\n * Heartbeat response from Agent Shield.\n * Returned by: POST /api/v1/molti/agents/{did}/heartbeat\n */\nexport const HeartbeatResponseSchema = z.object({\n /** Always true for successful heartbeats */\n ack: z.literal(true),\n /** Pending commands for the compute process to execute */\n commands: z.array(ComputeCommandSchema).default([]),\n /** ISO timestamp of last config change (compute compares to detect updates) */\n configUpdatedAt: z.string().datetime().optional(),\n});\n\nexport type HeartbeatResponse = z.infer<typeof HeartbeatResponseSchema>;\n\n// ============================================================================\n// Config Bundle\n// ============================================================================\n\n/**\n * Config bundle returned by Agent Shield to the compute process.\n * Fetched on boot: GET /api/v1/molti/deployments/{did}/config-bundle\n * Auth: X-Heartbeat-Token header (for managed) or X-API-Key (for BYOK)\n *\n * **Private Key Delivery**: The agent's private key is NOT included in the config bundle.\n * It is delivered as the `AGENT_PRIVATE_KEY` environment variable at Fly machine creation\n * time and persists in the machine's env. This avoids transmitting the key on every\n * config fetch and keeps it out of the config-bundle response surface.\n */\nexport const ConfigBundleSchema = z.object({\n /** Schema version — 2 for managed bundles */\n version: z.number().int().positive(),\n /** Kill switch — if true, compute must exit immediately */\n killed: z.boolean(),\n /** Target OpenClaw version to install */\n openclawVersion: z.string().min(1).max(50),\n /** Agent personality/system prompt file contents (max 100KB) */\n soulFile: z.string().max(100_000).nullable(),\n /** Gateway auth token for OpenClaw */\n gatewayToken: z.string().min(1).max(500),\n /** Channel configurations */\n channels: z.object({\n telegram: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n discord: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n slack: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n appToken: z.string().optional(),\n })\n .optional(),\n whatsapp: z\n .object({\n enabled: z.boolean(),\n })\n .strict()\n .optional(),\n }),\n /** AI provider configuration — key is decrypted, sent over TLS */\n aiProvider: z.object({\n type: z.enum(['anthropic', 'openai']),\n apiKey: z.string().min(1).max(500),\n /**\n * Optional base URL override. When set, OpenClaw routes all provider\n * traffic through this URL instead of the provider's default endpoint.\n * Used by managed deployments where AgentShield issues a per-deployment\n * gateway token and proxies to the upstream provider with budget tracking.\n */\n baseUrl: z.string().url().optional(),\n }),\n /**\n * Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).\n * Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —\n * the primary token-cost lever. Examples: \"30m\" (active), \"6h\" (idle),\n * \"off\" (dormant — heartbeat disabled entirely). When absent, the patcher\n * preserves whatever value already lives in openclaw.json (OpenClaw's\n * built-in default of \"30m\").\n */\n heartbeatEvery: z.string().min(1).max(20).optional(),\n /**\n * Optional override for `agents.defaults.model.primary` (e.g.\n * \"anthropic/claude-haiku-4-5\" for idle agents). When absent, the patcher\n * derives the model from `aiProvider.type` as before. Format must be\n * \"<provider>/<model-id>\".\n */\n modelOverride: z.string().min(1).max(100).optional(),\n /** ISO timestamp of last config modification */\n updatedAt: z.string().datetime(),\n});\n\nexport type ConfigBundle = z.infer<typeof ConfigBundleSchema>;\n\n// ============================================================================\n// Control Server (WebSocket :18790)\n// ============================================================================\n\n/**\n * Status frame pushed from compute control server to dashboard.\n * Sent on connect + every 5 seconds.\n */\nexport const ControlStatusSchema = z.object({\n /** Whether the agent runtime is healthy */\n healthy: z.boolean(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative(),\n /** Installed OpenClaw version */\n openclawVersion: z.string().min(1).max(50),\n /** @kya-os/compute version */\n computeVersion: z.string().min(1).max(50),\n /** Number of active WS connections to control server */\n activeConnections: z.number().int().nonnegative(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative(),\n /** CPU usage percentage (0-100) */\n cpuPercent: z.number().nonnegative().max(100),\n});\n\nexport type ControlStatus = z.infer<typeof ControlStatusSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,qBAAqB;;;;;;;;;;;AAgBlC,MAAa,kBAAkB,EAC5B,OAAO,CAAC,CACR,IAAI,GAAG,mCAAmC,CAAC,CAC3C,MAAM,uBAAuB,yDAAyD;;;;;;AAOzF,MAAa,kBAAkB,EAAE,KAAK;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA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EAAE,OAAO;;CAE1C,SAAS,EAAE,QAAQ;;CAEnB,eAAe,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEtC,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAEzC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAExC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;;CAEhD,UAAU,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEjC,YAAY,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG;AAC9C,CAAC"}
@@ -198,6 +198,7 @@ export declare const ERROR_CODES: {
198
198
  readonly TRANSACTION_FAILED: "TRANSACTION_FAILED";
199
199
  readonly DELETE_FAILED: "DELETE_FAILED";
200
200
  readonly PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS";
201
+ readonly FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED";
201
202
  readonly CONNECTION_FAILED: "NETWORK_CONNECTION_FAILED";
202
203
  readonly TIMEOUT: "NETWORK_TIMEOUT";
203
204
  readonly DNS_RESOLUTION_FAILED: "NETWORK_DNS_FAILED";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";qBA8Xa;;;;;;;;;;;;;;;;;;;;;;qBA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,oBAAoB,0BAA0B;qBAK7C,gBAAgB,OAAO;qBAuVvB,oBAAoB,QAAQ,OAAO;;;KCh1BpC,4BAA4B;KAE5B,iBAAiB,mBAAmB,8BACpC,KAAK,oBAAoB,aAAa;wBAUlC,qBAAqB,mBAAmB,gBACtD,MAAM,IACL,iBAAiB"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";qBA+Xa;;;;;;;;;;;;;;;;;;;;;;qBA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,oBAAoB,0BAA0B;qBAK7C,gBAAgB,OAAO;qBAyVvB,oBAAoB,QAAQ,OAAO;;;KCn1BpC,4BAA4B;KAE5B,iBAAiB,mBAAmB,8BACpC,KAAK,oBAAoB,aAAa;wBAUlC,qBAAqB,mBAAmB,gBACtD,MAAM,IACL,iBAAiB"}
@@ -198,6 +198,7 @@ export declare const ERROR_CODES: {
198
198
  readonly TRANSACTION_FAILED: "TRANSACTION_FAILED";
199
199
  readonly DELETE_FAILED: "DELETE_FAILED";
200
200
  readonly PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS";
201
+ readonly FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED";
201
202
  readonly CONNECTION_FAILED: "NETWORK_CONNECTION_FAILED";
202
203
  readonly TIMEOUT: "NETWORK_TIMEOUT";
203
204
  readonly DNS_RESOLUTION_FAILED: "NETWORK_DNS_FAILED";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";qBA8Xa;;;;;;;;;;;;;;;;;;;;;;qBA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,oBAAoB,0BAA0B;qBAK7C,gBAAgB,OAAO;qBAuVvB,oBAAoB,QAAQ,OAAO;;;KCh1BpC,4BAA4B;KAE5B,iBAAiB,mBAAmB,8BACpC,KAAK,oBAAoB,aAAa;wBAUlC,qBAAqB,mBAAmB,gBACtD,MAAM,IACL,iBAAiB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/constants/errors.ts","../../src/constants/pick-error-codes.ts"],"mappings":";qBA+Xa;;;;;;;;;;;;;;;;;;;;;;qBA4FA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,oBAAoB,0BAA0B;qBAK7C,gBAAgB,OAAO;qBAyVvB,oBAAoB,QAAQ,OAAO;;;KCn1BpC,4BAA4B;KAE5B,iBAAiB,mBAAmB,8BACpC,KAAK,oBAAoB,aAAa;wBAUlC,qBAAqB,mBAAmB,gBACtD,MAAM,IACL,iBAAiB"}
@@ -96,7 +96,8 @@ const INTERNAL_ERRORS = {
96
96
  SERVICE_UNAVAILABLE_TRANSIENT: "SERVICE_UNAVAILABLE_TRANSIENT",
97
97
  TRANSACTION_FAILED: "TRANSACTION_FAILED",
98
98
  DELETE_FAILED: "DELETE_FAILED",
99
- PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS"
99
+ PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS",
100
+ FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED"
100
101
  };
101
102
  /**
102
103
  * Session Error Codes
@@ -507,9 +508,10 @@ const ERROR_MESSAGES = {
507
508
  [INTERNAL_ERRORS.PROCESSING_ERROR]: "Processing error",
508
509
  [INTERNAL_ERRORS.UNKNOWN_ERROR]: "An unknown error occurred",
509
510
  [INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: "A dependency is temporarily unavailable. Retry shortly.",
510
- [INTERNAL_ERRORS.TRANSACTION_FAILED]: "The deletion failed because of a database error. Nothing was deleted.",
511
+ [INTERNAL_ERRORS.TRANSACTION_FAILED]: "The deletion failed because of a database error. The project was not deleted.",
511
512
  [INTERNAL_ERRORS.DELETE_FAILED]: "Failed to delete project",
512
513
  [INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: "The project data is being archived. Retry shortly.",
514
+ [INTERNAL_ERRORS.FLY_CLEANUP_FAILED]: "Couldn't stop a managed agent's machine, so the delete was refused. Retry the delete.",
513
515
  [SESSION_ERRORS.SESSION_NOT_FOUND]: "Session not found",
514
516
  [SESSION_ERRORS.SESSION_EXPIRED]: "Session has expired",
515
517
  [SESSION_ERRORS.SESSION_INVALID]: "Session is invalid",
@@ -848,6 +850,7 @@ const ERROR_STATUS_CODES = {
848
850
  [AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_OUT_OF_ORDER]: 500,
849
851
  [GATEWAY_VAULT_ERRORS.GATEWAY_NOT_CONFIGURED]: 500,
850
852
  [NETWORK_ERRORS.UPSTREAM_ERROR]: 502,
853
+ [INTERNAL_ERRORS.FLY_CLEANUP_FAILED]: 502,
851
854
  [INTERNAL_ERRORS.INITIALIZATION_ERROR]: 503,
852
855
  [INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: 503,
853
856
  [INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: 503,
@@ -95,7 +95,8 @@ const INTERNAL_ERRORS = {
95
95
  SERVICE_UNAVAILABLE_TRANSIENT: "SERVICE_UNAVAILABLE_TRANSIENT",
96
96
  TRANSACTION_FAILED: "TRANSACTION_FAILED",
97
97
  DELETE_FAILED: "DELETE_FAILED",
98
- PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS"
98
+ PARTITION_RETIREMENT_IN_PROGRESS: "PARTITION_RETIREMENT_IN_PROGRESS",
99
+ FLY_CLEANUP_FAILED: "FLY_CLEANUP_FAILED"
99
100
  };
100
101
  /**
101
102
  * Session Error Codes
@@ -506,9 +507,10 @@ const ERROR_MESSAGES = {
506
507
  [INTERNAL_ERRORS.PROCESSING_ERROR]: "Processing error",
507
508
  [INTERNAL_ERRORS.UNKNOWN_ERROR]: "An unknown error occurred",
508
509
  [INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: "A dependency is temporarily unavailable. Retry shortly.",
509
- [INTERNAL_ERRORS.TRANSACTION_FAILED]: "The deletion failed because of a database error. Nothing was deleted.",
510
+ [INTERNAL_ERRORS.TRANSACTION_FAILED]: "The deletion failed because of a database error. The project was not deleted.",
510
511
  [INTERNAL_ERRORS.DELETE_FAILED]: "Failed to delete project",
511
512
  [INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: "The project data is being archived. Retry shortly.",
513
+ [INTERNAL_ERRORS.FLY_CLEANUP_FAILED]: "Couldn't stop a managed agent's machine, so the delete was refused. Retry the delete.",
512
514
  [SESSION_ERRORS.SESSION_NOT_FOUND]: "Session not found",
513
515
  [SESSION_ERRORS.SESSION_EXPIRED]: "Session has expired",
514
516
  [SESSION_ERRORS.SESSION_INVALID]: "Session is invalid",
@@ -847,6 +849,7 @@ const ERROR_STATUS_CODES = {
847
849
  [AUDIT_PROTOCOL_ERRORS.AUDIT_MIRROR_OUT_OF_ORDER]: 500,
848
850
  [GATEWAY_VAULT_ERRORS.GATEWAY_NOT_CONFIGURED]: 500,
849
851
  [NETWORK_ERRORS.UPSTREAM_ERROR]: 502,
852
+ [INTERNAL_ERRORS.FLY_CLEANUP_FAILED]: 502,
850
853
  [INTERNAL_ERRORS.INITIALIZATION_ERROR]: 503,
851
854
  [INTERNAL_ERRORS.SERVICE_UNAVAILABLE_TRANSIENT]: 503,
852
855
  [INTERNAL_ERRORS.PARTITION_RETIREMENT_IN_PROGRESS]: 503,