@alfe.ai/openclaw-google 0.0.41 → 0.0.43

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/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # `@alfe.ai/openclaw-google`
2
+
3
+ OpenClaw tools for multi-account Google Workspace access through the
4
+ [`gws`](https://github.com/googleworkspace/cli) CLI.
5
+
6
+ The plugin exposes three tools:
7
+
8
+ - `google_list_accounts` discovers the connected accounts.
9
+ - `google_run_command` runs a `gws` command for one required account email.
10
+ - `google_disconnect_account` permanently disconnects one confirmed account.
11
+
12
+ ## Safety and command syntax
13
+
14
+ The account selector is mandatory for every credential-touching call. The
15
+ selected per-account config directory is the only Google credential source
16
+ passed to the child process; ambient Google token and credentials-file
17
+ environment variables are removed.
18
+
19
+ `command` uses familiar shell-style quoting only to form an argument vector—it
20
+ is never passed to a shell. This preserves JSON arguments such as:
21
+
22
+ ```text
23
+ drive files list --params '{"pageSize": 10}'
24
+ ```
25
+
26
+ `gws auth` commands are blocked because the integration owns authentication.
27
+ `--upload` and `--output` paths are confined to the configured agent workspace.
28
+ Destructive method names require `confirmCommand` to exactly repeat the command,
29
+ unless `--dry-run` is present. Account disconnection similarly requires an
30
+ exact `confirmEmail`.
31
+
32
+ Non-zero `gws` exits are returned as explicit tool errors. Their diagnostics
33
+ are bounded and redact credentials plus local config/workspace paths.
34
+
35
+ ## Development
36
+
37
+ ```bash
38
+ pnpm --filter @alfe.ai/openclaw-google lint
39
+ pnpm --filter @alfe.ai/openclaw-google typecheck
40
+ pnpm --filter @alfe.ai/openclaw-google test
41
+ pnpm --filter @alfe.ai/openclaw-google build
42
+ ```
43
+
44
+ The package publishes ESM and CJS entrypoints and declares its complete static
45
+ tool catalog in `openclaw.plugin.json`.
46
+
47
+ Part of [Alfe](https://alfe.ai). See the [documentation](https://docs.alfe.ai)
48
+ for platform setup.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const require_plugin = require("./plugin.cjs");
2
- module.exports = require_plugin;
1
+ const require_plugin = require("./plugin2.cjs");
2
+ module.exports = require_plugin.plugin;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import plugin from "./plugin.js";
1
+ import { t as plugin } from "./plugin2.js";
2
2
  export { plugin as default };
package/dist/plugin.cjs CHANGED
@@ -1,188 +1,2 @@
1
- let _sinclair_typebox = require("@sinclair/typebox");
2
- let _alfe_ai_config = require("@alfe.ai/config");
3
- let _alfe_ai_agent_api_client = require("@alfe.ai/agent-api-client");
4
- let _alfe_ai_openclaw_plugin_kit = require("@alfe.ai/openclaw-plugin-kit");
5
- let node_child_process = require("node:child_process");
6
- let node_path = require("node:path");
7
- let node_os = require("node:os");
8
- //#region src/plugin.ts
9
- /**
10
- * @alfe/openclaw-google — OpenClaw native plugin
11
- *
12
- * Registers Google Workspace account management tools with OpenClaw.
13
- * Multi-account by design — every gws command requires an explicit
14
- * `email` (schema-enforced) so the LLM picks the target account per call.
15
- *
16
- * Tools:
17
- * - google_list_accounts — list connected Google accounts
18
- * - google_run_command — run a gws command (requires email)
19
- * - google_disconnect_account — disconnect an account
20
- *
21
- * 2026-05-14 (connections-redesign PR 1): the "default account" concept is
22
- * gone. Use `google_list_accounts` to discover available accounts, then
23
- * pass `email` to `google_run_command` to target one.
24
- */
25
- const pkg = (0, require("node:module").createRequire)(require("url").pathToFileURL(__filename).href)("../package.json");
26
- const GOOGLE_ACTIVATION_KEY = (0, _alfe_ai_openclaw_plugin_kit.getActivationKey)("google");
27
- function sanitizeEmail(email) {
28
- return email.replace(/@/g, "-").replace(/\./g, "-");
29
- }
30
- function resolveConfigDir(email) {
31
- return (0, node_path.join)((0, node_os.homedir)(), ".config", `gws-${sanitizeEmail(email)}`);
32
- }
33
- let client = null;
34
- let cachedAccounts = [];
35
- function getClient() {
36
- if (!client) {
37
- const config = (0, _alfe_ai_config.resolveConfig)();
38
- client = new _alfe_ai_agent_api_client.AgentApiClient({
39
- apiKey: config.apiKey,
40
- apiUrl: config.apiUrl
41
- });
42
- }
43
- return client;
44
- }
45
- async function refreshAccountCache() {
46
- cachedAccounts = (await getClient().getGoogleCredentials()).accounts.map((a) => ({
47
- email: a.email,
48
- displayName: a.displayName,
49
- connectedAt: a.connectedAt,
50
- configDir: resolveConfigDir(a.email)
51
- }));
52
- return cachedAccounts;
53
- }
54
- function findAccount(email) {
55
- const account = cachedAccounts.find((a) => a.email === email);
56
- if (!account) throw new Error(`Google account "${email}" not found. Available: ${cachedAccounts.map((a) => a.email).join(", ")}`);
57
- return account;
58
- }
59
- function runGwsCommand(args, configDir) {
60
- return new Promise((resolve) => {
61
- (0, node_child_process.execFile)("gws", args, {
62
- env: {
63
- ...process.env,
64
- GOOGLE_WORKSPACE_CLI_CONFIG_DIR: configDir
65
- },
66
- timeout: 6e4,
67
- maxBuffer: 10 * 1024 * 1024
68
- }, (error, stdout, stderr) => {
69
- resolve({
70
- stdout,
71
- stderr,
72
- exitCode: typeof error?.code === "number" ? error.code : error ? 1 : 0
73
- });
74
- });
75
- });
76
- }
77
- const googleTools = [
78
- (0, _alfe_ai_openclaw_plugin_kit.defineTool)({
79
- name: "google_list_accounts",
80
- description: "List all connected Google Workspace accounts. Shows email, display name, when each account was connected, and the gws CLI config directory path. Use this to resolve which account to target (e.g., 'Kevin\\'s emails' → kevin@alfe.ai).",
81
- parameters: _sinclair_typebox.Type.Object({}),
82
- handler: async () => {
83
- const accounts = await refreshAccountCache();
84
- return {
85
- accounts: accounts.map((a) => ({
86
- email: a.email,
87
- displayName: a.displayName,
88
- connectedAt: a.connectedAt,
89
- configDir: a.configDir
90
- })),
91
- count: accounts.length
92
- };
93
- }
94
- }),
95
- (0, _alfe_ai_openclaw_plugin_kit.defineTool)({
96
- name: "google_run_command",
97
- description: "Run a gws (Google Workspace CLI) command targeting a specific account. Automatically sets GOOGLE_WORKSPACE_CLI_CONFIG_DIR for the target account. Email is required — call google_list_accounts first if you don't know which account to use. Example: google_run_command({ command: 'gmail list', email: 'kevin@alfe.ai' })",
98
- parameters: _sinclair_typebox.Type.Object({
99
- command: _sinclair_typebox.Type.String({ description: "The gws CLI command and arguments (e.g., 'gmail list', 'calendar agenda', 'drive list')" }),
100
- email: _sinclair_typebox.Type.String({ description: "Email of the Google account to use. Required — there is no implicit default." })
101
- }),
102
- handler: async (params) => {
103
- const { command, email } = params;
104
- if (cachedAccounts.length === 0) await refreshAccountCache();
105
- const account = findAccount(email);
106
- const args = command.split(/\s+/).filter(Boolean);
107
- if (args.length === 0) throw new Error("Command cannot be empty");
108
- const result = await runGwsCommand(args, account.configDir);
109
- return {
110
- account: account.email,
111
- command: `gws ${command}`,
112
- ...result
113
- };
114
- }
115
- }),
116
- (0, _alfe_ai_openclaw_plugin_kit.defineTool)({
117
- name: "google_disconnect_account",
118
- description: "Disconnect a specific Google account from this agent. Revokes the OAuth token and removes the account.",
119
- parameters: _sinclair_typebox.Type.Object({ email: _sinclair_typebox.Type.String({ description: "Email of the Google account to disconnect" }) }),
120
- handler: async (params) => {
121
- const { email } = params;
122
- const result = await getClient().disconnectGoogleAccount(email);
123
- await refreshAccountCache();
124
- return {
125
- message: `${email} has been disconnected`,
126
- remainingAccounts: result.accounts
127
- };
128
- }
129
- })
130
- ];
131
- const plugin = {
132
- id: "@alfe.ai/openclaw-google",
133
- name: "Alfe Google Workspace Plugin",
134
- description: "Multi-account Google Workspace management — list accounts and run gws commands with an explicit account selector",
135
- version: pkg.version,
136
- activate(api) {
137
- (0, _alfe_ai_agent_api_client.installToolErrorCapture)(api, { plugin: "openclaw-google" });
138
- const log = api.logger;
139
- for (const tool of googleTools) api.registerTool(tool);
140
- log.info(`Registered ${googleTools.length.toString()} Google tools: ${googleTools.map((t) => t.name).join(", ")}`);
141
- const startGoogleService = () => {
142
- (0, _alfe_ai_openclaw_plugin_kit.guardedStart)(GOOGLE_ACTIVATION_KEY, log, () => {
143
- log.info("Alfe Google Workspace plugin activating...");
144
- try {
145
- const config = (0, _alfe_ai_config.resolveConfig)();
146
- client = new _alfe_ai_agent_api_client.AgentApiClient({
147
- apiKey: config.apiKey,
148
- apiUrl: config.apiUrl
149
- });
150
- refreshAccountCache().then((accounts) => {
151
- log.info(`Cached ${accounts.length.toString()} Google account(s): ${accounts.map((a) => a.email).join(", ")}`);
152
- }).catch((err) => {
153
- log.warn(`Failed to pre-cache Google accounts: ${err instanceof Error ? err.message : "unknown"}`);
154
- });
155
- } catch (err) {
156
- log.error(`Failed to resolve config: ${err instanceof Error ? err.message : "unknown"}`);
157
- log.warn("Google tools will fail — no API config available");
158
- (0, _alfe_ai_openclaw_plugin_kit.resetActivation)(GOOGLE_ACTIVATION_KEY);
159
- return;
160
- }
161
- log.info("Alfe Google Workspace plugin activated");
162
- });
163
- };
164
- const stopGoogleService = () => {
165
- client = null;
166
- cachedAccounts = [];
167
- (0, _alfe_ai_openclaw_plugin_kit.resetActivation)(GOOGLE_ACTIVATION_KEY);
168
- log.info("Alfe Google Workspace plugin stopped");
169
- };
170
- if (api.registerService) api.registerService({
171
- id: "alfe-google-workspace",
172
- start: () => {
173
- startGoogleService();
174
- },
175
- stop: () => {
176
- stopGoogleService();
177
- }
178
- });
179
- },
180
- deactivate(api) {
181
- client = null;
182
- cachedAccounts = [];
183
- (0, _alfe_ai_openclaw_plugin_kit.resetActivation)(GOOGLE_ACTIVATION_KEY);
184
- api.logger.info("Alfe Google Workspace plugin deactivated");
185
- }
186
- };
187
- //#endregion
188
- module.exports = plugin;
1
+ const require_plugin = require("./plugin2.cjs");
2
+ module.exports = require_plugin.plugin;
package/dist/plugin.d.cts CHANGED
@@ -5,16 +5,6 @@ import { TSchema } from "@sinclair/typebox";
5
5
  //# sourceMappingURL=types.d.ts.map
6
6
  //#endregion
7
7
  //#region src/tools.d.ts
8
- /**
9
- * Tool-definition helpers — the `defineTool` / `ok` / `errResult` trio that
10
- * was copy-pasted across 8 plugins (identity, google, teams, mobile,
11
- * whatsapp, voice, chat a2a-tools, base openclaw).
12
- *
13
- * Error handling is standardized on the openclaw-google variant — the only
14
- * copy that survived non-`Error` throws (`e instanceof Error ? e.message :
15
- * "Unknown error"`). The other copies did `(e as Error).message`, which
16
- * crashes the tool executor when a handler throws a string/object.
17
- */
18
8
  /** Shape returned to OpenClaw from a tool `execute`. */
19
9
  interface ToolResult {
20
10
  content: {
@@ -22,15 +12,8 @@ interface ToolResult {
22
12
  text: string;
23
13
  }[];
24
14
  details: unknown;
15
+ isError?: boolean;
25
16
  }
26
- /**
27
- * An OpenClaw tool definition.
28
- *
29
- * `parameters` is generic because the fleet is split between TypeBox
30
- * `TSchema` schemas (identity/google/teams/mobile/whatsapp) and plain
31
- * JSON-Schema objects (chat a2a-tools). Instantiate with whichever schema
32
- * type the plugin uses — the kit itself has no schema dependency.
33
- */
34
17
  interface ToolDef<TParameters = unknown> {
35
18
  name: string;
36
19
  description: string;
@@ -38,44 +21,42 @@ interface ToolDef<TParameters = unknown> {
38
21
  parameters: TParameters;
39
22
  execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;
40
23
  }
41
- /** Wrap a successful handler result in the OpenClaw tool-result envelope. */
24
+ /** Deliberately model-safe validation/usage failure. Other exceptions stay private. */
42
25
  //#endregion
43
- //#region src/plugin.d.ts
44
-
45
- interface Logger {
46
- info(msg: string, ...args: unknown[]): void;
47
- warn(msg: string, ...args: unknown[]): void;
48
- error(msg: string, ...args: unknown[]): void;
49
- debug(msg: string, ...args: unknown[]): void;
26
+ //#region src/runtime.d.ts
27
+ interface PluginLogger {
28
+ info(message: string, ...args: unknown[]): void;
29
+ warn(message: string, ...args: unknown[]): void;
30
+ error(message: string, ...args: unknown[]): void;
31
+ debug(message: string, ...args: unknown[]): void;
50
32
  }
51
33
  interface PluginServiceContext {
52
34
  config?: Record<string, unknown>;
53
35
  workspaceDir?: string;
54
36
  stateDir?: string;
55
- logger?: Logger;
37
+ logger?: PluginLogger;
56
38
  }
57
- interface OpenClawPluginApi {
58
- logger: Logger;
59
- registrationMode?: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
39
+ interface PluginApi {
40
+ logger: PluginLogger;
41
+ registrationMode?: "full" | "discovery" | "tool-discovery" | "setup-only" | "setup-runtime" | "cli-metadata";
60
42
  registerTool(tool: ToolDef<TSchema>): void;
61
- registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
62
43
  registerService?(service: {
63
44
  id: string;
64
- start: (ctx: PluginServiceContext) => void | Promise<void>;
65
- stop?: (ctx: PluginServiceContext) => void | Promise<void>;
66
- }): void;
67
- on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
68
- priority?: number;
45
+ start: (context: PluginServiceContext) => void | Promise<void>;
46
+ stop?: (context: PluginServiceContext) => void | Promise<void>;
69
47
  }): void;
70
48
  }
71
- declare const plugin: {
49
+ interface GooglePlugin {
72
50
  id: string;
73
51
  name: string;
74
52
  description: string;
75
53
  version: string;
76
- activate(api: OpenClawPluginApi): void;
77
- deactivate(api: OpenClawPluginApi): void;
78
- };
54
+ activate(api: PluginApi): void;
55
+ deactivate(api: PluginApi): void;
56
+ }
57
+ //#endregion
58
+ //#region src/plugin.d.ts
59
+ declare const plugin: GooglePlugin;
79
60
  //#endregion
80
61
  export { plugin as t };
81
62
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":["KitLogger","ToolResult","ToolDef","TParameters","Record","Promise","ok","errResult","defineTool","IpcResponse","IpcClient","ConnectToDaemonOptions","connectToDaemon","ResolveOpenClawSdkOptions","resolveOpenClawSdk","T","getActivationKey","isActivated","resetActivation","guardedStart","ScheduleRefreshOptions","RefreshHandle","scheduleRefresh"],"sources":["../../openclaw-plugin-kit/dist/index.d.ts","../src/plugin.ts"],"sourcesContent":["//#region src/types.d.ts\n/**\n * Minimal logger contract shared by every helper in the kit.\n *\n * Deliberately the *narrowest* shape in the fleet: some plugins declare\n * variadic loggers (`info(msg: string, ...args: unknown[])`), others\n * single-arg (`info(msg: string)`). Both are assignable to this. The kit\n * only ever calls with a single string.\n */\ninterface KitLogger {\n info(msg: string): void;\n warn(msg: string): void;\n error(msg: string): void;\n debug(msg: string): void;\n}\n//# sourceMappingURL=types.d.ts.map\n//#endregion\n//#region src/tools.d.ts\n/**\n * Tool-definition helpers — the `defineTool` / `ok` / `errResult` trio that\n * was copy-pasted across 8 plugins (identity, google, teams, mobile,\n * whatsapp, voice, chat a2a-tools, base openclaw).\n *\n * Error handling is standardized on the openclaw-google variant — the only\n * copy that survived non-`Error` throws (`e instanceof Error ? e.message :\n * \"Unknown error\"`). The other copies did `(e as Error).message`, which\n * crashes the tool executor when a handler throws a string/object.\n */\n/** Shape returned to OpenClaw from a tool `execute`. */\ninterface ToolResult {\n content: {\n type: \"text\";\n text: string;\n }[];\n details: unknown;\n}\n/**\n * An OpenClaw tool definition.\n *\n * `parameters` is generic because the fleet is split between TypeBox\n * `TSchema` schemas (identity/google/teams/mobile/whatsapp) and plain\n * JSON-Schema objects (chat a2a-tools). Instantiate with whichever schema\n * type the plugin uses — the kit itself has no schema dependency.\n */\ninterface ToolDef<TParameters = unknown> {\n name: string;\n description: string;\n label: string;\n parameters: TParameters;\n execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;\n}\n/** Wrap a successful handler result in the OpenClaw tool-result envelope. */\ndeclare function ok(data: unknown): ToolResult;\n/** Wrap an error message in the OpenClaw tool-result envelope. */\ndeclare function errResult(message: string): ToolResult;\n/**\n * Define an OpenClaw tool from a plain async handler. Handler throws (of\n * any type — `Error` or not) are converted to `errResult` envelopes so the\n * LLM sees a structured error instead of the tool executor crashing.\n */\ndeclare function defineTool<TParameters>(def: {\n name: string;\n description: string;\n parameters: TParameters;\n handler: (params: Record<string, unknown>) => Promise<unknown>;\n}): ToolDef<TParameters>;\n//# sourceMappingURL=tools.d.ts.map\n//#endregion\n//#region src/daemon.d.ts\n/** Response envelope for daemon IPC requests. */\ninterface IpcResponse {\n ok: boolean;\n error?: {\n message?: string;\n };\n [key: string]: unknown;\n}\n/** The subset of `@alfe.ai/openclaw`'s IPCClient the kit relies on. */\ninterface IpcClient {\n on(event: string, handler: (...args: unknown[]) => void): void;\n request(method: string, params: Record<string, unknown>): Promise<IpcResponse>;\n start(): void;\n stop(): void;\n}\ninterface ConnectToDaemonOptions {\n /** Plugin package name sent with `capability.register` (e.g. `@alfe.ai/openclaw-sync`). */\n pluginId: string;\n /** Capabilities to register on every (re)connect. Constants stay per-plugin. */\n capabilities?: readonly string[];\n /**\n * Optional handler for daemon → plugin messages. Only invoked with\n * object payloads — the kit does the message-shape checking.\n */\n onMessage?: (msg: Record<string, unknown>) => void;\n /** Log line when the daemon isn't available (plugin runs standalone). */\n standaloneNote?: string;\n}\n/**\n * Attempt to connect to the Alfe daemon IPC socket. Returns `null` (after\n * an info log) when `@alfe.ai/openclaw` isn't installed — plugins degrade\n * gracefully to standalone mode.\n */\ndeclare function connectToDaemon(socketPath: string, log: KitLogger, options: ConnectToDaemonOptions): Promise<IpcClient | null>;\n//# sourceMappingURL=daemon.d.ts.map\n//#endregion\n//#region src/sdk.d.ts\ninterface ResolveOpenClawSdkOptions {\n /** Module specifier resolved from OpenClaw's context. */\n specifier?: string;\n /** Named export to extract from the resolved module. */\n exportName?: string;\n /** Warn line emitted when the SDK can't be resolved. */\n unresolvableNote?: string;\n}\n/**\n * Resolve a named export from the running OpenClaw process's SDK.\n *\n * Defaults target `dispatchInboundDirectDmWithRuntime` from\n * `openclaw/plugin-sdk/channel-inbound` — the export both existing\n * consumers (chat, google-chat) need. Returns `null` (after a warn log)\n * when unresolvable; callers degrade gracefully.\n */\ndeclare function resolveOpenClawSdk<T = unknown>(log: KitLogger, options?: ResolveOpenClawSdkOptions): T | null;\n//# sourceMappingURL=sdk.d.ts.map\n\n//#endregion\n//#region src/activation.d.ts\n/**\n * Canonical activation-flag key for a plugin: `__alfe<Name>PluginActivated`.\n *\n * Accepts a short name (`\"google\"`, `\"google-chat\"`) or a full package name\n * (`\"@alfe.ai/openclaw-teams\"`); scope + `openclaw-` prefix are stripped\n * and the remainder PascalCased:\n *\n * getActivationKey(\"google\") → \"__alfeGooglePluginActivated\"\n * getActivationKey(\"google-chat\") → \"__alfeGoogleChatPluginActivated\"\n * getActivationKey(\"@alfe.ai/openclaw-teams\") → \"__alfeTeamsPluginActivated\"\n */\ndeclare function getActivationKey(name: string): string;\n/** True when the activation flag for `key` is currently set. */\ndeclare function isActivated(key: string): boolean;\n/**\n * Clear the activation flag so a later start can run again.\n *\n * Call this LAST in stop/deactivate paths — after side effects are stopped\n * (see the ordering rule in the module doc). Also exported for soft-failure\n * paths inside a `guardedStart` fn that want to log at a custom level and\n * return normally instead of throwing.\n */\ndeclare function resetActivation(key: string): void;\n/**\n * Run a service start exactly once per activation cycle.\n *\n * - If the flag is already set, logs at debug and returns `false` (skipped).\n * - Otherwise sets the flag and runs `fn`.\n * - If `fn` throws synchronously OR returns a promise that rejects, the\n * flag is RESET (so a later activate can retry) and the error is logged.\n * Errors are not rethrown — matching fleet behavior where a failed start\n * must never crash the host's plugin loader.\n *\n * Returns `true` when the start was initiated (even if an async portion\n * later fails), `false` when skipped or when `fn` threw synchronously.\n *\n * Note: cleaning up partial side effects on failure is `fn`'s job (throw\n * only after tearing down what was started); the kit only guarantees the\n * flag reset happens after `fn` has failed — i.e. after `fn`'s own cleanup.\n */\ndeclare function guardedStart(key: string, log: KitLogger, fn: () => void | Promise<void>): boolean;\n//# sourceMappingURL=activation.d.ts.map\n//#endregion\n//#region src/refresh.d.ts\ninterface ScheduleRefreshOptions {\n /** Cadence between successful refreshes (per-provider token lifetime — stays in the consuming package). */\n intervalMs: number;\n /** Delay before retrying after a failed refresh. */\n retryMs: number;\n /** Run one refresh immediately instead of waiting a full interval first. Default false. */\n immediate?: boolean;\n}\ninterface RefreshHandle {\n /** Cancel the schedule. Safe to call multiple times. */\n stop(): void;\n}\n/**\n * Run `refreshFn` every `intervalMs`; on failure, log a warning and retry\n * after `retryMs`. Timers are unref'd so the schedule never keeps the\n * process alive.\n */\ndeclare function scheduleRefresh(refreshFn: () => Promise<void>, options: ScheduleRefreshOptions, log: KitLogger): RefreshHandle;\n//# sourceMappingURL=refresh.d.ts.map\n\n//#endregion\nexport { type ConnectToDaemonOptions, type IpcClient, type IpcResponse, type KitLogger, type RefreshHandle, type ResolveOpenClawSdkOptions, type ScheduleRefreshOptions, type ToolDef, type ToolResult, connectToDaemon, defineTool, errResult, getActivationKey, guardedStart, isActivated, ok, resetActivation, resolveOpenClawSdk, scheduleRefresh };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;ACkCgB;;;;;AAWC;;;;;;;;;UDhBPC,UAAAA,CC2BuC;SAEW,EAAA;IAAO,IAAA,EAAA,MAAA;IAoK7D,IAAA,EAAA,MAqEL;EAAA,CAAA,EAAA;SA/De,EAAA,OAAA;;;;;;;;;;UDxLNC;;;;cAIIC;wCAC0BC,4BAA4BC,QAAQJ;;;;;;UCflE,MAAA,CAWC;EAAM,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAGP,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAA,KAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;OACjB,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;UARA,oBAAA,CAUW;QACkD,CAAA,EAV5D,MAU4D,CAAA,MAAA,EAAA,OAAA,CAAA;cAGtD,CAAA,EAAA,MAAA;UAAgC,CAAA,EAAA,MAAA;QAChC,CAAA,EAXN,MAWM;;UARP,iBAAA,CAUkD;EAAO,MAAA,EATzD,MASyD;EAoK7D,gBAqEL,CAAA,EAAA,MAAA,GAAA,YAAA,GAAA,eAAA,GAAA,cAAA;EAAA,YAAA,CAAA,IAAA,EAhPoB,OAgPpB,CAhP4B,OAgP5B,CAAA,CAAA,EAAA,IAAA;uBA/De,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAhLuD,OAgLvD,CAAA,OAAA,CAAA,CAAA,EAAA,IAAA;iBAwDE,EAAA,OAAA,EAAA;IAAiB,EAAA,EAAA,MAAA;iBArOlB,gCAAgC;iBAChC,gCAAgC;;4DAEW;;;;cAoKtD;;;;;gBAMU;kBAwDE"}
1
+ {"version":3,"file":"plugin.d.cts","names":["KitLogger","ToolResult","ToolDef","TParameters","Record","Promise","PublicToolError","Error","publicToolError","ok","errResult","defineTool","IpcResponse","IpcClient","IpcModule","ConnectToDaemonOptions","ConnectToDaemonDependencies","connectToDaemon","ResolveOpenClawSdkOptions","ResolveOpenClawSdkDependencies","resolveOpenClawSdk","T","getActivationKey","isActivated","resetActivation","guardedStart"],"sources":["../../openclaw-plugin-kit/dist/index.d.ts","../src/runtime.ts","../src/plugin.ts"],"sourcesContent":["//#region src/types.d.ts\n/**\n * Minimal logger contract shared by every helper in the kit.\n *\n * Deliberately the *narrowest* shape in the fleet: some plugins declare\n * variadic loggers (`info(msg: string, ...args: unknown[])`), others\n * single-arg (`info(msg: string)`). Both are assignable to this. The kit\n * only ever calls with a single string.\n */\ninterface KitLogger {\n info(msg: string): void;\n warn(msg: string): void;\n error(msg: string): void;\n debug(msg: string): void;\n}\n//# sourceMappingURL=types.d.ts.map\n//#endregion\n//#region src/tools.d.ts\n/** Shape returned to OpenClaw from a tool `execute`. */\ninterface ToolResult {\n content: {\n type: \"text\";\n text: string;\n }[];\n details: unknown;\n isError?: boolean;\n}\ninterface ToolDef<TParameters = unknown> {\n name: string;\n description: string;\n label: string;\n parameters: TParameters;\n execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;\n}\n/** Deliberately model-safe validation/usage failure. Other exceptions stay private. */\ndeclare class PublicToolError extends Error {\n readonly name = \"PublicToolError\";\n}\ndeclare function publicToolError(message: string): PublicToolError;\n/** Wrap bounded JSON in the OpenClaw tool-result envelope. */\ndeclare function ok(data: unknown): ToolResult;\n/** Wrap an explicitly public error in a captured OpenClaw error envelope. */\ndeclare function errResult(message: string): ToolResult;\n/**\n * Define a tool whose unexpected exceptions never expose provider, filesystem,\n * credential, or transport diagnostics to the model. Throw `PublicToolError`\n * only for a message deliberately safe for model display.\n */\ndeclare function defineTool<TParameters>(def: {\n name: string;\n description: string;\n parameters: TParameters;\n handler: (params: Record<string, unknown>) => Promise<unknown>;\n}): ToolDef<TParameters>;\n//# sourceMappingURL=tools.d.ts.map\n//#endregion\n//#region src/daemon.d.ts\ninterface IpcResponse {\n ok: boolean;\n error?: {\n message?: string;\n };\n [key: string]: unknown;\n}\ninterface IpcClient {\n on(event: string, handler: (...args: unknown[]) => void): void;\n request(method: string, params: Record<string, unknown>): Promise<IpcResponse>;\n start(): void;\n stop(): void;\n}\ninterface IpcModule {\n IPCClient: new (socketPath: string, log: KitLogger) => IpcClient;\n}\ninterface ConnectToDaemonOptions {\n pluginId: string;\n capabilities?: readonly string[];\n onMessage?: (msg: Record<string, unknown>) => void;\n standaloneNote?: string;\n}\ninterface ConnectToDaemonDependencies {\n loadIpcModule?: () => Promise<IpcModule>;\n}\ndeclare function connectToDaemon(socketPath: string, log: KitLogger, options: ConnectToDaemonOptions, dependencies?: ConnectToDaemonDependencies): Promise<IpcClient | null>;\n//#endregion\n//#region src/sdk.d.ts\ninterface ResolveOpenClawSdkOptions {\n specifier?: string;\n exportName?: string;\n unresolvableNote?: string;\n}\ninterface ResolveOpenClawSdkDependencies {\n anchors?: readonly string[];\n globalPackageJsonPath?: string;\n requireFrom?: (anchor: string) => (specifier: string) => unknown;\n}\ndeclare function resolveOpenClawSdk<T = unknown>(log: KitLogger, options?: ResolveOpenClawSdkOptions, dependencies?: ResolveOpenClawSdkDependencies): T | null;\n//# sourceMappingURL=sdk.d.ts.map\n\n//#endregion\n//#region src/activation.d.ts\n/**\n * Canonical activation-flag key for a plugin: `__alfe<Name>PluginActivated`.\n *\n * Accepts a short name (`\"google\"`, `\"google-chat\"`) or a full package name\n * (`\"@alfe.ai/openclaw-teams\"`); scope + `openclaw-` prefix are stripped\n * and the remainder PascalCased:\n *\n * getActivationKey(\"google\") → \"__alfeGooglePluginActivated\"\n * getActivationKey(\"google-chat\") → \"__alfeGoogleChatPluginActivated\"\n * getActivationKey(\"@alfe.ai/openclaw-teams\") → \"__alfeTeamsPluginActivated\"\n */\ndeclare function getActivationKey(name: string): string;\n/** True when the activation flag for `key` is currently set. */\ndeclare function isActivated(key: string): boolean;\n/**\n * Clear the activation flag so a later start can run again.\n *\n * Call this LAST in stop/deactivate paths — after side effects are stopped\n * (see the ordering rule in the module doc). Also exported for soft-failure\n * paths inside a `guardedStart` fn that want to log at a custom level and\n * return normally instead of throwing.\n */\ndeclare function resetActivation(key: string): void;\n/**\n * Run a service start exactly once per activation cycle.\n *\n * - If the flag is already set, logs at debug and returns `false` (skipped).\n * - Otherwise sets the flag and runs `fn`.\n * - If `fn` throws synchronously OR returns a promise that rejects, the\n * flag is RESET (so a later activate can retry) and the error is logged.\n * Errors are not rethrown — matching fleet behavior where a failed start\n * must never crash the host's plugin loader.\n *\n * Returns `true` when the start was initiated (even if an async portion\n * later fails), `false` when skipped or when `fn` threw synchronously.\n *\n * Note: cleaning up partial side effects on failure is `fn`'s job (throw\n * only after tearing down what was started); the kit only guarantees the\n * flag reset happens after `fn` has failed — i.e. after `fn`'s own cleanup.\n */\ndeclare function guardedStart(key: string, log: KitLogger, fn: () => void | Promise<void>): boolean;\n//# sourceMappingURL=activation.d.ts.map\n\n//#endregion\nexport { type ConnectToDaemonDependencies, type ConnectToDaemonOptions, type IpcClient, type IpcResponse, type KitLogger, PublicToolError, type ResolveOpenClawSdkDependencies, type ResolveOpenClawSdkOptions, type ToolDef, type ToolResult, connectToDaemon, defineTool, errResult, getActivationKey, guardedStart, isActivated, ok, publicToolError, resetActivation, resolveOpenClawSdk };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;ACyCC;;;;UDtBSC,UAAAA,CC4Ba;EAGvB,OAAiB,EAAA;IAAS,IAAA,EAAA,MAAA;QAChB,EAAA,MAAA;;SAQW,EAAA,OAAA;SAGA,CAAA,EAAA,OAAA;;UDnCXC,OCoCW,CAAA,cAAA,OAAA,CAAA,CAAA;QAAgC,MAAA;EAAO,WAAA,EAAA,MAAA;EAuC5D,KAAiB,EAAA,MAAA;EAAY,UAAA,EDvEfC,WCuEe;SAKb,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,MAAA,ED3EwBC,MC2ExB,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GD3EoDC,OC2EpD,CD3E4DJ,UC2E5D,CAAA;;;;;AD3EwBG,UCIvB,YAAA,CDJuBA;MAAoCH,CAAAA,OAAAA,EAAAA,MAAAA,EAAAA,GAAAA,IAAAA,EAAAA,OAAAA,EAAAA,CAAAA,EAAAA,IAAAA;MAARI,CAAAA,OAAAA,EAAAA,MAAAA,EAAAA,GAAAA,IAAAA,EAAAA,OAAAA,EAAAA,CAAAA,EAAAA,IAAAA;EAAO,KAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;;UCWjE,oBAAA;EAPO,MAAA,CAAA,EAQN,MARkB,CAAA,MAAA,EAAA,OAAA,CAAA;EAOnB,YAAA,CAAA,EAAA,MAAA;EAAoB,QAAA,CAAA,EAAA,MAAA;QACnB,CAAA,EAGA,YAHA;;AAGY,UAGN,SAAA,CAHM;EAGN,MAAA,EACP,YADgB;EAAA,gBAAA,CAAA,EAAA,MAAA,GAAA,WAAA,GAAA,gBAAA,GAAA,YAAA,GAAA,eAAA,GAAA,cAAA;cAChB,CAAA,IAAA,EAQW,OARX,CAQmB,OARnB,CAAA,CAAA,EAAA,IAAA;iBAQmB,EAAA,OAAA,EAAA;IAAR,EAAA,EAAA,MAAA;IAGA,KAAA,EAAA,CAAA,OAAA,EAAA,oBAAA,EAAA,GAAA,IAAA,GAAgC,OAAhC,CAAA,IAAA,CAAA;IAAgC,IAAA,CAAA,EAAA,CAAA,OAAA,EAChC,oBADgC,EAAA,GAAA,IAAA,GACA,OADA,CAAA,IAAA,CAAA;MAChC,IAAA;;UAuCJ,YAAA;;;;;gBAKD;kBACE;;;;cCxGZ,QAAQ"}
package/dist/plugin.d.ts CHANGED
@@ -5,16 +5,6 @@ import { TSchema } from "@sinclair/typebox";
5
5
  //# sourceMappingURL=types.d.ts.map
6
6
  //#endregion
7
7
  //#region src/tools.d.ts
8
- /**
9
- * Tool-definition helpers — the `defineTool` / `ok` / `errResult` trio that
10
- * was copy-pasted across 8 plugins (identity, google, teams, mobile,
11
- * whatsapp, voice, chat a2a-tools, base openclaw).
12
- *
13
- * Error handling is standardized on the openclaw-google variant — the only
14
- * copy that survived non-`Error` throws (`e instanceof Error ? e.message :
15
- * "Unknown error"`). The other copies did `(e as Error).message`, which
16
- * crashes the tool executor when a handler throws a string/object.
17
- */
18
8
  /** Shape returned to OpenClaw from a tool `execute`. */
19
9
  interface ToolResult {
20
10
  content: {
@@ -22,15 +12,8 @@ interface ToolResult {
22
12
  text: string;
23
13
  }[];
24
14
  details: unknown;
15
+ isError?: boolean;
25
16
  }
26
- /**
27
- * An OpenClaw tool definition.
28
- *
29
- * `parameters` is generic because the fleet is split between TypeBox
30
- * `TSchema` schemas (identity/google/teams/mobile/whatsapp) and plain
31
- * JSON-Schema objects (chat a2a-tools). Instantiate with whichever schema
32
- * type the plugin uses — the kit itself has no schema dependency.
33
- */
34
17
  interface ToolDef<TParameters = unknown> {
35
18
  name: string;
36
19
  description: string;
@@ -38,44 +21,42 @@ interface ToolDef<TParameters = unknown> {
38
21
  parameters: TParameters;
39
22
  execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;
40
23
  }
41
- /** Wrap a successful handler result in the OpenClaw tool-result envelope. */
24
+ /** Deliberately model-safe validation/usage failure. Other exceptions stay private. */
42
25
  //#endregion
43
- //#region src/plugin.d.ts
44
-
45
- interface Logger {
46
- info(msg: string, ...args: unknown[]): void;
47
- warn(msg: string, ...args: unknown[]): void;
48
- error(msg: string, ...args: unknown[]): void;
49
- debug(msg: string, ...args: unknown[]): void;
26
+ //#region src/runtime.d.ts
27
+ interface PluginLogger {
28
+ info(message: string, ...args: unknown[]): void;
29
+ warn(message: string, ...args: unknown[]): void;
30
+ error(message: string, ...args: unknown[]): void;
31
+ debug(message: string, ...args: unknown[]): void;
50
32
  }
51
33
  interface PluginServiceContext {
52
34
  config?: Record<string, unknown>;
53
35
  workspaceDir?: string;
54
36
  stateDir?: string;
55
- logger?: Logger;
37
+ logger?: PluginLogger;
56
38
  }
57
- interface OpenClawPluginApi {
58
- logger: Logger;
59
- registrationMode?: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
39
+ interface PluginApi {
40
+ logger: PluginLogger;
41
+ registrationMode?: "full" | "discovery" | "tool-discovery" | "setup-only" | "setup-runtime" | "cli-metadata";
60
42
  registerTool(tool: ToolDef<TSchema>): void;
61
- registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
62
43
  registerService?(service: {
63
44
  id: string;
64
- start: (ctx: PluginServiceContext) => void | Promise<void>;
65
- stop?: (ctx: PluginServiceContext) => void | Promise<void>;
66
- }): void;
67
- on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
68
- priority?: number;
45
+ start: (context: PluginServiceContext) => void | Promise<void>;
46
+ stop?: (context: PluginServiceContext) => void | Promise<void>;
69
47
  }): void;
70
48
  }
71
- declare const plugin: {
49
+ interface GooglePlugin {
72
50
  id: string;
73
51
  name: string;
74
52
  description: string;
75
53
  version: string;
76
- activate(api: OpenClawPluginApi): void;
77
- deactivate(api: OpenClawPluginApi): void;
78
- };
54
+ activate(api: PluginApi): void;
55
+ deactivate(api: PluginApi): void;
56
+ }
57
+ //#endregion
58
+ //#region src/plugin.d.ts
59
+ declare const plugin: GooglePlugin;
79
60
  //#endregion
80
61
  export { plugin as t };
81
62
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","names":["KitLogger","ToolResult","ToolDef","TParameters","Record","Promise","ok","errResult","defineTool","IpcResponse","IpcClient","ConnectToDaemonOptions","connectToDaemon","ResolveOpenClawSdkOptions","resolveOpenClawSdk","T","getActivationKey","isActivated","resetActivation","guardedStart","ScheduleRefreshOptions","RefreshHandle","scheduleRefresh"],"sources":["../../openclaw-plugin-kit/dist/index.d.ts","../src/plugin.ts"],"sourcesContent":["//#region src/types.d.ts\n/**\n * Minimal logger contract shared by every helper in the kit.\n *\n * Deliberately the *narrowest* shape in the fleet: some plugins declare\n * variadic loggers (`info(msg: string, ...args: unknown[])`), others\n * single-arg (`info(msg: string)`). Both are assignable to this. The kit\n * only ever calls with a single string.\n */\ninterface KitLogger {\n info(msg: string): void;\n warn(msg: string): void;\n error(msg: string): void;\n debug(msg: string): void;\n}\n//# sourceMappingURL=types.d.ts.map\n//#endregion\n//#region src/tools.d.ts\n/**\n * Tool-definition helpers — the `defineTool` / `ok` / `errResult` trio that\n * was copy-pasted across 8 plugins (identity, google, teams, mobile,\n * whatsapp, voice, chat a2a-tools, base openclaw).\n *\n * Error handling is standardized on the openclaw-google variant — the only\n * copy that survived non-`Error` throws (`e instanceof Error ? e.message :\n * \"Unknown error\"`). The other copies did `(e as Error).message`, which\n * crashes the tool executor when a handler throws a string/object.\n */\n/** Shape returned to OpenClaw from a tool `execute`. */\ninterface ToolResult {\n content: {\n type: \"text\";\n text: string;\n }[];\n details: unknown;\n}\n/**\n * An OpenClaw tool definition.\n *\n * `parameters` is generic because the fleet is split between TypeBox\n * `TSchema` schemas (identity/google/teams/mobile/whatsapp) and plain\n * JSON-Schema objects (chat a2a-tools). Instantiate with whichever schema\n * type the plugin uses — the kit itself has no schema dependency.\n */\ninterface ToolDef<TParameters = unknown> {\n name: string;\n description: string;\n label: string;\n parameters: TParameters;\n execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;\n}\n/** Wrap a successful handler result in the OpenClaw tool-result envelope. */\ndeclare function ok(data: unknown): ToolResult;\n/** Wrap an error message in the OpenClaw tool-result envelope. */\ndeclare function errResult(message: string): ToolResult;\n/**\n * Define an OpenClaw tool from a plain async handler. Handler throws (of\n * any type — `Error` or not) are converted to `errResult` envelopes so the\n * LLM sees a structured error instead of the tool executor crashing.\n */\ndeclare function defineTool<TParameters>(def: {\n name: string;\n description: string;\n parameters: TParameters;\n handler: (params: Record<string, unknown>) => Promise<unknown>;\n}): ToolDef<TParameters>;\n//# sourceMappingURL=tools.d.ts.map\n//#endregion\n//#region src/daemon.d.ts\n/** Response envelope for daemon IPC requests. */\ninterface IpcResponse {\n ok: boolean;\n error?: {\n message?: string;\n };\n [key: string]: unknown;\n}\n/** The subset of `@alfe.ai/openclaw`'s IPCClient the kit relies on. */\ninterface IpcClient {\n on(event: string, handler: (...args: unknown[]) => void): void;\n request(method: string, params: Record<string, unknown>): Promise<IpcResponse>;\n start(): void;\n stop(): void;\n}\ninterface ConnectToDaemonOptions {\n /** Plugin package name sent with `capability.register` (e.g. `@alfe.ai/openclaw-sync`). */\n pluginId: string;\n /** Capabilities to register on every (re)connect. Constants stay per-plugin. */\n capabilities?: readonly string[];\n /**\n * Optional handler for daemon → plugin messages. Only invoked with\n * object payloads — the kit does the message-shape checking.\n */\n onMessage?: (msg: Record<string, unknown>) => void;\n /** Log line when the daemon isn't available (plugin runs standalone). */\n standaloneNote?: string;\n}\n/**\n * Attempt to connect to the Alfe daemon IPC socket. Returns `null` (after\n * an info log) when `@alfe.ai/openclaw` isn't installed — plugins degrade\n * gracefully to standalone mode.\n */\ndeclare function connectToDaemon(socketPath: string, log: KitLogger, options: ConnectToDaemonOptions): Promise<IpcClient | null>;\n//# sourceMappingURL=daemon.d.ts.map\n//#endregion\n//#region src/sdk.d.ts\ninterface ResolveOpenClawSdkOptions {\n /** Module specifier resolved from OpenClaw's context. */\n specifier?: string;\n /** Named export to extract from the resolved module. */\n exportName?: string;\n /** Warn line emitted when the SDK can't be resolved. */\n unresolvableNote?: string;\n}\n/**\n * Resolve a named export from the running OpenClaw process's SDK.\n *\n * Defaults target `dispatchInboundDirectDmWithRuntime` from\n * `openclaw/plugin-sdk/channel-inbound` — the export both existing\n * consumers (chat, google-chat) need. Returns `null` (after a warn log)\n * when unresolvable; callers degrade gracefully.\n */\ndeclare function resolveOpenClawSdk<T = unknown>(log: KitLogger, options?: ResolveOpenClawSdkOptions): T | null;\n//# sourceMappingURL=sdk.d.ts.map\n\n//#endregion\n//#region src/activation.d.ts\n/**\n * Canonical activation-flag key for a plugin: `__alfe<Name>PluginActivated`.\n *\n * Accepts a short name (`\"google\"`, `\"google-chat\"`) or a full package name\n * (`\"@alfe.ai/openclaw-teams\"`); scope + `openclaw-` prefix are stripped\n * and the remainder PascalCased:\n *\n * getActivationKey(\"google\") → \"__alfeGooglePluginActivated\"\n * getActivationKey(\"google-chat\") → \"__alfeGoogleChatPluginActivated\"\n * getActivationKey(\"@alfe.ai/openclaw-teams\") → \"__alfeTeamsPluginActivated\"\n */\ndeclare function getActivationKey(name: string): string;\n/** True when the activation flag for `key` is currently set. */\ndeclare function isActivated(key: string): boolean;\n/**\n * Clear the activation flag so a later start can run again.\n *\n * Call this LAST in stop/deactivate paths — after side effects are stopped\n * (see the ordering rule in the module doc). Also exported for soft-failure\n * paths inside a `guardedStart` fn that want to log at a custom level and\n * return normally instead of throwing.\n */\ndeclare function resetActivation(key: string): void;\n/**\n * Run a service start exactly once per activation cycle.\n *\n * - If the flag is already set, logs at debug and returns `false` (skipped).\n * - Otherwise sets the flag and runs `fn`.\n * - If `fn` throws synchronously OR returns a promise that rejects, the\n * flag is RESET (so a later activate can retry) and the error is logged.\n * Errors are not rethrown — matching fleet behavior where a failed start\n * must never crash the host's plugin loader.\n *\n * Returns `true` when the start was initiated (even if an async portion\n * later fails), `false` when skipped or when `fn` threw synchronously.\n *\n * Note: cleaning up partial side effects on failure is `fn`'s job (throw\n * only after tearing down what was started); the kit only guarantees the\n * flag reset happens after `fn` has failed — i.e. after `fn`'s own cleanup.\n */\ndeclare function guardedStart(key: string, log: KitLogger, fn: () => void | Promise<void>): boolean;\n//# sourceMappingURL=activation.d.ts.map\n//#endregion\n//#region src/refresh.d.ts\ninterface ScheduleRefreshOptions {\n /** Cadence between successful refreshes (per-provider token lifetime — stays in the consuming package). */\n intervalMs: number;\n /** Delay before retrying after a failed refresh. */\n retryMs: number;\n /** Run one refresh immediately instead of waiting a full interval first. Default false. */\n immediate?: boolean;\n}\ninterface RefreshHandle {\n /** Cancel the schedule. Safe to call multiple times. */\n stop(): void;\n}\n/**\n * Run `refreshFn` every `intervalMs`; on failure, log a warning and retry\n * after `retryMs`. Timers are unref'd so the schedule never keeps the\n * process alive.\n */\ndeclare function scheduleRefresh(refreshFn: () => Promise<void>, options: ScheduleRefreshOptions, log: KitLogger): RefreshHandle;\n//# sourceMappingURL=refresh.d.ts.map\n\n//#endregion\nexport { type ConnectToDaemonOptions, type IpcClient, type IpcResponse, type KitLogger, type RefreshHandle, type ResolveOpenClawSdkOptions, type ScheduleRefreshOptions, type ToolDef, type ToolResult, connectToDaemon, defineTool, errResult, getActivationKey, guardedStart, isActivated, ok, resetActivation, resolveOpenClawSdk, scheduleRefresh };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;ACkCgB;;;;;AAWC;;;;;;;;;UDhBPC,UAAAA,CC2BuC;SAEW,EAAA;IAAO,IAAA,EAAA,MAAA;IAoK7D,IAAA,EAAA,MAqEL;EAAA,CAAA,EAAA;SA/De,EAAA,OAAA;;;;;;;;;;UDxLNC;;;;cAIIC;wCAC0BC,4BAA4BC,QAAQJ;;;;;;UCflE,MAAA,CAWC;EAAM,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAGP,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAiB,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAA,KAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;OACjB,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;UARA,oBAAA,CAUW;QACkD,CAAA,EAV5D,MAU4D,CAAA,MAAA,EAAA,OAAA,CAAA;cAGtD,CAAA,EAAA,MAAA;UAAgC,CAAA,EAAA,MAAA;QAChC,CAAA,EAXN,MAWM;;UARP,iBAAA,CAUkD;EAAO,MAAA,EATzD,MASyD;EAoK7D,gBAqEL,CAAA,EAAA,MAAA,GAAA,YAAA,GAAA,eAAA,GAAA,cAAA;EAAA,YAAA,CAAA,IAAA,EAhPoB,OAgPpB,CAhP4B,OAgP5B,CAAA,CAAA,EAAA,IAAA;uBA/De,CAAA,IAAA,EAAA,MAAA,EAAA,OAAA,EAAA,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAhLuD,OAgLvD,CAAA,OAAA,CAAA,CAAA,EAAA,IAAA;iBAwDE,EAAA,OAAA,EAAA;IAAiB,EAAA,EAAA,MAAA;iBArOlB,gCAAgC;iBAChC,gCAAgC;;4DAEW;;;;cAoKtD;;;;;gBAMU;kBAwDE"}
1
+ {"version":3,"file":"plugin.d.ts","names":["KitLogger","ToolResult","ToolDef","TParameters","Record","Promise","PublicToolError","Error","publicToolError","ok","errResult","defineTool","IpcResponse","IpcClient","IpcModule","ConnectToDaemonOptions","ConnectToDaemonDependencies","connectToDaemon","ResolveOpenClawSdkOptions","ResolveOpenClawSdkDependencies","resolveOpenClawSdk","T","getActivationKey","isActivated","resetActivation","guardedStart"],"sources":["../../openclaw-plugin-kit/dist/index.d.ts","../src/runtime.ts","../src/plugin.ts"],"sourcesContent":["//#region src/types.d.ts\n/**\n * Minimal logger contract shared by every helper in the kit.\n *\n * Deliberately the *narrowest* shape in the fleet: some plugins declare\n * variadic loggers (`info(msg: string, ...args: unknown[])`), others\n * single-arg (`info(msg: string)`). Both are assignable to this. The kit\n * only ever calls with a single string.\n */\ninterface KitLogger {\n info(msg: string): void;\n warn(msg: string): void;\n error(msg: string): void;\n debug(msg: string): void;\n}\n//# sourceMappingURL=types.d.ts.map\n//#endregion\n//#region src/tools.d.ts\n/** Shape returned to OpenClaw from a tool `execute`. */\ninterface ToolResult {\n content: {\n type: \"text\";\n text: string;\n }[];\n details: unknown;\n isError?: boolean;\n}\ninterface ToolDef<TParameters = unknown> {\n name: string;\n description: string;\n label: string;\n parameters: TParameters;\n execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;\n}\n/** Deliberately model-safe validation/usage failure. Other exceptions stay private. */\ndeclare class PublicToolError extends Error {\n readonly name = \"PublicToolError\";\n}\ndeclare function publicToolError(message: string): PublicToolError;\n/** Wrap bounded JSON in the OpenClaw tool-result envelope. */\ndeclare function ok(data: unknown): ToolResult;\n/** Wrap an explicitly public error in a captured OpenClaw error envelope. */\ndeclare function errResult(message: string): ToolResult;\n/**\n * Define a tool whose unexpected exceptions never expose provider, filesystem,\n * credential, or transport diagnostics to the model. Throw `PublicToolError`\n * only for a message deliberately safe for model display.\n */\ndeclare function defineTool<TParameters>(def: {\n name: string;\n description: string;\n parameters: TParameters;\n handler: (params: Record<string, unknown>) => Promise<unknown>;\n}): ToolDef<TParameters>;\n//# sourceMappingURL=tools.d.ts.map\n//#endregion\n//#region src/daemon.d.ts\ninterface IpcResponse {\n ok: boolean;\n error?: {\n message?: string;\n };\n [key: string]: unknown;\n}\ninterface IpcClient {\n on(event: string, handler: (...args: unknown[]) => void): void;\n request(method: string, params: Record<string, unknown>): Promise<IpcResponse>;\n start(): void;\n stop(): void;\n}\ninterface IpcModule {\n IPCClient: new (socketPath: string, log: KitLogger) => IpcClient;\n}\ninterface ConnectToDaemonOptions {\n pluginId: string;\n capabilities?: readonly string[];\n onMessage?: (msg: Record<string, unknown>) => void;\n standaloneNote?: string;\n}\ninterface ConnectToDaemonDependencies {\n loadIpcModule?: () => Promise<IpcModule>;\n}\ndeclare function connectToDaemon(socketPath: string, log: KitLogger, options: ConnectToDaemonOptions, dependencies?: ConnectToDaemonDependencies): Promise<IpcClient | null>;\n//#endregion\n//#region src/sdk.d.ts\ninterface ResolveOpenClawSdkOptions {\n specifier?: string;\n exportName?: string;\n unresolvableNote?: string;\n}\ninterface ResolveOpenClawSdkDependencies {\n anchors?: readonly string[];\n globalPackageJsonPath?: string;\n requireFrom?: (anchor: string) => (specifier: string) => unknown;\n}\ndeclare function resolveOpenClawSdk<T = unknown>(log: KitLogger, options?: ResolveOpenClawSdkOptions, dependencies?: ResolveOpenClawSdkDependencies): T | null;\n//# sourceMappingURL=sdk.d.ts.map\n\n//#endregion\n//#region src/activation.d.ts\n/**\n * Canonical activation-flag key for a plugin: `__alfe<Name>PluginActivated`.\n *\n * Accepts a short name (`\"google\"`, `\"google-chat\"`) or a full package name\n * (`\"@alfe.ai/openclaw-teams\"`); scope + `openclaw-` prefix are stripped\n * and the remainder PascalCased:\n *\n * getActivationKey(\"google\") → \"__alfeGooglePluginActivated\"\n * getActivationKey(\"google-chat\") → \"__alfeGoogleChatPluginActivated\"\n * getActivationKey(\"@alfe.ai/openclaw-teams\") → \"__alfeTeamsPluginActivated\"\n */\ndeclare function getActivationKey(name: string): string;\n/** True when the activation flag for `key` is currently set. */\ndeclare function isActivated(key: string): boolean;\n/**\n * Clear the activation flag so a later start can run again.\n *\n * Call this LAST in stop/deactivate paths — after side effects are stopped\n * (see the ordering rule in the module doc). Also exported for soft-failure\n * paths inside a `guardedStart` fn that want to log at a custom level and\n * return normally instead of throwing.\n */\ndeclare function resetActivation(key: string): void;\n/**\n * Run a service start exactly once per activation cycle.\n *\n * - If the flag is already set, logs at debug and returns `false` (skipped).\n * - Otherwise sets the flag and runs `fn`.\n * - If `fn` throws synchronously OR returns a promise that rejects, the\n * flag is RESET (so a later activate can retry) and the error is logged.\n * Errors are not rethrown — matching fleet behavior where a failed start\n * must never crash the host's plugin loader.\n *\n * Returns `true` when the start was initiated (even if an async portion\n * later fails), `false` when skipped or when `fn` threw synchronously.\n *\n * Note: cleaning up partial side effects on failure is `fn`'s job (throw\n * only after tearing down what was started); the kit only guarantees the\n * flag reset happens after `fn` has failed — i.e. after `fn`'s own cleanup.\n */\ndeclare function guardedStart(key: string, log: KitLogger, fn: () => void | Promise<void>): boolean;\n//# sourceMappingURL=activation.d.ts.map\n\n//#endregion\nexport { type ConnectToDaemonDependencies, type ConnectToDaemonOptions, type IpcClient, type IpcResponse, type KitLogger, PublicToolError, type ResolveOpenClawSdkDependencies, type ResolveOpenClawSdkOptions, type ToolDef, type ToolResult, connectToDaemon, defineTool, errResult, getActivationKey, guardedStart, isActivated, ok, publicToolError, resetActivation, resolveOpenClawSdk };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;ACyCC;;;;UDtBSC,UAAAA,CC4Ba;EAGvB,OAAiB,EAAA;IAAS,IAAA,EAAA,MAAA;QAChB,EAAA,MAAA;;SAQW,EAAA,OAAA;SAGA,CAAA,EAAA,OAAA;;UDnCXC,OCoCW,CAAA,cAAA,OAAA,CAAA,CAAA;QAAgC,MAAA;EAAO,WAAA,EAAA,MAAA;EAuC5D,KAAiB,EAAA,MAAA;EAAY,UAAA,EDvEfC,WCuEe;SAKb,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,MAAA,ED3EwBC,MC2ExB,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,GD3EoDC,OC2EpD,CD3E4DJ,UC2E5D,CAAA;;;;;AD3EwBG,UCIvB,YAAA,CDJuBA;MAAoCH,CAAAA,OAAAA,EAAAA,MAAAA,EAAAA,GAAAA,IAAAA,EAAAA,OAAAA,EAAAA,CAAAA,EAAAA,IAAAA;MAARI,CAAAA,OAAAA,EAAAA,MAAAA,EAAAA,GAAAA,IAAAA,EAAAA,OAAAA,EAAAA,CAAAA,EAAAA,IAAAA;EAAO,KAAA,CAAA,OAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;;UCWjE,oBAAA;EAPO,MAAA,CAAA,EAQN,MARkB,CAAA,MAAA,EAAA,OAAA,CAAA;EAOnB,YAAA,CAAA,EAAA,MAAA;EAAoB,QAAA,CAAA,EAAA,MAAA;QACnB,CAAA,EAGA,YAHA;;AAGY,UAGN,SAAA,CAHM;EAGN,MAAA,EACP,YADgB;EAAA,gBAAA,CAAA,EAAA,MAAA,GAAA,WAAA,GAAA,gBAAA,GAAA,YAAA,GAAA,eAAA,GAAA,cAAA;cAChB,CAAA,IAAA,EAQW,OARX,CAQmB,OARnB,CAAA,CAAA,EAAA,IAAA;iBAQmB,EAAA,OAAA,EAAA;IAAR,EAAA,EAAA,MAAA;IAGA,KAAA,EAAA,CAAA,OAAA,EAAA,oBAAA,EAAA,GAAA,IAAA,GAAgC,OAAhC,CAAA,IAAA,CAAA;IAAgC,IAAA,CAAA,EAAA,CAAA,OAAA,EAChC,oBADgC,EAAA,GAAA,IAAA,GACA,OADA,CAAA,IAAA,CAAA;MAChC,IAAA;;UAuCJ,YAAA;;;;;gBAKD;kBACE;;;;cCxGZ,QAAQ"}