@agent-native/core 0.119.4 → 0.119.6

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 (150) hide show
  1. package/corpus/README.md +2 -2
  2. package/corpus/core/CHANGELOG.md +14 -0
  3. package/corpus/core/package.json +1 -1
  4. package/corpus/core/src/agent/durable-background.ts +1 -0
  5. package/corpus/core/src/agent/engine/index.ts +2 -0
  6. package/corpus/core/src/agent/engine/registry.ts +95 -2
  7. package/corpus/core/src/deploy/build.ts +144 -2
  8. package/corpus/core/src/deploy/workspace-deploy.ts +123 -1
  9. package/corpus/core/src/integrations/integration-durable-dispatch-config.ts +22 -0
  10. package/corpus/core/src/integrations/integration-durable-dispatch.ts +190 -0
  11. package/corpus/core/src/integrations/pending-tasks-retry-job.ts +175 -87
  12. package/corpus/core/src/integrations/pending-tasks-store.ts +114 -11
  13. package/corpus/core/src/integrations/plugin.ts +113 -60
  14. package/corpus/core/src/integrations/task-queue-stats.ts +68 -15
  15. package/corpus/core/src/integrations/webhook-handler.ts +21 -46
  16. package/corpus/core/src/scripts/agent-engines/list-agent-engines.ts +8 -0
  17. package/corpus/core/src/scripts/agent-engines/manage-agent-engine.ts +5 -1
  18. package/corpus/core/src/scripts/agent-engines/set-agent-engine.ts +9 -1
  19. package/corpus/core/src/server/auth.ts +6 -0
  20. package/corpus/core/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +63 -22
  21. package/corpus/core/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +63 -22
  22. package/corpus/core/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +63 -22
  23. package/corpus/templates/dispatch/changelog/2026-07-21-recover-stalled-slack-agent-work.md +6 -0
  24. package/corpus/templates/slides/actions/patch-deck.ts +2 -1
  25. package/corpus/templates/slides/changelog/2026-07-23-opening-or-refining-a-deck-no-longer-crashes-with-a-blank-er.md +6 -0
  26. package/corpus/templates/slides/shared/aspect-ratios.ts +4 -1
  27. package/corpus/templates/tasks/.oxfmtrc.json +8 -0
  28. package/corpus/templates/tasks/AGENTS.md +34 -41
  29. package/corpus/templates/tasks/README.md +13 -6
  30. package/corpus/templates/tasks/actions/bulk-delete-inbox-items.ts +10 -8
  31. package/corpus/templates/tasks/actions/bulk-delete-tasks.ts +10 -8
  32. package/corpus/templates/tasks/actions/bulk-mark-inbox-items-ready.ts +1 -1
  33. package/corpus/templates/tasks/actions/bulk-update-tasks.ts +12 -10
  34. package/corpus/templates/tasks/actions/create-inbox-item.ts +7 -4
  35. package/corpus/templates/tasks/actions/create-task.ts +2 -1
  36. package/corpus/templates/tasks/actions/delete-inbox-item.ts +6 -4
  37. package/corpus/templates/tasks/actions/delete-task.ts +1 -1
  38. package/corpus/templates/tasks/actions/list-inbox-items.ts +4 -2
  39. package/corpus/templates/tasks/actions/list-visible-task-fields.ts +3 -1
  40. package/corpus/templates/tasks/actions/mark-inbox-item-ready.ts +6 -4
  41. package/corpus/templates/tasks/actions/navigate.ts +16 -14
  42. package/corpus/templates/tasks/actions/reorder-inbox-items.ts +9 -7
  43. package/corpus/templates/tasks/actions/update-inbox-item.ts +6 -4
  44. package/corpus/templates/tasks/actions/update-task.ts +12 -9
  45. package/corpus/templates/tasks/actions/update-visible-task-fields.ts +10 -8
  46. package/corpus/templates/tasks/actions/view-screen.ts +1 -1
  47. package/corpus/templates/tasks/app/components/tasks/fields/TaskFieldsSidebar.tsx +15 -0
  48. package/corpus/templates/tasks/changelog/2026-07-23-task-detail-extensions.md +6 -0
  49. package/corpus/templates/tasks/drizzle.config.ts +3 -0
  50. package/corpus/templates/tasks/package.json +4 -1
  51. package/corpus/templates/tasks/server/db/schema.ts +0 -10
  52. package/corpus/templates/tasks/server/db/test-tasks-table.ts +0 -5
  53. package/corpus/templates/tasks/server/plugins/agent-chat.ts +1 -1
  54. package/corpus/templates/tasks/server/plugins/db.ts +43 -10
  55. package/corpus/templates/tasks/server/user-config/store.ts +42 -81
  56. package/corpus/templates/tasks/tsconfig.json +1 -2
  57. package/corpus/templates/tasks/vitest.config.ts +10 -1
  58. package/dist/agent/durable-background.d.ts +1 -0
  59. package/dist/agent/durable-background.d.ts.map +1 -1
  60. package/dist/agent/durable-background.js +1 -0
  61. package/dist/agent/durable-background.js.map +1 -1
  62. package/dist/agent/engine/index.d.ts +1 -1
  63. package/dist/agent/engine/index.d.ts.map +1 -1
  64. package/dist/agent/engine/index.js +1 -1
  65. package/dist/agent/engine/index.js.map +1 -1
  66. package/dist/agent/engine/registry.d.ts +32 -1
  67. package/dist/agent/engine/registry.d.ts.map +1 -1
  68. package/dist/agent/engine/registry.js +75 -3
  69. package/dist/agent/engine/registry.js.map +1 -1
  70. package/dist/deploy/build.d.ts +3 -0
  71. package/dist/deploy/build.d.ts.map +1 -1
  72. package/dist/deploy/build.js +106 -3
  73. package/dist/deploy/build.js.map +1 -1
  74. package/dist/deploy/workspace-deploy.d.ts.map +1 -1
  75. package/dist/deploy/workspace-deploy.js +103 -2
  76. package/dist/deploy/workspace-deploy.js.map +1 -1
  77. package/dist/file-upload/actions/upload-image.d.ts +1 -1
  78. package/dist/integrations/integration-durable-dispatch-config.d.ts +7 -0
  79. package/dist/integrations/integration-durable-dispatch-config.d.ts.map +1 -0
  80. package/dist/integrations/integration-durable-dispatch-config.js +16 -0
  81. package/dist/integrations/integration-durable-dispatch-config.js.map +1 -0
  82. package/dist/integrations/integration-durable-dispatch.d.ts +23 -0
  83. package/dist/integrations/integration-durable-dispatch.d.ts.map +1 -0
  84. package/dist/integrations/integration-durable-dispatch.js +115 -0
  85. package/dist/integrations/integration-durable-dispatch.js.map +1 -0
  86. package/dist/integrations/pending-tasks-retry-job.d.ts +13 -1
  87. package/dist/integrations/pending-tasks-retry-job.d.ts.map +1 -1
  88. package/dist/integrations/pending-tasks-retry-job.js +133 -74
  89. package/dist/integrations/pending-tasks-retry-job.js.map +1 -1
  90. package/dist/integrations/pending-tasks-store.d.ts +14 -2
  91. package/dist/integrations/pending-tasks-store.d.ts.map +1 -1
  92. package/dist/integrations/pending-tasks-store.js +75 -11
  93. package/dist/integrations/pending-tasks-store.js.map +1 -1
  94. package/dist/integrations/plugin.d.ts.map +1 -1
  95. package/dist/integrations/plugin.js +88 -55
  96. package/dist/integrations/plugin.js.map +1 -1
  97. package/dist/integrations/task-queue-stats.d.ts +15 -3
  98. package/dist/integrations/task-queue-stats.d.ts.map +1 -1
  99. package/dist/integrations/task-queue-stats.js +45 -15
  100. package/dist/integrations/task-queue-stats.js.map +1 -1
  101. package/dist/integrations/webhook-handler.d.ts +1 -1
  102. package/dist/integrations/webhook-handler.d.ts.map +1 -1
  103. package/dist/integrations/webhook-handler.js +18 -42
  104. package/dist/integrations/webhook-handler.js.map +1 -1
  105. package/dist/notifications/routes.d.ts +2 -2
  106. package/dist/observability/routes.d.ts +5 -5
  107. package/dist/progress/routes.d.ts +1 -1
  108. package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
  109. package/dist/provider-api/actions/provider-api.d.ts +4 -4
  110. package/dist/resources/handlers.d.ts +1 -1
  111. package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
  112. package/dist/scripts/agent-engines/list-agent-engines.js +8 -2
  113. package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
  114. package/dist/scripts/agent-engines/manage-agent-engine.d.ts.map +1 -1
  115. package/dist/scripts/agent-engines/manage-agent-engine.js +5 -2
  116. package/dist/scripts/agent-engines/manage-agent-engine.js.map +1 -1
  117. package/dist/scripts/agent-engines/set-agent-engine.d.ts.map +1 -1
  118. package/dist/scripts/agent-engines/set-agent-engine.js +9 -2
  119. package/dist/scripts/agent-engines/set-agent-engine.js.map +1 -1
  120. package/dist/secrets/routes.d.ts +3 -3
  121. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  122. package/dist/server/auth.d.ts.map +1 -1
  123. package/dist/server/auth.js +5 -0
  124. package/dist/server/auth.js.map +1 -1
  125. package/dist/server/realtime-token.d.ts +1 -1
  126. package/dist/server/transcribe-voice.d.ts +1 -1
  127. package/dist/templates/default/.agents/skills/integration-webhooks/SKILL.md +63 -22
  128. package/dist/templates/headless/.agents/skills/integration-webhooks/SKILL.md +63 -22
  129. package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +63 -22
  130. package/package.json +1 -1
  131. package/src/agent/durable-background.ts +1 -0
  132. package/src/agent/engine/index.ts +2 -0
  133. package/src/agent/engine/registry.ts +95 -2
  134. package/src/deploy/build.ts +144 -2
  135. package/src/deploy/workspace-deploy.ts +123 -1
  136. package/src/integrations/integration-durable-dispatch-config.ts +22 -0
  137. package/src/integrations/integration-durable-dispatch.ts +190 -0
  138. package/src/integrations/pending-tasks-retry-job.ts +175 -87
  139. package/src/integrations/pending-tasks-store.ts +114 -11
  140. package/src/integrations/plugin.ts +113 -60
  141. package/src/integrations/task-queue-stats.ts +68 -15
  142. package/src/integrations/webhook-handler.ts +21 -46
  143. package/src/scripts/agent-engines/list-agent-engines.ts +8 -0
  144. package/src/scripts/agent-engines/manage-agent-engine.ts +5 -1
  145. package/src/scripts/agent-engines/set-agent-engine.ts +9 -1
  146. package/src/server/auth.ts +6 -0
  147. package/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +63 -22
  148. package/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +63 -22
  149. package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +63 -22
  150. package/corpus/templates/tasks/.prettierrc +0 -5
