@agent-native/core 0.119.6 → 0.120.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 (44) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +12 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/cli/index.ts +64 -3
  5. package/corpus/core/src/templates/default/package.json +1 -1
  6. package/corpus/templates/assets/package.json +1 -1
  7. package/corpus/templates/brain/package.json +1 -1
  8. package/corpus/templates/calendar/package.json +1 -1
  9. package/corpus/templates/clips/package.json +1 -1
  10. package/corpus/templates/content/actions/add-database-item.ts +1 -0
  11. package/corpus/templates/content/actions/set-document-property.ts +0 -4
  12. package/corpus/templates/content/app/components/editor/DocumentBlockFields.tsx +10 -1
  13. package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +10 -4
  14. package/corpus/templates/content/app/components/editor/DocumentInfoPanel.tsx +5 -1
  15. package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +6 -0
  16. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +52 -33
  17. package/corpus/templates/content/app/components/editor/previewDocumentSaveController.ts +16 -4
  18. package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +16 -7
  19. package/corpus/templates/content/app/hooks/use-create-page.ts +8 -3
  20. package/corpus/templates/content/app/hooks/use-document-properties.ts +1 -0
  21. package/corpus/templates/content/app/hooks/use-documents.ts +3 -1
  22. package/corpus/templates/content/app/lib/optimistic-document.ts +29 -0
  23. package/corpus/templates/content/changelog/2026-07-21-editing-a-database-property-no-longer-refreshes-unrelated-co.md +6 -0
  24. package/corpus/templates/content/changelog/2026-07-23-new-database-ready.md +6 -0
  25. package/corpus/templates/content/package.json +1 -1
  26. package/corpus/templates/content/shared/api.ts +1 -0
  27. package/corpus/templates/design/package.json +1 -1
  28. package/corpus/templates/dispatch/package.json +1 -1
  29. package/corpus/templates/forms/package.json +1 -1
  30. package/corpus/templates/macros/package.json +1 -1
  31. package/corpus/templates/mail/package.json +1 -1
  32. package/corpus/templates/slides/package.json +1 -1
  33. package/dist/cli/index.js +53 -2
  34. package/dist/cli/index.js.map +1 -1
  35. package/dist/collab/struct-routes.d.ts +1 -1
  36. package/dist/notifications/routes.d.ts +3 -3
  37. package/dist/observability/routes.d.ts +2 -2
  38. package/dist/progress/routes.d.ts +1 -1
  39. package/dist/secrets/routes.d.ts +3 -3
  40. package/dist/server/realtime-token.d.ts +1 -1
  41. package/dist/templates/default/package.json +1 -1
  42. package/package.json +1 -1
  43. package/src/cli/index.ts +64 -3
  44. package/src/templates/default/package.json +1 -1
