@btst/stack 4.3.0 → 4.5.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.
Files changed (120) hide show
  1. package/README.md +2 -2
  2. package/dist/packages/stack/src/plugins/ai-chat/api/compaction.cjs +289 -0
  3. package/dist/packages/stack/src/plugins/ai-chat/api/compaction.mjs +281 -0
  4. package/dist/packages/stack/src/plugins/ai-chat/api/context-checkpoint.cjs +54 -0
  5. package/dist/packages/stack/src/plugins/ai-chat/api/context-checkpoint.mjs +51 -0
  6. package/dist/packages/stack/src/plugins/ai-chat/api/getters.cjs +2 -0
  7. package/dist/packages/stack/src/plugins/ai-chat/api/getters.mjs +2 -0
  8. package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +285 -89
  9. package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +285 -89
  10. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +6 -3
  11. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +6 -3
  12. package/dist/packages/stack/src/plugins/ai-chat/api/serializers.cjs +1 -0
  13. package/dist/packages/stack/src/plugins/ai-chat/api/serializers.mjs +1 -0
  14. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +62 -17
  15. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +62 -17
  16. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.cjs +22 -2
  17. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.mjs +22 -2
  18. package/dist/packages/stack/src/plugins/ai-chat/client/context-checkpoint.cjs +30 -0
  19. package/dist/packages/stack/src/plugins/ai-chat/client/context-checkpoint.mjs +27 -0
  20. package/dist/packages/stack/src/plugins/ai-chat/db.cjs +8 -0
  21. package/dist/packages/stack/src/plugins/ai-chat/db.mjs +8 -0
  22. package/dist/packages/stack/src/plugins/ai-chat/history.cjs +47 -0
  23. package/dist/packages/stack/src/plugins/ai-chat/history.mjs +45 -0
  24. package/dist/packages/stack/src/plugins/ai-chat/schemas.cjs +2 -0
  25. package/dist/packages/stack/src/plugins/ai-chat/schemas.mjs +2 -0
  26. package/dist/packages/ui/src/components/markdown-content.cjs +9 -9
  27. package/dist/packages/ui/src/components/markdown-content.mjs +9 -9
  28. package/dist/plugins/ai-chat/api/index.d.cts +2 -2
  29. package/dist/plugins/ai-chat/api/index.d.mts +2 -2
  30. package/dist/plugins/ai-chat/api/index.d.ts +2 -2
  31. package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
  32. package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
  33. package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
  34. package/dist/plugins/ai-chat/client/hooks/index.d.cts +2 -2
  35. package/dist/plugins/ai-chat/client/hooks/index.d.mts +2 -2
  36. package/dist/plugins/ai-chat/client/hooks/index.d.ts +2 -2
  37. package/dist/plugins/ai-chat/client/index.d.cts +3 -3
  38. package/dist/plugins/ai-chat/client/index.d.mts +3 -3
  39. package/dist/plugins/ai-chat/client/index.d.ts +3 -3
  40. package/dist/plugins/ai-chat/query-keys.d.cts +1 -1
  41. package/dist/plugins/ai-chat/query-keys.d.mts +1 -1
  42. package/dist/plugins/ai-chat/query-keys.d.ts +1 -1
  43. package/dist/plugins/blog/api/index.d.cts +2 -2
  44. package/dist/plugins/blog/api/index.d.mts +2 -2
  45. package/dist/plugins/blog/api/index.d.ts +2 -2
  46. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  47. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  48. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  49. package/dist/plugins/blog/client/index.d.cts +2 -2
  50. package/dist/plugins/blog/client/index.d.mts +2 -2
  51. package/dist/plugins/blog/client/index.d.ts +2 -2
  52. package/dist/plugins/blog/query-keys.d.cts +2 -2
  53. package/dist/plugins/blog/query-keys.d.mts +2 -2
  54. package/dist/plugins/blog/query-keys.d.ts +2 -2
  55. package/dist/plugins/cms/api/index.d.cts +1 -1
  56. package/dist/plugins/cms/api/index.d.mts +1 -1
  57. package/dist/plugins/cms/api/index.d.ts +1 -1
  58. package/dist/plugins/cms/query-keys.d.cts +1 -1
  59. package/dist/plugins/cms/query-keys.d.mts +1 -1
  60. package/dist/plugins/cms/query-keys.d.ts +1 -1
  61. package/dist/plugins/form-builder/api/index.d.cts +1 -1
  62. package/dist/plugins/form-builder/api/index.d.mts +1 -1
  63. package/dist/plugins/form-builder/api/index.d.ts +1 -1
  64. package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
  65. package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
  66. package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
  67. package/dist/plugins/form-builder/query-keys.d.cts +1 -1
  68. package/dist/plugins/form-builder/query-keys.d.mts +1 -1
  69. package/dist/plugins/form-builder/query-keys.d.ts +1 -1
  70. package/dist/plugins/ui-builder/client/hooks/index.d.cts +1 -1
  71. package/dist/plugins/ui-builder/client/hooks/index.d.mts +1 -1
  72. package/dist/plugins/ui-builder/client/hooks/index.d.ts +1 -1
  73. package/dist/plugins/ui-builder/client/index.d.cts +1 -1
  74. package/dist/plugins/ui-builder/client/index.d.mts +1 -1
  75. package/dist/plugins/ui-builder/client/index.d.ts +1 -1
  76. package/dist/plugins/ui-builder/query-keys.d.cts +1 -1
  77. package/dist/plugins/ui-builder/query-keys.d.mts +1 -1
  78. package/dist/plugins/ui-builder/query-keys.d.ts +1 -1
  79. package/dist/shared/{stack.D2y4gl03.d.mts → stack.94kN3pEK.d.mts} +5 -5
  80. package/dist/shared/{stack.DBH1Bjko.d.ts → stack.B2EYZyh_.d.ts} +16 -2
  81. package/dist/shared/{stack.rmWRtSjs.d.cts → stack.BTStHVTy.d.cts} +5 -5
  82. package/dist/shared/{stack.CZ1h_T4k.d.mts → stack.BggTHKlo.d.mts} +90 -90
  83. package/dist/shared/{stack.DzJgoNqJ.d.cts → stack.Cei2T2gc.d.cts} +2 -0
  84. package/dist/shared/{stack.DiYg7Jw1.d.cts → stack.CtrnoQgH.d.cts} +90 -90
  85. package/dist/shared/{stack.CHrtGKLz.d.mts → stack.DZRZAzcx.d.mts} +2 -0
  86. package/dist/shared/{stack.CnDMBj4z.d.ts → stack.DfrRYOIl.d.ts} +5 -5
  87. package/dist/shared/{stack.B7Mj74BQ.d.mts → stack.DivuAnNI.d.mts} +16 -2
  88. package/dist/shared/{stack.qMp2VzNw.d.ts → stack.byjorQi5.d.ts} +2 -0
  89. package/dist/shared/{stack.Dgt3MCtW.d.cts → stack.fF273jws.d.cts} +16 -2
  90. package/dist/shared/{stack.DQpyA3Cq.d.ts → stack.lPKwd_v0.d.ts} +90 -90
  91. package/package.json +1 -1
  92. package/src/__tests__/markdown-link-navigation.test.tsx +29 -0
  93. package/src/plugins/ai-chat/__tests__/authorization.test.ts +56 -30
  94. package/src/plugins/ai-chat/__tests__/classnames-overrides.test.tsx +25 -0
  95. package/src/plugins/ai-chat/__tests__/client-sweep.test.tsx +101 -0
  96. package/src/plugins/ai-chat/__tests__/compaction.test.ts +272 -0
  97. package/src/plugins/ai-chat/__tests__/persisted-compaction.test.ts +819 -0
  98. package/src/plugins/ai-chat/api/compaction.ts +377 -0
  99. package/src/plugins/ai-chat/api/context-checkpoint.ts +66 -0
  100. package/src/plugins/ai-chat/api/getters.ts +2 -0
  101. package/src/plugins/ai-chat/api/operations.ts +380 -93
  102. package/src/plugins/ai-chat/api/plugin.ts +15 -4
  103. package/src/plugins/ai-chat/api/serializers.ts +1 -0
  104. package/src/plugins/ai-chat/client/components/chat-interface.tsx +97 -21
  105. package/src/plugins/ai-chat/client/components/chat-message.tsx +32 -2
  106. package/src/plugins/ai-chat/client/context-checkpoint.ts +47 -0
  107. package/src/plugins/ai-chat/client/localization/index.ts +2 -0
  108. package/src/plugins/ai-chat/db.ts +8 -0
  109. package/src/plugins/ai-chat/history.ts +68 -0
  110. package/src/plugins/ai-chat/schemas.ts +2 -0
  111. package/src/plugins/ai-chat/types.ts +2 -0
  112. package/dist/shared/{stack.lsbdKRj7.d.mts → stack.B8PG21zX.d.mts} +16 -16
  113. package/dist/shared/{stack.CGmh-Lpe.d.ts → stack.BuxUQqL8.d.ts} +12 -12
  114. package/dist/shared/{stack.DtZgEX84.d.cts → stack.CKc_Bais.d.cts} +6 -6
  115. package/dist/shared/{stack.DtZgEX84.d.mts → stack.CKc_Bais.d.mts} +6 -6
  116. package/dist/shared/{stack.DtZgEX84.d.ts → stack.CKc_Bais.d.ts} +6 -6
  117. package/dist/shared/{stack.zch70Loj.d.cts → stack.CX83YNuS.d.cts} +12 -12
  118. package/dist/shared/{stack.BMlTZnZp.d.ts → stack.CyalJ0j6.d.ts} +16 -16
  119. package/dist/shared/{stack.BV0uNV4f.d.cts → stack.D6Pg-ufX.d.cts} +16 -16
  120. package/dist/shared/{stack.Doy2_wgl.d.mts → stack.Egr3RWhA.d.mts} +12 -12
