@optima-chat/agentic-sdk 0.15.1 → 0.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.
- package/dist/hooks/use-workspace-list.d.ts +26 -0
- package/dist/hooks/use-workspace-list.d.ts.map +1 -0
- package/dist/hooks/use-workspace-list.js +39 -0
- package/dist/hooks/use-workspace-list.js.map +1 -0
- package/dist/hooks/use-workspace-mutations.d.ts +20 -0
- package/dist/hooks/use-workspace-mutations.d.ts.map +1 -0
- package/dist/hooks/use-workspace-mutations.js +94 -0
- package/dist/hooks/use-workspace-mutations.js.map +1 -0
- package/dist/hooks/workspace-query-keys.d.ts +35 -0
- package/dist/hooks/workspace-query-keys.d.ts.map +1 -0
- package/dist/hooks/workspace-query-keys.js +35 -0
- package/dist/hooks/workspace-query-keys.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
|
|
2
|
+
import type { ListOptions, WorkspaceFile } from '../workspace/types.js';
|
|
3
|
+
export interface UseWorkspaceListOptions extends ListOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Pass-through to TanStack Query. Useful overrides:
|
|
6
|
+
* - `refetchOnWindowFocus: false` to opt out of the default focus-refetch
|
|
7
|
+
* - `enabled: false` for lazy/manual fetching
|
|
8
|
+
* - `staleTime: ms` for custom freshness window
|
|
9
|
+
*
|
|
10
|
+
* `queryKey` and `queryFn` are managed by the hook and cannot be overridden.
|
|
11
|
+
*/
|
|
12
|
+
queryOptions?: Omit<UseQueryOptions<WorkspaceFile[], Error>, 'queryKey' | 'queryFn'>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Subscribe to a directory listing with TanStack Query cache + automatic
|
|
16
|
+
* invalidation by the mutation hooks.
|
|
17
|
+
*
|
|
18
|
+
* Consumer must wrap the tree in `<QueryClientProvider>`. The hook reads
|
|
19
|
+
* `workspaceProvider` from `<ChatProvider>` context and throws if none is
|
|
20
|
+
* wired (matching `useWorkspaceFiles`'s behavior).
|
|
21
|
+
*
|
|
22
|
+
* For simpler use cases without cache concerns, the existing
|
|
23
|
+
* `useWorkspaceFiles` hook remains available.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useWorkspaceList(options?: UseWorkspaceListOptions): UseQueryResult<WorkspaceFile[], Error>;
|
|
26
|
+
//# sourceMappingURL=use-workspace-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-workspace-list.d.ts","sourceRoot":"","sources":["../../src/hooks/use-workspace-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5F,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAExE,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,IAAI,CACjB,eAAe,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,EACvC,UAAU,GAAG,SAAS,CACvB,CAAC;CACH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,uBAA4B,GACpC,cAAc,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,CA2BxC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useChatContext } from '../provider/chat-context.js';
|
|
3
|
+
import { workspaceKeys, WORKSPACE_DEFAULT_PATH } from './workspace-query-keys.js';
|
|
4
|
+
/**
|
|
5
|
+
* Subscribe to a directory listing with TanStack Query cache + automatic
|
|
6
|
+
* invalidation by the mutation hooks.
|
|
7
|
+
*
|
|
8
|
+
* Consumer must wrap the tree in `<QueryClientProvider>`. The hook reads
|
|
9
|
+
* `workspaceProvider` from `<ChatProvider>` context and throws if none is
|
|
10
|
+
* wired (matching `useWorkspaceFiles`'s behavior).
|
|
11
|
+
*
|
|
12
|
+
* For simpler use cases without cache concerns, the existing
|
|
13
|
+
* `useWorkspaceFiles` hook remains available.
|
|
14
|
+
*/
|
|
15
|
+
export function useWorkspaceList(options = {}) {
|
|
16
|
+
const { workspaceProvider } = useChatContext();
|
|
17
|
+
if (!workspaceProvider) {
|
|
18
|
+
throw new Error('useWorkspaceList requires a workspaceProvider on <ChatProvider>');
|
|
19
|
+
}
|
|
20
|
+
const { path, includeStats, queryOptions } = options;
|
|
21
|
+
// Normalize the default path to WORKSPACE_DEFAULT_PATH (matches gateway's
|
|
22
|
+
// WORKSPACE_PREFIX and createDefaultWorkspaceProvider's upload default).
|
|
23
|
+
// Critical for the cache invariant: omitted-path queries and explicit
|
|
24
|
+
// '/home/aiuser' queries MUST share a cache slot, because mutation hooks'
|
|
25
|
+
// default-path invalidation also targets '/home/aiuser'. Pass raw `path`
|
|
26
|
+
// (may be undefined) to the provider so the gateway default-mapping
|
|
27
|
+
// semantics stay intact.
|
|
28
|
+
const resolvedPath = path ?? WORKSPACE_DEFAULT_PATH;
|
|
29
|
+
const key = workspaceKeys.list(resolvedPath, includeStats ?? false);
|
|
30
|
+
// Spread queryOptions FIRST so managed queryKey/queryFn always win at
|
|
31
|
+
// runtime — defense in depth against `queryOptions: { ... } as any`
|
|
32
|
+
// callers that bypass the type-level Omit guard.
|
|
33
|
+
return useQuery({
|
|
34
|
+
...queryOptions,
|
|
35
|
+
queryKey: key,
|
|
36
|
+
queryFn: () => workspaceProvider.listFiles({ path, includeStats }),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=use-workspace-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-workspace-list.js","sourceRoot":"","sources":["../../src/hooks/use-workspace-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA6C,MAAM,uBAAuB,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAkBlF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,UAAmC,EAAE;IAErC,MAAM,EAAE,iBAAiB,EAAE,GAAG,cAAc,EAAE,CAAC;IAC/C,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACrD,0EAA0E;IAC1E,yEAAyE;IACzE,sEAAsE;IACtE,0EAA0E;IAC1E,yEAAyE;IACzE,oEAAoE;IACpE,yBAAyB;IACzB,MAAM,YAAY,GAAG,IAAI,IAAI,sBAAsB,CAAC;IACpD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,IAAI,KAAK,CAAC,CAAC;IAEpE,sEAAsE;IACtE,oEAAoE;IACpE,iDAAiD;IACjD,OAAO,QAAQ,CAAyB;QACtC,GAAG,YAAY;QACf,QAAQ,EAAE,GAAG;QACb,OAAO,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;KACnE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import type { DeleteOptions, UploadOptions } from '../workspace/types.js';
|
|
3
|
+
import type { UploadResult } from '../types.js';
|
|
4
|
+
export type DeleteFileVariables = string | {
|
|
5
|
+
path: string;
|
|
6
|
+
options?: DeleteOptions;
|
|
7
|
+
};
|
|
8
|
+
export declare function useDeleteFile(): UseMutationResult<void, Error, DeleteFileVariables>;
|
|
9
|
+
export interface RenameFileVariables {
|
|
10
|
+
oldPath: string;
|
|
11
|
+
newPath: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function useRenameFile(): UseMutationResult<void, Error, RenameFileVariables>;
|
|
14
|
+
export interface UploadFilesVariables {
|
|
15
|
+
files: File[];
|
|
16
|
+
options?: UploadOptions;
|
|
17
|
+
}
|
|
18
|
+
export declare function useUploadFiles(): UseMutationResult<UploadResult[], Error, UploadFilesVariables>;
|
|
19
|
+
export declare function useMakeDirectory(): UseMutationResult<void, Error, string>;
|
|
20
|
+
//# sourceMappingURL=use-workspace-mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-workspace-mutations.d.ts","sourceRoot":"","sources":["../../src/hooks/use-workspace-mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAyBhD,MAAM,MAAM,mBAAmB,GAC3B,MAAM,GACN;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,aAAa,CAAA;CAAE,CAAC;AAE9C,wBAAgB,aAAa,IAAI,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAmBnF;AAID,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,IAAI,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAqBnF;AAID,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,wBAAgB,cAAc,IAAI,iBAAiB,CACjD,YAAY,EAAE,EACd,KAAK,EACL,oBAAoB,CACrB,CAeA;AAID,wBAAgB,gBAAgB,IAAI,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,CAczE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useMutation, useQueryClient, } from '@tanstack/react-query';
|
|
2
|
+
import { useChatContext } from '../provider/chat-context.js';
|
|
3
|
+
import { workspaceKeys, WORKSPACE_DEFAULT_PATH } from './workspace-query-keys.js';
|
|
4
|
+
/**
|
|
5
|
+
* Strip the last path segment. POSIX-only (container paths are always
|
|
6
|
+
* `/home/aiuser/...` form). For `/home/aiuser/a.txt` returns `/home/aiuser`;
|
|
7
|
+
* for `/home/aiuser` returns `/home`; for `/foo` returns `/`. Empty string
|
|
8
|
+
* input returns empty string (defensive).
|
|
9
|
+
*/
|
|
10
|
+
function dirname(p) {
|
|
11
|
+
if (!p)
|
|
12
|
+
return '';
|
|
13
|
+
const idx = p.lastIndexOf('/');
|
|
14
|
+
if (idx <= 0)
|
|
15
|
+
return '/';
|
|
16
|
+
return p.slice(0, idx);
|
|
17
|
+
}
|
|
18
|
+
function useRequiredProvider(opName) {
|
|
19
|
+
const { workspaceProvider } = useChatContext();
|
|
20
|
+
if (!workspaceProvider) {
|
|
21
|
+
throw new Error(`${opName} requires a workspaceProvider on <ChatProvider>`);
|
|
22
|
+
}
|
|
23
|
+
return workspaceProvider;
|
|
24
|
+
}
|
|
25
|
+
export function useDeleteFile() {
|
|
26
|
+
const provider = useRequiredProvider('useDeleteFile');
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
return useMutation({
|
|
29
|
+
mutationFn: async (variables) => {
|
|
30
|
+
const [path, options] = typeof variables === 'string'
|
|
31
|
+
? [variables, undefined]
|
|
32
|
+
: [variables.path, variables.options];
|
|
33
|
+
await provider.deleteFile(path, options);
|
|
34
|
+
},
|
|
35
|
+
onSuccess: (_, variables) => {
|
|
36
|
+
const path = typeof variables === 'string' ? variables : variables.path;
|
|
37
|
+
void queryClient.invalidateQueries({
|
|
38
|
+
queryKey: workspaceKeys.listByPath(dirname(path)),
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function useRenameFile() {
|
|
44
|
+
const provider = useRequiredProvider('useRenameFile');
|
|
45
|
+
const queryClient = useQueryClient();
|
|
46
|
+
return useMutation({
|
|
47
|
+
mutationFn: async ({ oldPath, newPath }) => {
|
|
48
|
+
await provider.renameFile(oldPath, newPath);
|
|
49
|
+
},
|
|
50
|
+
onSuccess: (_, { oldPath, newPath }) => {
|
|
51
|
+
const oldParent = dirname(oldPath);
|
|
52
|
+
const newParent = dirname(newPath);
|
|
53
|
+
void queryClient.invalidateQueries({
|
|
54
|
+
queryKey: workspaceKeys.listByPath(oldParent),
|
|
55
|
+
});
|
|
56
|
+
if (newParent !== oldParent) {
|
|
57
|
+
void queryClient.invalidateQueries({
|
|
58
|
+
queryKey: workspaceKeys.listByPath(newParent),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function useUploadFiles() {
|
|
65
|
+
const provider = useRequiredProvider('useUploadFiles');
|
|
66
|
+
const queryClient = useQueryClient();
|
|
67
|
+
return useMutation({
|
|
68
|
+
mutationFn: async ({ files, options }) => {
|
|
69
|
+
return await provider.uploadFiles(files, options);
|
|
70
|
+
},
|
|
71
|
+
onSuccess: (_, { options }) => {
|
|
72
|
+
const target = options?.path ?? WORKSPACE_DEFAULT_PATH;
|
|
73
|
+
void queryClient.invalidateQueries({
|
|
74
|
+
queryKey: workspaceKeys.listByPath(target),
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
// ===== useMakeDirectory =====
|
|
80
|
+
export function useMakeDirectory() {
|
|
81
|
+
const provider = useRequiredProvider('useMakeDirectory');
|
|
82
|
+
const queryClient = useQueryClient();
|
|
83
|
+
return useMutation({
|
|
84
|
+
mutationFn: async (path) => {
|
|
85
|
+
await provider.makeDirectory(path);
|
|
86
|
+
},
|
|
87
|
+
onSuccess: (_, path) => {
|
|
88
|
+
void queryClient.invalidateQueries({
|
|
89
|
+
queryKey: workspaceKeys.listByPath(dirname(path)),
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=use-workspace-mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-workspace-mutations.js","sourceRoot":"","sources":["../../src/hooks/use-workspace-mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAQlF;;;;;GAKG;AACH,SAAS,OAAO,CAAC,CAAS;IACxB,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAClB,MAAM,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,GAAG,CAAC;IACzB,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,mBAAmB,CAAC,MAAc;IACzC,MAAM,EAAE,iBAAiB,EAAE,GAAG,cAAc,EAAE,CAAC;IAC/C,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,iDAAiD,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAQD,MAAM,UAAU,aAAa;IAC3B,MAAM,QAAQ,GAAG,mBAAmB,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AAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;YACrB,KAAK,WAAW,CAAC,iBAAiB,CAAC;gBACjC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;aAClD,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace root path. Mirrors:
|
|
3
|
+
* - the gateway's `WORKSPACE_PREFIX` (`/home/aiuser`)
|
|
4
|
+
* - `createDefaultWorkspaceProvider`'s `uploadFiles` default
|
|
5
|
+
* (`targetPath = options.path ?? '/home/aiuser'`)
|
|
6
|
+
*
|
|
7
|
+
* Shared by `useWorkspaceList` (for the key when `path` is omitted) and
|
|
8
|
+
* `useUploadFiles` (for invalidation when `options.path` is omitted) so
|
|
9
|
+
* default-path queries and default-path mutations target the same cache
|
|
10
|
+
* slot. If the gateway / provider default ever moves, change this one
|
|
11
|
+
* place and run the integration test (`workspace-cache-integration.test.tsx`)
|
|
12
|
+
* to confirm both sides still agree.
|
|
13
|
+
*/
|
|
14
|
+
export declare const WORKSPACE_DEFAULT_PATH = "/home/aiuser";
|
|
15
|
+
/**
|
|
16
|
+
* Query key factory for workspace cache hooks.
|
|
17
|
+
*
|
|
18
|
+
* TanStack Query matches keys by prefix, so a hierarchical shape lets us
|
|
19
|
+
* target invalidation precisely:
|
|
20
|
+
*
|
|
21
|
+
* - `['workspace']` — all workspace queries (test-only)
|
|
22
|
+
* - `['workspace', 'list']` — all list queries (test-only)
|
|
23
|
+
* - `['workspace', 'list', path]` — both includeStats variants for `path`
|
|
24
|
+
* - `['workspace', 'list', path, bool]` — the specific query
|
|
25
|
+
*
|
|
26
|
+
* Mutation invalidation uses `listByPath` so both stats variants refresh
|
|
27
|
+
* after a single mutation.
|
|
28
|
+
*/
|
|
29
|
+
export declare const workspaceKeys: {
|
|
30
|
+
all: () => readonly ["workspace"];
|
|
31
|
+
lists: () => readonly ["workspace", "list"];
|
|
32
|
+
listByPath: (path: string) => readonly ["workspace", "list", string];
|
|
33
|
+
list: (path: string, includeStats?: boolean) => readonly ["workspace", "list", string, boolean];
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=workspace-query-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-query-keys.d.ts","sourceRoot":"","sources":["../../src/hooks/workspace-query-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,sBAAsB,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;;;uBAGL,MAAM;iBACZ,MAAM,iBAAgB,OAAO;CAE3C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace root path. Mirrors:
|
|
3
|
+
* - the gateway's `WORKSPACE_PREFIX` (`/home/aiuser`)
|
|
4
|
+
* - `createDefaultWorkspaceProvider`'s `uploadFiles` default
|
|
5
|
+
* (`targetPath = options.path ?? '/home/aiuser'`)
|
|
6
|
+
*
|
|
7
|
+
* Shared by `useWorkspaceList` (for the key when `path` is omitted) and
|
|
8
|
+
* `useUploadFiles` (for invalidation when `options.path` is omitted) so
|
|
9
|
+
* default-path queries and default-path mutations target the same cache
|
|
10
|
+
* slot. If the gateway / provider default ever moves, change this one
|
|
11
|
+
* place and run the integration test (`workspace-cache-integration.test.tsx`)
|
|
12
|
+
* to confirm both sides still agree.
|
|
13
|
+
*/
|
|
14
|
+
export const WORKSPACE_DEFAULT_PATH = '/home/aiuser';
|
|
15
|
+
/**
|
|
16
|
+
* Query key factory for workspace cache hooks.
|
|
17
|
+
*
|
|
18
|
+
* TanStack Query matches keys by prefix, so a hierarchical shape lets us
|
|
19
|
+
* target invalidation precisely:
|
|
20
|
+
*
|
|
21
|
+
* - `['workspace']` — all workspace queries (test-only)
|
|
22
|
+
* - `['workspace', 'list']` — all list queries (test-only)
|
|
23
|
+
* - `['workspace', 'list', path]` — both includeStats variants for `path`
|
|
24
|
+
* - `['workspace', 'list', path, bool]` — the specific query
|
|
25
|
+
*
|
|
26
|
+
* Mutation invalidation uses `listByPath` so both stats variants refresh
|
|
27
|
+
* after a single mutation.
|
|
28
|
+
*/
|
|
29
|
+
export const workspaceKeys = {
|
|
30
|
+
all: () => ['workspace'],
|
|
31
|
+
lists: () => ['workspace', 'list'],
|
|
32
|
+
listByPath: (path) => ['workspace', 'list', path],
|
|
33
|
+
list: (path, includeStats = false) => ['workspace', 'list', path, includeStats],
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=workspace-query-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-query-keys.js","sourceRoot":"","sources":["../../src/hooks/workspace-query-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,CAAU;IACjC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,CAAU;IAC3C,UAAU,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAU;IAClE,IAAI,EAAE,CAAC,IAAY,EAAE,eAAwB,KAAK,EAAE,EAAE,CACpD,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,CAAU;CACrD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,11 @@ export { useApproval } from './hooks/use-approval.js';
|
|
|
8
8
|
export { useSwitchConfig } from './hooks/use-switch-config.js';
|
|
9
9
|
export { useProcessingConversations } from './hooks/use-processing-conversations.js';
|
|
10
10
|
export { useWorkspaceFiles } from './hooks/use-workspace-files.js';
|
|
11
|
+
export { useWorkspaceList } from './hooks/use-workspace-list.js';
|
|
12
|
+
export type { UseWorkspaceListOptions } from './hooks/use-workspace-list.js';
|
|
13
|
+
export { useDeleteFile, useRenameFile, useUploadFiles, useMakeDirectory, } from './hooks/use-workspace-mutations.js';
|
|
14
|
+
export type { DeleteFileVariables, RenameFileVariables, UploadFilesVariables, } from './hooks/use-workspace-mutations.js';
|
|
15
|
+
export { workspaceKeys, WORKSPACE_DEFAULT_PATH } from './hooks/workspace-query-keys.js';
|
|
11
16
|
export type { UseWorkspaceFilesOptions, UseWorkspaceFilesResult } from './hooks/use-workspace-files.js';
|
|
12
17
|
export type { ChatProviderProps, ConnectionState, MessageStatus, ToolCallStatus, ChatError, Conversation, ConversationLastMessageKind, Message, MessageAttachment, ToolCall, QuestionRequest, ApprovalRequestWithId, SendMessageOptions, UploadResult, } from './types.js';
|
|
13
18
|
export type { WorkspaceProvider, WorkspaceFile, FilePreview, ShareLink, UploadProgress, AuthenticatedUploader, UploadOptions, ListOptions, DeleteOptions, } from './workspace/types.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,y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C/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,YAAY,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACxF,YAAY,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGxG,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,cAAc,EACd,SAAS,EACT,YAAY,EACZ,2BAA2B,EAC3B,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,WAAW,EACX,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,8BAA8B,EAC9B,KAAK,+BAA+B,GACrC,MAAM,iCAAiC,CAAC;AAGzC,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,9 @@ export { useApproval } from './hooks/use-approval.js';
|
|
|
10
10
|
export { useSwitchConfig } from './hooks/use-switch-config.js';
|
|
11
11
|
export { useProcessingConversations } from './hooks/use-processing-conversations.js';
|
|
12
12
|
export { useWorkspaceFiles } from './hooks/use-workspace-files.js';
|
|
13
|
+
export { useWorkspaceList } from './hooks/use-workspace-list.js';
|
|
14
|
+
export { useDeleteFile, useRenameFile, useUploadFiles, useMakeDirectory, } from './hooks/use-workspace-mutations.js';
|
|
15
|
+
export { workspaceKeys, WORKSPACE_DEFAULT_PATH } from './hooks/workspace-query-keys.js';
|
|
13
16
|
export { WorkspaceFileError } from './workspace/errors.js';
|
|
14
17
|
export { createDefaultWorkspaceProvider, } from './workspace/default-provider.js';
|
|
15
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,QAAQ;AACR,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAE3D,QAAQ;AACR,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,GACjB,MAAM,oCAAoC,CAAC;AAM5C,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAiCxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EACL,8BAA8B,GAE/B,MAAM,iCAAiC,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.16.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@optima-chat/agentic-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "Chat core logic for Optima gateway - Provider, hooks, store, WebSocket client",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"directory": "packages/sdk"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
+
"@tanstack/react-query": "^5.0.0",
|
|
28
29
|
"react": "^19.0.0",
|
|
29
30
|
"zustand": "^5.0.0"
|
|
30
31
|
},
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@optima-chat/gateway-protocol": "^0.4.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
36
|
+
"@tanstack/react-query": "^5.90.0",
|
|
35
37
|
"@testing-library/react": "^16.0.0",
|
|
36
38
|
"@types/react": "^19.0.0",
|
|
37
39
|
"jsdom": "^25.0.0",
|