replicas-cli 0.3.588 → 0.3.590

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 (2) hide show
  1. package/dist/index.cjs +40 -8
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -38257,7 +38257,7 @@ function parsePiEvents(events) {
38257
38257
  const messages = [];
38258
38258
  const text3 = /* @__PURE__ */ new Map();
38259
38259
  const thinking = /* @__PURE__ */ new Map();
38260
- let activeMessageId = "assistant";
38260
+ let activeMessageId = null;
38261
38261
  for (const event of events) {
38262
38262
  if (event.type === "event_msg" && event.payload.type === "user_message" && typeof event.payload.message === "string") {
38263
38263
  messages.push({ id: getUserMessageId(event) ?? `pi-user-${event.timestamp}-${messages.length}`, type: "user", content: event.payload.message, timestamp: event.timestamp });
@@ -38277,6 +38277,31 @@ function parsePiEvents(events) {
38277
38277
  continue;
38278
38278
  }
38279
38279
  if (event.type === "pi-message_end") {
38280
+ const message2 = isRecord(event.payload.message) ? event.payload.message : null;
38281
+ if (message2?.role === "assistant") {
38282
+ const id = typeof message2.id === "string" && message2.id ? message2.id : activeMessageId ?? `assistant-${event.timestamp}-${messages.length}`;
38283
+ if (Array.isArray(message2.content)) {
38284
+ const thinkingParts = [];
38285
+ const textParts = [];
38286
+ for (const block of message2.content) {
38287
+ if (!isRecord(block)) continue;
38288
+ if (block.type === "thinking" && typeof block.thinking === "string" && block.thinking) {
38289
+ thinkingParts.push(block.thinking);
38290
+ } else if (block.type === "text" && typeof block.text === "string" && block.text) {
38291
+ textParts.push(block.text);
38292
+ }
38293
+ }
38294
+ if (thinkingParts.length > 0) {
38295
+ const content = thinkingParts.join("\n\n");
38296
+ upsertDisplayMessage(messages, { id: `pi-thinking-${id}`, type: "reasoning", content, status: "completed", timestamp: event.timestamp });
38297
+ }
38298
+ if (textParts.length > 0) {
38299
+ const content = textParts.join("\n\n");
38300
+ upsertDisplayMessage(messages, { id: `pi-${id}`, type: "agent", content, timestamp: event.timestamp });
38301
+ }
38302
+ }
38303
+ activeMessageId = null;
38304
+ }
38280
38305
  const error62 = assistantErrorMessage(event.payload.message);
38281
38306
  if (error62) {
38282
38307
  messages.push({ id: `pi-error-${event.timestamp}-${messages.length}`, type: "error", message: error62, timestamp: event.timestamp });
@@ -38285,7 +38310,7 @@ function parsePiEvents(events) {
38285
38310
  }
38286
38311
  if (event.type === "pi-message_update") {
38287
38312
  const payload = nestedPayload(event);
38288
- const id = typeof payload.id === "string" ? payload.id : activeMessageId;
38313
+ const id = typeof payload.id === "string" ? payload.id : activeMessageId ?? "assistant";
38289
38314
  if (payload.type === "text_delta" && typeof payload.delta === "string") text3.set(id, `${text3.get(id) ?? ""}${payload.delta}`);
38290
38315
  if (payload.type === "thinking_delta" && typeof payload.delta === "string") thinking.set(id, `${thinking.get(id) ?? ""}${payload.delta}`);
38291
38316
  const textContent = text3.get(id);
@@ -40624,7 +40649,7 @@ var CLI_VERSION;
40624
40649
  var init_cli_version = __esm({
40625
40650
  "../shared/src/cli-version.ts"() {
40626
40651
  "use strict";
40627
- CLI_VERSION = "0.3.588";
40652
+ CLI_VERSION = "0.3.590";
40628
40653
  }
40629
40654
  });
40630
40655
 
@@ -52936,6 +52961,13 @@ var init_identity = __esm({
52936
52961
  });
52937
52962
 
52938
52963
  // src/lib/ssh.ts
52964
+ function ensureSSHTransport() {
52965
+ const result = (0, import_child_process.spawnSync)("websocat", ["--version"], { stdio: "ignore" });
52966
+ if (result.error || result.status !== 0) {
52967
+ const install = process.platform === "darwin" ? "Install it with: brew install websocat" : "Install it from https://github.com/vi/websocat#installation";
52968
+ throw new Error(`SSH requires websocat on your PATH. ${install}`);
52969
+ }
52970
+ }
52939
52971
  function buildSSHArgs(token, host, proxyCommand, localForward) {
52940
52972
  return [
52941
52973
  ...SSH_OPTIONS,
@@ -52957,9 +52989,10 @@ async function connectSSH(token, host, proxyCommand, localForward) {
52957
52989
  const ssh = (0, import_child_process.spawn)("ssh", buildSSHArgs(token, host, proxyCommand, localForward), {
52958
52990
  stdio: "inherit"
52959
52991
  });
52960
- ssh.on("close", (code) => {
52961
- if (localForward && code) {
52962
- reject(new Error(`SSH tunnel exited with code ${code}`));
52992
+ ssh.on("close", (code, signal) => {
52993
+ if (code !== 0) {
52994
+ const reason = signal ? `signal ${signal}` : `code ${code}`;
52995
+ reject(new Error(`SSH${localForward ? " tunnel" : ""} exited with ${reason}`));
52963
52996
  } else {
52964
52997
  resolve4();
52965
52998
  }
@@ -53123,11 +53156,10 @@ var init_workspace_connection = __esm({
53123
53156
  // src/commands/connect.ts
53124
53157
  async function connectCommand(workspaceName) {
53125
53158
  ensureOrgApiAuthenticated();
53159
+ ensureSSHTransport();
53126
53160
  const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
53127
53161
  console.log(import_chalk10.default.blue(`
53128
53162
  Connecting to ${workspace.name}...`));
53129
- const sshCommand = `ssh ${sshToken}@${sshHost}`;
53130
- console.log(import_chalk10.default.gray(`SSH command: ${sshCommand}`));
53131
53163
  console.log(import_chalk10.default.gray("\nPress Ctrl+D to disconnect.\n"));
53132
53164
  await connectSSH(sshToken, sshHost, sshProxyCommand);
53133
53165
  console.log(import_chalk10.default.green("\n\u2713 Disconnected from workspace.\n"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.588",
3
+ "version": "0.3.590",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {