@astralform/js 4.6.0 → 4.7.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.
package/dist/index.cjs CHANGED
@@ -507,6 +507,12 @@ var AstralformClient = class {
507
507
  return await response.json();
508
508
  });
509
509
  }
510
+ async patch(path, body) {
511
+ return this.withDeadline(async (signal) => {
512
+ const response = await this.send("PATCH", path, body, signal);
513
+ return await response.json();
514
+ });
515
+ }
510
516
  async del(path) {
511
517
  await this.request("DELETE", path);
512
518
  }
@@ -577,6 +583,25 @@ var AstralformClient = class {
577
583
  createdAt: m.created_at
578
584
  }));
579
585
  }
586
+ /**
587
+ * Replace the title the server generated from the conversation's first turn.
588
+ *
589
+ * The server does NOT bump `updated_at` for a rename — conversations list
590
+ * newest-updated first, and relabelling one is not activity — so the
591
+ * timestamp coming back is the original. Callers should merge the response
592
+ * rather than stamp their own, or they reintroduce the reordering the
593
+ * server deliberately avoids.
594
+ */
595
+ async renameConversation(id, title) {
596
+ const c = await this.patch(`/v1/conversations/${encodeURIComponent(id)}`, { title });
597
+ return {
598
+ id: c.id,
599
+ title: c.title,
600
+ messageCount: c.message_count,
601
+ createdAt: c.created_at,
602
+ updatedAt: c.updated_at
603
+ };
604
+ }
580
605
  async deleteConversation(id) {
581
606
  await this.del(`/v1/conversations/${encodeURIComponent(id)}`);
582
607
  }
@@ -1926,6 +1951,26 @@ var ChatSession = class {
1926
1951
  this.isLoadingConversations = false;
1927
1952
  }
1928
1953
  }
1954
+ /**
1955
+ * Rename a conversation, server first.
1956
+ *
1957
+ * Deliberately NOT optimistic, unlike the delete below. A failed delete is
1958
+ * self-correcting (the row is still there on the next page fetch), but a
1959
+ * failed rename that had already been written locally would leave the
1960
+ * sidebar showing a title the server never accepted — and nothing refetches
1961
+ * a conversation that is already in the loaded list.
1962
+ *
1963
+ * Mirrors the `title_generated` path: the entry in `conversations` is
1964
+ * mutated in place, which is what every consumer of the list reads.
1965
+ */
1966
+ async renameConversation(id, title) {
1967
+ const updated = await this.client.renameConversation(id, title);
1968
+ const conv = this.conversations.find((c) => c.id === id);
1969
+ if (conv) {
1970
+ conv.title = updated.title;
1971
+ }
1972
+ await this.storage.updateConversationTitle(id, updated.title);
1973
+ }
1929
1974
  async deleteConversation(id) {
1930
1975
  try {
1931
1976
  await this.client.deleteConversation(id);
@@ -2132,6 +2177,7 @@ var StreamManager = class {
2132
2177
  agentName: options?.agentName,
2133
2178
  uploadIds: options?.uploadIds,
2134
2179
  planMode: options?.planMode,
2180
+ imageMode: options?.imageMode,
2135
2181
  goal: options?.goal,
2136
2182
  provider: options?.provider,
2137
2183
  model: options?.model,
@@ -2215,12 +2261,19 @@ var StreamManager = class {
2215
2261
  }
2216
2262
  await this.restore(conversationId);
2217
2263
  }
2218
- // ── Create / delete conversation ──────────────────────────────
2264
+ // ── Create / rename / delete conversation ─────────────────────
2219
2265
  async createConversation() {
2220
2266
  const id = await this.session.createNewConversation();
2221
2267
  this.setActiveConversation(id);
2222
2268
  return id;
2223
2269
  }
2270
+ /**
2271
+ * Rename a conversation. Purely a relabel — no active-conversation or
2272
+ * background-job bookkeeping to do, unlike delete, so this is a passthrough.
2273
+ */
2274
+ async renameConversation(id, title) {
2275
+ await this.session.renameConversation(id, title);
2276
+ }
2224
2277
  async deleteConversation(id) {
2225
2278
  await this.session.deleteConversation(id);
2226
2279
  this._backgroundJobs.delete(id);