@agent-native/core 0.233.0 → 0.234.0-nightly-20261125004429

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 (70) hide show
  1. package/dist/agent/engine/ai-sdk-engine.d.ts +1 -0
  2. package/dist/agent/engine/ai-sdk-engine.js +36 -1
  3. package/dist/agent/engine/anthropic-engine.js +12 -1
  4. package/dist/agent/production-agent.d.ts +7 -0
  5. package/dist/agent/tool-search.js +34 -4
  6. package/dist/application-state/handlers.d.ts +3 -3
  7. package/dist/cli/skills-content/an-skill.d.ts +1 -1
  8. package/dist/cli/skills-content/an-skill.js +30 -13
  9. package/dist/client/action-get-batch.d.ts +1 -0
  10. package/dist/client/action-get-batch.js +5 -1
  11. package/dist/client/application-state.js +65 -7
  12. package/dist/client/chat/agentkit-protocol.js +15 -3
  13. package/dist/client/feature-flags/use-feature-flag.js +3 -0
  14. package/dist/client/labs/use-lab.js +2 -0
  15. package/dist/client/session-identity.d.ts +1 -0
  16. package/dist/client/session-identity.js +7 -0
  17. package/dist/client/use-action.d.ts +1 -0
  18. package/dist/client/use-action.js +19 -6
  19. package/dist/collab/struct-routes.d.ts +1 -1
  20. package/dist/framework-package-versions.json +8 -8
  21. package/dist/identity/rekey.js +55 -2
  22. package/dist/jobs/background-automation-runner.d.ts +7 -1
  23. package/dist/jobs/background-automation-runner.js +18 -2
  24. package/dist/mcp/build-server.d.ts +2 -0
  25. package/dist/mcp/build-server.js +45 -4
  26. package/dist/mcp/embed-app.js +52 -1
  27. package/dist/mcp/skills-extension.d.ts +42 -0
  28. package/dist/mcp/skills-extension.js +61 -0
  29. package/dist/org/migrations.d.ts +1 -1
  30. package/dist/org/workspace-app-access.js +2 -1
  31. package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
  32. package/dist/provider-api/actions/provider-api.d.ts +8 -8
  33. package/dist/resources/handlers.d.ts +2 -2
  34. package/dist/server/action-discovery.js +7 -37
  35. package/dist/server/action-files.d.ts +15 -0
  36. package/dist/server/action-files.js +71 -0
  37. package/dist/server/agent-chat/mcp-options.d.ts +3 -0
  38. package/dist/server/agent-chat/mcp-options.js +1 -0
  39. package/dist/server/agent-chat/plugin-options.d.ts +27 -3
  40. package/dist/server/agent-chat-plugin.d.ts +4 -5
  41. package/dist/server/agent-chat-plugin.js +34 -3
  42. package/dist/server/agent-teams.d.ts +15 -3
  43. package/dist/server/agent-teams.js +26 -4
  44. package/dist/server/dev-database-lifecycle.d.ts +11 -0
  45. package/dist/server/dev-database-lifecycle.js +11 -5
  46. package/dist/server/first-touch-route.d.ts +1 -1
  47. package/dist/server/index.d.ts +1 -0
  48. package/dist/shared/analytics-panel-capture.d.ts +2 -1
  49. package/dist/shared/analytics-panel-capture.js +1 -0
  50. package/dist/shared/reasoning-effort.d.ts +9 -0
  51. package/dist/shared/reasoning-effort.js +19 -0
  52. package/dist/templates/chat/.agents/skills/actions/SKILL.md +2 -0
  53. package/dist/templates/default/.agents/skills/actions/SKILL.md +2 -0
  54. package/dist/templates/headless/.agents/skills/actions/SKILL.md +2 -0
  55. package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +2 -0
  56. package/dist/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +7 -2
  57. package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +8 -8
  58. package/dist/templates/workspace-root/AGENTS.md +3 -0
  59. package/dist/templates/workspace-root/README.md +7 -2
  60. package/dist/vite/action-types-plugin.js +13 -42
  61. package/dist/vite/client.js +28 -17
  62. package/package.json +3 -3
  63. package/src/templates/chat/.agents/skills/actions/SKILL.md +2 -0
  64. package/src/templates/default/.agents/skills/actions/SKILL.md +2 -0
  65. package/src/templates/headless/.agents/skills/actions/SKILL.md +2 -0
  66. package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +2 -0
  67. package/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +7 -2
  68. package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +8 -8
  69. package/src/templates/workspace-root/AGENTS.md +3 -0
  70. package/src/templates/workspace-root/README.md +7 -2
@@ -320,6 +320,7 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
320
320
  notes?: string | undefined;
321
321
  scope?: "org" | "user" | undefined;