@@ -9,7 +9,7 @@ import '../../../../shared/stack.fdi94T4S.js';
9
9
  import 'react-hook-form';
10
10
  import 'react/jsx-runtime';
11
11
  import '@btst/stack/plugins/client';
12
- import '../../../../shared/stack.BMlTZnZp.js';
12
+ import '../../../../shared/stack.CyalJ0j6.js';
13
13
  import '@btst/stack/plugins/api';
14
14
  import '../../../../authorization/index.js';
15
15
  import 'better-call';
@@ -15,7 +15,7 @@ import '../../../shared/stack.B3_aDcYL.cjs';
15
15
  import 'react-hook-form';
16
16
  import '@tanstack/react-query';
17
17
  import '@btst/stack/plugins/client/hooks';
18
- import '../../../shared/stack.BV0uNV4f.cjs';
18
+ import '../../../shared/stack.D6Pg-ufX.cjs';
19
19
  import '@btst/stack/plugins/api';
20
20
  import '../../../authorization/index.cjs';
21
21
  import 'better-call';
@@ -15,7 +15,7 @@ import '../../../shared/stack.B3_aDcYL.mjs';
15
15
  import 'react-hook-form';
16
16
  import '@tanstack/react-query';
17
17
  import '@btst/stack/plugins/client/hooks';
