@codeagentswarm/cas-cloud 0.0.1 → 0.0.2

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/cas.js +38 -14
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -161,8 +161,8 @@ new updater once through `npx` from the same environment as the updater service:
161
161
 
162
162
  ```sh
163
163
  CAS_CLI_INSTALL_ROOT="$HOME/.local/share/codeagentswarm-cloud" \
164
- CAS_CLI_UPDATE_SPEC="@codeagentswarm/cas-cloud@0.0.1" \
165
- npx --yes "@codeagentswarm/cas-cloud@0.0.1" update
164
+ CAS_CLI_UPDATE_SPEC="@codeagentswarm/cas-cloud@0.0.2" \
165
+ npx --yes "@codeagentswarm/cas-cloud@0.0.2" update
166
166
  ```
167
167
 
168
168
  Carry over any non-secret `CAS_CLI_STATE`, `CAS_CLI_SYSTEMD_SCOPE` and
package/dist/cas.js CHANGED
@@ -19730,13 +19730,6 @@ var require_codex_app_server_driver = __commonJS({
19730
19730
  "Codex is not signed in. Run `codex login`, then retry Chat."
19731
19731
  );
19732
19732
  }
19733
- if (!toolsDisabled && !imageGenerationOnly) {
19734
- try {
19735
- await this._ensureRequiredMcpServer();
19736
- } catch (error) {
19737
- console.warn(`[CodexAppServerDriver] Continuing without verified task MCP tools: ${error.message}`);
19738
- }
19739
- }
19740
19733
  const utilityInstructions = imageGenerationOnly ? IMAGE_ONLY_INSTRUCTIONS : toolsDisabled ? TEXT_ONLY_INSTRUCTIONS : null;
19741
19734
  const threadParams = {
19742
19735
  cwd,
@@ -19793,6 +19786,13 @@ var require_codex_app_server_driver = __commonJS({
19793
19786
  }
19794
19787
  }
19795
19788
  this._threadId = ((_a = result == null ? void 0 : result.thread) == null ? void 0 : _a.id) || (result == null ? void 0 : result.threadId) || (resumeSessionId || null);
19789
+ if (!toolsDisabled && !imageGenerationOnly) {
19790
+ try {
19791
+ await this._ensureRequiredMcpServer(this._threadId);
19792
+ } catch (error) {
19793
+ console.warn(`[CodexAppServerDriver] Continuing without verified task MCP tools: ${error.message}`);
19794
+ }
19795
+ }
19796
19796
  this._sessionCwd = (result == null ? void 0 : result.cwd) || ((_b = result == null ? void 0 : result.thread) == null ? void 0 : _b.cwd) || cwd;
19797
19797
  let historyPage = result == null ? void 0 : result.initialTurnsPage;
19798
19798
  const returnedTurns = Array.isArray((_c = result == null ? void 0 : result.thread) == null ? void 0 : _c.turns) ? result.thread.turns : [];
@@ -19833,13 +19833,14 @@ var require_codex_app_server_driver = __commonJS({
19833
19833
  } : {}
19834
19834
  };
19835
19835
  }
