@alfe.ai/openclaw-google 0.0.40 → 0.0.42

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.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import plugin from "./plugin.cjs";
1
+ import { t as plugin } from "./plugin.cjs";
2
2
  export { plugin as default };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import plugin from "./plugin.js";
1
+ import { t as plugin } from "./plugin.js";
2
2
  export { plugin as default };
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,220 +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 node_child_process = require("node:child_process");
5
- let node_path = require("node:path");
6
- let node_os = require("node:os");
7
- //#region src/plugin.ts
8
- /**
9
- * @alfe/openclaw-google — OpenClaw native plugin
10
- *
11
- * Registers Google Workspace account management tools with OpenClaw.
12
- * Multi-account by design — every gws command requires an explicit
13
- * `email` (schema-enforced) so the LLM picks the target account per call.
14
- *
15
- * Tools:
16
- * - google_list_accounts — list connected Google accounts
17
- * - google_run_command — run a gws command (requires email)
18
- * - google_disconnect_account — disconnect an account
19
- *
20
- * 2026-05-14 (connections-redesign PR 1): the "default account" concept is
21
- * gone. Use `google_list_accounts` to discover available accounts, then
22
- * pass `email` to `google_run_command` to target one.
23
- */
24
- const pkg = (0, require("node:module").createRequire)(require("url").pathToFileURL(__filename).href)("../package.json");
25
- function ok(data) {
26
- return {
27
- content: [{
28
- type: "text",
29
- text: JSON.stringify(data)
30
- }],
31
- details: data
32
- };
33
- }
34
- function errResult(message) {
35
- return {
36
- content: [{
37
- type: "text",
38
- text: JSON.stringify({ error: message })
39
- }],
40
- details: { error: message }
41
- };
42
- }
43
- function defineTool(def) {
44
- return {
45
- name: def.name,
46
- description: def.description,
47
- label: def.name,
48
- parameters: def.parameters,
49
- execute: async (_toolCallId, params) => {
50
- try {
51
- return ok(await def.handler(params));
52
- } catch (e) {
53
- return errResult(e instanceof Error ? e.message : "Unknown error");
54
- }
55
- }
56
- };
57
- }
58
- function sanitizeEmail(email) {
59
- return email.replace(/@/g, "-").replace(/\./g, "-");
60
- }
61
- function resolveConfigDir(email) {
62
- return (0, node_path.join)((0, node_os.homedir)(), ".config", `gws-${sanitizeEmail(email)}`);
63
- }
64
- let client = null;
65
- let cachedAccounts = [];
66
- function getClient() {
67
- if (!client) {
68
- const config = (0, _alfe_ai_config.resolveConfig)();
69
- client = new _alfe_ai_agent_api_client.AgentApiClient({
70
- apiKey: config.apiKey,
71
- apiUrl: config.apiUrl
72
- });
73
- }
74
- return client;
75
- }
76
- async function refreshAccountCache() {
77
- cachedAccounts = (await getClient().getGoogleCredentials()).accounts.map((a) => ({
78
- email: a.email,
79
- displayName: a.displayName,
80
- connectedAt: a.connectedAt,
81
- configDir: resolveConfigDir(a.email)
82
- }));
83
- return cachedAccounts;
84
- }
85
- function findAccount(email) {
86
- const account = cachedAccounts.find((a) => a.email === email);
87
- if (!account) throw new Error(`Google account "${email}" not found. Available: ${cachedAccounts.map((a) => a.email).join(", ")}`);
88
- return account;
89
- }
90
- function runGwsCommand(args, configDir) {
91
- return new Promise((resolve) => {
92
- (0, node_child_process.execFile)("gws", args, {
93
- env: {
94
- ...process.env,
95
- GOOGLE_WORKSPACE_CLI_CONFIG_DIR: configDir
96
- },
97
- timeout: 6e4,
98
- maxBuffer: 10 * 1024 * 1024
99
- }, (error, stdout, stderr) => {
100
- resolve({
101
- stdout,
102
- stderr,
103
- exitCode: typeof error?.code === "number" ? error.code : error ? 1 : 0
104
- });
105
- });
106
- });
107
- }
108
- const googleTools = [
109
- defineTool({
110
- name: "google_list_accounts",
111
- 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).",
112
- parameters: _sinclair_typebox.Type.Object({}),
113
- handler: async () => {
114
- const accounts = await refreshAccountCache();
115
- return {
116
- accounts: accounts.map((a) => ({
117
- email: a.email,
118
- displayName: a.displayName,
119
- connectedAt: a.connectedAt,
120
- configDir: a.configDir
121
- })),
122
- count: accounts.length
123
- };
124
- }
125
- }),
126
- defineTool({
127
- name: "google_run_command",
128
- 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' })",
129
- parameters: _sinclair_typebox.Type.Object({
130
- command: _sinclair_typebox.Type.String({ description: "The gws CLI command and arguments (e.g., 'gmail list', 'calendar agenda', 'drive list')" }),
131
- email: _sinclair_typebox.Type.String({ description: "Email of the Google account to use. Required — there is no implicit default." })
132
- }),
133
- handler: async (params) => {
134
- const { command, email } = params;
135
- if (cachedAccounts.length === 0) await refreshAccountCache();
136
- const account = findAccount(email);
137
- const args = command.split(/\s+/).filter(Boolean);
138
- if (args.length === 0) throw new Error("Command cannot be empty");
139
- const result = await runGwsCommand(args, account.configDir);
140
- return {
141
- account: account.email,
142
- command: `gws ${command}`,
143
- ...result
144
- };
145
- }
146
- }),
147
- defineTool({
148
- name: "google_disconnect_account",
149
- description: "Disconnect a specific Google account from this agent. Revokes the OAuth token and removes the account.",
150
- parameters: _sinclair_typebox.Type.Object({ email: _sinclair_typebox.Type.String({ description: "Email of the Google account to disconnect" }) }),
151
- handler: async (params) => {
152
- const { email } = params;
153
- const result = await getClient().disconnectGoogleAccount(email);
154
- await refreshAccountCache();
155
- return {
156
- message: `${email} has been disconnected`,
157
- remainingAccounts: result.accounts
158
- };
159
- }
160
- })
161
- ];
162
- const plugin = {
163
- id: "@alfe.ai/openclaw-google",
164
- name: "Alfe Google Workspace Plugin",
165
- description: "Multi-account Google Workspace management — list accounts and run gws commands with an explicit account selector",
166
- version: pkg.version,
167
- activate(api) {
168
- (0, _alfe_ai_agent_api_client.installToolErrorCapture)(api, { plugin: "openclaw-google" });
169
- const log = api.logger;
170
- for (const tool of googleTools) api.registerTool(tool);
171
- log.info(`Registered ${googleTools.length.toString()} Google tools: ${googleTools.map((t) => t.name).join(", ")}`);
172
- const startGoogleService = () => {
173
- if (globalThis.__googlePluginActivated === true) {
174
- log.debug("Google plugin already activated — skipping duplicate");
175
- return;
176
- }
177
- globalThis.__googlePluginActivated = true;
178
- log.info("Alfe Google Workspace plugin activating...");
179
- try {
180
- const config = (0, _alfe_ai_config.resolveConfig)();
181
- client = new _alfe_ai_agent_api_client.AgentApiClient({
182
- apiKey: config.apiKey,
183
- apiUrl: config.apiUrl
184
- });
185
- refreshAccountCache().then((accounts) => {
186
- log.info(`Cached ${accounts.length.toString()} Google account(s): ${accounts.map((a) => a.email).join(", ")}`);
187
- }).catch((err) => {
188
- log.warn(`Failed to pre-cache Google accounts: ${err instanceof Error ? err.message : "unknown"}`);
189
- });
190
- } catch (err) {
191
- log.error(`Failed to resolve config: ${err instanceof Error ? err.message : "unknown"}`);
192
- log.warn("Google tools will fail — no API config available");
193
- }
194
- log.info("Alfe Google Workspace plugin activated");
195
- };
196
- const stopGoogleService = () => {
197
- globalThis.__googlePluginActivated = false;
198
- client = null;
199
- cachedAccounts = [];
200
- log.info("Alfe Google Workspace plugin stopped");
201
- };
202
- if (api.registerService) api.registerService({
203
- id: "alfe-google-workspace",
204
- start: () => {
205
- startGoogleService();
206
- },
207
- stop: () => {
208
- stopGoogleService();
209
- }
210
- });
211
- },
212
- deactivate(api) {
213
- globalThis.__googlePluginActivated = false;
214
- client = null;
215
- cachedAccounts = [];
216
- api.logger.info("Alfe Google Workspace plugin deactivated");
217
- }
218
- };
219
- //#endregion
220
- module.exports = plugin;
1
+ const require_plugin = require("./plugin2.cjs");
2
+ module.exports = require_plugin.plugin;
package/dist/plugin.d.cts CHANGED
@@ -1,54 +1,62 @@
1
1
  import { TSchema } from "@sinclair/typebox";
