ztile-cli 0.3.1 → 0.3.3

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.
package/dist/cli.js CHANGED
@@ -2,8 +2,12 @@
2
2
 
3
3
  // src/cli.ts
4
4
  var args = process.argv.slice(2);
5
+ if (args[0] === "version" || args[0] === "--version" || args[0] === "-v") {
6
+ console.log("0.3.3");
7
+ process.exit(0);
8
+ }
5
9
  if (args[0] === "hook") {
6
- const { handleHook } = await import("./hook-ZR4EVEUT.js");
10
+ const { handleHook } = await import("./hook-5CIEDLN5.js");
7
11
  await handleHook();
8
12
  process.exit(0);
9
13
  }
@@ -29,7 +33,7 @@ if (args[0] === "install") {
29
33
  process.exit(0);
30
34
  }
31
35
  if (args[0] === "connect") {
32
- const { runConnect } = await import("./connect-ZGETP6WZ.js");
36
+ const { runConnect } = await import("./connect-CZ727ZOC.js");
33
37
  const projectDir = findArg(args, "--project") ?? process.env["ZTILE_PROJECT"] ?? process.cwd();
34
38
  const daemon = args.includes("--daemon") || args.includes("-d");
35
39
  await runConnect({ projectDir, daemon });
@@ -39,13 +43,14 @@ if (args[0] === "disconnect") {
39
43
  disconnect();
40
44
  process.exit(0);
41
45
  }
42
- if (args.length === 0 || !["hook", "install", "connect", "disconnect", "login"].includes(args[0])) {
46
+ if (args.length === 0 || !["hook", "install", "connect", "disconnect", "login", "version"].includes(args[0])) {
43
47
  if (args.length > 0) console.error(`Unknown command: ${args[0]}`);
44
48
  console.log("Usage:");
45
49
  console.log(" ztile login Save API key and server config");
46
50
  console.log(" ztile install Configure Claude Code hooks");
47
51
  console.log(" ztile connect Connect to dashboard for remote control");
48
52
  console.log(" ztile disconnect Stop background connection");
53
+ console.log(" ztile version Show CLI version");
49
54
  console.log(" ztile hook Handle Claude Code hook (internal)");
50
55
  console.log("");
51
56
  console.log("Options:");
@@ -107,6 +107,8 @@ async function sendStreamData(sessionId, workspaceId, data) {
107
107
 
108
108
  // src/lib/session-manager.ts
109
109
  import { spawn as ptySpawn } from "node-pty";
110
+ import { EventEmitter } from "events";
111
+ var sessionEvents = new EventEmitter();
110
112
  var sessions = /* @__PURE__ */ new Map();
111
113
  function log(msg) {
112
114
  console.log(`[session] ${msg}`);
@@ -126,10 +128,39 @@ function attachStreamParser(pty, info, commandId) {
126
128
  info.sessionId = msg.session_id;
127
129
  info.status = "running";
128
130
  log(`session started: ${info.sessionId}`);
131
+ sessionEvents.emit("message", { type: "init", sessionId: info.sessionId });
132
+ }
133
+ if (msg.type === "assistant" && msg.message) {
134
+ const content = msg.message;
135
+ const texts = content.content?.filter((c) => c.type === "text").map((c) => c.text).filter(Boolean) ?? [];
136
+ if (texts.length > 0) {
137
+ sessionEvents.emit("message", {
138
+ type: "assistant",
139
+ sessionId: info.sessionId,
140
+ text: texts.join("\n")
141
+ });
142
+ }
143
+ }
144
+ if (msg.type === "assistant" && msg.message) {
145
+ const content = msg.message;
146
+ const tools = content.content?.filter((c) => c.type === "tool_use").map((c) => c.name).filter(Boolean) ?? [];
147
+ for (const toolName of tools) {
148
+ sessionEvents.emit("message", {
149
+ type: "tool_use",
150
+ sessionId: info.sessionId,
151
+ toolName
152
+ });
153
+ }
129
154
  }
130
155
  if (msg.type === "result") {
131
156
  info.status = "idle";
132
157
  log(`session completed: ${info.sessionId} (${msg.duration_ms}ms, $${msg.total_cost_usd})`);
158
+ sessionEvents.emit("message", {
159
+ type: "result",
160
+ sessionId: info.sessionId,
161
+ durationMs: msg.duration_ms,
162
+ costUsd: msg.total_cost_usd
163
+ });
133
164
  }
134
165
  if (info.sessionId) {
135
166
  sendStreamData(info.sessionId, info.workspaceId, msg).catch((err) => {
@@ -340,6 +371,21 @@ async function runConnect(options) {
340
371
  log2("!", `Heartbeat failed, retrying...`, YELLOW);
341
372
  }
342
373
  }, HEARTBEAT_INTERVAL_MS);
374
+ sessionEvents.on("message", (evt) => {
375
+ switch (evt.type) {
376
+ case "assistant": {
377
+ const preview = (evt.text ?? "").split("\n")[0].slice(0, 120);
378
+ log2("\u25C0", `${preview}${(evt.text ?? "").length > 120 ? "..." : ""}`, CYAN);
379
+ break;
380
+ }
381
+ case "tool_use":
382
+ log2("\u2699", `Tool: ${evt.toolName}`, DIM);
383
+ break;
384
+ case "result":
385
+ log2("\u2713", `Done (${((evt.durationMs ?? 0) / 1e3).toFixed(1)}s, $${(evt.costUsd ?? 0).toFixed(4)})`, GREEN);
386
+ break;
387
+ }
388
+ });
343
389
  let commandCount = 0;
344
390
  const pollTimer = setInterval(async () => {
345
391
  try {
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ resolveApiKey,
4
+ resolveServerUrl
5
+ } from "./chunk-XSAVKZSF.js";
2
6
  import "./chunk-PDX44BCA.js";
3
7
 
4
8
  // src/commands/hook.ts
@@ -78,11 +82,10 @@ async function releaseLock() {
78
82
  }
79
83
 
80
84
  // src/outputs/server.ts
81
- var DEFAULT_SERVER_URL = "https://ztile.dev";
82
85
  function getServerConfig() {
83
86
  return {
84
- serverUrl: process.env["ZTILE_SERVER_URL"] ?? DEFAULT_SERVER_URL,
85
- apiKey: process.env["ZTILE_API_KEY"]
87
+ serverUrl: resolveServerUrl(),
88
+ apiKey: resolveApiKey()
86
89
  };
87
90
  }
88
91
  async function sendRawToServer(payload) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztile-cli",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Mission control for autonomous coding agents (Claude Code, Codex, Gemini CLI)",
5
5
  "bin": {
6
6
  "ztile": "dist/cli.js"