chainlesschain 0.143.0 → 0.145.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 (133) hide show
  1. package/package.json +1 -1
  2. package/src/commands/a2a.js +196 -28
  3. package/src/commands/activitypub.js +157 -27
  4. package/src/commands/agent.js +587 -103
  5. package/src/commands/audit.js +206 -0
  6. package/src/commands/bi.js +152 -27
  7. package/src/commands/bm25.js +111 -27
  8. package/src/commands/browse.js +190 -29
  9. package/src/commands/ccron.js +128 -28
  10. package/src/commands/chat.js +207 -0
  11. package/src/commands/compliance.js +414 -34
  12. package/src/commands/compt.js +127 -29
  13. package/src/commands/consol.js +8 -2
  14. package/src/commands/cowork.js +580 -34
  15. package/src/commands/crosschain.js +182 -28
  16. package/src/commands/dao.js +182 -28
  17. package/src/commands/dlp.js +172 -27
  18. package/src/commands/economy.js +205 -50
  19. package/src/commands/evolution.js +203 -50
  20. package/src/commands/evomap.js +182 -27
  21. package/src/commands/fflag.js +74 -22
  22. package/src/commands/git.js +177 -37
  23. package/src/commands/hardening.js +209 -0
  24. package/src/commands/hmemory.js +204 -50
  25. package/src/commands/incentive.js +209 -0
  26. package/src/commands/inference.js +170 -34
  27. package/src/commands/itbudget.js +149 -33
  28. package/src/commands/kg.js +206 -0
  29. package/src/commands/lowcode.js +195 -38
  30. package/src/commands/marketplace.js +206 -0
  31. package/src/commands/matrix.js +179 -27
  32. package/src/commands/mcpscaf.js +145 -33
  33. package/src/commands/meminj.js +145 -33
  34. package/src/commands/nostr.js +178 -27
  35. package/src/commands/orchestrate.js +217 -0
  36. package/src/commands/orchgov.js +144 -33
  37. package/src/commands/pdfp.js +109 -27
  38. package/src/commands/perf.js +169 -32
  39. package/src/commands/perm.js +144 -33
  40. package/src/commands/pipeline.js +207 -52
  41. package/src/commands/planmode.js +141 -32
  42. package/src/commands/privacy.js +203 -0
  43. package/src/commands/promcomp.js +111 -27
  44. package/src/commands/recommend.js +177 -34
  45. package/src/commands/reputation.js +208 -0
  46. package/src/commands/sandbox.js +206 -0
  47. package/src/commands/seshhook.js +145 -33
  48. package/src/commands/seshsearch.js +141 -33
  49. package/src/commands/seshtail.js +144 -33
  50. package/src/commands/seshu.js +152 -33
  51. package/src/commands/sganal.js +123 -29
  52. package/src/commands/siem.js +201 -34
  53. package/src/commands/sla.js +212 -0
  54. package/src/commands/slotfill.js +146 -33
  55. package/src/commands/social.js +157 -32
  56. package/src/commands/stress.js +206 -0
  57. package/src/commands/svccont.js +145 -33
  58. package/src/commands/terraform.js +206 -0
  59. package/src/commands/tms.js +171 -33
  60. package/src/commands/topiccls.js +146 -33
  61. package/src/commands/uprof.js +141 -32
  62. package/src/commands/vcheck.js +122 -28
  63. package/src/commands/webfetch.js +141 -32
  64. package/src/commands/zkp.js +184 -28
  65. package/src/index.js +40 -0
  66. package/src/lib/a2a-protocol.js +319 -51
  67. package/src/lib/activitypub-bridge.js +288 -50
  68. package/src/lib/agent-economy.js +304 -51
  69. package/src/lib/app-builder.js +279 -46
  70. package/src/lib/audit-logger.js +321 -0
  71. package/src/lib/autonomous-agent.js +284 -48
  72. package/src/lib/bi-engine.js +283 -49
  73. package/src/lib/bm25-search.js +301 -49
  74. package/src/lib/browser-automation.js +296 -49
  75. package/src/lib/chat-core.js +336 -0
  76. package/src/lib/claude-code-bridge.js +341 -0
  77. package/src/lib/compliance-framework-reporter.js +305 -51
  78. package/src/lib/compliance-manager.js +330 -0
  79. package/src/lib/compression-telemetry.js +301 -49
  80. package/src/lib/content-recommender.js +317 -52
  81. package/src/lib/cowork-cron.js +298 -49
  82. package/src/lib/cowork-learning.js +333 -0
  83. package/src/lib/cowork-task-runner.js +308 -51
  84. package/src/lib/cowork-workflow.js +327 -0
  85. package/src/lib/cross-chain.js +311 -51
  86. package/src/lib/dao-governance.js +280 -46
  87. package/src/lib/dlp-engine.js +287 -49
  88. package/src/lib/evolution-system.js +278 -47
  89. package/src/lib/evomap-manager.js +280 -46
  90. package/src/lib/execution-backend.js +294 -48
  91. package/src/lib/feature-flags.js +294 -49
  92. package/src/lib/git-integration.js +285 -47
  93. package/src/lib/hardening-manager.js +341 -0
  94. package/src/lib/hierarchical-memory.js +284 -48
  95. package/src/lib/inference-network.js +308 -51
  96. package/src/lib/iteration-budget.js +302 -50
  97. package/src/lib/knowledge-graph.js +333 -0
  98. package/src/lib/matrix-bridge.js +281 -47
  99. package/src/lib/mcp-scaffold.js +318 -54
  100. package/src/lib/memory-injection.js +288 -49
  101. package/src/lib/nostr-bridge.js +286 -49
  102. package/src/lib/orchestrator.js +293 -48
  103. package/src/lib/pdf-parser.js +298 -49
  104. package/src/lib/perf-tuning.js +309 -50
  105. package/src/lib/permission-engine.js +287 -49
  106. package/src/lib/pipeline-orchestrator.js +289 -49
  107. package/src/lib/plan-mode.js +298 -51
  108. package/src/lib/privacy-computing.js +335 -0
  109. package/src/lib/reputation-optimizer.js +340 -0
  110. package/src/lib/sandbox-v2.js +327 -0
  111. package/src/lib/service-container.js +313 -52
  112. package/src/lib/session-consolidator.js +296 -49
  113. package/src/lib/session-hooks.js +312 -53
  114. package/src/lib/session-search.js +304 -51
  115. package/src/lib/session-tail.js +288 -49
  116. package/src/lib/session-usage.js +298 -52
  117. package/src/lib/siem-exporter.js +298 -51
  118. package/src/lib/skill-marketplace.js +345 -0
  119. package/src/lib/sla-manager.js +341 -0
  120. package/src/lib/slot-filler.js +303 -51
  121. package/src/lib/social-graph-analytics.js +295 -49
  122. package/src/lib/social-graph.js +272 -49
  123. package/src/lib/stress-tester.js +342 -0
  124. package/src/lib/sub-agent-registry.js +302 -53
  125. package/src/lib/task-model-selector.js +302 -50
  126. package/src/lib/terraform-manager.js +333 -0
  127. package/src/lib/todo-manager.js +281 -47
  128. package/src/lib/token-incentive.js +341 -0
  129. package/src/lib/topic-classifier.js +297 -49
  130. package/src/lib/user-profile.js +294 -50
  131. package/src/lib/version-checker.js +304 -50
  132. package/src/lib/web-fetch.js +292 -51
  133. package/src/lib/zkp-engine.js +286 -49