2
2
 
3
- //#region src/plugin.d.ts
3
+ //#region ../openclaw-plugin-kit/dist/index.d.ts
4
4
 
5
- interface Logger {
6
- info(msg: string, ...args: unknown[]): void;
7
- warn(msg: string, ...args: unknown[]): void;
8
- error(msg: string, ...args: unknown[]): void;
9
- debug(msg: string, ...args: unknown[]): void;
5
+ //# sourceMappingURL=types.d.ts.map
6
+ //#endregion
7
+ //#region src/tools.d.ts
8
+ /** Shape returned to OpenClaw from a tool `execute`. */
9
+ interface ToolResult {
10
+ content: {
11
+ type: "text";
12
+ text: string;
13
+ }[];
14
+ details: unknown;
15
+ isError?: boolean;
16
+ }
17
+ interface ToolDef<TParameters = unknown> {
18
+ name: string;
19
+ description: string;
20
+ label: string;
21
+ parameters: TParameters;
22
+ execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;
23
+ }
24
+ /** Deliberately model-safe validation/usage failure. Other exceptions stay private. */
25
+ //#endregion
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;
10
32
  }
11
33
  interface PluginServiceContext {
12
34
  config?: Record<string, unknown>;
13
35
  workspaceDir?: string;
14
36
  stateDir?: string;
15
- logger?: Logger;
37
+ logger?: PluginLogger;
16
38
  }
