@agent-native/core 0.214.0 → 0.217.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.
- package/dist/action.js +54 -1
- package/dist/agent/actions/disconnect-chatgpt-subscription.js +5 -0
- package/dist/agent/actions/get-agentkit-capabilities.js +3 -3
- package/dist/agent/actions/manage-builder-connection.js +5 -0
- package/dist/agent/actions/manage-provider-key-policy.js +5 -0
- package/dist/agent/actions/manage-provider-models.js +5 -0
- package/dist/agent/actions/manage-service-providers.js +5 -0
- package/dist/agent/actions/select-chatgpt-subscription-account.js +5 -0
- package/dist/agent/context-xray/actions/context-evict.js +5 -0
- package/dist/agent/context-xray/actions/context-pin.js +5 -0
- package/dist/agent/context-xray/actions/context-report.js +5 -0
- package/dist/agent/context-xray/actions/context-restore.js +5 -0
- package/dist/agent/execution-fence.d.ts +1 -0
- package/dist/agent/execution-fence.js +5 -0
- package/dist/agent/production-agent.d.ts +35 -2
- package/dist/agent/production-agent.js +629 -32
- package/dist/agent/run-manager.d.ts +2 -0
- package/dist/agent/run-manager.js +397 -115
- package/dist/agent/run-slot-lock.d.ts +2 -0
- package/dist/agent/run-slot-lock.js +6 -0
- package/dist/agent/run-store.d.ts +5 -0
- package/dist/agent/run-store.js +423 -156
- package/dist/agent/thread-data-builder.js +27 -5
- package/dist/agent/types.d.ts +6 -12
- package/dist/agentkit/capabilities.d.ts +1 -1
- package/dist/app-config/analytics.js +1 -1
- package/dist/application-state/store.d.ts +5 -0
- package/dist/application-state/store.js +26 -0
- package/dist/automation/index.d.ts +1 -1
- package/dist/chat-threads/schema-migrations.js +17 -0
- package/dist/chat-threads/store.d.ts +21 -1
- package/dist/chat-threads/store.js +223 -41
- package/dist/cli/skills-content/turn-into-app-skill.d.ts +1 -1
- package/dist/cli/skills-content/turn-into-app-skill.js +20 -18
- package/dist/cli/templates-meta.js +14 -0
- package/dist/client/analytics-session.d.ts +7 -0
- package/dist/client/analytics-session.js +27 -1
- package/dist/client/analytics.js +276 -31
- package/dist/client/chat/agentkit-agent-native.js +79 -3
- package/dist/client/chat/agentkit-protocol.js +80 -42
- package/dist/client/chat/runtime.d.ts +5 -1
- package/dist/client/chat/runtime.js +46 -3
- package/dist/client/consent.d.ts +48 -0
- package/dist/client/consent.js +413 -0
- package/dist/client/onboarding/index.d.ts +1 -0
- package/dist/client/onboarding/index.js +1 -0
- package/dist/client/onboarding/use-onboarding-checklist.d.ts +23 -0
- package/dist/client/onboarding/use-onboarding-checklist.js +115 -0
- package/dist/client/review/use-review.d.ts +2 -0
- package/dist/client/review/use-review.js +28 -1
- package/dist/client/session-replay.d.ts +1 -1
- package/dist/client/session-replay.js +142 -3
- package/dist/client/sharing/useResourceAccessGate.d.ts +3 -2
- package/dist/client/sharing/useResourceAccessGate.js +9 -1
- package/dist/client/use-chat-thread-list.d.ts +2 -0
- package/dist/client/use-chat-thread-list.js +12 -2
- package/dist/client/use-chat-threads.d.ts +1 -0
- package/dist/client/use-chat-threads.js +2 -0
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/connections/catalog.d.ts +5 -5
- package/dist/connections/catalog.js +22 -3
- package/dist/data-widgets/index.d.ts +36 -2
- package/dist/data-widgets/index.js +94 -6
- package/dist/db/migrations.js +4 -1
- package/dist/db/schema-snapshot.generated.js +8 -1
- package/dist/feature-flags/actions/set-feature-flag.js +5 -0
- package/dist/feature-flags/index.d.ts +1 -1
- package/dist/feature-flags/index.js +1 -1
- package/dist/feature-flags/store.d.ts +12 -0
- package/dist/feature-flags/store.js +79 -7
- package/dist/file-upload/actions/manage-file-storage.js +5 -0
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.js +5 -0
- package/dist/history/actions/create-resource-version.js +5 -0
- package/dist/history/actions/restore-resource-version.js +5 -0
- package/dist/ingestion/index.d.ts +1 -1
- package/dist/ingestion/index.js +1 -1
- package/dist/ingestion/pptx.d.ts +11 -0
- package/dist/ingestion/pptx.js +81 -1
- package/dist/integrations/actions/manage-messaging-channel.js +5 -0
- package/dist/jobs/actions/manage-recurring-job.d.ts +1 -1
- package/dist/jobs/scheduler.js +17 -1
- package/dist/labs/actions/set-lab.js +5 -0
- package/dist/localization/actions/set-localization-preference.js +5 -0
- package/dist/localization/consent-banner-messages.d.ts +16 -0
- package/dist/localization/consent-banner-messages.js +149 -0
- package/dist/localization/core-messages.js +4 -0
- package/dist/localization/default-messages.d.ts +1 -0
- package/dist/localization/default-messages.js +2 -0
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/actions/save-observability-instruction-update.js +5 -0
- package/dist/observability/actions/save-observability-review-summary.js +5 -0
- package/dist/observability/routes.d.ts +6 -6
- package/dist/onboarding/index.d.ts +2 -1
- package/dist/onboarding/index.js +1 -0
- package/dist/onboarding/plugin.js +55 -46
- package/dist/onboarding/status.d.ts +15 -0
- package/dist/onboarding/status.js +59 -0
- package/dist/onboarding/types.d.ts +12 -0
- package/dist/onboarding/types.js +2 -1
- package/dist/org/workspace-app-access.js +19 -9
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +16 -16
- package/dist/provider-api/actions/provider-api.d.ts +11 -11
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/provider-api/index.js +9 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/review/actions/consume-review-feedback.js +5 -0
- package/dist/review/actions/create-review-comment.js +5 -0
- package/dist/review/actions/delete-review-comment.js +5 -0
- package/dist/review/actions/react-to-review-comment.js +5 -0
- package/dist/review/actions/reply-review-comment.js +5 -0
- package/dist/review/actions/resolve-review-thread.js +5 -0
- package/dist/review/actions/send-review-thread-to-agent.js +5 -0
- package/dist/review/actions/set-review-status.js +5 -0
- package/dist/review/actions/set-review-thread-muted.js +5 -0
- package/dist/review/actions/set-review-thread-unread.js +5 -0
- package/dist/review/actions/set-review-threads-unread.js +5 -0
- package/dist/review/actions/update-review-comment-anchor.js +5 -0
- package/dist/review/actions/update-review-comment.js +5 -0
- package/dist/review/suggestions/actions.js +60 -21
- package/dist/review/suggestions/store.d.ts +2 -0
- package/dist/review/suggestions/store.js +28 -0
- package/dist/secrets/actions/delete-api-key.js +5 -0
- package/dist/secrets/routes.d.ts +6 -6
- package/dist/server/agent-capabilities.js +13 -6
- package/dist/server/agent-chat/context-tools.js +63 -2
- package/dist/server/agent-chat-plugin.d.ts +2 -0
- package/dist/server/agent-chat-plugin.js +242 -54
- package/dist/server/agent-engine-default-model-route.d.ts +1 -1
- package/dist/server/agent-engine-ollama-models-route.d.ts +1 -1
- package/dist/server/analytics.d.ts +0 -1
- package/dist/server/analytics.js +81 -20
- package/dist/server/application-state-maintenance.d.ts +2 -0
- package/dist/server/application-state-maintenance.js +2 -0
- package/dist/server/attribution.d.ts +14 -0
- package/dist/server/attribution.js +62 -2
- package/dist/server/auth.js +7 -0
- package/dist/server/builder-api-auth.d.ts +7 -0
- package/dist/server/builder-api-auth.js +24 -0
- package/dist/server/builder-oauth.d.ts +5 -1
- package/dist/server/builder-oauth.js +5 -0
- package/dist/server/consent-route.d.ts +41 -0
- package/dist/server/consent-route.js +102 -0
- package/dist/server/core-routes-plugin.d.ts +1 -1
- package/dist/server/first-touch-route.d.ts +39 -0
- package/dist/server/first-touch-route.js +115 -0
- package/dist/server/index.d.ts +2 -1
- package/dist/server/index.js +2 -1
- package/dist/server/queued-submission-inbox-drain.d.ts +9 -0
- package/dist/server/queued-submission-inbox-drain.js +12 -0
- package/dist/server/request-origin.d.ts +6 -0
- package/dist/server/request-origin.js +12 -0
- package/dist/settings/org-settings.d.ts +2 -1
- package/dist/settings/org-settings.js +4 -1
- package/dist/settings/store.d.ts +8 -0
- package/dist/settings/store.js +14 -5
- package/dist/shared/consent.d.ts +33 -0
- package/dist/shared/consent.js +149 -0
- package/dist/shared/first-touch-persistence.d.ts +31 -0
- package/dist/shared/first-touch-persistence.js +53 -0
- package/dist/sharing/actions/set-resource-visibility.js +5 -0
- package/dist/sharing/actions/share-resource.js +5 -0
- package/dist/sharing/actions/unshare-resource.js +5 -0
- package/dist/templates/chat/.agents/skills/actions/references/action-fields.md +1 -1
- package/dist/templates/default/.agents/skills/actions/references/action-fields.md +1 -1
- package/dist/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +36 -80
- package/dist/templates/factory/.agents/skills/review-latest-feedback/references/channel-inventory.md +54 -16
- package/dist/templates/factory/.agents/skills/review-latest-feedback/references/slack-reaction-replies.md +50 -73
- package/dist/templates/headless/.agents/skills/actions/references/action-fields.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/actions/references/action-fields.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +20 -18
- package/dist/triggers/actions/manage-automation.d.ts +4 -4
- package/dist/usage/actions/get-usage-metrics.js +27 -4
- package/dist/usage/actions/manage-usage-alert.js +5 -0
- package/dist/vite/client.js +8 -6
- package/dist/workspace-connections/actions/bulk-update-workspace-user-groups.js +5 -0
- package/dist/workspace-connections/actions/delete-workspace-user-group.js +5 -0
- package/dist/workspace-connections/actions/upsert-workspace-user-group.js +5 -0
- package/docs/content/actions-access-control.mdx +8 -8
- package/docs/content/actions-defining.mdx +9 -8
- package/docs/content/deployment-environment-variables.mdx +1 -1
- package/docs/content/environment-variables.mdx +1 -1
- package/docs/content/template-design-developers.mdx +9 -9
- package/docs/content/template-design-features.mdx +1 -3
- package/docs/content/turn-into-app.mdx +4 -0
- package/package.json +6 -3
- package/src/templates/chat/.agents/skills/actions/references/action-fields.md +1 -1
- package/src/templates/default/.agents/skills/actions/references/action-fields.md +1 -1
- package/src/templates/factory/.agents/skills/review-latest-feedback/SKILL.md +36 -80
- package/src/templates/factory/.agents/skills/review-latest-feedback/references/channel-inventory.md +54 -16
- package/src/templates/factory/.agents/skills/review-latest-feedback/references/slack-reaction-replies.md +50 -73
- package/src/templates/headless/.agents/skills/actions/references/action-fields.md +1 -1
- package/src/templates/workspace-core/.agents/skills/actions/references/action-fields.md +1 -1
- package/src/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +20 -18
package/dist/action.js
CHANGED
|
@@ -205,6 +205,50 @@ export function ranCallEmitsChange(entry, outcome, args, fallbackReadOnly) {
|
|
|
205
205
|
const readOnly = actionCallReadOnly(entry, args) ?? fallbackReadOnly;
|
|
206
206
|
return invocationEffect(entry, outcome, { readOnly }).changed;
|
|
207
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* PostgreSQL breaks a deadlock (40P01) or a serializable conflict (40001) by
|
|
210
|
+
* rolling back one whole transaction. Drivers and Drizzle surface that as an
|
|
211
|
+
* untyped "Failed query", which reads as a bug and hides the rollback, so an
|
|
212
|
+
* action reports it as a typed conflict. The message must not claim nothing
|
|
213
|
+
* was saved: an action can commit an earlier transaction or an external write
|
|
214
|
+
* before the one that rolled back.
|
|
215
|
+
*/
|
|
216
|
+
const TRANSACTION_CONFLICT_SQLSTATES = new Set(["40P01", "40001"]);
|
|
217
|
+
/** What a run that threw `error` throws: a transaction conflict as typed. */
|
|
218
|
+
function typedTransactionConflict(error) {
|
|
219
|
+
let sqlState;
|
|
220
|
+
try {
|
|
221
|
+
sqlState = transactionConflictSqlState(error);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
// Any read of a thrown value may throw. That value goes on as thrown,
|
|
225
|
+
// so readableFailure reports it as unreadable instead of the read's own
|
|
226
|
+
// error replacing it.
|
|
227
|
+
return error;
|
|
228
|
+
}
|
|
229
|
+
if (!sqlState)
|
|
230
|
+
return error;
|
|
231
|
+
return new ActionContractError("The database rolled back this action's transaction because it conflicted with another transaction running at the same time. Anything the action saved outside that transaction stays saved, so read the current state and redo only what is missing.", {
|
|
232
|
+
errorCode: "transaction_conflict",
|
|
233
|
+
statusCode: 409,
|
|
234
|
+
details: { sqlState },
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function transactionConflictSqlState(error) {
|
|
238
|
+
if (isActionContractError(error))
|
|
239
|
+
return null;
|
|
240
|
+
let cause = error;
|
|
241
|
+
for (let depth = 0; depth < 5; depth += 1) {
|
|
242
|
+
if (!cause || typeof cause !== "object")
|
|
243
|
+
return null;
|
|
244
|
+
const code = cause.code;
|
|
245
|
+
if (typeof code === "string" && TRANSACTION_CONFLICT_SQLSTATES.has(code)) {
|
|
246
|
+
return code;
|
|
247
|
+
}
|
|
248
|
+
cause = cause.cause;
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
208
252
|
export class AgentActionStopError extends Error {
|
|
209
253
|
agentNativeStop = true;
|
|
210
254
|
errorCode;
|
|
@@ -360,9 +404,18 @@ export function defineAction(options) {
|
|
|
360
404
|
}
|
|
361
405
|
return options.run(args, ctx);
|
|
362
406
|
};
|
|
363
|
-
const
|
|
407
|
+
const accessCheckedRun = typeof options.authorize === "function" || options.access
|
|
364
408
|
? wrapRunWithAccess(handlerRun, options.access, options.authorize)
|
|
365
409
|
: handlerRun;
|
|
410
|
+
// Access checks query the database too, so they convert the same way.
|
|
411
|
+
const guardedRun = async (args, ctx, gateArgs) => {
|
|
412
|
+
try {
|
|
413
|
+
return await accessCheckedRun(args, ctx, gateArgs);
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
throw typedTransactionConflict(error);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
366
419
|
const uiOnlyGuardedRun = options.uiOnly === true
|
|
367
420
|
? async (args, ctx, gateArgs) => {
|
|
368
421
|
if (ctx?.caller !== "frontend") {
|
|
@@ -13,6 +13,11 @@ export default defineAction({
|
|
|
13
13
|
.optional()
|
|
14
14
|
.describe("Remove the user's unusable credential from the older experimental ChatGPT flow."),
|
|
15
15
|
}),
|
|
16
|
+
mcpAnnotations: {
|
|
17
|
+
readOnlyHint: false,
|
|
18
|
+
destructiveHint: true,
|
|
19
|
+
openWorldHint: true,
|
|
20
|
+
},
|
|
16
21
|
run: async (_args, ctx) => {
|
|
17
22
|
const email = ctx?.userEmail;
|
|
18
23
|
if (!email)
|
|
@@ -2,7 +2,7 @@ import { z } from "zod";
|
|
|
2
2
|
import { defineAction, fail } from "../../action.js";
|
|
3
3
|
import { listAgentKitCapabilities, } from "../../agentkit/capabilities.js";
|
|
4
4
|
export default defineAction({
|
|
5
|
-
description: "Read the signed-in user's AgentKit context-source and integration capabilities for Design or Slides. Returns only supported, connected capability labels and availability; never returns credentials or connection details.",
|
|
5
|
+
description: "Read the signed-in user's AgentKit context-source and integration capabilities for Design, Slides, or Slides 2. Returns only supported, connected capability labels and availability; never returns credentials or connection details.",
|
|
6
6
|
schema: z.object({}),
|
|
7
7
|
http: { method: "GET" },
|
|
8
8
|
readOnly: true,
|
|
@@ -10,8 +10,8 @@ export default defineAction({
|
|
|
10
10
|
toolCallable: false,
|
|
11
11
|
run: async (_args, ctx) => {
|
|
12
12
|
const appId = ctx?.appId;
|
|
13
|
-
if (appId !== "design" && appId !== "slides") {
|
|
14
|
-
fail("AgentKit capabilities are only available in Design and Slides.", {
|
|
13
|
+
if (appId !== "design" && appId !== "slides" && appId !== "slides-2") {
|
|
14
|
+
fail("AgentKit capabilities are only available in Design, Slides, and Slides 2.", {
|
|
15
15
|
errorCode: "agentkit_capabilities_unsupported_app",
|
|
16
16
|
statusCode: 400,
|
|
17
17
|
});
|
|
@@ -30,6 +30,11 @@ export default defineAction({
|
|
|
30
30
|
},
|
|
31
31
|
// disconnectBuilderConnectionAtScope records the disconnect at its scope.
|
|
32
32
|
audit: { enabled: false },
|
|
33
|
+
mcpAnnotations: {
|
|
34
|
+
readOnlyHint: false,
|
|
35
|
+
destructiveHint: true,
|
|
36
|
+
openWorldHint: true,
|
|
37
|
+
},
|
|
33
38
|
run: async (args, ctx) => {
|
|
34
39
|
const email = ctx?.userEmail?.trim().toLowerCase();
|
|
35
40
|
if (!email) {
|
|
@@ -52,6 +52,11 @@ export default defineAction({
|
|
|
52
52
|
},
|
|
53
53
|
// Only real changes (and refused ones) are recorded, below.
|
|
54
54
|
audit: { enabled: false },
|
|
55
|
+
mcpAnnotations: {
|
|
56
|
+
readOnlyHint: false,
|
|
57
|
+
destructiveHint: false,
|
|
58
|
+
openWorldHint: false,
|
|
59
|
+
},
|
|
55
60
|
run: async (args, ctx) => {
|
|
56
61
|
const email = ctx?.userEmail?.trim().toLowerCase();
|
|
57
62
|
const orgId = ctx?.orgId?.trim();
|
|
@@ -40,6 +40,11 @@ export default defineAction({
|
|
|
40
40
|
: `Set ${scope} ${args.provider} models (${args.models?.length ?? 0})`;
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
+
mcpAnnotations: {
|
|
44
|
+
readOnlyHint: false,
|
|
45
|
+
destructiveHint: false,
|
|
46
|
+
openWorldHint: false,
|
|
47
|
+
},
|
|
43
48
|
run: async (args, ctx) => {
|
|
44
49
|
if (!ctx?.userEmail)
|
|
45
50
|
fail("Not authenticated.", { statusCode: 401 });
|
|
@@ -134,6 +134,11 @@ export default defineAction({
|
|
|
134
134
|
toolCallable: false,
|
|
135
135
|
// Only real changes (and refused ones) are recorded, below.
|
|
136
136
|
audit: { enabled: false },
|
|
137
|
+
mcpAnnotations: {
|
|
138
|
+
readOnlyHint: false,
|
|
139
|
+
destructiveHint: false,
|
|
140
|
+
openWorldHint: false,
|
|
141
|
+
},
|
|
137
142
|
run: async (args, ctx) => {
|
|
138
143
|
const email = ctx?.userEmail?.trim().toLowerCase();
|
|
139
144
|
const orgId = ctx?.orgId?.trim();
|
|
@@ -6,6 +6,11 @@ export default defineAction({
|
|
|
6
6
|
schema: z.object({
|
|
7
7
|
accountId: z.string().min(1).max(80),
|
|
8
8
|
}),
|
|
9
|
+
mcpAnnotations: {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: false,
|
|
13
|
+
},
|
|
9
14
|
run: async (args, ctx) => {
|
|
10
15
|
const email = ctx?.userEmail;
|
|
11
16
|
if (!email)
|
|
@@ -10,6 +10,11 @@ export default defineAction({
|
|
|
10
10
|
threadId: z.string(),
|
|
11
11
|
segmentId: z.string(),
|
|
12
12
|
}),
|
|
13
|
+
mcpAnnotations: {
|
|
14
|
+
readOnlyHint: false,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
},
|
|
13
18
|
run: async (args) => {
|
|
14
19
|
const ownerEmail = getRequestUserEmail();
|
|
15
20
|
if (!ownerEmail)
|
|
@@ -10,6 +10,11 @@ export default defineAction({
|
|
|
10
10
|
threadId: z.string(),
|
|
11
11
|
segmentId: z.string(),
|
|
12
12
|
}),
|
|
13
|
+
mcpAnnotations: {
|
|
14
|
+
readOnlyHint: false,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
},
|
|
13
18
|
run: async (args) => {
|
|
14
19
|
const ownerEmail = getRequestUserEmail();
|
|
15
20
|
if (!ownerEmail)
|
|
@@ -21,6 +21,11 @@ export default defineAction({
|
|
|
21
21
|
model: z.string().optional(),
|
|
22
22
|
segments: z.array(reportedSegmentSchema).default([]),
|
|
23
23
|
}),
|
|
24
|
+
mcpAnnotations: {
|
|
25
|
+
readOnlyHint: false,
|
|
26
|
+
destructiveHint: false,
|
|
27
|
+
openWorldHint: false,
|
|
28
|
+
},
|
|
24
29
|
run: async (args) => {
|
|
25
30
|
const ownerEmail = getRequestUserEmail();
|
|
26
31
|
if (!ownerEmail)
|
|
@@ -10,6 +10,11 @@ export default defineAction({
|
|
|
10
10
|
threadId: z.string(),
|
|
11
11
|
segmentId: z.string(),
|
|
12
12
|
}),
|
|
13
|
+
mcpAnnotations: {
|
|
14
|
+
readOnlyHint: false,
|
|
15
|
+
destructiveHint: false,
|
|
16
|
+
openWorldHint: false,
|
|
17
|
+
},
|
|
13
18
|
run: async (args) => {
|
|
14
19
|
const ownerEmail = getRequestUserEmail();
|
|
15
20
|
if (!ownerEmail)
|
|
@@ -23,6 +23,7 @@ export declare function currentExecutionFenceForScope(scope: {
|
|
|
23
23
|
}): ExecutionFence | undefined;
|
|
24
24
|
export declare function withExecutionLeaseRequested<T>(work: () => T): T;
|
|
25
25
|
export declare function withExecutionFence<T>(fence: ExecutionFence, work: () => T): T;
|
|
26
|
+
export declare function runWithoutExecutionFence<T>(work: () => T): T;
|
|
26
27
|
export declare function lockAndAssertCurrentExecutionFences(tx: DbExec): Promise<void>;
|
|
27
28
|
export declare function withFencedExecutionWrite<T>(write: (tx: DbExec) => Promise<T>, scope?: {
|
|
28
29
|
runId?: string;
|
|
@@ -61,6 +61,11 @@ export function withExecutionFence(fence, work) {
|
|
|
61
61
|
executionLeaseRequested: true,
|
|
62
62
|
}, work);
|
|
63
63
|
}
|
|
64
|
+
export function runWithoutExecutionFence(work) {
|
|
65
|
+
// A follow-up turn scheduled by a completed run must not inherit that run's
|
|
66
|
+
// now-expired lease through AsyncLocalStorage.
|
|
67
|
+
return executionFenceStorage.run({ fences: [], executionLeaseRequested: false }, work);
|
|
68
|
+
}
|
|
64
69
|
export async function lockAndAssertCurrentExecutionFences(tx) {
|
|
65
70
|
const fences = executionFenceStorage.getStore()?.fences ?? [];
|
|
66
71
|
for (const activeFence of fences) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentSubmissionPayload } from "@agent-native/agentkit/protocol";
|
|
1
|
+
import { type AgentRunOptions, type AgentSubmissionReference, type AgentSubmissionPayload } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import type { EventHandler as H3EventHandler } from "h3";
|
|
3
3
|
import "../authorization/check-action.js";
|
|
4
4
|
import type { Task } from "../a2a/types.js";
|
|
@@ -23,7 +23,7 @@ import type { AgentEngine, EngineTool, EngineMessage, EngineContentPart, EngineI
|
|
|
23
23
|
import { type Processor } from "./processors.js";
|
|
24
24
|
import { subscribeToRun, getActiveRunForThread, getActiveRunForThreadAsync, getRun, abortRun, abortRunDurably, abortRunAndTurnDurably, abortRunAtSafeBoundaryDurably, abortTurnByRefDurably, abortTurnDurably } from "./run-manager.js";
|
|
25
25
|
import type { ActiveRun } from "./run-manager.js";
|
|
26
|
-
import { type AgentTurnInitiator, insertRun, isTurnAborted, markRunAborted, updateRunHeartbeat, updateRunStatusIfRunning, updateRunTerminalStateIfRunning, setRunError, setRunTerminalReason, claimBackgroundRun, readBackgroundRunClaim, recordRunDiagnostic, countRunsForTurn } from "./run-store.js";
|
|
26
|
+
import { type AgentTurnInitiator, insertRun, isRunAborted, isTurnAborted, markRunAborted, updateRunHeartbeat, updateRunStatusIfRunning, updateRunTerminalStateIfRunning, setRunError, setRunTerminalReason, claimBackgroundRun, readBackgroundRunClaim, recordRunDiagnostic, countRunsForTurn } from "./run-store.js";
|
|
27
27
|
import { type AgentActionScope, ActionTool, AgentChatAttachment, AgentChatEvent, AgentFileMutationProof, AgentChatReference, AgentChatStructuredMessage } from "./types.js";
|
|
28
28
|
import { type ToolWriteReceipt } from "./write-receipts.js";
|
|
29
29
|
export { PROVIDER_TO_ENV };
|
|
@@ -719,6 +719,19 @@ export declare function shouldGuardRepeatedSourceSweep(opts: {
|
|
|
719
719
|
message: string;
|
|
720
720
|
} | null;
|
|
721
721
|
type ModelInputObserver = (messages: readonly unknown[]) => void | Promise<void>;
|
|
722
|
+
export type QueuedRunInterruptBoundaryResult = "none" | "aborted" | "pending";
|
|
723
|
+
export declare function createRunSafeBoundaryGuards(input: {
|
|
724
|
+
signal: AbortSignal;
|
|
725
|
+
flushEvents: () => Promise<void>;
|
|
726
|
+
interruptRequestedAtBoundary: () => Promise<QueuedRunInterruptBoundaryResult>;
|
|
727
|
+
}): {
|
|
728
|
+
beforeModelDispatch: BeforeModelDispatch;
|
|
729
|
+
beforeWrite: () => Promise<void>;
|
|
730
|
+
};
|
|
731
|
+
export declare function confirmQueuedRunInterrupt(input: {
|
|
732
|
+
abort: () => Promise<boolean>;
|
|
733
|
+
defer: () => Promise<unknown>;
|
|
734
|
+
}): Promise<Exclude<QueuedRunInterruptBoundaryResult, "none">>;
|
|
722
735
|
export declare function runAgentLoop(opts: {
|
|
723
736
|
engine: AgentEngine;
|
|
724
737
|
model: string;
|
|
@@ -915,6 +928,25 @@ export declare function resolvePriorContinuationState(backgroundRunMarker: Recor
|
|
|
915
928
|
};
|
|
916
929
|
export declare function resolvePriorContinuationReason(backgroundRunMarker: Record<string, unknown> | null | undefined, body: Record<string, unknown>): string | undefined;
|
|
917
930
|
declare function readTurnStartedAt(threadId: string, turnId: string): Promise<number | null>;
|
|
931
|
+
interface AdmittedQueuedMessagePromotion {
|
|
932
|
+
id: string;
|
|
933
|
+
text: string;
|
|
934
|
+
attachments?: unknown[];
|
|
935
|
+
requestAttachments?: Record<string, unknown>[];
|
|
936
|
+
references?: AgentSubmissionReference[];
|
|
937
|
+
metadata?: Record<string, unknown>;
|
|
938
|
+
options?: AgentRunOptions;
|
|
939
|
+
}
|
|
940
|
+
/** @internal exported for unit tests only */
|
|
941
|
+
export declare function readAdmittedQueuedMessagePromotion(opts: {
|
|
942
|
+
ownerEmail: string | null;
|
|
943
|
+
orgId: string | null;
|
|
944
|
+
threadId?: string;
|
|
945
|
+
messageId: unknown;
|
|
946
|
+
claimId: unknown;
|
|
947
|
+
message: string;
|
|
948
|
+
continuationRequested: boolean;
|
|
949
|
+
}): Promise<AdmittedQueuedMessagePromotion | null>;
|
|
918
950
|
/** @internal exported for unit tests only */
|
|
919
951
|
export declare function queuedPromotionAttachments(attachments: unknown[], requestAttachments?: Record<string, unknown>[]): AgentChatAttachment[];
|
|
920
952
|
declare function emitRunText(run: ActiveRun, text: string): Promise<void>;
|
|
@@ -933,6 +965,7 @@ export interface ChainServerDrivenContinuationDeps {
|
|
|
933
965
|
setRunError?: typeof setRunError;
|
|
934
966
|
recordRunDiagnostic?: typeof recordRunDiagnostic;
|
|
935
967
|
markBackgroundContinuationChunkTerminal?: typeof markBackgroundContinuationChunkTerminal;
|
|
968
|
+
isRunAborted?: typeof isRunAborted;
|
|
936
969
|
generateRunId?: typeof generateRunId;
|
|
937
970
|
sleep?: (ms: number) => Promise<void>;
|
|
938
971
|
}
|