@semiont/cli 0.4.19 → 0.4.21

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/dist/cli.mjs +235 -181
  2. package/dist/frontend/dist/assets/{CookiePreferences-BBb5XMuG.js → CookiePreferences-CWvTznuy.js} +2 -2
  3. package/dist/frontend/dist/assets/{CookiePreferences-BBb5XMuG.js.map → CookiePreferences-CWvTznuy.js.map} +1 -1
  4. package/dist/frontend/dist/assets/PdfAnnotationCanvas.client-6ZGFEN2N-Dnq2pEeZ.js +2 -0
  5. package/dist/frontend/dist/assets/PdfAnnotationCanvas.client-6ZGFEN2N-Dnq2pEeZ.js.map +1 -0
  6. package/dist/frontend/dist/assets/ToolbarPanels-DQrfch_k.js +2 -0
  7. package/dist/frontend/dist/assets/ToolbarPanels-DQrfch_k.js.map +1 -0
  8. package/dist/frontend/dist/assets/client-9KMfqezG.js +2 -0
  9. package/dist/frontend/dist/assets/client-9KMfqezG.js.map +1 -0
  10. package/dist/frontend/dist/assets/client-Bvrf4lLa.js +2 -0
  11. package/dist/frontend/dist/assets/client-Bvrf4lLa.js.map +1 -0
  12. package/dist/frontend/dist/assets/client-D9qa8fAn.js +2 -0
  13. package/dist/frontend/dist/assets/client-D9qa8fAn.js.map +1 -0
  14. package/dist/frontend/dist/assets/client-kIBNRH2w.js +2 -0
  15. package/dist/frontend/dist/assets/client-kIBNRH2w.js.map +1 -0
  16. package/dist/frontend/dist/assets/index-DaA8-3Y1.js +169 -0
  17. package/dist/frontend/dist/assets/index-DaA8-3Y1.js.map +1 -0
  18. package/dist/frontend/dist/assets/{index-DNL392dn.css → index-fHqJXd_A.css} +1 -1
  19. package/dist/frontend/dist/assets/layout-BLGpzYwk.js +2 -0
  20. package/dist/frontend/dist/assets/layout-BLGpzYwk.js.map +1 -0
  21. package/dist/frontend/dist/assets/layout-BgHlzaj1.js +2 -0
  22. package/dist/frontend/dist/assets/layout-BgHlzaj1.js.map +1 -0
  23. package/dist/frontend/dist/assets/layout-Dj1MEjN6.js +2 -0
  24. package/dist/frontend/dist/assets/layout-Dj1MEjN6.js.map +1 -0
  25. package/dist/frontend/dist/assets/layout-easR0slx.js +2 -0
  26. package/dist/frontend/dist/assets/layout-easR0slx.js.map +1 -0
  27. package/dist/frontend/dist/assets/not-found-nC4IaXPt.js +2 -0
  28. package/dist/frontend/dist/assets/{not-found-BKG2_Fv3.js.map → not-found-nC4IaXPt.js.map} +1 -1
  29. package/dist/frontend/dist/assets/page-8zC_t3l-.js +2 -0
  30. package/dist/frontend/dist/assets/page-8zC_t3l-.js.map +1 -0
  31. package/dist/frontend/dist/assets/page-BD9EKRMV.js +2 -0
  32. package/dist/frontend/dist/assets/{page-DbwQv5n_.js.map → page-BD9EKRMV.js.map} +1 -1
  33. package/dist/frontend/dist/assets/page-BDMxGD5Z.js +8 -0
  34. package/dist/frontend/dist/assets/{page-aKPxuWo3.js.map → page-BDMxGD5Z.js.map} +1 -1
  35. package/dist/frontend/dist/assets/page-BwiRQxa7.js +2 -0
  36. package/dist/frontend/dist/assets/page-BwiRQxa7.js.map +1 -0
  37. package/dist/frontend/dist/assets/page-By8BIN8Q.js +2 -0
  38. package/dist/frontend/dist/assets/{page-IgGNB4a9.js.map → page-By8BIN8Q.js.map} +1 -1
  39. package/dist/frontend/dist/assets/{page-BRTi-f95.js → page-C8zOqZ8M.js} +3 -3
  40. package/dist/frontend/dist/assets/{page-BRTi-f95.js.map → page-C8zOqZ8M.js.map} +1 -1
  41. package/dist/frontend/dist/assets/page-CQsfujTh.js +2 -0
  42. package/dist/frontend/dist/assets/page-CQsfujTh.js.map +1 -0
  43. package/dist/frontend/dist/assets/page-CTvUxWH5.js +2 -0
  44. package/dist/frontend/dist/assets/{page-BSB8GP79.js.map → page-CTvUxWH5.js.map} +1 -1
  45. package/dist/frontend/dist/assets/page-ChjwiTJ8.js +2 -0
  46. package/dist/frontend/dist/assets/page-ChjwiTJ8.js.map +1 -0
  47. package/dist/frontend/dist/assets/page-D8JSCVFI.js +2 -0
  48. package/dist/frontend/dist/assets/{page-CDSGl6uY.js.map → page-D8JSCVFI.js.map} +1 -1
  49. package/dist/frontend/dist/assets/page-DB1HZ_Jr.js +2 -0
  50. package/dist/frontend/dist/assets/{page-D1q6VB02.js.map → page-DB1HZ_Jr.js.map} +1 -1
  51. package/dist/frontend/dist/assets/page-DBoIW_-n.js +2 -0
  52. package/dist/frontend/dist/assets/{page-DzoXV-AN.js.map → page-DBoIW_-n.js.map} +1 -1
  53. package/dist/frontend/dist/assets/page-DEHEdU59.js +2 -0
  54. package/dist/frontend/dist/assets/{page-BNJp__R7.js.map → page-DEHEdU59.js.map} +1 -1
  55. package/dist/frontend/dist/assets/page-DWS9ulKD.js +5 -0
  56. package/dist/frontend/dist/assets/{page-D3THDsqd.js.map → page-DWS9ulKD.js.map} +1 -1
  57. package/dist/frontend/dist/assets/page-DoqFVg4p.js +2 -0
  58. package/dist/frontend/dist/assets/page-DoqFVg4p.js.map +1 -0
  59. package/dist/frontend/dist/assets/page-btIB2WK4.js +2 -0
  60. package/dist/frontend/dist/assets/page-btIB2WK4.js.map +1 -0
  61. package/dist/frontend/dist/assets/page-jr_Rqa0A.js +2 -0
  62. package/dist/frontend/dist/assets/page-jr_Rqa0A.js.map +1 -0
  63. package/dist/frontend/dist/assets/page-kLVTeA46.js +2 -0
  64. package/dist/frontend/dist/assets/{page-CJLuuiG8.js.map → page-kLVTeA46.js.map} +1 -1
  65. package/dist/frontend/dist/assets/privacy-mpF0jllH.js +2 -0
  66. package/dist/frontend/dist/assets/{privacy-BAxopuZI.js.map → privacy-mpF0jllH.js.map} +1 -1
  67. package/dist/frontend/dist/assets/{routing-rYtBowvy.js → routing-BmJG4tNe.js} +2 -2
  68. package/dist/frontend/dist/assets/{routing-rYtBowvy.js.map → routing-BmJG4tNe.js.map} +1 -1
  69. package/dist/frontend/dist/assets/routing-JYkXODZK.js +2 -0
  70. package/dist/frontend/dist/assets/{routing-Cm_oCwum.js.map → routing-JYkXODZK.js.map} +1 -1
  71. package/dist/frontend/dist/index.html +2 -3
  72. package/dist/frontend/dist/messages/ar.json +0 -1
  73. package/dist/frontend/dist/messages/bn.json +0 -1
  74. package/dist/frontend/dist/messages/cs.json +0 -1
  75. package/dist/frontend/dist/messages/da.json +0 -1
  76. package/dist/frontend/dist/messages/de.json +0 -1
  77. package/dist/frontend/dist/messages/el.json +0 -1
  78. package/dist/frontend/dist/messages/en.json +0 -1
  79. package/dist/frontend/dist/messages/es.json +0 -1
  80. package/dist/frontend/dist/messages/fa.json +0 -1
  81. package/dist/frontend/dist/messages/fi.json +0 -1
  82. package/dist/frontend/dist/messages/fr.json +0 -1
  83. package/dist/frontend/dist/messages/he.json +0 -1
  84. package/dist/frontend/dist/messages/hi.json +0 -1
  85. package/dist/frontend/dist/messages/id.json +0 -1
  86. package/dist/frontend/dist/messages/it.json +0 -1
  87. package/dist/frontend/dist/messages/ja.json +0 -1
  88. package/dist/frontend/dist/messages/ko.json +0 -1
  89. package/dist/frontend/dist/messages/ms.json +0 -1
  90. package/dist/frontend/dist/messages/nl.json +0 -1
  91. package/dist/frontend/dist/messages/no.json +0 -1
  92. package/dist/frontend/dist/messages/pl.json +0 -1
  93. package/dist/frontend/dist/messages/pt.json +0 -1
  94. package/dist/frontend/dist/messages/ro.json +0 -1
  95. package/dist/frontend/dist/messages/sv.json +0 -1
  96. package/dist/frontend/dist/messages/th.json +0 -1
  97. package/dist/frontend/dist/messages/tr.json +0 -1
  98. package/dist/frontend/dist/messages/uk.json +0 -1
  99. package/dist/frontend/dist/messages/vi.json +0 -1
  100. package/dist/frontend/dist/messages/zh.json +0 -1
  101. package/dist/frontend/package.json +1 -1
  102. package/package.json +7 -7
  103. package/dist/frontend/dist/assets/PdfAnnotationCanvas.client-CHDCGQBR-mCGxablw.js +0 -2
  104. package/dist/frontend/dist/assets/PdfAnnotationCanvas.client-CHDCGQBR-mCGxablw.js.map +0 -1
  105. package/dist/frontend/dist/assets/StreamStatusContext-BNiTXRfJ.js +0 -2
  106. package/dist/frontend/dist/assets/StreamStatusContext-BNiTXRfJ.js.map +0 -1
  107. package/dist/frontend/dist/assets/ToolbarPanels-CfaOVIc9.js +0 -2
  108. package/dist/frontend/dist/assets/ToolbarPanels-CfaOVIc9.js.map +0 -1
  109. package/dist/frontend/dist/assets/client-CWwdB0xQ.js +0 -2
  110. package/dist/frontend/dist/assets/client-CWwdB0xQ.js.map +0 -1
  111. package/dist/frontend/dist/assets/client-Cgz-uiSd.js +0 -2
  112. package/dist/frontend/dist/assets/client-Cgz-uiSd.js.map +0 -1
  113. package/dist/frontend/dist/assets/client-D3W9xTBT.js +0 -2
  114. package/dist/frontend/dist/assets/client-D3W9xTBT.js.map +0 -1
  115. package/dist/frontend/dist/assets/client-DeL0szs5.js +0 -2
  116. package/dist/frontend/dist/assets/client-DeL0szs5.js.map +0 -1
  117. package/dist/frontend/dist/assets/index-C5oI0kaf.js +0 -161
  118. package/dist/frontend/dist/assets/index-C5oI0kaf.js.map +0 -1
  119. package/dist/frontend/dist/assets/layout-B_JLc3yI.js +0 -2
  120. package/dist/frontend/dist/assets/layout-B_JLc3yI.js.map +0 -1
  121. package/dist/frontend/dist/assets/layout-DJI7aibW.js +0 -2
  122. package/dist/frontend/dist/assets/layout-DJI7aibW.js.map +0 -1
  123. package/dist/frontend/dist/assets/layout-DXY8hCsB.js +0 -2
  124. package/dist/frontend/dist/assets/layout-DXY8hCsB.js.map +0 -1
  125. package/dist/frontend/dist/assets/layout-VBQ97DvJ.js +0 -2
  126. package/dist/frontend/dist/assets/layout-VBQ97DvJ.js.map +0 -1
  127. package/dist/frontend/dist/assets/not-found-BKG2_Fv3.js +0 -2
  128. package/dist/frontend/dist/assets/page-8OrS1-4-.js +0 -2
  129. package/dist/frontend/dist/assets/page-8OrS1-4-.js.map +0 -1
  130. package/dist/frontend/dist/assets/page-B4Qu9WPd.js +0 -2
  131. package/dist/frontend/dist/assets/page-B4Qu9WPd.js.map +0 -1
  132. package/dist/frontend/dist/assets/page-BNJp__R7.js +0 -2
  133. package/dist/frontend/dist/assets/page-BSB8GP79.js +0 -2
  134. package/dist/frontend/dist/assets/page-Bx8QAzic.js +0 -2
  135. package/dist/frontend/dist/assets/page-Bx8QAzic.js.map +0 -1
  136. package/dist/frontend/dist/assets/page-CDSGl6uY.js +0 -2
  137. package/dist/frontend/dist/assets/page-CJLuuiG8.js +0 -2
  138. package/dist/frontend/dist/assets/page-CyFJt2nP.js +0 -2
  139. package/dist/frontend/dist/assets/page-CyFJt2nP.js.map +0 -1
  140. package/dist/frontend/dist/assets/page-D1q6VB02.js +0 -2
  141. package/dist/frontend/dist/assets/page-D3THDsqd.js +0 -5
  142. package/dist/frontend/dist/assets/page-DCxg1lHk.js +0 -2
  143. package/dist/frontend/dist/assets/page-DCxg1lHk.js.map +0 -1
  144. package/dist/frontend/dist/assets/page-DbwQv5n_.js +0 -2
  145. package/dist/frontend/dist/assets/page-DddZ9Yxm.js +0 -2
  146. package/dist/frontend/dist/assets/page-DddZ9Yxm.js.map +0 -1
  147. package/dist/frontend/dist/assets/page-DzoXV-AN.js +0 -2
  148. package/dist/frontend/dist/assets/page-IgGNB4a9.js +0 -2
  149. package/dist/frontend/dist/assets/page-aKPxuWo3.js +0 -8
  150. package/dist/frontend/dist/assets/page-jxC42AIR.js +0 -2
  151. package/dist/frontend/dist/assets/page-jxC42AIR.js.map +0 -1
  152. package/dist/frontend/dist/assets/privacy-BAxopuZI.js +0 -2
  153. package/dist/frontend/dist/assets/query-B6BuIB0M.js +0 -10
  154. package/dist/frontend/dist/assets/query-B6BuIB0M.js.map +0 -1
  155. package/dist/frontend/dist/assets/routing-Cm_oCwum.js +0 -2
