@agentsky/sky 2.14.0 → 2.16.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.
@@ -38,7 +38,7 @@ function currentUniverse() {
38
38
  }
39
39
 
40
40
  // src/version.ts
41
- var CLI_VERSION = "2.14.0";
41
+ var CLI_VERSION = "2.16.0";
42
42
  var USER_AGENT = `sky-cli/${CLI_VERSION} (${process.platform}; node/${process.versions.node})`;
43
43
 
44
44
  export {
@@ -3,9 +3,12 @@ import {
3
3
  apiBase,
4
4
  apiToken,
5
5
  currentUniverse
6
- } from "./chunk-VJEE2ALN.js";
6
+ } from "./chunk-5JHQH7WH.js";
7
7
 
8
8
  // src/api.ts
9
+ import { createWriteStream, writeFileSync } from "fs";
10
+ import { Readable } from "stream";
11
+ import { pipeline } from "stream/promises";
9
12
  var ApiError = class extends Error {
10
13
  constructor(status, code, message) {
11
14
  super(message);
@@ -88,12 +91,21 @@ async function apiForm(method, path, form) {
88
91
  if (!res.ok) await parseError(res);
89
92
  return await res.json();
90
93
  }
91
- async function downloadFile(fileId) {
94
+ async function downloadFileTo(fileId, outPath) {
92
95
  const res = await fetch(`${apiBase()}/files/${encodeURIComponent(fileId)}/content`, {
93
96
  headers: { "user-agent": USER_AGENT, ...authHeaders() }
94
97
  });
95
98
  if (!res.ok) await parseError(res);
96
- return { bytes: new Uint8Array(await res.arrayBuffer()), mediaType: res.headers.get("content-type") ?? "application/octet-stream" };
99
+ if (!res.body) {
100
+ writeFileSync(outPath, new Uint8Array(0));
101
+ return 0;
102
+ }
103
+ let written = 0;
104
+ const counted = Readable.fromWeb(res.body).on("data", (chunk) => {
105
+ written += chunk.length;
106
+ });
107
+ await pipeline(counted, createWriteStream(outPath));
108
+ return written;
97
109
  }
98
110
  async function apiBytes(method, path, body) {
99
111
  const res = await fetch(`${apiBase()}${path}`, {
@@ -132,7 +144,7 @@ async function resolveSessionRef(ref) {
132
144
  return agent.defaultSessionId;
133
145
  }
134
146
  async function* streamEvents(sessionId, signal) {
135
- const { parseSseStream } = await import("./src-EJU5U2GO.js");
147
+ const { parseSseStream } = await import("./src-KLP774OA.js");
136
148
  const res = await fetch(
137
149
  `${apiBase()}/sessions/${encodeURIComponent(sessionId)}/stream`,
138
150
  {
@@ -161,7 +173,7 @@ export {
161
173
  postEvents,
162
174
  uploadFile,
163
175
  apiForm,
164
- downloadFile,
176
+ downloadFileTo,
165
177
  apiBytes,
166
178
  resolveSessionRef,
167
179
  streamEvents
@@ -19737,6 +19737,7 @@ var SessionSourceCollector = class {
19737
19737
  summed = { input_tokens: 0, output_tokens: 0, cache_read_tokens: 0, cache_write_tokens: 0, reasoning_tokens: 0 };
19738
19738
  cumulative = null;
19739
19739
  meta = {};
19740
+ summaryTitle = "";
19740
19741
  push(raw) {
19741
19742
  const record2 = obj(raw);
19742
19743
  if (!record2) return;
@@ -19757,6 +19758,15 @@ var SessionSourceCollector = class {
19757
19758
  this.model(str(info?.model) || str(payload.model));
19758
19759
  return;
19759
19760
  }
19761
+ if (type === "custom-title") {
19762
+ const title = str(record2.customTitle).slice(0, 120);
19763
+ if (title) this.meta.title = title;
19764
+ return;
19765
+ }
19766
+ if (type === "summary") {
19767
+ this.summaryTitle = str(record2.summary).slice(0, 120) || this.summaryTitle;
19768
+ return;
19769
+ }
19760
19770
  if (type === "response_item") return this.time(str(record2.timestamp));
19761
19771
  if (type === "user" || type === "assistant") return this.claudeLine(record2, type);
19762
19772
  }
@@ -19765,6 +19775,7 @@ var SessionSourceCollector = class {
19765
19775
  const usage = Object.fromEntries(Object.entries(this.cumulative ?? this.summed).filter(([, value]) => num(value) > 0));
19766
19776
  return {
19767
19777
  ...this.meta,
19778
+ ...!this.meta.title && this.summaryTitle ? { title: this.summaryTitle } : {},
19768
19779
  ...models.length ? { models } : {},
19769
19780
  ...this.efforts.size ? { effort: [...this.efforts].join(", ") } : {},
19770
19781
  ...Object.keys(usage).length ? { usage } : {}