@axhub/acp 0.1.0 → 0.1.2-beta.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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +4 -0
- package/.next/build-manifest.json +3 -3
- package/.next/fallback-build-manifest.json +3 -3
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/routes-manifest.json +28 -0
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/api/acp/capabilities/route.js +5 -3
- package/.next/server/app/api/acp/capabilities/route.js.nft.json +1 -1
- package/.next/server/app/api/acp/commands/route.js +1 -1
- package/.next/server/app/api/acp/commands/route.js.nft.json +1 -1
- package/.next/server/app/api/acp/runtime/route.js.nft.json +1 -1
- package/.next/server/app/api/chat/cancel/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/chat/cancel/route/build-manifest.json +9 -0
- package/.next/server/app/api/chat/cancel/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/chat/cancel/route.js +11 -0
- package/.next/server/app/api/chat/cancel/route.js.nft.json +1 -0
- package/.next/server/app/api/chat/cancel/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/chat/resume/[streamId]/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/chat/resume/[streamId]/route/build-manifest.json +9 -0
- package/.next/server/app/api/chat/resume/[streamId]/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/chat/resume/[streamId]/route.js +11 -0
- package/.next/server/app/api/chat/resume/[streamId]/route.js.nft.json +1 -0
- package/.next/server/app/api/chat/resume/[streamId]/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/chat/route.js +5 -3
- package/.next/server/app/api/chat/route.js.nft.json +1 -1
- package/.next/server/app/api/conversations/[threadId]/messages/route.js +4 -2
- package/.next/server/app/api/conversations/[threadId]/messages/route.js.nft.json +1 -1
- package/.next/server/app/api/conversations/[threadId]/route.js +2 -2
- package/.next/server/app/api/conversations/[threadId]/route.js.nft.json +1 -1
- package/.next/server/app/api/conversations/[threadId]/runtime/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/conversations/[threadId]/runtime/route/build-manifest.json +9 -0
- package/.next/server/app/api/conversations/[threadId]/runtime/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/conversations/[threadId]/runtime/route.js +11 -0
- package/.next/server/app/api/conversations/[threadId]/runtime/route.js.nft.json +1 -0
- package/.next/server/app/api/conversations/[threadId]/runtime/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/conversations/route.js +2 -2
- package/.next/server/app/api/conversations/route.js.nft.json +1 -1
- package/.next/server/app/api/local-files/image/route.js.nft.json +1 -1
- package/.next/server/app/api/local-files/open/route.js.nft.json +1 -1
- package/.next/server/app/api/output-artifacts/thread/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/output-artifacts/thread/route/build-manifest.json +9 -0
- package/.next/server/app/api/output-artifacts/thread/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/output-artifacts/thread/route.js +8 -0
- package/.next/server/app/api/output-artifacts/thread/route.js.nft.json +1 -0
- package/.next/server/app/api/output-artifacts/thread/route_client-reference-manifest.js +3 -0
- package/.next/server/app/api/output-artifacts/workspace/route.js +1 -1
- package/.next/server/app/api/output-artifacts/workspace/route.js.nft.json +1 -1
- package/.next/server/app/api/tools/image-generation/files/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/tools/image-generation/records/route.js.nft.json +1 -1
- package/.next/server/app/api/tools/user-choice/route.js.nft.json +1 -1
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/session/[provider]/[sessionId]/page.js +1 -1
- package/.next/server/app/session/[provider]/[sessionId]/page.js.nft.json +1 -1
- package/.next/server/app/session/[provider]/[sessionId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/thread/[threadId]/page.js +1 -1
- package/.next/server/app/thread/[threadId]/page.js.nft.json +1 -1
- package/.next/server/app/thread/[threadId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +4 -0
- package/.next/server/chunks/0zjb_server_app_api_conversations_[threadId]_runtime_route_actions_08lhdqs.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__04pn6ap._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0aovkxs._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0c.r6ru._.js +76 -0
- package/.next/server/chunks/[root-of-the-server]__0gmxr~m._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0iokgmz._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0j-lxr4._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0lbwo2g._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0ly6hop._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0ml.1wa._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0o2epta._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0os92l7._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0tmhg7j._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0txmfnw._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__0wo0b8z._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0xh8d4~._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0zmyki-._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__0zn3~pq._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__13xepwb._.js +3 -0
- package/.next/server/chunks/_0_9_730._.js +107 -0
- package/.next/server/chunks/_0gx~6n6._.js +107 -0
- package/.next/server/chunks/_next-internal_server_app_api_chat_cancel_route_actions_0hdg4o_.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_chat_resume_[streamId]_route_actions_12ynw6q.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_output-artifacts_thread_route_actions_04~2mo7.js +3 -0
- package/.next/server/chunks/lib_conversations_store_ts_0gzcj38._.js +4 -4
- package/.next/server/chunks/node_modules_0nyqhq8._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__0piffp7._.js → [root-of-the-server]__09wwymw._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__0488vn3._.js → [root-of-the-server]__0n6oe29._.js} +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__0icm-_h._.js → [root-of-the-server]__0niwg81._.js} +2 -2
- package/.next/server/chunks/ssr/_03.pm1z._.js +18 -16
- package/.next/server/chunks/ssr/_0txwi90._.js +1 -1
- package/.next/server/chunks/ssr/lib_conversations_store_ts_0-pd6d3._.js +2 -2
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_0ghu-f7.js +1 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_02suzhc.js +2 -2
- package/.next/server/functions-config-manifest.json +3 -0
- package/.next/server/instrumentation.js.nft.json +1 -1
- package/.next/server/middleware-build-manifest.js +3 -3
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/static/chunks/0c~b2_-vk17t5.css +1 -0
- package/.next/static/chunks/0r125n-._y5ny.js +104 -0
- package/README.md +2 -2
- package/bin/acp.mjs +0 -48
- package/dist/components/assistant-ui/acp-command-menu.mjs +42 -9
- package/dist/components/assistant-ui/acp-elicitation-option-list.mjs +1 -1
- package/dist/components/assistant-ui/acp-selectors.mjs +1 -3
- package/dist/components/assistant-ui/file.mjs +2 -2
- package/dist/components/assistant-ui/image-generation-settings-dialog.mjs +25 -6
- package/dist/components/assistant-ui/image.mjs +2 -2
- package/dist/components/assistant-ui/markdown-text.mjs +3 -3
- package/dist/components/assistant-ui/thread/composer.d.ts +1 -1
- package/dist/components/assistant-ui/thread/composer.mjs +37 -3
- package/dist/components/assistant-ui/thread/context-chips.mjs +3 -2
- package/dist/components/assistant-ui/thread/index.mjs +1 -1
- package/dist/components/assistant-ui/thread/message-list.mjs +1 -1
- package/dist/components/assistant-ui/thread/messages.mjs +2 -2
- package/dist/components/assistant-ui/thread-list.d.ts +8 -2
- package/dist/components/assistant-ui/thread-list.mjs +80 -7
- package/dist/components/assistant-ui/threadlist-sidebar.d.ts +4 -1
- package/dist/components/assistant-ui/threadlist-sidebar.mjs +2 -2
- package/dist/components/assistant-ui/tool-fallback.d.ts +1 -1
- package/dist/components/assistant-ui/tool-fallback.mjs +48 -11
- package/dist/components/tool-ui/option-list.d.ts +2 -1
- package/dist/components/tool-ui/option-list.mjs +4 -4
- package/dist/lib/acp2aisdk/client-context.d.ts +6 -0
- package/dist/lib/acp2aisdk/client-context.mjs +43 -7
- package/dist/lib/acp2aisdk/commands.mjs +5 -20
- package/dist/lib/acp2aisdk/context.d.ts +4 -0
- package/dist/lib/acp2aisdk/errors.d.ts +2 -0
- package/dist/lib/acp2aisdk/errors.mjs +37 -0
- package/dist/lib/acp2aisdk/index.d.ts +7 -0
- package/dist/lib/acp2aisdk/index.mjs +110 -34
- package/dist/lib/acp2aisdk/provider-compat.mjs +4 -2
- package/dist/lib/acp2aisdk/provider-registry.mjs +2 -5
- package/dist/lib/acp2aisdk/resumable-ui-stream.d.ts +11 -0
- package/dist/lib/acp2aisdk/resumable-ui-stream.mjs +323 -0
- package/dist/lib/acp2aisdk/runtime-message-filter.d.ts +6 -0
- package/dist/lib/acp2aisdk/runtime-message-filter.mjs +22 -0
- package/dist/lib/acp2aisdk/runtime-persistence.d.ts +21 -0
- package/dist/lib/acp2aisdk/runtime-persistence.mjs +135 -0
- package/dist/lib/acp2aisdk/session-store.mjs +7 -1
- package/dist/lib/acp2aisdk/skill-command-cache.mjs +1 -1
- package/dist/lib/acp2aisdk/types.d.ts +0 -1
- package/dist/lib/api/client.d.ts +51 -4
- package/dist/lib/api/client.mjs +35 -4
- package/dist/lib/api/cors.mjs +7 -1
- package/dist/lib/api/http-response.d.ts +2 -0
- package/dist/lib/api/http-response.mjs +22 -0
- package/dist/lib/conversations/client-adapter.d.ts +1 -0
- package/dist/lib/conversations/client-adapter.mjs +158 -51
- package/dist/lib/conversations/provider-message-loader.d.ts +7 -0
- package/dist/lib/conversations/provider-message-loader.mjs +99 -0
- package/dist/lib/conversations/runtime-message-recovery.d.ts +9 -0
- package/dist/lib/conversations/runtime-message-recovery.mjs +95 -0
- package/dist/lib/conversations/store.d.ts +2 -2
- package/dist/lib/conversations/store.mjs +49 -149
- package/dist/lib/conversations/title-text.d.ts +3 -0
- package/dist/lib/conversations/title-text.mjs +81 -0
- package/dist/lib/conversations/types.d.ts +12 -1
- package/dist/lib/local-image-files.mjs +9 -1
- package/dist/lib/local-image-paths.mjs +31 -6
- package/dist/lib/output-artifacts/thread.d.ts +22 -0
- package/dist/lib/output-artifacts/thread.mjs +47 -0
- package/dist/lib/output-artifacts/workspace.mjs +6 -2
- package/dist/lib/provider-history/codex.mjs +5 -30
- package/dist/public-api/server.d.ts +1 -1
- package/dist/public-api/server.mjs +1 -1
- package/dist/tools/image-generation/client.mjs +6 -4
- package/dist/tools/image-generation/server.mjs +3 -1
- package/dist/tools/image-generation/shared.d.ts +1 -0
- package/dist/tools/image-generation/shared.mjs +4 -0
- package/dist/tools/image-generation/ui-detail.mjs +66 -2
- package/dist/tools/user-choice/ui.mjs +66 -30
- package/package.json +6 -6
- package/.next/server/chunks/[root-of-the-server]__04xq..~._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__07sxz4_._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0dwg3fr._.js +0 -178
- package/.next/server/chunks/[root-of-the-server]__0eanzwb._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0gqx~5k._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__0~mtsby._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__10-n4io._.js +0 -3
- package/.next/server/chunks/[root-of-the-server]__10g507v._.js +0 -3
- package/.next/static/chunks/0zftsky7gte_9.js +0 -102
- package/.next/static/chunks/1610ha42i.fl~.css +0 -1
- /package/.next/static/{mbk_N5Gs4ZJg3lciRL6ya → 0241KNhzDEg6VFWZ_e_qK}/_buildManifest.js +0 -0
- /package/.next/static/{mbk_N5Gs4ZJg3lciRL6ya → 0241KNhzDEg6VFWZ_e_qK}/_clientMiddlewareManifest.js +0 -0
- /package/.next/static/{mbk_N5Gs4ZJg3lciRL6ya → 0241KNhzDEg6VFWZ_e_qK}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { loadConversationMessages, saveConversationMessage, upsertConversation, } from "../conversations/store.mjs";
|
|
2
|
+
import { sanitizePersistedBuiltinToolSettingsPatch } from "../../tools/registry.mjs";
|
|
3
|
+
import { normalizeAcpProvider } from "./provider-registry.mjs";
|
|
4
|
+
import { normalizePermissionMode } from "./runtime-options.mjs";
|
|
5
|
+
import { normalizeThreadId, normalizeWorkspacePath } from "./session-store.mjs";
|
|
6
|
+
function isRecord(value) {
|
|
7
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
8
|
+
}
|
|
9
|
+
function createConversationPatch(request) {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
|
+
const builtinToolSettings = sanitizePersistedBuiltinToolSettingsPatch(request.builtinToolSettings);
|
|
12
|
+
const patch = {
|
|
13
|
+
threadId: normalizeThreadId((_a = request.threadId) !== null && _a !== void 0 ? _a : request.id),
|
|
14
|
+
workspacePath: normalizeWorkspacePath(request.workspacePath),
|
|
15
|
+
};
|
|
16
|
+
if (request.provider !== undefined) {
|
|
17
|
+
patch.provider = normalizeAcpProvider(request.provider);
|
|
18
|
+
}
|
|
19
|
+
if (request.model !== undefined)
|
|
20
|
+
patch.model = (_b = request.model) !== null && _b !== void 0 ? _b : null;
|
|
21
|
+
if (request.modeId !== undefined)
|
|
22
|
+
patch.modeId = (_c = request.modeId) !== null && _c !== void 0 ? _c : null;
|
|
23
|
+
if (request.thoughtLevel !== undefined) {
|
|
24
|
+
patch.thoughtLevel = (_d = request.thoughtLevel) !== null && _d !== void 0 ? _d : null;
|
|
25
|
+
}
|
|
26
|
+
if (request.permissionMode !== undefined) {
|
|
27
|
+
patch.permissionMode = normalizePermissionMode(request.permissionMode);
|
|
28
|
+
}
|
|
29
|
+
if (builtinToolSettings) {
|
|
30
|
+
patch.builtinToolSettings = builtinToolSettings;
|
|
31
|
+
}
|
|
32
|
+
return patch;
|
|
33
|
+
}
|
|
34
|
+
function ensureMessageId(threadId, message, index) {
|
|
35
|
+
const fallbackId = `${threadId}:${message.role || "message"}:${index}`;
|
|
36
|
+
return String((message === null || message === void 0 ? void 0 : message.id) || fallbackId);
|
|
37
|
+
}
|
|
38
|
+
function withAcpRunMetadata({ message, runState, threadId, acpSessionId, error, streamId, }) {
|
|
39
|
+
const metadata = isRecord(message.metadata)
|
|
40
|
+
? message.metadata
|
|
41
|
+
: undefined;
|
|
42
|
+
const custom = isRecord(metadata === null || metadata === void 0 ? void 0 : metadata.custom) ? metadata.custom : {};
|
|
43
|
+
return Object.assign(Object.assign({}, message), { metadata: Object.assign(Object.assign({}, (metadata !== null && metadata !== void 0 ? metadata : {})), { custom: Object.assign(Object.assign({}, custom), { acpRun: Object.assign(Object.assign({ status: runState, threadId, acpSessionId: acpSessionId !== null && acpSessionId !== void 0 ? acpSessionId : null, error: error !== null && error !== void 0 ? error : null }, (streamId ? { streamId } : {})), { updatedAt: Date.now() }) }) }) });
|
|
44
|
+
}
|
|
45
|
+
function mergeStoredMetadata(message, existing) {
|
|
46
|
+
if (!existing || !isRecord(existing.metadata))
|
|
47
|
+
return message;
|
|
48
|
+
const existingMetadata = existing.metadata;
|
|
49
|
+
const nextMetadata = isRecord(message.metadata)
|
|
50
|
+
? message.metadata
|
|
51
|
+
: undefined;
|
|
52
|
+
const existingCustom = isRecord(existingMetadata.custom)
|
|
53
|
+
? existingMetadata.custom
|
|
54
|
+
: {};
|
|
55
|
+
const nextCustom = isRecord(nextMetadata === null || nextMetadata === void 0 ? void 0 : nextMetadata.custom) ? nextMetadata.custom : {};
|
|
56
|
+
return Object.assign(Object.assign({}, message), { metadata: Object.assign(Object.assign(Object.assign({}, existingMetadata), (nextMetadata !== null && nextMetadata !== void 0 ? nextMetadata : {})), { custom: Object.assign(Object.assign({}, existingCustom), nextCustom) }) });
|
|
57
|
+
}
|
|
58
|
+
function getAcpRunStatus(message) {
|
|
59
|
+
const metadata = isRecord(message === null || message === void 0 ? void 0 : message.metadata)
|
|
60
|
+
? message.metadata
|
|
61
|
+
: undefined;
|
|
62
|
+
const custom = isRecord(metadata === null || metadata === void 0 ? void 0 : metadata.custom) ? metadata.custom : {};
|
|
63
|
+
const acpRun = isRecord(custom.acpRun) ? custom.acpRun : {};
|
|
64
|
+
const status = acpRun.status;
|
|
65
|
+
return status === "completed" || status === "aborted" || status === "error"
|
|
66
|
+
? status
|
|
67
|
+
: null;
|
|
68
|
+
}
|
|
69
|
+
export async function persistRuntimeMessages({ request, messages, runState, acpSessionId, error, runMetadataMessageId, streamId, }) {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
const threadId = normalizeThreadId((_a = request.threadId) !== null && _a !== void 0 ? _a : request.id);
|
|
72
|
+
const workspacePath = normalizeWorkspacePath(request.workspacePath);
|
|
73
|
+
await upsertConversation(createConversationPatch(request));
|
|
74
|
+
const existingMessages = await loadConversationMessages(threadId, "ai-sdk/v6", workspacePath, "runtime").catch(() => null);
|
|
75
|
+
const existingById = new Map(((_b = existingMessages === null || existingMessages === void 0 ? void 0 : existingMessages.messages) !== null && _b !== void 0 ? _b : []).flatMap((entry) => {
|
|
76
|
+
const content = entry.content;
|
|
77
|
+
return isRecord(content) && typeof content.id === "string"
|
|
78
|
+
? [[content.id, content]]
|
|
79
|
+
: [];
|
|
80
|
+
}));
|
|
81
|
+
const persistedMessages = messages.map((message, index) => {
|
|
82
|
+
const id = ensureMessageId(threadId, message, index);
|
|
83
|
+
const existing = existingById.get(id);
|
|
84
|
+
if (runState === "running" && getAcpRunStatus(existing)) {
|
|
85
|
+
return Object.assign(Object.assign({}, existing), { id });
|
|
86
|
+
}
|
|
87
|
+
const shouldAttachRunMetadata = runMetadataMessageId !== undefined
|
|
88
|
+
? id === runMetadataMessageId
|
|
89
|
+
: index === messages.length - 1;
|
|
90
|
+
const nextMessage = shouldAttachRunMetadata
|
|
91
|
+
? withAcpRunMetadata({
|
|
92
|
+
message,
|
|
93
|
+
runState,
|
|
94
|
+
threadId,
|
|
95
|
+
acpSessionId,
|
|
96
|
+
error,
|
|
97
|
+
streamId,
|
|
98
|
+
})
|
|
99
|
+
: message;
|
|
100
|
+
return Object.assign(Object.assign({}, mergeStoredMetadata(nextMessage, existing)), { id });
|
|
101
|
+
});
|
|
102
|
+
for (let index = 0; index < persistedMessages.length; index += 1) {
|
|
103
|
+
const message = persistedMessages[index];
|
|
104
|
+
await saveConversationMessage(threadId, {
|
|
105
|
+
parentId: index > 0 ? ((_d = (_c = persistedMessages[index - 1]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null) : null,
|
|
106
|
+
message: {
|
|
107
|
+
id: message.id,
|
|
108
|
+
content: Object.assign({}, message),
|
|
109
|
+
},
|
|
110
|
+
format: "ai-sdk/v6",
|
|
111
|
+
}, workspacePath);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export async function persistRequestRuntimeMessages(request) {
|
|
115
|
+
await persistRuntimeMessages({
|
|
116
|
+
request,
|
|
117
|
+
messages: request.messages,
|
|
118
|
+
runState: "running",
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export async function persistPartialAssistantMessage({ request, message, acpSessionId, streamId, }) {
|
|
122
|
+
const lastRequestMessage = request.messages.at(-1);
|
|
123
|
+
const baseMessages = (lastRequestMessage === null || lastRequestMessage === void 0 ? void 0 : lastRequestMessage.role) === "assistant" &&
|
|
124
|
+
lastRequestMessage.id === message.id
|
|
125
|
+
? request.messages.slice(0, -1)
|
|
126
|
+
: request.messages;
|
|
127
|
+
await persistRuntimeMessages({
|
|
128
|
+
request,
|
|
129
|
+
messages: [...baseMessages, message],
|
|
130
|
+
runState: "running",
|
|
131
|
+
acpSessionId,
|
|
132
|
+
runMetadataMessageId: message.id,
|
|
133
|
+
streamId,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
@@ -110,7 +110,13 @@ function cleanupAcpProvider(provider) {
|
|
|
110
110
|
const agentProcess = getAgentProcess(provider);
|
|
111
111
|
const pid = agentProcess === null || agentProcess === void 0 ? void 0 : agentProcess.pid;
|
|
112
112
|
const descendantPids = pid ? collectDescendantPids(pid) : [];
|
|
113
|
-
|
|
113
|
+
try {
|
|
114
|
+
provider.cleanup();
|
|
115
|
+
}
|
|
116
|
+
catch (_a) {
|
|
117
|
+
// Cleanup happens on request paths such as runtime polling. A provider
|
|
118
|
+
// teardown failure should not take down the Next dev server.
|
|
119
|
+
}
|
|
114
120
|
for (const childPid of descendantPids) {
|
|
115
121
|
forceKillProcess(childPid);
|
|
116
122
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { safeLocalStorage } from "./capability-cache.mjs";
|
|
3
|
-
const SKILL_COMMAND_CACHE_PREFIX = "skill-commands:
|
|
3
|
+
const SKILL_COMMAND_CACHE_PREFIX = "skill-commands:v2";
|
|
4
4
|
export const SKILL_COMMAND_CACHE_TTL_MS = 30 * 60 * 1000;
|
|
5
5
|
function normalizeText(value) {
|
|
6
6
|
return typeof value === "string" ? value.trim() : "";
|
|
@@ -19,7 +19,6 @@ export type AcpProviderRegistryEntry = {
|
|
|
19
19
|
defaultModel?: string | null;
|
|
20
20
|
defaultModeId?: string | null;
|
|
21
21
|
supportsImages: boolean;
|
|
22
|
-
enabledInP0: boolean;
|
|
23
22
|
};
|
|
24
23
|
export type AcpProviderOverride = Partial<Pick<AcpProviderRegistryEntry, "command" | "args" | "authMethodId" | "sessionDelayMs" | "persistSession" | "defaultModel" | "defaultModeId">>;
|
|
25
24
|
export type AcpChatRequest = {
|
package/dist/lib/api/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { AcpOutputArtifact } from "../../components/assistant-ui/addons/output-artifacts";
|
|
1
2
|
import type { AcpCapabilitySnapshot, AcpChatRequest } from "../acp2aisdk";
|
|
2
3
|
import type { AcpUiCommand } from "../acp2aisdk/commands";
|
|
3
|
-
import type {
|
|
4
|
-
import type { ConversationInitializeResponse, ConversationListResponse, ConversationMessagesResponse, ConversationMessageUpsertRequest, ConversationRecord, ConversationUpsertRequest } from "../conversations/types";
|
|
4
|
+
import type { ConversationInitializeResponse, ConversationListResponse, ConversationMessageSource, ConversationMessagesResponse, ConversationMessageUpsertRequest, ConversationRecord, ConversationRuntimeResponse, ConversationUpsertRequest } from "../conversations/types";
|
|
5
5
|
import type { ImageGenerationRecord } from "../../tools/image-generation/shared";
|
|
6
6
|
import type { UserChoicePendingRequest, UserChoiceToolResult } from "../../tools/user-choice/shared";
|
|
7
7
|
export type AcpUiRuntimeConfig = {
|
|
@@ -27,6 +27,13 @@ type CommandsResponse = {
|
|
|
27
27
|
type WorkspaceOutputArtifactsResponse = {
|
|
28
28
|
artifacts: AcpOutputArtifact[];
|
|
29
29
|
};
|
|
30
|
+
type ThreadOutputArtifactsResponse = {
|
|
31
|
+
messages: ConversationMessagesResponse["messages"];
|
|
32
|
+
artifacts: AcpOutputArtifact[];
|
|
33
|
+
imageGenerationRecords: ImageGenerationRecord[];
|
|
34
|
+
workspaceArtifacts: AcpOutputArtifact[];
|
|
35
|
+
diagnostic?: ConversationMessagesResponse["diagnostic"];
|
|
36
|
+
};
|
|
30
37
|
declare global {
|
|
31
38
|
interface Window {
|
|
32
39
|
__ACP_UI_RUNTIME_CONFIG__?: AcpUiRuntimeConfig;
|
|
@@ -36,9 +43,17 @@ export declare function configureAcpUiRuntime(config: AcpUiRuntimeConfig): void;
|
|
|
36
43
|
export declare function readAcpUiRuntimeConfig(): AcpUiRuntimeConfig;
|
|
37
44
|
export declare const acpApiEndpoints: {
|
|
38
45
|
chat: () => string;
|
|
46
|
+
chatCancel: () => string;
|
|
47
|
+
chatResume: (streamId: string, query?: {
|
|
48
|
+
id?: string | null;
|
|
49
|
+
threadId?: string | null;
|
|
50
|
+
provider?: string | null;
|
|
51
|
+
workspacePath?: string | null;
|
|
52
|
+
}) => string;
|
|
39
53
|
conversations: (workspacePath?: string | null, options?: ConversationListOptions) => string;
|
|
40
54
|
conversation: (threadId: string, workspacePath?: string | null) => string;
|
|
41
|
-
conversationMessages: (threadId: string, workspacePath?: string | null, format?: string | null) => string;
|
|
55
|
+
conversationMessages: (threadId: string, workspacePath?: string | null, format?: string | null, source?: ConversationMessageSource | null, hideResumable?: boolean | null) => string;
|
|
56
|
+
conversationRuntime: (threadId: string, workspacePath?: string | null) => string;
|
|
42
57
|
imageGenerationRecords: (workspacePath?: string | null, threadId?: string | null, limit?: number) => string;
|
|
43
58
|
userChoice: (query?: {
|
|
44
59
|
workspacePath?: string | null;
|
|
@@ -47,16 +62,39 @@ export declare const acpApiEndpoints: {
|
|
|
47
62
|
requestId?: string | null;
|
|
48
63
|
}) => string;
|
|
49
64
|
workspaceOutputArtifacts: (workspacePath?: string | null, threadId?: string | null, sinceMs?: number) => string;
|
|
65
|
+
threadOutputArtifacts: (query: {
|
|
66
|
+
workspacePath?: string | null;
|
|
67
|
+
threadId?: string | null;
|
|
68
|
+
format?: string | null;
|
|
69
|
+
source?: ConversationMessageSource | null;
|
|
70
|
+
sinceMs?: number | null;
|
|
71
|
+
}) => string;
|
|
50
72
|
capabilities: ({ provider, threadId, workspacePath }: AcpQuery) => string;
|
|
51
73
|
commands: ({ provider, threadId, workspacePath }: AcpQuery) => string;
|
|
52
74
|
};
|
|
53
75
|
export declare const acpApiClient: {
|
|
54
76
|
chatUrl(): string;
|
|
77
|
+
chatResumeUrl(streamId: string, query?: {
|
|
78
|
+
id?: string | null;
|
|
79
|
+
threadId?: string | null;
|
|
80
|
+
provider?: string | null;
|
|
81
|
+
workspacePath?: string | null;
|
|
82
|
+
}): string;
|
|
83
|
+
cancelChat(body: {
|
|
84
|
+
id?: string | null;
|
|
85
|
+
threadId?: string | null;
|
|
86
|
+
provider?: string | null;
|
|
87
|
+
workspacePath?: string | null;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
cancelled: boolean;
|
|
90
|
+
cleaned: boolean;
|
|
91
|
+
}>;
|
|
55
92
|
listConversations(workspacePath?: string | null, options?: ConversationListOptions): Promise<ConversationListResponse>;
|
|
56
93
|
upsertConversation(body: ConversationUpsertRequest, workspacePath?: string | null): Promise<ConversationInitializeResponse>;
|
|
57
94
|
getConversation(threadId: string, workspacePath?: string | null): Promise<{
|
|
58
95
|
thread: ConversationRecord;
|
|
59
96
|
}>;
|
|
97
|
+
getConversationRuntime(threadId: string, workspacePath?: string | null): Promise<ConversationRuntimeResponse>;
|
|
60
98
|
renameConversation(threadId: string, title: string, workspacePath?: string | null): Promise<{
|
|
61
99
|
thread: ConversationRecord;
|
|
62
100
|
}>;
|
|
@@ -64,7 +102,9 @@ export declare const acpApiClient: {
|
|
|
64
102
|
thread: ConversationRecord;
|
|
65
103
|
}>;
|
|
66
104
|
deleteConversation(threadId: string, workspacePath?: string | null): Promise<void>;
|
|
67
|
-
loadConversationMessages<TContent extends Record<string, unknown>>(threadId: string, workspacePath: string | null | undefined, format: string
|
|
105
|
+
loadConversationMessages<TContent extends Record<string, unknown>>(threadId: string, workspacePath: string | null | undefined, format: string, source?: ConversationMessageSource, options?: {
|
|
106
|
+
hideResumable?: boolean;
|
|
107
|
+
}): Promise<ConversationMessagesResponse<TContent>>;
|
|
68
108
|
saveConversationMessage<TContent extends Record<string, unknown>>(threadId: string, workspacePath: string | null | undefined, body: ConversationMessageUpsertRequest<TContent>): Promise<{
|
|
69
109
|
message: unknown;
|
|
70
110
|
}>;
|
|
@@ -87,6 +127,13 @@ export declare const acpApiClient: {
|
|
|
87
127
|
request: UserChoicePendingRequest;
|
|
88
128
|
}>;
|
|
89
129
|
listWorkspaceOutputArtifacts(workspacePath: string | null | undefined, threadId: string | null | undefined, sinceMs: number): Promise<WorkspaceOutputArtifactsResponse>;
|
|
130
|
+
collectThreadOutputArtifacts(query: {
|
|
131
|
+
workspacePath?: string | null;
|
|
132
|
+
threadId?: string | null;
|
|
133
|
+
format?: string | null;
|
|
134
|
+
source?: ConversationMessageSource | null;
|
|
135
|
+
sinceMs?: number | null;
|
|
136
|
+
}): Promise<ThreadOutputArtifactsResponse>;
|
|
90
137
|
getCapabilities(query: AcpQuery): Promise<CapabilityResponse>;
|
|
91
138
|
listCommands(query: AcpQuery): Promise<CommandsResponse>;
|
|
92
139
|
};
|
package/dist/lib/api/client.mjs
CHANGED
|
@@ -106,6 +106,12 @@ function conversationPath(threadId) {
|
|
|
106
106
|
function conversationMessagesPath(threadId) {
|
|
107
107
|
return `${conversationPath(threadId)}/messages`;
|
|
108
108
|
}
|
|
109
|
+
function conversationRuntimePath(threadId) {
|
|
110
|
+
return `${conversationPath(threadId)}/runtime`;
|
|
111
|
+
}
|
|
112
|
+
function chatResumePath(streamId) {
|
|
113
|
+
return `/chat/resume/${encodeURIComponent(streamId)}`;
|
|
114
|
+
}
|
|
109
115
|
function imageGenerationRecordsPath() {
|
|
110
116
|
return "/tools/image-generation/records";
|
|
111
117
|
}
|
|
@@ -114,19 +120,29 @@ function userChoicePath() {
|
|
|
114
120
|
}
|
|
115
121
|
export const acpApiEndpoints = {
|
|
116
122
|
chat: () => buildApiUrl("/chat"),
|
|
123
|
+
chatCancel: () => buildApiUrl("/chat/cancel"),
|
|
124
|
+
chatResume: (streamId, query) => buildApiUrl(chatResumePath(streamId), query),
|
|
117
125
|
conversations: (workspacePath, options) => buildApiUrl("/conversations", conversationQuery(workspacePath, options)),
|
|
118
126
|
conversation: (threadId, workspacePath) => buildApiUrl(conversationPath(threadId), { workspacePath }),
|
|
119
|
-
conversationMessages: (threadId, workspacePath, format) => buildApiUrl(conversationMessagesPath(threadId), {
|
|
127
|
+
conversationMessages: (threadId, workspacePath, format, source, hideResumable) => buildApiUrl(conversationMessagesPath(threadId), {
|
|
120
128
|
workspacePath,
|
|
121
129
|
format,
|
|
130
|
+
source,
|
|
131
|
+
hideResumable,
|
|
122
132
|
}),
|
|
133
|
+
conversationRuntime: (threadId, workspacePath) => buildApiUrl(conversationRuntimePath(threadId), { workspacePath }),
|
|
123
134
|
imageGenerationRecords: (workspacePath, threadId, limit) => buildApiUrl(imageGenerationRecordsPath(), {
|
|
124
135
|
workspacePath,
|
|
125
136
|
threadId,
|
|
126
137
|
limit,
|
|
127
138
|
}),
|
|
128
139
|
userChoice: (query) => buildApiUrl(userChoicePath(), query),
|
|
129
|
-
workspaceOutputArtifacts: (workspacePath, threadId, sinceMs) => buildApiUrl("/output-artifacts/workspace", {
|
|
140
|
+
workspaceOutputArtifacts: (workspacePath, threadId, sinceMs) => buildApiUrl("/output-artifacts/workspace", {
|
|
141
|
+
workspacePath,
|
|
142
|
+
threadId,
|
|
143
|
+
sinceMs,
|
|
144
|
+
}),
|
|
145
|
+
threadOutputArtifacts: (query) => buildApiUrl("/output-artifacts/thread", query),
|
|
130
146
|
capabilities: ({ provider, threadId, workspacePath }) => buildApiUrl("/acp/capabilities", { provider, threadId, workspacePath }),
|
|
131
147
|
commands: ({ provider, threadId, workspacePath }) => buildApiUrl("/acp/commands", { provider, threadId, workspacePath }),
|
|
132
148
|
};
|
|
@@ -134,6 +150,15 @@ export const acpApiClient = {
|
|
|
134
150
|
chatUrl() {
|
|
135
151
|
return acpApiEndpoints.chat();
|
|
136
152
|
},
|
|
153
|
+
chatResumeUrl(streamId, query) {
|
|
154
|
+
return acpApiEndpoints.chatResume(streamId, query);
|
|
155
|
+
},
|
|
156
|
+
async cancelChat(body) {
|
|
157
|
+
return requestJson(acpApiEndpoints.chatCancel(), {
|
|
158
|
+
method: "POST",
|
|
159
|
+
body: JSON.stringify(body),
|
|
160
|
+
});
|
|
161
|
+
},
|
|
137
162
|
async listConversations(workspacePath, options) {
|
|
138
163
|
return requestJson(acpApiEndpoints.conversations(workspacePath, options));
|
|
139
164
|
},
|
|
@@ -146,6 +171,9 @@ export const acpApiClient = {
|
|
|
146
171
|
async getConversation(threadId, workspacePath) {
|
|
147
172
|
return requestJson(acpApiEndpoints.conversation(threadId, workspacePath));
|
|
148
173
|
},
|
|
174
|
+
async getConversationRuntime(threadId, workspacePath) {
|
|
175
|
+
return requestJson(acpApiEndpoints.conversationRuntime(threadId, workspacePath));
|
|
176
|
+
},
|
|
149
177
|
async renameConversation(threadId, title, workspacePath) {
|
|
150
178
|
return requestJson(acpApiEndpoints.conversation(threadId, workspacePath), {
|
|
151
179
|
method: "PATCH",
|
|
@@ -166,8 +194,8 @@ export const acpApiClient = {
|
|
|
166
194
|
throw new Error(`${response.status} ${response.statusText}`);
|
|
167
195
|
}
|
|
168
196
|
},
|
|
169
|
-
async loadConversationMessages(threadId, workspacePath, format) {
|
|
170
|
-
return requestJson(acpApiEndpoints.conversationMessages(threadId, workspacePath, format));
|
|
197
|
+
async loadConversationMessages(threadId, workspacePath, format, source, options) {
|
|
198
|
+
return requestJson(acpApiEndpoints.conversationMessages(threadId, workspacePath, format, source, options === null || options === void 0 ? void 0 : options.hideResumable));
|
|
171
199
|
},
|
|
172
200
|
async saveConversationMessage(threadId, workspacePath, body) {
|
|
173
201
|
return requestJson(acpApiEndpoints.conversationMessages(threadId, workspacePath, body.format), {
|
|
@@ -190,6 +218,9 @@ export const acpApiClient = {
|
|
|
190
218
|
async listWorkspaceOutputArtifacts(workspacePath, threadId, sinceMs) {
|
|
191
219
|
return requestJson(acpApiEndpoints.workspaceOutputArtifacts(workspacePath, threadId, sinceMs));
|
|
192
220
|
},
|
|
221
|
+
async collectThreadOutputArtifacts(query) {
|
|
222
|
+
return requestJson(acpApiEndpoints.threadOutputArtifacts(query));
|
|
223
|
+
},
|
|
193
224
|
async getCapabilities(query) {
|
|
194
225
|
return requestJson(acpApiEndpoints.capabilities(query));
|
|
195
226
|
},
|
package/dist/lib/api/cors.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasNullBodyStatus } from "./http-response.mjs";
|
|
1
2
|
const ALLOWED_METHODS = "GET,POST,PATCH,DELETE,OPTIONS";
|
|
2
3
|
const DEFAULT_ALLOWED_HEADERS = "Content-Type, Authorization, X-Requested-With, Accept";
|
|
3
4
|
function configuredOrigins() {
|
|
@@ -36,7 +37,12 @@ export function withCors(request, response) {
|
|
|
36
37
|
headers.set("Access-Control-Allow-Headers", (_a = request.headers.get("access-control-request-headers")) !== null && _a !== void 0 ? _a : DEFAULT_ALLOWED_HEADERS);
|
|
37
38
|
headers.set("Access-Control-Max-Age", "86400");
|
|
38
39
|
appendVaryOrigin(headers);
|
|
39
|
-
|
|
40
|
+
const body = hasNullBodyStatus(response.status) ? null : response.body;
|
|
41
|
+
if (body === null) {
|
|
42
|
+
headers.delete("content-length");
|
|
43
|
+
headers.delete("transfer-encoding");
|
|
44
|
+
}
|
|
45
|
+
return new Response(body, {
|
|
40
46
|
headers,
|
|
41
47
|
status: response.status,
|
|
42
48
|
statusText: response.statusText,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const NULL_BODY_STATUS_CODES = new Set([204, 205, 304]);
|
|
2
|
+
export function hasNullBodyStatus(status) {
|
|
3
|
+
return NULL_BODY_STATUS_CODES.has(status);
|
|
4
|
+
}
|
|
5
|
+
export function withoutBodyForNullBodyStatus(response) {
|
|
6
|
+
if (!hasNullBodyStatus(response.status) || !response.body)
|
|
7
|
+
return response;
|
|
8
|
+
try {
|
|
9
|
+
void response.body.cancel().catch(() => { });
|
|
10
|
+
}
|
|
11
|
+
catch (_a) {
|
|
12
|
+
// The body may already be locked by the time a defensive wrapper sees it.
|
|
13
|
+
}
|
|
14
|
+
const headers = new Headers(response.headers);
|
|
15
|
+
headers.delete("content-length");
|
|
16
|
+
headers.delete("transfer-encoding");
|
|
17
|
+
return new Response(null, {
|
|
18
|
+
headers,
|
|
19
|
+
status: response.status,
|
|
20
|
+
statusText: response.statusText,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -11,6 +11,7 @@ type AcpThreadContext = {
|
|
|
11
11
|
permissionMode?: string;
|
|
12
12
|
workspacePath?: string | null;
|
|
13
13
|
builtinToolSettings?: AcpBuiltinToolSettings;
|
|
14
|
+
runtimeBuiltinToolSettings?: AcpBuiltinToolSettings;
|
|
14
15
|
consumeContextBundle?: () => ContextBundleV2 | null;
|
|
15
16
|
};
|
|
16
17
|
type ConversationRuntimeOptions = {
|