@opentabs-dev/plugin-sdk 0.0.1

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.
@@ -0,0 +1,70 @@
1
+ import type { z } from 'zod';
2
+ export { NAME_REGEX, RESERVED_NAMES, validatePluginName, validateUrlPattern } from '@opentabs-dev/shared';
3
+ export type { ManifestTool, PluginManifest as Manifest } from '@opentabs-dev/shared';
4
+ export interface ToolDefinition<TInput extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>, TOutput extends z.ZodType = z.ZodType> {
5
+ /** Tool name — auto-prefixed with plugin name (e.g., 'send_message' → 'slack_send_message') */
6
+ name: string;
7
+ /** Human-readable description shown to MCP clients / AI agents */
8
+ description: string;
9
+ /** Zod schema — used for MCP registration + server-side input validation */
10
+ input: TInput;
11
+ /** Zod schema describing the tool output shape. Used for manifest generation and MCP tool registration. */
12
+ output: TOutput;
13
+ /** Execute the tool. Runs in the browser page context. Input is pre-validated. */
14
+ handle(params: z.infer<TInput>): Promise<z.infer<TOutput>>;
15
+ }
16
+ /** Type-safe factory — identity function that provides generic inference */
17
+ export declare const defineTool: <TInput extends z.ZodObject<z.ZodRawShape>, TOutput extends z.ZodType>(config: ToolDefinition<TInput, TOutput>) => ToolDefinition<TInput, TOutput>;
18
+ /**
19
+ * Abstract base class for all OpenTabs plugins.
20
+ * Plugin authors extend this and export an instance.
21
+ */
22
+ export declare abstract class OpenTabsPlugin {
23
+ /** Unique identifier (lowercase alphanumeric + hyphens) */
24
+ abstract readonly name: string;
25
+ /** Semver version string */
26
+ abstract readonly version: string;
27
+ /** Brief description of the plugin's purpose */
28
+ abstract readonly description: string;
29
+ /**
30
+ * Chrome match patterns — determines which tabs get the adapter injected.
31
+ * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
32
+ */
33
+ abstract readonly urlPatterns: string[];
34
+ /** All tool definitions for this plugin */
35
+ abstract readonly tools: ToolDefinition[];
36
+ /**
37
+ * Readiness probe (Kubernetes convention).
38
+ * Called by the extension to determine if the service in the current
39
+ * tab is ready to accept tool requests. Runs in the page context.
40
+ *
41
+ * Tab state mapping:
42
+ * - No matching tab exists → 'closed'
43
+ * - Tab exists, isReady=false → 'unavailable'
44
+ * - Tab exists, isReady=true → 'ready'
45
+ *
46
+ * @returns true if the user is authenticated and the service is operational
47
+ */
48
+ abstract isReady(): Promise<boolean>;
49
+ /** Human-readable display name. Defaults to `name` if not set. */
50
+ displayName?: string;
51
+ /**
52
+ * Called by the platform before re-injection (plugin.update) to allow
53
+ * cleanup of event listeners, timers, or global state set up by the
54
+ * previous adapter version. Optional — plugins that do not set up
55
+ * persistent side effects can omit this.
56
+ */
57
+ teardown?(): void;
58
+ }
59
+ /**
60
+ * Typed error for tool handlers — the platform catches these
61
+ * and returns structured MCP error responses.
62
+ */
63
+ export declare class ToolError extends Error {
64
+ /** Machine-readable error code (e.g., 'CHANNEL_NOT_FOUND') */
65
+ readonly code: string;
66
+ constructor(message: string,
67
+ /** Machine-readable error code (e.g., 'CHANNEL_NOT_FOUND') */
68
+ code: string);
69
+ }
70
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1G,YAAY,EAAE,YAAY,EAAE,cAAc,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMrF,MAAM,WAAW,cAAc,CAC7B,MAAM,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EACtE,OAAO,SAAS,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO;IAErC,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E,MAAM;gBAF5B,OAAO,EAAE,MAAM;IACf,8DAA8D;IAC9C,IAAI,EAAE,MAAM;CAK/B"}
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Re-exports from @opentabs-dev/shared (single source of truth)
3
+ // ---------------------------------------------------------------------------
4
+ export { NAME_REGEX, RESERVED_NAMES, validatePluginName, validateUrlPattern } from '@opentabs-dev/shared';
5
+ /** Type-safe factory — identity function that provides generic inference */
6
+ export const defineTool = (config) => config;
7
+ /**
8
+ * Abstract base class for all OpenTabs plugins.
9
+ * Plugin authors extend this and export an instance.
10
+ */
11
+ export class OpenTabsPlugin {
12
+ /** Human-readable display name. Defaults to `name` if not set. */
13
+ displayName;
14
+ }
15
+ /**
16
+ * Typed error for tool handlers — the platform catches these
17
+ * and returns structured MCP error responses.
18
+ */
19
+ export class ToolError extends Error {
20
+ code;
21
+ constructor(message,
22
+ /** Machine-readable error code (e.g., 'CHANNEL_NOT_FOUND') */
23
+ code) {
24
+ super(message);
25
+ this.code = code;
26
+ this.name = 'ToolError';
27
+ }
28
+ }
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,gEAAgE;AAChE,8EAA8E;AAE9E,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAuB1G,4EAA4E;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAuC,EACN,EAAE,CAAC,MAAM,CAAC;AAE7C;;;GAGG;AACH,MAAM,OAAgB,cAAc;IA2BlC,kEAAkE;IAClE,WAAW,CAAU;CAQtB;AAED;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAIhB;IAHlB,YACE,OAAe;IACf,8DAA8D;IAC9C,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@opentabs-dev/plugin-sdk",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ }
10
+ },
11
+ "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "publishConfig": {
16
+ "access": "restricted"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc --build"
20
+ },
21
+ "dependencies": {
22
+ "@opentabs-dev/shared": "^0.0.1"
23
+ },
24
+ "peerDependencies": {
25
+ "zod": "^3.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "bun-types": "^1.3.9"
29
+ }
30
+ }