@agent-native/core 0.164.3 → 0.164.11
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/calendar/app/components/calendar/CreateEventDialog.tsx +36 -47
- package/corpus/templates/calendar/app/components/calendar/DayView.tsx +3 -0
- package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +18 -1
- package/corpus/templates/calendar/app/components/calendar/InlineEventPickers.tsx +256 -38
- package/corpus/templates/calendar/app/hooks/use-google-auth.ts +43 -3
- package/corpus/templates/calendar/app/i18n-data.ts +120 -0
- package/corpus/templates/calendar/app/lib/event-form-utils.ts +113 -0
- package/corpus/templates/calendar/server/handlers/google-auth.ts +119 -3
- package/corpus/templates/calendar/server/routes/[base]/_agent-native/google/add-account/auth-url.post.ts +1 -0
- package/corpus/templates/calendar/server/routes/[base]/_agent-native/google/auth-url.post.ts +1 -0
- package/corpus/templates/calendar/server/routes/_agent-native/google/add-account/auth-url.post.ts +1 -0
- package/corpus/templates/calendar/server/routes/_agent-native/google/auth-url.post.ts +1 -0
- package/corpus/templates/clips/.agents/skills/video-sharing/SKILL.md +1 -1
- package/corpus/templates/clips/app/components/player/video-player.tsx +12 -0
- package/corpus/templates/clips/app/routes/_app.dictate.tsx +18 -4
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +114 -20
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +86 -78
- package/corpus/templates/clips/changelog/2026-08-19-clips-nightly-builds-are-available-for-trying-the-latest-upd.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-19-social-preview-video-frames.md +6 -0
- package/corpus/templates/clips/desktop/README.md +19 -4
- package/corpus/templates/clips/desktop/src/app.tsx +78 -16
- package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +3 -2
- package/corpus/templates/clips/desktop/src-tauri/tauri.conf.json +1 -0
- package/corpus/templates/clips/server/lib/slack-unfurls.ts +7 -13
- package/corpus/templates/clips/server/routes/[base]/_agent-native/google/auth-url.post.ts +1 -0
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +41 -3
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.post.ts +1 -0
- package/corpus/templates/clips/server/routes/_agent-native/google/callback.get.ts +22 -1
- package/corpus/templates/clips/server/routes/api/clips-updater.json.get.ts +41 -22
- package/corpus/templates/clips/shared/share-meta.ts +67 -3
- package/corpus/templates/content/actions/list-content-databases.ts +95 -1
- package/corpus/templates/content/changelog/2026-08-11-content-mutations-delegated-from-verified-slack-dms-now-use-.md +6 -0
- package/corpus/templates/content/shared/api.ts +11 -0
- package/corpus/templates/factory/AGENTS.md +1 -1
- package/corpus/templates/factory/actions/list-factory-automations.ts +4 -0
- package/corpus/templates/factory/actions/start-builder-for-item.ts +19 -17
- package/corpus/templates/factory/app/components/factory/FactoryAuditView.tsx +100 -36
- package/corpus/templates/factory/app/i18n/en-US.ts +4 -0
- package/corpus/templates/factory/app/routes/factory.tsx +209 -46
- package/corpus/templates/factory/server/connectors/slack.ts +44 -2
- package/corpus/templates/factory/server/plugins/agent-chat.ts +9 -7
- package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +13 -0
- package/corpus/templates/factory/server/triage/slack-client.ts +5 -0
- package/corpus/templates/factory/server/triage/slack-poller.ts +72 -4
- package/corpus/templates/mail/actions/view-screen.ts +1 -1
- package/corpus/templates/mail/app/components/GoogleConnectBanner.tsx +100 -18
- package/corpus/templates/mail/server/handlers/google-auth.ts +125 -24
- package/corpus/templates/mail/server/lib/gmail-query.ts +5 -2
- package/corpus/templates/mail/server/routes/[base]/_agent-native/google/add-account/auth-url.post.ts +1 -0
- package/corpus/templates/mail/server/routes/[base]/_agent-native/google/auth-url.post.ts +1 -0
- package/corpus/templates/mail/server/routes/_agent-native/google/add-account/auth-url.post.ts +1 -0
- package/corpus/templates/mail/server/routes/_agent-native/google/auth-url.post.ts +1 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +0 -12
- package/corpus/templates/plan/changelog/2026-08-19-plan-prompts-now-guide-you-to-connect-ai-before-sending-and-.md +6 -0
- package/corpus/templates/slides/actions/approve-deck-access-request.ts +234 -0
- package/corpus/templates/slides/actions/get-deck-access-status.ts +35 -2
- package/corpus/templates/slides/actions/request-deck-access.ts +263 -64
- package/corpus/templates/slides/app/components/editor/MissingDeckAccessPane.tsx +196 -0
- package/corpus/templates/slides/app/components/editor/RequestDeckAccessDialog.tsx +101 -0
- package/corpus/templates/slides/app/hooks/use-deck-access.ts +7 -4
- package/corpus/templates/slides/app/i18n/en-US.ts +29 -6
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +147 -169
- package/corpus/templates/slides/app/routes/access-request.approve.tsx +250 -0
- package/corpus/templates/slides/server/db/schema.ts +8 -0
- package/corpus/templates/slides/server/lib/access-request-email.ts +36 -0
- package/corpus/templates/slides/server/lib/emails.ts +26 -0
- package/corpus/templates/slides/server/plugins/agent-chat.ts +7 -0
- package/corpus/templates/slides/server/plugins/db.ts +50 -0
- package/corpus/templates/slides/shared/deck-access.ts +31 -0
- package/dist/a2a/artifact-response.d.ts +50 -0
- package/dist/a2a/artifact-response.js +266 -39
- package/dist/a2a/index.d.ts +2 -0
- package/dist/a2a/index.js +1 -0
- package/dist/a2a/task-store.d.ts +1 -0
- package/dist/a2a/task-store.js +1 -1
- package/dist/agent/observational-memory/store.d.ts +1 -0
- package/dist/agent/observational-memory/store.js +1 -1
- package/dist/agent/run-store.d.ts +1 -0
- package/dist/agent/run-store.js +1 -1
- package/dist/agent/tool-approval-store.d.ts +1 -0
- package/dist/agent/tool-approval-store.js +1 -1
- package/dist/application-state/store.d.ts +1 -0
- package/dist/application-state/store.js +1 -1
- package/dist/browser-sessions/store.d.ts +1 -0
- package/dist/browser-sessions/store.js +1 -1
- package/dist/checkpoints/store.d.ts +1 -0
- package/dist/checkpoints/store.js +1 -1
- package/dist/cli/code-agent-schedules.d.ts +11 -0
- package/dist/cli/code-agent-schedules.js +44 -5
- package/dist/client/AgentPanel.d.ts +5 -1
- package/dist/client/AgentPanel.js +2 -2
- package/dist/client/AssistantChat.d.ts +5 -1
- package/dist/client/AssistantChat.js +40 -6
- package/dist/client/EnvironmentBadge.d.ts +7 -13
- package/dist/client/EnvironmentBadge.js +43 -92
- package/dist/client/agent-chat/index.d.ts +1 -0
- package/dist/client/agent-chat/index.js +1 -0
- package/dist/client/agent-chat-adapter.js +76 -50
- package/dist/client/app-providers.js +4 -4
- package/dist/client/chat/message-components.d.ts +4 -0
- package/dist/client/chat/message-components.js +28 -1
- package/dist/client/chat/run-recovery.js +26 -0
- package/dist/client/chat-first/apps-rail.d.ts +1 -0
- package/dist/client/chat-first/apps-rail.js +28 -2
- package/dist/client/sse-event-processor.js +13 -8
- package/dist/client/use-active-agent-chat-run.d.ts +2 -0
- package/dist/client/use-active-agent-chat-run.js +22 -0
- package/dist/coding-tools/sandbox/executions-store.d.ts +1 -0
- package/dist/coding-tools/sandbox/executions-store.js +1 -1
- package/dist/collab/awareness-store.d.ts +1 -0
- package/dist/collab/awareness-store.js +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/storage.d.ts +1 -0
- package/dist/collab/storage.js +1 -1
- package/dist/db/client.js +3 -3
- package/dist/db/ddl-guard.js +8 -0
- package/dist/db/migration-runtime.d.ts +23 -0
- package/dist/db/migration-runtime.js +41 -0
- package/dist/db/migrations.d.ts +1 -2
- package/dist/db/migrations.js +2 -24
- package/dist/email-catalog/log.d.ts +1 -0
- package/dist/email-catalog/log.js +1 -1
- package/dist/guards/index.d.ts +1 -0
- package/dist/guards/index.js +1 -0
- package/dist/guards/release-schema-complete.d.ts +22 -0
- package/dist/guards/release-schema-complete.js +144 -0
- package/dist/integrations/a2a-continuations-store.d.ts +1 -0
- package/dist/integrations/a2a-continuations-store.js +1 -1
- package/dist/integrations/adapters/slack.js +58 -7
- package/dist/integrations/awaiting-input-store.d.ts +1 -0
- package/dist/integrations/awaiting-input-store.js +1 -1
- package/dist/integrations/config-store.d.ts +1 -0
- package/dist/integrations/config-store.js +1 -1
- package/dist/integrations/controls-store.d.ts +1 -0
- package/dist/integrations/controls-store.js +1 -1
- package/dist/integrations/identity-links-store.d.ts +1 -0
- package/dist/integrations/identity-links-store.js +1 -1
- package/dist/integrations/installations-store.d.ts +1 -0
- package/dist/integrations/installations-store.js +1 -1
- package/dist/integrations/remote-commands-store.d.ts +1 -0
- package/dist/integrations/remote-commands-store.js +1 -1
- package/dist/integrations/remote-devices-store.d.ts +1 -0
- package/dist/integrations/remote-devices-store.js +1 -1
- package/dist/integrations/remote-push-store.d.ts +1 -0
- package/dist/integrations/remote-push-store.js +1 -1
- package/dist/integrations/remote-run-events-store.d.ts +1 -0
- package/dist/integrations/remote-run-events-store.js +1 -1
- package/dist/integrations/scope-store.d.ts +1 -0
- package/dist/integrations/scope-store.js +1 -1
- package/dist/integrations/thread-mapping-store.d.ts +1 -0
- package/dist/integrations/thread-mapping-store.js +1 -1
- package/dist/integrations/usage-budget-store.d.ts +1 -0
- package/dist/integrations/usage-budget-store.js +1 -1
- package/dist/jobs/background-automation-runner.js +111 -9
- package/dist/jobs/run-history.d.ts +1 -0
- package/dist/jobs/run-history.js +1 -1
- package/dist/jobs/scheduler-health.d.ts +1 -0
- package/dist/jobs/scheduler-health.js +1 -1
- package/dist/mcp/approval-store.d.ts +1 -0
- package/dist/mcp/approval-store.js +1 -1
- package/dist/mcp/connect-store.d.ts +1 -0
- package/dist/mcp/connect-store.js +1 -1
- package/dist/mcp/oauth-store.d.ts +1 -0
- package/dist/mcp/oauth-store.js +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/notifications/store.d.ts +1 -0
- package/dist/notifications/store.js +1 -1
- package/dist/oauth-tokens/store.d.ts +1 -0
- package/dist/oauth-tokens/store.js +1 -1
- package/dist/observability/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/progress/store.d.ts +1 -0
- package/dist/progress/store.js +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
- package/dist/provider-api/actions/provider-api.d.ts +4 -4
- package/dist/provider-api/corpus-jobs-store.d.ts +1 -0
- package/dist/provider-api/corpus-jobs-store.js +1 -1
- package/dist/provider-api/custom-registry.d.ts +1 -0
- package/dist/provider-api/custom-registry.js +1 -1
- package/dist/provider-api/quota-governor.d.ts +1 -0
- package/dist/provider-api/quota-governor.js +1 -1
- package/dist/provider-api/staged-datasets-store.d.ts +1 -0
- package/dist/provider-api/staged-datasets-store.js +1 -1
- package/dist/resources/handlers.d.ts +3 -3
- package/dist/resources/store.d.ts +1 -0
- package/dist/resources/store.js +1 -1
- package/dist/scripts/dev/index.js +15 -1
- package/dist/search/index.js +3 -0
- package/dist/secrets/storage.d.ts +1 -0
- package/dist/secrets/storage.js +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +2 -1
- package/dist/server/agent-chat/action-filters-a2a.js +10 -2
- package/dist/server/agent-chat-plugin.js +71 -20
- package/dist/server/agent-teams-run-queue.d.ts +1 -0
- package/dist/server/agent-teams-run-queue.js +1 -1
- package/dist/server/auth-marketing.js +3 -1
- package/dist/server/auth.d.ts +18 -1
- package/dist/server/auth.js +370 -154
- package/dist/server/embed-session.d.ts +1 -0
- package/dist/server/embed-session.js +1 -1
- package/dist/server/google-auth-plugin.js +3 -1
- package/dist/server/google-oauth.d.ts +10 -0
- package/dist/server/google-oauth.js +25 -1
- package/dist/server/identity-sso-store.d.ts +1 -0
- package/dist/server/identity-sso-store.js +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/onboarding-html.js +200 -31
- package/dist/server/poll.d.ts +2 -0
- package/dist/server/poll.js +19 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/server/release-migrations.js +5 -0
- package/dist/server/release-schema.d.ts +46 -0
- package/dist/server/release-schema.js +307 -0
- package/dist/settings/store.d.ts +1 -0
- package/dist/settings/store.js +1 -1
- package/dist/shared/environment-lanes.d.ts +28 -0
- package/dist/shared/environment-lanes.js +61 -0
- package/dist/sharing/actions/share-resource.js +22 -2
- package/dist/styles/agent-native.css +17 -15
- package/dist/triggers/routes.d.ts +11 -0
- package/dist/triggers/routes.js +10 -0
- package/dist/usage/alerts-store.d.ts +1 -0
- package/dist/usage/alerts-store.js +1 -1
- package/dist/usage/store.d.ts +1 -0
- package/dist/usage/store.js +1 -1
- package/docs/content/drop-in-agent.mdx +4 -4
- package/docs/content/faq.mdx +15 -15
- package/docs/content/getting-started.mdx +173 -41
- package/docs/content/key-concepts.mdx +10 -10
- package/docs/content/using-your-agent.mdx +2 -2
- package/docs/content/what-is-agent-native.mdx +79 -228
- package/package.json +2 -2
|
@@ -42,7 +42,7 @@ const CREATE_SQL = `CREATE TABLE IF NOT EXISTS custom_api_providers (
|
|
|
42
42
|
PRIMARY KEY (scope, scope_id, id)
|
|
43
43
|
)`;
|
|
44
44
|
let _initPromise;
|
|
45
|
-
async function ensureTable() {
|
|
45
|
+
export async function ensureTable() {
|
|
46
46
|
if (!_initPromise) {
|
|
47
47
|
_initPromise = (async () => {
|
|
48
48
|
const client = getDbExec();
|
|
@@ -50,3 +50,4 @@ export declare function createProviderRequestDedupeKey(input: {
|
|
|
50
50
|
}): string | undefined;
|
|
51
51
|
export declare function executeWithProviderQuota<T>(options: ExecuteWithProviderQuotaOptions<T>): Promise<T>;
|
|
52
52
|
export declare function resetProviderQuotaStateForTests(): void;
|
|
53
|
+
export declare function ensureCooldownTable(): Promise<void>;
|
|
@@ -244,7 +244,7 @@ function persistenceTemporarilyUnavailable() {
|
|
|
244
244
|
return Boolean(state.persistenceUnavailableUntil &&
|
|
245
245
|
state.persistenceUnavailableUntil > Date.now());
|
|
246
246
|
}
|
|
247
|
-
async function ensureCooldownTable() {
|
|
247
|
+
export async function ensureCooldownTable() {
|
|
248
248
|
if (!shouldPersistCooldowns())
|
|
249
249
|
return;
|
|
250
250
|
if (persistenceTemporarilyUnavailable())
|
|
@@ -23,7 +23,7 @@ export const MAX_BYTES_PER_APP = 50 * 1024 * 1024; // 50 MB
|
|
|
23
23
|
// Table initialisation
|
|
24
24
|
// ---------------------------------------------------------------------------
|
|
25
25
|
let _initPromise;
|
|
26
|
-
async function ensureTables() {
|
|
26
|
+
export async function ensureTables() {
|
|
27
27
|
if (!_initPromise) {
|
|
28
28
|
_initPromise = (async () => {
|
|
29
29
|
const db = getDbExec();
|
|
@@ -48,11 +48,11 @@ 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
|
-
ok?: undefined;
|
|
52
51
|
error: string;
|
|
52
|
+
ok?: undefined;
|
|
53
53
|
} | {
|
|
54
|
-
error?: undefined;
|
|
55
54
|
ok: boolean;
|
|
55
|
+
error?: undefined;
|
|
56
56
|
}>;
|
|
57
57
|
/** POST /_agent-native/resources/upload — upload a file as a resource */
|
|
58
58
|
export declare function handleUploadResource(event: any): Promise<import("./store.js").Resource | {
|
|
@@ -73,10 +73,10 @@ export declare function handleUploadResource(event: any): Promise<import("./stor
|
|
|
73
73
|
runId: string | null;
|
|
74
74
|
expiresAt: number | null;
|
|
75
75
|
metadata: string | null;
|
|
76
|
-
error?: undefined;
|
|
77
76
|
url: string;
|
|
78
77
|
provider: string;
|
|
79
78
|
storageSetupRequired?: undefined;
|
|
79
|
+
error?: undefined;
|
|
80
80
|
} | {
|
|
81
81
|
error: string;
|
|
82
82
|
storageSetupRequired: boolean;
|
|
@@ -94,6 +94,7 @@ export interface EffectiveResourceContext {
|
|
|
94
94
|
export declare const LOCAL_WORKSPACE_RESOURCE_METADATA_SOURCE = "local-workspace-resource";
|
|
95
95
|
export declare function canWriteLocalWorkspaceResourcePath(resourcePath: string): Promise<boolean>;
|
|
96
96
|
export { isLocalWorkspaceResourceId };
|
|
97
|
+
export declare function ensureTable(): Promise<void>;
|
|
97
98
|
/**
|
|
98
99
|
* Seed personal AGENTS.md and LEARNINGS.md for a user if they don't exist.
|
|
99
100
|
* Called when listing resources or from the agent chat plugin.
|
package/dist/resources/store.js
CHANGED
|
@@ -601,7 +601,7 @@ function scheduleExpiredAgentScratchCleanup(client) {
|
|
|
601
601
|
console.warn("[resources] expired agent-scratch cleanup failed; will retry on a later read:", err?.message ?? err);
|
|
602
602
|
});
|
|
603
603
|
}
|
|
604
|
-
async function ensureTable() {
|
|
604
|
+
export async function ensureTable() {
|
|
605
605
|
if (!_initPromise) {
|
|
606
606
|
_initPromise = _doEnsureTable().catch((err) => {
|
|
607
607
|
// Don't cache the rejection — let the next caller retry a fresh init.
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* registered in production.
|
|
7
7
|
*/
|
|
8
8
|
import { createCodingToolRegistry } from "../../coding-tools/index.js";
|
|
9
|
+
import { getRequestRunContext } from "../../server/request-context.js";
|
|
9
10
|
import { normalizeDatabaseToolsMode, } from "../db/tool-mode.js";
|
|
10
11
|
import { dbExecToolParameters } from "../db/tool-schemas.js";
|
|
11
12
|
import { tool as listFilesTool, run as listFilesRun } from "./list-files.js";
|
|
@@ -67,6 +68,19 @@ function blockedDatabaseActionFromBash(command, databaseToolsMode) {
|
|
|
67
68
|
}
|
|
68
69
|
return null;
|
|
69
70
|
}
|
|
71
|
+
function unauthorizedActionFromBash(command, allowedActionNames) {
|
|
72
|
+
if (!allowedActionNames)
|
|
73
|
+
return null;
|
|
74
|
+
const allowed = new Set(allowedActionNames);
|
|
75
|
+
const actionCommands = command.matchAll(/\b(?:pnpm|npm|yarn|bun)(?:\s+\S+){0,4}\s+action\s+([a-z][a-z0-9-]*)\b/g);
|
|
76
|
+
for (const match of actionCommands) {
|
|
77
|
+
const actionName = match[1];
|
|
78
|
+
if (actionName && !allowed.has(actionName)) {
|
|
79
|
+
return `Error: action "${actionName}" is not available in this request's action surface.`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
70
84
|
/**
|
|
71
85
|
* Creates the dev-mode script registry with shared bash/read/edit/write
|
|
72
86
|
* coding tools and database tools. Call this and merge with your app's registry
|
|
@@ -200,7 +214,7 @@ export async function createDevScriptRegistry(options = {}) {
|
|
|
200
214
|
const codingEntries = createCodingToolRegistry({
|
|
201
215
|
cwd: process.cwd(),
|
|
202
216
|
bashThrowsOnNonZero: true,
|
|
203
|
-
beforeBash: ({ command }) => blockedDatabaseActionFromBash(command, databaseToolsMode),
|
|
217
|
+
beforeBash: ({ command }) => unauthorizedActionFromBash(command, getRequestRunContext()?.allowedActionNames) ?? blockedDatabaseActionFromBash(command, databaseToolsMode),
|
|
204
218
|
});
|
|
205
219
|
const legacyEntries = options.legacyAliases
|
|
206
220
|
? {
|
package/dist/search/index.js
CHANGED
|
@@ -48,6 +48,9 @@ export function assertPgVectorAvailable(postgres = isPostgres()) {
|
|
|
48
48
|
if (!postgres)
|
|
49
49
|
throw new Error(PGVECTOR_REQUIRED_MESSAGE);
|
|
50
50
|
}
|
|
51
|
+
// guard:allow-unreleased-schema - the table name is derived at call time from
|
|
52
|
+
// the search namespace and embedding dimensions (`${namespace}_vectors${suffix}`),
|
|
53
|
+
// so the set of tables is not known at release time and cannot be pre-created.
|
|
51
54
|
export async function ensurePgVectorIndex(db, dimensions, options) {
|
|
52
55
|
const resolved = pgVectorOptions(options);
|
|
53
56
|
const names = searchNamespaceIdentifiers(resolved.namespace, dimensions);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* Secret values are NEVER logged and NEVER returned from any route handler.
|
|
13
13
|
*/
|
|
14
14
|
import type { SecretScope } from "./register.js";
|
|
15
|
+
export declare function ensureTable(): Promise<void>;
|
|
15
16
|
/**
|
|
16
17
|
* Return the last 4 characters of a secret, with any leading characters
|
|
17
18
|
* masked. Used to show a preview without leaking the value.
|
package/dist/secrets/storage.js
CHANGED
|
@@ -21,7 +21,7 @@ import { APP_SECRETS_CREATE_SQL } from "./schema.js";
|
|
|
21
21
|
// Table bootstrap
|
|
22
22
|
// ---------------------------------------------------------------------------
|
|
23
23
|
let _initPromise;
|
|
24
|
-
async function ensureTable() {
|
|
24
|
+
export async function ensureTable() {
|
|
25
25
|
if (!_initPromise) {
|
|
26
26
|
_initPromise = (async () => {
|
|
27
27
|
const client = getDbExec();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type A2AArtifactResponseOptions, type A2AToolResultSummary } from "../../a2a/artifact-response.js";
|
|
1
|
+
import { type A2AArtifactResponseOptions, type A2APersistedMutationReceipt, type A2AToolResultSummary } from "../../a2a/artifact-response.js";
|
|
2
2
|
import type { AgentSkill } from "../../a2a/types.js";
|
|
3
3
|
import type { EngineTool } from "../../agent/engine/types.js";
|
|
4
4
|
import { type ActionEntry, type AgentLoopOutcome } from "../../agent/production-agent.js";
|
|
@@ -74,6 +74,7 @@ export declare function assembleA2AFinalResponse(events: readonly AgentChatEvent
|
|
|
74
74
|
}): {
|
|
75
75
|
responseText: string;
|
|
76
76
|
finalText: string;
|
|
77
|
+
mutationReceipts: A2APersistedMutationReceipt[];
|
|
77
78
|
};
|
|
78
79
|
type A2AAgentLoopRunner = typeof runAgentLoopDirectWithSoftTimeout;
|
|
79
80
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getHeader } from "h3";
|
|
2
|
-
import { appendA2AArtifactLinks, } from "../../a2a/artifact-response.js";
|
|
2
|
+
import { appendA2AArtifactLinks, extractA2APersistedMutationReceipts, } from "../../a2a/artifact-response.js";
|
|
3
3
|
import { collectFinalResponseTextFromAgentEvents } from "../../a2a/response-text.js";
|
|
4
4
|
import { resolveMainChatMaxOutputTokens } from "../../agent/engine/output-tokens.js";
|
|
5
5
|
import { filterInitialEngineTools, resolveAgentRequestReasoningEffort, } from "../../agent/production-agent.js";
|
|
@@ -200,7 +200,15 @@ export function assembleA2AFinalResponse(events, toolResults, options = {}) {
|
|
|
200
200
|
baseUrl: options.baseUrl ?? resolveArtifactBaseUrl(options.event),
|
|
201
201
|
includeReferencedArtifacts: true,
|
|
202
202
|
includePersistedArtifactMarker: true,
|
|
203
|
+
persistedArtifactSecret: options.persistedArtifactSecret,
|
|
204
|
+
delegatedTaskId: options.delegatedTaskId,
|
|
203
205
|
});
|
|
206
|
+
const mutationReceipts = extractA2APersistedMutationReceipts([...toolResults], options.persistedArtifactSecret
|
|
207
|
+
? {
|
|
208
|
+
persistedArtifactSecrets: [options.persistedArtifactSecret],
|
|
209
|
+
expectedDelegatedTaskId: options.delegatedTaskId,
|
|
210
|
+
}
|
|
211
|
+
: {});
|
|
204
212
|
if (terminalError) {
|
|
205
213
|
const partialResult = finalText.trim()
|
|
206
214
|
? `\n\nPartial verified results before the failure:\n${finalText.trim()}`
|
|
@@ -210,7 +218,7 @@ export function assembleA2AFinalResponse(events, toolResults, options = {}) {
|
|
|
210
218
|
if (!finalText.trim()) {
|
|
211
219
|
throw new Error("Agent completed without a response or verified artifact.\ncode: empty_agent_response");
|
|
212
220
|
}
|
|
213
|
-
return { responseText, finalText };
|
|
221
|
+
return { responseText, finalText, mutationReceipts };
|
|
214
222
|
}
|
|
215
223
|
function terminalErrorFromOutcome(outcome) {
|
|
216
224
|
if (outcome.state === "completed")
|
|
@@ -199,17 +199,19 @@ export function createSerializedA2ATaskStatusWriter(taskId, writeStatus = update
|
|
|
199
199
|
const A2A_ACTIVITY_CHECKPOINT_MIN_INTERVAL_MS = 2_000;
|
|
200
200
|
export async function resolveA2ARecoverableArtifactSecret(orgId = getRequestOrgId()) {
|
|
201
201
|
const globalSecret = process.env.A2A_SECRET?.trim();
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
202
|
+
if (orgId) {
|
|
203
|
+
try {
|
|
204
|
+
const { getOrgA2ASecret } = await import("../org/context.js");
|
|
205
|
+
const orgSecret = (await getOrgA2ASecret(orgId))?.trim();
|
|
206
|
+
if (orgSecret)
|
|
207
|
+
return orgSecret;
|
|
208
|
+
// coercion-ok: undefined is the fail-closed result when organization secret lookup throws
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
return undefined;
|
|
212
|
+
}
|
|
212
213
|
}
|
|
214
|
+
return globalSecret || undefined;
|
|
213
215
|
}
|
|
214
216
|
export function buildLeanRunPolicyPrompt(codeEditingSurfaceRestriction, prodCodeExecPromptNote) {
|
|
215
217
|
return codeEditingSurfaceRestriction + prodCodeExecPromptNote;
|
|
@@ -1619,6 +1621,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1619
1621
|
baseUrl: artifactBaseUrl,
|
|
1620
1622
|
includePersistedArtifactMarker: true,
|
|
1621
1623
|
persistedArtifactSecret: recoverableArtifactSecret,
|
|
1624
|
+
delegatedTaskId: context.taskId,
|
|
1622
1625
|
})
|
|
1623
1626
|
: null;
|
|
1624
1627
|
if (recoverableArtifactText &&
|
|
@@ -1723,7 +1726,12 @@ export function createAgentChatPlugin(options) {
|
|
|
1723
1726
|
};
|
|
1724
1727
|
return;
|
|
1725
1728
|
}
|
|
1726
|
-
const { responseText, finalText } = assembleA2AFinalResponse(a2aEvents, a2aToolResults, {
|
|
1729
|
+
const { responseText, finalText, mutationReceipts } = assembleA2AFinalResponse(a2aEvents, a2aToolResults, {
|
|
1730
|
+
event: context.event,
|
|
1731
|
+
outcome: a2aOutcome,
|
|
1732
|
+
persistedArtifactSecret: recoverableArtifactSecret,
|
|
1733
|
+
delegatedTaskId: context.taskId,
|
|
1734
|
+
});
|
|
1727
1735
|
console.log(`[A2A] Loop complete. Text: ${responseText.slice(0, 100)}...`);
|
|
1728
1736
|
// Yield the final accumulated text
|
|
1729
1737
|
yield {
|
|
@@ -1734,6 +1742,18 @@ export function createAgentChatPlugin(options) {
|
|
|
1734
1742
|
type: "text",
|
|
1735
1743
|
text: finalText,
|
|
1736
1744
|
},
|
|
1745
|
+
...(mutationReceipts.length > 0
|
|
1746
|
+
? [
|
|
1747
|
+
{
|
|
1748
|
+
type: "data",
|
|
1749
|
+
data: {
|
|
1750
|
+
kind: "agent-native/mutation-receipts",
|
|
1751
|
+
version: 1,
|
|
1752
|
+
receipts: mutationReceipts,
|
|
1753
|
+
},
|
|
1754
|
+
},
|
|
1755
|
+
]
|
|
1756
|
+
: []),
|
|
1737
1757
|
],
|
|
1738
1758
|
};
|
|
1739
1759
|
},
|
|
@@ -1791,9 +1811,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1791
1811
|
// `nativeActionsInDev` or `leanPrompt`), the dev prompt's "invoke
|
|
1792
1812
|
// template actions via bash" guidance is wrong — use the prod prompt
|
|
1793
1813
|
// + tool-format action list instead, same as production.
|
|
1794
|
-
const devNative = options?.nativeActionsInDev === true ||
|
|
1795
|
-
leanPrompt ||
|
|
1796
|
-
Boolean(options?.resolveActionSurface);
|
|
1814
|
+
const devNative = options?.nativeActionsInDev === true || leanPrompt;
|
|
1797
1815
|
// Keep legacy names for the composition below
|
|
1798
1816
|
const basePrompt = prodPrompt;
|
|
1799
1817
|
const getFrameworkPromptActions = () => Object.fromEntries(Object.entries(prodActions).filter(([name]) => !templateScripts[name] && !mcpActionEntries[name]));
|
|
@@ -2000,8 +2018,10 @@ export function createAgentChatPlugin(options) {
|
|
|
2000
2018
|
delegation: { protocol: "mcp" },
|
|
2001
2019
|
},
|
|
2002
2020
|
});
|
|
2021
|
+
const persistedArtifactSecret = await resolveA2ARecoverableArtifactSecret();
|
|
2003
2022
|
return assembleA2AFinalResponse(mcpEvents, mcpToolResults, {
|
|
2004
2023
|
outcome: mcpOutcome,
|
|
2024
|
+
persistedArtifactSecret,
|
|
2005
2025
|
}).finalText;
|
|
2006
2026
|
},
|
|
2007
2027
|
});
|
|
@@ -2933,11 +2953,44 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
2933
2953
|
// template's actions as native tools instead of routing through bash.
|
|
2934
2954
|
// Templates with structured-arg actions (objects/arrays) need this to
|
|
2935
2955
|
// avoid round-tripping JSON through the CLI parser.
|
|
2956
|
+
// Request-scoped dev actions are present for authorization and the
|
|
2957
|
+
// `pnpm action` prompt, but remain CLI-only instead of becoming native
|
|
2958
|
+
// tools. The resolver therefore sees the same action names that the
|
|
2959
|
+
// dev prompt can teach without changing the shell-backed dev surface.
|
|
2960
|
+
const requestScopedDevActions = options?.resolveActionSurface
|
|
2961
|
+
? Object.fromEntries(Object.entries({ ...discoveredActions, ...templateScripts }).map(([name, entry]) => [name, { ...entry, agentTool: false }]))
|
|
2962
|
+
: {};
|
|
2963
|
+
// Keep the local coding registry in every dev handler variant. Native
|
|
2964
|
+
// action mode changes how app actions are called; it must not remove
|
|
2965
|
+
// bash/read/edit/write from Electron's local chat surface.
|
|
2966
|
+
const devScriptRegistry = await createDevScriptRegistry({
|
|
2967
|
+
databaseTools: databaseToolsMode,
|
|
2968
|
+
});
|
|
2969
|
+
const localDevActionNames = new Set(Object.keys(devScriptRegistry));
|
|
2970
|
+
const resolveDevActionSurface = options?.resolveActionSurface
|
|
2971
|
+
? async (details) => {
|
|
2972
|
+
const appActionNames = details.availableActionNames.filter((name) => !localDevActionNames.has(name));
|
|
2973
|
+
const surface = await options.resolveActionSurface({
|
|
2974
|
+
...details,
|
|
2975
|
+
availableActionNames: appActionNames,
|
|
2976
|
+
});
|
|
2977
|
+
const localActionNames = details.availableActionNames.filter((name) => localDevActionNames.has(name));
|
|
2978
|
+
return {
|
|
2979
|
+
allowedActionNames: [
|
|
2980
|
+
...new Set([
|
|
2981
|
+
...surface.allowedActionNames,
|
|
2982
|
+
...localActionNames,
|
|
2983
|
+
]),
|
|
2984
|
+
],
|
|
2985
|
+
};
|
|
2986
|
+
}
|
|
2987
|
+
: undefined;
|
|
2936
2988
|
const devActions = attachToolSearch(leanPrompt
|
|
2937
|
-
? leanActions
|
|
2989
|
+
? { ...devScriptRegistry, ...leanActions }
|
|
2938
2990
|
: devNative
|
|
2939
|
-
? prodActions
|
|
2991
|
+
? { ...devScriptRegistry, ...prodActions }
|
|
2940
2992
|
: {
|
|
2993
|
+
...requestScopedDevActions,
|
|
2941
2994
|
...resourceScripts,
|
|
2942
2995
|
...docsScripts,
|
|
2943
2996
|
...(lazyContext ? frameworkContextTool : {}),
|
|
@@ -2959,9 +3012,7 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
2959
3012
|
...coreAttachmentTools,
|
|
2960
3013
|
...browserTools,
|
|
2961
3014
|
...mcpActionEntries,
|
|
2962
|
-
...
|
|
2963
|
-
databaseTools: databaseToolsMode,
|
|
2964
|
-
})),
|
|
3015
|
+
...devScriptRegistry,
|
|
2965
3016
|
// Full-database admin tools (NODE_ENV=development gate — see
|
|
2966
3017
|
// dbAdminScripts; also in prodActions so App mode has them too).
|
|
2967
3018
|
...dbAdminScripts,
|
|
@@ -3051,7 +3102,7 @@ Non-code requests are still fine on this surface: read data, navigate the UI, su
|
|
|
3051
3102
|
}
|
|
3052
3103
|
return options?.prepareRequest?.(details);
|
|
3053
3104
|
},
|
|
3054
|
-
resolveActionSurface:
|
|
3105
|
+
resolveActionSurface: resolveDevActionSurface,
|
|
3055
3106
|
skipFilesContext,
|
|
3056
3107
|
initialToolNames: effectiveInitialToolNames,
|
|
3057
3108
|
...(options?.toolLimits ? { toolLimits: options.toolLimits } : {}),
|
|
@@ -51,6 +51,7 @@ export interface AgentTeamRunQueueRow {
|
|
|
51
51
|
createdAt: number;
|
|
52
52
|
updatedAt: number;
|
|
53
53
|
}
|
|
54
|
+
export declare function ensureTable(): Promise<void>;
|
|
54
55
|
declare function getAffectedRowCount(result: unknown): number;
|
|
55
56
|
export interface EnqueueAgentTeamRunInput {
|
|
56
57
|
taskId: string;
|
|
@@ -37,7 +37,7 @@ export const RUN_DISPATCH_STUCK_AFTER_MS = 15_000;
|
|
|
37
37
|
* retried (side-effectful work may already have happened). Mirrors A2A. */
|
|
38
38
|
export const RUN_PROCESSING_STUCK_AFTER_MS = 5 * 60 * 1000;
|
|
39
39
|
let _initPromise;
|
|
40
|
-
async function ensureTable() {
|
|
40
|
+
export async function ensureTable() {
|
|
41
41
|
if (!_initPromise) {
|
|
42
42
|
_initPromise = (async () => {
|
|
43
43
|
const client = getDbExec();
|
|
@@ -203,7 +203,9 @@ function slugFromHost(value) {
|
|
|
203
203
|
if (!host)
|
|
204
204
|
return undefined;
|
|
205
205
|
if (host.endsWith(".agent-native.com")) {
|
|
206
|
-
|
|
206
|
+
const hostSlug = host.slice(0, -".agent-native.com".length);
|
|
207
|
+
return (normalizeSlug(hostSlug) ??
|
|
208
|
+
normalizeSlug(hostSlug.replace(/^beta[.-]/, "")));
|
|
207
209
|
}
|
|
208
210
|
return undefined;
|
|
209
211
|
}
|
package/dist/server/auth.d.ts
CHANGED
|
@@ -211,6 +211,7 @@ export declare function isLoopbackAddress(ip: string | undefined): boolean;
|
|
|
211
211
|
*/
|
|
212
212
|
export declare function isLoopbackRequest(event: H3Event): boolean;
|
|
213
213
|
export declare function isExpectedAuthFailure(error: unknown): boolean;
|
|
214
|
+
export declare function ensureSessionTable(): Promise<void>;
|
|
214
215
|
/**
|
|
215
216
|
* Create a new session in the legacy sessions table.
|
|
216
217
|
* Used by google-oauth.ts for mobile deep linking.
|
|
@@ -244,7 +245,23 @@ export interface DesktopExchangeErrorPayload {
|
|
|
244
245
|
existingOwner?: string;
|
|
245
246
|
attemptedOwner?: string;
|
|
246
247
|
}
|
|
247
|
-
export declare
|
|
248
|
+
export declare const DESKTOP_OAUTH_BROWSER_BINDING_COOKIE = "an_desktop_oauth_binding";
|
|
249
|
+
/**
|
|
250
|
+
* Create or reuse the browser-local binding for a desktop Google OAuth flow.
|
|
251
|
+
* The raw value stays in an HttpOnly cookie; only its hash travels in signed
|
|
252
|
+
* OAuth state and the exchange challenge. This prevents a caller from
|
|
253
|
+
* initiating a flow and handing its authorization URL to another browser.
|
|
254
|
+
*/
|
|
255
|
+
export declare function prepareDesktopOAuthBrowserBinding(event: H3Event): string;
|
|
256
|
+
/** Verify that a desktop OAuth callback is returning to its initiating browser. */
|
|
257
|
+
export declare function matchesDesktopOAuthBrowserBinding(event: H3Event, expectedHash: string): boolean;
|
|
258
|
+
export declare function setDesktopExchange(flowId: string, token: string, email: string, verifierHash: string): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Register the client-held verifier for a desktop OAuth flow before Google
|
|
261
|
+
* sees the request. Only the verifier hash is persisted; the initiating
|
|
262
|
+
* browser keeps the raw verifier and presents it when polling the exchange.
|
|
263
|
+
*/
|
|
264
|
+
export declare function registerDesktopExchange(flowId: string, verifier: string, browserBindingHash?: string): Promise<string>;
|
|
248
265
|
export declare function setDesktopExchangeError(flowId: string, error: DesktopExchangeErrorPayload): void;
|
|
249
266
|
/**
|
|
250
267
|
* Run the auth guard on an event. Returns a Response/object to block the
|