openclaw-openagent 1.0.12 → 1.0.14
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/index.js +2 -0
- package/dist/src/config/config-schema.d.ts +9 -0
- package/dist/src/config/config-schema.js +6 -0
- package/dist/src/messaging/executor.d.ts +2 -3
- package/dist/src/messaging/executor.js +4 -31
- package/dist/src/plugin-ui/assets/openagent-override.js +124 -18
- package/dist/src/proxy/auth-proxy.js +5 -0
- package/dist/src/runtime/update-checker.d.ts +18 -0
- package/dist/src/runtime/update-checker.js +216 -0
- package/index.ts +3 -0
- package/package.json +1 -3
- package/src/app/channel-tools.ts +0 -249
- package/src/app/discovery-tools.ts +0 -273
- package/src/app/download-file-tool.ts +0 -133
- package/src/app/hooks.ts +0 -144
- package/src/app/index.ts +0 -84
- package/src/app/messaging-tools.ts +0 -79
- package/src/app/ops-tools.ts +0 -155
- package/src/app/remote-agent-tool.ts +0 -762
- package/src/app/types.ts +0 -68
- package/src/app/upload-file-tool.ts +0 -411
- package/src/app/verbose-preflight.ts +0 -190
- package/src/auth/config.ts +0 -266
- package/src/auth/credential-manager.ts +0 -146
- package/src/auth/index.ts +0 -24
- package/src/auth/verify.ts +0 -99
- package/src/channel.ts +0 -566
- package/src/compat.ts +0 -94
- package/src/config/config-schema.ts +0 -39
- package/src/messaging/aggregator.ts +0 -120
- package/src/messaging/collector.ts +0 -89
- package/src/messaging/executor.ts +0 -72
- package/src/messaging/inbound.ts +0 -150
- package/src/messaging/index.ts +0 -11
- package/src/messaging/mention-protocol.ts +0 -94
- package/src/messaging/process-c2c-request.ts +0 -564
- package/src/messaging/process-message.ts +0 -373
- package/src/messaging/scheduler.ts +0 -55
- package/src/messaging/types.ts +0 -38
- package/src/plugin-ui/adapters/oc-2026-04.js +0 -103
- package/src/plugin-ui/adapters/oc-2026-05.js +0 -125
- package/src/plugin-ui/adapters/oc-2026-06.js +0 -125
- package/src/plugin-ui/adapters/oc-unknown.js +0 -48
- package/src/plugin-ui/assets/agentbook-icon.svg +0 -5
- package/src/plugin-ui/assets/bg.png +0 -0
- package/src/plugin-ui/assets/icon.png +0 -0
- package/src/plugin-ui/assets/magic.svg +0 -5
- package/src/plugin-ui/assets/openagent-override.js +0 -11156
- package/src/plugin-ui/build.cjs +0 -463
- package/src/plugin-ui/index.ts +0 -18
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +0 -570
- package/src/plugin-ui/modules/agent-book/panel/agent-card.js +0 -170
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +0 -643
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +0 -665
- package/src/plugin-ui/modules/agent-book/panel/mention-state.js +0 -206
- package/src/plugin-ui/modules/agent-book/panel/styles.js +0 -833
- package/src/plugin-ui/modules/agent-book/panel/theme-adapter.js +0 -86
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +0 -295
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +0 -211
- package/src/plugin-ui/modules/agent-book/scanner.js +0 -131
- package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +0 -500
- package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +0 -652
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +0 -256
- package/src/plugin-ui/modules/loader/bootstrap.js +0 -38
- package/src/plugin-ui/modules/loader/shared-state.js +0 -838
- package/src/plugin-ui/modules/loader/ws-intercept.js +0 -199
- package/src/plugin-ui/modules/remote-agent/chunk-parser.js +0 -161
- package/src/plugin-ui/modules/remote-agent/execution-card.js +0 -530
- package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +0 -256
- package/src/plugin-ui/modules/remote-agent/media-links.js +0 -151
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +0 -134
- package/src/plugin-ui/modules/remote-agent/output-card.js +0 -342
- package/src/plugin-ui/modules/remote-agent/progress-store.js +0 -363
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +0 -1700
- package/src/plugin-ui/modules/remote-agent/styles.js +0 -896
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +0 -130
- package/src/plugin-ui/postinstall-deploy.cjs +0 -52
- package/src/plugin-ui/ui-extension-loader/backup.ts +0 -92
- package/src/plugin-ui/ui-extension-loader/index.ts +0 -276
- package/src/plugin-ui/ui-extension-loader/locator.ts +0 -152
- package/src/plugin-ui/ui-extension-loader/manifest.ts +0 -57
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +0 -944
- package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +0 -70
- package/src/plugin-ui/ui-extension-loader/types.ts +0 -72
- package/src/proxy/auth-proxy.ts +0 -409
- package/src/runtime/account.ts +0 -549
- package/src/runtime/index.ts +0 -7
- package/src/runtime/plugin-runtime.ts +0 -94
- package/src/runtime/registry.ts +0 -71
- package/src/sdk/CLASS_MAP.md +0 -143
- package/src/sdk/index.d.ts +0 -126
- package/src/sdk/index.js +0 -23990
- package/src/sdk/modules/cloud-search-module.js +0 -1117
- package/src/sdk/modules/follow-module.js +0 -1069
- package/src/sdk/modules/group-module.js +0 -7397
- package/src/sdk/modules/relationship-module.js +0 -2269
- package/src/sdk/modules/signaling-module.js +0 -1468
- package/src/sdk/modules/tim-upload-plugin.js +0 -730
- package/src/sdk/node-env/http-request.js +0 -90
- package/src/sdk/node-env/index.js +0 -57
- package/src/sdk/node-env/storage.js +0 -114
- package/src/sdk/package.json +0 -10
- package/src/sdk/tsconfig.json +0 -16
- package/src/state/pending-invocation-store.ts +0 -43
- package/src/state/store.ts +0 -756
- package/src/tim/c2c.ts +0 -451
- package/src/tim/channels.ts +0 -364
- package/src/tim/client.ts +0 -330
- package/src/tim/index.ts +0 -18
- package/src/tim/messages.ts +0 -166
- package/src/tim/sdk-logger-init.ts +0 -50
- package/src/tools.ts +0 -10
- package/src/transport/factory.ts +0 -95
- package/src/transport/oasn/index.ts +0 -17
- package/src/transport/oasn/oasn-agent-card.ts +0 -111
- package/src/transport/oasn/oasn-discovery.ts +0 -108
- package/src/transport/oasn/oasn-files.ts +0 -210
- package/src/transport/oasn/oasn-http.ts +0 -529
- package/src/transport/oasn/oasn-invocation.ts +0 -604
- package/src/transport/oasn/oasn-normalize.ts +0 -133
- package/src/transport/oasn/oasn-register.ts +0 -33
- package/src/transport/oasn/oasn-transport.ts +0 -318
- package/src/transport/oasn/oasn-types.ts +0 -404
- package/src/transport/tim/index.ts +0 -8
- package/src/transport/tim/tim-transport.ts +0 -515
- package/src/transport/types.ts +0 -538
- package/src/types/openclaw-plugin-sdk-media-store.d.ts +0 -9
- package/src/types/openclaw.d.ts +0 -97
- package/src/types/tencentcloud-chat.d.ts +0 -15
- package/src/util/http.ts +0 -113
- package/src/util/logger.ts +0 -131
- package/src/util/url-resolver.ts +0 -77
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* node-env/http-request.js
|
|
3
|
-
*
|
|
4
|
-
* 替代 XMLHttpRequest,用 Node.js 内置 fetch() 实现。
|
|
5
|
-
* SDK 中两处使用 XMLHttpRequest:
|
|
6
|
-
* 1. Io 函数(网络诊断 getconninfo)— index.js L15844
|
|
7
|
-
* 2. ErrMsgModule._fetchErrCode(错误码表拉取)— index.js L21296
|
|
8
|
-
*
|
|
9
|
-
* 本模块导出两个函数,分别对应这两种用法。
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 替代 Io 函数中的 XMLHttpRequest 用法。
|
|
14
|
-
* 功能:发送 HTTP 请求,3秒超时,返回 Promise。
|
|
15
|
-
*
|
|
16
|
-
* @param {string} method - HTTP 方法 (GET/POST)
|
|
17
|
-
* @param {string} url - 请求 URL
|
|
18
|
-
* @param {string} [body] - 请求体(POST 时)
|
|
19
|
-
* @param {Function} resolve - Promise resolve
|
|
20
|
-
* @param {Function} reject - Promise reject
|
|
21
|
-
* @param {Function} createError - 创建 SDK 错误对象的工厂函数 (code) => Error
|
|
22
|
-
* @param {object} errorCodes - { NETWORK_ERROR, NETWORK_TIMEOUT }
|
|
23
|
-
* @param {object} logger - SDK 日志对象 { l, w, e }
|
|
24
|
-
*/
|
|
25
|
-
export function httpDiagnose(method, url, body, resolve, reject, createError, errorCodes, logger) {
|
|
26
|
-
const controller = new AbortController();
|
|
27
|
-
const timer = setTimeout(() => {
|
|
28
|
-
controller.abort();
|
|
29
|
-
reject(createError(errorCodes.NETWORK_TIMEOUT));
|
|
30
|
-
}, 3000);
|
|
31
|
-
|
|
32
|
-
fetch(url, {
|
|
33
|
-
method,
|
|
34
|
-
headers: { "Content-type": "application/x-www-form-urlencoded;charset=UTF-8" },
|
|
35
|
-
body: body || undefined,
|
|
36
|
-
signal: controller.signal,
|
|
37
|
-
})
|
|
38
|
-
.then((res) => {
|
|
39
|
-
clearTimeout(timer);
|
|
40
|
-
if (res.ok || res.status === 304) {
|
|
41
|
-
return res.text().then((text) => {
|
|
42
|
-
if (text && text.indexOf("NetCheckInfo") > -1) {
|
|
43
|
-
logger.l("getconninfo ok in node. ret:", JSON.parse(text));
|
|
44
|
-
}
|
|
45
|
-
resolve();
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
reject(createError(errorCodes.NETWORK_ERROR));
|
|
49
|
-
})
|
|
50
|
-
.catch(() => {
|
|
51
|
-
clearTimeout(timer);
|
|
52
|
-
reject(createError(errorCodes.NETWORK_TIMEOUT));
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* 替代 ErrMsgModule._fetchErrCode 中的 XMLHttpRequest 用法。
|
|
58
|
-
* 功能:GET 请求拉取错误码 JSON,3秒超时。
|
|
59
|
-
*
|
|
60
|
-
* @param {string} url - 错误码表 URL
|
|
61
|
-
* @param {string} contentType - Content-Type header
|
|
62
|
-
* @param {Function} resolve - Promise resolve,传入响应文本
|
|
63
|
-
* @param {Function} reject - Promise reject
|
|
64
|
-
* @param {object} logger - SDK 日志对象
|
|
65
|
-
*/
|
|
66
|
-
export function httpFetchText(url, contentType, resolve, reject, logger) {
|
|
67
|
-
const controller = new AbortController();
|
|
68
|
-
const timer = setTimeout(() => {
|
|
69
|
-
controller.abort();
|
|
70
|
-
}, 3000);
|
|
71
|
-
|
|
72
|
-
fetch(url, {
|
|
73
|
-
method: "GET",
|
|
74
|
-
headers: { "Content-type": contentType },
|
|
75
|
-
signal: controller.signal,
|
|
76
|
-
})
|
|
77
|
-
.then((res) => {
|
|
78
|
-
clearTimeout(timer);
|
|
79
|
-
if (res.ok || res.status === 304) {
|
|
80
|
-
return res.text().then((text) => {
|
|
81
|
-
resolve(text);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
reject(res.status);
|
|
85
|
-
})
|
|
86
|
-
.catch((err) => {
|
|
87
|
-
clearTimeout(timer);
|
|
88
|
-
reject(err);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* node-env/index.js
|
|
3
|
-
*
|
|
4
|
-
* SDK 的 Node.js 环境适配层。
|
|
5
|
-
* 在 import SDK 之前先 import 此文件,自动注入浏览器 API 的 Node.js 替代实现。
|
|
6
|
-
*
|
|
7
|
-
* 使用方式:
|
|
8
|
-
* import './node-env/index.js'; // 必须在 SDK import 之前
|
|
9
|
-
* import SDK from './index.js'; // SDK 正常使用
|
|
10
|
-
*
|
|
11
|
-
* 提供的替代能力:
|
|
12
|
-
* - localStorage → 内存 Map(支持 for...in 遍历)
|
|
13
|
-
* - navigator.cookieEnabled → true
|
|
14
|
-
* - httpDiagnose / httpFetchText → 通过 SDK 源码内引用
|
|
15
|
-
*
|
|
16
|
-
* 不在这里处理的(需要改 SDK 源码):
|
|
17
|
-
* - XMLHttpRequest → 在 index.js 中直接引用 http-request.js
|
|
18
|
-
* - unhandled rejection → 在 index.js send() 方法中加 .catch
|
|
19
|
-
* - OPENAGENT logger → 已有 globalThis.__OPENAGENT_SDK_LOGGER 机制
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import WS from "ws";
|
|
23
|
-
import { installStorage } from "./storage.js";
|
|
24
|
-
|
|
25
|
-
// ─── 替换 WebSocket(禁用 permessage-deflate)──────────────
|
|
26
|
-
// 根因:Node.js v22 内置 WebSocket 自动协商 permessage-deflate 扩展,
|
|
27
|
-
// 导致某些 WebSocket 帧(特别是 million_group_open_http_svc 社区群协议)
|
|
28
|
-
// 的响应数据被损坏或丢失。浏览器 WebSocket 不支持此扩展,SDK 设计时
|
|
29
|
-
// 假设接收的是未经传输层压缩的原始数据。
|
|
30
|
-
// 解决方案:用 ws npm 包替代内置 WebSocket,显式关闭 perMessageDeflate。
|
|
31
|
-
globalThis.WebSocket = class OpenAgentWebSocket extends WS {
|
|
32
|
-
constructor(url, protocols) {
|
|
33
|
-
super(url, protocols, { perMessageDeflate: false });
|
|
34
|
-
this.binaryType = "arraybuffer";
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// ─── 安装 localStorage ────────────────────────────────────
|
|
39
|
-
installStorage();
|
|
40
|
-
|
|
41
|
-
// ─── unhandledRejection 安全网 ────────────────────────────
|
|
42
|
-
// 即使 SDK 内部的 send() 已加 p.catch(),仍需全局兜底
|
|
43
|
-
// 以防其他代码路径产生 unhandled rejection
|
|
44
|
-
if (!globalThis.__OPENAGENT_REJECTION_HANDLER_INSTALLED) {
|
|
45
|
-
process.on("unhandledRejection", (reason) => {
|
|
46
|
-
const code = reason?.code || "UNKNOWN";
|
|
47
|
-
const msg = reason?.message || "";
|
|
48
|
-
// 用 OPENAGENT logger(如果已注入)或 stderr
|
|
49
|
-
const logger = globalThis.__OPENAGENT_SDK_LOGGER;
|
|
50
|
-
if (logger) {
|
|
51
|
-
logger.warn(`[SDK] unhandled rejection: code=${code} ${msg}`);
|
|
52
|
-
} else {
|
|
53
|
-
console.error(`[SDK] unhandled rejection: code=${code} ${msg}`);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
globalThis.__OPENAGENT_REJECTION_HANDLER_INSTALLED = true;
|
|
57
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* node-env/storage.js
|
|
3
|
-
*
|
|
4
|
-
* 替代浏览器 localStorage,用内存 Map 实现。
|
|
5
|
-
* SDK 通过 StorageModule(index.js L11400区)使用 localStorage。
|
|
6
|
-
*
|
|
7
|
-
* 原始 SDK 通过 _canIUseCookies() 检测:
|
|
8
|
-
* typeof window !== "undefined" && navigator.cookieEnabled && localStorage
|
|
9
|
-
* 在 Node.js 下返回 false → 所有存储操作被跳过。
|
|
10
|
-
*
|
|
11
|
-
* 本模块提供一个 localStorage 兼容对象。
|
|
12
|
-
* 使用方式:在 SDK import 前设置 globalThis.localStorage。
|
|
13
|
-
* 同时需要设置 globalThis.navigator.cookieEnabled = true。
|
|
14
|
-
*
|
|
15
|
-
* 注意:这是内存实现,进程退出后数据丢失。
|
|
16
|
-
* 对 Agent 场景足够——不需要跨进程持久化。
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
const _store = new Map();
|
|
20
|
-
|
|
21
|
-
const memoryStorage = {
|
|
22
|
-
getItem(key) {
|
|
23
|
-
return _store.has(key) ? _store.get(key) : null;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
setItem(key, value) {
|
|
27
|
-
_store.set(key, String(value));
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
removeItem(key) {
|
|
31
|
-
_store.delete(key);
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
clear() {
|
|
35
|
-
_store.clear();
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
get length() {
|
|
39
|
-
return _store.size;
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
key(index) {
|
|
43
|
-
const keys = [..._store.keys()];
|
|
44
|
-
return index < keys.length ? keys[index] : null;
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 支持 for...in 遍历(SDK L11445: for (let e in localStorage))
|
|
49
|
-
* 通过 Proxy 在 install() 时实现
|
|
50
|
-
*/
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 安装 localStorage polyfill 到 globalThis。
|
|
55
|
-
* 使用 Proxy 支持 for...in 遍历和 hasOwnProperty 调用。
|
|
56
|
-
*
|
|
57
|
-
* 必须在 SDK import 之前调用。
|
|
58
|
-
*/
|
|
59
|
-
export function installStorage() {
|
|
60
|
-
// Proxy 让 for...in 和 hasOwnProperty 工作
|
|
61
|
-
const storageProxy = new Proxy(memoryStorage, {
|
|
62
|
-
ownKeys() {
|
|
63
|
-
return [..._store.keys()];
|
|
64
|
-
},
|
|
65
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
66
|
-
if (_store.has(prop)) {
|
|
67
|
-
return {
|
|
68
|
-
configurable: true,
|
|
69
|
-
enumerable: true,
|
|
70
|
-
value: _store.get(prop),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
if (prop in target) {
|
|
74
|
-
return Object.getOwnPropertyDescriptor(target, prop);
|
|
75
|
-
}
|
|
76
|
-
return undefined;
|
|
77
|
-
},
|
|
78
|
-
has(target, prop) {
|
|
79
|
-
return _store.has(prop) || prop in target;
|
|
80
|
-
},
|
|
81
|
-
get(target, prop) {
|
|
82
|
-
if (prop === "hasOwnProperty") {
|
|
83
|
-
return (key) => _store.has(key);
|
|
84
|
-
}
|
|
85
|
-
if (prop in target) {
|
|
86
|
-
const val = target[prop];
|
|
87
|
-
return typeof val === "function" ? val.bind(target) : val;
|
|
88
|
-
}
|
|
89
|
-
return _store.get(prop);
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
globalThis.localStorage = storageProxy;
|
|
94
|
-
|
|
95
|
-
// navigator.cookieEnabled 让 _canIUseCookies() 返回 true
|
|
96
|
-
if (typeof globalThis.navigator === "undefined") {
|
|
97
|
-
globalThis.navigator = {};
|
|
98
|
-
}
|
|
99
|
-
globalThis.navigator.cookieEnabled = true;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 获取内部 store 的大小(调试用)
|
|
104
|
-
*/
|
|
105
|
-
export function getStorageSize() {
|
|
106
|
-
return _store.size;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* 导出内存 store 的快照(调试用)
|
|
111
|
-
*/
|
|
112
|
-
export function getStorageSnapshot() {
|
|
113
|
-
return Object.fromEntries(_store);
|
|
114
|
-
}
|
package/src/sdk/package.json
DELETED
package/src/sdk/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "ES2020",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"strict": false,
|
|
7
|
-
"noImplicitAny": false,
|
|
8
|
-
"noEmit": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"allowJs": true,
|
|
12
|
-
"checkJs": false
|
|
13
|
-
},
|
|
14
|
-
"include": ["./*.ts"],
|
|
15
|
-
"exclude": ["./modules/*"]
|
|
16
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StateStore → OasnInvocation.PendingInvocationStore 适配器
|
|
3
|
-
*
|
|
4
|
-
* 设计依据:docs/specs/2026-06-16-oasn-transport-abstraction-design.md §11.1
|
|
5
|
-
*
|
|
6
|
-
* 把 SQLite-backed StateStore 的 pending_invocations CRUD 方法包装成
|
|
7
|
-
* OasnInvocation 模块需要的 PendingInvocationStore 接口形状。
|
|
8
|
-
*
|
|
9
|
-
* 拆出独立适配器的好处:
|
|
10
|
-
* 1. OasnInvocation 不直接依赖 StateStore 类型 —— 子模块测试时可注入纯内存假实现
|
|
11
|
-
* 2. 后续若多账号场景需要切表/前缀,可以在此层做隔离,不污染 StateStore 主接口
|
|
12
|
-
* 3. 启动时续轮询逻辑(扫描 listUnsettledInvocations)放在 AccountRuntime 里调用,
|
|
13
|
-
* 适配器只承担运行时单条 CRUD,职责清晰
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import type { PendingInvocationStore } from '../transport/oasn/index.js';
|
|
17
|
-
import type { StateStore } from './store.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 适配 StateStore 暴露 PendingInvocationStore 接口。
|
|
21
|
-
*
|
|
22
|
-
* 用法:
|
|
23
|
-
* const store = new StateStore();
|
|
24
|
-
* await store.init(accountId);
|
|
25
|
-
* const pending = createPendingInvocationStore(store);
|
|
26
|
-
* const transport = createTransport({ ..., pendingStore: pending });
|
|
27
|
-
*/
|
|
28
|
-
export function createPendingInvocationStore(store: StateStore): PendingInvocationStore {
|
|
29
|
-
return {
|
|
30
|
-
getPending(toolCallId) {
|
|
31
|
-
return store.getPendingInvocation(toolCallId);
|
|
32
|
-
},
|
|
33
|
-
upsertPending(record) {
|
|
34
|
-
store.upsertPendingInvocation(record);
|
|
35
|
-
},
|
|
36
|
-
markTerminal(invocationId, status) {
|
|
37
|
-
store.markPendingInvocationTerminal(invocationId, status);
|
|
38
|
-
},
|
|
39
|
-
markAbandoned(invocationId) {
|
|
40
|
-
store.markPendingInvocationAbandoned(invocationId);
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|