@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
|
@@ -1329,6 +1329,22 @@ export function claimQueuedMessage(repo, messageId) {
|
|
|
1329
1329
|
normalized[CLAIMED_QUEUED_MESSAGE_IDS_KEY] = [...claimed, messageId].slice(-MAX_CLAIMED_QUEUED_MESSAGE_IDS);
|
|
1330
1330
|
return pruneClaimedQueuedMessages(normalized);
|
|
1331
1331
|
}
|
|
1332
|
+
function reconcileDirectSubmissionQueue(repo, userCustom) {
|
|
1333
|
+
if (!userCustom ||
|
|
1334
|
+
typeof userCustom !== "object" ||
|
|
1335
|
+
Array.isArray(userCustom)) {
|
|
1336
|
+
return repo;
|
|
1337
|
+
}
|
|
1338
|
+
const messageId = userCustom.agentKitMessageId;
|
|
1339
|
+
if (typeof messageId !== "string" ||
|
|
1340
|
+
!Array.isArray(repo?.queuedMessages) ||
|
|
1341
|
+
!repo.queuedMessages.some((message) => message &&
|
|
1342
|
+
typeof message === "object" &&
|
|
1343
|
+
message.id === messageId)) {
|
|
1344
|
+
return repo;
|
|
1345
|
+
}
|
|
1346
|
+
return claimQueuedMessage(repo, messageId);
|
|
1347
|
+
}
|
|
1332
1348
|
export function applySubmittedUserMessage(repo, userMessage, queuedMessage) {
|
|
1333
1349
|
const userCustom = userMessage.metadata.custom;
|
|
1334
1350
|
const wasSubmitted = queuedMessage && Array.isArray(repo?.messages)
|
|
@@ -1370,7 +1386,10 @@ export function applySubmittedUserMessage(repo, userMessage, queuedMessage) {
|
|
|
1370
1386
|
custom.submittedRunId === submittedRunId);
|
|
1371
1387
|
});
|
|
1372
1388
|
if (wasDirectlySubmitted) {
|
|
1373
|
-
return {
|
|
1389
|
+
return {
|
|
1390
|
+
status: "already_submitted",
|
|
1391
|
+
repo: reconcileDirectSubmissionQueue(repo, userCustom),
|
|
1392
|
+
};
|
|
1374
1393
|
}
|
|
1375
1394
|
if (userCustom &&
|
|
1376
1395
|
Object.prototype.hasOwnProperty.call(userCustom, AGENT_NATIVE_SUBMISSION_EXPIRES_AT_METADATA_KEY)) {
|
|
@@ -1382,7 +1401,10 @@ export function applySubmittedUserMessage(repo, userMessage, queuedMessage) {
|
|
|
1382
1401
|
}
|
|
1383
1402
|
}
|
|
1384
1403
|
if (!queuedMessage) {
|
|
1385
|
-
return {
|
|
1404
|
+
return {
|
|
1405
|
+
status: "submitted",
|
|
1406
|
+
repo: upsertUserMessage(reconcileDirectSubmissionQueue(repo, userCustom), userMessage),
|
|
1407
|
+
};
|
|
1386
1408
|
}
|
|
1387
1409
|
if (hasClaimedQueuedMessage(repo, queuedMessage.id)) {
|
|
1388
1410
|
return { status: "already_claimed" };
|
|
@@ -2978,9 +3000,9 @@ export function mergeThreadDataForClientSave(existingRepo, incomingRepo, options
|
|
|
2978
3000
|
}
|
|
2979
3001
|
}
|
|
2980
3002
|
}
|
|
2981
|
-
// Queue mutations
|
|
2982
|
-
//
|
|
2983
|
-
// a promotion claim or an append that landed in between.
|
|
3003
|
+
// Queue mutations own the queue; a submitted-message marker can remove its
|
|
3004
|
+
// matching row. Other saves carry a queue they read earlier, and letting
|
|
3005
|
+
// that copy win drops a promotion claim or an append that landed in between.
|
|
2984
3006
|
if (preserveExistingQueuedMessages) {
|
|
2985
3007
|
if (existingNormalized?.queuedMessages !== undefined) {
|
|
2986
3008
|
merged.queuedMessages = existingNormalized.queuedMessages;
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentSubmissionPayload, AgentSuggestion } from "@agent-native/agentkit/protocol";
|
|
1
|
+
import type { AgentSubmissionReference, AgentSubmissionPayload, AgentRunOptions, AgentSuggestion } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import type { A2AAgentActivitySnapshot } from "../a2a/activity.js";
|
|
3
3
|
import type { ActionChatUIConfig } from "../action-ui.js";
|
|
4
4
|
import type { WriteReceipt } from "../action.js";
|
|
@@ -84,17 +84,7 @@ export interface AgentChatStructuredMessage {
|
|
|
84
84
|
role: "user" | "assistant";
|
|
85
85
|
content: AgentChatStructuredContentPart[];
|
|
86
86
|
}
|
|
87
|
-
export
|
|
88
|
-
type: "file" | "skill" | "mention" | "agent" | "custom-agent";
|
|
89
|
-
path: string;
|
|
90
|
-
name: string;
|
|
91
|
-
source: string;
|
|
92
|
-
refType?: string;
|
|
93
|
-
refId?: string;
|
|
94
|
-
slotKey?: string;
|
|
95
|
-
slotLabel?: string;
|
|
96
|
-
metadata?: Record<string, unknown>;
|
|
97
|
-
}
|
|
87
|
+
export type AgentChatReference = AgentSubmissionReference;
|
|
98
88
|
export type MentionItemMedia = {
|
|
99
89
|
type: "text";
|
|
100
90
|
text: string;
|
|
@@ -144,6 +134,8 @@ export interface MentionProvider {
|
|
|
144
134
|
export interface AgentChatAttachment {
|
|
145
135
|
type: string;
|
|
146
136
|
name: string;
|
|
137
|
+
id?: string;
|
|
138
|
+
mediaType?: string;
|
|
147
139
|
displayOnly?: boolean;
|
|
148
140
|
data?: string;
|
|
149
141
|
url?: string;
|
|
@@ -153,6 +145,7 @@ export interface AgentChatAttachment {
|
|
|
153
145
|
storageRequired?: boolean;
|
|
154
146
|
storageUploadFailed?: boolean;
|
|
155
147
|
contentType?: string;
|
|
148
|
+
referenceUrl?: string;
|
|
156
149
|
text?: string;
|
|
157
150
|
}
|
|
158
151
|
export interface AgentChatScope {
|
|
@@ -169,6 +162,7 @@ export interface AgentChatRequest {
|
|
|
169
162
|
agentKitMessageId?: string;
|
|
170
163
|
/** Original queue-shaped submit used for idempotent direct/queued admission. */
|
|
171
164
|
submissionPayload?: AgentSubmissionPayload;
|
|
165
|
+
options?: AgentRunOptions;
|
|
172
166
|
actionScope?: AgentActionScope;
|
|
173
167
|
queuedMessageId?: string;
|
|
174
168
|
queuedMessageClaimId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CredentialContext } from "../credentials/index.js";
|
|
2
|
-
export type AgentKitCapabilityAppId = "design" | "slides";
|
|
2
|
+
export type AgentKitCapabilityAppId = "design" | "slides" | "slides-2";
|
|
3
3
|
export interface AgentKitIntegrationCapability {
|
|
4
4
|
id: string;
|
|
5
5
|
label: string;
|
|
@@ -32,6 +32,6 @@ export const analyticsConfig = z.object({
|
|
|
32
32
|
.optional()
|
|
33
33
|
.meta({
|
|
34
34
|
env: "AGENT_NATIVE_HEAD_SCRIPT_SRC",
|
|
35
|
-
doc: "HTTPS URL of a script
|
|
35
|
+
doc: "HTTPS URL of a script added to every server-rendered page, for deployment-specific tooling such as support or feedback widgets. Where the consent banner shows, it waits for analytics consent, like Google Analytics.",
|
|
36
36
|
}),
|
|
37
37
|
});
|
|
@@ -25,4 +25,9 @@ export declare function appStateListByKeyPrefix(keyPrefix: string, limit?: numbe
|
|
|
25
25
|
key: string;
|
|
26
26
|
value: Record<string, unknown>;
|
|
27
27
|
}>>;
|
|
28
|
+
/** Lists metadata for maintenance keys within the current app namespace. */
|
|
29
|
+
export declare function appStateListKeysByKeySuffixPrefix(suffixPrefix: string, limit?: number): Promise<Array<{
|
|
30
|
+
sessionId: string;
|
|
31
|
+
key: string;
|
|
32
|
+
}>>;
|
|
28
33
|
export declare function appStateDeleteByPrefix(sessionId: string, keyPrefix: string, options?: StoreWriteOptions): Promise<number>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAppConfig } from "../app-config/index.js";
|
|
1
2
|
import { getDbExec, isLocalDatabase } from "../db/client.js";
|
|
2
3
|
import { ensureIndexExists, ensureTableExists } from "../db/ddl-guard.js";
|
|
3
4
|
import { defineStore } from "../db/store-registry.js";
|
|
@@ -227,6 +228,31 @@ export async function appStateListByKeyPrefix(keyPrefix, limit = 100) {
|
|
|
227
228
|
value: JSON.parse(row.value),
|
|
228
229
|
}));
|
|
229
230
|
}
|
|
231
|
+
/** Lists metadata for maintenance keys within the current app namespace. */
|
|
232
|
+
export async function appStateListKeysByKeySuffixPrefix(suffixPrefix, limit = 100) {
|
|
233
|
+
if (!suffixPrefix || suffixPrefix.startsWith(":")) {
|
|
234
|
+
throw new Error("Cross-session application-state scans require a non-empty key suffix prefix.");
|
|
235
|
+
}
|
|
236
|
+
const keyPrefix = `${getAppStateMaintenanceNamespacePrefix()}${suffixPrefix}`;
|
|
237
|
+
await ensureTable();
|
|
238
|
+
const client = getDbExec();
|
|
239
|
+
const boundedLimit = Math.max(1, Math.min(Math.floor(limit), 2_048));
|
|
240
|
+
const { rows } = await client.execute({
|
|
241
|
+
sql: `SELECT session_id, key FROM application_state WHERE key LIKE ? ESCAPE '!' ORDER BY updated_at ASC LIMIT ?`,
|
|
242
|
+
args: [escapeLike(keyPrefix) + "%", boundedLimit],
|
|
243
|
+
});
|
|
244
|
+
return rows.map((row) => ({
|
|
245
|
+
sessionId: row.session_id,
|
|
246
|
+
key: row.key,
|
|
247
|
+
}));
|
|
248
|
+
}
|
|
249
|
+
function getAppStateMaintenanceNamespacePrefix() {
|
|
250
|
+
const namespace = getAppConfig().app.slug;
|
|
251
|
+
if (!namespace || namespace !== namespace.trim() || namespace.includes(":")) {
|
|
252
|
+
throw new Error("Application-state maintenance requires a configured app namespace.");
|
|
253
|
+
}
|
|
254
|
+
return `${namespace}:`;
|
|
255
|
+
}
|
|
230
256
|
export async function appStateDeleteByPrefix(sessionId, keyPrefix, options) {
|
|
231
257
|
await ensureTable();
|
|
232
258
|
const client = getDbExec();
|
|
@@ -139,8 +139,8 @@ export declare function createAutomationCallbackHandler(runtime: AutomationRunti
|
|
|
139
139
|
duplicate?: undefined;
|
|
140
140
|
eventId?: undefined;
|
|
141
141
|
} | {
|
|
142
|
-
error?: undefined;
|
|
143
142
|
accepted: boolean;
|
|
144
143
|
duplicate: boolean;
|
|
145
144
|
eventId: string;
|
|
145
|
+
error?: undefined;
|
|
146
146
|
}>;
|
|
@@ -109,4 +109,21 @@ export const CHAT_THREAD_SCHEMA_MIGRATIONS = [
|
|
|
109
109
|
ADD COLUMN IF NOT EXISTS interrupt_run_id TEXT
|
|
110
110
|
`,
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
version: 7,
|
|
114
|
+
name: "chat-thread-inbox-thread-order-index",
|
|
115
|
+
sql: `
|
|
116
|
+
CREATE INDEX IF NOT EXISTS agent_chat_submission_inbox_thread_pending_idx
|
|
117
|
+
ON agent_chat_submission_inbox (thread_id, interrupt_active_run DESC, move_to_top_at DESC, queue_order ASC)
|
|
118
|
+
WHERE state = 'queued'
|
|
119
|
+
`,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
version: 8,
|
|
123
|
+
name: "chat-thread-inbox-retry-count",
|
|
124
|
+
sql: `
|
|
125
|
+
ALTER TABLE agent_chat_submission_inbox
|
|
126
|
+
ADD COLUMN IF NOT EXISTS retry_count INTEGER NOT NULL DEFAULT 0
|
|
127
|
+
`,
|
|
128
|
+
},
|
|
112
129
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentSubmissionPayload, type AgentRunOptions } from "@agent-native/agentkit/protocol";
|
|
1
|
+
import { type AgentSubmissionReference, type AgentSubmissionPayload, type AgentRunOptions } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import { type ThreadAnnotationSnapshotConflict } from "../agent/thread-data-builder.js";
|
|
3
3
|
import { type DbExec } from "../db/client.js";
|
|
4
4
|
import { type AccessContext } from "../sharing/access.js";
|
|
@@ -124,6 +124,9 @@ export declare function ensureChatThreadTables(): Promise<void>;
|
|
|
124
124
|
*/
|
|
125
125
|
export declare function hasThreadAccess(userEmail: string | null | undefined, threadId: string | null | undefined, minRole?: ShareRole | "owner", ctx?: Omit<AccessContext, "userEmail">): Promise<boolean>;
|
|
126
126
|
export declare function resolveThreadAccess(userEmail: string | null | undefined, threadId: string | null | undefined, minRole?: ShareRole | "owner", ctx?: Omit<AccessContext, "userEmail">): Promise<ChatThread | null>;
|
|
127
|
+
export declare function resolveThreadAccessScope(userEmail: string | null | undefined, threadId: string | null | undefined, minRole?: ShareRole | "owner", ctx?: Omit<AccessContext, "userEmail">): Promise<{
|
|
128
|
+
scope: ChatThreadScope | null;
|
|
129
|
+
} | null>;
|
|
127
130
|
export declare function resolveThreadsAccess(userEmail: string | null | undefined, threadIds: readonly string[], ctx?: Pick<AccessContext, "orgId">): Promise<Map<string, ChatThread>>;
|
|
128
131
|
export declare function getThread(id: string): Promise<ChatThread | null>;
|
|
129
132
|
/**
|
|
@@ -259,6 +262,7 @@ export interface QueuedMessage {
|
|
|
259
262
|
createdAt?: string;
|
|
260
263
|
attachments?: unknown[];
|
|
261
264
|
requestAttachments?: unknown[];
|
|
265
|
+
references?: AgentSubmissionReference[];
|
|
262
266
|
metadata?: Record<string, unknown>;
|
|
263
267
|
options?: AgentRunOptions;
|
|
264
268
|
interruptActiveRun?: boolean;
|
|
@@ -287,6 +291,7 @@ export interface QueuedSubmissionReceipt {
|
|
|
287
291
|
submittedRunId?: string;
|
|
288
292
|
interruptRunId?: string;
|
|
289
293
|
retryAfter?: number;
|
|
294
|
+
retryCount: number;
|
|
290
295
|
createdAt: number;
|
|
291
296
|
updatedAt: number;
|
|
292
297
|
}
|
|
@@ -299,10 +304,18 @@ export declare function hashQueuedSubmissionPayload(threadId: string, message: Q
|
|
|
299
304
|
export declare function queuedSubmissionBehaviorMatches(threadId: string, message: QueuedMessage, identity: AgentSubmissionPayload): boolean;
|
|
300
305
|
/** Returns the durable admission receipt used to dedupe direct starts and queue retries. */
|
|
301
306
|
export declare function getQueuedSubmissionReceipt(threadId: string, messageId: string): Promise<QueuedSubmissionReceipt | null>;
|
|
307
|
+
export declare function getQueuedSubmissionReceiptStatus(threadId: string, messageId: string): Promise<{
|
|
308
|
+
state: QueuedSubmissionState;
|
|
309
|
+
submittedRunId?: string;
|
|
310
|
+
} | null>;
|
|
311
|
+
/** Checks the inbox inside a caller's transaction before a fresh run claims its slot. */
|
|
312
|
+
export declare function hasPendingQueuedSubmissionReceipt(tx: DbExec, threadId: string): Promise<boolean>;
|
|
302
313
|
/** Finds accepted queue rows in priority order for the signed server sweep. */
|
|
303
314
|
export declare function listQueuedSubmissionReceipts(options?: {
|
|
304
315
|
limit?: number;
|
|
305
316
|
now?: number;
|
|
317
|
+
threadId?: string;
|
|
318
|
+
interruptActiveRun?: boolean;
|
|
306
319
|
}): Promise<QueuedSubmissionReceipt[]>;
|
|
307
320
|
/** Records a run admission in the same transaction that persists its user message. */
|
|
308
321
|
export declare function markQueuedSubmissionSubmitted(tx: DbExec, input: {
|
|
@@ -316,6 +329,7 @@ export declare function markQueuedSubmissionSubmitted(tx: DbExec, input: {
|
|
|
316
329
|
/** Delays a retryable drain failure without releasing the accepted submission. */
|
|
317
330
|
export declare function retryQueuedSubmissionReceipt(threadId: string, messageId: string, retryAfter: number, options?: {
|
|
318
331
|
claimId?: string;
|
|
332
|
+
countRetry?: boolean;
|
|
319
333
|
}): Promise<boolean>;
|
|
320
334
|
/** Retains but stops automatically promoting a row that can no longer be authorized. */
|
|
321
335
|
export declare function blockQueuedSubmissionReceipt(threadId: string, messageId: string, options?: {
|
|
@@ -349,6 +363,9 @@ export type ThreadQueuedMessageMutation = {
|
|
|
349
363
|
} | {
|
|
350
364
|
type: "remove";
|
|
351
365
|
messageId: string;
|
|
366
|
+
} | {
|
|
367
|
+
type: "cancel";
|
|
368
|
+
messageId: string;
|
|
352
369
|
} | {
|
|
353
370
|
type: "moveToTop";
|
|
354
371
|
messageId: string;
|
|
@@ -365,6 +382,7 @@ export type ThreadQueuedMessageMutation = {
|
|
|
365
382
|
messageId: string;
|
|
366
383
|
retryAfter: number;
|
|
367
384
|
claimId?: string;
|
|
385
|
+
countRetry?: boolean;
|
|
368
386
|
} | {
|
|
369
387
|
type: "blockReceipt";
|
|
370
388
|
messageId: string;
|
|
@@ -393,7 +411,9 @@ export interface ThreadQueuedMessageMutationResult {
|
|
|
393
411
|
claimBusy?: boolean;
|
|
394
412
|
submissionExpired?: boolean;
|
|
395
413
|
promotionBusy?: boolean;
|
|
414
|
+
receiptManaged?: boolean;
|
|
396
415
|
receiptUnavailable?: boolean;
|
|
416
|
+
retryDeferred?: boolean;
|
|
397
417
|
receiptConflict?: boolean;
|
|
398
418
|
receiptUpdated?: boolean;
|
|
399
419
|
claimLost?: boolean;
|