@agent-native/core 0.147.0 → 0.148.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 (172) hide show
  1. package/corpus/README.md +1 -1
  2. package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +115 -68
  3. package/corpus/templates/analytics/DEVELOPING.md +50 -3
  4. package/corpus/templates/analytics/actions/purge-first-party-analytics-postgres.ts +190 -0
  5. package/corpus/templates/analytics/app/i18n/index.ts +14 -29
  6. package/corpus/templates/analytics/app/i18n-data.ts +10 -10
  7. package/corpus/templates/analytics/app/pages/Settings.tsx +5 -21
  8. package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +1 -3
  9. package/corpus/templates/analytics/scripts/first-party-analytics-bigquery-backfill.ts +197 -18
  10. package/corpus/templates/analytics/server/db/schema.ts +23 -0
  11. package/corpus/templates/analytics/server/handlers/first-party-analytics.ts +3 -1
  12. package/corpus/templates/analytics/server/jobs/analytics-bigquery-backfill.ts +1 -1
  13. package/corpus/templates/analytics/server/lib/first-party-analytics-backend.ts +113 -13
  14. package/corpus/templates/analytics/server/lib/first-party-analytics-purge.ts +140 -0
  15. package/corpus/templates/analytics/server/lib/first-party-analytics-volume.ts +207 -0
  16. package/corpus/templates/analytics/server/lib/first-party-analytics.ts +40 -9
  17. package/corpus/templates/analytics/server/lib/gcloud.ts +148 -20
  18. package/corpus/templates/analytics/server/plugins/db.ts +42 -0
  19. package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +115 -68
  20. package/corpus/templates/assets/app/i18n/index.ts +14 -29
  21. package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +115 -68
  22. package/corpus/templates/brain/app/i18n/index.ts +14 -29
  23. package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +115 -68
  24. package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +115 -68
  25. package/corpus/templates/chat/app/i18n/index.ts +14 -29
  26. package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +115 -68
  27. package/corpus/templates/clips/app/components/player/transcript-panel.tsx +2 -7
  28. package/corpus/templates/clips/app/components/recorder/storage-setup-card.tsx +18 -13
  29. package/corpus/templates/clips/app/components/settings/ai-setup-section.tsx +87 -370
  30. package/corpus/templates/clips/app/components/settings/slack-section.tsx +59 -101
  31. package/corpus/templates/clips/app/components/settings/video-storage-section.tsx +136 -213
  32. package/corpus/templates/clips/app/i18n/en-US.ts +11 -8
  33. package/corpus/templates/clips/desktop/src/app.tsx +1 -1
  34. package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +115 -68
  35. package/corpus/templates/content/app/i18n/index.ts +14 -29
  36. package/corpus/templates/crm/app/i18n/index.ts +14 -29
  37. package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +115 -68
  38. package/corpus/templates/design/actions/analyze-brand-assets.ts +15 -15
  39. package/corpus/templates/design/actions/import-code.ts +2 -43
  40. package/corpus/templates/design/app/i18n/index.ts +14 -29
  41. package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +115 -68
  42. package/corpus/templates/dispatch/app/i18n-data.ts +1 -1
  43. package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +115 -68
  44. package/corpus/templates/factory/AGENTS.md +40 -49
  45. package/corpus/templates/factory/actions/babysit-agent-native-pull-request.ts +66 -0
  46. package/corpus/templates/factory/actions/evaluate-triage-item.ts +37 -0
  47. package/corpus/templates/factory/actions/get-slack-feedback-context.ts +20 -0
  48. package/corpus/templates/factory/actions/get-triage-item.ts +25 -4
  49. package/corpus/templates/factory/actions/govern-agent-native-pull-request.ts +55 -0
  50. package/corpus/templates/factory/actions/ingest-github-observation.ts +21 -0
  51. package/corpus/templates/factory/actions/list-factory-audit.ts +118 -0
  52. package/corpus/templates/factory/actions/list-factory-automations.ts +2 -1
  53. package/corpus/templates/factory/actions/list-triage-items.ts +24 -2
  54. package/corpus/templates/factory/actions/poll-github-sources.ts +60 -0
  55. package/corpus/templates/factory/actions/poll-sentry-errors.ts +39 -0
  56. package/corpus/templates/factory/actions/poll-slack-channel.ts +45 -1
  57. package/corpus/templates/factory/actions/run-factory-automation.ts +1 -1
  58. package/corpus/templates/factory/actions/save-factory-automation.ts +2 -2
  59. package/corpus/templates/factory/actions/start-builder-for-item.ts +51 -0
  60. package/corpus/templates/factory/app/components/factory/FactoryAuditView.tsx +685 -0
  61. package/corpus/templates/factory/app/hooks/use-navigation-state.ts +6 -0
  62. package/corpus/templates/factory/app/i18n/en-US.ts +25 -0
  63. package/corpus/templates/factory/app/routes/factory.tsx +95 -42
  64. package/corpus/templates/factory/server/db/schema.ts +37 -0
  65. package/corpus/templates/factory/server/lib/require-factory-automation.ts +5 -1
  66. package/corpus/templates/factory/server/plugins/factory-migrations.ts +29 -0
  67. package/corpus/templates/factory/server/triage/audit.ts +79 -0
  68. package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +115 -68
  69. package/corpus/templates/forms/app/i18n/index.ts +14 -29
  70. package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +115 -68
  71. package/corpus/templates/macros/app/i18n/index.ts +14 -29
  72. package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +115 -68
  73. package/corpus/templates/mail/app/i18n/index.ts +14 -29
  74. package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +115 -68
  75. package/corpus/templates/plan/app/components/plan/wireframe/Wireframe.tsx +7 -7
  76. package/corpus/templates/plan/app/i18n/index.ts +14 -29
  77. package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +115 -68
  78. package/corpus/templates/slides/actions/analyze-brand-assets.ts +15 -15
  79. package/corpus/templates/slides/actions/import-code.ts +2 -43
  80. package/corpus/templates/slides/app/i18n/index.ts +14 -29
  81. package/corpus/templates/slides/server/routes/api/preview-images.get.ts +4 -1
  82. package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +115 -68
  83. package/corpus/templates/tasks/app/components/layout/HeaderActions.tsx +1 -84
  84. package/corpus/templates/tasks/app/hooks/use-mobile.tsx +1 -21
  85. package/corpus/templates/tasks/app/i18n/index.ts +14 -29
  86. package/dist/agent/engine/ai-sdk-engine.js +2 -1
  87. package/dist/agent/engine/openai-compatible-endpoint.d.ts +2 -0
  88. package/dist/agent/engine/openai-compatible-endpoint.js +5 -1
  89. package/dist/agent/engine/provider-endpoint-validation.d.ts +9 -0
  90. package/dist/agent/engine/provider-endpoint-validation.js +26 -0
  91. package/dist/agent/engine/provider-env-vars.d.ts +1 -1
  92. package/dist/agent/engine/provider-env-vars.js +1 -1
  93. package/dist/agent/engine/registry.d.ts +8 -6
  94. package/dist/agent/engine/registry.js +37 -24
  95. package/dist/agent/tool-search.d.ts +1 -0
  96. package/dist/agent/tool-search.js +17 -1
  97. package/dist/automations/service.js +4 -10
  98. package/dist/brand-kit/brand-signals.d.ts +13 -0
  99. package/dist/brand-kit/brand-signals.js +15 -0
  100. package/dist/brand-kit/index.d.ts +2 -2
  101. package/dist/brand-kit/index.js +1 -1
  102. package/dist/cli/plan-blocks.d.ts +3 -18
  103. package/dist/cli/plan-blocks.js +2 -95
  104. package/dist/cli/plan-publish-store.d.ts +2 -61
  105. package/dist/cli/plan-publish-store.js +2 -127
  106. package/dist/cli/skills-content/connection.d.ts +1 -1
  107. package/dist/cli/skills-content/connection.js +1 -52
  108. package/dist/cli/skills-content/visual-recap-skill.d.ts +1 -1
  109. package/dist/cli/skills-content/visual-recap-skill.js +1 -553
  110. package/dist/client/agent-engine-key.d.ts +14 -4
  111. package/dist/client/agent-engine-key.js +51 -5
  112. package/dist/client/agent-provider-catalog.d.ts +20 -0
  113. package/dist/client/agent-provider-catalog.js +100 -0
  114. package/dist/client/blocks/index.d.ts +1 -0
  115. package/dist/client/blocks/index.js +1 -0
  116. package/dist/client/chat/run-recovery.js +4 -48
  117. package/dist/client/chat-first.js +4 -3
  118. package/dist/client/i18n.d.ts +14 -0
  119. package/dist/client/i18n.js +18 -0
  120. package/dist/client/settings/ProviderSetupForm.d.ts +21 -0
  121. package/dist/client/settings/ProviderSetupForm.js +145 -0
  122. package/dist/client/settings/SettingsPanel.js +52 -49
  123. package/dist/client/settings/index.d.ts +2 -0
  124. package/dist/client/settings/index.js +2 -0
  125. package/dist/coding-tools/run-code.d.ts +5 -0
  126. package/dist/coding-tools/run-code.js +196 -36
  127. package/dist/coding-tools/tool-orchestration.d.ts +10 -0
  128. package/dist/coding-tools/tool-orchestration.js +107 -0
  129. package/dist/collab/awareness.d.ts +2 -2
  130. package/dist/jobs/frontmatter.d.ts +9 -0
  131. package/dist/jobs/frontmatter.js +16 -0
  132. package/dist/jobs/scheduler.js +8 -8
  133. package/dist/jobs/tools.d.ts +1 -1
  134. package/dist/jobs/tools.js +2 -7
  135. package/dist/localization/default-messages.d.ts +20 -0
  136. package/dist/localization/default-messages.js +25 -5
  137. package/dist/observability/routes.d.ts +3 -3
  138. package/dist/onboarding/app-profile.js +1 -1
  139. package/dist/progress/routes.d.ts +1 -1
  140. package/dist/provider-api/actions/custom-provider-registration.d.ts +8 -8
  141. package/dist/provider-api/actions/provider-api.d.ts +11 -11
  142. package/dist/resources/handlers.d.ts +1 -1
  143. package/dist/scripts/agent-engines/test-agent-engine.js +34 -10
  144. package/dist/secrets/routes.d.ts +9 -9
  145. package/dist/server/agent-chat/run-code-tools.d.ts +1 -1
  146. package/dist/server/agent-chat/run-code-tools.js +3 -1
  147. package/dist/server/agent-chat-plugin.js +6 -6
  148. package/dist/server/agent-engine-api-key-route.d.ts +1 -1
  149. package/dist/server/agent-engine-api-key-route.js +43 -12
  150. package/dist/server/agents-bundle.js +2 -1
  151. package/dist/server/auth.js +21 -5
  152. package/dist/server/credential-provider.js +1 -0
  153. package/dist/server/design-token-utils.d.ts +18 -0
  154. package/dist/server/design-token-utils.js +31 -0
  155. package/dist/server/onboarding-html.js +22 -2
  156. package/dist/server/realtime-token.d.ts +1 -1
  157. package/dist/templates/chat/.agents/skills/frontend-design/SKILL.md +115 -68
  158. package/dist/templates/chat/app/i18n/index.ts +14 -29
  159. package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +115 -68
  160. package/dist/templates/default/app/i18n/index.ts +14 -29
  161. package/dist/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +22 -9
  162. package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +115 -68
  163. package/dist/triggers/dispatcher.js +1 -8
  164. package/docs/content/environment-variables.mdx +39 -38
  165. package/package.json +4 -4
  166. package/src/templates/chat/.agents/skills/frontend-design/SKILL.md +115 -68
  167. package/src/templates/chat/app/i18n/index.ts +14 -29
  168. package/src/templates/default/.agents/skills/frontend-design/SKILL.md +115 -68
  169. package/src/templates/default/app/i18n/index.ts +14 -29
  170. package/src/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +22 -9
  171. package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +115 -68
  172. package/corpus/templates/plan/app/components/plan/wireframe/sanitize-html.ts +0 -343
