openclaw-openagent 1.0.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/index.ts +114 -0
- package/openclaw.plugin.json +159 -0
- package/package.json +79 -0
- package/skills/clawlink/SKILL.md +145 -0
- package/skills/clawlink/SKILL.md.bak +165 -0
- package/src/app/channel-tools.ts +249 -0
- package/src/app/discovery-tools.ts +273 -0
- package/src/app/hooks.ts +60 -0
- package/src/app/index.ts +78 -0
- package/src/app/messaging-tools.ts +79 -0
- package/src/app/ops-tools.ts +155 -0
- package/src/app/remote-agent-tool.ts +476 -0
- package/src/app/types.ts +67 -0
- package/src/app/verbose-preflight.ts +190 -0
- package/src/auth/config.ts +197 -0
- package/src/auth/credential-manager.ts +146 -0
- package/src/auth/index.ts +24 -0
- package/src/auth/verify.ts +99 -0
- package/src/channel.ts +565 -0
- package/src/compat.ts +82 -0
- package/src/config/config-schema.ts +39 -0
- package/src/messaging/aggregator.ts +120 -0
- package/src/messaging/collector.ts +89 -0
- package/src/messaging/executor.ts +72 -0
- package/src/messaging/inbound.ts +150 -0
- package/src/messaging/index.ts +11 -0
- package/src/messaging/mention-protocol.ts +94 -0
- package/src/messaging/process-c2c-request.ts +564 -0
- package/src/messaging/process-message.ts +373 -0
- package/src/messaging/scheduler.ts +55 -0
- package/src/messaging/types.ts +38 -0
- package/src/plugin-ui/assets/agentbook-icon.svg +5 -0
- package/src/plugin-ui/assets/magic.svg +5 -0
- package/src/plugin-ui/assets/openagent-override.js +9329 -0
- package/src/plugin-ui/build.cjs +175 -0
- package/src/plugin-ui/index.ts +18 -0
- package/src/plugin-ui/modules/agent-book/panel/agent-book.js +458 -0
- package/src/plugin-ui/modules/agent-book/panel/agent-card.js +154 -0
- package/src/plugin-ui/modules/agent-book/panel/agent-data.js +644 -0
- package/src/plugin-ui/modules/agent-book/panel/inject-ui.js +456 -0
- package/src/plugin-ui/modules/agent-book/panel/mention-state.js +206 -0
- package/src/plugin-ui/modules/agent-book/panel/styles.js +670 -0
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/components-core.js +293 -0
- package/src/plugin-ui/modules/agent-book/remote-agent-tool/thought-chain-card.js +208 -0
- package/src/plugin-ui/modules/agent-book/scanner.js +119 -0
- package/src/plugin-ui/modules/agent-book/travelcard/travel-cards.js +500 -0
- package/src/plugin-ui/modules/agent-book/travelcard/travel-engine.js +652 -0
- package/src/plugin-ui/modules/agent-book/travelcard/travel-styles.js +251 -0
- package/src/plugin-ui/modules/loader/bootstrap.js +38 -0
- package/src/plugin-ui/modules/loader/shared-state.js +560 -0
- package/src/plugin-ui/modules/loader/ws-intercept.js +199 -0
- package/src/plugin-ui/modules/remote-agent/chunk-parser.js +161 -0
- package/src/plugin-ui/modules/remote-agent/execution-card.js +269 -0
- package/src/plugin-ui/modules/remote-agent/markdown-renderer.js +256 -0
- package/src/plugin-ui/modules/remote-agent/native-style-adapter.js +146 -0
- package/src/plugin-ui/modules/remote-agent/output-card.js +259 -0
- package/src/plugin-ui/modules/remote-agent/progress-store.js +363 -0
- package/src/plugin-ui/modules/remote-agent/render-hooks.js +1609 -0
- package/src/plugin-ui/modules/remote-agent/styles.js +668 -0
- package/src/plugin-ui/modules/remote-agent/tool-card-model.js +56 -0
- package/src/plugin-ui/ui-extension-loader/backup.ts +92 -0
- package/src/plugin-ui/ui-extension-loader/index.ts +276 -0
- package/src/plugin-ui/ui-extension-loader/locator.ts +152 -0
- package/src/plugin-ui/ui-extension-loader/manifest.ts +57 -0
- package/src/plugin-ui/ui-extension-loader/registry-regex.ts +729 -0
- package/src/plugin-ui/ui-extension-loader/removed-extensions.ts +70 -0
- package/src/plugin-ui/ui-extension-loader/types.ts +68 -0
- package/src/proxy/auth-proxy.ts +356 -0
- package/src/runtime/account.ts +572 -0
- package/src/runtime/index.ts +7 -0
- package/src/runtime/plugin-runtime.ts +94 -0
- package/src/runtime/registry.ts +71 -0
- package/src/sdk/CLASS_MAP.md +143 -0
- package/src/sdk/index.d.ts +126 -0
- package/src/sdk/index.js +23990 -0
- package/src/sdk/modules/cloud-search-module.js +1117 -0
- package/src/sdk/modules/follow-module.js +1069 -0
- package/src/sdk/modules/group-module.js +7397 -0
- package/src/sdk/modules/relationship-module.js +2269 -0
- package/src/sdk/modules/signaling-module.js +1468 -0
- package/src/sdk/modules/tim-upload-plugin.js +730 -0
- package/src/sdk/node-env/http-request.js +90 -0
- package/src/sdk/node-env/index.js +57 -0
- package/src/sdk/node-env/storage.js +114 -0
- package/src/sdk/package.json +10 -0
- package/src/sdk/tsconfig.json +16 -0
- package/src/state/pending-invocation-store.ts +43 -0
- package/src/state/store.ts +676 -0
- package/src/tim/c2c.ts +451 -0
- package/src/tim/channels.ts +364 -0
- package/src/tim/client.ts +330 -0
- package/src/tim/index.ts +18 -0
- package/src/tim/messages.ts +166 -0
- package/src/tim/sdk-logger-init.ts +50 -0
- package/src/tools.ts +10 -0
- package/src/transport/factory.ts +95 -0
- package/src/transport/oasn/index.ts +17 -0
- package/src/transport/oasn/oasn-agent-card.ts +111 -0
- package/src/transport/oasn/oasn-discovery.ts +108 -0
- package/src/transport/oasn/oasn-files.ts +210 -0
- package/src/transport/oasn/oasn-http.ts +483 -0
- package/src/transport/oasn/oasn-invocation.ts +527 -0
- package/src/transport/oasn/oasn-normalize.ts +159 -0
- package/src/transport/oasn/oasn-register.ts +106 -0
- package/src/transport/oasn/oasn-transport.ts +341 -0
- package/src/transport/oasn/oasn-types.ts +353 -0
- package/src/transport/tim/index.ts +8 -0
- package/src/transport/tim/tim-transport.ts +515 -0
- package/src/transport/types.ts +541 -0
- package/src/types/openclaw.d.ts +97 -0
- package/src/types/tencentcloud-chat.d.ts +15 -0
- package/src/util/http.ts +113 -0
- package/src/util/logger.ts +131 -0
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport ๆฅๅฃๅฎไนๅฑ โโ OASN/TIM ๅ่ฝจๆฝ่ฑก็"้ถไพ่ต"ๅบ็ก
|
|
3
|
+
*
|
|
4
|
+
* ่ฎพ่ฎกไพๆฎ๏ผdocs/specs/2026-06-16-oasn-transport-abstraction-design.md ยง2.1
|
|
5
|
+
*
|
|
6
|
+
* ่ฎพ่ฎกๅๅ๏ผInterface Segregation Principle๏ผ๏ผ
|
|
7
|
+
* ๆๅๆฌ"ๅกๅจไธไธช AgentTransport ๆฅๅฃ้"็ๆๆ่ฝๅๆๆ 6 ไธช่ฝๅๆฅๅฃ๏ผ
|
|
8
|
+
* ๅ็จ TypeScript intersection type ็ปๅๅบ OasnTransport / TimTransport๏ผ
|
|
9
|
+
* ่ๅไธบ AgentTransportใไธๅฑไปฃ็ ไพ่ตๆๅฐ่ฝๅ้ๅณๅฏ๏ผไธๅ้่ฆ
|
|
10
|
+
* `transport.foo?.()` ้ฒๅพกๅผ่ฐ็จ โโ ็ฑปๅ็ณป็ปๅจ็ผ่ฏๆๅฐฑไฟ่ฏ่ฐ็จๅๆณๆงใ
|
|
11
|
+
*
|
|
12
|
+
* ่ฝๅ โ ๅฎ็ฐ ็ฉ้ต๏ผ
|
|
13
|
+
*
|
|
14
|
+
* ่ฝๅๆฅๅฃ โ OasnTransport โ TimTransport
|
|
15
|
+
* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
16
|
+
* CoreTransport โ โ โ โ
|
|
17
|
+
* TaskTransport โ โ โ โ
|
|
18
|
+
* DiscoveryTransport โ โ โ โ
|
|
19
|
+
* RegistrationTransportโ โ โ โ
|
|
20
|
+
* FileTransport โ โ โ โ
|
|
21
|
+
* IMChannelTransport โ โ โ โ
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
25
|
+
// ๅญ่ฏๅฑ
|
|
26
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* ้็จไผ ่พๅญ่ฏใไธค็ง transport ๅจไธๅๅญๆฎต่ฏญไนไธๅค็จๅไธ็ปๆใ
|
|
30
|
+
*
|
|
31
|
+
* ๅญๆฎต โ OASN โ TIM
|
|
32
|
+
* โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
33
|
+
* identity โ agent_id (`agt_cli_*`) โ userId๏ผ= agentId๏ผ
|
|
34
|
+
* token โ api_key (`oak_*`) Bearer โ userSig
|
|
35
|
+
* expiresAt โ 0๏ผapi_key ไธ่ฟๆ๏ผ โ epoch ms๏ผๅซ 5min margin๏ผ
|
|
36
|
+
*
|
|
37
|
+
* ๆณจ๏ผๅฎ็ฐ็ธๅ
ณๅธธ้๏ผapiBase / sdkAppId ็ญ๏ผๅฑไบ"transport ๆ้ ๅๆฐ"๏ผ
|
|
38
|
+
* ไธ่ฟๅ
ฅๅญ่ฏ็ปๆ๏ผ้ฟๅ
่ฟ่กๆ Record<string, unknown> ็ฑปๅ้้ธใ
|
|
39
|
+
*/
|
|
40
|
+
export interface TransportCredentials {
|
|
41
|
+
/** OASN: agent_id๏ผTIM: userId */
|
|
42
|
+
identity: string;
|
|
43
|
+
/** OASN: api_key (Bearer)๏ผTIM: userSig */
|
|
44
|
+
token: string;
|
|
45
|
+
/** ่ฟๆๆถ้ดๆณ (epoch ms)ใOASN ้ๆ api_key = 0 */
|
|
46
|
+
expiresAt: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
50
|
+
// ไปปๅก่ฏทๆฑ / ็ปๆ
|
|
51
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* ๅ่ตทไธๆฌก่ฟ็จ Agent ่ฐ็จ็ๅ
ฅๅใ
|
|
55
|
+
*
|
|
56
|
+
* - OASN ่ทฏๅพ๏ผrequestId ไป
ๅๅฎขๆท็ซฏ trace๏ผๆๅก็ซฏ็จ idempotency_key + invocation_id ๆ ่ฏ่ฐ็จ
|
|
57
|
+
* - TIM ่ทฏๅพ๏ผrequestId ็ดๆฅไฝไธบ C2C ๅ
ณ่ id
|
|
58
|
+
*/
|
|
59
|
+
export interface TaskRequest {
|
|
60
|
+
/** ๅฎขๆท็ซฏ็ๆ็่ฏทๆฑ id๏ผไธ็ญๅไบ OASN ็ invocation_id๏ผ */
|
|
61
|
+
requestId: string;
|
|
62
|
+
/** ไปปๅกๆๆฌๅ
ๅฎน โโ LLM ๅทฅๅ
ท็ `task` ๅๆฐ */
|
|
63
|
+
task: string;
|
|
64
|
+
/**
|
|
65
|
+
* ็ปญไผ ๅทฒๆ session ๆถๅกซๅ
ฅใ
|
|
66
|
+
* - OASN: ็จไบๅจๅทฒๆ session ไธๅ ๅ ๆฐ Invocation
|
|
67
|
+
* - TIM: C2C ๆ session ๆฆๅฟต๏ผไผ ๅ
ฅๅณๅฟฝ็ฅ
|
|
68
|
+
*/
|
|
69
|
+
sessionId?: string;
|
|
70
|
+
/** ้ไปถๅผ็จๅ่กจ๏ผOASN file_ref๏ผTIM ๅฝๅไธๆฏๆ๏ผๅฟฝ็ฅ๏ผ */
|
|
71
|
+
inputFileRefs?: string[];
|
|
72
|
+
/** Artifact ๅผ็จๅ่กจ๏ผOASN-only๏ผ */
|
|
73
|
+
inputArtifactRefs?: string[];
|
|
74
|
+
/** OASN Invocation ๆๆๆง่ก่ถ
ๆถ๏ผๆๅก็ซฏไผ่ฃๅณไธบ effective_timeout_ms */
|
|
75
|
+
timeoutMs?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** ่ฟๅบฆๅ่ฐ่ฝฝ่ท */
|
|
79
|
+
export interface TaskProgress {
|
|
80
|
+
requestId: string;
|
|
81
|
+
/**
|
|
82
|
+
* ่ฟๅบฆๆๆฌใ
|
|
83
|
+
* - OASN: progress.safe_status_message
|
|
84
|
+
* - TIM: C2C `openagent_task_progress` ่ชๅฎไนๆถๆฏไธญ็ content
|
|
85
|
+
*/
|
|
86
|
+
content: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Artifact ๅผ็จ โโ ่ฟ็จ Agent ่ฟๅ็ไบง็ฉ๏ผๆไปถ/ไบ่ฟๅถ๏ผใ
|
|
91
|
+
* ไธๅฑ่ฅ้่ฆๅ
ๅฎน๏ผๅฟ
้กปๅๆฌก่ฐ็จ `FileTransport.downloadArtifact()` ๆๅใ
|
|
92
|
+
*/
|
|
93
|
+
export interface ArtifactRef {
|
|
94
|
+
id: string;
|
|
95
|
+
displayName: string;
|
|
96
|
+
mimeType: string;
|
|
97
|
+
sizeBytes: number;
|
|
98
|
+
/** ๆๅก็ซฏๆฏๅฆๅทฒๅฐฑ็ปชๅฏไธ่ฝฝใOASN ๆฅ่ช artifacts[].content_available */
|
|
99
|
+
contentAvailable: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* ๅ
ๅฎนๆๅๅฐๅใ
|
|
102
|
+
* - OASN: `${apiBase}/api/artifacts/{id}/content`๏ผ้ Bearer api_key๏ผ
|
|
103
|
+
* - TIM: TIM ๆๅกไธ่ฝฝ URL๏ผfetch ๅณๅพ๏ผ
|
|
104
|
+
*/
|
|
105
|
+
contentUrl: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** ไปปๅก็ปๆ */
|
|
109
|
+
export interface TaskResult {
|
|
110
|
+
requestId: string;
|
|
111
|
+
status: 'complete' | 'error';
|
|
112
|
+
/**
|
|
113
|
+
* ๆๆฌ็ปๆใ
|
|
114
|
+
* - OASN: inline_result.summary
|
|
115
|
+
* - TIM: C2C `openagent_task_result.content`
|
|
116
|
+
*/
|
|
117
|
+
content: string;
|
|
118
|
+
/** ไบง็ฉๅ่กจใๅฏ่ฝไธบ็ฉบ */
|
|
119
|
+
artifacts?: ArtifactRef[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* `sendTask` ่ฟๅๅผใๆบๅธฆๅฏ่งๅฏๆง id๏ผไพฟไบไธๅฑ trace + idempotency ็ปญ่ฝฎ่ฏขใ
|
|
124
|
+
*
|
|
125
|
+
* - OASN: ๅซ invocation_id / session_id / effective_timeout_ms
|
|
126
|
+
* - TIM: invocationId = requestId๏ผC2C ๆ ็ฌ็ซ invocation๏ผ๏ผๅ
ถไปๅญๆฎต undefined
|
|
127
|
+
*/
|
|
128
|
+
export interface TaskHandle {
|
|
129
|
+
/** OASN: invocation_id๏ผTIM: requestId */
|
|
130
|
+
invocationId: string;
|
|
131
|
+
/** OASN: session_id๏ผTIM: undefined */
|
|
132
|
+
sessionId?: string;
|
|
133
|
+
/** ๆๅก็ซฏ่ฃๅณๅ็ๅฎ้
่ถ
ๆถ๏ผOASN: effective_timeout_ms๏ผ */
|
|
134
|
+
effectiveTimeoutMs?: number;
|
|
135
|
+
/** ๆๅก็ซฏ้ฆ่ฝฎๅปบ่ฎฎ่ฝฎ่ฏข้ด้๏ผOASN: next_poll_after_ms๏ผ */
|
|
136
|
+
nextPollAfterMs?: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** ่ฟๅบฆๅ่ฐ็ญพๅ */
|
|
140
|
+
export type ProgressCallback = (progress: TaskProgress) => void;
|
|
141
|
+
|
|
142
|
+
/** ่ขซ่ฐ็ซฏไปปๅกๅค็ๅจ็ญพๅ๏ผOASN ไธไผ่งฆๅ๏ผไป
TIM ็ T3 ่ทฏๅพไฝฟ็จ๏ผ */
|
|
143
|
+
export type TaskHandler = (request: TaskRequest & { from: string }) => Promise<TaskResult>;
|
|
144
|
+
|
|
145
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
146
|
+
// ้่ฏฏ็ฑปๅ
|
|
147
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* ไผ ่พๅฑ็ปไธ้่ฏฏใHTTP ้่ฏฏ / SDK ้่ฏฏ้ฝๅจ transport ๅ
้จ่ฝฌๆขไธบๆญค็ฑปๅใ
|
|
151
|
+
*
|
|
152
|
+
* - OASN ๆฅๆบ๏ผๅๅบไฝ `error.{ code, message, retryable, details, request_id }`
|
|
153
|
+
* - TIM ๆฅๆบ๏ผSDK ้่ฏฏ code๏ผKICKED_OUT / NETWORK_TIMEOUT / ...๏ผ
|
|
154
|
+
*/
|
|
155
|
+
export interface TransportError extends Error {
|
|
156
|
+
/** ๅๅง้่ฏฏ็ */
|
|
157
|
+
code: string;
|
|
158
|
+
/** ๆฏๅฆๅฏ้่ฏ๏ผOASN ๆๅก็ซฏ่ฃๅณ๏ผTIM ็ฑๆฌๅฐๅคๆญ๏ผ */
|
|
159
|
+
retryable: boolean;
|
|
160
|
+
/** OASN: error.request_id๏ผTIM: SDK request id๏ผ่ฅๆ๏ผ */
|
|
161
|
+
requestId?: string;
|
|
162
|
+
/** ๅ
ณ่ invocation/session๏ผๅฆๆ๏ผ */
|
|
163
|
+
invocationId?: string;
|
|
164
|
+
sessionId?: string;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* ๆ้ TransportError ็ๅทฅๅใๅ transport ๅฎ็ฐๅ
้จ่ฐ็จใ
|
|
169
|
+
* ๆญคๅคๆพๅผๅฃฐๆไธบ function ่้ class๏ผๅ ไธบ TransportError ๆฏๆฅๅฃ่้ๅ
ทไฝ็ฑปๅใ
|
|
170
|
+
*/
|
|
171
|
+
export function makeTransportError(
|
|
172
|
+
code: string,
|
|
173
|
+
message: string,
|
|
174
|
+
opts: { retryable?: boolean; requestId?: string; invocationId?: string; sessionId?: string } = {},
|
|
175
|
+
): TransportError {
|
|
176
|
+
const err = new Error(message) as TransportError;
|
|
177
|
+
err.code = code;
|
|
178
|
+
err.retryable = opts.retryable ?? false;
|
|
179
|
+
if (opts.requestId) err.requestId = opts.requestId;
|
|
180
|
+
if (opts.invocationId) err.invocationId = opts.invocationId;
|
|
181
|
+
if (opts.sessionId) err.sessionId = opts.sessionId;
|
|
182
|
+
return err;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
186
|
+
// Agent ๅ็ฐ โโ AgentCard / ๆ็ดข
|
|
187
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* OASN AgentCard ๅ
ฌๅผ่งๅพใ
|
|
191
|
+
* ไธ OASN apis.md `GET /api/agent-cards/{agent_id}` ๅๅบๅญๆฎตไธไธๅฏน้ฝใ
|
|
192
|
+
*/
|
|
193
|
+
export interface AgentCard {
|
|
194
|
+
agent_id: string;
|
|
195
|
+
agent_type: 'client' | 'service';
|
|
196
|
+
name: string;
|
|
197
|
+
description: string | null;
|
|
198
|
+
/** Model Operation Manual โโ ไฝฟ็จ่ฏดๆ๏ผMarkdown๏ผ */
|
|
199
|
+
MOM: string | null;
|
|
200
|
+
tags: Array<{ tag_id: string; name: string }>;
|
|
201
|
+
category: string[];
|
|
202
|
+
avatar_url: string | null;
|
|
203
|
+
visibility?: 'public' | 'private';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** ๆ็ดข่ฏทๆฑใไธ็งๆ็ดขๆจกๅผ๏ผby-query / by-category / by-tags๏ผๅ
ฑ็จๅไธ็ปๆ๏ผ็ฑ้็ฉบๅญๆฎตๅคๅฎ่ตฐๅชไธช็ซฏ็น */
|
|
207
|
+
export interface SearchQuery {
|
|
208
|
+
/** ่ช็ถ่ฏญ่จ๏ผ`by-query`๏ผ */
|
|
209
|
+
query?: string;
|
|
210
|
+
/** category id ๆฐ็ป๏ผ`by-category`๏ผ */
|
|
211
|
+
category?: string[];
|
|
212
|
+
/** tag id ๆฐ็ป๏ผ`by-tags`๏ผ */
|
|
213
|
+
tags?: string[];
|
|
214
|
+
/** ้ป่ฎค `["service"]`ใๅฝๅ OASN search ๅชๆฏๆ service */
|
|
215
|
+
agentTypes?: string[];
|
|
216
|
+
sort?: Array<'relevance' | 'usage' | 'recency'>;
|
|
217
|
+
pageSize?: number;
|
|
218
|
+
pageNum?: number;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export interface SearchResult {
|
|
222
|
+
searchId: string;
|
|
223
|
+
agentCards: AgentCard[];
|
|
224
|
+
pageNum: number;
|
|
225
|
+
pageSize: number;
|
|
226
|
+
hasNext: boolean;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
230
|
+
// ๆณจๅ / ่ฎค้ข / Owner๏ผOASN-only๏ผ
|
|
231
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
232
|
+
|
|
233
|
+
/** `POST /api/agents/register` ๅๅบ */
|
|
234
|
+
export interface RegisterResult {
|
|
235
|
+
agent_id: string;
|
|
236
|
+
agent_type: 'client';
|
|
237
|
+
/** ไธๆฌกๆงๆๆ api_key โโ ๆไน
ๅๅๅฟ
้กป็ซๅณไปๅ
ๅญๆธ
็ */
|
|
238
|
+
api_key: string;
|
|
239
|
+
claim_url: string;
|
|
240
|
+
status: 'unclaimed';
|
|
241
|
+
agent_card: AgentCard;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** `POST /api/agents/claim` ่ฏทๆฑ */
|
|
245
|
+
export interface ClaimParams {
|
|
246
|
+
agent_id?: string;
|
|
247
|
+
/** ๆฅ่ช claim_url ๆซๆฎต๏ผไธ agent_id+api_key ไบ้ไธ๏ผ */
|
|
248
|
+
claim_token?: string;
|
|
249
|
+
owner_email: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface ClaimResult {
|
|
253
|
+
agent_id: string;
|
|
254
|
+
status: 'claim_email_sent';
|
|
255
|
+
owner_email_masked: string;
|
|
256
|
+
/** ้ฎไปถ้ช่ฏ้พๆฅ่ฟๆๆถ้ด๏ผISO 8601 ๅญ็ฌฆไธฒ๏ผ */
|
|
257
|
+
expires_at: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** `GET /api/agents/{agent_id}` ๅๅบ */
|
|
261
|
+
export interface AgentStatusResult {
|
|
262
|
+
agent_id: string;
|
|
263
|
+
status: 'unclaimed' | 'claim_pending' | 'claimed';
|
|
264
|
+
/** CA/ClientAgent access token, not Owner token. Runtime-only. */
|
|
265
|
+
access_token?: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** `PATCH /api/agent-cards/{agent_id}` ่ฏทๆฑใPATCH ่ฏญไน๏ผ็็ฅ=ไธๅ๏ผๆพๅผ null=ๆธ
็ฉบ */
|
|
269
|
+
export interface AgentCardPatch {
|
|
270
|
+
name?: string | null;
|
|
271
|
+
description?: string | null;
|
|
272
|
+
MOM?: string | null;
|
|
273
|
+
tags?: string[] | null;
|
|
274
|
+
category?: string[] | null;
|
|
275
|
+
avatar_ref?: string | null;
|
|
276
|
+
visibility?: 'public' | 'private';
|
|
277
|
+
public_metadata?: Record<string, unknown> | null;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Category ๆ ่็น */
|
|
281
|
+
export interface CategoryNode {
|
|
282
|
+
category_id: string;
|
|
283
|
+
name: string;
|
|
284
|
+
children?: CategoryNode[];
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface CategoryTree {
|
|
288
|
+
categories: CategoryNode[];
|
|
289
|
+
updated_at: string;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** `GET /api/users/me` ๅๅบ๏ผOwner ็ปดๅบฆ๏ผๆไปถๅฝๅไธป่ฆ่ตฐ Agent api_key๏ผ */
|
|
293
|
+
export interface OwnerInfo {
|
|
294
|
+
owner_id: string;
|
|
295
|
+
owner_type: string;
|
|
296
|
+
display_name: string;
|
|
297
|
+
email_masked: string;
|
|
298
|
+
email_verified_at?: string;
|
|
299
|
+
status: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
303
|
+
// ๆไปถ / Artifact๏ผOASN-only๏ผ
|
|
304
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
305
|
+
|
|
306
|
+
/** `POST /api/files` ่พๅ
ฅๅๆฐ */
|
|
307
|
+
export interface UploadFileParams {
|
|
308
|
+
/** ๆไปถๅ
ๅฎน๏ผๆต่งๅจ Blob ๆ Node Buffer๏ผ */
|
|
309
|
+
content: Blob | Buffer;
|
|
310
|
+
/** ๅฑ็คบๅ๏ผๅซๅ็ผ๏ผ */
|
|
311
|
+
displayName: string;
|
|
312
|
+
/** ็จ้ๆ ็ญพ๏ผinput / reference / ... */
|
|
313
|
+
purpose?: string;
|
|
314
|
+
/** ๆๆๅฏๅผ็จๆถ้ฟ๏ผ็ง๏ผ๏ผๆๅก็ซฏๆ็ป่ฃๅณ */
|
|
315
|
+
expiresInSeconds?: number;
|
|
316
|
+
/** MIME ็ฑปๅ๏ผๅฏ้๏ผๆชไผ ๆถๆๅก็ซฏๆจๆญ๏ผ */
|
|
317
|
+
mimeType?: string;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/** `POST /api/files` ๅๅบ */
|
|
321
|
+
export interface UploadFileResult {
|
|
322
|
+
/** ๅ็ปญ Invocation ็ input_file_refs ไฝฟ็จ */
|
|
323
|
+
fileRef: string;
|
|
324
|
+
displayName: string;
|
|
325
|
+
mimeType: string;
|
|
326
|
+
sizeBytes: number;
|
|
327
|
+
/** epoch ms */
|
|
328
|
+
expiresAt: number;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** Artifact ไธ่ฝฝ็ปๆ */
|
|
332
|
+
export interface DownloadArtifactResult {
|
|
333
|
+
content: ArrayBuffer;
|
|
334
|
+
mimeType: string;
|
|
335
|
+
displayName: string;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
339
|
+
// IM ้ข้๏ผTIM-only๏ผๅคๆฐๅฝๅ DORMANT๏ผ
|
|
340
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
341
|
+
|
|
342
|
+
export interface ChannelInfo {
|
|
343
|
+
id: string;
|
|
344
|
+
name: string;
|
|
345
|
+
desc: string;
|
|
346
|
+
memberCount?: number;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export interface MemberInfo {
|
|
350
|
+
id: string;
|
|
351
|
+
nick: string;
|
|
352
|
+
role: string;
|
|
353
|
+
avatar?: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** ็พค่ๆๆฌๆถๆฏ๏ผTIM-only๏ผ */
|
|
357
|
+
export interface TransportMessage {
|
|
358
|
+
id: string;
|
|
359
|
+
channelId: string;
|
|
360
|
+
from: string;
|
|
361
|
+
nick: string;
|
|
362
|
+
text: string;
|
|
363
|
+
/** epoch ms๏ผๆณจ๏ผTIM ๅๅงไธบ็ง๏ผ่ฝฌๆข็ฑ transport ๅฑๅฎๆ๏ผ */
|
|
364
|
+
time: number;
|
|
365
|
+
mentionsMe: boolean;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
369
|
+
// ไบไปถ็ฑปๅ
|
|
370
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
371
|
+
|
|
372
|
+
/** ไธค็ง transport ้ฝไผ่งฆๅ็ๆ ธๅฟไบไปถ */
|
|
373
|
+
export type CoreTransportEvent =
|
|
374
|
+
/** ๅญ่ฏๅคฑๆใOASN: 401 UNAUTHENTICATED๏ผTIM: KICKED_OUT */
|
|
375
|
+
| 'credential_expired'
|
|
376
|
+
/** ้่ฟๆๅ๏ผTIM ๆๆไน๏ผOASN ้ๅธธไธ่งฆๅ๏ผ */
|
|
377
|
+
| 'reconnected'
|
|
378
|
+
/** ่ฟๆฅๆญๅผ๏ผTIM ๆๆไน๏ผOASN ้ๅธธไธ่งฆๅ๏ผ */
|
|
379
|
+
| 'disconnected';
|
|
380
|
+
|
|
381
|
+
/** ไป
TIM transport ไผ่งฆๅ็ไบไปถ */
|
|
382
|
+
export type TimOnlyTransportEvent =
|
|
383
|
+
/** ็พค่ๆถๆฏๅฐ่พพ */
|
|
384
|
+
| 'message'
|
|
385
|
+
/** ๆถๅฐ่ฟ็จ agent ็ C2C ไปปๅก่ฏทๆฑ๏ผT3 ่ทฏๅพ๏ผ */
|
|
386
|
+
| 'task_received'
|
|
387
|
+
/** ไปปๅก่ฟๅบฆๆจ้๏ผC2C ๆฅๆถๆน๏ผ */
|
|
388
|
+
| 'task_progress';
|
|
389
|
+
|
|
390
|
+
export type TransportEvent = CoreTransportEvent | TimOnlyTransportEvent;
|
|
391
|
+
|
|
392
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
393
|
+
// ่ฝๅๆฅๅฃ
|
|
394
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* ๆ ธๅฟ็ๅฝๅจๆ โโ ไธค็ง transport ้ฝๅฎ็ฐใ
|
|
398
|
+
*
|
|
399
|
+
* `ready / isReady` ่ฏญไน็ปไธไธบ"ๅญ่ฏๅทฒๆ ก้ช๏ผๅฏๅทฅไฝ"๏ผ
|
|
400
|
+
* - OASN: api_key ้่ฟ GET /api/agent-cards/{agent_id} ้ช่ฏ
|
|
401
|
+
* - TIM: WS ๅทฒ login ไธ SDK_READY
|
|
402
|
+
*/
|
|
403
|
+
export interface CoreTransport {
|
|
404
|
+
/** ๅฎไพ id๏ผๅค่ดฆๆทๆฏๆๆถ็จไฝ key๏ผ */
|
|
405
|
+
readonly id: string;
|
|
406
|
+
readonly transportType: 'oasn' | 'tim';
|
|
407
|
+
|
|
408
|
+
/** ๆ ก้ชๅญ่ฏๅนถ่ฟๅ
ฅๅฏๅทฅไฝ็ถๆ */
|
|
409
|
+
ready(credentials: TransportCredentials): Promise<void>;
|
|
410
|
+
|
|
411
|
+
/** ้ๆพ่ตๆบ๏ผOASN: ๆธ
่ฝฎ่ฏข timer๏ผTIM: WS logout๏ผ */
|
|
412
|
+
dispose(): Promise<void>;
|
|
413
|
+
|
|
414
|
+
/** ๆฏๅฆๅคไบๅฏๅทฅไฝ็ถๆ */
|
|
415
|
+
readonly isReady: boolean;
|
|
416
|
+
|
|
417
|
+
on(event: CoreTransportEvent, handler: (...args: any[]) => void): void;
|
|
418
|
+
off(event: CoreTransportEvent, handler: (...args: any[]) => void): void;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
* ไปปๅก่ฐ็จ๏ผT2 ไธป่ทฏๅพ๏ผโโ ไธค็ง transport ้ฝๅฎ็ฐใ
|
|
423
|
+
*
|
|
424
|
+
* ๆณจๆ๏ผ่ฟๅ็ `TaskHandle` ็ฑ่ฐ็จๆนๆๆๅนถไผ ็ป `waitForTaskResult`ใ
|
|
425
|
+
* ไธๅฑไธ่ฆๅ่ฎพๅฎๆฏ็ฎๅ็ string id โโ OASN ้่ฆ invocation_id + session_id ่ๅจใ
|
|
426
|
+
*/
|
|
427
|
+
export interface TaskTransport {
|
|
428
|
+
/** ๅ่ตท่ฟ็จ่ฐ็จ */
|
|
429
|
+
sendTask(targetAgentId: string, task: TaskRequest): Promise<TaskHandle>;
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* ็ญๅพ
ไปปๅก็ปๆใ
|
|
433
|
+
* - OASN: ่ฝฎ่ฏข๏ผๆ SSE ๅ็บง๏ผ่ง่ฎพ่ฎกๆๆกฃ ยง11.8๏ผ
|
|
434
|
+
* - TIM: ้ปๅก็ญๅพ
C2C `openagent_task_result` ๆถๆฏ
|
|
435
|
+
*
|
|
436
|
+
* ่ถ
ๆถ็ฑ `options.timeoutMs` ๆงๅถ๏ผOASN ไธ effective_timeout_ms ๅ่ฐ๏ผ่ง ยง11.3๏ผใ
|
|
437
|
+
*/
|
|
438
|
+
waitForTaskResult(
|
|
439
|
+
handle: TaskHandle,
|
|
440
|
+
options: { timeoutMs: number; signal?: AbortSignal; onProgress?: ProgressCallback },
|
|
441
|
+
): Promise<TaskResult>;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** Agent ๅ็ฐ โโ ไธค็ง transport ้ฝๅฎ็ฐ๏ผTIM ๆ channel ๅ่กจไผช่ฃ
ๆ AgentCard๏ผ */
|
|
445
|
+
export interface DiscoveryTransport {
|
|
446
|
+
searchAgents(query: SearchQuery): Promise<SearchResult>;
|
|
447
|
+
getAgent(agentId: string): Promise<AgentCard | null>;
|
|
448
|
+
/** Category ๆ ๏ผOASN-only๏ผTIM ๅฎ็ฐๅฏ่ฟๅ็ฉบๆ ๏ผ */
|
|
449
|
+
getCategories?(params?: { agentType?: string }): Promise<CategoryTree>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/** Agent ๆณจๅไธ็ฎก็ โโ OASN-only */
|
|
453
|
+
export interface RegistrationTransport {
|
|
454
|
+
/** `POST /api/agents/register`ใinstall_id ็ฑ ยง11.7 ้ฒๅญคๅฟๆบๅถๆไพ */
|
|
455
|
+
registerAgent(
|
|
456
|
+
platform: string,
|
|
457
|
+
params?: { installId?: string; deviceHint?: string },
|
|
458
|
+
): Promise<RegisterResult>;
|
|
459
|
+
claimAgent(params: ClaimParams): Promise<ClaimResult>;
|
|
460
|
+
getAgentStatus(agentId: string): Promise<AgentStatusResult>;
|
|
461
|
+
updateAgentCard(agentId: string, patch: AgentCardPatch): Promise<AgentCard>;
|
|
462
|
+
getCurrentOwner?(): Promise<OwnerInfo | null>;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/** ๆไปถ / Artifact โโ OASN-only */
|
|
466
|
+
export interface FileTransport {
|
|
467
|
+
/** ไธไผ ๆไปถ๏ผ่ฟๅ file_ref๏ผๅซ LRU ็ผๅญ๏ผ่ง่ฎพ่ฎกๆๆกฃ ยง11.4๏ผ */
|
|
468
|
+
uploadFile(file: UploadFileParams): Promise<UploadFileResult>;
|
|
469
|
+
/** ไธ่ฝฝ Artifact ไบ่ฟๅถๅ
ๅฎน */
|
|
470
|
+
downloadArtifact(artifactId: string): Promise<DownloadArtifactResult>;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** IM ็พค่ไธ้ข้็ฎก็ โโ TIM-only */
|
|
474
|
+
export interface IMChannelTransport {
|
|
475
|
+
/** TIM-only ไบไปถ่ฎข้
*/
|
|
476
|
+
on(event: TimOnlyTransportEvent, handler: (...args: any[]) => void): void;
|
|
477
|
+
off(event: TimOnlyTransportEvent, handler: (...args: any[]) => void): void;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* ๆฅๆถ่ฟ็จ agent ไปปๅก๏ผT3 ่ทฏๅพ๏ผใ
|
|
481
|
+
* OASN ๆ ๆญค่ฝๅ โโ ClientAgent ๆฏๆถ่ดน่
ไพง๏ผไธๆฅๆถๅคๆฅ Invocationใ
|
|
482
|
+
*/
|
|
483
|
+
onTaskReceived(handler: TaskHandler): void;
|
|
484
|
+
|
|
485
|
+
/** ็พค่ๅๆๆฌ๏ผๆฏๆ @ ๏ผ */
|
|
486
|
+
sendGroupMessage(
|
|
487
|
+
channelId: string,
|
|
488
|
+
text: string,
|
|
489
|
+
atUserList?: string[],
|
|
490
|
+
): Promise<{ ok: boolean; messageId: string }>;
|
|
491
|
+
|
|
492
|
+
/** ๆๅ็พคๅๅฒ */
|
|
493
|
+
fetchGroupHistory(channelId: string, count?: number): Promise<TransportMessage[]>;
|
|
494
|
+
|
|
495
|
+
// ไปฅไธๆนๆณๅจๅฝๅไธๅก้ DORMANT โโ ๆฅๅฃไฟ็ไธบ optional๏ผ่ฟ่กๆถไธๆฟๆดป
|
|
496
|
+
listChannels?(): Promise<ChannelInfo[]>;
|
|
497
|
+
searchChannels?(keyword: string): Promise<ChannelInfo[]>;
|
|
498
|
+
joinChannel?(channelId: string): Promise<{ success: boolean; message: string }>;
|
|
499
|
+
leaveChannel?(channelId: string): Promise<{ success: boolean; message: string }>;
|
|
500
|
+
getMembers?(channelId: string): Promise<MemberInfo[]>;
|
|
501
|
+
createChannel?(name: string, desc?: string): Promise<{ success: boolean; channelId: string }>;
|
|
502
|
+
getChannelSkill?(channelId: string): Promise<string | null>;
|
|
503
|
+
setChannelSkill?(channelId: string, skill: string): Promise<{ success: boolean }>;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
507
|
+
// ๅฎ็ฐไพง่ๅ็ฑปๅ
|
|
508
|
+
// โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* OASN transport ็ๅฎ้
่ฝๅ้ๅ โโ
|
|
512
|
+
* ๅซๆ ธๅฟ็ๅฝๅจๆ + ไปปๅก่ฐ็จ + ๅ็ฐ + ๆณจๅ/่ฎค้ข + ๆไปถ๏ผไธๅซ IM ็พค่ใ
|
|
513
|
+
*/
|
|
514
|
+
export type OasnTransport =
|
|
515
|
+
& CoreTransport
|
|
516
|
+
& TaskTransport
|
|
517
|
+
& DiscoveryTransport
|
|
518
|
+
& RegistrationTransport
|
|
519
|
+
& FileTransport;
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* TIM transport ็ๅฎ้
่ฝๅ้ๅ โโ
|
|
523
|
+
* ๅซๆ ธๅฟ็ๅฝๅจๆ + ไปปๅก่ฐ็จ + ๅ็ฐ + IM ็พค่๏ผไธๅซ OASN ๆณจๅ/ๆไปถใ
|
|
524
|
+
*/
|
|
525
|
+
export type TimTransport =
|
|
526
|
+
& CoreTransport
|
|
527
|
+
& TaskTransport
|
|
528
|
+
& DiscoveryTransport
|
|
529
|
+
& IMChannelTransport;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* ไธๅฑ่ฐ็จๆนๆๆ็่ๅ็ฑปๅใ
|
|
533
|
+
*
|
|
534
|
+
* ไฝฟ็จ่ง่๏ผ
|
|
535
|
+
* - ๅช็จ Core/Task/Discovery ่ฝๅ โ ็ดๆฅๆฅๆถ AgentTransport
|
|
536
|
+
* - ้่ฆ OASN-only ่ฝๅ๏ผๆณจๅ/ๆไปถ๏ผโ ้่ฟ `transport.transportType === 'oasn'` narrow
|
|
537
|
+
* - ้่ฆ TIM-only ่ฝๅ๏ผ็พค่/T3๏ผโ ้่ฟ `transport.transportType === 'tim'` narrow
|
|
538
|
+
*
|
|
539
|
+
* ไธ่ฆไฝฟ็จ `transport.foo?.()` ้ฒๅพกๅผ่ฐ็จ โโ ็จ transportType ๅจ็ผ่ฏๆ narrowใ
|
|
540
|
+
*/
|
|
541
|
+
export type AgentTransport = OasnTransport | TimTransport;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal type declarations for openclaw peer dependency.
|
|
3
|
+
* Only declares the APIs actually used by this plugin.
|
|
4
|
+
*
|
|
5
|
+
* These stubs allow `tsc --noEmit` to pass in environments where
|
|
6
|
+
* openclaw is not installed (e.g. npm pack / CI).
|
|
7
|
+
* At runtime, the real openclaw package provides the implementations.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare module 'openclaw/plugin-sdk/infra-runtime' {
|
|
11
|
+
export function resolvePreferredOpenClawTmpDir(): string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module 'openclaw/plugin-sdk/plugin-entry' {
|
|
15
|
+
export interface OpenClawPluginApi {
|
|
16
|
+
runtime?: import('openclaw/plugin-sdk/core').PluginRuntime;
|
|
17
|
+
registerChannel(opts: { plugin: unknown }): void;
|
|
18
|
+
registerTool(factory: unknown, opts?: { optional?: boolean }): void;
|
|
19
|
+
registerHook?(hook: unknown): void;
|
|
20
|
+
registerHttpRoute(params: {
|
|
21
|
+
path: string;
|
|
22
|
+
auth: 'gateway' | 'plugin';
|
|
23
|
+
match?: 'exact' | 'prefix';
|
|
24
|
+
replaceExisting?: boolean;
|
|
25
|
+
handler: (req: import('node:http').IncomingMessage, res: import('node:http').ServerResponse) => Promise<boolean> | boolean;
|
|
26
|
+
}): void;
|
|
27
|
+
registrationMode?: string;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module 'openclaw/plugin-sdk/channel-config-schema' {
|
|
32
|
+
export function buildChannelConfigSchema(schema: unknown): unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
declare module 'openclaw/plugin-sdk/core' {
|
|
36
|
+
export interface PluginRuntime {
|
|
37
|
+
version?: string;
|
|
38
|
+
channel: {
|
|
39
|
+
routing: {
|
|
40
|
+
resolveAgentRoute(params: {
|
|
41
|
+
cfg: unknown;
|
|
42
|
+
channel: string;
|
|
43
|
+
accountId: string;
|
|
44
|
+
peer: { kind: string; id: string };
|
|
45
|
+
}): {
|
|
46
|
+
agentId?: string;
|
|
47
|
+
sessionKey?: string;
|
|
48
|
+
mainSessionKey?: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
reply: {
|
|
52
|
+
finalizeInboundContext(ctx: unknown): unknown;
|
|
53
|
+
createReplyDispatcherWithTyping(opts: {
|
|
54
|
+
deliver: (
|
|
55
|
+
payload: { text?: string; mediaUrl?: string; mediaUrls?: string[] },
|
|
56
|
+
meta?: { kind?: string },
|
|
57
|
+
) => Promise<void>;
|
|
58
|
+
onError?: (err: unknown, info: { kind: string }) => void;
|
|
59
|
+
}): {
|
|
60
|
+
dispatcher: unknown;
|
|
61
|
+
replyOptions: Record<string, unknown>;
|
|
62
|
+
markDispatchIdle: () => void;
|
|
63
|
+
};
|
|
64
|
+
withReplyDispatcher(opts: { dispatcher: unknown; run: () => Promise<void> }): Promise<void>;
|
|
65
|
+
dispatchReplyFromConfig(opts: {
|
|
66
|
+
ctx: unknown;
|
|
67
|
+
cfg: unknown;
|
|
68
|
+
dispatcher: unknown;
|
|
69
|
+
replyOptions?: Record<string, unknown>;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
};
|
|
72
|
+
session: {
|
|
73
|
+
resolveStorePath(store: unknown, opts: { agentId: string }): string;
|
|
74
|
+
recordInboundSession(opts: {
|
|
75
|
+
storePath: string;
|
|
76
|
+
sessionKey?: string;
|
|
77
|
+
ctx: unknown;
|
|
78
|
+
updateLastRoute?: {
|
|
79
|
+
sessionKey?: string;
|
|
80
|
+
channel: string;
|
|
81
|
+
to: string;
|
|
82
|
+
accountId: string;
|
|
83
|
+
};
|
|
84
|
+
onRecordError?: (err: unknown) => void;
|
|
85
|
+
}): Promise<void>;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
events: {
|
|
89
|
+
onAgentEvent(listener: (evt: {
|
|
90
|
+
sessionKey?: string;
|
|
91
|
+
stream?: string;
|
|
92
|
+
data: { phase?: string; partialResult?: unknown; [key: string]: unknown };
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
}) => void): () => void;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for local SDK modules
|
|
3
|
+
*
|
|
4
|
+
* These are JS-only modules bundled in src/sdk/ that need
|
|
5
|
+
* minimal type stubs for TypeScript compilation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare module '../sdk/modules/group-module.js' {
|
|
9
|
+
const GroupModule: unknown;
|
|
10
|
+
export default GroupModule;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '../sdk/node-env/index.js' {
|
|
14
|
+
// Side-effect only module โ installs ws WebSocket, localStorage, rejection handler
|
|
15
|
+
}
|