@agent-native/core 0.90.4 → 0.90.5

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 (86) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/core/CHANGELOG.md +8 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/agent/durable-background.ts +18 -18
  5. package/corpus/core/src/agent/engine/ai-sdk-engine.ts +8 -2
  6. package/corpus/core/src/agent/engine/anthropic-engine.ts +11 -1
  7. package/corpus/core/src/agent/production-agent.ts +22 -11
  8. package/corpus/core/src/agent/run-manager.ts +17 -6
  9. package/corpus/core/src/agent/run-store.ts +16 -11
  10. package/corpus/core/src/cli/design-connect.ts +16 -2
  11. package/corpus/core/src/client/KeepTabOpenNotice.tsx +20 -15
  12. package/corpus/core/src/client/RunStuckBanner.tsx +14 -13
  13. package/corpus/core/src/client/agent-chat-adapter.ts +28 -17
  14. package/corpus/core/src/client/use-run-stuck-detection.ts +8 -5
  15. package/corpus/templates/content/AGENTS.md +1 -0
  16. package/corpus/templates/content/actions/_database-source-utils.ts +73 -8
  17. package/corpus/templates/content/actions/_database-utils.ts +2 -1
  18. package/corpus/templates/content/actions/prepare-builder-source-review.ts +20 -1
  19. package/corpus/templates/content/actions/stage-builder-source-bulk-update.ts +663 -0
  20. package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +33 -7
  21. package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +53 -4
  22. package/corpus/templates/content/app/components/editor/database/settings.tsx +24 -0
  23. package/corpus/templates/content/app/hooks/use-content-database.ts +70 -1
  24. package/corpus/templates/content/app/hooks/use-document-properties.ts +63 -5
  25. package/corpus/templates/content/app/i18n/zh-TW.ts +3 -0
  26. package/corpus/templates/content/app/i18n-data.ts +31 -0
  27. package/corpus/templates/content/changelog/2026-07-01-builder-source-rows-can-be-staged-in-bulk-with-a-reviewable.md +6 -0
  28. package/corpus/templates/content/changelog/2026-07-07-builder-backed-database-fields-now-edit-like-normal-content-fields.md +6 -0
  29. package/corpus/templates/content/parity/matrix.md +24 -24
  30. package/corpus/templates/content/parity/matrix.ts +2 -0
  31. package/corpus/templates/content/shared/api.ts +59 -4
  32. package/corpus/templates/design/actions/connect-localhost.ts +26 -3
  33. package/corpus/templates/design/actions/open-visual-edit.ts +4 -37
  34. package/corpus/templates/design/app/components/design/DesignCanvas.tsx +26 -10
  35. package/corpus/templates/design/changelog/2026-07-07-local-visual-edit-keeps-bridge-access-when-opening-previousl.md +6 -0
  36. package/corpus/templates/design/changelog/2026-07-07-local-visual-edit-now-keeps-the-live-app-connection-authenti.md +6 -0
  37. package/dist/agent/durable-background.d.ts +12 -12
  38. package/dist/agent/durable-background.js +18 -18
  39. package/dist/agent/durable-background.js.map +1 -1
  40. package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
  41. package/dist/agent/engine/ai-sdk-engine.js +8 -2
  42. package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
  43. package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
  44. package/dist/agent/engine/anthropic-engine.js +11 -1
  45. package/dist/agent/engine/anthropic-engine.js.map +1 -1
  46. package/dist/agent/production-agent.d.ts +2 -2
  47. package/dist/agent/production-agent.d.ts.map +1 -1
  48. package/dist/agent/production-agent.js +18 -11
  49. package/dist/agent/production-agent.js.map +1 -1
  50. package/dist/agent/run-manager.d.ts +7 -1
  51. package/dist/agent/run-manager.d.ts.map +1 -1
  52. package/dist/agent/run-manager.js +6 -1
  53. package/dist/agent/run-manager.js.map +1 -1
  54. package/dist/agent/run-store.d.ts +1 -1
  55. package/dist/agent/run-store.d.ts.map +1 -1
  56. package/dist/agent/run-store.js +15 -10
  57. package/dist/agent/run-store.js.map +1 -1
  58. package/dist/cli/design-connect.d.ts.map +1 -1
  59. package/dist/cli/design-connect.js +12 -2
  60. package/dist/cli/design-connect.js.map +1 -1
  61. package/dist/client/KeepTabOpenNotice.d.ts +9 -10
  62. package/dist/client/KeepTabOpenNotice.d.ts.map +1 -1
  63. package/dist/client/KeepTabOpenNotice.js +8 -4
  64. package/dist/client/KeepTabOpenNotice.js.map +1 -1
  65. package/dist/client/RunStuckBanner.d.ts.map +1 -1
  66. package/dist/client/RunStuckBanner.js +14 -13
  67. package/dist/client/RunStuckBanner.js.map +1 -1
  68. package/dist/client/agent-chat-adapter.d.ts.map +1 -1
  69. package/dist/client/agent-chat-adapter.js +25 -17
  70. package/dist/client/agent-chat-adapter.js.map +1 -1
  71. package/dist/client/use-run-stuck-detection.d.ts +1 -1
  72. package/dist/client/use-run-stuck-detection.d.ts.map +1 -1
  73. package/dist/client/use-run-stuck-detection.js +6 -4
  74. package/dist/client/use-run-stuck-detection.js.map +1 -1
  75. package/dist/collab/awareness.d.ts +2 -2
  76. package/dist/collab/awareness.d.ts.map +1 -1
  77. package/dist/collab/routes.d.ts +1 -1
  78. package/dist/collab/struct-routes.d.ts +1 -1
  79. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  80. package/dist/notifications/routes.d.ts +1 -1
  81. package/dist/observability/routes.d.ts +3 -3
  82. package/dist/progress/routes.d.ts +1 -1
  83. package/dist/resources/handlers.d.ts +3 -3
  84. package/dist/secrets/routes.d.ts +9 -9
  85. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  86. package/package.json +1 -1