@@ -0,0 +1,107 @@
1
+ import { executeSandboxCode, } from "./run-code.js";
2
+ const DEFAULT_TIMEOUT_MS = 60_000;
3
+ const MAX_TIMEOUT_MS = 120_000;
4
+ const DEFAULT_MAX_OUTPUT_CHARS = 50_000;
5
+ const MAX_OUTPUT_CHARS = 100_000;
6
+ const DEFAULT_MAX_TOOL_CALLS = 32;
7
+ const MAX_TOOL_CALLS = 128;
8
+ /**
9
+ * Create the bounded read-only orchestration tool.
10
+ *
11
+ * This deliberately has a separate registry entry from run-code. The latter
12
+ * retains its existing workspace staging and background-execution contract;
13
+ * this entry is for short fan-out, reduction, and aggregation over tools that
14
+ * the host can prove are read-only for the supplied arguments.
15
+ */
16
+ export function createToolOrchestrationEntry(getActions) {
17
+ return {
18
+ readOnly: true,
19
+ allowInPlanMode: false,
20
+ timeoutMs: MAX_TIMEOUT_MS,
21
+ maxResultChars: MAX_OUTPUT_CHARS,
22
+ tool: {
23
+ description: [
24
+ "Run a bounded JavaScript orchestration script in the existing sandbox.",
25
+ "Use toolSearch(query) to discover read-only or conditionally read-only tools, then toolCall(name, args) to fan out, join, filter, and aggregate their results without putting every intermediate payload into chat. The host rechecks conditional policies against each argument object.",
26
+ "The host rechecks every child call: mutating actions, hidden actions, provider writes, non-GET/HEAD web requests, staging, file saves, and workspace writes are rejected. Call mutations directly as native tools.",
27
+ "The orchestration sandbox has no background mode, a strict child-tool-call budget, and a 20-page cap on each provider fetchAllPages call. It is a bounded orchestration path, not a general-purpose replacement for run-code.",
28
+ "Available globals: toolSearch(query?, options?), toolCall(name, args?), providerFetch(provider, path, init?), providerFetchAll(...), providerSearchAll(...), webFetch(url, init?), webRead(url, init?), workspaceRead(path, opts?), workspaceReadMeta(path, opts?), workspaceList(prefix?), and appAction(name, args?) for eligible read-only actions.",
29
+ "Print only the compact result needed by the conversation with console.log().",
30
+ ].join(" "),
31
+ parameters: {
32
+ type: "object",
33
+ properties: {
34
+ code: {
35
+ type: "string",
36
+ description: "JavaScript source to execute. ESM syntax and top-level await are supported.",
37
+ },
38
+ timeoutMs: {
39
+ type: "number",
40
+ description: `Execution timeout in milliseconds. Default: ${DEFAULT_TIMEOUT_MS}; max: ${MAX_TIMEOUT_MS}.`,
41
+ },
42
+ maxOutputChars: {
43
+ type: "number",
44
+ description: `Maximum combined stdout+stderr characters. Default: ${DEFAULT_MAX_OUTPUT_CHARS}; max: ${MAX_OUTPUT_CHARS}.`,
45
+ },
46
+ maxToolCalls: {
47
+ type: "number",
48
+ description: `Maximum bridged child-tool calls. Default: ${DEFAULT_MAX_TOOL_CALLS}; max: ${MAX_TOOL_CALLS}.`,
49
+ },
50
+ },
51
+ required: ["code"],
52
+ },
53
+ },
54
+ run: async (args, context) => {
55
+ if (args.background || args.executionId) {
56
+ return "Error: tool-orchestration is foreground-only and does not support background or polling arguments. Use run-code for durable long-running execution.";
57
+ }
58
+ const code = typeof args.code === "string" ? args.code : "";
59
+ if (!code.trim())
60
+ return "Error: code is required.";
61
+ const requestedTimeout = Number(args.timeoutMs);
62
+ const timeoutMs = Number.isFinite(requestedTimeout) && requestedTimeout > 0
63
+ ? Math.min(requestedTimeout, MAX_TIMEOUT_MS)
64
+ : DEFAULT_TIMEOUT_MS;
65
+ const requestedOutput = Number(args.maxOutputChars);
66
+ const maxOutputChars = Number.isFinite(requestedOutput) && requestedOutput > 0
67
+ ? Math.min(requestedOutput, MAX_OUTPUT_CHARS)
68
+ : DEFAULT_MAX_OUTPUT_CHARS;
69
+ const requestedCalls = Number(args.maxToolCalls);
70
+ const maxToolCalls = Number.isFinite(requestedCalls) && requestedCalls > 0
71
+ ? Math.min(Math.floor(requestedCalls), MAX_TOOL_CALLS)
72
+ : DEFAULT_MAX_TOOL_CALLS;
73
+ const result = await executeSandboxCode({
74
+ code,
75
+ timeoutMs,
76
+ getActions,
77
+ mode: "tool-orchestration",
78
+ maxToolCalls,
79
+ context,
80
+ });
81
+ return formatResult(result, timeoutMs, maxOutputChars);
82
+ },
83
+ };
84
+ }
85
+ function formatResult(result, timeoutMs, maxOutputChars) {
86
+ const combined = [
87
+ result.stdout ? `stdout:\n${result.stdout}` : "",
88
+ result.stderr ? `stderr:\n${result.stderr}` : "",
89
+ ]
90
+ .filter(Boolean)
91
+ .join("\n\n") || "(no output)";
92
+ const lines = [];
93
+ if (result.timedOut)
94
+ lines.push(`timedOut: true (${timeoutMs}ms)`);
95
+ if (result.exitCode !== 0 && result.exitCode !== null) {
96
+ lines.push(`exitCode: ${result.exitCode}`);
97
+ }
98
+ if (result.bridgeToolsUsed.length) {
99
+ lines.push(`bridgeToolsUsed: ${result.bridgeToolsUsed.join(", ")}`);
100
+ }
101
+ lines.push(combined);
102
+ const full = lines.join("\n\n");
103
+ if (full.length <= maxOutputChars)
104
+ return full;
105
+ const truncated = full.slice(0, maxOutputChars);
106
+ return `${truncated}\n\n...[truncated ${(full.length - maxOutputChars).toLocaleString()} chars]`;
107
+ }
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
62
62
  error: string;