@@ -1002,3 +1002,330 @@ export function getSandboxStatsV2() {
1002
1002
  },
1003
1003
  };
1004
1004
  }
1005
+
1006
+ // =====================================================================
1007
+ // sandbox-v2 V2 governance overlay (iter16)
1008
+ // =====================================================================
1009
+ export const SBOX_PROFILE_MATURITY_V2 = Object.freeze({
1010
+ PENDING: "pending",
1011
+ ACTIVE: "active",
1012
+ PAUSED: "paused",
1013
+ ARCHIVED: "archived",
1014
+ });
1015
+ export const SBOX_EXEC_LIFECYCLE_V2 = Object.freeze({
1016
+ QUEUED: "queued",
1017
+ RUNNING: "running",
1018
+ COMPLETED: "completed",
1019
+ FAILED: "failed",
1020
+ CANCELLED: "cancelled",
1021
+ });
1022
+ const _sboxPTrans = new Map([
1023
+ [
1024
+ SBOX_PROFILE_MATURITY_V2.PENDING,
1025
+ new Set([
1026
+ SBOX_PROFILE_MATURITY_V2.ACTIVE,
1027
+ SBOX_PROFILE_MATURITY_V2.ARCHIVED,
1028
+ ]),
1029
+ ],
1030
+ [
1031
+ SBOX_PROFILE_MATURITY_V2.ACTIVE,
1032
+ new Set([
1033
+ SBOX_PROFILE_MATURITY_V2.PAUSED,
1034
+ SBOX_PROFILE_MATURITY_V2.ARCHIVED,
1035
+ ]),
1036
+ ],
1037
+ [
1038
+ SBOX_PROFILE_MATURITY_V2.PAUSED,
1039
+ new Set([
1040
+ SBOX_PROFILE_MATURITY_V2.ACTIVE,
1041
+ SBOX_PROFILE_MATURITY_V2.ARCHIVED,
1042
+ ]),
1043
+ ],
1044
+ [SBOX_PROFILE_MATURITY_V2.ARCHIVED, new Set()],
1045
+ ]);
1046
+ const _sboxPTerminal = new Set([SBOX_PROFILE_MATURITY_V2.ARCHIVED]);
1047
+ const _sboxJTrans = new Map([
1048
+ [
1049
+ SBOX_EXEC_LIFECYCLE_V2.QUEUED,
1050
+ new Set([SBOX_EXEC_LIFECYCLE_V2.RUNNING, SBOX_EXEC_LIFECYCLE_V2.CANCELLED]),
1051
+ ],
1052
+ [
1053
+ SBOX_EXEC_LIFECYCLE_V2.RUNNING,
1054
+ new Set([
1055
+ SBOX_EXEC_LIFECYCLE_V2.COMPLETED,
1056
+ SBOX_EXEC_LIFECYCLE_V2.FAILED,
1057
+ SBOX_EXEC_LIFECYCLE_V2.CANCELLED,
1058
+ ]),
1059
+ ],
1060
+ [SBOX_EXEC_LIFECYCLE_V2.COMPLETED, new Set()],
1061
+ [SBOX_EXEC_LIFECYCLE_V2.FAILED, new Set()],
1062
+ [SBOX_EXEC_LIFECYCLE_V2.CANCELLED, new Set()],
1063
+ ]);
1064
+ const _sboxPsV2 = new Map();
1065
+ const _sboxJsV2 = new Map();
1066
+ let _sboxMaxActive = 6,
1067
+ _sboxMaxPending = 12,
1068
+ _sboxIdleMs = 30 * 24 * 60 * 60 * 1000,
1069
+ _sboxStuckMs = 60 * 1000;
1070
+ function _sboxPos(n, label) {
1071
+ const v = Math.floor(Number(n));
1072
+ if (!Number.isFinite(v) || v <= 0)
1073
+ throw new Error(`${label} must be positive integer`);
1074
+ return v;
1075
+ }
1076
+ function _sboxCheckP(from, to) {
1077
+ const a = _sboxPTrans.get(from);
1078
+ if (!a || !a.has(to))
1079
+ throw new Error(`invalid sbox profile transition ${from} → ${to}`);
1080
+ }
1081
+ function _sboxCheckJ(from, to) {
1082
+ const a = _sboxJTrans.get(from);
1083
+ if (!a || !a.has(to))
1084
+ throw new Error(`invalid sbox exec transition ${from} → ${to}`);
1085
+ }
1086
+ function _sboxCountActive(owner) {
1087
+ let c = 0;
1088
+ for (const p of _sboxPsV2.values())
1089
+ if (p.owner === owner && p.status === SBOX_PROFILE_MATURITY_V2.ACTIVE) c++;
1090
+ return c;
1091
+ }
1092
+ function _sboxCountPending(profileId) {
1093
+ let c = 0;
1094
+ for (const j of _sboxJsV2.values())
1095
+ if (
1096
+ j.profileId === profileId &&
1097
+ (j.status === SBOX_EXEC_LIFECYCLE_V2.QUEUED ||
1098
+ j.status === SBOX_EXEC_LIFECYCLE_V2.RUNNING)
1099
+ )
1100
+ c++;
1101
+ return c;
1102
+ }
1103
+ export function setMaxActiveSboxProfilesPerOwnerV2(n) {
1104
+ _sboxMaxActive = _sboxPos(n, "maxActiveSboxProfilesPerOwner");
1105
+ }
1106
+ export function getMaxActiveSboxProfilesPerOwnerV2() {
1107
+ return _sboxMaxActive;
1108
+ }
1109
+ export function setMaxPendingSboxExecsPerProfileV2(n) {
1110
+ _sboxMaxPending = _sboxPos(n, "maxPendingSboxExecsPerProfile");
1111
+ }
1112
+ export function getMaxPendingSboxExecsPerProfileV2() {
1113
+ return _sboxMaxPending;
1114
+ }
1115
+ export function setSboxProfileIdleMsV2(n) {
1116
+ _sboxIdleMs = _sboxPos(n, "sboxProfileIdleMs");
1117
+ }
1118
+ export function getSboxProfileIdleMsV2() {
1119
+ return _sboxIdleMs;
1120
+ }
1121
+ export function setSboxExecStuckMsV2(n) {
1122
+ _sboxStuckMs = _sboxPos(n, "sboxExecStuckMs");
1123
+ }
1124
+ export function getSboxExecStuckMsV2() {
1125
+ return _sboxStuckMs;
1126
+ }
1127
+ export function _resetStateSandboxV2() {
1128
+ _sboxPsV2.clear();
1129
+ _sboxJsV2.clear();
1130
+ _sboxMaxActive = 6;
1131
+ _sboxMaxPending = 12;
1132
+ _sboxIdleMs = 30 * 24 * 60 * 60 * 1000;
1133
+ _sboxStuckMs = 60 * 1000;
1134
+ }
1135
+ export function registerSboxProfileV2({ id, owner, template, metadata } = {}) {
1136
+ if (!id || !owner) throw new Error("id and owner required");
1137
+ if (_sboxPsV2.has(id)) throw new Error(`sbox profile ${id} already exists`);
1138
+ const now = Date.now();
1139
+ const p = {
1140
+ id,
1141
+ owner,
1142
+ template: template || "default",
1143
+ status: SBOX_PROFILE_MATURITY_V2.PENDING,
1144
+ createdAt: now,
1145
+ updatedAt: now,
1146
+ lastTouchedAt: now,
1147
+ activatedAt: null,
1148
+ archivedAt: null,
1149
+ metadata: { ...(metadata || {}) },
1150
+ };
1151
+ _sboxPsV2.set(id, p);
1152
+ return { ...p, metadata: { ...p.metadata } };
1153
+ }
1154
+ export function activateSboxProfileV2(id) {
1155
+ const p = _sboxPsV2.get(id);
1156
+ if (!p) throw new Error(`sbox profile ${id} not found`);
1157
+ const isInitial = p.status === SBOX_PROFILE_MATURITY_V2.PENDING;
1158
+ _sboxCheckP(p.status, SBOX_PROFILE_MATURITY_V2.ACTIVE);
1159
+ if (isInitial && _sboxCountActive(p.owner) >= _sboxMaxActive)
1160
+ throw new Error(`max active sbox profiles for owner ${p.owner} reached`);
1161
+ const now = Date.now();
1162
+ p.status = SBOX_PROFILE_MATURITY_V2.ACTIVE;
1163
+ p.updatedAt = now;
1164
+ p.lastTouchedAt = now;
1165
+ if (!p.activatedAt) p.activatedAt = now;
1166
+ return { ...p, metadata: { ...p.metadata } };
1167
+ }
1168
+ export function pauseSboxProfileV2(id) {
1169
+ const p = _sboxPsV2.get(id);
1170
+ if (!p) throw new Error(`sbox profile ${id} not found`);
1171
+ _sboxCheckP(p.status, SBOX_PROFILE_MATURITY_V2.PAUSED);
1172
+ p.status = SBOX_PROFILE_MATURITY_V2.PAUSED;
1173
+ p.updatedAt = Date.now();
1174
+ return { ...p, metadata: { ...p.metadata } };
1175
+ }
1176
+ export function archiveSboxProfileV2(id) {
1177
+ const p = _sboxPsV2.get(id);
1178
+ if (!p) throw new Error(`sbox profile ${id} not found`);
1179
+ _sboxCheckP(p.status, SBOX_PROFILE_MATURITY_V2.ARCHIVED);
1180
+ const now = Date.now();
1181
+ p.status = SBOX_PROFILE_MATURITY_V2.ARCHIVED;
1182
+ p.updatedAt = now;
1183
+ if (!p.archivedAt) p.archivedAt = now;
1184
+ return { ...p, metadata: { ...p.metadata } };
1185
+ }
1186
+ export function touchSboxProfileV2(id) {
1187
+ const p = _sboxPsV2.get(id);
1188
+ if (!p) throw new Error(`sbox profile ${id} not found`);
1189
+ if (_sboxPTerminal.has(p.status))
1190
+ throw new Error(`cannot touch terminal sbox profile ${id}`);
1191
+ const now = Date.now();
1192
+ p.lastTouchedAt = now;
1193
+ p.updatedAt = now;
1194
+ return { ...p, metadata: { ...p.metadata } };
1195
+ }
1196
+ export function getSboxProfileV2(id) {
1197
+ const p = _sboxPsV2.get(id);
1198
+ if (!p) return null;
1199
+ return { ...p, metadata: { ...p.metadata } };
1200
+ }
1201
+ export function listSboxProfilesV2() {
1202
+ return [..._sboxPsV2.values()].map((p) => ({
1203
+ ...p,
1204
+ metadata: { ...p.metadata },
1205
+ }));
1206
+ }
1207
+ export function createSboxExecV2({ id, profileId, command, metadata } = {}) {
1208
+ if (!id || !profileId) throw new Error("id and profileId required");
1209
+ if (_sboxJsV2.has(id)) throw new Error(`sbox exec ${id} already exists`);
1210
+ if (!_sboxPsV2.has(profileId))
1211
+ throw new Error(`sbox profile ${profileId} not found`);
1212
+ if (_sboxCountPending(profileId) >= _sboxMaxPending)
1213
+ throw new Error(`max pending sbox execs for profile ${profileId} reached`);
1214
+ const now = Date.now();
1215
+ const j = {
1216
+ id,
1217
+ profileId,
1218
+ command: command || "",
1219
+ status: SBOX_EXEC_LIFECYCLE_V2.QUEUED,
1220
+ createdAt: now,
1221
+ updatedAt: now,
1222
+ startedAt: null,
1223
+ settledAt: null,
1224
+ metadata: { ...(metadata || {}) },
1225
+ };
1226
+ _sboxJsV2.set(id, j);
1227
+ return { ...j, metadata: { ...j.metadata } };
1228
+ }
1229
+ export function runningSboxExecV2(id) {
1230
+ const j = _sboxJsV2.get(id);
1231
+ if (!j) throw new Error(`sbox exec ${id} not found`);
1232
+ _sboxCheckJ(j.status, SBOX_EXEC_LIFECYCLE_V2.RUNNING);
1233
+ const now = Date.now();
1234
+ j.status = SBOX_EXEC_LIFECYCLE_V2.RUNNING;
1235
+ j.updatedAt = now;
1236
+ if (!j.startedAt) j.startedAt = now;
1237
+ return { ...j, metadata: { ...j.metadata } };
1238
+ }
1239
+ export function completeExecSboxV2(id) {
1240
+ const j = _sboxJsV2.get(id);
1241
+ if (!j) throw new Error(`sbox exec ${id} not found`);
1242
+ _sboxCheckJ(j.status, SBOX_EXEC_LIFECYCLE_V2.COMPLETED);
1243
+ const now = Date.now();
1244
+ j.status = SBOX_EXEC_LIFECYCLE_V2.COMPLETED;
1245
+ j.updatedAt = now;
1246
+ if (!j.settledAt) j.settledAt = now;
1247
+ return { ...j, metadata: { ...j.metadata } };
1248
+ }
1249
+ export function failSboxExecV2(id, reason) {
1250
+ const j = _sboxJsV2.get(id);
1251
+ if (!j) throw new Error(`sbox exec ${id} not found`);
1252
+ _sboxCheckJ(j.status, SBOX_EXEC_LIFECYCLE_V2.FAILED);
1253
+ const now = Date.now();
1254
+ j.status = SBOX_EXEC_LIFECYCLE_V2.FAILED;
1255
+ j.updatedAt = now;
1256
+ if (!j.settledAt) j.settledAt = now;
1257
+ if (reason) j.metadata.failReason = String(reason);
1258
+ return { ...j, metadata: { ...j.metadata } };
1259
+ }
1260
+ export function cancelSboxExecV2(id, reason) {
1261
+ const j = _sboxJsV2.get(id);
1262
+ if (!j) throw new Error(`sbox exec ${id} not found`);
1263
+ _sboxCheckJ(j.status, SBOX_EXEC_LIFECYCLE_V2.CANCELLED);
1264
+ const now = Date.now();
1265
+ j.status = SBOX_EXEC_LIFECYCLE_V2.CANCELLED;
1266
+ j.updatedAt = now;
1267
+ if (!j.settledAt) j.settledAt = now;
1268
+ if (reason) j.metadata.cancelReason = String(reason);
1269
+ return { ...j, metadata: { ...j.metadata } };
1270
+ }
1271
+ export function getSboxExecV2(id) {
1272
+ const j = _sboxJsV2.get(id);
1273
+ if (!j) return null;
1274
+ return { ...j, metadata: { ...j.metadata } };
1275
+ }
1276
+ export function listSboxExecsV2() {
1277
+ return [..._sboxJsV2.values()].map((j) => ({
1278
+ ...j,
1279
+ metadata: { ...j.metadata },
1280
+ }));
1281
+ }
1282
+ export function autoPauseIdleSboxProfilesV2({ now } = {}) {
1283
+ const t = now ?? Date.now();
1284
+ const flipped = [];
1285
+ for (const p of _sboxPsV2.values())
1286
+ if (
1287
+ p.status === SBOX_PROFILE_MATURITY_V2.ACTIVE &&
1288
+ t - p.lastTouchedAt >= _sboxIdleMs
1289
+ ) {
1290
+ p.status = SBOX_PROFILE_MATURITY_V2.PAUSED;
1291
+ p.updatedAt = t;
1292
+ flipped.push(p.id);
1293
+ }
1294
+ return { flipped, count: flipped.length };
1295
+ }
1296
+ export function autoFailStuckSboxExecsV2({ now } = {}) {
1297
+ const t = now ?? Date.now();
1298
+ const flipped = [];
1299
+ for (const j of _sboxJsV2.values())
1300
+ if (
1301
+ j.status === SBOX_EXEC_LIFECYCLE_V2.RUNNING &&
1302
+ j.startedAt != null &&
1303
+ t - j.startedAt >= _sboxStuckMs
1304
+ ) {
1305
+ j.status = SBOX_EXEC_LIFECYCLE_V2.FAILED;
1306
+ j.updatedAt = t;
1307
+ if (!j.settledAt) j.settledAt = t;
1308
+ j.metadata.failReason = "auto-fail-stuck";
1309
+ flipped.push(j.id);
1310
+ }
1311
+ return { flipped, count: flipped.length };
1312
+ }
1313
+ export function getSandboxGovStatsV2() {
1314
+ const profilesByStatus = {};
1315
+ for (const v of Object.values(SBOX_PROFILE_MATURITY_V2))
1316
+ profilesByStatus[v] = 0;
1317
+ for (const p of _sboxPsV2.values()) profilesByStatus[p.status]++;
1318
+ const execsByStatus = {};
1319
+ for (const v of Object.values(SBOX_EXEC_LIFECYCLE_V2)) execsByStatus[v] = 0;
1320
+ for (const j of _sboxJsV2.values()) execsByStatus[j.status]++;
1321
+ return {
1322
+ totalSboxProfilesV2: _sboxPsV2.size,
1323
+ totalSboxExecsV2: _sboxJsV2.size,
1324
+ maxActiveSboxProfilesPerOwner: _sboxMaxActive,
1325
+ maxPendingSboxExecsPerProfile: _sboxMaxPending,
1326
+ sboxProfileIdleMs: _sboxIdleMs,
1327
+ sboxExecStuckMs: _sboxStuckMs,
1328
+ profilesByStatus,
1329
+ execsByStatus,
1330
+ };
1331
+ }