17
- interface OpenClawPluginApi {
18
- logger: Logger;
19
- registrationMode?: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
20
- registerTool(tool: ToolDef): void;
21
- registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
39
+ interface PluginApi {
40
+ logger: PluginLogger;
41
+ registrationMode?: "full" | "discovery" | "tool-discovery" | "setup-only" | "setup-runtime" | "cli-metadata";
42
+ registerTool(tool: ToolDef<TSchema>): void;
22
43
  registerService?(service: {
23
44
  id: string;
24
- start: (ctx: PluginServiceContext) => void | Promise<void>;
25
- stop?: (ctx: PluginServiceContext) => void | Promise<void>;
45
+ start: (context: PluginServiceContext) => void | Promise<void>;
46
+ stop?: (context: PluginServiceContext) => void | Promise<void>;
26
47
  }): void;
27
- on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
28
- priority?: number;
29
- }): void;
30
- }
31
- interface ToolDef {
32
- name: string;
33
- description: string;
34
- label: string;
35
- parameters: TSchema;
36
- execute: (toolCallId: string, params: Record<string, unknown>) => Promise<{
37
- content: {
38
- type: "text";
39
- text: string;
40
- }[];
41
- details: unknown;
42
- }>;
43
48
  }
44
- declare const plugin: {
49
+ interface GooglePlugin {
45
50
  id: string;
46
51
  name: string;
47
52
  description: string;
48
53
  version: string;
49
- activate(api: OpenClawPluginApi): void;
50
- deactivate(api: OpenClawPluginApi): void;
51
- };
54
+ activate(api: PluginApi): void;
55
+ deactivate(api: PluginApi): void;
56
+ }
57
+ //#endregion
58
+ //#region src/plugin.d.ts
59
+ declare const plugin: GooglePlugin;
52
60
  //#endregion
53
- export { plugin as default };
61
+ export { plugin as t };
54
62
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;UA2BU,MAAA,CAsBuC;MAEW,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAO,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAKzD,KAAA,CAAA,GAAA,EAAO,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAA,KAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;UAtBP,oBAAA,CA2B8B;QAA4B,CAAA,EA1BzD,MA0ByD,CAAA,MAAA,EAAA,OAAA,CAAA;EAAO,YAAA,CAAA,EAAA,MAAA;EAiMrE,QAAA,CAmEL,EAAA,MAAA;EAAA,MAAA,CAAA,EA3RU,MA2RV;;UAxRS,iBAAA,CAkRQ;EAAiB,MAAA,EAjRzB,MAiRyB;;qBA/Qd;uEACkD;;;iBAGtD,gCAAgC;iBAChC,gCAAgC;;4DAEW;;;;UAKlD,OAAA;;;;cAII;wCAC0B,4BAA4B;;;;;;;;cAiM9D;;;;;gBAMU;kBAuDE"}
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
@@ -1,54 +1,62 @@
1
1
  import { TSchema } from "@sinclair/typebox";
2
2
 