63
63
  states?: undefined;
64
64
  } | {
65
- error?: undefined;
66
65
  states: {
67
66
  clientId: number;
68
67
  state: string;
69
68
  }[];
69
+ error?: undefined;
70
70
  }>>;
71
71
  /**
72
72
  * GET /_agent-native/collab/:docId/users
@@ -77,9 +77,9 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
77
77
  error: string;
78
78
  users?: undefined;
79
79
  } | {
80
- error?: undefined;
81
80
  users: {
82
81
  clientId: number;
83
82
  lastSeen: number;
84
83
  }[];
84
+ error?: undefined;
85
85
  }>>;
@@ -54,6 +54,15 @@ export interface JobFrontmatter {
54
54
  */
55
55
  delegatedPolicyId?: string;
56
56
  }
57
+ /**
58
+ * Return whether a scheduler or trigger dispatcher may claim this resource.
59
+ *
60
+ * Personal legacy jobs have no app owner and remain compatible with the
61
+ * shared scheduler. An organization-owned resource without an explicit app
62
+ * owner is ambiguous, though: letting every installed app claim it can run
63
+ * the same job multiple times and with the wrong deployment credentials.
64
+ */
65
+ export declare function jobBelongsToApp(meta: Pick<JobFrontmatter, "appId" | "orgId">, appId: string | null | undefined): boolean;
57
66
  export interface JobResourceClassification {
58
67
  kind: "job" | "automation";
59
68
  hasExplicitTriggerType: boolean;
@@ -1,3 +1,19 @@
1
+ /**
2
+ * Return whether a scheduler or trigger dispatcher may claim this resource.
3
+ *
4
+ * Personal legacy jobs have no app owner and remain compatible with the
5
+ * shared scheduler. An organization-owned resource without an explicit app
6
+ * owner is ambiguous, though: letting every installed app claim it can run
7
+ * the same job multiple times and with the wrong deployment credentials.
8
+ */
9
+ export function jobBelongsToApp(meta, appId) {
10
+ const ownerAppId = meta.appId?.trim();
11
+ if (ownerAppId) {
12
+ const schedulerAppId = appId?.trim();
13
+ return Boolean(schedulerAppId && ownerAppId === schedulerAppId);
14
+ }
15
+ return !meta.orgId?.trim();
16
+ }
1
17
  const MAX_JOB_MCP_TOOLS = 64;
2
18
  const JOB_MCP_TOOL_NAME_RE = /^mcp__[^\s]+__[^\s]+$/;
3
19
  const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/;
@@ -1,7 +1,7 @@
1
1
  import { resourceGetByPath, resourceListAllOwners, resourcePutIfCurrent, } from "../resources/store.js";
2
2
  import { backgroundRunCutOffReason, isBackgroundAutomationRunActive, resolveBackgroundAutomationIdentity, runBackgroundAutomation, } from "./background-automation-runner.js";
3
3
  import { nextOccurrence, isValidCron, describeCron, effectiveTimezone, } from "./cron.js";
4
- import { buildJobResourceContent, parseJobResource, } from "./frontmatter.js";
4
+ import { buildJobResourceContent, jobBelongsToApp, parseJobResource, } from "./frontmatter.js";
5
5
  import { claimAutomationRun, finishAutomationRun, getAutomationRun, listAutomationRuns, } from "./run-history.js";
6
6
  import { acquireAutomationSchedulerLease, recordAutomationSchedulerHealth, releaseAutomationSchedulerLease, renewAutomationSchedulerLease, AUTOMATION_SCHEDULER_LEASE_RENEWAL_MS, } from "./scheduler-health.js";
7
7
  // ─── Frontmatter parsing ────────────────────────────────────────────────────
@@ -18,13 +18,6 @@ const MAX_IDENTITY_PREFLIGHTS_PER_TICK = MAX_CONCURRENT_SCHEDULED_JOBS * 4;
18
18
  const IDENTITY_FAILURE_RETRY_MS = 5 * 60_000;
19
19
  const _activeScheduledJobs = new Set();
20
20
  const _preflightingScheduledJobs = new Set();
21
- function jobBelongsToApp(meta, appId) {
22
- const ownerAppId = meta.appId?.trim();
23
- if (!ownerAppId)
24
- return true;
25
- const schedulerAppId = appId?.trim();
26
- return Boolean(schedulerAppId && ownerAppId === schedulerAppId);
27
- }
28
21
  // Skip the DB query on every tick if we recently confirmed no jobs exist.
29
22
  // `_hasJobsCache` is invalidated whenever a `jobs/*` resource is written or
30
23
  // deleted (subscribed below), and refreshed at most every 5 minutes.
@@ -429,6 +422,13 @@ async function executeJob(resource, meta, body, deps, now, options = {}) {
429
422
  requestContext,
430
423
  ...(options.historyId ? { historyId: options.historyId } : {}),
431
424
  actionCaller: "automation",
425
+ actionAutomation: {
426
+ triggerId: resource.id,
427
+ triggerName: jobName,
428
+ ...(meta.delegatedPolicyId
429
+ ? { policyId: meta.delegatedPolicyId }
430
+ : {}),
431
+ },
432
432
  }, deps);