@@ -4,16 +4,18 @@ import { z } from "zod";
4
4
  import { reorderInboxItems, requireUserEmail } from "../server/inbox/store.js";
5
5
  import { BULK_ID_LIMIT } from "../shared/bulk-limits.js";
6
6
 
7
+ export const reorderInboxItemsSchema = z.object({
8
+ inboxItemIds: z
9
+ .array(z.string())
10
+ .min(1)
11
+ .max(BULK_ID_LIMIT)
12
+ .describe("Inbox item ids in the desired order from top to bottom."),
13
+ });
14
+
7
15
  export default defineAction({
8
16
  description:
9
17
  "Reorder the inbox list by passing inbox item ids top-to-bottom.",
10
- schema: z.object({
11
- inboxItemIds: z
12
- .array(z.string())
13
- .min(1)
14
- .max(BULK_ID_LIMIT)
15
- .describe("Inbox item ids in the desired order from top to bottom."),
16
- }),
18
+ schema: reorderInboxItemsSchema,
17
19
  run: async (args, ctx) => {
18
20
  const ownerEmail = requireUserEmail(ctx?.userEmail);
19
21
  return reorderInboxItems({
@@ -4,12 +4,14 @@ import { z } from "zod";
4
4
  import { UserInputError } from "../server/errors.js";
5
5
  import { requireUserEmail, updateInboxItem } from "../server/inbox/store.js";
6
6
 
7
+ export const updateInboxItemSchema = z.object({
8
+ inboxItemId: z.string().describe("Inbox item id"),
9
+ title: z.string().min(1).optional().describe("New inbox item title"),
10
+ });
11
+
7
12
  export default defineAction({
8
13
  description: "Update an inbox item title.",
9
- schema: z.object({
10
- inboxItemId: z.string().describe("Inbox item id"),
11
- title: z.string().min(1).optional().describe("New inbox item title"),
12
- }),
14
+ schema: updateInboxItemSchema,
13
15
  run: async (args, ctx) => {
14
16
  const ownerEmail = requireUserEmail(ctx?.userEmail);
15
17
  if (args.title === undefined) {
@@ -25,16 +25,19 @@ const fieldValuesSchema: z.ZodType<FieldValuePatch[]> = z.preprocess(
25
25
  z.array(fieldValuePatchSchema),
26
26
  );
27
27
 
28
+ export const updateTaskSchema = z.object({
29
+ taskId: z.string().describe("Task id"),
30
+ title: z.string().min(1).optional().describe("New task title"),
31
+ done: z.boolean().optional().describe("Completion state"),
32
+ fieldValues: fieldValuesSchema
33
+ .optional()
34
+ .describe("Custom field values to set or clear for this task"),
35
+ });
36
+
28
37
  export default defineAction({
29
- description: "Update a task title, completion state, and/or custom fields.",
30
- schema: z.object({
31
- taskId: z.string().describe("Task id"),
32
- title: z.string().min(1).optional().describe("New task title"),
33
- done: z.boolean().optional().describe("Completion state"),
34
- fieldValues: fieldValuesSchema
35
- .optional()
36
- .describe("Custom field values to set or clear for this task"),
37
- }),
38
+ description:
39
+ "Update one task's title, completion state, and/or custom fields. Use bulk-update-tasks to apply the same title or completion state to multiple tasks.",
40
+ schema: updateTaskSchema,
38
41
  run: async (args, ctx) => {
39
42
  const ownerEmail = requireUserEmail(ctx?.userEmail);
40
43
  if (
@@ -5,17 +5,19 @@ import { requireUserEmail } from "../server/custom-fields/store.js";
5
5
  import { setTaskCardFieldIds } from "../server/user-config/store.js";
6
6
  import { TASK_CARD_FIELD_LIMIT } from "../shared/visible-task-fields.js";
7
7
 
8
+ export const updateVisibleTaskFieldsSchema = z.object({
9
+ fieldIds: z
10
+ .array(z.string())
11
+ .max(TASK_CARD_FIELD_LIMIT)
12
+ .describe(
13
+ `Field ids to show on task cards, top-to-bottom. Max ${TASK_CARD_FIELD_LIMIT}.`,
14
+ ),
15
+ });
16
+
8
17
  export default defineAction({
9
18
  description:
10
19
  "Replace the custom fields shown on task cards for the current user.",
11
- schema: z.object({
12
- fieldIds: z
13
- .array(z.string())
14
- .max(TASK_CARD_FIELD_LIMIT)
15
- .describe(
16
- `Field ids to show on task cards, top-to-bottom. Max ${TASK_CARD_FIELD_LIMIT}.`,
17
- ),
18
- }),
20
+ schema: updateVisibleTaskFieldsSchema,
19
21
  run: async (args, ctx) => {
20
22
  const ownerEmail = requireUserEmail(ctx?.userEmail);
21
23
  const fieldIds = await setTaskCardFieldIds({
@@ -89,7 +89,7 @@ async function readParsedAppState<T>(
89
89
 
90
90
  export default defineAction({
91
91
  description:
92
- "See what the user is currently looking at on screen. Returns navigation state, UI bulk selection on /tasks or /inbox when active, visible list snapshot, and selected item. Always call this first before ambiguous task or inbox edits.",
92
+ "Inspect the current Tasks screen. Returns navigation, visible items, the selected item, and active bulk selection.",
93
93
  schema: z.object({}),
94
94
  http: false,
95
95
  readOnly: true,
@@ -1,3 +1,4 @@
1
+ import { ExtensionSlot } from "@agent-native/core/client/extensions";
1
2
  import { useT } from "@agent-native/core/client/i18n";
2
3
  import { useCallback } from "react";
3
4
  import { toast } from "sonner";
@@ -76,6 +77,20 @@ function TaskFieldsSidebarPanel({ task }: { task: TaskWithFields }) {
76
77
  />
77
78
  ))
78
79
  )}
80
+
81
+ {/* Stable extension contract: changing this slot id or context requires a migration. */}
82
+ <ExtensionSlot
83
+ id="tasks.task-detail.bottom"
84
+ context={{
85
+ taskId: task.id,
86
+ title: task.title,
87
+ done: task.done,
88
+ fieldValues: fields.map((field) => ({
89
+ fieldId: field.id,
90
+ value: field.value ?? null,
91
+ })),
92
+ }}
93
+ />
79
94
  </div>
80
95
  );
81
96
  }
@@ -0,0 +1,6 @@
1
+ ---
2
+ type: added
3
+ date: 2026-07-23
4
+ ---
5
+
6
+ Task detail panels can now host installed extension widgets.
@@ -0,0 +1,3 @@
1
+ import { createDrizzleConfig } from "@agent-native/core/db/drizzle-config";
2
+
3
+ export default createDrizzleConfig();
@@ -12,6 +12,8 @@
12
12
  "typecheck": "agent-native typecheck",
13
13
  "action": "agent-native action",
14
14
  "script": "agent-native script",
15
+ "db:push": "drizzle-kit push",
16
+ "db:generate": "drizzle-kit generate",
15
17
  "test": "vitest --run --config vitest.config.ts",
16
18
  "test:e2e": "playwright test",
17
19
  "test:e2e:install": "playwright install chromium",
@@ -26,6 +28,7 @@
26
28
  "@fontsource-variable/inter": "^5.2.8",
27
29
  "@libsql/client": "^0.15.8",
28
30
  "@tabler/icons-react": "catalog:",
31
+ "drizzle-orm": "^0.45.2",
29
32
  "h3": "^2.0.1-rc.20",
30
33
  "isbot": "^5",
31
34
  "node-pty": "^1.1.0",
@@ -78,7 +81,7 @@
78
81
  "class-variance-authority": "^0.7.1",
79
82
  "clsx": "^2.1.1",
80
83
  "cmdk": "^1.1.1",
81
- "drizzle-orm": "^0.45.2",
84
+ "drizzle-kit": "^0.31.10",
82
85
  "embla-carousel-react": "^8.6.0",
83
86
  "input-otp": "^1.4.2",
84
87
  "next-themes": "^0.4.6",
@@ -51,17 +51,7 @@ export const customFieldValues = table(
51
51
  }),
52
52
  );
53
53
 
54
- export const userConfig = table("user_config", {
55
- ownerEmail: text("owner_email").primaryKey(),
56
- taskCardFieldIdsJson: text("task_card_field_ids_json")
57
- .notNull()
58
- .default("[]"),
59
- updatedAt: text("updated_at").notNull().default(now()),
60
- });
61
-
62
54
  export type StoredCustomField = typeof customFields.$inferSelect;
63
55
  export type NewCustomField = typeof customFields.$inferInsert;
64
56
  export type StoredCustomFieldValue = typeof customFieldValues.$inferSelect;
65
57
  export type NewCustomFieldValue = typeof customFieldValues.$inferInsert;
66
- export type StoredUserConfig = typeof userConfig.$inferSelect;
67
- export type NewUserConfig = typeof userConfig.$inferInsert;
@@ -51,11 +51,6 @@ CREATE INDEX IF NOT EXISTS idx_custom_field_values_owner_task
51
51
  ON custom_field_values (owner_email, task_id);
52
52
  CREATE INDEX IF NOT EXISTS idx_custom_field_values_owner_field
53
53
  ON custom_field_values (owner_email, field_id);
54
- CREATE TABLE IF NOT EXISTS user_config (
55
- owner_email TEXT PRIMARY KEY,
56
- task_card_field_ids_json TEXT NOT NULL DEFAULT '[]',
57
- updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
58
- );
59
54
  `;
60
55
 
61
56
  // libsql, not better-sqlite3: its sync driver lets `.run()`/`.all()`/`.get()` pass here and fail in production.
@@ -43,6 +43,6 @@ When the user asks to see, review, or manage the task list, check the current-sc
43
43
  When view-screen returns selection, treat selectedItems as the user's current UI multi-select on /tasks or /inbox.
44
44
  Prefer bulk-update-tasks and bulk-delete-tasks when the user clearly means multiple tasks (e.g. "mark these done", "delete the selected ones", or several titles at once). Use single-task actions for one task or when bulk selection is not in play.
45
45
  Prefer bulk-delete-inbox-items when the user clearly means multiple inbox items.
46
- Ask for confirmation before delete-task, bulk-delete-tasks, delete-inbox-item, and bulk-delete-inbox-items.
46
+ Ask for confirmation before deleting tasks, inbox items, or custom fields.
47
47
  Do not use db-query for normal task or inbox operations.`,
48
48
  });
@@ -1,6 +1,14 @@
1
- import { runMigrations } from "@agent-native/core/db";
1
+ import {
2
+ ensureAdditiveColumns,
3
+ getDbExec,
4
+ runMigrations,
5
+ } from "@agent-native/core/db";
2
6
 
3
- export default runMigrations(
7
+ import * as schema from "../db/schema.js";
8
+
9
+ // Keep historical entries unnamed for legacy-ledger compatibility; every new
10
+ // migration must add a stable, unique `name` slug.
11
+ const runTasksMigrations = runMigrations(
4
12
  [
5
13
  {
6
14
  version: 1,
@@ -77,14 +85,39 @@ export default runMigrations(
77
85
  CREATE INDEX IF NOT EXISTS idx_custom_field_values_owner_field
78
86
  ON custom_field_values (owner_email, field_id)`,
79
87
  },
80
- {
81
- version: 8,
82
- sql: `CREATE TABLE IF NOT EXISTS user_config (
83
- owner_email TEXT PRIMARY KEY,
84
- task_card_field_ids_json TEXT NOT NULL DEFAULT '[]',
85
- updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
86
- )`,
87
- },
88
88
  ],
89
89
  { table: "tasks_migrations" },
90
90
  );
91
+
92
+ function isDrizzleTable(value: unknown): value is object {
93
+ return (
94
+ !!value &&
95
+ typeof value === "object" &&
96
+ Object.getOwnPropertySymbols(value).some((s) =>
97
+ s.toString().includes("drizzle"),
98
+ )
99
+ );
100
+ }
101
+
102
+ const schemaTables = Object.values(schema).filter(isDrizzleTable);
103
+
104
+ export default async (nitroApp: any): Promise<void> => {
105
+ await runTasksMigrations(nitroApp);
106
+ try {
107
+ const summary = await ensureAdditiveColumns({
108
+ db: getDbExec(),
109
+ tables: schemaTables,
110
+ });
111
+ if (summary.errors.length > 0) {
112
+ console.warn(
113
+ "[db] ensureAdditiveColumns completed with errors:",
114
+ summary.errors,
115
+ );
116
+ }
117
+ } catch (err) {
118
+ console.warn(
119
+ "[db] ensureAdditiveColumns failed (non-fatal):",
120
+ err instanceof Error ? err.message : err,
121
+ );
122
+ }
123
+ };
@@ -1,18 +1,16 @@
1
- import { eq } from "drizzle-orm";
1
+ import { getUserSetting, putUserSetting } from "@agent-native/core/settings";
2
2
 
3
3
  import {
4
4
  DEFAULT_TASK_CARD_FIELD_NAMES,
5
5
  TASK_CARD_FIELD_LIMIT,
6
6
  } from "../../shared/visible-task-fields.js";
7
7
  import { listCustomFields } from "../custom-fields/store.js";
8
- import { getDb } from "../db/index.js";
9
- import { timestamp } from "../db/record-utils.js";
10
- import { userConfig } from "../db/schema.js";
11
- import type { DbHandle } from "../db/transaction.js";
12
8
  import { UserInputError } from "../errors.js";
13
9
 
14
10
  export { DEFAULT_TASK_CARD_FIELD_NAMES, TASK_CARD_FIELD_LIMIT };
15
11
 
12
+ const VISIBLE_TASK_FIELDS_SETTING_KEY = "visible-task-fields";
13
+
16
14
  function fieldIdsForNames(
17
15
  fieldNames: readonly string[],
18
16
  fields: readonly { id: string; title: string }[],
@@ -26,16 +24,11 @@ function fieldIdsForNames(
26
24
  .slice(0, TASK_CARD_FIELD_LIMIT);
27
25
  }
28
26
 
29
- function parseStoredFieldIds(raw: string): string[] {
30
- try {
31
- const parsed = JSON.parse(raw);
32
- if (!Array.isArray(parsed)) return [];
33
- return parsed
34
- .filter((value): value is string => typeof value === "string")
35
- .slice(0, TASK_CARD_FIELD_LIMIT);
36
- } catch {
37
- return [];
38
- }
27
+ function parseFieldIdsValue(value: unknown): string[] {
28
+ if (!Array.isArray(value)) return [];
29
+ return value
30
+ .filter((entry): entry is string => typeof entry === "string")
31
+ .slice(0, TASK_CARD_FIELD_LIMIT);
39
32
  }
40
33
 
41
34
  function dedupeFieldIds(fieldIds: readonly string[]) {
@@ -49,39 +42,34 @@ function filterKnownFieldIds(
49
42
  return fieldIds.filter((fieldId) => knownIds.has(fieldId));
50
43
  }
51
44
 
52
- export async function getTaskCardFieldIds(
53
- input: {
54
- ownerEmail: string;
55
- },
56
- db: DbHandle = getDb(),
57
- ): Promise<string[]> {
45
+ async function readStoredFieldIds(
46
+ ownerEmail: string,
47
+ ): Promise<string[] | null> {
48
+ const setting = await getUserSetting(
49
+ ownerEmail,
50
+ VISIBLE_TASK_FIELDS_SETTING_KEY,
51
+ );
52
+ return setting ? parseFieldIdsValue(setting.fieldIds) : null;
53
+ }
54
+
55
+ export async function getTaskCardFieldIds(input: {
56
+ ownerEmail: string;
57
+ }): Promise<string[]> {
58
58
  const { fields } = await listCustomFields({ ownerEmail: input.ownerEmail });
59
59
  const knownIds = new Set(fields.map((field) => field.id));
60
60
 
61
- const [row] = await db
62
- .select()
63
- .from(userConfig)
64
- .where(eq(userConfig.ownerEmail, input.ownerEmail))
65
- .limit(1);
66
-
67
- if (!row) {
61
+ const stored = await readStoredFieldIds(input.ownerEmail);
62
+ if (stored === null) {
68
63
  return fieldIdsForNames(DEFAULT_TASK_CARD_FIELD_NAMES, fields);
69
64
  }
70
65
 
71
- return filterKnownFieldIds(
72
- parseStoredFieldIds(row.taskCardFieldIdsJson),
73
- knownIds,
74
- );
66
+ return filterKnownFieldIds(stored, knownIds);
75
67
  }
76
68
 
77
- export async function setTaskCardFieldIds(
78
- input: {
79
- ownerEmail: string;
80
- fieldIds: readonly string[];
81
- now?: string;
82
- },
83
- db: DbHandle = getDb(),
84
- ): Promise<string[]> {
69
+ export async function setTaskCardFieldIds(input: {
70
+ ownerEmail: string;
71
+ fieldIds: readonly string[];
72
+ }): Promise<string[]> {
85
73
  const { fields } = await listCustomFields({ ownerEmail: input.ownerEmail });
86
74
  const knownIds = new Set(fields.map((field) => field.id));
87
75
  const next = dedupeFieldIds(input.fieldIds);
@@ -90,49 +78,22 @@ export async function setTaskCardFieldIds(
90
78
  throw new UserInputError("fieldIds must reference existing custom fields.");
91
79
  }
92
80
 
93
- const updatedAt = timestamp(input.now);
94
- const taskCardFieldIdsJson = JSON.stringify(next);
95
-
96
- await db
97
- .insert(userConfig)
98
- .values({
99
- ownerEmail: input.ownerEmail,
100
- taskCardFieldIdsJson,
101
- updatedAt,
102
- })
103
- .onConflictDoUpdate({
104
- target: userConfig.ownerEmail,
105
- set: { taskCardFieldIdsJson, updatedAt },
106
- });
81
+ await putUserSetting(input.ownerEmail, VISIBLE_TASK_FIELDS_SETTING_KEY, {
82
+ fieldIds: next,
83
+ });
107
84
 
108
85
  return next;
109
86
  }
110
87
 
111
- export async function removeTaskCardFieldId(
112
- input: {
113
- ownerEmail: string;
114
- fieldId: string;
115
- now?: string;
116
- },
117
- db: DbHandle = getDb(),
118
- ): Promise<void> {
119
- const [row] = await db
120
- .select()
121
- .from(userConfig)
122
- .where(eq(userConfig.ownerEmail, input.ownerEmail))
123
- .limit(1);
124
-
125
- if (!row) return;
126
-
127
- const next = parseStoredFieldIds(row.taskCardFieldIdsJson).filter(
128
- (fieldId) => fieldId !== input.fieldId,
129
- );
130
-
131
- await db
132
- .update(userConfig)
133
- .set({
134
- taskCardFieldIdsJson: JSON.stringify(next),
135
- updatedAt: timestamp(input.now),
136
- })
137
- .where(eq(userConfig.ownerEmail, input.ownerEmail));
88
+ export async function removeTaskCardFieldId(input: {
89
+ ownerEmail: string;
90
+ fieldId: string;
91
+ }): Promise<void> {
92
+ const stored = await readStoredFieldIds(input.ownerEmail);
93
+ if (stored === null) return;
94
+
95
+ const next = stored.filter((fieldId) => fieldId !== input.fieldId);
96
+ await putUserSetting(input.ownerEmail, VISIBLE_TASK_FIELDS_SETTING_KEY, {
97
+ fieldIds: next,
98
+ });
138
99
  }
@@ -19,6 +19,5 @@
19
19
  "react-router.config.ts",
20
20
  ".react-router/types/**/*",
21
21
  ".generated/**/*"
22
- ],
23
- "exclude": ["**/*.test.ts", "**/*.spec.ts"]
22
+ ]
24
23
  }
@@ -1,8 +1,17 @@
1
+ import path from "node:path";
2
+
1
3
  import { defineConfig } from "vitest/config";
2
4
 
3
5
  export default defineConfig({
6
+ resolve: {
7
+ alias: {
8
+ "@": path.resolve(__dirname, "./app"),
9
+ "@shared": path.resolve(__dirname, "./shared"),
10
+ },
11
+ },
4
12
  test: {
5
- include: ["**/*.test.ts"],
13
+ include: ["**/*.{test,spec}.?(c|m)[jt]s?(x)"],
14
+ exclude: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/e2e/**"],
6
15
  environment: "node",
7
16
  },
8
17
  });
@@ -33,6 +33,7 @@ export declare const AGENT_BACKGROUND_FUNCTION_URL_PATH = "/.netlify/functions/s
33
33
  */
34
34
  export declare const AGENT_BACKGROUND_PROCESSOR_FIELD = "__agentNativeProcessor";
35
35
  export declare const AGENT_BACKGROUND_PROCESSOR_A2A = "a2a";
36
+ export declare const AGENT_BACKGROUND_PROCESSOR_INTEGRATION = "integration";
36
37
  export declare const AGENT_BACKGROUND_PROCESSOR_ROUTE = "route";
37
38
  export declare const AGENT_BACKGROUND_PROCESSOR_ROUTE_FIELD = "__agentNativeProcessorRoute";
38
39
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"durable-background.d.ts","sourceRoot":"","sources":["../../src/agent/durable-background.ts"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,2CACE,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AAExE;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,gDAA0D,CAAC;AAE1G;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AACzE,eAAO,MAAM,8BAA8B,QAAQ,CAAC;AACpD,eAAO,MAAM,gCAAgC,UAAU,CAAC;AACxD,eAAO,MAAM,sCAAsC,gCACpB,CAAC;AAiChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,CAQ/D;AAED,wBAAgB,oCAAoC,CAClD,YAAY,EAAE,MAAM,GACnB,MAAM,CAQR;AAED,wBAAgB,4CAA4C,CAC1D,YAAY,EAAE,MAAM,GACnB,OAAO,CAET;AAED;;;GAGG;AACH,eAAO,MAAM,iCAAiC,kCACb,CAAC;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,oBAAoB,CAAC;AAEjE;;;;GAIG;AACH,wBAAgB,mCAAmC,IAAI,OAAO,CAsB7D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAsBvD;AAED,wBAAgB,2CAA2C,CACzD,MAAM,EAAE,OAAO,GACd,OAAO,CAOT;AAED,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,OAAO,GACf,OAAO,CAKT;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAQzE;AAwCD;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,CAAC,EAAE;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAiBV;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,qCACb,CAAC;AAiBrC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qCAAqC,IAAI,OAAO,CAM/D;AAED,uDAAuD;AACvD,MAAM,MAAM,qBAAqB,GAC7B;IACE,EAAE,EAAE,IAAI,CAAC;IACT,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEN;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAahE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,GAAE,OAAe,GACxB,qBAAqB,CAqDvB"}
1
+ {"version":3,"file":"durable-background.d.ts","sourceRoot":"","sources":["../../src/agent/durable-background.ts"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,2CACE,CAAC;AAE3C;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AAExE;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,gDAA0D,CAAC;AAE1G;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC,2BAA2B,CAAC;AACzE,eAAO,MAAM,8BAA8B,QAAQ,CAAC;AACpD,eAAO,MAAM,sCAAsC,gBAAgB,CAAC;AACpE,eAAO,MAAM,gCAAgC,UAAU,CAAC;AACxD,eAAO,MAAM,sCAAsC,gCACpB,CAAC;AAiChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,sCAAsC,IAAI,MAAM,CAQ/D;AAED,wBAAgB,oCAAoC,CAClD,YAAY,EAAE,MAAM,GACnB,MAAM,CAQR;AAED,wBAAgB,4CAA4C,CAC1D,YAAY,EAAE,MAAM,GACnB,OAAO,CAET;AAED;;;GAGG;AACH,eAAO,MAAM,iCAAiC,kCACb,CAAC;AAElC;;;;;;GAMG;AACH,eAAO,MAAM,+BAA+B,oBAAoB,CAAC;AAEjE;;;;GAIG;AACH,wBAAgB,mCAAmC,IAAI,OAAO,CAsB7D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,6BAA6B,IAAI,OAAO,CAsBvD;AAED,wBAAgB,2CAA2C,CACzD,MAAM,EAAE,OAAO,GACd,OAAO,CAOT;AAED,wBAAgB,2CAA2C,CACzD,OAAO,EAAE,OAAO,GACf,OAAO,CAKT;AAED,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAQzE;AAwCD;;;;;;;GAOG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,CAAC,EAAE;IAC5D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,OAAO,CAiBV;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,qCACb,CAAC;AAiBrC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qCAAqC,IAAI,OAAO,CAM/D;AAED,uDAAuD;AACvD,MAAM,MAAM,qBAAqB,GAC7B;IACE,EAAE,EAAE,IAAI,CAAC;IACT,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEN;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAahE;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,OAAO,EACb,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,QAAQ,GAAE,OAAe,GACxB,qBAAqB,CAqDvB"}
@@ -74,6 +74,7 @@ export const AGENT_BACKGROUND_FUNCTION_URL_PATH = `/.netlify/functions/${AGENT_B
74
74
  */
75
75
  export const AGENT_BACKGROUND_PROCESSOR_FIELD = "__agentNativeProcessor";
76
76
  export const AGENT_BACKGROUND_PROCESSOR_A2A = "a2a";
77
+ export const AGENT_BACKGROUND_PROCESSOR_INTEGRATION = "integration";
77
78
  export const AGENT_BACKGROUND_PROCESSOR_ROUTE = "route";
78
79
  export const AGENT_BACKGROUND_PROCESSOR_ROUTE_FIELD = "__agentNativeProcessorRoute";
79
80
  /**