@notis_ai/cli 0.2.0-beta.32.1 → 0.2.0-beta.35.1
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 +41 -106
- package/dist/scaffolds/notes/app/globals.css +3 -0
- package/dist/scaffolds/notes/app/layout.tsx +6 -0
- package/dist/scaffolds/notes/app/page.tsx +1465 -0
- package/dist/scaffolds/notes/components/ui/badge.tsx +28 -0
- package/dist/scaffolds/notes/components/ui/button.tsx +53 -0
- package/dist/scaffolds/notes/components/ui/card.tsx +56 -0
- package/dist/scaffolds/notes/components.json +20 -0
- package/dist/scaffolds/notes/lib/utils.ts +6 -0
- package/dist/scaffolds/notes/notis.config.ts +31 -0
- package/dist/scaffolds/notes/package.json +31 -0
- package/dist/scaffolds/notes/postcss.config.mjs +8 -0
- package/dist/scaffolds/notes/tailwind.config.ts +58 -0
- package/dist/scaffolds/notes/tsconfig.json +22 -0
- package/dist/scaffolds/notes/vite.config.ts +10 -0
- package/dist/scaffolds.json +13 -0
- package/package.json +7 -3
- package/skills/notis-apps/SKILL.md +168 -0
- package/skills/notis-apps/cli.md +208 -0
- package/skills/notis-cli/SKILL.md +263 -0
- package/skills/notis-query/cli.md +40 -0
- package/src/cli.js +1 -1
- package/src/command-specs/apps.js +211 -46
- package/src/command-specs/helpers.js +0 -60
- package/src/command-specs/index.js +0 -6
- package/src/command-specs/meta.js +7 -6
- package/src/command-specs/tools.js +1 -33
- package/src/runtime/app-dev-server.js +30 -2
- package/src/runtime/app-platform.js +376 -24
- package/src/runtime/profiles.js +2 -2
- package/src/runtime/transport.js +2 -2
- package/template/.harness/index.html.tmpl +1 -50
- package/template/app/page.tsx +41 -6
- package/template/metadata/cover.png +0 -0
- package/template/metadata/screenshot-1.png +0 -0
- package/template/metadata/screenshot-2.png +0 -0
- package/template/metadata/screenshot-3.png +0 -0
- package/template/notis.config.ts +10 -6
- package/template/package.json +2 -2
- package/template/packages/{notis-sdk → sdk}/src/components/MultiSelectActionBar.tsx +2 -1
- package/template/packages/{notis-sdk → sdk}/src/components/MultiSelectCheckbox.tsx +2 -2
- package/template/packages/{notis-sdk → sdk}/src/components/MultiSelectDragOverlay.tsx +2 -2
- package/template/packages/{notis-sdk → sdk}/src/config.ts +1 -1
- package/template/packages/{notis-sdk → sdk}/src/hooks/useMultiSelect.ts +4 -3
- package/template/packages/sdk/src/hooks/useNotis.ts +30 -0
- package/template/packages/{notis-sdk → sdk}/src/hooks/useNotisNavigation.ts +3 -3
- package/template/packages/{notis-sdk → sdk}/src/hooks/useTool.ts +22 -7
- package/template/packages/{notis-sdk → sdk}/src/index.ts +3 -24
- package/template/packages/{notis-sdk → sdk}/src/provider.tsx +1 -1
- package/template/packages/sdk/src/runtime.ts +80 -0
- package/src/command-specs/auth.js +0 -178
- package/src/command-specs/db.js +0 -163
- package/template/packages/notis-sdk/src/helpers.ts +0 -131
- package/template/packages/notis-sdk/src/hooks/useAppState.ts +0 -50
- package/template/packages/notis-sdk/src/hooks/useCollectionItem.ts +0 -58
- package/template/packages/notis-sdk/src/hooks/useDatabase.ts +0 -88
- package/template/packages/notis-sdk/src/hooks/useDocument.ts +0 -61
- package/template/packages/notis-sdk/src/hooks/useNotis.ts +0 -33
- package/template/packages/notis-sdk/src/hooks/useUpsertDocument.ts +0 -58
- package/template/packages/notis-sdk/src/runtime.ts +0 -182
- /package/template/packages/{notis-sdk → sdk}/package.json +0 -0
- /package/template/packages/{notis-sdk → sdk}/src/hooks/useBackend.ts +0 -0
- /package/template/packages/{notis-sdk → sdk}/src/hooks/useTools.ts +0 -0
- /package/template/packages/{notis-sdk → sdk}/src/hooks/useTopBarSearch.ts +0 -0
- /package/template/packages/{notis-sdk → sdk}/src/styles.css +0 -0
- /package/template/packages/{notis-sdk → sdk}/src/ui.ts +0 -0
- /package/template/packages/{notis-sdk → sdk}/src/vite.ts +0 -0
- /package/template/packages/{notis-sdk → sdk}/tsconfig.json +0 -0
package/src/runtime/transport.js
CHANGED
|
@@ -51,8 +51,8 @@ function normalizeBackendError(status, payload) {
|
|
|
51
51
|
exitCode: EXIT_CODES.auth,
|
|
52
52
|
hints: [
|
|
53
53
|
{
|
|
54
|
-
command: '
|
|
55
|
-
reason: '
|
|
54
|
+
command: 'Open the Notis desktop app and sign in',
|
|
55
|
+
reason: 'Open the Notis desktop app to refresh CLI auth, or set NOTIS_JWT',
|
|
56
56
|
},
|
|
57
57
|
],
|
|
58
58
|
details: payload || {},
|
|
@@ -107,8 +107,7 @@
|
|
|
107
107
|
return {
|
|
108
108
|
app: descriptor.app,
|
|
109
109
|
route: descriptor.route,
|
|
110
|
-
|
|
111
|
-
context: descriptor.context || { collectionItem: null },
|
|
110
|
+
context: descriptor.context || {},
|
|
112
111
|
navigate: (args) => record('navigate', args),
|
|
113
112
|
registerTopBarSearch: () => {},
|
|
114
113
|
setTopBarSearchValue: () => {},
|
|
@@ -121,34 +120,6 @@
|
|
|
121
120
|
record('callTool', { name, arguments: args || {} });
|
|
122
121
|
return { ok: true, result: null };
|
|
123
122
|
},
|
|
124
|
-
queryDatabase: async (args) => {
|
|
125
|
-
record('queryDatabase', args || {});
|
|
126
|
-
return { documents: [], next_offset: null };
|
|
127
|
-
},
|
|
128
|
-
getDocument: async (args) => {
|
|
129
|
-
record('getDocument', args || {});
|
|
130
|
-
return null;
|
|
131
|
-
},
|
|
132
|
-
upsertDocument: async (args) => {
|
|
133
|
-
record('upsertDocument', args || {});
|
|
134
|
-
return {
|
|
135
|
-
status: 'ok',
|
|
136
|
-
document: {
|
|
137
|
-
id: (args && args.documentId) || 'mock-doc',
|
|
138
|
-
title: (args && args.title) || '',
|
|
139
|
-
properties: (args && args.properties) || {},
|
|
140
|
-
databaseSlug: args && args.databaseSlug,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
},
|
|
144
|
-
listCollectionItems: async (args) => {
|
|
145
|
-
record('listCollectionItems', args || {});
|
|
146
|
-
return { items: [] };
|
|
147
|
-
},
|
|
148
|
-
listCollectionTree: async (args) => {
|
|
149
|
-
record('listCollectionTree', args || {});
|
|
150
|
-
return { items: [] };
|
|
151
|
-
},
|
|
152
123
|
request: async (path, options) => {
|
|
153
124
|
record('request', { path, options });
|
|
154
125
|
return null;
|
|
@@ -168,26 +139,6 @@
|
|
|
168
139
|
record('callTool', { name, arguments: args || {} });
|
|
169
140
|
return runtimeQuery({ method: 'tools/call', name, arguments: args || {} });
|
|
170
141
|
},
|
|
171
|
-
queryDatabase: async (args) => {
|
|
172
|
-
record('queryDatabase', args || {});
|
|
173
|
-
const result = await runtimeQuery({ method: 'tools/call', name: 'notis_query_database', arguments: args || {} });
|
|
174
|
-
return result.result || result;
|
|
175
|
-
},
|
|
176
|
-
getDocument: async (args) => {
|
|
177
|
-
record('getDocument', args || {});
|
|
178
|
-
const result = await runtimeQuery({ method: 'tools/call', name: 'notis_get_document', arguments: args || {} });
|
|
179
|
-
return result.result || result;
|
|
180
|
-
},
|
|
181
|
-
upsertDocument: async (args) => {
|
|
182
|
-
record('upsertDocument', args || {});
|
|
183
|
-
const result = await runtimeQuery({ method: 'tools/call', name: 'notis_upsert_document', arguments: args || {} });
|
|
184
|
-
return result.result || result;
|
|
185
|
-
},
|
|
186
|
-
listCollectionItems: async (args) => {
|
|
187
|
-
record('listCollectionItems', args || {});
|
|
188
|
-
const result = await runtimeQuery({ method: 'tools/call', name: 'notis_list_collection_items', arguments: args || {} });
|
|
189
|
-
return result.result || result;
|
|
190
|
-
},
|
|
191
142
|
request: async (path, options) => {
|
|
192
143
|
record('request', { path, options });
|
|
193
144
|
const response = await fetch(`${String(apiBase).replace(/\/$/, '')}${path}`, {
|
package/template/app/page.tsx
CHANGED
|
@@ -1,12 +1,47 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useNotis, useTool } from '@notis/sdk';
|
|
4
5
|
import { Badge } from '@/components/ui/badge';
|
|
5
6
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
6
7
|
|
|
8
|
+
type ItemDocument = {
|
|
9
|
+
id?: string;
|
|
10
|
+
document_id?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
properties?: Record<string, unknown>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type QueryItemsArgs = {
|
|
16
|
+
database_slug: string;
|
|
17
|
+
query: {
|
|
18
|
+
page_size?: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type QueryItemsResult = {
|
|
23
|
+
documents?: ItemDocument[];
|
|
24
|
+
};
|
|
25
|
+
|
|
7
26
|
export default function HomePage() {
|
|
8
27
|
const { app, ready } = useNotis();
|
|
9
|
-
const
|
|
28
|
+
const queryItems = useTool<QueryItemsArgs, QueryItemsResult>('notis-default-query');
|
|
29
|
+
const [documents, setDocuments] = useState<ItemDocument[]>([]);
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
let cancelled = false;
|
|
33
|
+
queryItems
|
|
34
|
+
.call({ database_slug: 'items', query: { page_size: 25 } })
|
|
35
|
+
.then((result) => {
|
|
36
|
+
if (!cancelled) setDocuments(result.documents || []);
|
|
37
|
+
})
|
|
38
|
+
.catch(() => {
|
|
39
|
+
if (!cancelled) setDocuments([]);
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
cancelled = true;
|
|
43
|
+
};
|
|
44
|
+
}, [queryItems.call]);
|
|
10
45
|
|
|
11
46
|
return (
|
|
12
47
|
<main className="notis-app-shell space-y-6">
|
|
@@ -28,7 +63,7 @@ export default function HomePage() {
|
|
|
28
63
|
<CardDescription>Use shadcn surfaces and portal tokens so the app feels native inside Notis.</CardDescription>
|
|
29
64
|
</CardHeader>
|
|
30
65
|
<CardContent>
|
|
31
|
-
{loading ? (
|
|
66
|
+
{queryItems.loading ? (
|
|
32
67
|
<p className="text-sm text-muted-foreground">Loading...</p>
|
|
33
68
|
) : documents.length === 0 ? (
|
|
34
69
|
<div className="rounded-xl border border-dashed border-border px-4 py-10 text-center text-sm text-muted-foreground">
|
|
@@ -37,10 +72,10 @@ export default function HomePage() {
|
|
|
37
72
|
) : (
|
|
38
73
|
<div className="space-y-3">
|
|
39
74
|
{documents.map((doc) => (
|
|
40
|
-
<div key={doc.id} className="rounded-xl border border-border bg-background px-4 py-3">
|
|
75
|
+
<div key={doc.id || doc.document_id || doc.title} className="rounded-xl border border-border bg-background px-4 py-3">
|
|
41
76
|
<div className="flex items-center justify-between gap-3">
|
|
42
|
-
<p className="font-medium">{doc.title}</p>
|
|
43
|
-
{doc.properties
|
|
77
|
+
<p className="font-medium">{doc.title || 'Untitled'}</p>
|
|
78
|
+
{doc.properties?.status ? (
|
|
44
79
|
<Badge variant="outline">{String(doc.properties.status)}</Badge>
|
|
45
80
|
) : null}
|
|
46
81
|
</div>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/template/notis.config.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { defineNotisApp } from '@notis/sdk/config';
|
|
2
2
|
|
|
3
3
|
export default defineNotisApp({
|
|
4
|
-
name: '
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
name: 'my-notis-app',
|
|
5
|
+
title: 'My Notis App',
|
|
6
|
+
description: 'A focused Notis app with one route and one database-backed workflow.',
|
|
7
|
+
icon: 'phosphor:squares-four',
|
|
8
|
+
author: { name: 'Notis User' },
|
|
9
|
+
categories: ['Productivity'],
|
|
10
|
+
tagline: 'A clean starting point for a focused workflow.',
|
|
11
|
+
versionNotes: 'Initial release.',
|
|
7
12
|
|
|
8
13
|
databases: ['items'],
|
|
9
14
|
|
|
10
15
|
routes: [
|
|
11
|
-
{ path: '/', slug: 'home', name: 'Home', icon: '
|
|
16
|
+
{ path: '/', slug: 'home', name: 'Home', icon: 'phosphor:house', default: true },
|
|
12
17
|
// Example collection tree route:
|
|
13
18
|
// {
|
|
14
19
|
// path: '/notes',
|
|
@@ -27,7 +32,6 @@ export default defineNotisApp({
|
|
|
27
32
|
],
|
|
28
33
|
|
|
29
34
|
tools: [
|
|
30
|
-
'
|
|
31
|
-
'notis_upsert_document',
|
|
35
|
+
'notis-default-query',
|
|
32
36
|
],
|
|
33
37
|
});
|
package/template/package.json
CHANGED
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
"build": "vite build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@notis/sdk": "file:./packages/
|
|
11
|
+
"@notis/sdk": "file:./packages/sdk",
|
|
12
|
+
"@phosphor-icons/react": "^2.1.10",
|
|
12
13
|
"@radix-ui/react-slot": "^1.1.0",
|
|
13
14
|
"class-variance-authority": "^0.7.0",
|
|
14
15
|
"clsx": "^2.1.1",
|
|
15
|
-
"lucide-react": "^0.474.0",
|
|
16
16
|
"react": "^19.0.0",
|
|
17
17
|
"react-dom": "^19.0.0",
|
|
18
18
|
"tailwind-merge": "^2.6.0",
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useRef,
|
|
7
7
|
useState,
|
|
8
8
|
type CSSProperties,
|
|
9
|
+
type ReactElement,
|
|
9
10
|
type ReactNode,
|
|
10
11
|
} from 'react';
|
|
11
12
|
|
|
@@ -174,7 +175,7 @@ export function MultiSelectActionBar({
|
|
|
174
175
|
itemLabel,
|
|
175
176
|
className,
|
|
176
177
|
style,
|
|
177
|
-
}: MultiSelectActionBarProps):
|
|
178
|
+
}: MultiSelectActionBarProps): ReactElement | null {
|
|
178
179
|
const actionsRef = useRef(actions);
|
|
179
180
|
actionsRef.current = actions;
|
|
180
181
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { type CSSProperties, type MouseEvent as ReactMouseEvent } from 'react';
|
|
3
|
+
import { type CSSProperties, type MouseEvent as ReactMouseEvent, type ReactElement } from 'react';
|
|
4
4
|
|
|
5
5
|
export interface MultiSelectCheckboxProps {
|
|
6
6
|
isSelected: boolean;
|
|
@@ -44,7 +44,7 @@ export function MultiSelectCheckbox({
|
|
|
44
44
|
ariaLabel,
|
|
45
45
|
className,
|
|
46
46
|
style,
|
|
47
|
-
}: MultiSelectCheckboxProps):
|
|
47
|
+
}: MultiSelectCheckboxProps): ReactElement {
|
|
48
48
|
const merged: CSSProperties = {
|
|
49
49
|
...baseStyle,
|
|
50
50
|
...(isSelected ? selectedStyle : null),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { type CSSProperties } from 'react';
|
|
3
|
+
import { type CSSProperties, type ReactElement } from 'react';
|
|
4
4
|
import type { DragRect } from '../hooks/useMultiSelect';
|
|
5
5
|
|
|
6
6
|
export interface MultiSelectDragOverlayProps {
|
|
@@ -22,7 +22,7 @@ export function MultiSelectDragOverlay({
|
|
|
22
22
|
rect,
|
|
23
23
|
className,
|
|
24
24
|
style,
|
|
25
|
-
}: MultiSelectDragOverlayProps):
|
|
25
|
+
}: MultiSelectDragOverlayProps): ReactElement | null {
|
|
26
26
|
if (!rect) return null;
|
|
27
27
|
if (rect.width === 0 && rect.height === 0) return null;
|
|
28
28
|
|
|
@@ -149,7 +149,7 @@ export function useMultiSelect<T>(opts: UseMultiSelectOptions<T>): MultiSelectCo
|
|
|
149
149
|
|
|
150
150
|
const select = useCallback((ids: string[]) => {
|
|
151
151
|
setSelectedIds(new Set(ids));
|
|
152
|
-
setLastClickedId(ids.length > 0 ? ids[ids.length - 1] : null);
|
|
152
|
+
setLastClickedId(ids.length > 0 ? ids[ids.length - 1] ?? null : null);
|
|
153
153
|
}, []);
|
|
154
154
|
|
|
155
155
|
const clear = useCallback(() => {
|
|
@@ -159,7 +159,7 @@ export function useMultiSelect<T>(opts: UseMultiSelectOptions<T>): MultiSelectCo
|
|
|
159
159
|
const selectAll = useCallback(() => {
|
|
160
160
|
const all = orderedIdsRef.current;
|
|
161
161
|
setSelectedIds(new Set(all));
|
|
162
|
-
setLastClickedId(all.length > 0 ? all[all.length - 1] : null);
|
|
162
|
+
setLastClickedId(all.length > 0 ? all[all.length - 1] ?? null : null);
|
|
163
163
|
}, []);
|
|
164
164
|
|
|
165
165
|
const selectRange = useCallback((anchorId: string, targetId: string) => {
|
|
@@ -346,7 +346,7 @@ export function useMultiSelect<T>(opts: UseMultiSelectOptions<T>): MultiSelectCo
|
|
|
346
346
|
bottom: rect.top + rect.height,
|
|
347
347
|
});
|
|
348
348
|
setSelectedIds(new Set(ids));
|
|
349
|
-
setLastClickedId(ids.length > 0 ? ids[ids.length - 1] : null);
|
|
349
|
+
setLastClickedId(ids.length > 0 ? ids[ids.length - 1] ?? null : null);
|
|
350
350
|
};
|
|
351
351
|
|
|
352
352
|
const handleMouseUp = () => {
|
|
@@ -447,6 +447,7 @@ export function useMultiSelect<T>(opts: UseMultiSelectOptions<T>): MultiSelectCo
|
|
|
447
447
|
: Math.min(all.length - 1, Math.max(0, currentIdx + direction));
|
|
448
448
|
if (newIdx === currentIdx) return;
|
|
449
449
|
const newHead = all[newIdx];
|
|
450
|
+
if (!newHead) return;
|
|
450
451
|
const anchorId = lastClickedIdRef.current ?? currentHead ?? newHead;
|
|
451
452
|
const anchorIdx = all.indexOf(anchorId);
|
|
452
453
|
if (anchorIdx === -1) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useNotisRuntime } from '../provider';
|
|
4
|
+
import type { AppDescriptor, NotisRuntimeContext, RouteDescriptor } from '../runtime';
|
|
5
|
+
|
|
6
|
+
interface NotisContext {
|
|
7
|
+
/** App metadata (id, name, icon, description). Null before runtime loads. */
|
|
8
|
+
app: AppDescriptor | null;
|
|
9
|
+
/** Current route descriptor. Null before runtime loads. */
|
|
10
|
+
route: RouteDescriptor | null;
|
|
11
|
+
/** Generic route/app context supplied by the portal. */
|
|
12
|
+
context: NotisRuntimeContext;
|
|
13
|
+
/** Whether the runtime is loaded and available. */
|
|
14
|
+
ready: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Access app-level metadata, the current route, and generic portal context.
|
|
19
|
+
* Returns safe defaults when the portal runtime is not available.
|
|
20
|
+
*/
|
|
21
|
+
export function useNotis(): NotisContext {
|
|
22
|
+
const runtime = useNotisRuntime();
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
app: runtime?.app ?? null,
|
|
26
|
+
route: runtime?.route ?? null,
|
|
27
|
+
context: runtime?.context ?? {},
|
|
28
|
+
ready: runtime !== null,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -7,7 +7,7 @@ interface NavigationActions {
|
|
|
7
7
|
/** Navigate to a route within the app by its path. */
|
|
8
8
|
toRoute: (path: string) => void;
|
|
9
9
|
/** Navigate to a document detail view. */
|
|
10
|
-
toDocument: (documentId: string) => void;
|
|
10
|
+
toDocument: (documentId: string, title?: string | null) => void;
|
|
11
11
|
/** Navigate to the app's default route. */
|
|
12
12
|
toApp: () => void;
|
|
13
13
|
}
|
|
@@ -33,9 +33,9 @@ export function useNotisNavigation(): NavigationActions {
|
|
|
33
33
|
}
|
|
34
34
|
}, [runtime]);
|
|
35
35
|
|
|
36
|
-
const toDocument = useCallback((documentId: string) => {
|
|
36
|
+
const toDocument = useCallback((documentId: string, title?: string | null) => {
|
|
37
37
|
if (runtime?.navigate) {
|
|
38
|
-
runtime.navigate({ kind: 'document', documentId });
|
|
38
|
+
runtime.navigate({ kind: 'document', documentId, title: title ?? undefined });
|
|
39
39
|
}
|
|
40
40
|
}, [runtime]);
|
|
41
41
|
|
|
@@ -3,27 +3,42 @@
|
|
|
3
3
|
import { useCallback, useState } from 'react';
|
|
4
4
|
import { useNotisRuntime } from '../provider';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type ToolArguments = Record<string, unknown>;
|
|
7
|
+
|
|
8
|
+
type ToolCall<TArgs extends ToolArguments | undefined, TResult> = undefined extends TArgs
|
|
9
|
+
? (args?: Exclude<TArgs, undefined>) => Promise<TResult>
|
|
10
|
+
: (args: TArgs) => Promise<TResult>;
|
|
11
|
+
|
|
12
|
+
export interface ToolCallState {
|
|
8
13
|
loading: boolean;
|
|
9
14
|
error: Error | null;
|
|
10
15
|
}
|
|
11
16
|
|
|
17
|
+
export interface UseToolResult<
|
|
18
|
+
TArgs extends ToolArguments | undefined = ToolArguments | undefined,
|
|
19
|
+
TResult = unknown,
|
|
20
|
+
> extends ToolCallState {
|
|
21
|
+
call: ToolCall<TArgs, TResult>;
|
|
22
|
+
}
|
|
23
|
+
|
|
12
24
|
/**
|
|
13
25
|
* Call a specific Notis tool by name.
|
|
14
26
|
*
|
|
15
27
|
* ```tsx
|
|
16
|
-
* const { call, loading } = useTool('
|
|
28
|
+
* const { call, loading } = useTool('notis-default-web_search');
|
|
17
29
|
* const result = await call({ query: 'latest news' });
|
|
18
30
|
* ```
|
|
19
31
|
*/
|
|
20
|
-
export function useTool
|
|
32
|
+
export function useTool<
|
|
33
|
+
TArgs extends ToolArguments | undefined = ToolArguments | undefined,
|
|
34
|
+
TResult = unknown,
|
|
35
|
+
>(toolName: string): UseToolResult<TArgs, TResult> {
|
|
21
36
|
const runtime = useNotisRuntime();
|
|
22
37
|
const [loading, setLoading] = useState(false);
|
|
23
38
|
const [error, setError] = useState<Error | null>(null);
|
|
24
39
|
|
|
25
40
|
const call = useCallback(
|
|
26
|
-
async (args?:
|
|
41
|
+
async (args?: ToolArguments): Promise<TResult> => {
|
|
27
42
|
if (!runtime) {
|
|
28
43
|
throw new Error('Notis runtime not available. Ensure NotisProvider is mounted.');
|
|
29
44
|
}
|
|
@@ -32,7 +47,7 @@ export function useTool(toolName: string): UseToolResult {
|
|
|
32
47
|
setError(null);
|
|
33
48
|
|
|
34
49
|
try {
|
|
35
|
-
const result = await runtime.callTool(toolName, args);
|
|
50
|
+
const result = await runtime.callTool<TResult>(toolName, args);
|
|
36
51
|
return result;
|
|
37
52
|
} catch (err) {
|
|
38
53
|
const e = err instanceof Error ? err : new Error(String(err));
|
|
@@ -43,7 +58,7 @@ export function useTool(toolName: string): UseToolResult {
|
|
|
43
58
|
}
|
|
44
59
|
},
|
|
45
60
|
[runtime, toolName],
|
|
46
|
-
)
|
|
61
|
+
) as ToolCall<TArgs, TResult>;
|
|
47
62
|
|
|
48
63
|
return { call, loading, error };
|
|
49
64
|
}
|
|
@@ -7,20 +7,16 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
// Provider
|
|
10
|
-
export { NotisProvider
|
|
10
|
+
export { NotisProvider } from './provider';
|
|
11
11
|
|
|
12
12
|
// Hooks
|
|
13
13
|
export { useNotis } from './hooks/useNotis';
|
|
14
|
-
export { useDatabase } from './hooks/useDatabase';
|
|
15
|
-
export { useDocument } from './hooks/useDocument';
|
|
16
|
-
export { useUpsertDocument } from './hooks/useUpsertDocument';
|
|
17
14
|
export { useTool } from './hooks/useTool';
|
|
15
|
+
export type { ToolCallState, UseToolResult } from './hooks/useTool';
|
|
18
16
|
export { useTools } from './hooks/useTools';
|
|
19
|
-
export { useCollectionItems } from './hooks/useCollectionItem';
|
|
20
17
|
export { useNotisNavigation } from './hooks/useNotisNavigation';
|
|
21
18
|
export { useTopBarSearch } from './hooks/useTopBarSearch';
|
|
22
19
|
export { useBackend } from './hooks/useBackend';
|
|
23
|
-
export { useAppState } from './hooks/useAppState';
|
|
24
20
|
export { useMultiSelect } from './hooks/useMultiSelect';
|
|
25
21
|
|
|
26
22
|
// Multi-select components
|
|
@@ -39,29 +35,12 @@ export type {
|
|
|
39
35
|
export type { MultiSelectCheckboxProps } from './components/MultiSelectCheckbox';
|
|
40
36
|
export type { MultiSelectDragOverlayProps } from './components/MultiSelectDragOverlay';
|
|
41
37
|
|
|
42
|
-
// Property extraction helpers
|
|
43
|
-
export {
|
|
44
|
-
extractText,
|
|
45
|
-
extractSelect,
|
|
46
|
-
extractDate,
|
|
47
|
-
extractNumber,
|
|
48
|
-
extractCheckbox,
|
|
49
|
-
extractMultiSelect,
|
|
50
|
-
extractRelation,
|
|
51
|
-
docTitle,
|
|
52
|
-
} from './helpers';
|
|
53
|
-
|
|
54
38
|
// Types (re-exported for convenience)
|
|
55
39
|
export type {
|
|
56
40
|
AppDescriptor,
|
|
57
|
-
CollectionItem,
|
|
58
|
-
CollectionItemDetail,
|
|
59
|
-
DatabaseDescriptor,
|
|
60
|
-
DatabaseProperty,
|
|
61
|
-
DocumentRecord,
|
|
62
41
|
NotisRuntime,
|
|
63
42
|
NotisRuntimeContext,
|
|
64
|
-
QueryFilter,
|
|
65
43
|
RouteDescriptor,
|
|
66
44
|
ToolDescriptor,
|
|
45
|
+
ToolInputSchema,
|
|
67
46
|
} from './runtime';
|
|
@@ -36,7 +36,7 @@ export function NotisProvider({ children, runtime }: { children: ReactNode; runt
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Returns the raw NotisRuntime or null if not yet available.
|
|
39
|
-
* Prefer the typed hooks (
|
|
39
|
+
* Prefer the typed hooks (useTool, useNotis, etc.) over this.
|
|
40
40
|
*/
|
|
41
41
|
export function useNotisRuntime(): NotisRuntime | null {
|
|
42
42
|
return useContext(NotisContext);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NotisRuntime is the bridge between app code running in the browser and the
|
|
3
|
+
* Notis platform. The portal owns the runtime and injects it through
|
|
4
|
+
* `NotisProvider` when the app is rendered.
|
|
5
|
+
*
|
|
6
|
+
* App code should never reach for globals. Use the hooks from `@notis/sdk`
|
|
7
|
+
* (useTool, useNotis, etc.) which read from the NotisProvider context.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Tool types
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
export type ToolInputSchema = Record<string, unknown>;
|
|
15
|
+
|
|
16
|
+
export interface ToolDescriptor {
|
|
17
|
+
name: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
inputSchema?: ToolInputSchema;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// Route types
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
export interface RouteDescriptor {
|
|
27
|
+
slug: string;
|
|
28
|
+
path: string;
|
|
29
|
+
name: string;
|
|
30
|
+
icon?: string | null;
|
|
31
|
+
parentSlug?: string | null;
|
|
32
|
+
default?: boolean;
|
|
33
|
+
collection?: Record<string, unknown> | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// App descriptor
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
export interface AppDescriptor {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
icon?: string | null;
|
|
44
|
+
description?: string | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type NotisRuntimeContext = Record<string, unknown>;
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// NotisRuntime
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
export interface NotisRuntime {
|
|
54
|
+
app: AppDescriptor;
|
|
55
|
+
route: RouteDescriptor;
|
|
56
|
+
context: NotisRuntimeContext;
|
|
57
|
+
|
|
58
|
+
navigate?: (payload: { kind: string; [key: string]: unknown }) => void;
|
|
59
|
+
|
|
60
|
+
registerTopBarSearch?: (
|
|
61
|
+
config:
|
|
62
|
+
| {
|
|
63
|
+
onChange: (value: string) => void;
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
onSubmit?: () => void | Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
| null,
|
|
68
|
+
) => void;
|
|
69
|
+
setTopBarSearchValue?: (value: string) => void;
|
|
70
|
+
setTopBarSearchLoading?: (loading: boolean) => void;
|
|
71
|
+
|
|
72
|
+
listTools(): Promise<ToolDescriptor[]>;
|
|
73
|
+
callTool<TResult = unknown>(name: string, args?: Record<string, unknown>): Promise<TResult>;
|
|
74
|
+
|
|
75
|
+
request(path: string, options?: {
|
|
76
|
+
method?: string;
|
|
77
|
+
headers?: Record<string, string>;
|
|
78
|
+
body?: unknown;
|
|
79
|
+
}): Promise<unknown>;
|
|
80
|
+
}
|