@shaxpir/duiduidui-models 1.25.7 → 1.25.9

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.
@@ -82,6 +82,7 @@ export interface ChatError {
82
82
  export interface ChatCacheBreakpoints {
83
83
  system_prompt?: CacheBreakpoint;
84
84
  tools?: CacheBreakpoint;
85
+ auto?: CacheBreakpoint;
85
86
  }
86
87
  export interface ChatPayload {
87
88
  title?: string;
@@ -135,7 +136,8 @@ export declare class Chat extends SharedContent {
135
136
  * Set a cache breakpoint for the system prompt or tools at the conversation level.
136
137
  * These record that the server is using prompt caching for API calls in this chat.
137
138
  */
138
- setCacheBreakpoint(target: 'system_prompt' | 'tools', ttl: CacheTTL): void;
139
+ setCacheBreakpoint(target: 'system_prompt' | 'tools' | 'auto', ttl: CacheTTL): void;
140
+ removeCacheBreakpoint(target: 'system_prompt' | 'tools' | 'auto'): void;
139
141
  get cacheBreakpoints(): ChatCacheBreakpoints | undefined;
140
142
  clearExpiredBreakpoints(): void;
141
143
  }
@@ -54,25 +54,36 @@ class Chat extends SharedContent_1.SharedContent {
54
54
  */
55
55
  async modelUpdated() {
56
56
  this.checkDisposed('Chat.modelUpdated');
57
+ const chatId = this.id;
58
+ const title = this.title;
59
+ console.log(`[Chat.modelUpdated] START chat=${chatId} title=${JSON.stringify(title)} acquireCount=${this.acquireCount}`);
57
60
  // Update manifests for all participants
58
61
  await super.modelUpdated();
62
+ console.log(`[Chat.modelUpdated] after super.modelUpdated chat=${chatId} acquireCount=${this.acquireCount}`);
59
63
  // Update workspace stubs for all participants
60
64
  const stub = this.toStub();
61
65
  const userIds = this.getAllSharedUserIds();
66
+ console.log(`[Chat.modelUpdated] stub.title=${JSON.stringify(stub.title)} userIds=${JSON.stringify(userIds)}`);
62
67
  for (const userId of userIds) {
63
68
  try {
64
69
  const workspaceId = shaxpir_common_1.CachingHasher.makeMd5Base62Hash(userId + "-" + ContentKind_1.ContentKind.WORKSPACE);
65
70
  const workspace = await this.shareSync.acquire(ContentKind_1.ContentKind.WORKSPACE, workspaceId);
66
71
  if (workspace && workspace.exists()) {
72
+ console.log(`[Chat.modelUpdated] upserting stub for user=${userId} workspace=${workspaceId}`);
67
73
  // Cast needed to avoid circular dependency between Chat and Workspace
68
74
  workspace.upsertChatStub(stub);
69
75
  workspace.release();
70
76
  }
77
+ else {
78
+ console.log(`[Chat.modelUpdated] workspace not found for user=${userId} workspace=${workspaceId}`);
79
+ }
71
80
  }
72
81
  catch (err) {
82
+ console.error(`[Chat.modelUpdated] ERROR for user=${userId}:`, err);
73
83
  this.shareSync.onError(err, 'Chat.modelUpdated.workspaceStub');
74
84
  }
75
85
  }
86
+ console.log(`[Chat.modelUpdated] END chat=${chatId}`);
76
87
  }
77
88
  // ---- Getters ----
78
89
  get payload() {
@@ -234,6 +245,14 @@ class Chat extends SharedContent_1.SharedContent {
234
245
  }
235
246
  batch.commit();
236
247
  }
248
+ removeCacheBreakpoint(target) {
249
+ this.checkDisposed('Chat.removeCacheBreakpoint');
250
+ if (!this.payload.cache_breakpoints?.[target])
251
+ return;
252
+ const batch = new Operation_1.BatchOperation(this);
253
+ batch.removeValueAtPath(['payload', 'cache_breakpoints', target]);
254
+ batch.commit();
255
+ }
237
256
  get cacheBreakpoints() {
238
257
  return this.payload?.cache_breakpoints;
239
258
  }
@@ -257,6 +276,9 @@ class Chat extends SharedContent_1.SharedContent {
257
276
  if (cb.tools && shaxpir_common_1.Time.isDateTimeBefore(cb.tools.expires_at, now)) {
258
277
  batch.removeValueAtPath(['payload', 'cache_breakpoints', 'tools']);
259
278
  }
279
+ if (cb.auto && shaxpir_common_1.Time.isDateTimeBefore(cb.auto.expires_at, now)) {
280
+ batch.removeValueAtPath(['payload', 'cache_breakpoints', 'auto']);
281
+ }
260
282
  batch.commit();
261
283
  }
262
284
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaxpir/duiduidui-models",
3
- "version": "1.25.7",
3
+ "version": "1.25.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/shaxpir/duiduidui-models"