18
- import '../../../shared/stack.lsbdKRj7.mjs';
18
+ import '../../../shared/stack.B8PG21zX.mjs';
19
19
  import '@btst/stack/plugins/api';
20
20
  import '../../../authorization/index.mjs';
21
21
  import 'better-call';
@@ -15,7 +15,7 @@ import '../../../shared/stack.B3_aDcYL.js';
15
15
  import 'react-hook-form';
16
16
  import '@tanstack/react-query';
17
17
  import '@btst/stack/plugins/client/hooks';
18
- import '../../../shared/stack.BMlTZnZp.js';
18
+ import '../../../shared/stack.CyalJ0j6.js';
19
19
  import '@btst/stack/plugins/api';
20
20
  import '../../../authorization/index.js';
21
21
  import 'better-call';
@@ -1,6 +1,6 @@
1
1
  import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import { createApiClient } from '@btst/stack/plugins/client';
3
- import { a as ContentListDiscriminator, C as CMSApiRouter } from '../../shared/stack.BV0uNV4f.cjs';
3
+ import { a as ContentListDiscriminator, C as CMSApiRouter } from '../../shared/stack.D6Pg-ufX.cjs';
4
4
  import { C as ComponentLayer, V as Variable } from '../../shared/stack.DmpPDPxA.cjs';
5
5
  import { P as PaginatedContentItems, a as SerializedContentItemWithType } from '../../shared/stack.B3_aDcYL.cjs';
6
6
  import { UIBuilderPageSchemaType, PaginatedUIBuilderPages, SerializedUIBuilderPage } from './index.cjs';
@@ -1,6 +1,6 @@
1
1
  import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import { createApiClient } from '@btst/stack/plugins/client';
3
- import { a as ContentListDiscriminator, C as CMSApiRouter } from '../../shared/stack.lsbdKRj7.mjs';
3
+ import { a as ContentListDiscriminator, C as CMSApiRouter } from '../../shared/stack.B8PG21zX.mjs';
4
4
  import { C as ComponentLayer, V as Variable } from '../../shared/stack.B1srlBud.mjs';
5
5
  import { P as PaginatedContentItems, a as SerializedContentItemWithType } from '../../shared/stack.B3_aDcYL.mjs';
6
6
  import { UIBuilderPageSchemaType, PaginatedUIBuilderPages, SerializedUIBuilderPage } from './index.mjs';
