@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
|
@@ -81,53 +81,56 @@ function runtimeAttachmentFromFilePart(part) {
|
|
|
81
81
|
function runtimeRequestAttachments(args) {
|
|
82
82
|
const attachments = args.message?.parts.flatMap((part) => part.type === "file" ? [runtimeAttachmentFromFilePart(part)] : []) ?? [];
|
|
83
83
|
for (const requestAttachment of args.requestAttachments ?? []) {
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
84
|
+
const referenceUrl = requestAttachment.referenceUrl;
|
|
85
|
+
const originalUrl = referenceUrl;
|
|
86
|
+
const originalLookupUrl = originalUrl ?? requestAttachment.url;
|
|
87
|
+
const originalIndex = originalLookupUrl
|
|
88
|
+
? attachments.findIndex((attachment) => attachment.url === originalLookupUrl)
|
|
87
89
|
: -1;
|
|
90
|
+
const addReferenceOnly = (replaceOriginal) => {
|
|
91
|
+
const original = originalIndex >= 0 ? attachments[originalIndex] : null;
|
|
92
|
+
const reference = {
|
|
93
|
+
type: "file",
|
|
94
|
+
name: original?.name || requestAttachment.name,
|
|
95
|
+
contentType: original?.contentType || requestAttachment.contentType,
|
|
96
|
+
...(original?.id ? { id: original.id } : {}),
|
|
97
|
+
...(original?.mediaType ? { mediaType: original.mediaType } : {}),
|
|
98
|
+
url: originalLookupUrl,
|
|
99
|
+
referenceOnly: true,
|
|
100
|
+
};
|
|
101
|
+
if (replaceOriginal && originalIndex >= 0) {
|
|
102
|
+
attachments.splice(originalIndex, 1, reference);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
attachments.push(reference);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
88
108
|
if (typeof requestAttachment.data === "string") {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
109
|
+
// The image's identity is exactly what the client fingerprinted: its own
|
|
110
|
+
// url, never one derived from referenceUrl. An original file part is kept
|
|
111
|
+
// as a reference (even when the image shares its url), so the submitted
|
|
112
|
+
// file fingerprint still matches the mapped attachments.
|
|
113
|
+
const imageUrl = requestAttachment.url;
|
|
114
|
+
const keepsOriginalReference = originalIndex >= 0 ||
|
|
115
|
+
(originalUrl !== undefined &&
|
|
116
|
+
imageUrl !== undefined &&
|
|
117
|
+
originalUrl !== imageUrl);
|
|
93
118
|
if (keepsOriginalReference) {
|
|
94
|
-
|
|
95
|
-
const reference = {
|
|
96
|
-
type: "file",
|
|
97
|
-
name: original?.name || requestAttachment.name,
|
|
98
|
-
contentType: original?.contentType || requestAttachment.contentType,
|
|
99
|
-
url: originalUrl,
|
|
100
|
-
referenceOnly: true,
|
|
101
|
-
};
|
|
102
|
-
if (originalIndex >= 0)
|
|
103
|
-
attachments.splice(originalIndex, 1, reference);
|
|
104
|
-
else
|
|
105
|
-
attachments.push(reference);
|
|
119
|
+
addReferenceOnly(originalIndex >= 0);
|
|
106
120
|
}
|
|
107
|
-
|
|
121
|
+
attachments.push({
|
|
108
122
|
type: "image",
|
|
109
123
|
name: requestAttachment.name,
|
|
110
124
|
contentType: requestAttachment.contentType,
|
|
111
125
|
data: requestAttachment.data,
|
|
112
126
|
...(imageUrl ? { url: imageUrl } : {}),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
attachments.splice(originalIndex, 1, image);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
attachments.push(image);
|
|
119
|
-
}
|
|
127
|
+
...(referenceUrl ? { referenceUrl } : {}),
|
|
128
|
+
});
|
|
120
129
|
continue;
|
|
121
130
|
}
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
type: "file",
|
|
126
|
-
name: original.name || requestAttachment.name,
|
|
127
|
-
contentType: original.contentType,
|
|
128
|
-
url: originalUrl,
|
|
129
|
-
referenceOnly: true,
|
|
130
|
-
});
|
|
131
|
+
if (originalUrl &&
|
|
132
|
+
(originalIndex < 0 || requestAttachment.url !== originalUrl)) {
|
|
133
|
+
addReferenceOnly(originalIndex >= 0);
|
|
131
134
|
}
|
|
132
135
|
if (typeof requestAttachment.url === "string") {
|
|
133
136
|
attachments.push({
|
|
@@ -135,6 +138,7 @@ function runtimeRequestAttachments(args) {
|
|
|
135
138
|
name: requestAttachment.name,
|
|
136
139
|
contentType: requestAttachment.contentType,
|
|
137
140
|
url: requestAttachment.url,
|
|
141
|
+
...(referenceUrl ? { referenceUrl } : {}),
|
|
138
142
|
});
|
|
139
143
|
}
|
|
140
144
|
}
|
|
@@ -189,6 +193,17 @@ function mergeProtocolMetadata(...sources) {
|
|
|
189
193
|
}
|
|
190
194
|
return merged;
|
|
191
195
|
}
|
|
196
|
+
function withQueuedMessageIdMetadata(metadata, messageId) {
|
|
197
|
+
if (messageId === undefined)
|
|
198
|
+
return metadata;
|
|
199
|
+
return {
|
|
200
|
+
...metadata,
|
|
201
|
+
custom: {
|
|
202
|
+
...asRecord(metadata?.custom),
|
|
203
|
+
agentNativeQueuedMessageId: messageId,
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
}
|
|
192
207
|
const PROTECTED_PROTOCOL_METADATA_KEYS = [
|
|
193
208
|
"actor",
|
|
194
209
|
"workspace",
|
|
@@ -1504,7 +1519,7 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1504
1519
|
*/
|
|
1505
1520
|
async function openStartedRun(threadId, session, turn, turnMetadata, observability, start = {}) {
|
|
1506
1521
|
const runId = turn.runId ?? turn.id ?? createId("run");
|
|
1507
|
-
const runMetadata = mergeTrustedProtocolMetadata(options.metadata, turnMetadata, turn.metadata, {
|
|
1522
|
+
const runMetadata = withQueuedMessageIdMetadata(mergeTrustedProtocolMetadata(options.metadata, turnMetadata, turn.metadata, {
|
|
1508
1523
|
[AGENT_NATIVE_PROTOCOL_METADATA_KEY]: {
|
|
1509
1524
|
observability: {
|
|
1510
1525
|
protocolRunId: runId,
|
|
@@ -1516,7 +1531,7 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
1516
1531
|
...observability,
|
|
1517
1532
|
},
|
|
1518
1533
|
},
|
|
1519
|
-
});
|
|
1534
|
+
}), start.queuedMessageId);
|
|
1520
1535
|
setRuntimeRunIdMetadata(runMetadata, turn.runId);
|
|
1521
1536
|
setRuntimeTurnIdMetadata(runMetadata, turn.id);
|
|
1522
1537
|
const run = {
|
|
@@ -3127,7 +3142,11 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
3127
3142
|
const latestUserMetadata = asRecord(latestUserMessage?.metadata);
|
|
3128
3143
|
const recoveryMetadata = asRecord(latestUserMetadata?.custom);
|
|
3129
3144
|
const isRecoveryRetry = recoveryMetadata?.agentNativeRecoveryAction === "retry";
|
|
3130
|
-
const turnMetadata = mergeTrustedProtocolMetadata(options.metadata, input.metadata, input.options?.metadata, input.options?.agentId
|
|
3145
|
+
const turnMetadata = withQueuedMessageIdMetadata(mergeTrustedProtocolMetadata(options.metadata, input.metadata, input.options?.metadata, input.options?.agentId
|
|
3146
|
+
? { agentId: input.options.agentId }
|
|
3147
|
+
: undefined, input.options?.locale ? { locale: input.options.locale } : undefined, input.options?.mode ? { mode: input.options.mode } : undefined, isRecoveryRetry
|
|
3148
|
+
? { agentNativeInternalContinuation: true }
|
|
3149
|
+
: undefined), input.queuePromotion?.messageId);
|
|
3131
3150
|
const queuePromotionKey = input.queuePromotion
|
|
3132
3151
|
? JSON.stringify([input.threadId, input.queuePromotion.turnId])
|
|
3133
3152
|
: undefined;
|
|
@@ -3153,9 +3172,11 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
3153
3172
|
const turn = await session.startTurn({
|
|
3154
3173
|
prompt: latestUserPrompt(input.messages),
|
|
3155
3174
|
messages,
|
|
3175
|
+
...(input.options ? { options: input.options } : {}),
|
|
3156
3176
|
...(input.submissionPayload
|
|
3157
3177
|
? { submissionPayload: input.submissionPayload }
|
|
3158
3178
|
: {}),
|
|
3179
|
+
...(input.references?.length ? { references: input.references } : {}),
|
|
3159
3180
|
...(input.queuePromotion
|
|
3160
3181
|
? { queuePromotion: input.queuePromotion }
|
|
3161
3182
|
: {}),
|
|
@@ -3174,15 +3195,29 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
3174
3195
|
metadata: turnMetadata,
|
|
3175
3196
|
abortSignal: readers.signal,
|
|
3176
3197
|
});
|
|
3198
|
+
if (turn.queuedSubmission)
|
|
3199
|
+
return turn.queuedSubmission;
|
|
3177
3200
|
return openStartedRun(input.threadId, session, turn, turnMetadata, undefined, {
|
|
3178
3201
|
attachReplayedRun: true,
|
|
3179
3202
|
messageId: latestUserMessage?.id,
|
|
3203
|
+
...(input.queuePromotion
|
|
3204
|
+
? { queuedMessageId: input.queuePromotion.messageId }
|
|
3205
|
+
: {}),
|
|
3180
3206
|
});
|
|
3181
3207
|
};
|
|
3182
3208
|
if (!queuePromotionKey) {
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3209
|
+
const started = await createRun();
|
|
3210
|
+
return typeof started === "string"
|
|
3211
|
+
? { runId: started, capabilities }
|
|
3212
|
+
: { queuedSubmission: started, capabilities };
|
|
3213
|
+
}
|
|
3214
|
+
const pendingRun = Promise.resolve().then(async () => {
|
|
3215
|
+
const started = await createRun();
|
|
3216
|
+
if (typeof started !== "string") {
|
|
3217
|
+
throw new TypeError("A queue promotion cannot be acknowledged as a new queued submission.");
|
|
3218
|
+
}
|
|
3219
|
+
return started;
|
|
3220
|
+
});
|
|
3186
3221
|
pendingQueuePromotionRuns.set(queuePromotionKey, pendingRun);
|
|
3187
3222
|
try {
|
|
3188
3223
|
return { runId: await pendingRun, capabilities };
|
|
@@ -3806,6 +3841,9 @@ export function createAgentKitProtocolAdapter(runtime, options = {}) {
|
|
|
3806
3841
|
transport.cancelUpload = hostOperations.cancelUpload;
|
|
3807
3842
|
if (hostOperations?.listQueuedMessages)
|
|
3808
3843
|
transport.listQueuedMessages = hostOperations.listQueuedMessages;
|
|
3844
|
+
if (hostOperations?.getQueuedSubmissionStatus)
|
|
3845
|
+
transport.getQueuedSubmissionStatus =
|
|
3846
|
+
hostOperations.getQueuedSubmissionStatus;
|
|
3809
3847
|
if (hostOperations?.queueMessage) {
|
|
3810
3848
|
transport.queueMessage = (input, context) => {
|
|
3811
3849
|
const metadata = mergeTrustedProtocolMetadata(options.metadata, input.metadata);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentRunOptions, type AgentSubmissionReference, type AgentQueuedSubmissionReceipt, type AgentSuggestion } from "@agent-native/agentkit/protocol";
|
|
2
2
|
import type { ActionChatUIConfig } from "../../action-ui.js";
|
|
3
3
|
import type { AgentMcpAppPayload } from "../../mcp-client/app-result.js";
|
|
4
4
|
import type { ReasoningEffort } from "../../shared/reasoning-effort.js";
|
|
@@ -89,6 +89,7 @@ export interface AgentChatRuntimeAttachment {
|
|
|
89
89
|
readonly contentType?: string;
|
|
90
90
|
readonly data?: string;
|
|
91
91
|
readonly url?: string;
|
|
92
|
+
readonly referenceUrl?: string;
|
|
92
93
|
readonly text?: string;
|
|
93
94
|
readonly metadata?: AgentChatRuntimeMetadata;
|
|
94
95
|
}
|
|
@@ -218,6 +219,8 @@ export interface AgentChatRuntimeTurnInput {
|
|
|
218
219
|
readonly prompt?: string;
|
|
219
220
|
readonly messages?: readonly AgentChatRuntimeMessage[];
|
|
220
221
|
readonly submissionPayload?: unknown;
|
|
222
|
+
readonly options?: AgentRunOptions;
|
|
223
|
+
readonly references?: readonly AgentSubmissionReference[];
|
|
221
224
|
readonly queuePromotion?: {
|
|
222
225
|
readonly messageId: string;
|
|
223
226
|
readonly claimId: string;
|
|
@@ -549,6 +552,7 @@ export interface AgentChatRuntimeTurn<TEvent extends AgentChatRuntimeEventBase =
|
|
|
549
552
|
readonly sessionId: AgentChatRuntimeSessionId;
|
|
550
553
|
readonly runId?: string;
|
|
551
554
|
readonly metadata?: AgentChatRuntimeMetadata;
|
|
555
|
+
readonly queuedSubmission?: AgentQueuedSubmissionReceipt;
|
|
552
556
|
readonly events: AsyncIterable<TEvent>;
|
|
553
557
|
/** Close the local event stream without cancelling the underlying run. */
|
|
554
558
|
closeEvents?(): Promise<void> | void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AgentKitRunSlotBusyError } from "@agent-native/agentkit/client";
|
|
2
|
+
import { parseAgentQueuedSubmissionReceipt, } from "@agent-native/agentkit/protocol";
|
|
2
3
|
import { AUTO_CONTINUE_OF_RUN_METADATA_KEY, CONTINUE_OF_RUN_METADATA_KEY, } from "../../agent/auto-continue.js";
|
|
3
4
|
import { RUN_NOT_STARTED_METADATA_KEY } from "../../shared/agent-chat-run-not-started.js";
|
|
4
5
|
import { agentEngineStatusUrlForChatApi, requireAgentEngineConfiguredForDispatch, } from "../agent-engine-readiness.js";
|
|
@@ -261,6 +262,8 @@ function defaultHttpRuntimeRequest(input) {
|
|
|
261
262
|
messages: input.turn.messages,
|
|
262
263
|
attachments: input.turn.attachments,
|
|
263
264
|
submissionPayload: input.turn.submissionPayload,
|
|
265
|
+
options: input.turn.options,
|
|
266
|
+
references: input.turn.references,
|
|
264
267
|
tools: input.turn.tools,
|
|
265
268
|
model: input.turn.model,
|
|
266
269
|
reasoningEffort: input.turn.reasoningEffort,
|
|
@@ -476,6 +479,43 @@ export function createHttpAgentChatRuntime(options) {
|
|
|
476
479
|
}
|
|
477
480
|
throw withTurnId(error, turnId);
|
|
478
481
|
}
|
|
482
|
+
if (response.status === 202) {
|
|
483
|
+
let queuedSubmission;
|
|
484
|
+
try {
|
|
485
|
+
if (!response.headers
|
|
486
|
+
.get("Content-Type")
|
|
487
|
+
?.toLowerCase()
|
|
488
|
+
.includes("application/json")) {
|
|
489
|
+
throw new TypeError("Expected a JSON queued submission receipt.");
|
|
490
|
+
}
|
|
491
|
+
queuedSubmission = parseAgentQueuedSubmissionReceipt(await response.json());
|
|
492
|
+
const submission = asRecord(turn.submissionPayload);
|
|
493
|
+
const expectedThreadId = summary.threadId ?? sessionId;
|
|
494
|
+
if (queuedSubmission.message.threadId !== expectedThreadId ||
|
|
495
|
+
(typeof submission?.id === "string" &&
|
|
496
|
+
queuedSubmission.message.id !== submission.id)) {
|
|
497
|
+
throw new TypeError("The queued submission receipt does not match this session turn.");
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
catch (cause) {
|
|
501
|
+
cleanup();
|
|
502
|
+
throw withTurnId(Object.assign(new Error(cause instanceof Error
|
|
503
|
+
? `Invalid queued submission response: ${cause.message}`
|
|
504
|
+
: "Invalid queued submission response.", { cause }), {
|
|
505
|
+
code: "invalid_queued_submission_response",
|
|
506
|
+
status: response.status,
|
|
507
|
+
retryable: true,
|
|
508
|
+
}), turnId);
|
|
509
|
+
}
|
|
510
|
+
cleanup();
|
|
511
|
+
forgetTurnContext(turnId, turn);
|
|
512
|
+
return {
|
|
513
|
+
id: turnId,
|
|
514
|
+
sessionId,
|
|
515
|
+
queuedSubmission,
|
|
516
|
+
events: (async function* () { })(),
|
|
517
|
+
};
|
|
518
|
+
}
|
|
479
519
|
const runId = response.headers.get("X-Run-Id") ?? undefined;
|
|
480
520
|
const events = (async function* () {
|
|
481
521
|
let retryableFailure = false;
|
|
@@ -3230,6 +3270,8 @@ export function createAgentNativeChatRuntime(options = {}) {
|
|
|
3230
3270
|
...(turn.submissionPayload !== undefined
|
|
3231
3271
|
? { submissionPayload: turn.submissionPayload }
|
|
3232
3272
|
: {}),
|
|
3273
|
+
...(turn.references?.length ? { references: turn.references } : {}),
|
|
3274
|
+
...(turn.options ? { options: turn.options } : {}),
|
|
3233
3275
|
...(turn.queuePromotion
|
|
3234
3276
|
? {
|
|
3235
3277
|
queuedMessageId: turn.queuePromotion.messageId,
|
|
@@ -3298,6 +3340,7 @@ export function createAgentNativeChatRuntime(options = {}) {
|
|
|
3298
3340
|
const turnToContinue = continuation.attachments?.length
|
|
3299
3341
|
? { ...previousTurn, attachments: continuation.attachments }
|
|
3300
3342
|
: previousTurn;
|
|
3343
|
+
const { submissionPayload: _submissionPayload, ...continuationTurn } = turnToContinue ?? {};
|
|
3301
3344
|
const approval = continuation.approval;
|
|
3302
3345
|
const connection = continuation.connection;
|
|
3303
3346
|
const messageStateKey = continuation.turnId ?? session.id;
|
|
@@ -3314,7 +3357,7 @@ export function createAgentNativeChatRuntime(options = {}) {
|
|
|
3314
3357
|
if (messageState)
|
|
3315
3358
|
messageState.message.connectionPending = false;
|
|
3316
3359
|
return startTurn({
|
|
3317
|
-
...
|
|
3360
|
+
...continuationTurn,
|
|
3318
3361
|
prompt: continuation.prompt ??
|
|
3319
3362
|
`The ${connection.id} connection is now available. Continue the requested work.`,
|
|
3320
3363
|
metadata: {
|
|
@@ -3334,7 +3377,7 @@ export function createAgentNativeChatRuntime(options = {}) {
|
|
|
3334
3377
|
if (messageState)
|
|
3335
3378
|
messageState.message.approvalPending = false;
|
|
3336
3379
|
return startTurn({
|
|
3337
|
-
...
|
|
3380
|
+
...continuationTurn,
|
|
3338
3381
|
prompt: continuation.prompt,
|
|
3339
3382
|
metadata: {
|
|
3340
3383
|
...previousMetadata,
|
|
@@ -3376,7 +3419,7 @@ export function createAgentNativeChatRuntime(options = {}) {
|
|
|
3376
3419
|
if (messageState)
|
|
3377
3420
|
messageState.message.approvalPending = false;
|
|
3378
3421
|
return startTurn({
|
|
3379
|
-
...
|
|
3422
|
+
...continuationTurn,
|
|
3380
3423
|
prompt: continuation.prompt ??
|
|
3381
3424
|
"Approved. Go ahead and run the requested action.",
|
|
3382
3425
|
metadata: {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ConsentCategory, type ConsentChoice, type ConsentRegion } from "../shared/consent.js";
|
|
2
|
+
export type { ConsentCategory, ConsentChoice, ConsentRegion };
|
|
3
|
+
/** The visitor's stored choice, or `null` before they've made one. */
|
|
4
|
+
export declare function getConsentChoice(): ConsentChoice | null;
|
|
5
|
+
/**
|
|
6
|
+
* Whether this visitor gets the banner: the server's answer from the
|
|
7
|
+
* request's country, else the browser's time zone. Asked once a session.
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveConsentRegion(): Promise<ConsentRegion>;
|
|
10
|
+
/**
|
|
11
|
+
* Whether `category` is allowed right now, on the time zone's guess until the
|
|
12
|
+
* server answers. Pair it with `whenConsentAllows` and a `revoke` that undoes
|
|
13
|
+
* whatever this let through.
|
|
14
|
+
*/
|
|
15
|
+
export declare function consentAllowsNow(category: ConsentCategory): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether `category` is allowed, from the visitor's choice or the server's
|
|
18
|
+
* region; `null` until one of them is known, where `consentAllowsNow` would
|
|
19
|
+
* guess from the time zone. For what `revoke` can't undo once it's sent.
|
|
20
|
+
*/
|
|
21
|
+
export declare function consentDecision(category: ConsentCategory): boolean | null;
|
|
22
|
+
export interface WhenConsentAllowsOptions {
|
|
23
|
+
/**
|
|
24
|
+
* Run now on the time zone's guess instead of waiting for the server, and
|
|
25
|
+
* call `revoke` if the server or the visitor then says no. Only for storage
|
|
26
|
+
* `revoke` can fully undo; a third-party script can't be unloaded.
|
|
27
|
+
*/
|
|
28
|
+
optimistic?: boolean;
|
|
29
|
+
revoke?: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Run `run` once `category` is allowed: at once outside the consent region,
|
|
33
|
+
* and inside it when the visitor accepts. A later "reject" calls `revoke`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function whenConsentAllows(category: ConsentCategory, run: () => void, options?: WhenConsentAllowsOptions): void;
|
|
36
|
+
/**
|
|
37
|
+
* Run `send` once the visitor's choice or the server's region is known, so
|
|
38
|
+
* the time zone's guess never sends what consent covers. `decided` is false
|
|
39
|
+
* when the page closes first; send then without what consent covers.
|
|
40
|
+
*/
|
|
41
|
+
export declare function whenConsentDecided(send: (decided: boolean) => void): void;
|
|
42
|
+
/** Store the visitor's choice for every app on this site, and apply it. */
|
|
43
|
+
export declare function setConsentChoice(choice: ConsentChoice): void;
|
|
44
|
+
/** Reopen the banner so the visitor can change their choice. */
|
|
45
|
+
export declare function openConsentSettings(): void;
|
|
46
|
+
/** Whether the banner should show now, for the banner component. */
|
|
47
|
+
export declare function shouldShowConsentBanner(): boolean;
|
|
48
|
+
export declare function subscribeConsent(listener: () => void): () => void;
|