@agent-native/core 0.146.3 → 0.146.4
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/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +13 -10
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/analytics/actions/compose-dashboard.ts +53 -6
- package/corpus/templates/analytics/actions/dashboard-mutation-api.ts +8 -2
- package/corpus/templates/analytics/actions/migrate-first-party-analytics-to-bigquery.ts +3 -1
- package/corpus/templates/analytics/actions/mutate-dashboard.ts +48 -9
- package/corpus/templates/analytics/actions/update-dashboard.ts +80 -6
- package/corpus/templates/analytics/changelog/2026-08-07-dashboard-creation-and-edits-now-save-faster-with-reliable-s.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +19 -19
- package/corpus/templates/analytics/server/jobs/analytics-bigquery-backfill.ts +21 -2
- package/corpus/templates/analytics/server/lib/bigquery.ts +59 -24
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +44 -8
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +3 -5
- package/corpus/templates/analytics/server/lib/first-party-analytics-backend.ts +33 -69
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +90 -24
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +1 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +17 -2
- package/corpus/templates/analytics/shared/dashboard-report-timeouts.ts +2 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/assets/netlify.toml +1 -1
- package/corpus/templates/assets/package.json +1 -0
- package/corpus/templates/assets/scripts/migrate-production.ts +24 -0
- package/corpus/templates/assets/server/plugins/db.ts +1 -1
- package/corpus/templates/assets/tsconfig.json +1 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/brain/netlify.toml +1 -1
- package/corpus/templates/brain/package.json +2 -0
- package/corpus/templates/brain/scripts/migrate-production.ts +24 -0
- package/corpus/templates/brain/server/plugins/db.ts +1 -1
- package/corpus/templates/brain/tsconfig.json +1 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/calendar/netlify.toml +1 -1
- package/corpus/templates/calendar/package.json +1 -0
- package/corpus/templates/calendar/scripts/migrate-production.ts +24 -0
- package/corpus/templates/calendar/server/plugins/db.ts +1 -1
- package/corpus/templates/calendar/tsconfig.json +1 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/chat/netlify.toml +1 -1
- package/corpus/templates/chat/package.json +1 -0
- package/corpus/templates/chat/scripts/migrate-production.ts +31 -0
- package/corpus/templates/chat/tsconfig.json +1 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/clips/netlify.toml +1 -1
- package/corpus/templates/clips/package.json +1 -0
- package/corpus/templates/clips/scripts/migrate-production.ts +24 -0
- package/corpus/templates/clips/server/plugins/db.ts +1 -1
- package/corpus/templates/clips/tsconfig.json +1 -0
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/content/netlify.toml +1 -1
- package/corpus/templates/content/package.json +2 -0
- package/corpus/templates/content/scripts/migrate-production.ts +28 -0
- package/corpus/templates/content/server/plugins/db.ts +2 -2
- package/corpus/templates/crm/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/crm/netlify.toml +1 -1
- package/corpus/templates/crm/package.json +2 -0
- package/corpus/templates/crm/scripts/migrate-production.ts +24 -0
- package/corpus/templates/crm/server/plugins/db.ts +1 -1
- package/corpus/templates/crm/tsconfig.json +1 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/design/netlify.toml +1 -1
- package/corpus/templates/design/package.json +1 -0
- package/corpus/templates/design/scripts/migrate-production.ts +24 -0
- package/corpus/templates/design/server/plugins/db.ts +1 -1
- package/corpus/templates/design/tsconfig.json +1 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/dispatch/netlify.toml +1 -1
- package/corpus/templates/dispatch/package.json +1 -0
- package/corpus/templates/dispatch/scripts/migrate-production.ts +23 -0
- package/corpus/templates/dispatch/tsconfig.json +1 -0
- package/corpus/templates/factory/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/factory/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/factory/netlify.toml +1 -1
- package/corpus/templates/factory/package.json +1 -0
- package/corpus/templates/factory/scripts/migrate-production.ts +31 -0
- package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +2 -0
- package/corpus/templates/factory/tsconfig.json +1 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/forms/netlify.toml +1 -1
- package/corpus/templates/forms/package.json +2 -0
- package/corpus/templates/forms/scripts/migrate-production.ts +24 -0
- package/corpus/templates/forms/server/plugins/db.ts +1 -1
- package/corpus/templates/forms/tsconfig.json +1 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/macros/netlify.toml +1 -1
- package/corpus/templates/macros/package.json +1 -0
- package/corpus/templates/macros/scripts/migrate-production.ts +24 -0
- package/corpus/templates/macros/server/plugins/db.ts +1 -1
- package/corpus/templates/macros/tsconfig.json +1 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/mail/netlify.toml +1 -1
- package/corpus/templates/mail/package.json +1 -0
- package/corpus/templates/mail/scripts/migrate-production.ts +24 -0
- package/corpus/templates/mail/server/plugins/db.ts +1 -1
- package/corpus/templates/mail/tsconfig.json +1 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/plan/netlify.toml +1 -1
- package/corpus/templates/plan/package.json +1 -0
- package/corpus/templates/plan/scripts/migrate-production.ts +24 -0
- package/corpus/templates/plan/server/plugins/00-mcp.ts +3 -2
- package/corpus/templates/plan/server/plugins/db.ts +1 -1
- package/corpus/templates/plan/tsconfig.json +1 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/slides/netlify.toml +1 -1
- package/corpus/templates/slides/package.json +1 -0
- package/corpus/templates/slides/scripts/migrate-production.ts +24 -0
- package/corpus/templates/slides/server/plugins/db.ts +1 -1
- package/corpus/templates/slides/tsconfig.json +1 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/corpus/templates/tasks/netlify.toml +1 -1
- package/corpus/templates/tasks/package.json +1 -0
- package/corpus/templates/tasks/scripts/migrate-production.ts +24 -0
- package/corpus/templates/tasks/server/plugins/db.ts +1 -1
- package/corpus/templates/tasks/tsconfig.json +1 -0
- package/dist/action.d.ts +2 -0
- package/dist/agent/production-agent.d.ts +1 -0
- package/dist/agent/production-agent.js +2 -0
- package/dist/agent/thread-data-builder.d.ts +4 -0
- package/dist/agent/thread-data-builder.js +44 -0
- package/dist/automations/service.d.ts +1 -0
- package/dist/automations/service.js +21 -2
- package/dist/cli/create.js +20 -2
- package/dist/client/agent-page/AgentJobsTab.js +3 -1
- package/dist/client/agent-page/AutomationDetailsDialog.js +9 -2
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/db/migrations.js +7 -13
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/jobs/actions/list-automation-runs.d.ts +1 -0
- package/dist/jobs/actions/list-automation-runs.js +9 -2
- package/dist/jobs/actions/list-recurring-jobs.js +3 -1
- package/dist/jobs/actions/manage-recurring-job.js +1 -1
- package/dist/jobs/actions/run-automation-now.js +1 -0
- package/dist/jobs/background-automation-runner.js +2 -0
- package/dist/jobs/frontmatter.d.ts +2 -0
- package/dist/jobs/frontmatter.js +4 -0
- package/dist/jobs/run-history.d.ts +4 -0
- package/dist/jobs/run-history.js +28 -8
- package/dist/jobs/run-now.d.ts +4 -1
- package/dist/jobs/run-now.js +4 -3
- package/dist/jobs/scheduler.js +18 -0
- package/dist/jobs/tools.d.ts +3 -2
- package/dist/jobs/tools.js +26 -12
- package/dist/localization/default-messages.d.ts +1 -0
- package/dist/localization/default-messages.js +1 -0
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-routes.d.ts +2 -0
- package/dist/server/action-routes.js +1 -0
- package/dist/server/agent-chat-plugin.js +3 -2
- package/dist/server/builder-browser.js +24 -8
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/templates/chat/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/dist/templates/chat/netlify.toml +1 -1
- package/dist/templates/chat/package.json +1 -0
- package/dist/templates/chat/scripts/migrate-production.ts +31 -0
- package/dist/templates/chat/tsconfig.json +1 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/dist/templates/default/package.json +1 -0
- package/dist/templates/default/scripts/migrate-production.ts +31 -0
- package/dist/templates/default/tsconfig.json +1 -0
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/dist/templates/workspace-root/AGENTS.md +2 -1
- package/dist/triggers/actions/list-automations.js +1 -1
- package/dist/triggers/actions/manage-automation.js +5 -1
- package/dist/triggers/actions.d.ts +1 -1
- package/dist/triggers/actions.js +21 -15
- package/dist/triggers/dispatcher.js +17 -2
- package/dist/triggers/routes.d.ts +1 -0
- package/dist/triggers/routes.js +1 -0
- package/package.json +1 -1
- package/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/src/templates/chat/netlify.toml +1 -1
- package/src/templates/chat/package.json +1 -0
- package/src/templates/chat/scripts/migrate-production.ts +31 -0
- package/src/templates/chat/tsconfig.json +1 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/src/templates/default/package.json +1 -0
- package/src/templates/default/scripts/migrate-production.ts +31 -0
- package/src/templates/default/tsconfig.json +1 -0
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +7 -3
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +5 -2
- package/src/templates/workspace-root/AGENTS.md +2 -1
|
@@ -35,7 +35,7 @@ export default defineAction({
|
|
|
35
35
|
const userEmail = ctx?.userEmail;
|
|
36
36
|
if (!userEmail)
|
|
37
37
|
throw new Error("Not authenticated.");
|
|
38
|
-
const definitions = await listAutomationDefinitions({ userEmail, orgId: ctx?.orgId }, scope);
|
|
38
|
+
const definitions = await listAutomationDefinitions({ userEmail, orgId: ctx?.orgId, appId: ctx?.appId }, scope);
|
|
39
39
|
return definitions.map(({ resource, name, meta, body, canUpdate }) => ({
|
|
40
40
|
id: resource.id,
|
|
41
41
|
name,
|
|
@@ -17,7 +17,11 @@ export default defineAction({
|
|
|
17
17
|
const userEmail = ctx?.userEmail;
|
|
18
18
|
if (!userEmail)
|
|
19
19
|
throw new Error("Not authenticated.");
|
|
20
|
-
const actor = {
|
|
20
|
+
const actor = {
|
|
21
|
+
userEmail,
|
|
22
|
+
orgId: ctx?.orgId,
|
|
23
|
+
appId: ctx?.appId,
|
|
24
|
+
};
|
|
21
25
|
if (operation === "delete") {
|
|
22
26
|
await deleteAutomation(actor, scope, name);
|
|
23
27
|
await refreshEventSubscriptions();
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
* with an `action` discriminator to keep the tool registry compact.
|
|
10
10
|
*/
|
|
11
11
|
import type { ActionEntry } from "../agent/production-agent.js";
|
|
12
|
-
export declare function createAutomationToolEntries(getCurrentUser: () => string): Record<string, ActionEntry>;
|
|
12
|
+
export declare function createAutomationToolEntries(getCurrentUser: () => string, appId?: string): Record<string, ActionEntry>;
|
package/dist/triggers/actions.js
CHANGED
|
@@ -41,9 +41,9 @@ async function handleListEvents() {
|
|
|
41
41
|
});
|
|
42
42
|
return lines.join("\n");
|
|
43
43
|
}
|
|
44
|
-
async function handleList(args, getCurrentUser) {
|
|
44
|
+
async function handleList(args, getCurrentUser, appId) {
|
|
45
45
|
const scope = automationScope(args.scope);
|
|
46
|
-
const definitions = await listAutomationDefinitions({ userEmail: getCurrentUser(), orgId: getRequestOrgId() }, scope);
|
|
46
|
+
const definitions = await listAutomationDefinitions({ userEmail: getCurrentUser(), orgId: getRequestOrgId(), appId }, scope);
|
|
47
47
|
const automations = definitions
|
|
48
48
|
.filter(({ meta }) => !args.domain || meta.domain === args.domain)
|
|
49
49
|
.filter(({ meta }) => args.enabled_only !== "true" || meta.enabled)
|
|
@@ -60,6 +60,7 @@ async function handleList(args, getCurrentUser) {
|
|
|
60
60
|
condition: meta.condition ?? null,
|
|
61
61
|
mode: meta.mode,
|
|
62
62
|
domain: meta.domain ?? null,
|
|
63
|
+
appId: meta.appId ?? null,
|
|
63
64
|
enabled: meta.enabled,
|
|
64
65
|
lastRun: meta.lastRun ?? null,
|
|
65
66
|
lastStatus: meta.lastStatus ?? null,
|
|
@@ -91,7 +92,7 @@ function automationTriggerType(value) {
|
|
|
91
92
|
return value;
|
|
92
93
|
throw new Error('trigger_type must be "schedule" or "event".');
|
|
93
94
|
}
|
|
94
|
-
async function handleDefine(args, getCurrentUser) {
|
|
95
|
+
async function handleDefine(args, getCurrentUser, appId) {
|
|
95
96
|
if (args.mode === "deterministic") {
|
|
96
97
|
return ("Error: Deterministic mode was removed — it was never implemented and " +
|
|
97
98
|
"automations that set it never fired. Create the automation without " +
|
|
@@ -99,7 +100,11 @@ async function handleDefine(args, getCurrentUser) {
|
|
|
99
100
|
}
|
|
100
101
|
const integration = getIntegrationRequestContext();
|
|
101
102
|
try {
|
|
102
|
-
const definition = await defineAutomation({
|
|
103
|
+
const definition = await defineAutomation({
|
|
104
|
+
userEmail: getCurrentUser(),
|
|
105
|
+
orgId: getRequestOrgId(),
|
|
106
|
+
appId,
|
|
107
|
+
}, {
|
|
103
108
|
name: typeof args.name === "string" ? args.name : "",
|
|
104
109
|
scope: automationScope(args.scope),
|
|
105
110
|
triggerType: automationTriggerType(args.trigger_type),
|
|
@@ -154,9 +159,9 @@ async function handleDefine(args, getCurrentUser) {
|
|
|
154
159
|
return `Error: ${error.message}`;
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
|
-
async function handleUpdate(args, getCurrentUser) {
|
|
162
|
+
async function handleUpdate(args, getCurrentUser, appId) {
|
|
158
163
|
try {
|
|
159
|
-
const definition = await updateAutomation({ userEmail: getCurrentUser(), orgId: getRequestOrgId() }, {
|
|
164
|
+
const definition = await updateAutomation({ userEmail: getCurrentUser(), orgId: getRequestOrgId(), appId }, {
|
|
160
165
|
name: typeof args.name === "string" ? args.name : "",
|
|
161
166
|
scope: automationScope(args.scope),
|
|
162
167
|
enabled: args.enabled === undefined
|
|
@@ -207,10 +212,10 @@ async function handleUpdate(args, getCurrentUser) {
|
|
|
207
212
|
return `Error: ${error.message}`;
|
|
208
213
|
}
|
|
209
214
|
}
|
|
210
|
-
async function handleDelete(args, getCurrentUser) {
|
|
215
|
+
async function handleDelete(args, getCurrentUser, appId) {
|
|
211
216
|
const name = typeof args.name === "string" ? args.name : "";
|
|
212
217
|
try {
|
|
213
|
-
await deleteAutomation({ userEmail: getCurrentUser(), orgId: getRequestOrgId() }, automationScope(args.scope), name);
|
|
218
|
+
await deleteAutomation({ userEmail: getCurrentUser(), orgId: getRequestOrgId(), appId }, automationScope(args.scope), name);
|
|
214
219
|
await refreshEventSubscriptions();
|
|
215
220
|
return JSON.stringify({ deleted: true, name });
|
|
216
221
|
}
|
|
@@ -236,7 +241,7 @@ async function handleFireTest(args, getCurrentUser) {
|
|
|
236
241
|
emit("test.event.fired", { data }, { owner });
|
|
237
242
|
return `Test event fired with payload: ${JSON.stringify({ data })}. Any automations subscribed to "test.event.fired" will be evaluated.`;
|
|
238
243
|
}
|
|
239
|
-
async function handleRunNow(args, getCurrentUser, context) {
|
|
244
|
+
async function handleRunNow(args, getCurrentUser, appId, context) {
|
|
240
245
|
if (context?.caller === "automation") {
|
|
241
246
|
return "Error: an automation cannot run another automation.";
|
|
242
247
|
}
|
|
@@ -244,6 +249,7 @@ async function handleRunNow(args, getCurrentUser, context) {
|
|
|
244
249
|
const result = await queueAutomationRunNow({
|
|
245
250
|
userEmail: getCurrentUser(),
|
|
246
251
|
orgId: getRequestOrgId(),
|
|
252
|
+
appId,
|
|
247
253
|
scope: automationScope(args.scope),
|
|
248
254
|
name: typeof args.name === "string" ? args.name : "",
|
|
249
255
|
});
|
|
@@ -265,7 +271,7 @@ const VALID_ACTIONS = [
|
|
|
265
271
|
"fire-test",
|
|
266
272
|
"run-now",
|
|
267
273
|
];
|
|
268
|
-
export function createAutomationToolEntries(getCurrentUser) {
|
|
274
|
+
export function createAutomationToolEntries(getCurrentUser, appId) {
|
|
269
275
|
return {
|
|
270
276
|
"manage-automations": {
|
|
271
277
|
tool: {
|
|
@@ -371,17 +377,17 @@ export function createAutomationToolEntries(getCurrentUser) {
|
|
|
371
377
|
case "list-events":
|
|
372
378
|
return handleListEvents();
|
|
373
379
|
case "list":
|
|
374
|
-
return handleList(args, getCurrentUser);
|
|
380
|
+
return handleList(args, getCurrentUser, appId);
|
|
375
381
|
case "define":
|
|
376
|
-
return handleDefine(args, getCurrentUser);
|
|
382
|
+
return handleDefine(args, getCurrentUser, appId);
|
|
377
383
|
case "update":
|
|
378
|
-
return handleUpdate(args, getCurrentUser);
|
|
384
|
+
return handleUpdate(args, getCurrentUser, appId);
|
|
379
385
|
case "delete":
|
|
380
|
-
return handleDelete(args, getCurrentUser);
|
|
386
|
+
return handleDelete(args, getCurrentUser, appId);
|
|
381
387
|
case "fire-test":
|
|
382
388
|
return handleFireTest(args, getCurrentUser);
|
|
383
389
|
case "run-now":
|
|
384
|
-
return handleRunNow(args, getCurrentUser, context);
|
|
390
|
+
return handleRunNow(args, getCurrentUser, appId, context);
|
|
385
391
|
default:
|
|
386
392
|
return `Error: unknown action "${action}". Valid actions: ${VALID_ACTIONS.join(", ")}.`;
|
|
387
393
|
}
|
|
@@ -39,6 +39,13 @@ const _eventSubscriptions = new Map();
|
|
|
39
39
|
// deployments; multi-instance would need a conditional DB update.
|
|
40
40
|
const _dispatchingTriggers = new Set();
|
|
41
41
|
let _deps = null;
|
|
42
|
+
function jobBelongsToApp(meta, appId) {
|
|
43
|
+
const ownerAppId = meta.appId?.trim();
|
|
44
|
+
if (!ownerAppId)
|
|
45
|
+
return true;
|
|
46
|
+
const dispatcherAppId = appId?.trim();
|
|
47
|
+
return Boolean(dispatcherAppId && ownerAppId === dispatcherAppId);
|
|
48
|
+
}
|
|
42
49
|
/**
|
|
43
50
|
* Record that a tick evaluated this trigger and declined to dispatch it.
|
|
44
51
|
* `lastRun` stays untouched — nothing ran — and an unchanged outcome is not
|
|
@@ -106,6 +113,8 @@ export async function refreshEventSubscriptions() {
|
|
|
106
113
|
if (!resource.path.endsWith(".md"))
|
|
107
114
|
continue;
|
|
108
115
|
const { meta } = parseTriggerFrontmatter(resource.content);
|
|
116
|
+
if (!jobBelongsToApp(meta, _deps?.appId))
|
|
117
|
+
continue;
|
|
109
118
|
if (meta.triggerType === "event" && meta.event && meta.enabled) {
|
|
110
119
|
eventNames.add(meta.event);
|
|
111
120
|
}
|
|
@@ -129,7 +138,8 @@ export async function refreshEventSubscriptions() {
|
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
async function handleEvent(eventName, payload, eventMeta) {
|
|
132
|
-
|
|
141
|
+
const deps = _deps;
|
|
142
|
+
if (!deps)
|
|
133
143
|
return;
|
|
134
144
|
try {
|
|
135
145
|
const jobResources = await resourceListAllOwners("jobs/");
|
|
@@ -140,6 +150,7 @@ async function handleEvent(eventName, payload, eventMeta) {
|
|
|
140
150
|
return (meta.triggerType === "event" &&
|
|
141
151
|
meta.event === eventName &&
|
|
142
152
|
meta.enabled &&
|
|
153
|
+
jobBelongsToApp(meta, deps.appId) &&
|
|
143
154
|
!isBackgroundAutomationRunActive(meta));
|
|
144
155
|
});
|
|
145
156
|
for (const resource of matchingTriggers) {
|
|
@@ -178,7 +189,7 @@ async function handleEvent(eventName, payload, eventMeta) {
|
|
|
178
189
|
// Resolve API key for condition evaluation
|
|
179
190
|
const owner = identity.userEmail;
|
|
180
191
|
const userApiKey = await getOwnerActiveApiKey(owner);
|
|
181
|
-
const apiKey = userApiKey ||
|
|
192
|
+
const apiKey = userApiKey || deps.apiKey;
|
|
182
193
|
if (!apiKey) {
|
|
183
194
|
await recordTriggerSkip(resource, "error", "No API key is available for this automation");
|
|
184
195
|
console.warn(`[triggers] ${meta.lastError}: "${resource.path}"`);
|
|
@@ -227,6 +238,10 @@ async function dispatchAgentic(resource, payload, eventMeta, identity) {
|
|
|
227
238
|
return;
|
|
228
239
|
}
|
|
229
240
|
const latestTrigger = parseTriggerFrontmatter(latest.content);
|
|
241
|
+
if (!jobBelongsToApp(latestTrigger.meta, _deps.appId)) {
|
|
242
|
+
console.log(`[triggers] "${resource.path}" belongs to a different app; dropping the event.`);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
230
245
|
const runningMeta = {
|
|
231
246
|
...latestTrigger.meta,
|
|
232
247
|
lastRun: now.toISOString(),
|
package/dist/triggers/routes.js
CHANGED
|
@@ -122,6 +122,7 @@ async function resourceToAutomationItem(event, userEmail, resource) {
|
|
|
122
122
|
name: automationName(resource.path),
|
|
123
123
|
path: resource.path,
|
|
124
124
|
owner: resource.owner,
|
|
125
|
+
appId: meta.appId,
|
|
125
126
|
scope: resource.owner === userEmail && !meta.orgId ? "personal" : "organization",
|
|
126
127
|
canUpdate: await currentUserCanUpdateAutomation(event, userEmail, resource, meta),
|
|
127
128
|
triggerType: meta.triggerType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.146.
|
|
3
|
+
"version": "0.146.4",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -36,8 +36,10 @@ Tier 4 includes **all** of the following — not only editing package source:
|
|
|
36
36
|
- Files under `node_modules/@agent-native/*` (core, dispatch, scheduling, …)
|
|
37
37
|
- `pnpm.overrides`, `overrides`, `resolutions`, or `patchedDependencies` that
|
|
38
38
|
target any `@agent-native/*` package
|
|
39
|
-
-
|
|
40
|
-
|
|
39
|
+
- `pnpm patch`, `pnpm patch-commit`, or local package patch artifacts for any
|
|
40
|
+
dependency
|
|
41
|
+
- Invented "dispatch/core behavior" shims meant to paper over a version skew
|
|
42
|
+
or failed upgrade
|
|
41
43
|
|
|
42
44
|
This does not prohibit intentional app-owned UI customization. When public
|
|
43
45
|
props and composition are insufficient, the `customizing-agent-native` skill
|
|
@@ -100,8 +102,10 @@ inline strings in components.
|
|
|
100
102
|
- Don't confuse readable package source with app-owned code: use
|
|
101
103
|
`customizing-agent-native` and `agent-native eject` for supported ownership
|
|
102
104
|
transfer
|
|
105
|
+
- Don't use `pnpm patch` / `pnpm patch-commit`, commit `patches/` artifacts, or
|
|
106
|
+
add `pnpm.patchedDependencies` to "make the app run" after a version bump
|
|
103
107
|
- Don't add `pnpm.overrides` / `patchedDependencies` / `resolutions` for
|
|
104
|
-
`@agent-native/*` to
|
|
108
|
+
`@agent-native/*` to paper over a broken upgrade
|
|
105
109
|
- Don't invent local dispatch/core behavior overrides when upgrade fails —
|
|
106
110
|
run `npx @agent-native/core@latest upgrade`, then fix app-level errors only
|
|
107
111
|
- Don't modify `.agents/skills/` or `AGENTS.md` unless explicitly requested
|
|
@@ -15,8 +15,9 @@ metadata:
|
|
|
15
15
|
|
|
16
16
|
When an older Agent Native app/branch needs to run on current packages, use
|
|
17
17
|
`agent-native upgrade`. Never "fix" upgrade breakage with
|
|
18
|
-
`pnpm
|
|
19
|
-
|
|
18
|
+
`pnpm patch`, `pnpm patch-commit`, `pnpm.patchedDependencies`,
|
|
19
|
+
`pnpm.overrides`, `patchedDependencies`, `resolutions`, local patch artifacts,
|
|
20
|
+
or edits under `node_modules/@agent-native/*` — especially not against
|
|
20
21
|
`@agent-native/core` or `@agent-native/dispatch`.
|
|
21
22
|
|
|
22
23
|
## Why
|
|
@@ -109,6 +110,8 @@ install → refresh scaffold skills → verify, then fix **app** code only.
|
|
|
109
110
|
|
|
110
111
|
- Don't add `pnpm.overrides`, `overrides`, `resolutions`, or
|
|
111
112
|
`patchedDependencies` for any `@agent-native/*` package
|
|
113
|
+
- Don't run `pnpm patch` or `pnpm patch-commit`, or commit files under
|
|
114
|
+
`patches/`, for any dependency
|
|
112
115
|
- Don't edit `node_modules/@agent-native/core` or
|
|
113
116
|
`node_modules/@agent-native/dispatch`
|
|
114
117
|
- Don't invent local "dispatch behavior" shims to paper over version skew
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[build]
|
|
2
2
|
ignore = "node ./scripts/netlify-ignore-build.mjs chat"
|
|
3
|
-
command = "export DATABASE_URL=${NETLIFY_DATABASE_URL:-$DATABASE_URL} && pnpm install && NITRO_PRESET=netlify pnpm --filter chat build"
|
|
3
|
+
command = "export DATABASE_URL=${NETLIFY_DATABASE_URL:-$DATABASE_URL} && pnpm install && NITRO_PRESET=netlify pnpm --filter chat build && if [ \"${CONTEXT:-}\" = \"production\" ]; then pnpm --filter chat migrate:production; fi"
|
|
4
4
|
publish = "templates/chat/dist"
|
|
5
5
|
functions = "templates/chat/.netlify/functions-internal"
|
|
6
6
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { closeDbExec, withMigrationRuntime } from "@agent-native/core/db";
|
|
2
|
+
import { runFrameworkReleaseMigrations } from "@agent-native/core/server";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Release-time schema entrypoint.
|
|
6
|
+
*
|
|
7
|
+
* Every deploy runs this once, and request functions never touch schema. That
|
|
8
|
+
* ordering is not an optimization: on serverless, "migrate on first use" means
|
|
9
|
+
* migrate on EVERY cold start, and a production incident traced a multi-hour
|
|
10
|
+
* outage to schema introspection running 4-6 times concurrently on the request
|
|
11
|
+
* path.
|
|
12
|
+
*
|
|
13
|
+
* `withMigrationRuntime()` is load-bearing. The Netlify BUILD environment sets
|
|
14
|
+
* NETLIFY=true, so this script looks like a serverless request to the guard in
|
|
15
|
+
* `runMigrations` — it is allowed to migrate only because it claims duty here.
|
|
16
|
+
* A release entrypoint that forgets the wrapper silently does nothing.
|
|
17
|
+
*
|
|
18
|
+
* If this app owns tables of its own, export its migration runner from
|
|
19
|
+
* `server/plugins/db.ts` and call it inside the same block.
|
|
20
|
+
*/
|
|
21
|
+
async function main(): Promise<void> {
|
|
22
|
+
await withMigrationRuntime(async () => {
|
|
23
|
+
await runFrameworkReleaseMigrations(null);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await main();
|
|
29
|
+
} finally {
|
|
30
|
+
await closeDbExec();
|
|
31
|
+
}
|
|
@@ -36,8 +36,10 @@ Tier 4 includes **all** of the following — not only editing package source:
|
|
|
36
36
|
- Files under `node_modules/@agent-native/*` (core, dispatch, scheduling, …)
|
|
37
37
|
- `pnpm.overrides`, `overrides`, `resolutions`, or `patchedDependencies` that
|
|
38
38
|
target any `@agent-native/*` package
|
|
39
|
-
-
|
|
40
|
-
|
|
39
|
+
- `pnpm patch`, `pnpm patch-commit`, or local package patch artifacts for any
|
|
40
|
+
dependency
|
|
41
|
+
- Invented "dispatch/core behavior" shims meant to paper over a version skew
|
|
42
|
+
or failed upgrade
|
|
41
43
|
|
|
42
44
|
This does not prohibit intentional app-owned UI customization. When public
|
|
43
45
|
props and composition are insufficient, the `customizing-agent-native` skill
|
|
@@ -100,8 +102,10 @@ inline strings in components.
|
|
|
100
102
|
- Don't confuse readable package source with app-owned code: use
|
|
101
103
|
`customizing-agent-native` and `agent-native eject` for supported ownership
|
|
102
104
|
transfer
|
|
105
|
+
- Don't use `pnpm patch` / `pnpm patch-commit`, commit `patches/` artifacts, or
|
|
106
|
+
add `pnpm.patchedDependencies` to "make the app run" after a version bump
|
|
103
107
|
- Don't add `pnpm.overrides` / `patchedDependencies` / `resolutions` for
|
|
104
|
-
`@agent-native/*` to
|
|
108
|
+
`@agent-native/*` to paper over a broken upgrade
|
|
105
109
|
- Don't invent local dispatch/core behavior overrides when upgrade fails —
|
|
106
110
|
run `npx @agent-native/core@latest upgrade`, then fix app-level errors only
|
|
107
111
|
- Don't modify `.agents/skills/` or `AGENTS.md` unless explicitly requested
|
|
@@ -15,8 +15,9 @@ metadata:
|
|
|
15
15
|
|
|
16
16
|
When an older Agent Native app/branch needs to run on current packages, use
|
|
17
17
|
`agent-native upgrade`. Never "fix" upgrade breakage with
|
|
18
|
-
`pnpm
|
|
19
|
-
|
|
18
|
+
`pnpm patch`, `pnpm patch-commit`, `pnpm.patchedDependencies`,
|
|
19
|
+
`pnpm.overrides`, `patchedDependencies`, `resolutions`, local patch artifacts,
|
|
20
|
+
or edits under `node_modules/@agent-native/*` — especially not against
|
|
20
21
|
`@agent-native/core` or `@agent-native/dispatch`.
|
|
21
22
|
|
|
22
23
|
## Why
|
|
@@ -109,6 +110,8 @@ install → refresh scaffold skills → verify, then fix **app** code only.
|
|
|
109
110
|
|
|
110
111
|
- Don't add `pnpm.overrides`, `overrides`, `resolutions`, or
|
|
111
112
|
`patchedDependencies` for any `@agent-native/*` package
|
|
113
|
+
- Don't run `pnpm patch` or `pnpm patch-commit`, or commit files under
|
|
114
|
+
`patches/`, for any dependency
|
|
112
115
|
- Don't edit `node_modules/@agent-native/core` or
|
|
113
116
|
`node_modules/@agent-native/dispatch`
|
|
114
117
|
- Don't invent local "dispatch behavior" shims to paper over version skew
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"agent-native:doctor": "agent-native doctor",
|
|
12
12
|
"action": "agent-native action",
|
|
13
13
|
"script": "agent-native script",
|
|
14
|
+
"migrate:production": "tsx scripts/migrate-production.ts",
|
|
14
15
|
"skills:update": "agent-native skills update scaffold --project",
|
|
15
16
|
"upgrade:agent-native": "agent-native upgrade"
|
|
16
17
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { closeDbExec, withMigrationRuntime } from "@agent-native/core/db";
|
|
2
|
+
import { runFrameworkReleaseMigrations } from "@agent-native/core/server";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Release-time schema entrypoint.
|
|
6
|
+
*
|
|
7
|
+
* Every deploy runs this once, and request functions never touch schema. That
|
|
8
|
+
* ordering is not an optimization: on serverless, "migrate on first use" means
|
|
9
|
+
* migrate on EVERY cold start, and a production incident traced a multi-hour
|
|
10
|
+
* outage to schema introspection running 4-6 times concurrently on the request
|
|
11
|
+
* path.
|
|
12
|
+
*
|
|
13
|
+
* `withMigrationRuntime()` is load-bearing. The Netlify BUILD environment sets
|
|
14
|
+
* NETLIFY=true, so this script looks like a serverless request to the guard in
|
|
15
|
+
* `runMigrations` — it is allowed to migrate only because it claims duty here.
|
|
16
|
+
* A release entrypoint that forgets the wrapper silently does nothing.
|
|
17
|
+
*
|
|
18
|
+
* If this app owns tables of its own, export its migration runner from
|
|
19
|
+
* `server/plugins/db.ts` and call it inside the same block.
|
|
20
|
+
*/
|
|
21
|
+
async function main(): Promise<void> {
|
|
22
|
+
await withMigrationRuntime(async () => {
|
|
23
|
+
await runFrameworkReleaseMigrations(null);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await main();
|
|
29
|
+
} finally {
|
|
30
|
+
await closeDbExec();
|
|
31
|
+
}
|
|
@@ -15,8 +15,9 @@ metadata:
|
|
|
15
15
|
|
|
16
16
|
When an older Agent Native app/branch needs to run on current packages, use
|
|
17
17
|
`agent-native upgrade`. Never "fix" upgrade breakage with
|
|
18
|
-
`pnpm
|
|
19
|
-
|
|
18
|
+
`pnpm patch`, `pnpm patch-commit`, `pnpm.patchedDependencies`,
|
|
19
|
+
`pnpm.overrides`, `patchedDependencies`, `resolutions`, local patch artifacts,
|
|
20
|
+
or edits under `node_modules/@agent-native/*` — especially not against
|
|
20
21
|
`@agent-native/core` or `@agent-native/dispatch`.
|
|
21
22
|
|
|
22
23
|
## Why
|
|
@@ -109,6 +110,8 @@ install → refresh scaffold skills → verify, then fix **app** code only.
|
|
|
109
110
|
|
|
110
111
|
- Don't add `pnpm.overrides`, `overrides`, `resolutions`, or
|
|
111
112
|
`patchedDependencies` for any `@agent-native/*` package
|
|
113
|
+
- Don't run `pnpm patch` or `pnpm patch-commit`, or commit files under
|
|
114
|
+
`patches/`, for any dependency
|
|
112
115
|
- Don't edit `node_modules/@agent-native/core` or
|
|
113
116
|
`node_modules/@agent-native/dispatch`
|
|
114
117
|
- Don't invent local "dispatch behavior" shims to paper over version skew
|
|
@@ -36,8 +36,10 @@ Tier 4 includes **all** of the following — not only editing package source:
|
|
|
36
36
|
- Files under `node_modules/@agent-native/*` (core, dispatch, scheduling, …)
|
|
37
37
|
- `pnpm.overrides`, `overrides`, `resolutions`, or `patchedDependencies` that
|
|
38
38
|
target any `@agent-native/*` package
|
|
39
|
-
-
|
|
40
|
-
|
|
39
|
+
- `pnpm patch`, `pnpm patch-commit`, or local package patch artifacts for any
|
|
40
|
+
dependency
|
|
41
|
+
- Invented "dispatch/core behavior" shims meant to paper over a version skew
|
|
42
|
+
or failed upgrade
|
|
41
43
|
|
|
42
44
|
This does not prohibit intentional app-owned UI customization. When public
|
|
43
45
|
props and composition are insufficient, the `customizing-agent-native` skill
|
|
@@ -100,8 +102,10 @@ inline strings in components.
|
|
|
100
102
|
- Don't confuse readable package source with app-owned code: use
|
|
101
103
|
`customizing-agent-native` and `agent-native eject` for supported ownership
|
|
102
104
|
transfer
|
|
105
|
+
- Don't use `pnpm patch` / `pnpm patch-commit`, commit `patches/` artifacts, or
|
|
106
|
+
add `pnpm.patchedDependencies` to "make the app run" after a version bump
|
|
103
107
|
- Don't add `pnpm.overrides` / `patchedDependencies` / `resolutions` for
|
|
104
|
-
`@agent-native/*` to
|
|
108
|
+
`@agent-native/*` to paper over a broken upgrade
|
|
105
109
|
- Don't invent local dispatch/core behavior overrides when upgrade fails —
|
|
106
110
|
run `npx @agent-native/core@latest upgrade`, then fix app-level errors only
|
|
107
111
|
- Don't modify `.agents/skills/` or `AGENTS.md` unless explicitly requested
|
|
@@ -15,8 +15,9 @@ metadata:
|
|
|
15
15
|
|
|
16
16
|
When an older Agent Native app/branch needs to run on current packages, use
|
|
17
17
|
`agent-native upgrade`. Never "fix" upgrade breakage with
|
|
18
|
-
`pnpm
|
|
19
|
-
|
|
18
|
+
`pnpm patch`, `pnpm patch-commit`, `pnpm.patchedDependencies`,
|
|
19
|
+
`pnpm.overrides`, `patchedDependencies`, `resolutions`, local patch artifacts,
|
|
20
|
+
or edits under `node_modules/@agent-native/*` — especially not against
|
|
20
21
|
`@agent-native/core` or `@agent-native/dispatch`.
|
|
21
22
|
|
|
22
23
|
## Why
|
|
@@ -109,6 +110,8 @@ install → refresh scaffold skills → verify, then fix **app** code only.
|
|
|
109
110
|
|
|
110
111
|
- Don't add `pnpm.overrides`, `overrides`, `resolutions`, or
|
|
111
112
|
`patchedDependencies` for any `@agent-native/*` package
|
|
113
|
+
- Don't run `pnpm patch` or `pnpm patch-commit`, or commit files under
|
|
114
|
+
`patches/`, for any dependency
|
|
112
115
|
- Don't edit `node_modules/@agent-native/core` or
|
|
113
116
|
`node_modules/@agent-native/dispatch`
|
|
114
117
|
- Don't invent local "dispatch behavior" shims to paper over version skew
|
|
@@ -36,7 +36,8 @@ Preview before `--apply`, commit `agent-native.ejections.json`, and never edit
|
|
|
36
36
|
To bring an older workspace current, run `pnpm upgrade:agent-native` or
|
|
37
37
|
`npx @agent-native/core@latest upgrade` from the workspace root. That bumps
|
|
38
38
|
`@agent-native/*` deps, installs, refreshes scaffold skills, and typechecks.
|
|
39
|
-
Do **not**
|
|
39
|
+
Do **not** run `pnpm patch` / `pnpm patch-commit`, add
|
|
40
|
+
`pnpm.patchedDependencies`, commit dependency patches, or edit
|
|
40
41
|
`node_modules/@agent-native/*` when an upgrade fails — fix app code or ask.
|
|
41
42
|
See the `upgrade-agent-native` and `self-modifying-code` skills.
|
|
42
43
|
After a manual core bump only, `pnpm skills:update` (or
|