package/dist/cli.mjs CHANGED
@@ -6528,10 +6528,10 @@ async function isPortInUse(port) {
6528
6528
  server.listen(port);
6529
6529
  });
6530
6530
  }
6531
- async function isHostReachable(host, port, timeout4 = 5e3) {
6531
+ async function isHostReachable(host, port, timeout = 5e3) {
6532
6532
  return new Promise((resolve9) => {
6533
6533
  const socket = new net.Socket();
6534
- socket.setTimeout(timeout4);
6534
+ socket.setTimeout(timeout);
6535
6535
  socket.once("connect", () => {
6536
6536
  socket.end();
6537
6537
  resolve9(true);
@@ -7008,7 +7008,7 @@ import * as fs11 from "fs";
7008
7008
  import * as path11 from "path";
7009
7009
  import { execFileSync as execFileSync8 } from "child_process";
7010
7010
  import { SemiontProject as SemiontProject4 } from "@semiont/core/node";
7011
- import { baseUrl, EventBus } from "@semiont/core";
7011
+ import { baseUrl } from "@semiont/core";
7012
7012
  import { SemiontApiClient } from "@semiont/api-client";
7013
7013
  var checkBackendService, preflightBackendCheck, backendCheckDescriptor;
7014
7014
  var init_backend_check = __esm({
@@ -7089,7 +7089,7 @@ var init_backend_check = __esm({
7089
7089
  }
7090
7090
  if (status === "unhealthy" || status === "unknown") {
7091
7091
  const localUrl = `http://localhost:${config.port}`;
7092
- const client = new SemiontApiClient({ baseUrl: baseUrl(localUrl), eventBus: new EventBus() });
7092
+ const client = new SemiontApiClient({ baseUrl: baseUrl(localUrl) });
7093
7093
  try {
7094
7094
  const healthData = await client.healthCheck();
7095
7095
  healthy = true;
@@ -8622,7 +8622,7 @@ ssl: {
8622
8622
  // src/platforms/posix/handlers/backend-provision.ts
8623
8623
  import * as fs20 from "fs";
8624
8624
  import * as path17 from "path";
8625
- import * as crypto from "crypto";
8625
+ import * as crypto2 from "crypto";
8626
8626
  import { execFileSync as execFileSync12 } from "child_process";
8627
8627
  import { SemiontProject as SemiontProject6 } from "@semiont/core/node";
8628
8628
  var provisionBackendService, preflightBackendProvision, backendProvisionDescriptor;
@@ -8667,7 +8667,7 @@ var init_backend_provision = __esm({
8667
8667
  }
8668
8668
  let jwtSecret = options.rotateSecret ? void 0 : readSecret("JWT_SECRET");
8669
8669
  if (!jwtSecret) {
8670
- jwtSecret = service.environmentConfig.app?.security?.jwtSecret ?? crypto.randomBytes(32).toString("base64");
8670
+ jwtSecret = service.environmentConfig.app?.security?.jwtSecret ?? crypto2.randomBytes(32).toString("base64");
8671
8671
  writeSecret("JWT_SECRET", jwtSecret);
8672
8672
  printInfo(options.rotateSecret ? "Generated new JWT_SECRET (--rotate-secret)" : "Generated new JWT_SECRET");
8673
8673
  } else {
@@ -8897,10 +8897,10 @@ async function stopJanusGraph(context) {
8897
8897
  printInfo(`Stopping JanusGraph gracefully (PID: ${pid})...`);
8898
8898
  }
8899
8899
  process.kill(pid, "SIGTERM");
8900
- const timeout4 = options.timeout * 1e3;
8900
+ const timeout = options.timeout * 1e3;
8901
8901
  const startTime = Date.now();
8902
8902
  let processRunning = true;
8903
- while (processRunning && Date.now() - startTime < timeout4) {
8903
+ while (processRunning && Date.now() - startTime < timeout) {
8904
8904
  await new Promise((resolve9) => setTimeout(resolve9, 1e3));
8905
8905
  try {
8906
8906
  process.kill(pid, 0);
@@ -9687,10 +9687,10 @@ var init_inference_stop = __esm({
9687
9687
  printInfo(`Stopping Ollama gracefully (PID: ${pid})...`);
9688
9688
  }
9689
9689
  process.kill(pid, "SIGTERM");
9690
- const timeout4 = options.timeout * 1e3;
9690
+ const timeout = options.timeout * 1e3;
9691
9691
  const startTime = Date.now();
9692
9692
  let processRunning = true;
9693
- while (processRunning && Date.now() - startTime < timeout4) {
9693
+ while (processRunning && Date.now() - startTime < timeout) {
9694
9694
  await new Promise((resolve9) => setTimeout(resolve9, 1e3));
9695
9695
  try {
9696
9696
  process.kill(pid, 0);
@@ -10192,7 +10192,7 @@ var init_platform2 = __esm({
10192
10192
 
10193
10193
  // src/platforms/container/handlers/web-check.ts
10194
10194
  import { execFileSync as execFileSync16 } from "child_process";
10195
- import { baseUrl as baseUrl2, EventBus as EventBus2 } from "@semiont/core";
10195
+ import { baseUrl as baseUrl2 } from "@semiont/core";
10196
10196
  import { SemiontApiClient as SemiontApiClient2 } from "@semiont/api-client";
10197
10197
  var checkWebContainer, preflightWebCheck, webCheckDescriptor, webFrontendCheckDescriptor;
10198
10198
  var init_web_check = __esm({
@@ -10248,7 +10248,7 @@ var init_web_check = __esm({
10248
10248
  try {
10249
10249
  if (isBackend) {
10250
10250
  const backendConfig = config;
10251
- const client = new SemiontApiClient2({ baseUrl: baseUrl2(backendConfig.publicURL), eventBus: new EventBus2() });
10251
+ const client = new SemiontApiClient2({ baseUrl: baseUrl2(backendConfig.publicURL) });
10252
10252
  try {
10253
10253
  const healthData = await client.healthCheck();
10254
10254
  health = {
@@ -14420,7 +14420,7 @@ var init_database_stop = __esm({
14420
14420
  init_preflight_utils();
14421
14421
  stopDatabaseContainer = async (context) => {
14422
14422
  const { service, runtime, containerName } = context;
14423
- const { force, timeout: timeout4 } = context.options;
14423
+ const { force, timeout } = context.options;
14424
14424
  if (!service.quiet) {
14425
14425
  printInfo(`Stopping database container: ${containerName}`);
14426
14426
  }
@@ -14459,7 +14459,7 @@ var init_database_stop = __esm({
14459
14459
  execFileSync25(runtime, ["kill", containerName], { stdio: "pipe" });
14460
14460
  } else {
14461
14461
  if (!service.quiet) {
14462
- printInfo(`Gracefully stopping database (timeout: ${timeout4}s)...`);
14462
+ printInfo(`Gracefully stopping database (timeout: ${timeout}s)...`);
14463
14463
  }
14464
14464
  const image = service.getImage();
14465
14465
  if (image.includes("postgres")) {
@@ -14471,26 +14471,26 @@ var init_database_stop = __esm({
14471
14471
  containerName,
14472
14472
  "su",
14473
14473
  "-c",
14474
- `pg_ctl stop -D /var/lib/postgresql/data -m smart -t ${timeout4}`,
14474
+ `pg_ctl stop -D /var/lib/postgresql/data -m smart -t ${timeout}`,
14475
14475
  "postgres"
14476
14476
  ],
14477
- { stdio: "pipe", timeout: (timeout4 + 5) * 1e3 }
14477
+ { stdio: "pipe", timeout: (timeout + 5) * 1e3 }
14478
14478
  );
14479
14479
  } catch {
14480
- execFileSync25(runtime, ["stop", "-t", timeout4.toString(), containerName], { stdio: "pipe" });
14480
+ execFileSync25(runtime, ["stop", "-t", timeout.toString(), containerName], { stdio: "pipe" });
14481
14481
  }
14482
14482
  } else if (image.includes("mysql")) {
14483
14483
  try {
14484
14484
  execFileSync25(
14485
14485
  runtime,
14486
14486
  ["exec", containerName, "mysqladmin", "shutdown"],
14487
- { stdio: "pipe", timeout: timeout4 * 1e3 }
14487
+ { stdio: "pipe", timeout: timeout * 1e3 }
14488
14488
  );
14489
14489
  } catch {
14490
- execFileSync25(runtime, ["stop", "-t", timeout4.toString(), containerName], { stdio: "pipe" });
14490
+ execFileSync25(runtime, ["stop", "-t", timeout.toString(), containerName], { stdio: "pipe" });
14491
14491
  }
14492
14492
  } else {
14493
- execFileSync25(runtime, ["stop", "-t", timeout4.toString(), containerName], { stdio: "pipe" });
14493
+ execFileSync25(runtime, ["stop", "-t", timeout.toString(), containerName], { stdio: "pipe" });
14494
14494
  }
14495
14495
  }
14496
14496
  let stopped = false;
@@ -18194,12 +18194,12 @@ async function fetchTaskLogs(clusterName, taskArn, region, verbose = false) {
18194
18194
  return [];
18195
18195
  }
18196
18196
  }
18197
- async function waitForECSDeployment(clusterName, serviceName, deploymentId, region, timeout4, verbose = false) {
18197
+ async function waitForECSDeployment(clusterName, serviceName, deploymentId, region, timeout, verbose = false) {
18198
18198
  const startTime = Date.now();
18199
18199
  const checkInterval = 5e3;
18200
18200
  let imagePullDetected = false;
18201
18201
  let lastEventCount = 0;
18202
- let effectiveTimeout = timeout4;
18202
+ let effectiveTimeout = timeout;
18203
18203
  let recentStoppedTasks = /* @__PURE__ */ new Set();
18204
18204
  let consecutiveFailures = 0;
18205
18205
  let taskDetails = { new: { total: 0, running: 0, healthy: 0, pending: 0 }, old: { total: 0, running: 0, healthy: 0, pending: 0 } };
@@ -18235,7 +18235,7 @@ async function waitForECSDeployment(clusterName, serviceName, deploymentId, regi
18235
18235
  );
18236
18236
  if (pullEvents.length > 0 && !imagePullDetected) {
18237
18237
  imagePullDetected = true;
18238
- effectiveTimeout = timeout4 + 300;
18238
+ effectiveTimeout = timeout + 300;
18239
18239
  if (!verbose) {
18240
18240
  process.stdout.write("\n");
18241
18241
  }
@@ -18619,11 +18619,11 @@ var init_ecs_update = __esm({
18619
18619
  const newDeployment = deployments.find((d) => d.status === "PRIMARY");
18620
18620
  const deploymentId = newDeployment?.id;
18621
18621
  if (service.config?.wait && deploymentId) {
18622
- const timeout4 = service.config.timeout || 300;
18622
+ const timeout = service.config.timeout || 300;
18623
18623
  if (!service.quiet) {
18624
- printInfo(`Waiting for deployment to complete (timeout: ${timeout4}s)...`);
18624
+ printInfo(`Waiting for deployment to complete (timeout: ${timeout}s)...`);
18625
18625
  }
18626
- await waitForECSDeployment(clusterName, serviceName, deploymentId, region, timeout4, service.verbose);
18626
+ await waitForECSDeployment(clusterName, serviceName, deploymentId, region, timeout, service.verbose);
18627
18627
  }
18628
18628
  return {
18629
18629
  success: true,
@@ -21908,16 +21908,16 @@ var require_timeoutProvider = __commonJS({
21908
21908
  Object.defineProperty(exports, "__esModule", { value: true });
21909
21909
  exports.timeoutProvider = void 0;
21910
21910
  exports.timeoutProvider = {
21911
- setTimeout: function(handler, timeout4) {
21911
+ setTimeout: function(handler, timeout) {
21912
21912
  var args = [];
21913
21913
  for (var _i = 2; _i < arguments.length; _i++) {
21914
21914
  args[_i - 2] = arguments[_i];
21915
21915
  }
21916
21916
  var delegate = exports.timeoutProvider.delegate;
21917
21917
  if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
21918
- return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout4], __read(args)));
21918
+ return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
21919
21919
  }
21920
- return setTimeout.apply(void 0, __spreadArray([handler, timeout4], __read(args)));
21920
+ return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
21921
21921
  },
21922
21922
  clearTimeout: function(handle) {
21923
21923
  var delegate = exports.timeoutProvider.delegate;
@@ -22991,26 +22991,26 @@ var require_BehaviorSubject = __commonJS({
22991
22991
  Object.defineProperty(exports, "__esModule", { value: true });
22992
22992
  exports.BehaviorSubject = void 0;
22993
22993
  var Subject_1 = require_Subject();
22994
- var BehaviorSubject = (function(_super) {
22995
- __extends(BehaviorSubject2, _super);
22996
- function BehaviorSubject2(_value) {
22994
+ var BehaviorSubject2 = (function(_super) {
22995
+ __extends(BehaviorSubject3, _super);
22996
+ function BehaviorSubject3(_value) {
22997
22997
  var _this = _super.call(this) || this;
22998
22998
  _this._value = _value;
22999
22999
  return _this;
23000
23000
  }
23001
- Object.defineProperty(BehaviorSubject2.prototype, "value", {
23001
+ Object.defineProperty(BehaviorSubject3.prototype, "value", {
23002
23002
  get: function() {
23003
23003
  return this.getValue();
23004
23004
  },
23005
23005
  enumerable: false,
23006
23006
  configurable: true
23007
23007
  });
23008
- BehaviorSubject2.prototype._subscribe = function(subscriber) {
23008
+ BehaviorSubject3.prototype._subscribe = function(subscriber) {
23009
23009
  var subscription = _super.prototype._subscribe.call(this, subscriber);
23010
23010
  !subscription.closed && subscriber.next(this._value);
23011
23011
  return subscription;
23012
23012
  };
23013
- BehaviorSubject2.prototype.getValue = function() {
23013
+ BehaviorSubject3.prototype.getValue = function() {
23014
23014
  var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, _value = _a._value;
23015
23015
  if (hasError) {
23016
23016
  throw thrownError;
@@ -23018,12 +23018,12 @@ var require_BehaviorSubject = __commonJS({
23018
23018
  this._throwIfClosed();
23019
23019
  return _value;
23020
23020
  };
23021
- BehaviorSubject2.prototype.next = function(value) {
23021
+ BehaviorSubject3.prototype.next = function(value) {
23022
23022
  _super.prototype.next.call(this, this._value = value);
23023
23023
  };
23024
- return BehaviorSubject2;
23024
+ return BehaviorSubject3;
23025
23025
  })(Subject_1.Subject);
23026
- exports.BehaviorSubject = BehaviorSubject;
23026
+ exports.BehaviorSubject = BehaviorSubject2;
23027
23027
  }
23028
23028
  });
23029
23029
 
@@ -23268,16 +23268,16 @@ var require_intervalProvider = __commonJS({
23268
23268
  Object.defineProperty(exports, "__esModule", { value: true });
23269
23269
  exports.intervalProvider = void 0;
23270
23270
  exports.intervalProvider = {
23271
- setInterval: function(handler, timeout4) {
23271
+ setInterval: function(handler, timeout) {
23272
23272
  var args = [];
23273
23273
  for (var _i = 2; _i < arguments.length; _i++) {
23274
23274
  args[_i - 2] = arguments[_i];
23275
23275
  }
23276
23276
  var delegate = exports.intervalProvider.delegate;
23277
23277
  if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
23278
- return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout4], __read(args)));
23278
+ return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
23279
23279
  }
23280
- return setInterval.apply(void 0, __spreadArray([handler, timeout4], __read(args)));
23280
+ return setInterval.apply(void 0, __spreadArray([handler, timeout], __read(args)));
23281
23281
  },
23282
23282
  clearInterval: function(handle) {
23283
23283
  var delegate = exports.intervalProvider.delegate;
@@ -25338,7 +25338,7 @@ var require_timeout = __commonJS({
25338
25338
  this.info = info;
25339
25339
  };
25340
25340
  });
25341
- function timeout4(config, schedulerArg) {
25341
+ function timeout(config, schedulerArg) {
25342
25342
  var _a = isDate_1.isValidDate(config) ? { first: config } : typeof config === "number" ? { each: config } : config, first = _a.first, each = _a.each, _b = _a.with, _with = _b === void 0 ? timeoutErrorFactory : _b, _c = _a.scheduler, scheduler = _c === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : async_1.asyncScheduler : _c, _d = _a.meta, meta = _d === void 0 ? null : _d;
25343
25343
  if (first == null && each == null) {
25344
25344
  throw new TypeError("No timeout provided.");
@@ -25376,7 +25376,7 @@ var require_timeout = __commonJS({
25376
25376
  !seen && startTimer(first != null ? typeof first === "number" ? first : +first - scheduler.now() : each);
25377
25377
  });
25378
25378
  }
25379
- exports.timeout = timeout4;
25379
+ exports.timeout = timeout;
25380
25380
  function timeoutErrorFactory(info) {
25381
25381
  throw new exports.TimeoutError(info);
25382
25382
  }
@@ -27612,7 +27612,7 @@ var require_take = __commonJS({
27612
27612
  var empty_1 = require_empty();
27613
27613
  var lift_1 = require_lift();
27614
27614
  var OperatorSubscriber_1 = require_OperatorSubscriber();
27615
- function take4(count) {
27615
+ function take(count) {
27616
27616
  return count <= 0 ? function() {
27617
27617
  return empty_1.EMPTY;
27618
27618
  } : lift_1.operate(function(source, subscriber) {
@@ -27627,7 +27627,7 @@ var require_take = __commonJS({
27627
27627
  }));
27628
27628
  });
27629
27629
  }
27630
- exports.take = take4;
27630
+ exports.take = take;
27631
27631
  }
27632
27632
  });
27633
27633
 
@@ -31683,7 +31683,7 @@ var require_package = __commonJS({
31683
31683
  "package.json"(exports, module) {
31684
31684
  module.exports = {
31685
31685
  name: "@semiont/cli",
31686
- version: "0.4.19",
31686
+ version: "0.4.21",
31687
31687
  description: "Semiont CLI - Unified environment management tool",
31688
31688
  _comment: "AWS SDK dependencies (@aws-sdk/*) are only used by platforms/aws",
31689
31689
  type: "module",
@@ -31730,12 +31730,12 @@ var require_package = __commonJS({
31730
31730
  "test:watch:unit": "vitest --watch --config vitest.config.unit.ts"
31731
31731
  },
31732
31732
  dependencies: {
31733
- "@semiont/api-client": "0.4.19",
31734
- "@semiont/content": "0.4.19",
31735
- "@semiont/core": "0.4.19",
31736
- "@semiont/event-sourcing": "0.4.19",
31737
- "@semiont/graph": "0.4.19",
31738
- "@semiont/make-meaning": "0.4.19",
31733
+ "@semiont/api-client": "0.4.21",
31734
+ "@semiont/content": "0.4.21",
31735
+ "@semiont/core": "0.4.21",
31736
+ "@semiont/event-sourcing": "0.4.21",
31737
+ "@semiont/graph": "0.4.21",
31738
+ "@semiont/make-meaning": "0.4.21",
31739
31739
  arg: "^5.0.2",
31740
31740
  argon2: "^0.44.0",
31741
31741
  express: "^5.2.1",
@@ -32784,7 +32784,7 @@ init_command_definition();
32784
32784
  init_base_options_schema();
32785
32785
  init_cli_logger();
32786
32786
  init_config_loader();
32787
- import * as crypto2 from "crypto";
32787
+ import * as crypto3 from "crypto";
32788
32788
  import * as argon2 from "argon2";
32789
32789
  import * as path30 from "path";
32790
32790
  import { createRequire as createRequire2 } from "module";
@@ -32846,7 +32846,7 @@ function extractDomain(email) {
32846
32846
  return parts[1];
32847
32847
  }
32848
32848
  function generatePassword() {
32849
- return crypto2.randomBytes(12).toString("base64");
32849
+ return crypto3.randomBytes(12).toString("base64");
32850
32850
  }
32851
32851
  async function useradd(options) {
32852
32852
  const startTime = Date.now();
@@ -33057,7 +33057,7 @@ init_config_loader();
33057
33057
  import * as fs38 from "fs";
33058
33058
  import * as path31 from "path";
33059
33059
  import { SemiontProject as SemiontProject11 } from "@semiont/core/node";
33060
- import { EventBus as EventBus3 } from "@semiont/core";
33060
+ import { EventBus } from "@semiont/core";
33061
33061
  import { createEventStore } from "@semiont/event-sourcing";
33062
33062
  import { WorkingTreeStore } from "@semiont/content";
33063
33063
  import { exportBackup } from "@semiont/make-meaning";
@@ -33086,7 +33086,7 @@ async function runBackup(options) {
33086
33086
  }
33087
33087
  const project = new SemiontProject11(projectRoot);
33088
33088
  const logger = createCliLogger(options.verbose ?? false);
33089
- const eventStore = createEventStore(project, new EventBus3(), logger);
33089
+ const eventStore = createEventStore(project, new EventBus(), logger);
33090
33090
  const contentStore = new WorkingTreeStore(
33091
33091
  project,
33092
33092
  logger.child({ component: "content-store" })
@@ -33140,7 +33140,7 @@ init_config_loader();
33140
33140
  import * as fs39 from "fs";
33141
33141
  import * as path32 from "path";
33142
33142
  import { SemiontProject as SemiontProject12 } from "@semiont/core/node";
33143
- import { EventBus as EventBus4 } from "@semiont/core";
33143
+ import { EventBus as EventBus2 } from "@semiont/core";
33144
33144
  import { createEventStore as createEventStore2 } from "@semiont/event-sourcing";
33145
33145
  import { importBackup, Stower, createKnowledgeBase } from "@semiont/make-meaning";
33146
33146
  function createCliLogger2(verbose) {
@@ -33212,7 +33212,7 @@ async function runRestore(options) {
33212
33212
  if (!options.quiet) {
33213
33213
  printInfo(`Restoring from ${filePath}`);
33214
33214
  }
33215
- const eventBus = new EventBus4();
33215
+ const eventBus = new EventBus2();
33216
33216
  const eventStore = createEventStore2(project, eventBus, logger);
33217
33217
  const kb = await createKnowledgeBase(eventStore, project, createNoopGraphDatabase(), eventBus, logger);
33218
33218
  const stower = new Stower(kb, eventBus, logger.child({ component: "stower" }));
@@ -33414,7 +33414,7 @@ init_config_loader();
33414
33414
  import * as fs41 from "fs";
33415
33415
  import * as path34 from "path";
33416
33416
  import { SemiontProject as SemiontProject13 } from "@semiont/core/node";
33417
- import { EventBus as EventBus5 } from "@semiont/core";
33417
+ import { EventBus as EventBus3 } from "@semiont/core";
33418
33418
  import { createEventStore as createEventStore3 } from "@semiont/event-sourcing";
33419
33419
  import { WorkingTreeStore as WorkingTreeStore2 } from "@semiont/content";
33420
33420
  import { exportLinkedData } from "@semiont/make-meaning";
@@ -33445,7 +33445,7 @@ async function runExport(options) {
33445
33445
  }
33446
33446
  const project = new SemiontProject13(projectRoot);
33447
33447
  const logger = createCliLogger3(options.verbose ?? false);
33448
- const eventStore = createEventStore3(project, new EventBus5(), logger);
33448
+ const eventStore = createEventStore3(project, new EventBus3(), logger);
33449
33449
  const contentStore = new WorkingTreeStore2(
33450
33450
  project,
33451
33451
  logger.child({ component: "content-store" })
@@ -33514,7 +33514,7 @@ init_config_loader();
33514
33514
  import * as fs42 from "fs";
33515
33515
  import * as path35 from "path";
33516
33516
  import { SemiontProject as SemiontProject14 } from "@semiont/core/node";
33517
- import { EventBus as EventBus6 } from "@semiont/core";
33517
+ import { EventBus as EventBus4 } from "@semiont/core";
33518
33518
  import { createEventStore as createEventStore4 } from "@semiont/event-sourcing";
33519
33519
  import { importLinkedData, Stower as Stower2, createKnowledgeBase as createKnowledgeBase2 } from "@semiont/make-meaning";
33520
33520
  function createCliLogger4(verbose) {
@@ -33589,7 +33589,7 @@ async function runImport(options) {
33589
33589
  printInfo(`Importing JSON-LD archive from ${filePath}`);
33590
33590
  printInfo(`User identity: ${userId}`);
33591
33591
  }
33592
- const eventBus = new EventBus6();
33592
+ const eventBus = new EventBus4();
33593
33593
  const eventStore = createEventStore4(project, eventBus, logger);
33594
33594
  const kb = await createKnowledgeBase2(eventStore, project, createNoopGraphDatabase2(), eventBus, logger);
33595
33595
  const stower = new Stower2(kb, eventBus, logger.child({ component: "stower" }));
@@ -34245,7 +34245,7 @@ init_cli_logger();
34245
34245
  init_config_loader();
34246
34246
  init_preflight_utils();
34247
34247
  import { SemiontProject as SemiontProject16 } from "@semiont/core/node";
34248
- import { EventBus as EventBus7 } from "@semiont/core";
34248
+ import { EventBus as EventBus5 } from "@semiont/core";
34249
34249
  import { createEventStore as createEventStore5 } from "@semiont/event-sourcing";
34250
34250
  import { Stower as Stower3, createKnowledgeBase as createKnowledgeBase3 } from "@semiont/make-meaning";
34251
34251
  function createCliLogger5(verbose) {
@@ -34325,7 +34325,7 @@ async function runMv(options) {
34325
34325
  const gitCheck = checkGitAvailable();
34326
34326
  if (!gitCheck.pass) throw new Error(gitCheck.message);
34327
34327
  }
34328
- const eventBus = new EventBus7();
34328
+ const eventBus = new EventBus5();
34329
34329
  const eventStore = createEventStore5(project, eventBus, logger);
34330
34330
  const kb = await createKnowledgeBase3(eventStore, project, createNoopGraphDatabase3(), eventBus, logger);
34331
34331
  const stower = new Stower3(kb, eventBus, logger.child({ component: "stower" }));
@@ -34387,7 +34387,7 @@ var mvCmd = new CommandBuilder().name("mv").description("Move (rename) a tracked
34387
34387
 
34388
34388
  // src/core/commands/yield.ts
34389
34389
  init_zod();
34390
- var import_rxjs = __toESM(require_cjs(), 1);
34390
+ var import_rxjs2 = __toESM(require_cjs(), 1);
34391
34391
  var import_operators = __toESM(require_operators(), 1);
34392
34392
  init_command_definition();
34393
34393
  init_base_options_schema();
@@ -34396,8 +34396,10 @@ init_config_loader();
34396
34396
  import * as path38 from "path";
34397
34397
  import { promises as nodeFs } from "fs";
34398
34398
  import { resourceId as toResourceId, annotationId as toAnnotationId } from "@semiont/core";
34399
+ import { createGatherVM, createYieldVM } from "@semiont/api-client";
34399
34400
 
34400
34401
  // src/core/api-client-factory.ts
34402
+ var import_rxjs = __toESM(require_cjs(), 1);
34401
34403
  import * as fs45 from "fs";
34402
34404
  import * as path37 from "path";
34403
34405
  import * as os6 from "os";
@@ -34405,8 +34407,7 @@ import { SemiontApiClient as SemiontApiClient3 } from "@semiont/api-client";
34405
34407
  import {
34406
34408
  email as toEmail,
34407
34409
  accessToken as toAccessToken,
34408
- baseUrl as toBaseUrl,
34409
- EventBus as EventBus8
34410
+ baseUrl as toBaseUrl
34410
34411
  } from "@semiont/core";
34411
34412
  var TOKEN_CACHE_TTL_MS = 864e5;
34412
34413
  function authStoreDir() {
@@ -34436,7 +34437,7 @@ function isTokenValid(cache) {
34436
34437
  return Date.now() < cachedAt + TOKEN_CACHE_TTL_MS;
34437
34438
  }
34438
34439
  async function acquireToken(rawBusUrl, emailStr, passwordStr) {
34439
- const semiont = new SemiontApiClient3({ baseUrl: toBaseUrl(rawBusUrl), eventBus: new EventBus8() });
34440
+ const semiont = new SemiontApiClient3({ baseUrl: toBaseUrl(rawBusUrl) });
34440
34441
  const authResult = await semiont.authenticatePassword(toEmail(emailStr), passwordStr);
34441
34442
  const cache = {
34442
34443
  bus: rawBusUrl,
@@ -34455,8 +34456,13 @@ function loadCachedClient(rawBusUrl) {
34455
34456
  Run: semiont login --bus ${rawBusUrl}`
34456
34457
  );
34457
34458
  }
34458
- const semiont = new SemiontApiClient3({ baseUrl: toBaseUrl(rawBusUrl), eventBus: new EventBus8() });
34459
- return { semiont, token: toAccessToken(cached.token) };
34459
+ const token = toAccessToken(cached.token);
34460
+ const token$ = new import_rxjs.BehaviorSubject(token);
34461
+ const semiont = new SemiontApiClient3({
34462
+ baseUrl: toBaseUrl(rawBusUrl),
34463
+ token$
34464
+ });
34465
+ return { semiont, token };
34460
34466
  }
34461
34467
  function resolveBusUrl(busFlag) {
34462
34468
  const url = busFlag ?? process.env.SEMIONT_BUS;
@@ -34523,21 +34529,28 @@ var YieldOptionsSchema = ApiOptionsSchema.extend({
34523
34529
  async function runDelegate(semiont, _token, options) {
34524
34530
  const rawResourceId = options.resource;
34525
34531
  const rawAnnotationId = options.annotation;
34526
- const resourceId = toResourceId(rawResourceId);
34527
- const annotationId = toAnnotationId(rawAnnotationId);
34528
- const gatherCompletion = await (0, import_rxjs.firstValueFrom)(
34529
- semiont.gather.annotation(annotationId, resourceId, { contextWindow: options.contextWindow }).pipe(
34530
- (0, import_operators.filter)((e) => "response" in e),
34531
- (0, import_operators.take)(1),
34532
- (0, import_operators.timeout)(6e4)
34533
- )
34534
- );
34535
- const context = gatherCompletion.response?.context;
34536
- if (!context) throw new Error("No context returned from gatherAnnotation \u2014 cannot generate");
34532
+ const rId = toResourceId(rawResourceId);
34533
+ const aId = toAnnotationId(rawAnnotationId);
34534
+ const gatherVM = createGatherVM(semiont, rId);
34535
+ let context;
34536
+ try {
34537
+ semiont.emit("gather:requested", {
34538
+ correlationId: crypto.randomUUID(),
34539
+ annotationId: aId,
34540
+ resourceId: rId,
34541
+ options: { contextWindow: options.contextWindow }
34542
+ });
34543
+ context = await (0, import_rxjs2.firstValueFrom)(
34544
+ gatherVM.context$.pipe((0, import_operators.filter)((c) => c !== null))
34545
+ );
34546
+ } finally {
34547
+ gatherVM.dispose();
34548
+ }
34537
34549
  if (!options.quiet) process.stderr.write(`Generating from annotation ${rawAnnotationId}...
34538
34550
  `);
34539
- const result = await new Promise((resolve9, reject) => {
34540
- semiont.yield.fromAnnotation(resourceId, annotationId, {
34551
+ const yieldVM = createYieldVM(semiont, rId, options.language ?? "en");
34552
+ try {
34553
+ yieldVM.generate(aId, {
34541
34554
  title: options.title ?? rawAnnotationId,
34542
34555
  storageUri: options.storageUri,
34543
34556
  context,
@@ -34545,17 +34558,27 @@ async function runDelegate(semiont, _token, options) {
34545
34558
  language: options.language,
34546
34559
  temperature: options.temperature,
34547
34560
  maxTokens: options.maxTokens
34548
- }).subscribe({
34549
- next: (progress) => {
34550
- if (progress.resourceId) {
34551
- resolve9({ resourceId: progress.resourceId, resourceName: progress.resourceName });
34552
- }
34553
- },
34554
- error: (err) => reject(err),
34555
- complete: () => resolve9({})
34556
34561
  });
34557
- });
34558
- return result;
34562
+ return await new Promise((resolve9, reject) => {
34563
+ const completeUnsub = semiont.on("job:complete", (event) => {
34564
+ if (event.jobType !== "generation") return;
34565
+ cleanup();
34566
+ const r = event.result ?? {};
34567
+ resolve9({ resourceId: r.resourceId, resourceName: r.resourceName });
34568
+ });
34569
+ const failUnsub = semiont.on("job:fail", (event) => {
34570
+ if (event.jobType !== "generation") return;
34571
+ cleanup();
34572
+ reject(new Error(event.error ?? "Generation failed"));
34573
+ });
34574
+ function cleanup() {
34575
+ completeUnsub();
34576
+ failUnsub();
34577
+ }
34578
+ });
34579
+ } finally {
34580
+ yieldVM.dispose();
34581
+ }
34559
34582
  }
34560
34583
  async function runYield(options) {
34561
34584
  const startTime = Date.now();
@@ -34688,6 +34711,7 @@ init_command_definition();
34688
34711
  init_base_options_schema();
34689
34712
  init_cli_logger();
34690
34713
  import { resourceId as toResourceId2 } from "@semiont/core";
34714
+ import { createMarkVM } from "@semiont/api-client";
34691
34715
  var MOTIVATIONS = ["highlighting", "commenting", "tagging", "assessing", "linking"];
34692
34716
  var CONTEXT_WINDOW = 32;
34693
34717
  var MarkOptionsSchema = ApiOptionsSchema.extend({
@@ -34719,7 +34743,7 @@ var MarkOptionsSchema = ApiOptionsSchema.extend({
34719
34743
  // ── Delegate mode: shared ──────────────────────────────────────────────
34720
34744
  instructions: external_exports.string().optional(),
34721
34745
  density: external_exports.coerce.number().int().optional(),
34722
- tone: external_exports.string().optional(),
34746
+ tone: external_exports.enum(["scholarly", "explanatory", "conversational", "technical", "analytical", "critical", "balanced", "constructive"]).optional(),
34723
34747
  // ── Delegate mode: linking ─────────────────────────────────────────────
34724
34748
  entityType: external_exports.array(external_exports.string()).default([]),
34725
34749
  includeDescriptive: external_exports.boolean().default(false),
@@ -34824,32 +34848,49 @@ function buildBody(options) {
34824
34848
  }
34825
34849
  async function runDelegate2(semiont, options) {
34826
34850
  const rawResourceId = options.resourceIdArr[0];
34827
- const resourceId = toResourceId2(rawResourceId);
34851
+ const rId = toResourceId2(rawResourceId);
34828
34852
  const { motivation, instructions, density, tone, entityType, includeDescriptive, schemaId, category } = options;
34829
34853
  if (!options.quiet) process.stderr.write(`Annotating ${motivation} on ${rawResourceId}...
34830
34854
  `);
34831
- const result = await new Promise((resolve9, reject) => {
34832
- semiont.mark.assist(resourceId, motivation, {
34833
- instructions,
34834
- density,
34835
- tone,
34836
- entityTypes: entityType,
34837
- includeDescriptiveReferences: includeDescriptive,
34838
- schemaId,
34839
- categories: category
34840
- }).subscribe({
34841
- next: (progress) => {
34842
- if ("foundCount" in progress) {
34843
- resolve9({ createdCount: progress.createdCount ?? 0 });
34844
- }
34845
- },
34846
- error: (err) => reject(err),
34847
- complete: () => resolve9({ createdCount: 0 })
34855
+ const vm = createMarkVM(semiont, rId);
34856
+ try {
34857
+ semiont.emit("mark:assist-request", {
34858
+ motivation,
34859
+ options: {
34860
+ instructions,
34861
+ density,
34862
+ tone,
34863
+ entityTypes: entityType,
34864
+ includeDescriptiveReferences: includeDescriptive,
34865
+ schemaId,
34866
+ categories: category
34867
+ }
34848
34868
  });
34849
- });
34850
- if (!options.quiet) process.stderr.write(`\u2713 ${result.createdCount} annotations created
34869
+ const result = await new Promise((resolve9, reject) => {
34870
+ const isAnnotationJob = (jt) => jt !== "generation";
34871
+ const completeUnsub = semiont.on("job:complete", (event) => {
34872
+ if (!isAnnotationJob(event.jobType)) return;
34873
+ cleanup();
34874
+ const r = event.result ?? {};
34875
+ const createdCount = typeof r.highlightsCreated === "number" && r.highlightsCreated || typeof r.commentsCreated === "number" && r.commentsCreated || typeof r.assessmentsCreated === "number" && r.assessmentsCreated || typeof r.tagsCreated === "number" && r.tagsCreated || typeof r.totalEmitted === "number" && r.totalEmitted || 0;
34876
+ resolve9({ createdCount });
34877
+ });
34878
+ const failUnsub = semiont.on("job:fail", (event) => {
34879
+ if (!isAnnotationJob(event.jobType)) return;
34880
+ cleanup();
34881
+ reject(new Error(event.error ?? "Annotation failed"));
34882
+ });
34883
+ function cleanup() {
34884
+ completeUnsub();
34885
+ failUnsub();
34886
+ }
34887
+ });
34888
+ if (!options.quiet) process.stderr.write(`\u2713 ${result.createdCount} annotations created
34851
34889
  `);
34852
- return { motivation, resourceId: rawResourceId, createdCount: result.createdCount };
34890
+ return { motivation, resourceId: rawResourceId, createdCount: result.createdCount };
34891
+ } finally {
34892
+ vm.dispose();
34893
+ }
34853
34894
  }
34854
34895
  async function runMark(options) {
34855
34896
  const startTime = Date.now();
@@ -35019,11 +35060,12 @@ var markCmd = new CommandBuilder().name("mark").description(
35019
35060
 
35020
35061
  // src/core/commands/gather.ts
35021
35062
  init_zod();
35022
- var import_rxjs2 = __toESM(require_cjs(), 1);
35063
+ var import_rxjs3 = __toESM(require_cjs(), 1);
35023
35064
  var import_operators2 = __toESM(require_operators(), 1);
35024
35065
  init_command_definition();
35025
35066
  init_base_options_schema();
35026
35067
  import { resourceId as toResourceId3, annotationId as toAnnotationId2 } from "@semiont/core";
35068
+ import { createGatherVM as createGatherVM2 } from "@semiont/api-client";
35027
35069
  var GatherOptionsSchema = ApiOptionsSchema.extend({
35028
35070
  args: external_exports.array(external_exports.string()).min(2, "Usage: semiont gather resource <resourceId> | gather annotation <resourceId> <annotationId>"),
35029
35071
  depth: external_exports.coerce.number().int().min(1).max(3).default(2),
@@ -35045,16 +35087,22 @@ async function runGather(options) {
35045
35087
  if (!rawAnnotationId) {
35046
35088
  throw new Error("Usage: semiont gather annotation <resourceId> <annotationId>");
35047
35089
  }
35048
- const resourceId = toResourceId3(rawResourceId);
35049
- const annotationId = toAnnotationId2(rawAnnotationId);
35050
- const completion = await (0, import_rxjs2.firstValueFrom)(
35051
- semiont.gather.annotation(annotationId, resourceId, { contextWindow: options.contextWindow }).pipe(
35052
- (0, import_operators2.filter)((e) => "response" in e),
35053
- (0, import_operators2.take)(1),
35054
- (0, import_operators2.timeout)(6e4)
35055
- )
35056
- );
35057
- result = completion.response;
35090
+ const rid = toResourceId3(rawResourceId);
35091
+ const aid = toAnnotationId2(rawAnnotationId);
35092
+ const vm = createGatherVM2(semiont, rid);
35093
+ try {
35094
+ semiont.emit("gather:requested", {
35095
+ correlationId: crypto.randomUUID(),
35096
+ annotationId: aid,
35097
+ resourceId: rid,
35098
+ options: { contextWindow: options.contextWindow }
35099
+ });
35100
+ result = await (0, import_rxjs3.firstValueFrom)(
35101
+ vm.context$.pipe((0, import_operators2.filter)((c) => c !== null))
35102
+ );
35103
+ } finally {
35104
+ vm.dispose();
35105
+ }
35058
35106
  } else {
35059
35107
  throw new Error(`Unknown subcommand: ${subcommand}. Use 'resource' or 'annotation'.`);
35060
35108
  }
@@ -35095,11 +35143,12 @@ var gatherCmd = new CommandBuilder().name("gather").description("Fetch LLM-optim
35095
35143
 
35096
35144
  // src/core/commands/match.ts
35097
35145
  init_zod();
35098
- var import_rxjs3 = __toESM(require_cjs(), 1);
35146
+ var import_rxjs4 = __toESM(require_cjs(), 1);
35099
35147
  var import_operators3 = __toESM(require_operators(), 1);
35100
35148
  init_command_definition();
35101
35149
  init_base_options_schema();
35102
35150
  import { resourceId as toResourceId4, annotationId as toAnnotationId3 } from "@semiont/core";
35151
+ import { createGatherVM as createGatherVM3 } from "@semiont/api-client";
35103
35152
  var MatchOptionsSchema = ApiOptionsSchema.extend({
35104
35153
  args: external_exports.array(external_exports.string()).min(2, "Usage: semiont match <resourceId> <annotationId>").max(2),
35105
35154
  contextWindow: external_exports.coerce.number().int().min(100).max(5e3).default(1e3),
@@ -35114,23 +35163,29 @@ async function runMatch(options) {
35114
35163
  const annotationId = toAnnotationId3(rawAnnotationId);
35115
35164
  const rawBusUrl = resolveBusUrl(options.bus);
35116
35165
  const { semiont } = loadCachedClient(rawBusUrl);
35117
- const gatherCompletion = await (0, import_rxjs3.firstValueFrom)(
35118
- semiont.gather.annotation(annotationId, resourceId, { contextWindow: options.contextWindow }).pipe(
35119
- (0, import_operators3.filter)((e) => "response" in e),
35120
- (0, import_operators3.take)(1),
35121
- (0, import_operators3.timeout)(6e4)
35122
- )
35123
- );
35124
- let context = gatherCompletion.response?.context;
35125
- if (!context) throw new Error("No context returned from gather");
35166
+ const gatherVM = createGatherVM3(semiont, resourceId);
35167
+ let context;
35168
+ try {
35169
+ semiont.emit("gather:requested", {
35170
+ correlationId: crypto.randomUUID(),
35171
+ annotationId,
35172
+ resourceId,
35173
+ options: { contextWindow: options.contextWindow }
35174
+ });
35175
+ context = await (0, import_rxjs4.firstValueFrom)(
35176
+ gatherVM.context$.pipe((0, import_operators3.filter)((c) => c !== null))
35177
+ );
35178
+ } finally {
35179
+ gatherVM.dispose();
35180
+ }
35126
35181
  if (options.userHint) {
35127
35182
  context = { ...context, userHint: options.userHint };
35128
35183
  }
35129
- const searchResult = await (0, import_rxjs3.firstValueFrom)(
35184
+ const searchResult = await (0, import_rxjs4.firstValueFrom)(
35130
35185
  semiont.match.search(resourceId, rawAnnotationId, context, {
35131
35186
  limit: options.limit,
35132
35187
  useSemanticScoring: !options.noSemantic
35133
- }).pipe((0, import_operators3.take)(1), (0, import_operators3.timeout)(6e4))
35188
+ })
35134
35189
  );
35135
35190
  const results = searchResult.response;
35136
35191
  process.stdout.write(JSON.stringify(results, null, 2));
@@ -35454,7 +35509,8 @@ var browseCmd = new CommandBuilder().name("browse").description(
35454
35509
  init_zod();
35455
35510
  init_command_definition();
35456
35511
  init_base_options_schema();
35457
- import { resourceId as toResourceId7, EventBus as EventBus9 } from "@semiont/core";
35512
+ import { resourceId as toResourceId7 } from "@semiont/core";
35513
+ import { createActorVM } from "@semiont/api-client";
35458
35514
  var ListenOptionsSchema = ApiOptionsSchema.extend({
35459
35515
  args: external_exports.array(external_exports.string()).default([])
35460
35516
  }).superRefine((val, ctx) => {
@@ -35466,46 +35522,53 @@ var ListenOptionsSchema = ApiOptionsSchema.extend({
35466
35522
  ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: "Usage: semiont listen resource <resourceId>" });
35467
35523
  }
35468
35524
  });
35525
+ var ALL_EVENT_TYPES = [
35526
+ "yield:created",
35527
+ "yield:cloned",
35528
+ "yield:updated",
35529
+ "yield:moved",
35530
+ "yield:representation-added",
35531
+ "yield:representation-removed",
35532
+ "mark:added",
35533
+ "mark:removed",
35534
+ "mark:body-updated",
35535
+ "mark:archived",
35536
+ "mark:unarchived",
35537
+ "mark:entity-tag-added",
35538
+ "mark:entity-tag-removed",
35539
+ "mark:entity-type-added",
35540
+ "job:started",
35541
+ "job:progress",
35542
+ "job:completed",
35543
+ "job:failed"
35544
+ ];
35469
35545
  async function runListen(options) {
35470
35546
  const startTime = Date.now();
35471
35547
  const rawBusUrl = resolveBusUrl(options.bus);
35472
- const { semiont, token } = loadCachedClient(rawBusUrl);
35548
+ const { token } = loadCachedClient(rawBusUrl);
35473
35549
  const [subcommand, rawResourceId] = options.args;
35474
35550
  const isResourceScoped = subcommand === "resource";
35475
- const eventBus = new EventBus9();
35476
35551
  let eventCount = 0;
35477
- const allEventTypes = [
35478
- "yield:created",
35479
- "yield:cloned",
35480
- "yield:updated",
35481
- "yield:moved",
35482
- "yield:representation-added",
35483
- "yield:representation-removed",
35484
- "mark:added",
35485
- "mark:removed",
35486
- "mark:body-updated",
35487
- "mark:archived",
35488
- "mark:unarchived",
35489
- "mark:entity-tag-added",
35490
- "mark:entity-tag-removed",
35491
- "mark:entity-type-added",
35492
- "job:started",
35493
- "job:progress",
35494
- "job:completed",
35495
- "job:failed"
35496
- ];
35497
- for (const eventType of allEventTypes) {
35498
- eventBus.get(eventType).subscribe((event) => {
35552
+ const label = isResourceScoped ? `Listening for events on resource ${rawResourceId}` : "Listening for global events";
35553
+ if (!options.quiet) process.stderr.write(label + " (Ctrl-C to stop)\n");
35554
+ const actor = createActorVM({
35555
+ baseUrl: rawBusUrl,
35556
+ token,
35557
+ channels: isResourceScoped ? [] : [...ALL_EVENT_TYPES]
35558
+ });
35559
+ if (isResourceScoped) {
35560
+ actor.addChannels([...ALL_EVENT_TYPES], toResourceId7(rawResourceId));
35561
+ }
35562
+ for (const eventType of ALL_EVENT_TYPES) {
35563
+ actor.on$(eventType).subscribe((event) => {
35499
35564
  eventCount++;
35500
35565
  process.stdout.write(JSON.stringify(event) + "\n");
35501
35566
  });
35502
35567
  }
35503
- const label = isResourceScoped ? `Listening for events on resource ${rawResourceId}` : "Listening for global events";
35504
- if (!options.quiet) process.stderr.write(label + " (Ctrl-C to stop)\n");
35505
- const stream = isResourceScoped ? semiont.sse.resourceEvents(toResourceId7(rawResourceId), { auth: token, eventBus }) : semiont.sse.globalEvents({ auth: token, eventBus });
35568
+ actor.start();
35506
35569
  await new Promise((resolve9) => {
35507
35570
  const cleanup = () => {
35508
- stream.close();
35571
+ actor.dispose();
35509
35572
  resolve9();
35510
35573
  };
35511
35574
  process.once("SIGINT", cleanup);
@@ -35517,22 +35580,13 @@ async function runListen(options) {
35517
35580
  timestamp: /* @__PURE__ */ new Date(),
35518
35581
  duration: Date.now() - startTime,
35519
35582
  summary: { succeeded: eventCount, failed: 0, total: eventCount, warnings: 0 },
35520
- executionContext: { user: process.env.USER || "unknown", workingDirectory: process.cwd(), dryRun: options.dryRun },
35521
- results: [{ entity: rawResourceId ?? "global", platform: "posix", success: true, duration: Date.now() - startTime }]
35583
+ executionContext: { user: process.env.USER || "unknown", workingDirectory: process.cwd(), dryRun: options.dryRun }
35522
35584
  };
35523
35585
  }
35524
- var listenCmd = new CommandBuilder().name("listen").description(
35525
- "Open a persistent SSE connection and stream domain events as NDJSON to stdout. Without a subcommand, streams global system events. With `resource <resourceId>`, streams events scoped to that resource. Runs until Ctrl-C or the server closes the connection."
35526
- ).requiresEnvironment(true).requiresServices(true).examples(
35586
+ var listenCmd = new CommandBuilder().name("listen").description("Subscribe to real-time domain events from the knowledge base").requiresEnvironment(true).requiresServices(true).examples(
35527
35587
  "semiont listen",
35528
- "semiont listen resource <resourceId>",
35529
- "semiont listen resource <resourceId> | jq .type",
35530
- "semiont listen | grep entitytype"
35531
- ).args({
35532
- ...withApiArgs({}, {}),
35533
- restAs: "args",
35534
- aliases: {}
35535
- }).schema(ListenOptionsSchema).handler(runListen).build();
35588
+ "semiont listen resource <resourceId>"
35589
+ ).args({ ...withApiArgs({}, {}), restAs: "args", aliases: {} }).schema(ListenOptionsSchema).handler(runListen).build();
35536
35590
 
35537
35591
  // src/core/commands/login.ts
35538
35592
  init_zod();
@@ -36770,7 +36824,7 @@ async function generateGlobalHelp() {
36770
36824
  }
36771
36825
 
36772
36826
  // src/cli.ts
36773
- var VERSION = "0.4.19";
36827
+ var VERSION = "0.4.21";
36774
36828
  function printVersion() {
36775
36829
  console.log(`Semiont CLI v${VERSION}`);
36776
36830
  }