322
322
  }, {
323
+ provider?: undefined;
323
324
  id?: undefined;
324
325
  message?: undefined;
325
326
  deleted?: undefined;
@@ -333,45 +334,44 @@ export declare function createProviderApiActions(runtime: Pick<ProviderApiRuntim
333
334
  updatedAt: number;
334
335
  }[];
335
336
  count: number;
336
- provider?: undefined;
337
337
  found?: undefined;
338
338
  registered?: undefined;
339
339
  label?: undefined;
340
340
  } | {
341
341
  id?: undefined;
342
+ count?: undefined;
342
343
  message?: undefined;
343
344
  deleted?: undefined;
344
- count?: undefined;
345
345
  providers?: undefined;
346
346
  found: boolean;
347
347
  provider: import("../custom-registry.js").CustomProviderConfig;
348
348
  registered?: undefined;
349
349
  label?: undefined;
350
350
  } | {
351
+ provider?: undefined;
352
+ count?: undefined;
351
353
  message?: undefined;
352
354
  deleted?: undefined;
353
- count?: undefined;
354
355
  providers?: undefined;
355
- provider?: undefined;
356
356
  found: boolean;
357
357
  id: string;
358
358
  registered?: undefined;
359
359
  label?: undefined;
360
360
  } | {
361
- message?: undefined;
361
+ provider?: undefined;
362
362
  count?: undefined;
363
+ message?: undefined;
363
364
  providers?: undefined;
364
- provider?: undefined;
365
365
  found?: undefined;
366
366
  deleted: boolean;
367
367
  id: string;
368
368
  registered?: undefined;
369
369
  label?: undefined;
370
370
  } | {
371
- deleted?: undefined;
371
+ provider?: undefined;
372
372
  count?: undefined;
373
+ deleted?: undefined;
373
374
  providers?: undefined;
374
- provider?: undefined;
375
375
  found?: undefined;
376
376
  registered: boolean;
377
377
  id: string;
@@ -57,8 +57,8 @@ export declare function handleCreateResource(event: any): Promise<{
57
57
  })>;
