@oharness/engine 0.1.0 → 0.2.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.
Files changed (90) hide show
  1. package/README.md +26 -0
  2. package/dist/agent/agent.d.ts +11 -0
  3. package/dist/agent/agent.js +30 -9
  4. package/dist/agent/agent.js.map +1 -1
  5. package/dist/agent/hooks.d.ts +2 -0
  6. package/dist/agent/hooks.js +11 -0
  7. package/dist/agent/hooks.js.map +1 -1
  8. package/dist/agent/memory.d.ts +10 -1
  9. package/dist/agent/memory.js +147 -49
  10. package/dist/agent/memory.js.map +1 -1
  11. package/dist/agent/permissions.js +21 -3
  12. package/dist/agent/permissions.js.map +1 -1
  13. package/dist/artifacts/publish.d.ts +2 -2
  14. package/dist/artifacts/publish.js +2 -2
  15. package/dist/auth/index.d.ts +1 -1
  16. package/dist/auth/index.js +1 -1
  17. package/dist/auth/index.js.map +1 -1
  18. package/dist/auth/manager.d.ts +14 -0
  19. package/dist/auth/manager.js +25 -5
  20. package/dist/auth/manager.js.map +1 -1
  21. package/dist/auth/providers/account.d.ts +10 -45
  22. package/dist/auth/providers/account.js +123 -233
  23. package/dist/auth/providers/account.js.map +1 -1
  24. package/dist/config-files.d.ts +27 -0
  25. package/dist/config-files.js +116 -0
  26. package/dist/config-files.js.map +1 -0
  27. package/dist/config.d.ts +5 -25
  28. package/dist/config.js +16 -2
  29. package/dist/config.js.map +1 -1
  30. package/dist/core/audit.d.ts +20 -0
  31. package/dist/core/audit.js +2 -0
  32. package/dist/core/audit.js.map +1 -0
  33. package/dist/harness.d.ts +35 -2
  34. package/dist/harness.js +162 -50
  35. package/dist/harness.js.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.js +1 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/providers/registry.d.ts +42 -0
  40. package/dist/providers/registry.js +71 -9
  41. package/dist/providers/registry.js.map +1 -1
  42. package/dist/runtime-plugins/audit.d.ts +11 -0
  43. package/dist/runtime-plugins/audit.js +31 -0
  44. package/dist/runtime-plugins/audit.js.map +1 -0
  45. package/dist/runtime-plugins/builtin/jsonl-audit.d.ts +7 -0
  46. package/dist/runtime-plugins/builtin/jsonl-audit.js +24 -0
  47. package/dist/runtime-plugins/builtin/jsonl-audit.js.map +1 -0
  48. package/dist/runtime-plugins/builtin/memory.d.ts +70 -0
  49. package/dist/runtime-plugins/builtin/memory.js +360 -0
  50. package/dist/runtime-plugins/builtin/memory.js.map +1 -0
  51. package/dist/runtime-plugins/cloud-connector.d.ts +56 -0
  52. package/dist/runtime-plugins/cloud-connector.js +261 -0
  53. package/dist/runtime-plugins/cloud-connector.js.map +1 -0
  54. package/dist/runtime-plugins/composio/client.d.ts +65 -0
  55. package/dist/runtime-plugins/composio/client.js +190 -0
  56. package/dist/runtime-plugins/composio/client.js.map +1 -0
  57. package/dist/runtime-plugins/composio/index.d.ts +23 -0
  58. package/dist/runtime-plugins/composio/index.js +113 -0
  59. package/dist/runtime-plugins/composio/index.js.map +1 -0
  60. package/dist/runtime-plugins/connector.d.ts +15 -0
  61. package/dist/runtime-plugins/connector.js +17 -0
  62. package/dist/runtime-plugins/connector.js.map +1 -0
  63. package/dist/runtime-plugins/extensions.d.ts +21 -0
  64. package/dist/runtime-plugins/extensions.js +23 -0
  65. package/dist/runtime-plugins/extensions.js.map +1 -0
  66. package/dist/runtime-plugins/host.d.ts +34 -0
  67. package/dist/runtime-plugins/host.js +263 -0
  68. package/dist/runtime-plugins/host.js.map +1 -0
  69. package/dist/runtime-plugins/index.d.ts +12 -0
  70. package/dist/runtime-plugins/index.js +7 -0
  71. package/dist/runtime-plugins/index.js.map +1 -0
  72. package/dist/runtime-plugins/loader.d.ts +5 -0
  73. package/dist/runtime-plugins/loader.js +36 -0
  74. package/dist/runtime-plugins/loader.js.map +1 -0
  75. package/dist/runtime-plugins/tool-adapter.d.ts +3 -0
  76. package/dist/runtime-plugins/tool-adapter.js +13 -0
  77. package/dist/runtime-plugins/tool-adapter.js.map +1 -0
  78. package/dist/runtime-plugins/types.d.ts +81 -0
  79. package/dist/runtime-plugins/types.js +2 -0
  80. package/dist/runtime-plugins/types.js.map +1 -0
  81. package/dist/sync/settings.d.ts +2 -0
  82. package/dist/sync/settings.js +17 -1
  83. package/dist/sync/settings.js.map +1 -1
  84. package/dist/tools/registry.d.ts +2 -0
  85. package/dist/tools/registry.js +10 -0
  86. package/dist/tools/registry.js.map +1 -1
  87. package/dist/tools/types.d.ts +2 -0
  88. package/dist/tools/types.js.map +1 -1
  89. package/official.json +1 -2
  90. package/package.json +1 -1