433
433
  await recordExecutionOutcome(resource, {
434
434
  lastRun: meta.lastRun,
@@ -1,6 +1,6 @@
1
1
  import type { ActionEntry } from "../agent/production-agent.js";
2
2
  import { type JobFrontmatter } from "./scheduler.js";
3
- export declare function jobBelongsToApp(meta: JobFrontmatter, appId?: string): boolean;
3
+ export { jobBelongsToApp } from "./frontmatter.js";
4
4
  /**
5
5
  * Authorise a mutation (update / delete) against a job resource. When the
6
6
  * job is in the SHARED scope the caller must either be the original
@@ -3,8 +3,9 @@ import { resolveUserSchedulingTimezone } from "../localization/user-timezone.js"
3
3
  import { resourcePut, resourceGetByPath, resourceList, resourceDelete, organizationIdFromResourceOwner, sharedResourceOwner, SHARED_OWNER, } from "../resources/store.js";
4
4
  import { getRequestUserEmail, getRequestOrgId, getIntegrationRequestContext, } from "../server/request-context.js";
5
5
  import { isValidCron, nextOccurrence, describeCron, effectiveTimezone, isValidTimezone, } from "./cron.js";
6
- import { classifyJobResource } from "./frontmatter.js";
6
+ import { classifyJobResource, jobBelongsToApp } from "./frontmatter.js";
7
7
  import { parseJobFrontmatter, buildJobContent, normalizeJobMcpTools, } from "./scheduler.js";
8
+ export { jobBelongsToApp } from "./frontmatter.js";
8
9
  function getOwner() {
9
10
  const email = getRequestUserEmail();
10
11
  if (!email)
@@ -14,12 +15,6 @@ function getOwner() {
14
15
  function getSharedOwner() {
15
16
  return sharedResourceOwner(getRequestOrgId());
16
17
  }
17
- export function jobBelongsToApp(meta, appId) {
18
- const ownerAppId = meta.appId?.trim();
19
- if (!ownerAppId)
20
- return true;
21
- return ownerAppId === appId?.trim();
22
- }
23
18
  /**
24
19
  * Determine if the current request's user is an org owner/admin in the
25
20
  * given org. Used to allow privileged users to update or delete shared
@@ -455,6 +455,26 @@ declare const messages: {
455
455
  builderModelCredits: string;
456
456
  addOwnKeys: string;
457
457
  configureProviderKeys: string;
458
+ chooseProvider: string;
459
+ searchProviders: string;
460
+ noProvidersFound: string;
461
+ availableProviders: string;
462
+ configured: string;
463
+ apiKey: string;
464
+ localRuntime: string;
465
+ enterApiKey: string;
466
+ providerSetupFailed: string;
467
+ noApiKeyNeeded: string;
468
+ modelId: string;
469
+ endpointUrl: string;
470
+ optional: string;
471
+ ollamaEndpointHint: string;
472
+ compatibleEndpointHint: string;
473
+ savingProvider: string;
474
+ providerSaved: string;
475
+ useProvider: string;
476
+ saveAndUseProvider: string;
477
+ getApiKey: string;
458
478
  checkingAiConnection: string;
459
479
  delegatedAgent: {
460
480
  asking: string;
@@ -389,7 +389,7 @@ const messages = {
389
389
  threadDebugRefreshFailures: "Refresh failed runs",
390
390
  threadDebugNoFailures: "No failed runs found.",
391
391
  threadDebugCurrentDatabase: "Current Dispatch DB",
392
- threadDebugSearchPlaceholder: "Search title, preview, messages, tools",
392
+ threadDebugSearchPlaceholder: "Search threads or email",
393
393
  threadDebugSearch: "Search",
394
394
  threadDebugLookupPlaceholder: "Paste thread or request/run ID",
395
395
  threadDebugInspect: "Inspect",
@@ -455,12 +455,32 @@ const messages = {
455
455
  askAgentTitle: "Ask the agent",
456
456
  askAgentPlaceholder: "Tell the agent what you want to do…",
457
457
  connectAi: "Connect AI",
458
- builderOrOwnKeys: "Use Builder.io free credits, or add your own provider keys.",
458
+ builderOrOwnKeys: "Choose Builder.io or custom keys.",
459
459
  connectBuilderIo: "Connect Builder.io",
460
460
  connectingBuilder: "Connecting Builder.io…",
461
461
  builderModelCredits: "Free credits for Claude, OpenAI & Gemini",
462
- addOwnKeys: "Add your own keys",
463
- configureProviderKeys: "Configure Anthropic, OpenAI, or another provider",
462
+ addOwnKeys: "Custom keys",
463
+ configureProviderKeys: "Choose a provider.",
464
+ chooseProvider: "Choose a provider",
465
+ searchProviders: "Search providers...",
466
+ noProvidersFound: "No providers found.",
467
+ availableProviders: "Available providers",
468
+ configured: "Configured",
469
+ apiKey: "API key",
470
+ localRuntime: "Local",
471
+ enterApiKey: "Enter your {{provider}} API key.",
472
+ providerSetupFailed: "Could not configure this provider.",
473
+ noApiKeyNeeded: "No API key required.",
474
+ modelId: "Model ID",
475
+ endpointUrl: "Endpoint URL",
476
+ optional: "Optional",
477
+ ollamaEndpointHint: "Defaults to Ollama at http://localhost:11434.",
478
+ compatibleEndpointHint: "Use this for LiteLLM or another OpenAI-compatible gateway.",
479
+ savingProvider: "Saving...",
480
+ providerSaved: "Connected",
481
+ useProvider: "Use {{provider}}",
482
+ saveAndUseProvider: "Save and use {{provider}}",
483
+ getApiKey: "Get an API key",
464
484
  checkingAiConnection: "Checking AI connection...",
465
485
  delegatedAgent: {
466
486
  asking: "Asking {{name}}...",
@@ -475,7 +495,7 @@ const messages = {
475
495
  setupTitle: "Set up voice mode",
476
496
  setupDescription: "Connect Builder.io to use managed voice with free credits, or add your own keys.",
477
497
  connectBuilder: "Connect Builder.io",
478
- useOpenAiKey: "Add your own keys",
498
+ useOpenAiKey: "Custom keys",
479
499
  startWithOpenAiKey: "Start with OpenAI key",
480
500
  start: "Real-time voice",
481
501
  keepDictating: "Dictate",
@@ -42,22 +42,22 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
42
42
  avgEvalScore: number;
43
43
  } | {
44
44
  error?: undefined;
45
- ok?: undefined;
46
45
  summary: import("./types.js").TraceSummary;
47
46
  spans: import("./types.js").TraceSpan[];
48
47
  id?: undefined;
48
+ ok?: undefined;
49
49
  } | {
50
50
  error?: undefined;
51
- ok?: undefined;
52
51
  summary?: undefined;
53
52
  spans?: undefined;
54
53
  id: string;
55
- } | {
56
54
  ok?: undefined;
55
+ } | {
57
56
  summary?: undefined;
58
57
  spans?: undefined;
59
58
  id?: undefined;
60
59
  error: any;
60
+ ok?: undefined;
61
61
  } | {
62
62
  error?: undefined;
63
63
  summary?: undefined;
@@ -3,7 +3,7 @@ const LLM_CAPABILITY = {
3
3
  label: "AI model",
4
4
  required: true,
5
5
  builderIncluded: true,
6
- keySummary: "One model key: Anthropic, OpenAI, Gemini, Groq, Mistral, or Cohere",
6
+ keySummary: "One model key or local connection: Anthropic, OpenAI, OpenRouter, Gemini, Groq, Mistral, Cohere, or Ollama",
7
7
  why: "The agent uses a language model to understand requests and produce answers.",
8
8
  };
9
9
  const DESIGN_SYSTEM_INTELLIGENCE_CAPABILITY = {
@@ -15,6 +15,6 @@ export declare function createProgressHandler(): import("h3").EventHandlerWithFe
15
15
  error: string;
16
16
  ok?: undefined;
17
17
  } | {
18
- error?: undefined;
19
18
  ok: boolean;
19
+ error?: undefined;
20
20
  }>>;
@@ -75,8 +75,9 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
75
75
  user: "user";
76
76
  }>>;
77
77
  }, z.core.$strip>>, {
78
- deleted?: undefined;
79
78
  id?: undefined;
79
+ provider?: undefined;
80
+ deleted?: undefined;
80
81
  providers: {
81
82
  id: string;
82
83
  label: string;
@@ -87,15 +88,14 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
87
88
  updatedAt: number;
88
89
  }[];
89
90
  count: number;
90
- provider?: undefined;
91
91
  found?: undefined;
92
92
  registered?: undefined;
93
93
  label?: undefined;
94
94
  message?: undefined;
95
95
  } | {
96
- deleted?: undefined;
97
96
  count?: undefined;
98
97
  id?: undefined;
98
+ deleted?: undefined;
99
99
  providers?: undefined;
100
100
  found: boolean;
101
101
  provider: import("../custom-registry.js").CustomProviderConfig;
@@ -103,10 +103,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
103
103
  label?: undefined;
104
104
  message?: undefined;
105
105
  } | {
106
- deleted?: undefined;
107
106
  count?: undefined;
108
- providers?: undefined;
109
107
  provider?: undefined;
108
+ deleted?: undefined;
109
+ providers?: undefined;
110
110
  found: boolean;
111
111
  id: string;
112
112
  registered?: undefined;
@@ -114,8 +114,8 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
114
114
  message?: undefined;
115
115
  } | {
116
116
  count?: undefined;
117
- providers?: undefined;
118
117
  provider?: undefined;
118
+ providers?: undefined;
119
119
  found?: undefined;
120
120
  deleted: boolean;
121
121
  id: string;
@@ -123,10 +123,10 @@ export declare function createCustomProviderRegistrationAction<TSchema extends Z
123
123
  label?: undefined;
124
124
  message?: undefined;
125
125
  } | {
126
- deleted?: undefined;
127
126
  count?: undefined;
128
- providers?: undefined;
129
127
  provider?: undefined;
128
+ deleted?: undefined;
129
+ providers?: undefined;
130
130
  found?: undefined;
131
131
  registered: boolean;
132
132
  id: string;
@@ -312,8 +312,6 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
312
312
  scope?: "org" | "user" | undefined;
313
313
  }, {
314
314
  id?: undefined;
315
- message?: undefined;
316
- provider?: undefined;
317
315
  deleted?: undefined;
318
316
  providers: {
319
317
  id: string;
@@ -325,44 +323,46 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
325
323
  updatedAt: number;
326
324
  }[];
327
325
  count: number;
326
+ provider?: undefined;
328
327
  found?: undefined;
329
328
  registered?: undefined;
330
329
  label?: undefined;
330
+ message?: undefined;
331
331
  } | {
332
332
  id?: undefined;
333
- message?: undefined;
334
- count?: undefined;
335
333
  deleted?: undefined;
334
+ count?: undefined;
336
335
  providers?: undefined;
337
336
  found: boolean;
338
337
  provider: import("../custom-registry.js").CustomProviderConfig;
339
338
  registered?: undefined;
340
339
  label?: undefined;
341
- } | {
342
340
  message?: undefined;
343
- count?: undefined;
344
- provider?: undefined;
341
+ } | {
345
342
  deleted?: undefined;
343
+ count?: undefined;
346
344
  providers?: undefined;
345
+ provider?: undefined;
347
346
  found: boolean;
348
347
  id: string;
349
348
  registered?: undefined;
350
349
  label?: undefined;
351
- } | {
352
350
  message?: undefined;
351
+ } | {
353
352
  count?: undefined;
354
- provider?: undefined;
355
353
  providers?: undefined;
354
+ provider?: undefined;
356
355
  found?: undefined;
357
356
  deleted: boolean;
358
357
  id: string;
359
358
  registered?: undefined;
360
359
  label?: undefined;
360
+ message?: undefined;
361
361
  } | {
362
- count?: undefined;
363
- provider?: undefined;
364
362
  deleted?: undefined;
363
+ count?: undefined;
365
364
  providers?: undefined;
365
+ provider?: undefined;
366
366
  found?: undefined;
367
367
  registered: boolean;
368
368
  id: string;
@@ -48,8 +48,8 @@ export declare function handleUpdateResource(event: any): Promise<import("./stor
48
48
  }>;
49
49
  /** DELETE /_agent-native/resources/:id — delete a resource */
50
50
  export declare function handleDeleteResource(event: any): Promise<{
51
- error: string;
52
51
  ok?: undefined;
52
+ error: string;
53
53
  } | {
54
54
  error?: undefined;
55
55
  ok: boolean;
@@ -2,7 +2,8 @@
2
2
  * test-agent-engine — sends a trivial prompt to verify the engine is working.
3
3
  */
4
4
  import { getAgentEngineEntry, registerBuiltinEngines, } from "../../agent/engine/index.js";
5
- import { normalizeOpenAiBaseUrl, OPENAI_BASE_URL_ENV_VAR, } from "../../agent/engine/openai-compatible-endpoint.js";
5
+ import { OLLAMA_BASE_URL_ENV_VAR, OPENAI_BASE_URL_ENV_VAR, } from "../../agent/engine/openai-compatible-endpoint.js";
6
+ import { validateProviderBaseUrl } from "../../agent/engine/provider-endpoint-validation.js";
6
7
  import { canUseDeployCredentialFallbackForRequest, readDeployCredentialEnv, resolveSecret, } from "../../server/credential-provider.js";
7
8
  export const tool = {
8
9
  description: "Test an agent engine by sending a trivial prompt and measuring latency. Useful for verifying API keys and connectivity before switching engines.",
@@ -31,13 +32,30 @@ async function resolveAgentEngineSecret(key) {
31
32
  if (value)
32
33
  return value;
33
34
  }
34
- catch {
35
- // Fall through to deploy env when this request is allowed to use it.
35
+ catch (error) {
36
+ if (!canUseDeployCredentialFallbackForRequest(key))
37
+ throw error;
38
+ console.warn("[test-agent-engine] Saved provider secret unavailable; using deploy configuration.", { key, error });
36
39
  }
37
40
  return canUseDeployCredentialFallbackForRequest(key)
38
41
  ? readDeployCredentialEnv(key)
39
42
  : undefined;
40
43
  }
44
+ async function resolveAgentEngineEndpoint(key) {
45
+ const value = await resolveSecret(key);
46
+ if (value) {
47
+ return validateProviderBaseUrl(value, {
48
+ allowLocalOllama: key === OLLAMA_BASE_URL_ENV_VAR &&
49
+ process.env.NODE_ENV === "development",
50
+ });
51
+ }
52
+ if (!canUseDeployCredentialFallbackForRequest(key))
53
+ return undefined;
54
+ const deployValue = readDeployCredentialEnv(key);
55
+ return deployValue
56
+ ? validateProviderBaseUrl(deployValue, { allowPrivate: true })
57
+ : undefined;
58
+ }
41
59
  function canUseDeployEnvForEntry(entry) {
42
60
  if (entry.requiredEnvVars.length === 0)
43
61
  return true;
@@ -50,13 +68,19 @@ async function createEngineConfig(entry, args) {
50
68
  : undefined,
51
69
  allowEnvFallback: canUseDeployEnvForEntry(entry),
52
70
  };
53
- if (entry.name === "ai-sdk:openai") {
54
- const rawBaseUrl = args.baseUrl?.trim()
55
- ? args.baseUrl
56
- : await resolveAgentEngineSecret(OPENAI_BASE_URL_ENV_VAR);
57
- if (rawBaseUrl) {
58
- config.baseUrl = normalizeOpenAiBaseUrl(rawBaseUrl);
59
- }
71
+ if (entry.name === "ai-sdk:openai" || entry.name === "ai-sdk:ollama") {
72
+ const endpointKey = entry.name === "ai-sdk:ollama"
73
+ ? OLLAMA_BASE_URL_ENV_VAR
74
+ : OPENAI_BASE_URL_ENV_VAR;
75
+ const explicitBaseUrl = args.baseUrl?.trim();
76
+ const baseUrl = explicitBaseUrl
77
+ ? await validateProviderBaseUrl(explicitBaseUrl, {
78
+ allowLocalOllama: entry.name === "ai-sdk:ollama" &&
79
+ process.env.NODE_ENV === "development",
80
+ })
81
+ : await resolveAgentEngineEndpoint(endpointKey);
82
+ if (baseUrl)
83
+ config.baseUrl = baseUrl;
60
84
  }
61
85
  return config;
62
86
  }
@@ -34,37 +34,37 @@ export declare function createListSecretsHandler(): import("h3").EventHandlerWit
34
34
  /** POST /_agent-native/secrets/:key — write a secret. */
35
35
  export declare function createWriteSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
36
36
  error: string;
37
- status?: undefined;
38
37
  ok?: undefined;
38
+ status?: undefined;
39
39
  } | {
40
+ error?: undefined;
40
41
  ok: boolean;
41
42
  status: string;
42
- error?: undefined;
43
43
  } | {
44
+ ok?: undefined;
44
45
  error: string;
45
46
  removed?: undefined;
46
- ok?: undefined;
47
47
  } | {
48
+ error?: undefined;
48
49
  ok: boolean;
49
50
  removed: boolean;
50
- error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — validate an optional candidate value
54
54
  * or the current stored value without changing anything.
55
55
  */
56
56
  export declare function createTestSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
57
+ ok?: undefined;
57
58
  error: string;
58
59
  note?: undefined;
59
- ok?: undefined;
60
60
  } | {
61
+ error?: undefined;
61
62
  ok: boolean;
62
63
  note?: undefined;
63
- error?: undefined;
64
64
  } | {
65
+ error?: undefined;
65
66
  ok: boolean;
66
67
  note: string;
67
- error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
+ error?: undefined;
98
99
  ok: boolean;
99
100
  key: string;
100
- error?: undefined;
101
101
  } | {
102
+ error?: undefined;
102
103
  ok: boolean;
103
104
  removed: boolean;
104
- error?: undefined;
105
105
  }>>;
@@ -1,7 +1,7 @@
1
1
  import type { ActionEntry } from "../../agent/production-agent.js";
2
2
  /**
3
3
  * Load the sandboxed code-execution tool entries for one action registry:
4
- * `run-code` plus its `get-code-execution` poll companion. The poll tool is
4
+ * `run-code`, bounded `tool-orchestration`, plus its `get-code-execution` poll companion. The poll tool is
5
5
  * registered ALONGSIDE run-code everywhere run-code appears, so the durable
6
6
  * background-execution guidance run-code emits ("check it with
7
7
  * get-code-execution") always points at a callable tool. Returns an empty
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Load the sandboxed code-execution tool entries for one action registry:
3
- * `run-code` plus its `get-code-execution` poll companion. The poll tool is
3
+ * `run-code`, bounded `tool-orchestration`, plus its `get-code-execution` poll companion. The poll tool is
4
4
  * registered ALONGSIDE run-code everywhere run-code appears, so the durable
5
5
  * background-execution guidance run-code emits ("check it with
6
6
  * get-code-execution") always points at a callable tool. Returns an empty
@@ -13,8 +13,10 @@
13
13
  export async function loadRunCodeToolEntries(supplier, runCodeOptions) {
14
14
  try {
15
15
  const { createRunCodeEntry, createGetCodeExecutionEntry } = await import("../../coding-tools/run-code.js");
16
+ const { createToolOrchestrationEntry } = await import("../../coding-tools/tool-orchestration.js");
16
17
  const entries = {
17
18
  "run-code": createRunCodeEntry(supplier, runCodeOptions),
19
+ "tool-orchestration": createToolOrchestrationEntry(supplier),
18
20
  "get-code-execution": createGetCodeExecutionEntry(),
19
21
  };
20
22
  // Data programs: stored JS scripts executed through this same run-code