58
58
  export declare function handleUpdateResource(event: any): Promise<{
59
59
  errorCode?: undefined;
60
- details?: undefined;
61
60
  error: string;
61
+ details?: undefined;
62
62
  } | {
63
63
  error: string;
64
64
  errorCode: string;
@@ -75,8 +75,8 @@ export declare function handleDeleteResource(event: any): Promise<{
75
75
  }>;
76
76
  export declare function handleUploadResource(event: any): Promise<{
77
77
  errorCode?: undefined;
78
- details?: undefined;
79
78
  error: string;
79
+ details?: undefined;
80
80
  } | {
81
81
  error: string;
82
82
  errorCode: string;
@@ -14,6 +14,7 @@ async function getFs() {
14
14
  return _fs;
15
15
  }
16
16
  import { fileURLToPath } from "node:url";
17
+ import { scanActionDir } from "./action-files.js";
17
18
  import { importRuntimeSourceModule } from "./runtime-source-module.js";
18
19
  const SKIP_FILES = new Set([
19
20
  "helpers",
@@ -23,15 +24,6 @@ const SKIP_FILES = new Set([
23
24
  "registry",
24
25
  "migrate-production",
25
26
  ]);
26
- function isRuntimeSourceFile(filename) {
27
- if (!/\.(ts|js)$/.test(filename))
28
- return false;
29
- if (/\.d\.ts$/.test(filename))
30
- return false;
31
- if (/\.(test|spec)\.(ts|js)$/.test(filename))
32
- return false;
33
- return true;
34
- }
35
27
  // Dev agent chat imports each of these files to read its tool definition, which
36
28
  // executes the module. `scripts/` holds CLI scripts with top-level side effects
37
29
  // (one closed the shared database at boot), so only `actions/` is listed.
@@ -40,13 +32,7 @@ export async function listDevActionFiles(cwd) {
40
32
  const actionsDir = nodePath.join(cwd, "actions");
41
33
  if (!fs.existsSync(actionsDir))
42
34
  return [];
43
- return fs
44
- .readdirSync(actionsDir)
45
- .filter((f) => f.endsWith(".ts") &&
46
- !f.startsWith("_") &&
47
- !/\.(test|spec)\.ts$/.test(f) &&
48
- !SKIP_FILES.has(f.replace(/\.ts$/, "")))
49
- .map((f) => nodePath.join(actionsDir, f));
35
+ return scanActionDir(actionsDir, SKIP_FILES).map((f) => nodePath.join(actionsDir, f.relPath));
50
36
  }
51
37
  const PACKAGE_ACTION_REGISTRY_KEY = Symbol.for("@agent-native/core.package-action-registry");
52
38
  function getPackageActionRegistry() {
@@ -136,28 +122,12 @@ async function resolveActionsDir(from) {
136
122
  return nodePath.resolve(from);
137
123
  }
138
124
  async function loadActionsIntoRegistry(actionsDir, registry, skipExisting) {
139
- let files;
140
- try {
141
- const fs = await getFs();
142
- if (!fs.existsSync(actionsDir))
143
- return;
144
- files = fs.readdirSync(actionsDir);
145
- }
146
- catch {
125
+ let actionFiles;
126
+ const fs = await getFs();
127
+ if (!fs.existsSync(actionsDir))
147
128
  return;
148
- }
149
- const actionFiles = files.filter((f) => {
150
- if (!isRuntimeSourceFile(f))
151
- return false;
152
- const name = f.replace(/\.(ts|js)$/, "");
153
- if (name.startsWith("_"))
154
- return false;
155
- if (SKIP_FILES.has(name))
156
- return false;
157
- return true;
158
- });
159
- for (const file of actionFiles) {
160
- const name = file.replace(/\.(ts|js)$/, "");
129
+ actionFiles = scanActionDir(actionsDir, SKIP_FILES);
130
+ for (const { relPath: file, name } of actionFiles) {
161
131
  if (skipExisting && registry[name])
162
132
  continue;
163
133
  const filePath = nodePath.join(actionsDir, file);
@@ -0,0 +1,15 @@
1
+ export interface ActionFileEntry {
2
+ /** Path relative to the actions dir, with forward slashes (`billing/create-invoice.ts`). */
3
+ relPath: string;
4
+ /** Action name: the relative path without extension, segments joined by `-`. */
5
+ name: string;
6
+ }
7
+ export declare function actionNameFromRelPath(relPath: string): string;
8
+ /**
9
+ * Recursively lists action source files under `actionsDir`. Directories that
10
+ * start with `_` or `.` are helpers and are skipped, like `_` files. Two files
11
+ * deriving the same action name (`billing/create-invoice.ts` and
12
+ * `billing-create-invoice.ts`) throw instead of one silently shadowing the other.
13
+ * `skipTopLevel` names top-level files that are never actions.
14
+ */
15
+ export declare function scanActionDir(actionsDir: string, skipTopLevel: ReadonlySet<string>): ActionFileEntry[];
@@ -0,0 +1,71 @@
1
+ import nodeFs from "node:fs";
2
+ import nodePath from "node:path";
3
+ class ActionNameCollisionError extends TypeError {
4
+ actionDefinitionError = true;
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = "ActionDefinitionError";
8
+ }
9
+ }
10
+ export function actionNameFromRelPath(relPath) {
11
+ return relPath
12
+ .replace(/\\/g, "/")
13
+ .replace(/\.(ts|js)$/, "")
14
+ .split("/")
15
+ .join("-");
16
+ }
17
+ function isActionSourceFile(filename) {
18
+ if (!/\.(ts|js)$/.test(filename))
19
+ return false;
20
+ if (/\.d\.ts$/.test(filename))
21
+ return false;
22
+ if (/\.(test|spec)\.(ts|js)$/.test(filename))
23
+ return false;
24
+ return !filename.startsWith("_");
25
+ }
26
+ /**
27
+ * Recursively lists action source files under `actionsDir`. Directories that
28
+ * start with `_` or `.` are helpers and are skipped, like `_` files. Two files
29
+ * deriving the same action name (`billing/create-invoice.ts` and
30
+ * `billing-create-invoice.ts`) throw instead of one silently shadowing the other.
31
+ * `skipTopLevel` names top-level files that are never actions.
32
+ */
33
+ export function scanActionDir(actionsDir, skipTopLevel) {
34
+ const found = new Map();
35
+ const walk = (dir, prefix) => {
36
+ let entries;
37
+ try {
38
+ entries = nodeFs.readdirSync(dir, { withFileTypes: true });
39
+ }
40
+ catch {
41
+ return;
42
+ }
43
+ entries.sort((a, b) => a.name.localeCompare(b.name));
44
+ for (const entry of entries) {
45
+ if (entry.isDirectory()) {
46
+ if (entry.name.startsWith("_") ||
47
+ entry.name.startsWith(".") ||
48
+ entry.name === "node_modules") {
49
+ continue;
50
+ }
51
+ walk(nodePath.join(dir, entry.name), `${prefix}${entry.name}/`);
52
+ continue;
53
+ }
54
+ if (!entry.isFile() && !entry.isSymbolicLink())
55
+ continue;
56
+ if (!isActionSourceFile(entry.name))
57
+ continue;
58
+ const relPath = `${prefix}${entry.name}`;
59
+ const name = actionNameFromRelPath(relPath);
60
+ if (!prefix && skipTopLevel.has(name))
61
+ continue;
62
+ const existing = found.get(name);
63
+ if (existing) {
64
+ throw new ActionNameCollisionError(`Action "${name}": "${existing.relPath}" and "${relPath}" both resolve to this name. Rename one of them.`);
65
+ }
66
+ found.set(name, { relPath, name });
67
+ }
68
+ };
69
+ walk(actionsDir, "");
70
+ return [...found.values()];
71
+ }
@@ -13,6 +13,8 @@ export interface AgentChatMcpOptions {
13
13
  connectorCatalog?: string[];
14
14
  taskCandidates?: MCPConfig["taskCandidates"];
15
15
  readOnlyResources?: boolean;
16
+ /** Serve the `an` skill over MCP (Skills extension). Dispatch only. */
17
+ servesAnSkill?: boolean;
16
18
  directoryProfile?: {
17
19
  connectorCatalog: string[];
18
20
  directoryRoute?: false;
@@ -80,6 +82,7 @@ export interface ResolvedAgentChatMcp {
80
82
  connectorCatalog: string[] | undefined;
81
83
  taskCandidates: MCPConfig["taskCandidates"];
82
84
  readOnlyResources: boolean | undefined;
85
+ servesAnSkill: boolean | undefined;
83
86
  directoryProfile: AgentChatMcpOptions["directoryProfile"] | undefined;
84
87
  externalAgents: ExternalAgentPolicy | undefined;
85
88
  builtinCrossAppTools: boolean | undefined;
@@ -54,6 +54,7 @@ export function resolveAgentChatMcpOptions(input) {
54
54
  connectorCatalog,
55
55
  taskCandidates: mcp.taskCandidates,
56
56
  readOnlyResources: mcp.readOnlyResources,
57
+ servesAnSkill: mcp.servesAnSkill,
57
58
  directoryProfile: mcp.directoryProfile,
58
59
  externalAgents,
59
60
  builtinCrossAppTools: mcp.builtinCrossAppTools,
@@ -11,6 +11,27 @@ import type { RealtimeVoiceIntelligence } from "../realtime-voice.js";
11
11
  import type { AgentChatAdditionalActionsExternalSurface, ResolveAgentChatAdditionalActions } from "./additional-actions.js";
12
12
  import type { AgentChatMcpIcon, AgentChatMcpOptions } from "./mcp-options.js";
13
13
  export type NitroPluginDef = (nitroApp: any) => void | Promise<void>;
14
+ /** Whether the run's result reached the durable thread. */
15
+ export type AgentChatRunProjectionOutcome = {
16
+ status: "updated";
17
+ } | {
18
+ status: "failed";
19
+ error: unknown;
20
+ };
21
+ export interface AgentChatRunCompleteOutcome {
22
+ turnContinues: boolean;
23
+ /** Absent when the run had no thread to project into. */
24
+ projection?: AgentChatRunProjectionOutcome;
25
+ }
26
+ export interface AgentChatRunNotStartedDetails {
27
+ runId: string;
28
+ turnId: string;
29
+ threadId: string;
30
+ failure: {
31
+ code: string;
32
+ message: string;
33
+ };
34
+ }
14
35
  export interface AgentChatPluginOptions {
15
36
  onQueuedSubmissionDrainReady?: (requestDrain: (threadId: string) => void) => void;
16
37
  /** Trusted hosts may explicitly aggregate thread access across apps. */
@@ -28,9 +49,12 @@ export interface AgentChatPluginOptions {
28
49
  * continuation boundary, so the turn is not finished: a continuation run
29
50
  * with a new run id carries it on.
30
51
  */
31
- onAgentRunComplete?: (scope: AgentChatScope | null | undefined, run: ActiveRun, outcome: {
32
- turnContinues: boolean;
33
- }) => void | Promise<void>;
52
+ onAgentRunComplete?: (scope: AgentChatScope | null | undefined, run: ActiveRun, outcome: AgentChatRunCompleteOutcome) => void | Promise<void>;
53
+ /**
54
+ * A turn was refused before any run started (for example no usable model
55
+ * credential). `runId` is the id the client already uses for the turn.
56
+ */
57
+ onAgentRunNotStarted?: (details: AgentChatRunNotStartedDetails) => void | Promise<void>;
34
58
  actions?: Record<string, ActionEntry> | (() => Record<string, ActionEntry> | Promise<Record<string, ActionEntry>>);
35
59
  /** @deprecated Use `actions` instead */
36
60
  scripts?: Record<string, ActionEntry> | (() => Record<string, ActionEntry> | Promise<Record<string, ActionEntry>>);
@@ -18,7 +18,7 @@ export declare function trackAgentChatRunLifecycle(event: "run_started" | "run_f
18
18
  export declare function trackAgentChatRunStarted(threadId: string, runId: string, turnId: string, owner: string | undefined, appId: string | undefined): void;
19
19
  import { buildSelectedA2AReceiverContext, createA2AEngineToolSurface, DEFAULT_DELEGATED_MAX_ITERATIONS, DEFAULT_DELEGATED_MAX_RUN_INPUT_TOKENS, DEFAULT_DELEGATED_MAX_TOOL_RESULT_CHARS, isSelectedA2AReceiver, runA2AAgentLoop, runMCPAgentLoop, assembleA2AFinalResponse, buildPublicAgentA2ASkills } from "./agent-chat/action-filters-a2a.js";
20
20
  import { _agentChatPromptSectionsForTests } from "./agent-chat/framework-prompts.js";
21
- import { type AgentChatPluginOptions, type NitroPluginDef } from "./agent-chat/plugin-options.js";
21
+ import { type AgentChatPluginOptions, type AgentChatRunCompleteOutcome, type AgentChatRunNotStartedDetails, type AgentChatRunProjectionOutcome, type NitroPluginDef } from "./agent-chat/plugin-options.js";
22
22
  import { finalizeClaimedAgentChatProcessRunFailure } from "./agent-chat/process-run-failure.js";
23
23
  import { loadResourcesForPrompt } from "./agent-chat/prompt-resources.js";
24
24
  import { isNetlifyRecurringJobsRuntime, resolveRecurringJobsBuildMarker, scheduledTriggerAvailability, shouldDisableRecurringJobsRuntime } from "./agent-chat/recurring-jobs-runtime.js";
@@ -51,13 +51,12 @@ export { scheduledTriggerAvailability };
51
51
  export { shouldDisableRecurringJobsRuntime };
52
52
  export { finalizeClaimedAgentChatProcessRunFailure };
53
53
  export declare function runPostAgentTurnAutosave(callback: AgentChatPluginOptions["onAgentTurnComplete"] | undefined, scope: AgentChatScope | null | undefined, run: ActiveRun): Promise<void>;
54
- export declare function runPostAgentRunComplete(callback: AgentChatPluginOptions["onAgentRunComplete"] | undefined, scope: AgentChatScope | null | undefined, run: ActiveRun, outcome?: {
55
- turnContinues: boolean;
56
- }): Promise<void>;
54
+ export declare function runPostAgentRunComplete(callback: AgentChatPluginOptions["onAgentRunComplete"] | undefined, scope: AgentChatScope | null | undefined, run: ActiveRun, outcome?: AgentChatRunCompleteOutcome): Promise<void>;
55
+ export declare function notifyRunNotStarted(callback: AgentChatPluginOptions["onAgentRunNotStarted"] | undefined, details: AgentChatRunNotStartedDetails): Promise<void>;
57
56
  export declare function runPreAgentTurnAutosave(callback: AgentChatPluginOptions["onAgentTurnStart"] | undefined, scope: AgentChatScope | null | undefined, run: Pick<ActiveRun, "threadId" | "runId">): Promise<void>;
58
57
  export { foldAgentChatRunCompletion };
59
58
  export declare function assertAgentChatRunProjectionUpdated(updated: boolean, threadId: string, runId: string): void;
60
- export declare function runAgentChatRunCompletionHooksAfterProjection(persistProjection: () => Promise<void>, runCompletionHooks: () => Promise<void>): Promise<void>;
59
+ export declare function runAgentChatRunCompletionHooksAfterProjection(persistProjection: () => Promise<void>, runCompletionHooks: (projection: AgentChatRunProjectionOutcome) => Promise<void>): Promise<void>;
61
60
  /**
62
61
  * The model this mount runs with, when the caller does not pass one per request.
63
62
  *
@@ -310,6 +310,22 @@ export async function runPostAgentRunComplete(callback, scope, run, outcome = {
310
310
  console.error("[agent-chat] post-agent-run observer failed:", error);
311
311
  }
312
312
  }
313
+ export async function notifyRunNotStarted(callback, details) {
314
+ if (!callback)
315
+ return;
316
+ try {
317
+ await callback(details);
318
+ }
319
+ catch (error) {
320
+ captureError(error, {
321
+ route: "agent-chat",
322
+ aiTraceId: details.runId,
323
+ tags: { source: "agent-chat", failureClass: "run-not-started-observer" },
324
+ extra: { runId: details.runId, threadId: details.threadId },
325
+ });
326
+ console.error("[agent-chat] run-not-started observer failed:", error);
327
+ }
328
+ }
313
329
  export async function runPreAgentTurnAutosave(callback, scope, run) {
314
330
  if (!callback || !scope)
315
331
  return;
@@ -351,7 +367,9 @@ export async function runAgentChatRunCompletionHooksAfterProjection(persistProje
351
367
  projectionError = error;
352
368
  }
353
369
  try {
354
- await runCompletionHooks();
370
+ await runCompletionHooks(projectionFailed
371
+ ? { status: "failed", error: projectionError }
372
+ : { status: "updated" });
355
373
  }
356
374
  catch (error) {
357
375
  if (projectionFailed) {
@@ -2724,6 +2742,7 @@ export function createAgentChatPlugin(options) {
2724
2742
  ? { taskCandidates: mcpOptions.taskCandidates }
2725
2743
  : {}),
2726
2744
  ...(mcpOptions.readOnlyResources ? { readOnlyResources: true } : {}),
2745
+ ...(mcpOptions.servesAnSkill ? { servesAnSkill: true } : {}),
2727
2746
  ...(mcpOptions.connectorCatalog
2728
2747
  ? { connectorCatalog: mcpOptions.connectorCatalog }
2729
2748
  : {}),
@@ -3160,13 +3179,13 @@ export function createAgentChatPlugin(options) {
3160
3179
  const meta = extractThreadMeta(repo);
3161
3180
  const projectionUpdated = await updateThreadData(threadId, JSON.stringify(repo), thread.title, meta.preview || thread.preview, repo.messages.length, { trustedRunSequenceResetIds: new Set([run.runId]) });
3162
3181
  assertAgentChatRunProjectionUpdated(projectionUpdated, threadId, run.runId);
3163
- }), async () => {
3182
+ }), async (projection) => {
3164
3183
  // Checkpoint creation is part of durable turn completion. The helper
3165
3184
  // catches and reports its own failures, so a broken app checkpoint does
3166
3185
  // not strand the run while a successful checkpoint cannot be lost when
3167
3186
  // a serverless invocation exits.
3168
3187
  await runPostAgentTurnAutosave(options?.onAgentTurnComplete, chatScope, run);
3169
- await runPostAgentRunComplete(options?.onAgentRunComplete, chatScope, run, { turnContinues: endsAtContinuationBoundary(run) });
3188
+ await runPostAgentRunComplete(options?.onAgentRunComplete, chatScope, run, { turnContinues: endsAtContinuationBoundary(run), projection });
3170
3189
  });
3171
3190
  scheduleQueuedSubmissionInboxDrain({
3172
3191
  threadId: runThreadId,
@@ -3526,6 +3545,12 @@ export function createAgentChatPlugin(options) {
3526
3545
  };
3527
3546
  const recordUnstartedTurn = async (details) => {
3528
3547
  trackAgentChatRunLifecycle("run_no_reply", details.threadId, details.runId, undefined, { failure_code: details.failure.code, stage: "not_started" }, options?.appId);
3548
+ await notifyRunNotStarted(options?.onAgentRunNotStarted, {
3549
+ runId: details.runId,
3550
+ turnId: details.turnId,
3551
+ threadId: details.threadId,
3552
+ failure: details.failure,
3553
+ });
3529
3554
  try {
3530
3555
  await persistSubmittedUserMessage(details);
3531
3556
  }
@@ -8342,6 +8367,9 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
8342
8367
  : []),
8343
8368
  ...(job?.meta.mcpTools ?? []),
8344
8369
  ],
8370
+ ...(options?.resolveActionSurface
8371
+ ? { resolveActionSurface: options.resolveActionSurface }
8372
+ : {}),
8345
8373
  apiKey: options?.apiKey,
8346
8374
  model: resolveConfiguredAgentModel(options),
8347
8375
  appId: options?.appId,
@@ -8886,6 +8914,9 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
8886
8914
  const { initTriggerDispatcher } = await import("../triggers/dispatcher.js");
8887
8915
  await initTriggerDispatcher({
8888
8916
  getActions: getBackgroundActionEntries,
8917
+ ...(options?.resolveActionSurface
8918
+ ? { resolveActionSurface: options.resolveActionSurface }
8919
+ : {}),
8889
8920
  getWorkspaceAppContext: getBackgroundWorkspaceAppContext,
8890
8921
  getSystemPrompt: async (owner) => {
8891
8922
  const resources = await loadResourcesForPrompt(owner, lazyContext, options?.appId, undefined, { disabledFrameworkGroups, skillReadTool });
@@ -4,6 +4,7 @@ import type { ActionEntry, AgentLoopFinalResponseGuard } from "../agent/producti
4
4
  import { type ActiveRun } from "../agent/run-manager.js";
5
5
  import type { AgentChatEvent } from "../agent/types.js";
6
6
  import type { RunEvent } from "../agent/types.js";
7
+ import { type ChatThreadScope } from "../chat-threads/store.js";
7
8
  import type { BackgroundAgentRun, BackgroundAgentRunStatus, BackgroundAgentTranscriptEvent } from "../code-agents/background-run.js";
8
9
  import type { BackgroundAgentController } from "../code-agents/index.js";
9
10
  import { type AgentTeamRunPayload } from "./agent-teams-run-queue.js";
@@ -47,6 +48,7 @@ export interface AgentTask {
47
48
  stopRequestedAt?: number;
48
49
  stopRequestedRunId?: string;
49
50
  stopRequestedReason?: string;
51
+ quiet?: boolean;
50
52
  }
51
53
  export interface AgentTeamOwnerScope {
52
54
  sourceAppId?: string | null;
@@ -135,11 +137,21 @@ export interface SpawnTaskOptions {
135
137
  instructions?: string;
136
138
  model?: string;
137
139
  ownerEmail: string;
138
- systemPrompt: string;
139
- actions: Record<string, ActionEntry>;
140
+ systemPrompt?: string;
141
+ actions?: Record<string, ActionEntry>;
140
142
  engine?: AgentEngine;
141
143
  apiKey?: string;
142
- parentSend: (event: AgentChatEvent) => void;
144
+ /** Omit when no chat is waiting on the task, as when app code starts it. */
145
+ parentSend?: (event: AgentChatEvent) => void;
146
+ /** The task thread's scope, so an app can keep it out of chat history. */
147
+ scope?: ChatThreadScope | null;
148
+ /** Keeps the task out of the runs tray. */
149
+ quiet?: boolean;
150
+ /**
151
+ * The only actions the sub-agent may call. Required without `parentSend`;
152
+ * inside a run that has its own allowlist, names outside it are dropped.
153
+ */
154
+ allowedActionNames?: readonly string[];
143
155
  parentThreadId?: string;
144
156
  parentSourceAppId?: string | null;
145
157
  parentRunId?: string;
@@ -798,6 +798,7 @@ function taskProgressMetadata(task) {
798
798
  currentStep: task.currentStep,
799
799
  surfaceUrl: `agent-native://threads/${encodeURIComponent(task.threadId)}`,
800
800
  ...(task.parentThreadId ? { parentThreadId: task.parentThreadId } : {}),
801
+ ...(task.quiet ? { quiet: true } : {}),
801
802
  ...(task.name ? { name: task.name } : {}),
802
803
  };
803
804
  }
@@ -806,6 +807,8 @@ function currentTaskProgressStep(task) {
806
807
  (task.preview ? "Working on response" : "Starting sub-agent"));
807
808
  }
808
809
  async function startTaskProgressRun(task, ownerEmail) {
810
+ if (task.quiet)
811
+ return;
809
812
  const runId = task.runId ?? taskRunId(task.taskId);
810
813
  task.runId = runId;
811
814
  try {
@@ -823,6 +826,8 @@ async function startTaskProgressRun(task, ownerEmail) {
823
826
  }
824
827
  }
825
828
  async function updateTaskProgressRun(task, ownerEmail) {
829
+ if (task.quiet)
830
+ return;
826
831
  const runId = task.runId ?? taskRunId(task.taskId);
827
832
  task.runId = runId;
828
833
  try {
@@ -836,6 +841,8 @@ async function updateTaskProgressRun(task, ownerEmail) {
836
841
  }
837
842
  }
838
843
  async function completeTaskProgressRun(task, ownerEmail, status, step) {
844
+ if (task.quiet)
845
+ return true;
839
846
  const runId = task.runId ?? taskRunId(task.taskId);
840
847
  task.runId = runId;
841
848
  try {
@@ -868,6 +875,8 @@ async function reconcileTerminalProgress(task, ownerEmail) {
868
875
  }
869
876
  }
870
877
  async function ensureTaskCompletionNotification(task, ownerEmail, hitContinuationLimit = false) {
878
+ if (task.quiet)
879
+ return true;
871
880
  try {
872
881
  const { hasNotificationWithMetadata, insertNotification } = await import("../notifications/store.js");
873
882
  if (await hasNotificationWithMetadata(ownerEmail, {
@@ -1194,6 +1203,10 @@ export class SubagentDelegationDepthError extends Error {
1194
1203
  }
1195
1204
  }
1196
1205
  export async function spawnTask(opts) {
1206
+ if (!opts.parentSend && opts.allowedActionNames === undefined) {
1207
+ throw new Error("spawnTask needs allowedActionNames when no chat is waiting on the task.");
1208
+ }
1209
+ const parentAllowedActionNames = getRequestRunContext()?.allowedActionNames;
1197
1210
  const parentDepth = typeof opts.parentDelegationDepth === "number"
1198
1211
  ? opts.parentDelegationDepth
1199
1212
  : currentAmbientDelegationDepth();
@@ -1223,6 +1236,7 @@ export async function spawnTask(opts) {
1223
1236
  const parentSourceAppId = opts.parentSourceAppId?.trim();
1224
1237
  const thread = await createThread(opts.ownerEmail, {
1225
1238
  title: opts.description.slice(0, 100),
1239
+ ...(opts.scope ? { scope: opts.scope } : {}),
1226
1240
  ...(parentSourceAppId ? { source: { appId: parentSourceAppId } } : {}),
1227
1241
  initialData: {
1228
1242
  threadData,
@@ -1249,10 +1263,11 @@ export async function spawnTask(opts) {
1249
1263
  startedAt: createdAt,
1250
1264
  runId,
1251
1265
  delegationDepth: childDepth,
1266
+ ...(opts.quiet ? { quiet: true } : {}),
1252
1267
  };
1253
1268
  await saveTask(task);
1254
1269
  await startTaskProgressRun(task, opts.ownerEmail);
1255
- opts.parentSend({
1270
+ opts.parentSend?.({
1256
1271
  type: "agent_task",
1257
1272
  taskId,
1258
1273
  threadId: thread.id,
@@ -1267,9 +1282,14 @@ export async function spawnTask(opts) {
1267
1282
  ...(opts.parentThreadId ? { parentThreadId: opts.parentThreadId } : {}),
1268
1283
  ...(opts.parentRunId ? { parentRunId: opts.parentRunId } : {}),
1269
1284
  ...(opts.name ? { name: opts.name } : {}),
1270
- ...(getRequestRunContext()?.allowedActionNames !== undefined
1271
- ? { allowedActionNames: Object.keys(opts.actions) }
1272
- : {}),
1285
+ ...(opts.allowedActionNames !== undefined
1286
+ ? {
1287
+ allowedActionNames: opts.allowedActionNames.filter((name) => parentAllowedActionNames === undefined ||
1288
+ parentAllowedActionNames.includes(name)),
1289
+ }
1290
+ : parentAllowedActionNames !== undefined
1291
+ ? { allowedActionNames: Object.keys(opts.actions ?? {}) }
1292
+ : {}),
1273
1293
  turnId: runId,
1274
1294
  };
1275
1295
  try {
@@ -2082,6 +2102,8 @@ export async function listTasks(scope) {
2082
2102
  const tasks = [];
2083
2103
  for (const entry of entries) {
2084
2104
  const task = entry.value;
2105
+ if (task.quiet)
2106
+ continue;
2085
2107
  if (await taskMatchesOwnerScope(task, ownerScope))
2086
2108
  tasks.push(task);
2087
2109
  }
@@ -1 +1,12 @@
1
+ type DevDatabaseHot = {
2
+ on(event: string, listener: (payload?: {
3
+ requestId?: unknown;
4
+ }) => void): void;
5
+ send(event: string, payload?: {
6
+ requestId: unknown;
7
+ error?: string;
8
+ }): void;
9
+ };
10
+ export declare function listenForDevDatabaseLifecycle(devDatabaseHot: DevDatabaseHot): void;
1
11
  export declare function installDevDatabaseCloseHook(nitroApp: any): void;
12
+ export {};
@@ -4,6 +4,9 @@ const devDatabaseCloseApps = new WeakSet();
4
4
  let devDatabaseClosePromise;
5
5
  const devDatabaseHot = import.meta.hot;
6
6
  if (process.env.NODE_ENV === "development" && devDatabaseHot) {
7
+ listenForDevDatabaseLifecycle(devDatabaseHot);
8
+ }
9
+ export function listenForDevDatabaseLifecycle(devDatabaseHot) {
7
10
  devDatabaseHot.on("agent-native:dev-database-resume", (payload) => {
8
11
  if (typeof payload?.requestId !== "string")
9
12
  return;
@@ -16,19 +19,22 @@ if (process.env.NODE_ENV === "development" && devDatabaseHot) {
16
19
  devDatabaseHot.on("agent-native:dev-database-close", (payload) => {
17
20
  if (typeof payload?.requestId !== "string")
18
21
  return;
19
- void closeDevDatabase(payload.requestId).then(() => devDatabaseHot.send("agent-native:dev-database-closed", {
22
+ const announceClosing = () => devDatabaseHot.send("agent-native:dev-database-closing", {
23
+ requestId: payload.requestId,
24
+ });
25
+ void closeDevDatabase(announceClosing).then(() => devDatabaseHot.send("agent-native:dev-database-closed", {
20
26
  requestId: payload.requestId,
21
27
  }), (error) => devDatabaseHot.send("agent-native:dev-database-closed", {
22
28
  error: error instanceof Error ? error.message : String(error),
23
29
  requestId: payload.requestId,
24
30
  }));
25
31
  });
32
+ devDatabaseHot.on("agent-native:dev-database-ready-check", () => devDatabaseHot.send("agent-native:dev-database-ready"));
33
+ devDatabaseHot.send("agent-native:dev-database-ready");
26
34
  }
27
- async function closeDevDatabase(requestId) {
35
+ async function closeDevDatabase(announceClosing) {
28
36
  beginPgliteClientShutdown();
29
- if (requestId) {
30
- devDatabaseHot?.send("agent-native:dev-database-closing", { requestId });
31
- }
37
+ announceClosing?.();
32
38
  devDatabaseClosePromise ??= (async () => {
33
39
  await waitForPgliteClientOperations();
34
40
  await closeDbExec();
@@ -17,9 +17,9 @@ export type FirstTouchSyncResult = {
17
17
  * browser's `an_ft` and `an_lt` again, so Safari keeps them their 30 days.
18
18
  */
19
19
  export declare function createFirstTouchHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
20
- stored?: undefined;
21
20
  error: string;
22
21
  reason?: undefined;
22
+ stored?: undefined;
23
23
  firstTouch?: undefined;
24
24
  } | {
25
25
  error?: undefined;
@@ -143,3 +143,4 @@ export type NitroPluginDef = (nitroApp: any) => void | Promise<void>;
143
143
  export declare function defineNitroPlugin(def: NitroPluginDef): NitroPluginDef;
144
144
  export { appStateListKeysByKeySuffixPrefix } from "./application-state-maintenance.js";
145
145
  export { PROVIDER_PAUSE_FORBIDDEN, assertProviderPauseOperator, isProviderPauseOperator, type ProviderPauseCaller, } from "./provider-pause-operator.js";
146
+ export type { AgentChatRunCompleteOutcome, AgentChatRunNotStartedDetails, AgentChatRunProjectionOutcome, } from "./agent-chat/plugin-options.js";
@@ -26,7 +26,7 @@ export declare const ANALYTICS_CAPTURE_MAX_COLORS = 100;
26
26
  /** The longest dashboard time range, in days, a pivoted chart fills against. */
27
27
  export declare const ANALYTICS_CAPTURE_MAX_TIME_RANGE_DAYS = 800;
28
28
  /** The data source types a dashboard panel reads, as toolkit names them. */
29
- export declare const ANALYTICS_CAPTURE_SOURCES: readonly ["bigquery", "ga4", "amplitude", "first-party", "demo", "prometheus", "program"];
29
+ export declare const ANALYTICS_CAPTURE_SOURCES: readonly ["bigquery", "ga4", "amplitude", "first-party", "demo", "prometheus", "program", "postgres"];
30
30
  export type AnalyticsCaptureSource = (typeof ANALYTICS_CAPTURE_SOURCES)[number];
31
31
  export declare const analyticsCaptureCellSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
32
32
  export type AnalyticsCaptureCell = z.infer<typeof analyticsCaptureCellSchema>;
@@ -156,6 +156,7 @@ export declare const analyticsPanelCaptureSchema: z.ZodObject<{
156
156
  demo: "demo";
157
157
  "first-party": "first-party";
158
158
  ga4: "ga4";
159
+ postgres: "postgres";
159
160
  program: "program";
160
161
  prometheus: "prometheus";
161
162
  }>>;