@@ -12,6 +12,7 @@ import {
12
12
  import { useContentSpaces } from "@/hooks/use-content-spaces";
13
13
  import { useCreateDocument } from "@/hooks/use-documents";
14
14
  import { useLocalStorage } from "@/hooks/use-local-storage";
15
+ import { markDocumentCreationPending } from "@/lib/optimistic-document";
15
16
 
16
17
  const LIST_DOCUMENTS_QUERY_KEY = [
17
18
  "action",
@@ -63,7 +64,7 @@ export function useCreatePage(opts?: {
63
64
  }
64
65
  const id = nanoid();
65
66
  const now = new Date().toISOString();
66
- const tempDoc: Document = {
67
+ const tempDoc = markDocumentCreationPending({
67
68
  id,
68
69
  parentId: parentId ?? null,
69
70
  title: "",
@@ -75,7 +76,7 @@ export function useCreatePage(opts?: {
75
76
  visibility: "private",
76
77
  createdAt: now,
77
78
  updatedAt: now,
78
- };
79
+ });
79
80
 
80
81
  queryClient.setQueryData(LIST_DOCUMENTS_QUERY_KEY, (old: any) => {
81
82
  const docs: Document[] =
@@ -90,12 +91,16 @@ export function useCreatePage(opts?: {
90
91
  }
91
92
 
92
93
  const persist = async () => {
93
- await createDocument.mutateAsync({
94
+ const created = await createDocument.mutateAsync({
94
95
  id,
95
96
  title: "",
96
97
  parentId: parentId ?? undefined,
97
98
  spaceId,
98
99
  });
100
+ queryClient.setQueryData(
101
+ ["action", "get-document", { id: created.id }],
102
+ created,
103
+ );
99
104
  // Replace optimistic doc with real server doc + clear any 404 error
100
105
  // state from the in-flight fetch that ran before create completed.
101
106
  queryClient.invalidateQueries({
@@ -70,6 +70,7 @@ export function useSetDocumentProperty(
70
70
  DocumentPropertiesResponse,
71
71
  SetDocumentPropertyRequest
72
72
  >("set-document-property", {
73
+ skipActionQueryInvalidation: true,
73
74
  onMutate: async (variables) => {
74
75
  await queryClient.cancelQueries(
75
76
  contentDatabaseQueryFilter(databaseDocumentId),
@@ -342,7 +342,9 @@ export function useUpdatePreviewDocumentDraft() {
342
342
  expectedTitle: string;
343
343
  expectedContent: string;
344
344
  }
345
- >("update-preview-document-draft");
345
+ >("update-preview-document-draft", {
346
+ skipActionQueryInvalidation: true,
347
+ });
346
348
  }
347
349
 
348
350
  export function useCreateDocument() {
@@ -0,0 +1,29 @@
1
+ import type { Document } from "@shared/api";
2
+
3
+ const pendingDocumentCreation = Symbol("pendingDocumentCreation");
4
+
5
+ type PendingDocument = Document & {
6
+ [pendingDocumentCreation]?: true;
7
+ };
8
+
9
+ export function markDocumentCreationPending(document: Document): Document {
10
+ return Object.assign(document, { [pendingDocumentCreation]: true as const });
11
+ }
12
+
13
+ export function isDocumentCreationPending(document: Document): boolean {
14
+ return (document as PendingDocument)[pendingDocumentCreation] === true;
15
+ }
16
+
17
+ export function isDatabaseChoicePending(
18
+ document: Document,
19
+ databaseCreationPending: boolean,
20
+ ): boolean {
21
+ return databaseCreationPending || isDocumentCreationPending(document);
22
+ }
23
+
24
+ export function shouldCreateDocumentOptimistically(args: {
25
+ localFileMode: boolean;
26
+ filesDatabaseId?: string;
27
+ }): boolean {
28
+ return !args.localFileMode || Boolean(args.filesDatabaseId);
29
+ }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-07-21
4
+ ---
5
+
6
+ Editing a database page no longer refreshes unrelated Content workspace data or interrupts typing in the originating tab.
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: fixed
3
+ date: 2026-07-23
4
+ ---
5
+
6
+ New pages wait until they are ready before offering database conversion.
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "dev:database": "node scripts/check-native-deps.mjs && node scripts/dev-database.mjs",
9
9
  "build": "agent-native build",
10
10
  "start": "agent-native start",
@@ -749,6 +749,7 @@ export interface ContentDatabaseResponse {
749
749
  };
750
750
  createdItemId?: string;
751
751
  createdDocumentId?: string;
752
+ createdDocumentUpdatedAt?: string;
752
753
  duplicatedItemId?: string;
753
754
  duplicatedDocumentId?: string;
754
755
  duplicatedItemIds?: string[];
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "build": "agent-native build",
9
9
  "start": "agent-native start",
10
10
  "test": "vitest --run",
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "build": "agent-native build",
9
9
  "start": "agent-native start",
10
10
  "typecheck": "agent-native typecheck",
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "build": "agent-native build",
9
9
  "start": "agent-native start",
10
10
  "format.fix": "oxfmt --write .",
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "build": "agent-native build",
9
9
  "start": "agent-native start",
10
10
  "test": "vitest --run --passWithNoTests",
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "build": "agent-native build",
9
9
  "start": "agent-native start",
10
10
  "test": "vitest --run",
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "dev": "agent-native dev",
7
+ "dev": "agent-native dev --inspect",
8
8
  "build": "agent-native build",
9
9
  "start": "agent-native start",
10
10
  "test": "vitest --run",
package/dist/cli/index.js CHANGED
@@ -241,6 +241,21 @@ function findBinUpwards(binName) {
241
241
  function findViteBin() {
242
242
  return findBinUpwards("vite") ?? "vite";
243
243
  }
244
+ function findViteJsEntry() {
245
+ try {
246
+ const require = createRequire(path.join(process.cwd(), "package.json"));
247
+ const pkgJsonPath = require.resolve("vite/package.json");
248
+ const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
249
+ const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.vite;
250
+ if (!rel)
251
+ return null;
252
+ const entry = path.join(path.dirname(pkgJsonPath), rel);
253
+ return fs.existsSync(entry) ? entry : null;
254
+ }
255
+ catch {
256
+ return null;
257
+ }
258
+ }
244
259
  function findTsxBin() {
245
260
  const localTsx = path.resolve("node_modules/.bin/tsx");
246
261
  if (fs.existsSync(localTsx))
@@ -336,11 +351,23 @@ function isWorkspaceRoot() {
336
351
  return false;
337
352
  }
338
353
  }
354
+ function extractNodeInspectFlag(args) {
355
+ const rest = [];
356
+ let inspectFlag = null;
357
+ for (const arg of args) {
358
+ if (/^--inspect(-brk)?(=.+)?$/.test(arg)) {
359
+ inspectFlag = arg;
360
+ continue;
361
+ }
362
+ rest.push(arg);
363
+ }
364
+ return { inspectFlag, rest };
365
+ }
339
366
  function run(cmd, cmdArgs, opts) {
340
367
  const child = spawn(cmd, cmdArgs, {
341
368
  stdio: opts?.stdio ?? "inherit",
342
369
  shell: process.platform === "win32",
343
- env: process.env,
370
+ env: opts?.env ?? process.env,
344
371
  });
345
372
  child.on("exit", (code) => process.exit(code ?? 0));
346
373
  // Forward signals to child so Cmd+C doesn't leave zombie processes holding ports
@@ -475,7 +502,31 @@ switch (command) {
475
502
  break;
476
503
  }
477
504
  const vite = findViteBin();
478
- run(vite, args);
505
+ const { inspectFlag, rest } = extractNodeInspectFlag(args);
506
+ if (!inspectFlag) {
507
+ run(vite, rest);
508
+ break;
509
+ }
510
+ const viteJsEntry = findViteJsEntry();
511
+ if (!viteJsEntry) {
512
+ console.warn("[agent-native] Could not resolve Vite's JS entry; starting dev " +
513
+ "server without the debugger.");
514
+ run(vite, rest);
515
+ break;
516
+ }
517
+ // Attach inspect flag to server process (not Vite or Nitro process)
518
+ const parsed = inspectFlag.match(/^--(inspect(?:-brk)?)(?:=(.+))?$/);
519
+ const kind = parsed?.[1] ?? "inspect";
520
+ const target = parsed?.[2] ?? "9229";
521
+ const directive = `--${kind}=${target}`;
522
+ const preload = "data:text/javascript," +
523
+ encodeURIComponent(`process.env.NODE_OPTIONS=((process.env.NODE_OPTIONS??"")+" ${directive}").trim();`);
524
+ const env = {
525
+ ...process.env,
526
+ NITRO_DEV_RUNNER: process.env.NITRO_DEV_RUNNER ?? "node-process",
527
+ };
528
+ console.log(`[agent-native] API server debugger listening on ${target}`);
529
+ run(process.execPath, ["--import", preload, viteJsEntry, ...rest], { env });
479
530
  break;
480
531
  }
481
532
  case "workspace-dev": {