@@ -1,6 +1,6 @@
1
1
  import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import { createApiClient } from '@btst/stack/plugins/client';
3
- import { a as ContentListDiscriminator, C as CMSApiRouter } from '../../shared/stack.BMlTZnZp.js';
3
+ import { a as ContentListDiscriminator, C as CMSApiRouter } from '../../shared/stack.CyalJ0j6.js';
4
4
  import { C as ComponentLayer, V as Variable } from '../../shared/stack.BK9Z2dcL.js';
5
5
  import { P as PaginatedContentItems, a as SerializedContentItemWithType } from '../../shared/stack.B3_aDcYL.js';
6
6
  import { UIBuilderPageSchemaType, PaginatedUIBuilderPages, SerializedUIBuilderPage } from './index.js';
@@ -2,7 +2,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { z } from 'zod';
3
3
  import { ResourceFormConfig, ResourceFormResult } from '@btst/stack/plugins/client/hooks';
4
4
  import { S as SerializedPost, a as SerializedTag } from './stack.Dsatjh0B.mjs';
5
- import { c as createPostSchema, u as updatePostSchema } from './stack.DtZgEX84.mjs';
5
+ import { c as createPostSchema, u as updatePostSchema } from './stack.CKc_Bais.mjs';
6
6
 
7
7
  /**
8
8
  * Options for the usePosts hook
@@ -136,8 +136,10 @@ declare function useSuspenseTags(): {
136
136
  declare function usePostForm<TValues>(config: ResourceFormConfig<TValues, SerializedPost | null, SerializedPost | null>): ResourceFormResult<TValues, SerializedPost | null, SerializedPost | null>;
137
137
  /** Create a new post */
138
138
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
139
- published: boolean;
140
139
  title: string;
140
+ content: string;
141
+ excerpt: string;
142
+ published: boolean;
141
143
  tags: ({
142
144
  name: string;
143
145
  } | {
@@ -145,12 +147,10 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
145
147
  name: string;
146
148
  slug: string;
147
149
  })[];
148
- content: string;
149
- excerpt: string;
150
150
  slug?: string | undefined;
151
+ publishedAt?: Date | undefined;
151
152
  createdAt?: Date | undefined;
152
153
  updatedAt?: Date | undefined;
153
- publishedAt?: Date | undefined;
154
154
  image?: string | undefined;
155
155
  }>;
156
156
  /** Update an existing post by id */
@@ -31,6 +31,8 @@ type Message = {
31
31
  conversationId: string;
32
32
  role: "system" | "user" | "assistant" | "data";
33
33
  content: string;
34
+ /** True when generation stopped before a successful completion. */
35
+ interrupted?: boolean | null;
34
36
  createdAt: Date;
35
37
  };
36
38
  type SerializedConversation = Omit<Conversation, "createdAt" | "updatedAt"> & {
@@ -55,6 +57,12 @@ interface AiChatPageContentConfig {
55
57
  description?: string;
56
58
  }
57
59
 
60
+ /** Opt-in context compaction for text-only conversations. */
61
+ interface AiChatCompactionConfig {
62
+ /** Actual context window. Configure the model's output limit at or below 20% of this. */
63
+ contextWindowTokens: number;
64
+ }
65
+
58
66
  type AiChatAccess = "authorized" | "public";
59
67
  /** Runtime input for one conversation operation. */
60
68
  declare const ConversationOperationInputSchema: z.ZodObject<{
@@ -85,6 +93,7 @@ type ChatOperationInput = {
85
93
  readonly metadata?: any;
86
94
  })[];
87
95
  readonly conversationId?: string;
96
+ readonly contextSummary?: string;
88
97
  readonly model?: string;
89
98
  readonly pageContext?: string;
90
99
  readonly availableTools?: readonly string[];
@@ -221,6 +230,8 @@ interface AiChatBackendConfig {
221
230
  */
222
231
  access?: AiChatAccess;
223
232
  systemPrompt?: string;
233
+ /** Automatically summarize older context in text chats; off by default. */
234
+ compaction?: AiChatCompactionConfig;
224
235
  tools?: Record<string, Tool>;
225
236
  /** Enable the standard readPage server tool for full page content. Reserves the readPage tool name. */
226
237
  pageContent?: AiChatPageContentConfig;
@@ -253,6 +264,7 @@ declare const aiChatBackendPlugin: <TTools extends Record<string, Tool> = Record
253
264
  metadata?: any;
254
265
  })[];
255
266
  conversationId?: string | undefined;