19836
- async _listMcpServers() {
19836
+ async _listMcpServers(threadId) {
19837
19837
  const servers = [];
19838
19838
  const seenCursors = /* @__PURE__ */ new Set();
19839
19839
  let cursor;
19840
19840
  do {
19841
19841
  const result = await this._request("mcpServerStatus/list", {
19842
19842
  detail: "toolsAndAuthOnly",
19843
+ ...threadId ? { threadId } : {},
19843
19844
  ...cursor ? { cursor } : {}
19844
19845
  });
19845
19846
  if (Array.isArray(result == null ? void 0 : result.data)) servers.push(...result.data);
@@ -19850,17 +19851,14 @@ var require_codex_app_server_driver = __commonJS({
19850
19851
  } while (cursor);
19851
19852
  return servers;
19852
19853
  }
19853
- async _ensureRequiredMcpServer() {
19854
+ async _ensureRequiredMcpServer(threadId) {
19854
19855
  if (!this._requiredMcpServer) return;
19855
19856
  const connected = (servers) => servers.some((server) => (server == null ? void 0 : server.name) === this._requiredMcpServer && Object.values(server.tools || {}).some((tool) => (tool == null ? void 0 : tool.name) === REQUIRED_TASK_MCP_TOOL));
19856
- if (connected(await this._listMcpServers())) return;
19857
+ if (connected(await this._listMcpServers(threadId))) return;
19857
19858
  if (this._repairMcpConfig && await this._repairMcpConfig() === false) {
19858
19859
  throw new Error("CodeAgentSwarm could not repair the Codex MCP configuration. Restart CodeAgentSwarm and retry Chat.");
19859
19860
  }
19860
19861
  await this._request("config/mcpServer/reload", null);
19861
- if (!connected(await this._listMcpServers())) {
19862
- throw new Error("CodeAgentSwarm MCP tools are unavailable in Codex. Restart CodeAgentSwarm and retry Chat.");
19863
- }
19864
19862
  }
19865
19863
  /**
19866
19864
  * Build a resumed thread's past items as historical `item.completed` events.
@@ -35427,6 +35425,18 @@ var require_mobile_runtime = __commonJS({
35427
35425
  this._sessionsChanged();
35428
35426
  return true;
35429
35427
  }
35428
+ notifySessionIdentity(identity = {}, alert = {}) {
35429
+ const directId = cleanText(identity.sessionId, 128);
35430
+ const threadId = cleanText(identity.threadId, 500);
35431
+ const terminalUuid = cleanText(identity.terminalUuid, 500);
35432
+ const sessions = Array.from(this.sessions.values());
35433
+ const terminalMatches = terminalUuid ? sessions.filter((candidate) => candidate.terminalUuid === terminalUuid && candidate.state !== "stopped") : [];
35434
+ const session = directId && this.sessions.get(directId) || threadId && sessions.find((candidate) => candidate.threadId === threadId && candidate.state !== "stopped") || terminalMatches.length === 1 && terminalMatches[0];
35435
+ if (!session || session.state === "stopped" || typeof this.notifyAttention !== "function") {
35436
+ return Promise.resolve({ sent: 0 });
35437
+ }
35438
+ return Promise.resolve(this.notifyAttention(attentionPushPayload(session, alert))).catch(() => ({ sent: 0 }));
35439
+ }
35430
35440
  notifyTerminal(terminalId, alert = {}) {
35431
35441
  if (!Number.isSafeInteger(terminalId) || terminalId < 1 || typeof this.notifyAttention !== "function") {
35432
35442
  return Promise.resolve({ sent: 0 });
@@ -47496,6 +47506,16 @@ var require_headless_runtime = __commonJS({
47496
47506
  cursor: new CursorConversationSearchService()
47497
47507
  };
47498
47508
  }
47509
+ function headlessStatusAlert(status) {
47510
+ if (typeof status !== "string" || !status.trim() || status === "working") return null;
47511
+ const body = {
47512
+ needs_input: "Agent needs confirmation",
47513
+ needs_testing: "Ready for testing",
47514
+ done: "Session finished",
47515
+ pushed: "Changes pushed"
47516
+ }[status] || `Session status: ${status.replaceAll("_", " ")}`;
47517
+ return { body };
47518
+ }
47499
47519
  function processHeadlessNotifications(runtime, filePath = path.join(os.homedir(), ".codeagentswarm", "task_notifications.json")) {
47500
47520
  try {
47501
47521
  const stat = fs.lstatSync(filePath);
@@ -47517,6 +47537,10 @@ var require_headless_runtime = __commonJS({
47517
47537
  identity = { workStatus: notification.status };
47518
47538
  }
47519
47539
  if (!identity || !runtime.updateSessionIdentity({ terminalUuid: notification.terminal_uuid, ...identity })) continue;
47540
+ const alert = notification.type === "terminal_status_update" ? headlessStatusAlert(notification.status) : null;
47541
+ if (alert && typeof runtime.notifySessionIdentity === "function") {
47542
+ void runtime.notifySessionIdentity({ terminalUuid: notification.terminal_uuid }, alert);
47543
+ }
47520
47544
  notification.processed = true;
47521
47545
  applied += 1;
47522
47546
  }
@@ -48560,7 +48584,7 @@ var require_cas = __commonJS({
48560
48584
  loadIdentity,
48561
48585
  resolveProject
48562
48586
  } = require_headless_runtime();
48563
- var version = true ? "0.0.1" : JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json"), "utf8")).version;
48587
+ var version = true ? "0.0.2" : JSON.parse(fs.readFileSync(path.join(__dirname, "..", "..", "package.json"), "utf8")).version;
48564
48588
  var DEFAULT_PAIRING_CODE_ORIGIN = "https://codeagentswarm-connect.elcaminodelprogramadorweb.workers.dev";
48565
48589
  function help() {
48566
48590
  return `CAS CLI ${version}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeagentswarm/cas-cloud",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "CAS Cloud runtime for remote CodeAgentSwarm sessions",
5
5
  "author": "Arturo Garcia <hello@codeagentswarm.com>",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",