@@ -0,0 +1,261 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { setTimeout as delay } from "node:timers/promises";
3
+ import { siteUrl } from "../auth/providers/account.js";
4
+ import { toolText } from "../tools/types.js";
5
+ export class CloudConnectorError extends Error {
6
+ code;
7
+ constructor(code) { super(code); this.code = code; }
8
+ }
9
+ const object = (x) => !!x && typeof x === "object" && !Array.isArray(x);
10
+ /** Per-Harness interaction broker. UI sees cards; model never sees authorization URLs. */
11
+ export class CloudConnectorService {
12
+ options;
13
+ pending = new Map();
14
+ cards = new Map();
15
+ listeners = new Set();
16
+ closed = false;
17
+ origin;
18
+ constructor(options) { this.options = options; }
19
+ subscribe(listener) {
20
+ this.listeners.add(listener);
21
+ return () => { this.listeners.delete(listener); };
22
+ }
23
+ snapshots() { return [...this.cards.values()].map((card) => ({ ...card })); }
24
+ emit(card) {
25
+ this.cards.set(card.id, { ...card });
26
+ for (const [id] of this.cards)
27
+ if (this.cards.size > 100 && !this.pending.has(id))
28
+ this.cards.delete(id);
29
+ for (const listener of this.listeners) {
30
+ try {
31
+ listener({ ...card });
32
+ }
33
+ catch { /* UI cannot break a tool. */ }
34
+ }
35
+ }
36
+ async call(action, body, signal) {
37
+ const origin = (this.options.origin ?? siteUrl)();
38
+ if (this.origin && origin !== this.origin)
39
+ throw new Error("Cloud 地址已改变,请重新启动任务。");
40
+ this.origin = origin;
41
+ const token = await this.options.token(origin);
42
+ if (!token)
43
+ throw new CloudConnectorError("请先登录 OHarness,再连接第三方应用。");
44
+ signal.throwIfAborted();
45
+ let response;
46
+ try {
47
+ response = await (this.options.fetch ?? fetch)(origin + "/api/connectors/" + action, {
48
+ method: "POST", redirect: "error", signal: AbortSignal.any([signal, AbortSignal.timeout(30000)]),
49
+ headers: { authorization: "Bearer " + token, "content-type": "application/json" }, body: JSON.stringify(body),
50
+ });
51
+ }
52
+ catch {
53
+ throw new CloudConnectorError("Cloud Connector 请求失败;未自动重试。");
54
+ }
55
+ const reader = response.body?.getReader();
56
+ if (!reader)
57
+ throw new CloudConnectorError("Cloud Connector 返回空响应。");
58
+ const chunks = [];
59
+ let size = 0;
60
+ let data;
61
+ try {
62
+ for (;;) {
63
+ const { done, value } = await reader.read();
64
+ if (done)
65
+ break;
66
+ size += value.byteLength;
67
+ if (size > 2 * 1024 * 1024) {
68
+ await reader.cancel();
69
+ throw new Error();
70
+ }
71
+ chunks.push(value);
72
+ }
73
+ data = JSON.parse(Buffer.concat(chunks).toString("utf8"));
74
+ if (!object(data))
75
+ throw new Error();
76
+ }
77
+ catch {
78
+ throw new CloudConnectorError("Cloud Connector 返回无效响应。");
79
+ }
80
+ finally {
81
+ reader.releaseLock();
82
+ }
83
+ if (!response.ok) {
84
+ // Only this structured refusal is safe to resume: the Cloud has not executed anything.
85
+ if (response.status === 409 && data.code === "connection_required")
86
+ return data;
87
+ const codes = new Set(["app_not_enabled", "connectors_not_configured", "multiple_accounts_require_admin_selection", "schema_changed_fetch_catalog_again", "sign_in_to_oharness"]);
88
+ throw new CloudConnectorError(codes.has(data.code) ? data.code : "Cloud Connector 操作失败;请检查状态,不要自动重试。");
89
+ }
90
+ return data;
91
+ }
92
+ async requireConnection(app, label, ctx, principal, logo) {
93
+ if (this.closed)
94
+ throw new Error("Connector closed");
95
+ ctx.signal.throwIfAborted();
96
+ if (typeof principal !== "string" || !principal)
97
+ throw new Error("Cloud 未返回用户身份。");
98
+ if (this.pending.size >= 50)
99
+ throw new Error("Too many pending connections");
100
+ const card = { id: randomUUID(), app, label, session: ctx.sessionId, toolCallId: ctx.toolCallId,
101
+ state: "required", message: "此任务需要连接应用。授权范围以应用授权页面为准。", messageKey: "connect.required", ...(logo ? { logo } : {}) };
102
+ let resolve, reject;
103
+ const waiting = new Promise((yes, no) => { resolve = yes; reject = no; });
104
+ const entry = { card, resolve, reject, principal, controller: new AbortController() };
105
+ this.pending.set(card.id, entry);
106
+ const abort = () => this.finish(entry, "cancelled", "任务已取消,未继续执行工具。", "connect.taskCancelled");
107
+ ctx.signal.addEventListener("abort", abort, { once: true });
108
+ const timer = setTimeout(() => this.finish(entry, "failed", "授权等待已超时,请重新发起任务。", "connect.timedOut"), this.options.waitMs ?? 600000);
109
+ this.emit(card);
110
+ ctx.onProgress({ toolCallId: ctx.toolCallId, toolName: "cloud_app_tools", message: "等待用户连接 " + label });
111
+ try {
112
+ await waiting;
113
+ ctx.signal.throwIfAborted();
114
+ }
115
+ finally {
116
+ clearTimeout(timer);
117
+ ctx.signal.removeEventListener("abort", abort);
118
+ entry.controller.abort();
119
+ this.pending.delete(card.id);
120
+ }
121
+ }
122
+ finish(entry, state, message, messageKey) {
123
+ if (!this.pending.has(entry.card.id))
124
+ return;
125
+ this.pending.delete(entry.card.id);
126
+ entry.controller.abort();
127
+ entry.card = { ...entry.card, state, message, ...(messageKey ? { messageKey } : {}) };
128
+ this.emit(entry.card);
129
+ if (state === "connected")
130
+ entry.resolve();
131
+ else
132
+ entry.reject(new Error(message));
133
+ }
134
+ cancel(id) {
135
+ const entry = this.pending.get(id);
136
+ if (entry)
137
+ this.finish(entry, "cancelled", "已取消连接,未继续执行工具。", "connect.cancelled");
138
+ }
139
+ async start(id) {
140
+ const entry = this.pending.get(id);
141
+ if (!entry)
142
+ throw new Error("连接请求已结束,请重新发起任务。");
143
+ if (entry.starting)
144
+ return entry.starting;
145
+ entry.starting = (async () => {
146
+ try {
147
+ const data = await this.call("link", { app: entry.card.app, expectedPrincipal: entry.principal }, entry.controller.signal);
148
+ entry.controller.signal.throwIfAborted();
149
+ if (data.connected === true) {
150
+ this.finish(entry, "connected", "账号已连接,继续任务。", "connect.connected");
151
+ return undefined;
152
+ }
153
+ const url = new URL(data.redirectUrl);
154
+ if (url.protocol !== "https:" || url.username || url.password || typeof data.accountId !== "string")
155
+ throw new Error();
156
+ entry.accountId = data.accountId;
157
+ entry.link = url.href;
158
+ entry.card = { ...entry.card, state: "authorizing", message: "请在授权页面完成连接;确认成功后任务会自动继续。", messageKey: "connect.authorizing" };
159
+ this.emit(entry.card);
160
+ void this.poll(entry);
161
+ return entry.link;
162
+ }
163
+ catch {
164
+ this.finish(entry, "failed", "无法创建授权链接。请检查 Cloud 配置后重新发起任务。", "connect.noLink");
165
+ throw new Error("无法创建授权链接。");
166
+ }
167
+ })();
168
+ return entry.starting;
169
+ }
170
+ async poll(entry) {
171
+ let failures = 0;
172
+ while (!entry.controller.signal.aborted) {
173
+ try {
174
+ await delay(this.options.pollMs ?? 3000, undefined, { signal: entry.controller.signal });
175
+ const result = await this.call("status", { app: entry.card.app, accountId: entry.accountId, expectedPrincipal: entry.principal }, entry.controller.signal);
176
+ if (result.connected === true) {
177
+ this.finish(entry, "connected", "连接成功,正在继续任务。", "connect.connectedNow");
178
+ return;
179
+ }
180
+ if (["FAILED", "EXPIRED", "INACTIVE", "REVOKED"].includes(result.status)) {
181
+ this.finish(entry, "failed", "授权未完成或已失效,请重新发起任务。", "connect.expired");
182
+ return;
183
+ }
184
+ failures = 0;
185
+ }
186
+ catch {
187
+ if (entry.controller.signal.aborted)
188
+ return;
189
+ if (++failures >= 3) {
190
+ this.finish(entry, "failed", "暂时无法确认授权状态,工具未继续执行。", "connect.unconfirmed");
191
+ return;
192
+ }
193
+ }
194
+ }
195
+ }
196
+ close() {
197
+ this.closed = true;
198
+ for (const entry of this.pending.values())
199
+ this.finish(entry, "cancelled", "服务已关闭,工具未继续执行。");
200
+ this.listeners.clear();
201
+ }
202
+ }
203
+ export function createCloudConnectorPlugin(service) {
204
+ return {
205
+ id: "connector-cloud", version: "1.0.0", apiVersion: 1,
206
+ description: "Platform-managed third-party apps through OHarness Cloud",
207
+ parseConfig(raw) { if (raw !== undefined && !object(raw))
208
+ throw new Error("Invalid connector config"); return {}; },
209
+ setup(ctx) {
210
+ ctx.onDispose(() => service.close());
211
+ ctx.tools.register({
212
+ name: "cloud_app_tools", readOnly: false, sessionLocal: false,
213
+ description: "Discover platform app tools (Gmail/email, GitHub, Slack, etc.). Before claiming an app is unavailable, call this tool. Omit app to list enabled apps; use an app slug such as gmail to get exact tool schemas and versions. If not connected, this opens a user authorization card and waits; never ask for passwords or API keys.",
214
+ inputSchema: { type: "object", properties: { app: { type: "string" } }, additionalProperties: false },
215
+ renderTitle(input) { const x = input; return x.app ? "Cloud apps: " + x.app : "Cloud apps"; },
216
+ validate(raw) { return object(raw) && (raw.app === undefined || (typeof raw.app === "string" && /^[a-z][a-z0-9_]{0,63}$/.test(raw.app))) ? { ok: true, value: raw } : { ok: false, error: "Invalid app" }; },
217
+ async execute(input, call) {
218
+ const { app } = input;
219
+ let data = await service.call("catalog", app ? { app } : {}, call.signal);
220
+ if (app && data.connected === false) {
221
+ const principal = data.principal;
222
+ await service.requireConnection(app, typeof data.label === "string" ? data.label : app, call, principal, typeof data.logo === "string" ? data.logo : undefined);
223
+ data = await service.call("catalog", { app, expectedPrincipal: principal }, call.signal);
224
+ if (data.connected !== true)
225
+ throw new Error("账号尚未连接,工具未执行。");
226
+ }
227
+ /*
228
+ * `logo` is for the card and is dropped here with `principal`. A
229
+ * vendor image URL tells the model nothing it can act on, and every
230
+ * catalog answer is a tool result that becomes context for the rest
231
+ * of the conversation — decoration is the last thing that should be
232
+ * paying for that room.
233
+ */
234
+ const { principal: _, logo: __, ...visible } = data;
235
+ return toolText(JSON.stringify(visible));
236
+ },
237
+ });
238
+ ctx.tools.register({
239
+ name: "cloud_app_execute", readOnly: false, sessionLocal: false,
240
+ description: "Execute an enabled Cloud app tool. First use cloud_app_tools to obtain the exact app/tool/version and argument schema. Account identity is supplied by OHarness, never by the model. If binding is missing a user card pauses this call. Never automatically retry a failed execution.",
241
+ inputSchema: { type: "object", properties: { app: { type: "string" }, tool: { type: "string" }, version: { type: "string" }, arguments: { type: "object" } }, required: ["app", "tool", "version", "arguments"], additionalProperties: false },
242
+ renderTitle(input) { const x = input; return "Cloud " + x.app + ": " + x.tool; },
243
+ validate(raw) { return object(raw) && typeof raw.app === "string" && typeof raw.tool === "string" && typeof raw.version === "string" && object(raw.arguments) ? { ok: true, value: raw } : { ok: false, error: "app, tool, version and arguments required" }; },
244
+ async execute(input, call) {
245
+ const { app, tool, version, arguments: args } = input;
246
+ const payload = { app, tool, version, arguments: args };
247
+ let data = await service.call("execute", payload, call.signal);
248
+ if (data.code === "connection_required") {
249
+ await service.requireConnection(app, typeof data.label === "string" ? data.label : app, call, data.principal, typeof data.logo === "string" ? data.logo : undefined);
250
+ // Retry only the explicit pre-execution refusal, never an uncertain POST failure.
251
+ data = await service.call("execute", { ...payload, expectedPrincipal: data.principal }, call.signal);
252
+ if (data.code === "connection_required")
253
+ throw new Error("绑定未生效,工具未执行。");
254
+ }
255
+ return toolText(JSON.stringify(data.data ?? null));
256
+ },
257
+ });
258
+ },
259
+ };
260
+ }
261
+ //# sourceMappingURL=cloud-connector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-connector.js","sourceRoot":"","sources":["../../src/runtime-plugins/cloud-connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AA0B7C,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,IAAI,CAAS;IACtB,YAAY,IAAY,IAAI,KA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G,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,EAAE,iBAAiB,EAAE,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;wBACrG,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB;4BAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;oBAC3E,CAAC;oBACD,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC;gBACrD,CAAC;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,65 @@
1
+ export interface ComposioClientOptions {
2
+ userId: string;
3
+ apiKeyEnv?: string;
4
+ timeoutMs?: number;
5
+ signal?: AbortSignal;
6
+ /** Dependency injection for offline contract tests; not a serializable config option. */
7
+ fetch?: typeof fetch;
8
+ }
9
+ export interface ComposioAccount {
10
+ id: string;
11
+ userId: string;
12
+ toolkit: string;
13
+ status: string;
14
+ disabled: boolean;
15
+ }
16
+ export interface ComposioAccountPage {
17
+ accounts: ComposioAccount[];
18
+ cursor?: string;
19
+ }
20
+ export interface ComposioAuthLink {
21
+ connectedAccountId: string;
22
+ redirectUrl: string;
23
+ expiresAt?: string;
24
+ }
25
+ export declare function record(value: unknown): value is Record<string, unknown>;
26
+ export declare class ComposioClient {
27
+ private readonly apiKey;
28
+ private readonly userId;
29
+ private readonly timeoutMs;
30
+ private readonly fetcher;
31
+ private readonly controller;
32
+ private readonly signal;
33
+ constructor(options: ComposioClientOptions);
34
+ close(): void;
35
+ /** Never return account credentials/state from the upstream response. */
36
+ account(id: string, signal?: AbortSignal): Promise<ComposioAccount>;
37
+ /**
38
+ * The accounts this user already has, because a configuration cannot be
39
+ * written out of ids nobody has a way to look up. `account()` answers for an
40
+ * id you hold; until this existed the only way to hold one was to link a new
41
+ * account or open the dashboard, which is not a thing a `status` command can
42
+ * tell you to do.
43
+ *
44
+ * Never return account credentials/state, exactly as `account()` does not.
45
+ * Each row of this response carries `data` and `state`, so this is the one
46
+ * place where forgetting that prints a live access token to a terminal.
47
+ *
48
+ * A row belonging to another user is an error rather than something to skip.
49
+ * The request already names the user; a server answering with someone else's
50
+ * account is not a filter that needs tightening, it is a response that should
51
+ * not be trusted for the rows that did match either.
52
+ */
53
+ accounts(options?: {
54
+ toolkit?: string;
55
+ limit?: number;
56
+ cursor?: string;
57
+ }, signal?: AbortSignal): Promise<ComposioAccountPage>;
58
+ assertAccount(id: string, toolkit: string, signal?: AbortSignal): Promise<void>;
59
+ tool(slug: string, version: string, signal?: AbortSignal): Promise<Record<string, unknown>>;
60
+ /** Called by a configured tool closure, never with an LLM-selected account/version. */
61
+ execute(slug: string, accountId: string, version: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<Record<string, unknown>>;
62
+ /** Explicit host/user operation, not an Agent tool and never called by plugin setup. */
63
+ createAuthLink(authConfigId: string, callbackUrl?: string): Promise<ComposioAuthLink>;
64
+ private request;
65
+ }
@@ -0,0 +1,190 @@
1
+ /** Official direct-execution REST API; no MCP or separate agent loop. */
2
+ const API = "https://backend.composio.dev/api/v3";
3
+ const MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
4
+ export function record(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ function identifier(value) {
8
+ if (!/^[a-zA-Z0-9_-]{1,128}$/.test(value))
9
+ throw new Error("Invalid Composio identifier");
10
+ return encodeURIComponent(value);
11
+ }
12
+ export class ComposioClient {
13
+ apiKey;
14
+ userId;
15
+ timeoutMs;
16
+ fetcher;
17
+ controller = new AbortController();
18
+ signal;
19
+ constructor(options) {
20
+ if (typeof options.userId !== "string" || !options.userId.trim() || options.userId.length > 256) {
21
+ throw new Error("A trusted Composio userId is required");
22
+ }
23
+ const env = options.apiKeyEnv ?? "COMPOSIO_API_KEY";
24
+ if (!/^[A-Z_][A-Z0-9_]*$/.test(env))
25
+ throw new Error("Invalid API key environment variable name");
26
+ const key = process.env[env];
27
+ if (!key?.trim())
28
+ throw new Error(`Missing ${env}; set it in the host environment`);
29
+ this.apiKey = key;
30
+ this.userId = options.userId;
31
+ this.timeoutMs = options.timeoutMs ?? 30_000;
32
+ if (!Number.isInteger(this.timeoutMs) || this.timeoutMs < 100 || this.timeoutMs > 120_000) {
33
+ throw new Error("Composio timeoutMs must be between 100 and 120000");
34
+ }
35
+ this.fetcher = options.fetch ?? fetch;
36
+ this.signal = AbortSignal.any([this.controller.signal, ...(options.signal ? [options.signal] : [])]);
37
+ }
38
+ close() { this.controller.abort(); }
39
+ /** Never return account credentials/state from the upstream response. */
40
+ async account(id, signal) {
41
+ const data = await this.request(`/connected_accounts/${identifier(id)}`, "GET", undefined, signal);
42
+ if (data.id !== id || data.user_id !== this.userId || !record(data.toolkit) ||
43
+ typeof data.toolkit.slug !== "string" || typeof data.status !== "string") {
44
+ throw new Error("Composio account does not belong to the configured user or returned invalid metadata");
45
+ }
46
+ return {
47
+ id, userId: this.userId, toolkit: data.toolkit.slug,
48
+ status: data.status, disabled: data.is_disabled === true,
49
+ };
50
+ }
51
+ /**
52
+ * The accounts this user already has, because a configuration cannot be
53
+ * written out of ids nobody has a way to look up. `account()` answers for an
54
+ * id you hold; until this existed the only way to hold one was to link a new
55
+ * account or open the dashboard, which is not a thing a `status` command can
56
+ * tell you to do.
57
+ *
58
+ * Never return account credentials/state, exactly as `account()` does not.
59
+ * Each row of this response carries `data` and `state`, so this is the one
60
+ * place where forgetting that prints a live access token to a terminal.
61
+ *
62
+ * A row belonging to another user is an error rather than something to skip.
63
+ * The request already names the user; a server answering with someone else's
64
+ * account is not a filter that needs tightening, it is a response that should
65
+ * not be trusted for the rows that did match either.
66
+ */
67
+ async accounts(options = {}, signal) {
68
+ const limit = options.limit ?? 50;
69
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100)
70
+ throw new Error("Composio account limit must be between 1 and 100");
71
+ const query = new URLSearchParams({ user_ids: this.userId, limit: String(limit) });
72
+ if (options.toolkit !== undefined) {
73
+ if (!/^[a-z][a-z0-9_]{0,63}$/.test(options.toolkit))
74
+ throw new Error("Invalid Composio toolkit slug");
75
+ query.set("toolkit_slugs", options.toolkit);
76
+ }
77
+ if (options.cursor !== undefined) {
78
+ if (!/^[A-Za-z0-9_.:=+/-]{1,512}$/.test(options.cursor))
79
+ throw new Error("Invalid Composio cursor");
80
+ query.set("cursor", options.cursor);
81
+ }
82
+ const data = await this.request(`/connected_accounts?${query}`, "GET", undefined, signal);
83
+ if (!Array.isArray(data.items))
84
+ throw new Error("Invalid Composio connected-account list");
85
+ const accounts = data.items.map((item) => {
86
+ if (!record(item) || typeof item.id !== "string" || item.user_id !== this.userId ||
87
+ !record(item.toolkit) || typeof item.toolkit.slug !== "string" || typeof item.status !== "string") {
88
+ throw new Error("Composio listed an account belonging to another user or returned invalid metadata");
89
+ }
90
+ return {
91
+ id: item.id, userId: this.userId, toolkit: item.toolkit.slug,
92
+ status: item.status, disabled: item.is_disabled === true,
93
+ };
94
+ });
95
+ return { accounts, ...(typeof data.next_cursor === "string" && data.next_cursor ? { cursor: data.next_cursor } : {}) };
96
+ }
97
+ async assertAccount(id, toolkit, signal) {
98
+ const account = await this.account(id, signal);
99
+ if (account.toolkit !== toolkit || account.status !== "ACTIVE" || account.disabled) {
100
+ throw new Error("Composio account is inactive, disabled, or belongs to a different toolkit");
101
+ }
102
+ }
103
+ tool(slug, version, signal) {
104
+ return this.request(`/tools/${identifier(slug)}?version=${encodeURIComponent(version)}`, "GET", undefined, signal);
105
+ }
106
+ /** Called by a configured tool closure, never with an LLM-selected account/version. */
107
+ execute(slug, accountId, version, args, signal) {
108
+ return this.request(`/tools/execute/${identifier(slug)}`, "POST", {
109
+ user_id: this.userId, connected_account_id: accountId, version, arguments: args,
110
+ }, signal);
111
+ }
112
+ /** Explicit host/user operation, not an Agent tool and never called by plugin setup. */
113
+ async createAuthLink(authConfigId, callbackUrl) {
114
+ identifier(authConfigId);
115
+ if (callbackUrl) {
116
+ const parsed = new URL(callbackUrl);
117
+ if (parsed.protocol !== "https:" || parsed.username || parsed.password)
118
+ throw new Error("callbackUrl must be HTTPS");
119
+ }
120
+ const data = await this.request("/connected_accounts/link", "POST", {
121
+ auth_config_id: authConfigId, user_id: this.userId,
122
+ ...(callbackUrl ? { callback_url: callbackUrl } : {}),
123
+ });
124
+ if (typeof data.connected_account_id !== "string" || typeof data.redirect_url !== "string") {
125
+ throw new Error("Invalid Composio auth-link response");
126
+ }
127
+ const redirect = new URL(data.redirect_url);
128
+ if (redirect.protocol !== "https:" || redirect.username || redirect.password)
129
+ throw new Error("Invalid Composio authorization URL");
130
+ return {
131
+ connectedAccountId: data.connected_account_id, redirectUrl: redirect.href,
132
+ ...(typeof data.expires_at === "string" ? { expiresAt: data.expires_at } : {}),
133
+ };
134
+ }
135
+ async request(endpoint, method, body, signal) {
136
+ const requestSignal = AbortSignal.any([
137
+ this.signal, AbortSignal.timeout(this.timeoutMs), ...(signal ? [signal] : []),
138
+ ]);
139
+ if (requestSignal.aborted)
140
+ throw new Error("Composio request cancelled before dispatch");
141
+ let response;
142
+ try {
143
+ response = await this.fetcher(API + endpoint, {
144
+ method, redirect: "error", signal: requestSignal,
145
+ headers: { "x-api-key": this.apiKey, "content-type": "application/json", accept: "application/json" },
146
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
147
+ });
148
+ }
149
+ catch {
150
+ throw new Error(method === "POST"
151
+ ? "Composio request failed or was cancelled; outcome may be unknown. Do not retry automatically."
152
+ : "Composio request failed or was cancelled");
153
+ }
154
+ if (!response.ok) {
155
+ await response.body?.cancel().catch(() => { });
156
+ throw new Error(`Composio HTTP ${response.status}${method === "POST" ? "; do not retry automatically" : ""}`);
157
+ }
158
+ try {
159
+ const reader = response.body?.getReader();
160
+ if (!reader)
161
+ throw new Error("empty response");
162
+ let size = 0;
163
+ const chunks = [];
164
+ try {
165
+ while (true) {
166
+ const chunk = await reader.read();
167
+ if (chunk.done)
168
+ break;
169
+ size += chunk.value.byteLength;
170
+ if (size > MAX_RESPONSE_BYTES)
171
+ throw new Error("response too large");
172
+ chunks.push(chunk.value);
173
+ }
174
+ }
175
+ finally {
176
+ await reader.cancel().catch(() => { });
177
+ reader.releaseLock();
178
+ }
179
+ const text = Buffer.concat(chunks).toString("utf8").replaceAll(this.apiKey, "[REDACTED]");
180
+ const data = JSON.parse(text);
181
+ if (!record(data))
182
+ throw new Error("invalid response");
183
+ return data;
184
+ }
185
+ catch {
186
+ throw new Error(`Invalid, oversized, or interrupted Composio response${method === "POST" ? "; outcome may be unknown, do not retry automatically" : ""}`);
187
+ }
188
+ }
189
+ }
190
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/runtime-plugins/composio/client.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,MAAM,GAAG,GAAG,qCAAqC,CAAC;AAClD,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AA8B3C,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC1F,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,OAAO,cAAc;IACR,MAAM,CAAS;IACf,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,OAAO,CAAe;IACtB,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACnC,MAAM,CAAc;IAErC,YAAY,OAA8B;QACxC,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,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AK,CAAC,kBAAkB,CAAC,CAAC;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,IAAI,KAAK,CAAC,uDAAuD,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,sDAAsD,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5J,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import type { RuntimePlugin } from "../types.ts";
2
+ export { ComposioClient } from "./client.ts";
3
+ export type { ComposioClientOptions, ComposioAccount, ComposioAccountPage, ComposioAuthLink } from "./client.ts";
4
+ export interface ComposioToolkitConfig {
5
+ slug: string;
6
+ connectedAccountId: string;
7
+ version: string;
8
+ tools: string[];
9
+ }
10
+ export interface ComposioPluginConfig {
11
+ userId: string;
12
+ apiKeyEnv: string;
13
+ timeoutMs: number;
14
+ toolkits: ComposioToolkitConfig[];
15
+ }
16
+ export declare function parseComposioConfig(raw: unknown): ComposioPluginConfig;
17
+ export declare function composioToolName(slug: string): string;
18
+ /** Uses the same RuntimePlugin protocol; the transport override is only for embedding/tests. */
19
+ export declare function createComposioPlugin(options?: {
20
+ fetch?: typeof fetch;
21
+ }): RuntimePlugin<ComposioPluginConfig>;
22
+ declare const _default: RuntimePlugin<ComposioPluginConfig>;
23
+ export default _default;