@palettelab/sdk 0.1.9 → 0.1.11

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/README.md CHANGED
@@ -122,6 +122,7 @@ import {
122
122
  PluginProvider,
123
123
  usePlatform,
124
124
  createPaletteClient,
125
+ usePluginTranslations,
125
126
  usePluginTasks,
126
127
  usePluginDataRooms,
127
128
  usePluginChat,
@@ -169,6 +170,37 @@ export default function PluginRoot(props: PluginComponentProps) {
169
170
  }
170
171
  ```
171
172
 
173
+ ## App Translations And OS Language
174
+
175
+ Palette OS passes the current global language into every plugin through
176
+ `usePlatform()`. Keep translations in your app repo, then let the SDK choose the
177
+ right language.
178
+
179
+ ```tsx
180
+ import { usePluginTranslations, type TranslationResources } from "@palettelab/sdk"
181
+
182
+ const resources = {
183
+ en: { title: "Invoices", greeting: "Hello, {{name}}" },
184
+ ko: { title: "청구서", greeting: "안녕하세요, {{name}}님" },
185
+ } satisfies TranslationResources
186
+
187
+ function App() {
188
+ const { t, language, setLanguage } = usePluginTranslations(resources)
189
+
190
+ return (
191
+ <main>
192
+ <h1>{t("title")}</h1>
193
+ <button onClick={() => setLanguage(language === "ko" ? "en" : "ko")}>
194
+ {language === "ko" ? "EN" : "KO"}
195
+ </button>
196
+ </main>
197
+ )
198
+ }
199
+ ```
200
+
201
+ The same context is available in `pltt dev`, so local development and OS runtime
202
+ use the same translation path.
203
+
172
204
  ## Palette Client
173
205
 
174
206
  Use `createPaletteClient()` when an app needs common Palette OS services without
@@ -195,7 +227,7 @@ Included clients:
195
227
 
196
228
  - `palette.user.current()` and `palette.user.updateProfile()`
197
229
  - `palette.organization.currentId()`, `currentRole()`, and `listMine()`
198
- - `palette.dataRooms.list()`, `create()`, `get()`, `folder()`, and `uploadFile()`
230
+ - `palette.dataRooms.list()`, `create()`, `get()`, `folder()`, `createFolder()`, `ensureFolder()`, `findRoomByName()`, `findFolderByName()`, `resolveFolderPath()`, `findFileByName()`, and `uploadFile()`
199
231
  - `palette.config.get()` and `palette.config.update(values)`, with optional plugin ID override
200
232
  - `palette.permissions.has()`, `hasAny()`, and `hasAll()`
201
233
  - `palette.storage.uploadToSignedUrl()`
@@ -204,6 +236,41 @@ Included clients:
204
236
  These helpers are intentionally thin wrappers over platform APIs. Apps can still
205
237
  use `apiFetch()` directly for custom backend routes.
206
238
 
239
+ ### Data Room Folders By Name
240
+
241
+ Apps can create or reuse custom Data Room folders by name:
242
+
243
+ ```tsx
244
+ const palette = createPaletteClient(usePlatform())
245
+
246
+ const room = await palette.dataRooms.ensureRoom("Finance")
247
+ const invoices = await palette.dataRooms.ensureFolder(room.id, "Invoices")
248
+
249
+ await palette.dataRooms.uploadFile(room.id, file, {
250
+ folderId: invoices.id,
251
+ })
252
+ ```
253
+
254
+ Apps can also resolve nested folders:
255
+
256
+ ```tsx
257
+ const folder = await palette.dataRooms.resolveFolderPath(
258
+ room.id,
259
+ "Clients/Acme/Invoices",
260
+ { create: true },
261
+ )
262
+ ```
263
+
264
+ To read existing files by name:
265
+
266
+ ```tsx
267
+ const room = await palette.dataRooms.requireRoomByName("Finance")
268
+ const folder = await palette.dataRooms.resolveFolderPath(room.id, "Clients/Acme/Invoices")
269
+ const file = folder
270
+ ? await palette.dataRooms.findFileByName(room.id, "jan.pdf", { folderId: folder.id })
271
+ : null
272
+ ```
273
+
207
274
  ## Permissions
208
275
 
209
276
  Use permission helpers to keep UI actions aligned with backend permission gates.
@@ -297,7 +364,7 @@ Use the SDK test utilities to render plugin components with a mock platform cont
297
364
  import { createMockPlatformContext, withPluginProvider } from "@palettelab/sdk"
298
365
 
299
366
  const ctx = createMockPlatformContext({
300
- pluginId: "hello-sdk",
367
+ pluginId: "my-plugin",
301
368
  organizationId: 1,
302
369
  })
303
370
 
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import react__default from 'react';
3
- import { P as PlatformContext } from '../plugin-o-qmdCBl.mjs';
3
+ import { P as PlatformContext } from '../plugin-DZRaxKt3.mjs';
4
4
 
5
5
  /**
6
6
  * Provider that wraps plugin components with the platform context.
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import react__default from 'react';
3
- import { P as PlatformContext } from '../plugin-o-qmdCBl.js';
3
+ import { P as PlatformContext } from '../plugin-DZRaxKt3.js';
4
4
 
5
5
  /**
6
6
  * Provider that wraps plugin components with the platform context.
@@ -1,71 +1,4 @@
1
- import * as react from 'react';
2
- import { P as PlatformContext } from '../plugin-o-qmdCBl.mjs';
3
- import { T as Task, i as TaskStats, g as TaskCreatePayload, l as TaskUpdatePayload, D as DataRoom, a as DataRoomFolder, b as DataRoomFile, d as ChatThread, c as ChatMessage } from '../data-room-Dtd9LLHf.mjs';
4
-
5
- /**
6
- * React context for platform services.
7
- * The platform runtime provides this — plugin developers consume it.
8
- */
9
- declare const PlatformCtx: react.Context<PlatformContext | null>;
10
- /**
11
- * Access the platform context from within a plugin component.
12
- *
13
- * Provides: user, organizationId, agents, apiFetch, navigate, showToast
14
- *
15
- * @example
16
- * ```tsx
17
- * import { usePlatform } from "@palettelab/sdk/hooks"
18
- *
19
- * function MyPlugin() {
20
- * const { user, apiFetch, showToast } = usePlatform()
21
- * // ...
22
- * }
23
- * ```
24
- */
25
- declare function usePlatform(): PlatformContext;
26
-
27
- /**
28
- * Hook for managing tasks from within a plugin.
29
- *
30
- * @param agentId - Optional agent ID to filter tasks
31
- */
32
- declare function usePluginTasks(agentId?: number): {
33
- tasks: Task[];
34
- stats: TaskStats | null;
35
- loading: boolean;
36
- createTask: (payload: TaskCreatePayload) => Promise<Task>;
37
- updateTask: (taskId: number, payload: TaskUpdatePayload) => Promise<Task>;
38
- deleteTask: (taskId: number) => Promise<void>;
39
- refetch: () => Promise<void>;
40
- };
41
-
42
- /**
43
- * Hook for accessing data rooms from within a plugin.
44
- */
45
- declare function usePluginDataRooms(): {
46
- rooms: DataRoom[];
47
- loading: boolean;
48
- fetchFolder: (roomId: number, folderId?: number) => Promise<{
49
- folders: DataRoomFolder[];
50
- files: DataRoomFile[];
51
- }>;
52
- refetch: () => Promise<void>;
53
- };
54
-
55
- /**
56
- * Hook for chat functionality within a plugin.
57
- * Supports creating threads, sending messages, and SSE streaming.
58
- */
59
- declare function usePluginChat(agentId: number): {
60
- threads: ChatThread[];
61
- messages: ChatMessage[];
62
- streaming: boolean;
63
- activeThreadId: string | null;
64
- fetchThreads: () => Promise<void>;
65
- createThread: () => Promise<ChatThread>;
66
- fetchMessages: (threadId: string) => Promise<void>;
67
- sendMessage: (threadId: string, content: string) => Promise<void>;
68
- stopStreaming: () => void;
69
- };
70
-
71
- export { PlatformCtx, usePlatform, usePluginChat, usePluginDataRooms, usePluginTasks };
1
+ export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-BL37Z-Ns.mjs';
2
+ import 'react';
3
+ import '../plugin-DZRaxKt3.mjs';
4
+ import '../data-room-Dtd9LLHf.mjs';
@@ -1,71 +1,4 @@
1
- import * as react from 'react';
2
- import { P as PlatformContext } from '../plugin-o-qmdCBl.js';
3
- import { T as Task, i as TaskStats, g as TaskCreatePayload, l as TaskUpdatePayload, D as DataRoom, a as DataRoomFolder, b as DataRoomFile, d as ChatThread, c as ChatMessage } from '../data-room-Dtd9LLHf.js';
4
-
5
- /**
6
- * React context for platform services.
7
- * The platform runtime provides this — plugin developers consume it.
8
- */
9
- declare const PlatformCtx: react.Context<PlatformContext | null>;
10
- /**
11
- * Access the platform context from within a plugin component.
12
- *
13
- * Provides: user, organizationId, agents, apiFetch, navigate, showToast
14
- *
15
- * @example
16
- * ```tsx
17
- * import { usePlatform } from "@palettelab/sdk/hooks"
18
- *
19
- * function MyPlugin() {
20
- * const { user, apiFetch, showToast } = usePlatform()
21
- * // ...
22
- * }
23
- * ```
24
- */
25
- declare function usePlatform(): PlatformContext;
26
-
27
- /**
28
- * Hook for managing tasks from within a plugin.
29
- *
30
- * @param agentId - Optional agent ID to filter tasks
31
- */
32
- declare function usePluginTasks(agentId?: number): {
33
- tasks: Task[];
34
- stats: TaskStats | null;
35
- loading: boolean;
36
- createTask: (payload: TaskCreatePayload) => Promise<Task>;
37
- updateTask: (taskId: number, payload: TaskUpdatePayload) => Promise<Task>;
38
- deleteTask: (taskId: number) => Promise<void>;
39
- refetch: () => Promise<void>;
40
- };
41
-
42
- /**
43
- * Hook for accessing data rooms from within a plugin.
44
- */
45
- declare function usePluginDataRooms(): {
46
- rooms: DataRoom[];
47
- loading: boolean;
48
- fetchFolder: (roomId: number, folderId?: number) => Promise<{
49
- folders: DataRoomFolder[];
50
- files: DataRoomFile[];
51
- }>;
52
- refetch: () => Promise<void>;
53
- };
54
-
55
- /**
56
- * Hook for chat functionality within a plugin.
57
- * Supports creating threads, sending messages, and SSE streaming.
58
- */
59
- declare function usePluginChat(agentId: number): {
60
- threads: ChatThread[];
61
- messages: ChatMessage[];
62
- streaming: boolean;
63
- activeThreadId: string | null;
64
- fetchThreads: () => Promise<void>;
65
- createThread: () => Promise<ChatThread>;
66
- fetchMessages: (threadId: string) => Promise<void>;
67
- sendMessage: (threadId: string, content: string) => Promise<void>;
68
- stopStreaming: () => void;
69
- };
70
-
71
- export { PlatformCtx, usePlatform, usePluginChat, usePluginDataRooms, usePluginTasks };
1
+ export { P as PlatformCtx, u as usePlatform, e as usePluginChat, f as usePluginDataRooms, g as usePluginTasks, h as usePluginTranslations } from '../index-DEvPH60n.js';
2
+ import 'react';
3
+ import '../plugin-DZRaxKt3.js';
4
+ import '../data-room-Dtd9LLHf.js';
@@ -24,7 +24,8 @@ __export(hooks_exports, {
24
24
  usePlatform: () => usePlatform,
25
25
  usePluginChat: () => usePluginChat,
26
26
  usePluginDataRooms: () => usePluginDataRooms,
27
- usePluginTasks: () => usePluginTasks
27
+ usePluginTasks: () => usePluginTasks,
28
+ usePluginTranslations: () => usePluginTranslations
28
29
  });
29
30
  module.exports = __toCommonJS(hooks_exports);
30
31
 
@@ -242,11 +243,75 @@ function usePluginChat(agentId) {
242
243
  stopStreaming
243
244
  };
244
245
  }
246
+
247
+ // src/i18n.ts
248
+ var import_react5 = require("react");
249
+ function normalizePaletteLanguage(language, fallback = "en") {
250
+ const trimmed = language?.trim().toLowerCase();
251
+ if (!trimmed) return fallback;
252
+ return trimmed.split("-")[0] || fallback;
253
+ }
254
+ function languageCandidates(language, fallbackLanguage = "en") {
255
+ const candidates = [
256
+ language,
257
+ normalizePaletteLanguage(language, fallbackLanguage),
258
+ fallbackLanguage,
259
+ normalizePaletteLanguage(fallbackLanguage, "en"),
260
+ "en"
261
+ ].filter(Boolean);
262
+ return Array.from(new Set(candidates));
263
+ }
264
+ function getValue(dictionary, key) {
265
+ if (!dictionary) return void 0;
266
+ let current = dictionary;
267
+ for (const part of key.split(".")) {
268
+ if (current === null || typeof current !== "object" || Array.isArray(current)) return void 0;
269
+ current = current[part];
270
+ }
271
+ if (typeof current === "string" || typeof current === "number" || typeof current === "boolean" || current === null) {
272
+ return current;
273
+ }
274
+ return void 0;
275
+ }
276
+ function interpolate(template, values) {
277
+ if (!values) return template;
278
+ return template.replace(/\{\{?\s*([a-zA-Z0-9_.-]+)\s*\}?\}/g, (match, key) => {
279
+ const value = values[key];
280
+ return value === void 0 || value === null ? match : String(value);
281
+ });
282
+ }
283
+ function translate(resources, key, options = {}) {
284
+ const fallbackLanguage = normalizePaletteLanguage(options.fallbackLanguage, "en");
285
+ for (const language of languageCandidates(options.language, fallbackLanguage)) {
286
+ const value = getValue(resources[language], key);
287
+ if (value !== void 0) {
288
+ return interpolate(String(value ?? ""), options.values);
289
+ }
290
+ }
291
+ return interpolate(options.defaultValue ?? key, options.values);
292
+ }
293
+ function usePluginTranslations(resources, options = {}) {
294
+ const platform = usePlatform();
295
+ const language = normalizePaletteLanguage(platform.language, options.fallbackLanguage ?? platform.fallbackLanguage);
296
+ const fallbackLanguage = normalizePaletteLanguage(options.fallbackLanguage ?? platform.fallbackLanguage, "en");
297
+ const t = (0, import_react5.useCallback)(
298
+ (key, values, defaultValue) => translate(resources, key, { language, fallbackLanguage, values, defaultValue }),
299
+ [fallbackLanguage, language, resources]
300
+ );
301
+ return {
302
+ language,
303
+ fallbackLanguage,
304
+ supportedLanguages: platform.supportedLanguages,
305
+ setLanguage: platform.setLanguage,
306
+ t
307
+ };
308
+ }
245
309
  // Annotate the CommonJS export names for ESM import in node:
246
310
  0 && (module.exports = {
247
311
  PlatformCtx,
248
312
  usePlatform,
249
313
  usePluginChat,
250
314
  usePluginDataRooms,
251
- usePluginTasks
315
+ usePluginTasks,
316
+ usePluginTranslations
252
317
  });
@@ -212,10 +212,74 @@ function usePluginChat(agentId) {
212
212
  stopStreaming
213
213
  };
214
214
  }
215
+
216
+ // src/i18n.ts
217
+ import { useCallback as useCallback4 } from "react";
218
+ function normalizePaletteLanguage(language, fallback = "en") {
219
+ const trimmed = language?.trim().toLowerCase();
220
+ if (!trimmed) return fallback;
221
+ return trimmed.split("-")[0] || fallback;
222
+ }
223
+ function languageCandidates(language, fallbackLanguage = "en") {
224
+ const candidates = [
225
+ language,
226
+ normalizePaletteLanguage(language, fallbackLanguage),
227
+ fallbackLanguage,
228
+ normalizePaletteLanguage(fallbackLanguage, "en"),
229
+ "en"
230
+ ].filter(Boolean);
231
+ return Array.from(new Set(candidates));
232
+ }
233
+ function getValue(dictionary, key) {
234
+ if (!dictionary) return void 0;
235
+ let current = dictionary;
236
+ for (const part of key.split(".")) {
237
+ if (current === null || typeof current !== "object" || Array.isArray(current)) return void 0;
238
+ current = current[part];
239
+ }
240
+ if (typeof current === "string" || typeof current === "number" || typeof current === "boolean" || current === null) {
241
+ return current;
242
+ }
243
+ return void 0;
244
+ }
245
+ function interpolate(template, values) {
246
+ if (!values) return template;
247
+ return template.replace(/\{\{?\s*([a-zA-Z0-9_.-]+)\s*\}?\}/g, (match, key) => {
248
+ const value = values[key];
249
+ return value === void 0 || value === null ? match : String(value);
250
+ });
251
+ }
252
+ function translate(resources, key, options = {}) {
253
+ const fallbackLanguage = normalizePaletteLanguage(options.fallbackLanguage, "en");
254
+ for (const language of languageCandidates(options.language, fallbackLanguage)) {
255
+ const value = getValue(resources[language], key);
256
+ if (value !== void 0) {
257
+ return interpolate(String(value ?? ""), options.values);
258
+ }
259
+ }
260
+ return interpolate(options.defaultValue ?? key, options.values);
261
+ }
262
+ function usePluginTranslations(resources, options = {}) {
263
+ const platform = usePlatform();
264
+ const language = normalizePaletteLanguage(platform.language, options.fallbackLanguage ?? platform.fallbackLanguage);
265
+ const fallbackLanguage = normalizePaletteLanguage(options.fallbackLanguage ?? platform.fallbackLanguage, "en");
266
+ const t = useCallback4(
267
+ (key, values, defaultValue) => translate(resources, key, { language, fallbackLanguage, values, defaultValue }),
268
+ [fallbackLanguage, language, resources]
269
+ );
270
+ return {
271
+ language,
272
+ fallbackLanguage,
273
+ supportedLanguages: platform.supportedLanguages,
274
+ setLanguage: platform.setLanguage,
275
+ t
276
+ };
277
+ }
215
278
  export {
216
279
  PlatformCtx,
217
280
  usePlatform,
218
281
  usePluginChat,
219
282
  usePluginDataRooms,
220
- usePluginTasks
283
+ usePluginTasks,
284
+ usePluginTranslations
221
285
  };
@@ -0,0 +1,96 @@
1
+ import * as react from 'react';
2
+ import { d as PaletteLanguage, P as PlatformContext } from './plugin-DZRaxKt3.mjs';
3
+ import { T as Task, i as TaskStats, g as TaskCreatePayload, l as TaskUpdatePayload, D as DataRoom, a as DataRoomFolder, b as DataRoomFile, d as ChatThread, c as ChatMessage } from './data-room-Dtd9LLHf.mjs';
4
+
5
+ type TranslationPrimitive = string | number | boolean | null;
6
+ type TranslationDictionary = {
7
+ [key: string]: TranslationPrimitive | TranslationDictionary;
8
+ };
9
+ type TranslationResources = Record<PaletteLanguage, TranslationDictionary>;
10
+ type TranslationValues = Record<string, string | number | boolean | null | undefined>;
11
+ interface TranslateOptions {
12
+ language?: PaletteLanguage;
13
+ fallbackLanguage?: PaletteLanguage;
14
+ defaultValue?: string;
15
+ values?: TranslationValues;
16
+ }
17
+ interface UsePluginTranslationsOptions {
18
+ fallbackLanguage?: PaletteLanguage;
19
+ }
20
+ declare function normalizePaletteLanguage(language?: string | null, fallback?: PaletteLanguage): PaletteLanguage;
21
+ declare function translate(resources: TranslationResources, key: string, options?: TranslateOptions): string;
22
+ declare function usePluginTranslations(resources: TranslationResources, options?: UsePluginTranslationsOptions): {
23
+ language: string;
24
+ fallbackLanguage: string;
25
+ supportedLanguages: string[];
26
+ setLanguage: (language: PaletteLanguage) => void;
27
+ t: (key: string, values?: TranslationValues, defaultValue?: string) => string;
28
+ };
29
+
30
+ /**
31
+ * React context for platform services.
32
+ * The platform runtime provides this — plugin developers consume it.
33
+ */
34
+ declare const PlatformCtx: react.Context<PlatformContext | null>;
35
+ /**
36
+ * Access the platform context from within a plugin component.
37
+ *
38
+ * Provides: user, organizationId, agents, apiFetch, navigate, showToast
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { usePlatform } from "@palettelab/sdk/hooks"
43
+ *
44
+ * function MyPlugin() {
45
+ * const { user, apiFetch, showToast } = usePlatform()
46
+ * // ...
47
+ * }
48
+ * ```
49
+ */
50
+ declare function usePlatform(): PlatformContext;
51
+
52
+ /**
53
+ * Hook for managing tasks from within a plugin.
54
+ *
55
+ * @param agentId - Optional agent ID to filter tasks
56
+ */
57
+ declare function usePluginTasks(agentId?: number): {
58
+ tasks: Task[];
59
+ stats: TaskStats | null;
60
+ loading: boolean;
61
+ createTask: (payload: TaskCreatePayload) => Promise<Task>;
62
+ updateTask: (taskId: number, payload: TaskUpdatePayload) => Promise<Task>;
63
+ deleteTask: (taskId: number) => Promise<void>;
64
+ refetch: () => Promise<void>;
65
+ };
66
+
67
+ /**
68
+ * Hook for accessing data rooms from within a plugin.
69
+ */
70
+ declare function usePluginDataRooms(): {
71
+ rooms: DataRoom[];
72
+ loading: boolean;
73
+ fetchFolder: (roomId: number, folderId?: number) => Promise<{
74
+ folders: DataRoomFolder[];
75
+ files: DataRoomFile[];
76
+ }>;
77
+ refetch: () => Promise<void>;
78
+ };
79
+
80
+ /**
81
+ * Hook for chat functionality within a plugin.
82
+ * Supports creating threads, sending messages, and SSE streaming.
83
+ */
84
+ declare function usePluginChat(agentId: number): {
85
+ threads: ChatThread[];
86
+ messages: ChatMessage[];
87
+ streaming: boolean;
88
+ activeThreadId: string | null;
89
+ fetchThreads: () => Promise<void>;
90
+ createThread: () => Promise<ChatThread>;
91
+ fetchMessages: (threadId: string) => Promise<void>;
92
+ sendMessage: (threadId: string, content: string) => Promise<void>;
93
+ stopStreaming: () => void;
94
+ };
95
+
96
+ export { PlatformCtx as P, type TranslateOptions as T, type UsePluginTranslationsOptions as U, type TranslationDictionary as a, type TranslationPrimitive as b, type TranslationResources as c, type TranslationValues as d, usePluginChat as e, usePluginDataRooms as f, usePluginTasks as g, usePluginTranslations as h, normalizePaletteLanguage as n, translate as t, usePlatform as u };
@@ -0,0 +1,96 @@
1
+ import * as react from 'react';
2
+ import { d as PaletteLanguage, P as PlatformContext } from './plugin-DZRaxKt3.js';
3
+ import { T as Task, i as TaskStats, g as TaskCreatePayload, l as TaskUpdatePayload, D as DataRoom, a as DataRoomFolder, b as DataRoomFile, d as ChatThread, c as ChatMessage } from './data-room-Dtd9LLHf.js';
4
+
5
+ type TranslationPrimitive = string | number | boolean | null;
6
+ type TranslationDictionary = {
7
+ [key: string]: TranslationPrimitive | TranslationDictionary;
8
+ };
9
+ type TranslationResources = Record<PaletteLanguage, TranslationDictionary>;
10
+ type TranslationValues = Record<string, string | number | boolean | null | undefined>;
11
+ interface TranslateOptions {
12
+ language?: PaletteLanguage;
13
+ fallbackLanguage?: PaletteLanguage;
14
+ defaultValue?: string;
15
+ values?: TranslationValues;
16
+ }
17
+ interface UsePluginTranslationsOptions {
18
+ fallbackLanguage?: PaletteLanguage;
19
+ }
20
+ declare function normalizePaletteLanguage(language?: string | null, fallback?: PaletteLanguage): PaletteLanguage;
21
+ declare function translate(resources: TranslationResources, key: string, options?: TranslateOptions): string;
22
+ declare function usePluginTranslations(resources: TranslationResources, options?: UsePluginTranslationsOptions): {
23
+ language: string;
24
+ fallbackLanguage: string;
25
+ supportedLanguages: string[];
26
+ setLanguage: (language: PaletteLanguage) => void;
27
+ t: (key: string, values?: TranslationValues, defaultValue?: string) => string;
28
+ };
29
+
30
+ /**
31
+ * React context for platform services.
32
+ * The platform runtime provides this — plugin developers consume it.
33
+ */
34
+ declare const PlatformCtx: react.Context<PlatformContext | null>;
35
+ /**
36
+ * Access the platform context from within a plugin component.
37
+ *
38
+ * Provides: user, organizationId, agents, apiFetch, navigate, showToast
39
+ *
40
+ * @example
41
+ * ```tsx
42
+ * import { usePlatform } from "@palettelab/sdk/hooks"
43
+ *
44
+ * function MyPlugin() {
45
+ * const { user, apiFetch, showToast } = usePlatform()
46
+ * // ...
47
+ * }
48
+ * ```
49
+ */
50
+ declare function usePlatform(): PlatformContext;
51
+
52
+ /**
53
+ * Hook for managing tasks from within a plugin.
54
+ *
55
+ * @param agentId - Optional agent ID to filter tasks
56
+ */
57
+ declare function usePluginTasks(agentId?: number): {
58
+ tasks: Task[];
59
+ stats: TaskStats | null;
60
+ loading: boolean;
61
+ createTask: (payload: TaskCreatePayload) => Promise<Task>;
62
+ updateTask: (taskId: number, payload: TaskUpdatePayload) => Promise<Task>;
63
+ deleteTask: (taskId: number) => Promise<void>;
64
+ refetch: () => Promise<void>;
65
+ };
66
+
67
+ /**
68
+ * Hook for accessing data rooms from within a plugin.
69
+ */
70
+ declare function usePluginDataRooms(): {
71
+ rooms: DataRoom[];
72
+ loading: boolean;
73
+ fetchFolder: (roomId: number, folderId?: number) => Promise<{
74
+ folders: DataRoomFolder[];
75
+ files: DataRoomFile[];
76
+ }>;
77
+ refetch: () => Promise<void>;
78
+ };
79
+
80
+ /**
81
+ * Hook for chat functionality within a plugin.
82
+ * Supports creating threads, sending messages, and SSE streaming.
83
+ */
84
+ declare function usePluginChat(agentId: number): {
85
+ threads: ChatThread[];
86
+ messages: ChatMessage[];
87
+ streaming: boolean;
88
+ activeThreadId: string | null;
89
+ fetchThreads: () => Promise<void>;
90
+ createThread: () => Promise<ChatThread>;
91
+ fetchMessages: (threadId: string) => Promise<void>;
92
+ sendMessage: (threadId: string, content: string) => Promise<void>;
93
+ stopStreaming: () => void;
94
+ };
95
+
96
+ export { PlatformCtx as P, type TranslateOptions as T, type UsePluginTranslationsOptions as U, type TranslationDictionary as a, type TranslationPrimitive as b, type TranslationResources as c, type TranslationValues as d, usePluginChat as e, usePluginDataRooms as f, usePluginTasks as g, usePluginTranslations as h, normalizePaletteLanguage as n, translate as t, usePlatform as u };