@alfe.ai/agent-api-client 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +107 -22
- package/dist/index.d.cts +73 -21
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +73 -21
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +107 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,92 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/tool-error-capture.ts
|
|
3
|
+
const INSTALLED_MARKER = Symbol.for("alfe.toolErrorCapture.installed");
|
|
4
|
+
const WRAPPED_MARKER = Symbol.for("alfe.toolErrorCapture.wrapped");
|
|
5
|
+
/** `isError: true` (MCP/Anthropic convention) or `details.status: 'error'` (OpenClaw). */
|
|
6
|
+
function readResultErrorMessage(result) {
|
|
7
|
+
if (typeof result !== "object" || result === null) return null;
|
|
8
|
+
const r = result;
|
|
9
|
+
if (!(r.isError === true || r.details?.status === "error")) return null;
|
|
10
|
+
if (typeof r.details?.error === "string") return r.details.error;
|
|
11
|
+
if (Array.isArray(r.content)) {
|
|
12
|
+
for (const item of r.content) if (item.type === "text" && typeof item.text === "string") return item.text;
|
|
13
|
+
}
|
|
14
|
+
return "(no error text)";
|
|
15
|
+
}
|
|
16
|
+
/** First stack frame, for inline context without emitting a multi-line block. */
|
|
17
|
+
function firstFrame(err) {
|
|
18
|
+
if (!(err instanceof Error) || !err.stack) return "";
|
|
19
|
+
const frame = err.stack.split("\n").find((l) => l.trimStart().startsWith("at "));
|
|
20
|
+
return frame ? ` (${frame.trim()})` : "";
|
|
21
|
+
}
|
|
22
|
+
function buildLine(plugin, tool, kind, message, frame = "") {
|
|
23
|
+
return `[ERROR] alfe-tool plugin=${plugin} tool=${tool} ${kind}: ${message.replace(/\s+/g, " ").trim()}${frame}`.slice(0, 480);
|
|
24
|
+
}
|
|
25
|
+
function wrapExecute(tool, opts) {
|
|
26
|
+
const execute = tool.execute;
|
|
27
|
+
if (typeof execute !== "function") return;
|
|
28
|
+
const marked = tool;
|
|
29
|
+
if (marked[WRAPPED_MARKER]) return;
|
|
30
|
+
marked[WRAPPED_MARKER] = true;
|
|
31
|
+
const name = typeof tool.name === "string" ? tool.name : "(unnamed)";
|
|
32
|
+
tool.execute = async (...args) => {
|
|
33
|
+
try {
|
|
34
|
+
const result = await execute.apply(tool, args);
|
|
35
|
+
const resultError = readResultErrorMessage(result);
|
|
36
|
+
if (resultError !== null) try {
|
|
37
|
+
opts.emit(buildLine(opts.plugin, name, "result-error", resultError));
|
|
38
|
+
} catch {}
|
|
39
|
+
return result;
|
|
40
|
+
} catch (err) {
|
|
41
|
+
try {
|
|
42
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
43
|
+
opts.emit(buildLine(opts.plugin, name, "thrown", message, firstFrame(err)));
|
|
44
|
+
} catch {}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Wrap `api.registerTool` so every tool registered AFTER this call gets
|
|
51
|
+
* failure capture. Handles both OpenClaw registration signatures:
|
|
52
|
+
* `registerTool(toolDef)` and `registerTool((ctx) => toolDef, opts)`.
|
|
53
|
+
* Call once, first thing in the plugin's `activate`/`register` entry.
|
|
54
|
+
* Never throws.
|
|
55
|
+
*/
|
|
56
|
+
function installToolErrorCapture(api, options) {
|
|
57
|
+
try {
|
|
58
|
+
const markedApi = api;
|
|
59
|
+
if (markedApi[INSTALLED_MARKER]) return;
|
|
60
|
+
markedApi[INSTALLED_MARKER] = true;
|
|
61
|
+
const emit = options.emit ?? ((line) => {
|
|
62
|
+
process.stderr.write(`${line}\n`);
|
|
63
|
+
});
|
|
64
|
+
const opts = {
|
|
65
|
+
plugin: options.plugin,
|
|
66
|
+
emit
|
|
67
|
+
};
|
|
68
|
+
const original = api.registerTool.bind(api);
|
|
69
|
+
api.registerTool = (...args) => {
|
|
70
|
+
try {
|
|
71
|
+
const [first, ...rest] = args;
|
|
72
|
+
if (typeof first === "function") {
|
|
73
|
+
const factory = first;
|
|
74
|
+
const wrappedFactory = (...fa) => {
|
|
75
|
+
const tool = factory(...fa);
|
|
76
|
+
if (typeof tool === "object" && tool !== null) wrapExecute(tool, opts);
|
|
77
|
+
return tool;
|
|
78
|
+
};
|
|
79
|
+
return original(wrappedFactory, ...rest);
|
|
80
|
+
}
|
|
81
|
+
if (typeof first === "object" && first !== null) wrapExecute(first, opts);
|
|
82
|
+
return original(first, ...rest);
|
|
83
|
+
} catch {
|
|
84
|
+
return original(...args);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
} catch {}
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
2
90
|
//#region src/index.ts
|
|
3
91
|
/**
|
|
4
92
|
* Encode each path segment but keep the `/` separators — `encodeURIComponent`
|
|
@@ -495,30 +583,26 @@ var AgentApiClient = class {
|
|
|
495
583
|
};
|
|
496
584
|
}
|
|
497
585
|
/**
|
|
498
|
-
* Microsoft 365
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* `mgc` credentials for the single (default) Microsoft account.
|
|
586
|
+
* Disconnects one connected Microsoft 365 account for the agent, by its
|
|
587
|
+
* `accountIdentifier`. Hits the generic per-account disconnect route
|
|
588
|
+
* (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
|
|
589
|
+
* resolves across the agent's full effective scope chain and deletes the
|
|
590
|
+
* matching Connection row. Returns the remaining accounts.
|
|
504
591
|
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
592
|
+
* IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
|
|
593
|
+
* a synthesised email. For Microsoft, `accountIdentifier` is the user's email
|
|
594
|
+
* only when the Graph profile fetch succeeded at connect time; it falls back
|
|
595
|
+
* to the Azure tenant id (`tid` claim) otherwise. The backend matches on
|
|
596
|
+
* `accountIdentifier` exactly, so passing an email would 404 on those
|
|
597
|
+
* fallback-identifier accounts. (This is why the param is not named `email`,
|
|
598
|
+
* unlike `disconnectGoogleAccount` where the identifier is always the email.)
|
|
509
599
|
*/
|
|
510
|
-
async
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
clientId: raw.clientId ?? "",
|
|
517
|
-
clientSecret: raw.clientSecret ?? "",
|
|
518
|
-
email: raw.email ?? raw.accountIdentifier,
|
|
519
|
-
microsoftTenantId: raw.microsoftTenantId,
|
|
520
|
-
workspaceDomain: raw.workspaceDomain
|
|
521
|
-
};
|
|
600
|
+
async disconnectMicrosoftAccount(accountIdentifier) {
|
|
601
|
+
return { accounts: (await this.request(`/agent/connect/microsoft/accounts/${encodeURIComponent(accountIdentifier)}`, { method: "DELETE" })).accounts.map((a) => ({
|
|
602
|
+
accountIdentifier: a.accountIdentifier,
|
|
603
|
+
displayName: a.displayName ?? void 0,
|
|
604
|
+
connectedAt: a.connectedAt
|
|
605
|
+
})) };
|
|
522
606
|
}
|
|
523
607
|
/**
|
|
524
608
|
* Pattern A: multi-account credential fetch for Microsoft 365.
|
|
@@ -1242,3 +1326,4 @@ var AgentApiClient = class {
|
|
|
1242
1326
|
};
|
|
1243
1327
|
//#endregion
|
|
1244
1328
|
exports.AgentApiClient = AgentApiClient;
|
|
1329
|
+
exports.installToolErrorCapture = installToolErrorCapture;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,60 @@
|
|
|
1
1
|
import { ChangelogAction, ChangelogActor, ChangelogEntry, ChangelogEntry as ChangelogEntry$1, EncryptedEnvelopeV1, EncryptedEnvelopeV1 as EncryptedEnvelopeV1$1, Field, FieldEnvelope, FieldEnvelope as FieldEnvelope$1, FieldFormat, FieldFormat as FieldFormat$1, FieldSensitivity, FieldSensitivity as FieldSensitivity$1, FieldView, GeneratedDataKey, GeneratedDataKey as GeneratedDataKey$1, IntegrationConfigResult, IntegrationConfigResult as IntegrationConfigResult$1, IntegrationConfigSchemaField, IntegrationInstall, IntegrationInstall as IntegrationInstall$1, RegistryEntry, RegistryEntry as RegistryEntry$1, ScopeInfo, ScopeInfo as ScopeInfo$1, SecretAggregate, SecretAggregate as SecretAggregate$1, SecretCategory, SecretCategory as SecretCategory$1, SecretMetadata, SecretMetadata as SecretMetadata$1, SecretScope, SecretScope as SecretScope$1 } from "@alfe/types";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/tool-error-capture.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tool-error capture for Alfe OpenClaw plugins.
|
|
7
|
+
*
|
|
8
|
+
* OpenClaw converts a thrown tool handler into a model-facing `tool_result`
|
|
9
|
+
* WITHOUT logging, and most Alfe plugins catch-and-return an error result the
|
|
10
|
+
* same silent way — so tool failures never appear in the runtime's output and
|
|
11
|
+
* therefore never reach Sentry (the gateway daemon supervises the OpenClaw
|
|
12
|
+
* process and reports error-looking output lines to the `agent-runtime`
|
|
13
|
+
* project — see packages/gateway/src/runtime-output-monitor.ts).
|
|
14
|
+
*
|
|
15
|
+
* `installToolErrorCapture(api, { plugin })` closes that gap at the ONE choke
|
|
16
|
+
* point every plugin already has: it wraps `api.registerTool` so every tool's
|
|
17
|
+
* `execute` emits a deterministic, detector-matched line on failure:
|
|
18
|
+
*
|
|
19
|
+
* [ERROR] alfe-tool plugin=<plugin> tool=<name> <thrown|result-error>: <msg> (at <first-frame>)
|
|
20
|
+
*
|
|
21
|
+
* The `[ERROR]` prefix at line start is exactly what the daemon's
|
|
22
|
+
* `ErrorLineDetector` classifies as an error-log block, so the failure lands
|
|
23
|
+
* in Sentry fingerprinted by its normalized message — no Sentry SDK inside
|
|
24
|
+
* the plugin process, no new dependency. Behavior toward OpenClaw and the
|
|
25
|
+
* model is UNCHANGED: throws are rethrown, results returned as-is.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Minimal shape of the OpenClaw plugin api this helper relies on. Method
|
|
29
|
+
* syntax on purpose — TS checks method signatures bivariantly, so each
|
|
30
|
+
* plugin's own concretely-typed `registerTool(tool: ToolDef): void` is
|
|
31
|
+
* accepted without casts.
|
|
32
|
+
*/
|
|
33
|
+
interface ToolCaptureApi {
|
|
34
|
+
registerTool(...args: never[]): unknown;
|
|
35
|
+
}
|
|
36
|
+
interface InstallToolErrorCaptureOptions {
|
|
37
|
+
/** Plugin package short-name for attribution (e.g. "openclaw-secrets"). */
|
|
38
|
+
plugin: string;
|
|
39
|
+
/**
|
|
40
|
+
* Line sink — defaults to writing `process.stderr` directly (the plugin
|
|
41
|
+
* runs in-process in OpenClaw, so this lands on the runtime's stderr, which
|
|
42
|
+
* the daemon supervises — and a console patch can't reformat it away).
|
|
43
|
+
* Injectable for tests.
|
|
44
|
+
*/
|
|
45
|
+
emit?: (line: string) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Wrap `api.registerTool` so every tool registered AFTER this call gets
|
|
49
|
+
* failure capture. Handles both OpenClaw registration signatures:
|
|
50
|
+
* `registerTool(toolDef)` and `registerTool((ctx) => toolDef, opts)`.
|
|
51
|
+
* Call once, first thing in the plugin's `activate`/`register` entry.
|
|
52
|
+
* Never throws.
|
|
53
|
+
*/
|
|
54
|
+
declare function installToolErrorCapture(api: ToolCaptureApi, options: InstallToolErrorCaptureOptions): void;
|
|
55
|
+
//# sourceMappingURL=tool-error-capture.d.ts.map
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/index.d.ts
|
|
5
58
|
interface AgentApiClientConfig {
|
|
6
59
|
apiKey: string;
|
|
7
60
|
apiUrl: string;
|
|
@@ -670,27 +723,26 @@ declare class AgentApiClient {
|
|
|
670
723
|
expiresAt: string;
|
|
671
724
|
}>;
|
|
672
725
|
/**
|
|
673
|
-
* Microsoft 365
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* `mgc` credentials for the single (default) Microsoft account.
|
|
726
|
+
* Disconnects one connected Microsoft 365 account for the agent, by its
|
|
727
|
+
* `accountIdentifier`. Hits the generic per-account disconnect route
|
|
728
|
+
* (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
|
|
729
|
+
* resolves across the agent's full effective scope chain and deletes the
|
|
730
|
+
* matching Connection row. Returns the remaining accounts.
|
|
679
731
|
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
732
|
+
* IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
|
|
733
|
+
* a synthesised email. For Microsoft, `accountIdentifier` is the user's email
|
|
734
|
+
* only when the Graph profile fetch succeeded at connect time; it falls back
|
|
735
|
+
* to the Azure tenant id (`tid` claim) otherwise. The backend matches on
|
|
736
|
+
* `accountIdentifier` exactly, so passing an email would 404 on those
|
|
737
|
+
* fallback-identifier accounts. (This is why the param is not named `email`,
|
|
738
|
+
* unlike `disconnectGoogleAccount` where the identifier is always the email.)
|
|
684
739
|
*/
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
email?: string;
|
|
692
|
-
microsoftTenantId?: string;
|
|
693
|
-
workspaceDomain?: string;
|
|
740
|
+
disconnectMicrosoftAccount(accountIdentifier: string): Promise<{
|
|
741
|
+
accounts: {
|
|
742
|
+
accountIdentifier: string;
|
|
743
|
+
displayName?: string;
|
|
744
|
+
connectedAt?: string;
|
|
745
|
+
}[];
|
|
694
746
|
}>;
|
|
695
747
|
/**
|
|
696
748
|
* Pattern A: multi-account credential fetch for Microsoft 365.
|
|
@@ -1381,5 +1433,5 @@ declare class AgentApiClient {
|
|
|
1381
1433
|
}
|
|
1382
1434
|
//# sourceMappingURL=index.d.ts.map
|
|
1383
1435
|
//#endregion
|
|
1384
|
-
export { AgentApiClient, AgentApiClientConfig, AgentAvatarPresign, AgentSelf, AgentVoice, AgentVoiceConfig, ChangeRequestActorKind, ChangeRequestOperation, ChangeRequestResourceType, ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeChangeRequest, KnowledgeDoc, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, ProposeScopeChangeInput, type RegistryEntry, RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry, VoiceSttArgs, VoiceSttResult, VoiceTtsArgs, VoiceTtsModel, VoiceTtsResult };
|
|
1436
|
+
export { AgentApiClient, AgentApiClientConfig, AgentAvatarPresign, AgentSelf, AgentVoice, AgentVoiceConfig, ChangeRequestActorKind, ChangeRequestOperation, ChangeRequestResourceType, ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type InstallToolErrorCaptureOptions, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeChangeRequest, KnowledgeDoc, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, ProposeScopeChangeInput, type RegistryEntry, RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry, type ToolCaptureApi, VoiceSttArgs, VoiceSttResult, VoiceTtsArgs, VoiceTtsModel, VoiceTtsResult, installToolErrorCapture };
|
|
1385
1437
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/tool-error-capture.ts","../src/index.ts"],"mappings":";;;;;;;AA6BA;AAIA;AA0GA;;;;;;;;ACtFA;AAOA;AAmBA;AAWA;AASA;;;;;AAOA;AAMA;AAQA;AAQA;AASA;AAQA;AASiB,UD7HA,cAAA,CC6HgB;EAQhB,YAAA,CAAA,GAAA,IAAA,EAAkB,KAAA,EAAA,CAAA,EAAA,OAAA;AAMnC;AAeY,UDtJK,8BAAA,CCsJa;EAEb;EAMA,MAAA,EAAA,MAAA;EAmBA;AAMjB;AAKA;;;;EAK6B,IAAA,CAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;AAK7B;AAiBA;AACA;AACA;AAMA;AAGA;;;AAIgB,iBD5HA,uBAAA,CC4HA,GAAA,ED3HT,cC2HS,EAAA,OAAA,ED1HL,8BC0HK,CAAA,EAAA,IAAA;;;;UAlNC,oBAAA;;;AAAjB;AAOiB,UAAA,iBAAA,CAAiB;EAmBjB,SAAA,EAAA,MAAa;EAWb,OAAA,EAAA,MAAA;EASA,OAAA,EAAA,SAAY,GAAA,UAAA;EAAA,MAAA,EAAA,eAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,UAAA,GAAA,WAAA,GAAA,SAAA,GAAA,QAAA;KAIL,CAAA,EAAA,MAAA;cAAf,CAAA,EAAA,MAAA;EAAM,WAAA,CAAA,EAAA,MAAA;A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FieldEnvelope as FieldEnvelope$1, FieldFormat, FieldFormat as FieldFormat$1, FieldSensitivity, FieldSensitivity as FieldSensitivity$1, FieldView, GeneratedDataKey, GeneratedDataKey as GeneratedDataKey$1, IntegrationConfigResult, IntegrationConfigResult as IntegrationConfigResult$1, IntegrationConfigSchemaField, IntegrationInstall, IntegrationInstall as IntegrationInstall$1, RegistryEntry, RegistryEntry as RegistryEntry$1, ScopeInfo, ScopeInfo as ScopeInfo$1, SecretAggregate, SecretAggregate as SecretAggregate$1, SecretCategory, SecretCategory as SecretCategory$1, SecretMetadata, SecretMetadata as SecretMetadata$1, SecretScope, SecretScope as SecretScope$1 } from "@alfe/types";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/tool-error-capture.d.ts
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Tool-error capture for Alfe OpenClaw plugins.
|
|
7
|
+
*
|
|
8
|
+
* OpenClaw converts a thrown tool handler into a model-facing `tool_result`
|
|
9
|
+
* WITHOUT logging, and most Alfe plugins catch-and-return an error result the
|
|
10
|
+
* same silent way — so tool failures never appear in the runtime's output and
|
|
11
|
+
* therefore never reach Sentry (the gateway daemon supervises the OpenClaw
|
|
12
|
+
* process and reports error-looking output lines to the `agent-runtime`
|
|
13
|
+
* project — see packages/gateway/src/runtime-output-monitor.ts).
|
|
14
|
+
*
|
|
15
|
+
* `installToolErrorCapture(api, { plugin })` closes that gap at the ONE choke
|
|
16
|
+
* point every plugin already has: it wraps `api.registerTool` so every tool's
|
|
17
|
+
* `execute` emits a deterministic, detector-matched line on failure:
|
|
18
|
+
*
|
|
19
|
+
* [ERROR] alfe-tool plugin=<plugin> tool=<name> <thrown|result-error>: <msg> (at <first-frame>)
|
|
20
|
+
*
|
|
21
|
+
* The `[ERROR]` prefix at line start is exactly what the daemon's
|
|
22
|
+
* `ErrorLineDetector` classifies as an error-log block, so the failure lands
|
|
23
|
+
* in Sentry fingerprinted by its normalized message — no Sentry SDK inside
|
|
24
|
+
* the plugin process, no new dependency. Behavior toward OpenClaw and the
|
|
25
|
+
* model is UNCHANGED: throws are rethrown, results returned as-is.
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Minimal shape of the OpenClaw plugin api this helper relies on. Method
|
|
29
|
+
* syntax on purpose — TS checks method signatures bivariantly, so each
|
|
30
|
+
* plugin's own concretely-typed `registerTool(tool: ToolDef): void` is
|
|
31
|
+
* accepted without casts.
|
|
32
|
+
*/
|
|
33
|
+
interface ToolCaptureApi {
|
|
34
|
+
registerTool(...args: never[]): unknown;
|
|
35
|
+
}
|
|
36
|
+
interface InstallToolErrorCaptureOptions {
|
|
37
|
+
/** Plugin package short-name for attribution (e.g. "openclaw-secrets"). */
|
|
38
|
+
plugin: string;
|
|
39
|
+
/**
|
|
40
|
+
* Line sink — defaults to writing `process.stderr` directly (the plugin
|
|
41
|
+
* runs in-process in OpenClaw, so this lands on the runtime's stderr, which
|
|
42
|
+
* the daemon supervises — and a console patch can't reformat it away).
|
|
43
|
+
* Injectable for tests.
|
|
44
|
+
*/
|
|
45
|
+
emit?: (line: string) => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Wrap `api.registerTool` so every tool registered AFTER this call gets
|
|
49
|
+
* failure capture. Handles both OpenClaw registration signatures:
|
|
50
|
+
* `registerTool(toolDef)` and `registerTool((ctx) => toolDef, opts)`.
|
|
51
|
+
* Call once, first thing in the plugin's `activate`/`register` entry.
|
|
52
|
+
* Never throws.
|
|
53
|
+
*/
|
|
54
|
+
declare function installToolErrorCapture(api: ToolCaptureApi, options: InstallToolErrorCaptureOptions): void;
|
|
55
|
+
//# sourceMappingURL=tool-error-capture.d.ts.map
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/index.d.ts
|
|
5
58
|
interface AgentApiClientConfig {
|
|
6
59
|
apiKey: string;
|
|
7
60
|
apiUrl: string;
|
|
@@ -670,27 +723,26 @@ declare class AgentApiClient {
|
|
|
670
723
|
expiresAt: string;
|
|
671
724
|
}>;
|
|
672
725
|
/**
|
|
673
|
-
* Microsoft 365
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
* `mgc` credentials for the single (default) Microsoft account.
|
|
726
|
+
* Disconnects one connected Microsoft 365 account for the agent, by its
|
|
727
|
+
* `accountIdentifier`. Hits the generic per-account disconnect route
|
|
728
|
+
* (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
|
|
729
|
+
* resolves across the agent's full effective scope chain and deletes the
|
|
730
|
+
* matching Connection row. Returns the remaining accounts.
|
|
679
731
|
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
*
|
|
732
|
+
* IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
|
|
733
|
+
* a synthesised email. For Microsoft, `accountIdentifier` is the user's email
|
|
734
|
+
* only when the Graph profile fetch succeeded at connect time; it falls back
|
|
735
|
+
* to the Azure tenant id (`tid` claim) otherwise. The backend matches on
|
|
736
|
+
* `accountIdentifier` exactly, so passing an email would 404 on those
|
|
737
|
+
* fallback-identifier accounts. (This is why the param is not named `email`,
|
|
738
|
+
* unlike `disconnectGoogleAccount` where the identifier is always the email.)
|
|
684
739
|
*/
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
email?: string;
|
|
692
|
-
microsoftTenantId?: string;
|
|
693
|
-
workspaceDomain?: string;
|
|
740
|
+
disconnectMicrosoftAccount(accountIdentifier: string): Promise<{
|
|
741
|
+
accounts: {
|
|
742
|
+
accountIdentifier: string;
|
|
743
|
+
displayName?: string;
|
|
744
|
+
connectedAt?: string;
|
|
745
|
+
}[];
|
|
694
746
|
}>;
|
|
695
747
|
/**
|
|
696
748
|
* Pattern A: multi-account credential fetch for Microsoft 365.
|
|
@@ -1381,5 +1433,5 @@ declare class AgentApiClient {
|
|
|
1381
1433
|
}
|
|
1382
1434
|
//# sourceMappingURL=index.d.ts.map
|
|
1383
1435
|
//#endregion
|
|
1384
|
-
export { AgentApiClient, AgentApiClientConfig, AgentAvatarPresign, AgentSelf, AgentVoice, AgentVoiceConfig, ChangeRequestActorKind, ChangeRequestOperation, ChangeRequestResourceType, ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeChangeRequest, KnowledgeDoc, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, ProposeScopeChangeInput, type RegistryEntry, RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry, VoiceSttArgs, VoiceSttResult, VoiceTtsArgs, VoiceTtsModel, VoiceTtsResult };
|
|
1436
|
+
export { AgentApiClient, AgentApiClientConfig, AgentAvatarPresign, AgentSelf, AgentVoice, AgentVoiceConfig, ChangeRequestActorKind, ChangeRequestOperation, ChangeRequestResourceType, ChangeRequestStatus, type ChangelogAction, type ChangelogActor, type ChangelogEntry, type EncryptedEnvelopeV1, type Field, type FieldEnvelope, type FieldFormat, type FieldSensitivity, type FieldView, type GeneratedDataKey, type InstallToolErrorCaptureOptions, type IntegrationConfigResult, type IntegrationConfigSchemaField, type IntegrationInstall, KnowledgeChangeRequest, KnowledgeDoc, KnowledgeProfile, KnowledgeProfileLink, KnowledgeScope, KnowledgeScopeType, KnowledgeSearchHit, KnowledgeSearchResult, ProposeScopeChangeInput, type RegistryEntry, RemoteSessionInfo, type ScopeInfo, type SecretAggregate, type SecretCategory, type SecretMetadata, type SecretScope, SharedFileEntry, SyncAgentInfo, SyncAgentStats, SyncConfirmedUpload, SyncFileEntry, SyncManifest, SyncManifestEntry, SyncPresignedUrl, SyncReconstructBundle, SyncReconstructFile, SyncSessionContent, SyncSessionEntry, type ToolCaptureApi, VoiceSttArgs, VoiceSttResult, VoiceTtsArgs, VoiceTtsModel, VoiceTtsResult, installToolErrorCapture };
|
|
1385
1437
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/tool-error-capture.ts","../src/index.ts"],"mappings":";;;;;;;AA6BA;AAIA;AA0GA;;;;;;;;ACtFA;AAOA;AAmBA;AAWA;AASA;;;;;AAOA;AAMA;AAQA;AAQA;AASA;AAQA;AASiB,UD7HA,cAAA,CC6HgB;EAQhB,YAAA,CAAA,GAAA,IAAA,EAAkB,KAAA,EAAA,CAAA,EAAA,OAAA;AAMnC;AAeY,UDtJK,8BAAA,CCsJa;EAEb;EAMA,MAAA,EAAA,MAAA;EAmBA;AAMjB;AAKA;;;;EAK6B,IAAA,CAAA,EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,GAAA,IAAA;AAK7B;AAiBA;AACA;AACA;AAMA;AAGA;;;AAIgB,iBD5HA,uBAAA,CC4HA,GAAA,ED3HT,cC2HS,EAAA,OAAA,ED1HL,8BC0HK,CAAA,EAAA,IAAA;;;;UAlNC,oBAAA;;;AAAjB;AAOiB,UAAA,iBAAA,CAAiB;EAmBjB,SAAA,EAAA,MAAa;EAWb,OAAA,EAAA,MAAA;EASA,OAAA,EAAA,SAAY,GAAA,UAAA;EAAA,MAAA,EAAA,eAAA,GAAA,gBAAA,GAAA,kBAAA,GAAA,UAAA,GAAA,WAAA,GAAA,SAAA,GAAA,QAAA;KAIL,CAAA,EAAA,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apture.installed");
|
|
3
|
+
const WRAPPED_MARKER = Symbol.for("alfe.toolErrorCapture.wrapped");
|
|
4
|
+
/** `isError: true` (MCP/Anthropic convention) or `details.status: 'error'` (OpenClaw). */
|
|
5
|
+
function readResultErrorMessage(result) {
|
|
6
|
+
if (typeof result !== "object" || result === null) return null;
|
|
7
|
+
const r = result;
|
|
8
|
+
if (!(r.isError === true || r.details?.status === "error")) return null;
|
|
9
|
+
if (typeof r.details?.error === "string") return r.details.error;
|
|
10
|
+
if (Array.isArray(r.content)) {
|
|
11
|
+
for (const item of r.content) if (item.type === "text" && typeof item.text === "string") return item.text;
|
|
12
|
+
}
|
|
13
|
+
return "(no error text)";
|
|
14
|
+
}
|
|
15
|
+
/** First stack frame, for inline context without emitting a multi-line block. */
|
|
16
|
+
function firstFrame(err) {
|
|
17
|
+
if (!(err instanceof Error) || !err.stack) return "";
|
|
18
|
+
const frame = err.stack.split("\n").find((l) => l.trimStart().startsWith("at "));
|
|
19
|
+
return frame ? ` (${frame.trim()})` : "";
|
|
20
|
+
}
|
|
21
|
+
function buildLine(plugin, tool, kind, message, frame = "") {
|
|
22
|
+
return `[ERROR] alfe-tool plugin=${plugin} tool=${tool} ${kind}: ${message.replace(/\s+/g, " ").trim()}${frame}`.slice(0, 480);
|
|
23
|
+
}
|
|
24
|
+
function wrapExecute(tool, opts) {
|
|
25
|
+
const execute = tool.execute;
|
|
26
|
+
if (typeof execute !== "function") return;
|
|
27
|
+
const marked = tool;
|
|
28
|
+
if (marked[WRAPPED_MARKER]) return;
|
|
29
|
+
marked[WRAPPED_MARKER] = true;
|
|
30
|
+
const name = typeof tool.name === "string" ? tool.name : "(unnamed)";
|
|
31
|
+
tool.execute = async (...args) => {
|
|
32
|
+
try {
|
|
33
|
+
const result = await execute.apply(tool, args);
|
|
34
|
+
const resultError = readResultErrorMessage(result);
|
|
35
|
+
if (resultError !== null) try {
|
|
36
|
+
opts.emit(buildLine(opts.plugin, name, "result-error", resultError));
|
|
37
|
+
} catch {}
|
|
38
|
+
return result;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
try {
|
|
41
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
42
|
+
opts.emit(buildLine(opts.plugin, name, "thrown", message, firstFrame(err)));
|
|
43
|
+
} catch {}
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Wrap `api.registerTool` so every tool registered AFTER this call gets
|
|
50
|
+
* failure capture. Handles both OpenClaw registration signatures:
|
|
51
|
+
* `registerTool(toolDef)` and `registerTool((ctx) => toolDef, opts)`.
|
|
52
|
+
* Call once, first thing in the plugin's `activate`/`register` entry.
|
|
53
|
+
* Never throws.
|
|
54
|
+
*/
|
|
55
|
+
function installToolErrorCapture(api, options) {
|
|
56
|
+
try {
|
|
57
|
+
const markedApi = api;
|
|
58
|
+
if (markedApi[INSTALLED_MARKER]) return;
|
|
59
|
+
markedApi[INSTALLED_MARKER] = true;
|
|
60
|
+
const emit = options.emit ?? ((line) => {
|
|
61
|
+
process.stderr.write(`${line}\n`);
|
|
62
|
+
});
|
|
63
|
+
const opts = {
|
|
64
|
+
plugin: options.plugin,
|
|
65
|
+
emit
|
|
66
|
+
};
|
|
67
|
+
const original = api.registerTool.bind(api);
|
|
68
|
+
api.registerTool = (...args) => {
|
|
69
|
+
try {
|
|
70
|
+
const [first, ...rest] = args;
|
|
71
|
+
if (typeof first === "function") {
|
|
72
|
+
const factory = first;
|
|
73
|
+
const wrappedFactory = (...fa) => {
|
|
74
|
+
const tool = factory(...fa);
|
|
75
|
+
if (typeof tool === "object" && tool !== null) wrapExecute(tool, opts);
|
|
76
|
+
return tool;
|
|
77
|
+
};
|
|
78
|
+
return original(wrappedFactory, ...rest);
|
|
79
|
+
}
|
|
80
|
+
if (typeof first === "object" && first !== null) wrapExecute(first, opts);
|
|
81
|
+
return original(first, ...rest);
|
|
82
|
+
} catch {
|
|
83
|
+
return original(...args);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
} catch {}
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
1
89
|
//#region src/index.ts
|
|
2
90
|
/**
|
|
3
91
|
* Encode each path segment but keep the `/` separators — `encodeURIComponent`
|
|
@@ -494,30 +582,26 @@ var AgentApiClient = class {
|
|
|
494
582
|
};
|
|
495
583
|
}
|
|
496
584
|
/**
|
|
497
|
-
* Microsoft 365
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
* `mgc` credentials for the single (default) Microsoft account.
|
|
585
|
+
* Disconnects one connected Microsoft 365 account for the agent, by its
|
|
586
|
+
* `accountIdentifier`. Hits the generic per-account disconnect route
|
|
587
|
+
* (`DELETE /agent/connect/microsoft/accounts/{accountIdentifier}`), which
|
|
588
|
+
* resolves across the agent's full effective scope chain and deletes the
|
|
589
|
+
* matching Connection row. Returns the remaining accounts.
|
|
503
590
|
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
591
|
+
* IMPORTANT: pass the `accountIdentifier` from `getMicrosoftAccounts()`, NOT
|
|
592
|
+
* a synthesised email. For Microsoft, `accountIdentifier` is the user's email
|
|
593
|
+
* only when the Graph profile fetch succeeded at connect time; it falls back
|
|
594
|
+
* to the Azure tenant id (`tid` claim) otherwise. The backend matches on
|
|
595
|
+
* `accountIdentifier` exactly, so passing an email would 404 on those
|
|
596
|
+
* fallback-identifier accounts. (This is why the param is not named `email`,
|
|
597
|
+
* unlike `disconnectGoogleAccount` where the identifier is always the email.)
|
|
508
598
|
*/
|
|
509
|
-
async
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
clientId: raw.clientId ?? "",
|
|
516
|
-
clientSecret: raw.clientSecret ?? "",
|
|
517
|
-
email: raw.email ?? raw.accountIdentifier,
|
|
518
|
-
microsoftTenantId: raw.microsoftTenantId,
|
|
519
|
-
workspaceDomain: raw.workspaceDomain
|
|
520
|
-
};
|
|
599
|
+
async disconnectMicrosoftAccount(accountIdentifier) {
|
|
600
|
+
return { accounts: (await this.request(`/agent/connect/microsoft/accounts/${encodeURIComponent(accountIdentifier)}`, { method: "DELETE" })).accounts.map((a) => ({
|
|
601
|
+
accountIdentifier: a.accountIdentifier,
|
|
602
|
+
displayName: a.displayName ?? void 0,
|
|
603
|
+
connectedAt: a.connectedAt
|
|
604
|
+
})) };
|
|
521
605
|
}
|
|
522
606
|
/**
|
|
523
607
|
* Pattern A: multi-account credential fetch for Microsoft 365.
|
|
@@ -1240,6 +1324,6 @@ var AgentApiClient = class {
|
|
|
1240
1324
|
}
|
|
1241
1325
|
};
|
|
1242
1326
|
//#endregion
|
|
1243
|
-
export { AgentApiClient };
|
|
1327
|
+
export { AgentApiClient, installToolErrorCapture };
|
|
1244
1328
|
|
|
1245
1329
|
//# sourceMappingURL=index.js.map
|