3
- //#region src/plugin.d.ts
3
+ //#region ../openclaw-plugin-kit/dist/index.d.ts
4
4
 
5
- interface Logger {
6
- info(msg: string, ...args: unknown[]): void;
7
- warn(msg: string, ...args: unknown[]): void;
8
- error(msg: string, ...args: unknown[]): void;
9
- debug(msg: string, ...args: unknown[]): void;
5
+ //# sourceMappingURL=types.d.ts.map
6
+ //#endregion
7
+ //#region src/tools.d.ts
8
+ /** Shape returned to OpenClaw from a tool `execute`. */
9
+ interface ToolResult {
10
+ content: {
11
+ type: "text";
12
+ text: string;
13
+ }[];
14
+ details: unknown;
15
+ isError?: boolean;
16
+ }
17
+ interface ToolDef<TParameters = unknown> {
18
+ name: string;
19
+ description: string;
20
+ label: string;
21
+ parameters: TParameters;
22
+ execute: (toolCallId: string, params: Record<string, unknown>) => Promise<ToolResult>;
23
+ }
24
+ /** Deliberately model-safe validation/usage failure. Other exceptions stay private. */
25
+ //#endregion
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;
10
32
  }
11
33
  interface PluginServiceContext {
12
34
  config?: Record<string, unknown>;
13
35
  workspaceDir?: string;
14
36
  stateDir?: string;
15
- logger?: Logger;
37
+ logger?: PluginLogger;
16
38
  }
17
- interface OpenClawPluginApi {
18
- logger: Logger;
19
- registrationMode?: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
20
- registerTool(tool: ToolDef): void;
21
- registerGatewayMethod(name: string, handler: (...args: unknown[]) => Promise<unknown>): void;
39
+ interface PluginApi {
40
+ logger: PluginLogger;
41
+ registrationMode?: "full" | "discovery" | "tool-discovery" | "setup-only" | "setup-runtime" | "cli-metadata";
42
+ registerTool(tool: ToolDef<TSchema>): void;
22
43
  registerService?(service: {
23
44
  id: string;
24
- start: (ctx: PluginServiceContext) => void | Promise<void>;
25
- stop?: (ctx: PluginServiceContext) => void | Promise<void>;
45
+ start: (context: PluginServiceContext) => void | Promise<void>;
46
+ stop?: (context: PluginServiceContext) => void | Promise<void>;
26
47
  }): void;
27
- on(event: string, handler: (...args: unknown[]) => void | Promise<void>, options?: {
28
- priority?: number;
29
- }): void;
30
- }
31
- interface ToolDef {
32
- name: string;
33
- description: string;
34
- label: string;
35
- parameters: TSchema;
36
- execute: (toolCallId: string, params: Record<string, unknown>) => Promise<{
37
- content: {
38
- type: "text";
39
- text: string;
40
- }[];
41
- details: unknown;
42
- }>;
43
48
  }
44
- declare const plugin: {
49
+ interface GooglePlugin {
45
50
  id: string;
46
51
  name: string;
47
52
  description: string;
48
53
  version: string;
49
- activate(api: OpenClawPluginApi): void;
50
- deactivate(api: OpenClawPluginApi): void;
51
- };
54
+ activate(api: PluginApi): void;
55
+ deactivate(api: PluginApi): void;
56
+ }
57
+ //#endregion
58
+ //#region src/plugin.d.ts
59
+ declare const plugin: GooglePlugin;
52
60
  //#endregion
53
- export { plugin as default };
61
+ export { plugin as t };
54
62
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;;UA2BU,MAAA,CAsBuC;MAEW,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAO,IAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAKzD,KAAA,CAAA,GAAA,EAAO,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;EAAA,KAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,OAAA,EAAA,CAAA,EAAA,IAAA;;UAtBP,oBAAA,CA2B8B;QAA4B,CAAA,EA1BzD,MA0ByD,CAAA,MAAA,EAAA,OAAA,CAAA;EAAO,YAAA,CAAA,EAAA,MAAA;EAiMrE,QAAA,CAmEL,EAAA,MAAA;EAAA,MAAA,CAAA,EA3RU,MA2RV;;UAxRS,iBAAA,CAkRQ;EAAiB,MAAA,EAjRzB,MAiRyB;;qBA/Qd;uEACkD;;;iBAGtD,gCAAgC;iBAChC,gCAAgC;;4DAEW;;;;UAKlD,OAAA;;;;cAII;wCAC0B,4BAA4B;;;;;;;;cAiM9D;;;;;gBAMU;kBAuDE"}
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"}