@@ -302,6 +302,7 @@ export function serializeSourceField(
302
302
 
303
303
  function serializeSourceRowRecord(
304
304
  row: ContentDatabaseSourceRecordRowDb,
305
+ options: { includeHeavyBuilderBodyValues?: boolean } = {},
305
306
  ): ContentDatabaseSourceRow {
306
307
  return {
307
308
  id: row.id,
@@ -310,10 +311,12 @@ function serializeSourceRowRecord(
310
311
  sourceRowId: row.sourceRowId,
311
312
  sourceQualifiedId: row.sourceQualifiedId,
312
313
  sourceDisplayKey: row.sourceDisplayKey,
313
- sourceValues:
314
+ sourceValues: sourceValuesForSnapshot(
314
315
  parseObject<Record<string, DocumentPropertyValue>>(
315
316
  row.sourceValuesJson,
316
317
  ) ?? {},
318
+ options,
319
+ ),
317
320
  provenance: row.provenance,
318
321
  syncState: normalizeSourceSyncState(row.syncState),
319
322
  freshness: normalizeSourceFreshness(row.freshness),
@@ -322,6 +325,27 @@ function serializeSourceRowRecord(
322
325
  };
323
326
  }
324
327
 
328
+ const HEAVY_BUILDER_BODY_SOURCE_VALUE_KEYS = new Set([
329
+ BUILDER_CMS_BODY_CONTENT_KEY,
330
+ BUILDER_CMS_BODY_LOSSLESS_CONTENT_KEY,
331
+ BUILDER_CMS_BODY_READABLE_MAP_KEY,
332
+ BUILDER_CMS_BODY_SIDECARS_KEY,
333
+ ]);
334
+
335
+ export function sourceValuesForSnapshot(
336
+ sourceValues: Record<string, DocumentPropertyValue>,
337
+ options: { includeHeavyBuilderBodyValues?: boolean } = {},
338
+ ): Record<string, DocumentPropertyValue> {
339
+ if (options.includeHeavyBuilderBodyValues === true) return sourceValues;
340
+ let next: Record<string, DocumentPropertyValue> | null = null;
341
+ for (const key of HEAVY_BUILDER_BODY_SOURCE_VALUE_KEYS) {
342
+ if (!Object.prototype.hasOwnProperty.call(sourceValues, key)) continue;
343
+ next ??= { ...sourceValues };
344
+ delete next[key];
345
+ }
346
+ return next ?? sourceValues;
347
+ }
348
+
325
349
  function serializeSourceChangeSet(
326
350
  row: ContentDatabaseSourceChangeSetRowDb,
327
351
  ): ContentDatabaseSourceChangeSet {
@@ -1919,7 +1943,9 @@ export async function getContentDatabaseSourceSnapshot(
1919
1943
  asc(schema.contentDatabaseSources.id),
1920
1944
  );
1921
1945
  if (!source) return null;
1922
- return loadSourceSnapshot(source, database);
1946
+ return loadSourceSnapshot(source, database, {
1947
+ includeHeavyBuilderBodyValues: false,
1948
+ });
1923
1949
  }
1924
1950
 
1925
1951
  /**
@@ -1942,7 +1968,9 @@ export async function getContentDatabaseSourceSnapshotById(
1942
1968
  ),
1943
1969
  );
1944
1970
  if (!source) return null;
1945
- return loadSourceSnapshot(source, database);
1971
+ return loadSourceSnapshot(source, database, {
1972
+ includeHeavyBuilderBodyValues: false,
1973
+ });
1946
1974
  }
1947
1975
 
1948
1976
  /**
@@ -1955,9 +1983,37 @@ export async function getContentDatabaseSourceSnapshotForWrite(
1955
1983
  database: ContentDatabaseRow | ContentDatabase,
1956
1984
  sourceId?: string | null,
1957
1985
  ): Promise<ContentDatabaseSource | null> {
1958
- return sourceId
1959
- ? getContentDatabaseSourceSnapshotById(database, sourceId)
1960
- : getContentDatabaseSourceSnapshot(database);
1986
+ if (sourceId) {
1987
+ const db = getDb();
1988
+ const [source] = await db
1989
+ .select()
1990
+ .from(schema.contentDatabaseSources)
1991
+ .where(
1992
+ and(
1993
+ eq(schema.contentDatabaseSources.id, sourceId),
1994
+ eq(schema.contentDatabaseSources.databaseId, database.id),
1995
+ ),
1996
+ );
1997
+ return source
1998
+ ? loadSourceSnapshot(source, database, {
1999
+ includeHeavyBuilderBodyValues: true,
2000
+ })
2001
+ : null;
2002
+ }
2003
+ const db = getDb();
2004
+ const [source] = await db
2005
+ .select()
2006
+ .from(schema.contentDatabaseSources)
2007
+ .where(eq(schema.contentDatabaseSources.databaseId, database.id))
2008
+ .orderBy(
2009
+ asc(schema.contentDatabaseSources.createdAt),
2010
+ asc(schema.contentDatabaseSources.id),
2011
+ );
2012
+ return source
2013
+ ? loadSourceSnapshot(source, database, {
2014
+ includeHeavyBuilderBodyValues: true,
2015
+ })
2016
+ : null;
1961
2017
  }
1962
2018
 
1963
2019
  /**
@@ -1982,7 +2038,11 @@ export async function getAllContentDatabaseSourceSnapshots(
1982
2038
  );
1983
2039
  const snapshots: ContentDatabaseSource[] = [];
1984
2040
  for (const source of sources) {
1985
- snapshots.push(await loadSourceSnapshot(source, database));
2041
+ snapshots.push(
2042
+ await loadSourceSnapshot(source, database, {
2043
+ includeHeavyBuilderBodyValues: false,
2044
+ }),
2045
+ );
1986
2046
  }
1987
2047
  return snapshots;
1988
2048
  }
@@ -2135,6 +2195,7 @@ async function loadSourceSnapshotRowsOptimistically(args: {
2135
2195
  async function loadSourceSnapshot(
2136
2196
  source: ContentDatabaseSourceRowDb,
2137
2197
  database: ContentDatabaseRow | ContentDatabase,
2198
+ options: { includeHeavyBuilderBodyValues: boolean },
2138
2199
  ): Promise<ContentDatabaseSource> {
2139
2200
  const db = getDb();
2140
2201
  const [fieldRows, changeRows, reviewRows, executionRows, propertyDefs] =
@@ -2218,7 +2279,11 @@ async function loadSourceSnapshot(
2218
2279
  database,
2219
2280
  isBuilderSource,
2220
2281
  });
2221
- const rows = rowRows.map(serializeSourceRowRecord);
2282
+ const rows = rowRows.map((row) =>
2283
+ serializeSourceRowRecord(row, {
2284
+ includeHeavyBuilderBodyValues: options.includeHeavyBuilderBodyValues,
2285
+ }),
2286
+ );
2222
2287
  const documentTitleById = new Map(
2223
2288
  rowDocuments.map((document) => [document.id, document.title]),
2224
2289
  );
@@ -123,12 +123,13 @@ export function normalizeContentDatabasePageOptions(options: {
123
123
  function serializeDocument(
124
124
  doc: typeof schema.documents.$inferSelect,
125
125
  membership?: DatabaseMembershipRow,
126
+ options: { includeContent?: boolean } = {},
126
127
  ) {
127
128
  return {
128
129
  id: doc.id,
129
130
  parentId: doc.parentId,
130
131
  title: doc.title,
131
- content: doc.content,
132
+ content: options.includeContent === true ? doc.content : "",
132
133
  icon: doc.icon,
133
134
  position: doc.position,
134
135
  isFavorite: parseDocumentFavorite(doc.isFavorite),
@@ -382,6 +382,11 @@ export default defineAction({
382
382
  .string()
383
383
  .optional()
384
384
  .describe("Target source ID (defaults to the primary source)"),
385
+ changeSetIds: z
386
+ .array(z.string())
387
+ .max(BUILDER_SOURCE_REVIEW_PREPARE_LIMIT)
388
+ .optional()
389
+ .describe("Optional bounded set of Builder change-set IDs to prepare"),
385
390
  pushModeConfirmation: z
386
391
  .enum(["autosave", "draft", "publish"])
387
392
  .optional()
@@ -409,13 +414,27 @@ export default defineAction({
409
414
  if (!snapshot || snapshot.sourceType !== "builder-cms") {
410
415
  throw new Error("Attach a Builder CMS source before reviewing updates.");
411
416
  }
417
+ const requestedIds = new Set(args.changeSetIds ?? []);
412
418
  const allReviewableChanges = snapshot.changeSets.filter(
413
419
  (changeSet) =>
414
420
  changeSet.direction === "outbound" &&
415
421
  (changeSet.state === "pending_push" ||
416
422
  changeSet.state === "staged_revision" ||
417
- changeSet.state === "approved"),
423
+ changeSet.state === "approved") &&
424
+ (requestedIds.size === 0 || requestedIds.has(changeSet.id)),
418
425
  );
426
+ if (
427
+ requestedIds.size > 0 &&
428
+ allReviewableChanges.length !== requestedIds.size
429
+ ) {
430
+ const foundIds = new Set(
431
+ allReviewableChanges.map((changeSet) => changeSet.id),
432
+ );
433
+ const missingIds = [...requestedIds].filter((id) => !foundIds.has(id));
434
+ throw new Error(
435
+ `Requested Builder change-set is not reviewable: ${missingIds.join(", ")}.`,
436
+ );
437
+ }
419
438
  if (allReviewableChanges.length === 0) {
420
439
  throw new Error("No pending local Builder changes to review.");
421
440
  }