267
+ contextSummary?: string | undefined;
256
268
  model?: string | undefined;
257
269
  pageContext?: string | undefined;
258
270
  availableTools?: string[] | undefined;
@@ -273,6 +285,7 @@ declare const aiChatBackendPlugin: <TTools extends Record<string, Tool> = Record
273
285
  metadata?: any;
274
286
  })[];
275
287
  conversationId?: string | undefined;
288
+ contextSummary?: string | undefined;
276
289
  model?: string | undefined;
277
290
  pageContext?: string | undefined;
278
291
  availableTools?: string[] | undefined;
@@ -308,6 +321,7 @@ declare const aiChatBackendPlugin: <TTools extends Record<string, Tool> = Record
308
321
  readonly conversationId: string;
309
322
  readonly role: "system" | "user" | "assistant" | "data";
310
323
  readonly content: string;
324
+ readonly interrupted?: boolean | null | undefined;
311
325
  readonly createdAt: string;
312
326
  }[];
313
327
  }>;
@@ -519,5 +533,5 @@ declare function createAiChatQueryKeys(client: ReturnType<typeof createApiClient
519
533
  }>;
520
534
  type AiChatQueryKeys = ReturnType<typeof createAiChatQueryKeys>;
521
535
 
522
- export { UpdateConversationOperationInputSchema as U, aiChatIdentityKey as d, aiChatResources as e, createAiChatQueryKeys as f, aiChatBackendPlugin as i, AI_CHAT_OPERATION_INVENTORY as o, AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY as p, AiChatOperationError as q, ChatOperationInputSchema as r, ConversationOperationInputSchema as s };
523
- export type { AiChatIdentityPartition as A, ConversationWithMessages as C, Message as M, RenameConversationInput as R, SerializedConversation as S, SerializedMessage as a, CreateConversationInput as b, Conversation as c, AiChatQueryKeys as g, AiChatBackendConfig as h, AiChatApiRouter as j, AiChatPageContentConfig as k, AiChatAccess as l, AiChatBackendHooks as m, ChatApiContext as n };
536
+ export { UpdateConversationOperationInputSchema as U, aiChatIdentityKey as d, aiChatResources as e, createAiChatQueryKeys as f, aiChatBackendPlugin as i, AI_CHAT_OPERATION_INVENTORY as p, AI_CHAT_RAW_ESCAPE_HATCH_INVENTORY as q, AiChatOperationError as r, ChatOperationInputSchema as s, ConversationOperationInputSchema as t };
537
+ export type { AiChatIdentityPartition as A, ConversationWithMessages as C, Message as M, RenameConversationInput as R, SerializedConversation as S, SerializedMessage as a, CreateConversationInput as b, Conversation as c, AiChatQueryKeys as g, AiChatBackendConfig as h, AiChatApiRouter as j, AiChatCompactionConfig as k, AiChatPageContentConfig as l, AiChatAccess as m, AiChatBackendHooks as n, ChatApiContext as o };
@@ -2,7 +2,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { z } from 'zod';
3
3
  import { ResourceFormConfig, ResourceFormResult } from '@btst/stack/plugins/client/hooks';
4
4
  import { S as SerializedPost, a as SerializedTag } from './stack.Dsatjh0B.cjs';
5
- import { c as createPostSchema, u as updatePostSchema } from './stack.DtZgEX84.cjs';
5
+ import { c as createPostSchema, u as updatePostSchema } from './stack.CKc_Bais.cjs';
6
6
 
7
7
  /**
8
8
  * Options for the usePosts hook
@@ -136,8 +136,10 @@ declare function useSuspenseTags(): {
136
136
  declare function usePostForm<TValues>(config: ResourceFormConfig<TValues, SerializedPost | null, SerializedPost | null>): ResourceFormResult<TValues, SerializedPost | null, SerializedPost | null>;
137
137
  /** Create a new post */
138
138
  declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
139
- published: boolean;
140
139
  title: string;
140
+ content: string;
141
+ excerpt: string;
142
+ published: boolean;
141
143
  tags: ({
142
144
  name: string;
143
145
  } | {
@@ -145,12 +147,10 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
145
147
  name: string;
146
148
  slug: string;
147
149
  })[];
148
- content: string;
149
- excerpt: string;
150
150
  slug?: string | undefined;
151
+ publishedAt?: Date | undefined;
151
152
  createdAt?: Date | undefined;
152
153
  updatedAt?: Date | undefined;
153
- publishedAt?: Date | undefined;
154
154
  image?: string | undefined;
155
155
  }>;
156
156
  /** Update an existing post by id */