@ama-work/plugin-contract 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ask-Me-Anything-dot-work
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # @ama-work/plugin-contract
2
+
3
+ Neutral TypeScript contract package shared between the Orchestrator core (`ama-agent-orchestrator`) and all mesh plugins.
4
+
5
+ ## Purpose
6
+
7
+ This package defines the interface boundary between the Orchestrator and plugins. Neither side depends on the other — both depend only on this package. This property must be preserved; do not import from `ama-agent-orchestrator` or any specific plugin repo.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ bun add @ama-work/plugin-contract
13
+ # or
14
+ npm install @ama-work/plugin-contract
15
+ ```
16
+
17
+ ## Exported Types
18
+
19
+ ```typescript
20
+ import {
21
+ PluginBridge,
22
+ IncomingEvent,
23
+ PluginManifest,
24
+ ConsolePanel,
25
+ OrchestratorPlugin,
26
+ Logger,
27
+ } from "@ama-work/plugin-contract";
28
+ ```
29
+
30
+ ### PluginBridge
31
+
32
+ The interface plugins use to interact with the orchestrator. Implement `PluginBridge` to receive events, mount routes, and manage config.
33
+
34
+ ### PluginManifest
35
+
36
+ Plugin metadata. The `provides` field is `string[]` (open type) — any plugin can declare arbitrary capability strings without requiring changes to this contract.
37
+
38
+ ```typescript
39
+ const manifest: PluginManifest = {
40
+ id: "my-plugin",
41
+ name: "My Plugin",
42
+ version: "1.0.0",
43
+ provides: ["connector", "custom-thing"],
44
+ };
45
+ ```
46
+
47
+ ### ConsolePanel
48
+
49
+ Console panel descriptor for UI integration:
50
+
51
+ ```typescript
52
+ interface ConsolePanel {
53
+ id: string;
54
+ navLabel: string;
55
+ icon: string;
56
+ mixinUrl: string;
57
+ templateUrl: string;
58
+ }
59
+ ```
60
+
61
+ ### OrchestratorPlugin
62
+
63
+ Plugin lifecycle hooks:
64
+
65
+ ```typescript
66
+ interface OrchestratorPlugin {
67
+ id: string;
68
+ onInstall?(bridge: PluginBridge): Promise<void>;
69
+ onStart(bridge: PluginBridge): Promise<void>;
70
+ onStop(): Promise<void>;
71
+ }
72
+ ```
73
+
74
+ ## Testing with MockBridge
75
+
76
+ ```typescript
77
+ import { MockBridge } from "@ama-work/plugin-contract/testing";
78
+ ```
79
+
80
+ `MockBridge` is a full in-memory `PluginBridge` implementation for unit tests:
81
+
82
+ - `submittedEvents` — array of events submitted via `submitEvent()`
83
+ - `mountedPanels` — array of panels mounted via `mountConsolePanel()`
84
+ - `mountRoutes(router)` — starts a local Hono server on configurable port
85
+ - `getConfig()` / `saveConfig()` — round-trips in memory
86
+ - All other methods are no-op stubs
87
+
88
+ ## Versioning Policy
89
+
90
+ Any change to the exported interfaces is a **semver major** bump. This package is the stable dependency point for all downstream plugins — treat instability as a cost imposed on every plugin author.
91
+
92
+ ## License
93
+
94
+ MIT
@@ -0,0 +1,2 @@
1
+ export type { PluginBridge, IncomingEvent, OrchestratorPlugin, PluginManifest, ConsolePanel, Logger, } from "./plugin/types.js";
2
+ export { MockBridge } from "./plugin/testing/mock-bridge.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { MockBridge } from "./plugin/testing/mock-bridge.js";
@@ -0,0 +1,19 @@
1
+ import { Hono } from "hono";
2
+ import type { PluginBridge, IncomingEvent, ConsolePanel, Logger } from "../types.js";
3
+ export declare class MockBridge implements PluginBridge {
4
+ readonly submittedEvents: IncomingEvent[];
5
+ readonly mountedPanels: ConsolePanel[];
6
+ private config;
7
+ private server;
8
+ private port;
9
+ readonly logger: Logger;
10
+ constructor(port?: number);
11
+ submitEvent(event: IncomingEvent): Promise<void>;
12
+ mountRoutes(router: Hono): void;
13
+ mountConsolePanel(panel: ConsolePanel): void;
14
+ runMigrations(_migrationsDir: string): Promise<void>;
15
+ getConfig<T>(): Promise<T>;
16
+ saveConfig<T>(config: T): Promise<void>;
17
+ getPort(): number;
18
+ stop(): void;
19
+ }
@@ -0,0 +1,42 @@
1
+ import { serve } from "@hono/node-server";
2
+ export class MockBridge {
3
+ submittedEvents = [];
4
+ mountedPanels = [];
5
+ config = {};
6
+ server = null;
7
+ port;
8
+ logger = {
9
+ info: () => { },
10
+ warn: () => { },
11
+ error: () => { },
12
+ debug: () => { },
13
+ };
14
+ constructor(port = 0) {
15
+ this.port = port;
16
+ }
17
+ async submitEvent(event) {
18
+ this.submittedEvents.push(event);
19
+ }
20
+ mountRoutes(router) {
21
+ this.server = serve({ fetch: router.fetch, port: this.port });
22
+ }
23
+ mountConsolePanel(panel) {
24
+ this.mountedPanels.push(panel);
25
+ }
26
+ async runMigrations(_migrationsDir) { }
27
+ async getConfig() {
28
+ return this.config;
29
+ }
30
+ async saveConfig(config) {
31
+ this.config = config;
32
+ }
33
+ getPort() {
34
+ return this.port;
35
+ }
36
+ stop() {
37
+ if (this.server) {
38
+ this.server.close();
39
+ this.server = null;
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,45 @@
1
+ import type { Hono } from "hono";
2
+ export interface PluginBridge {
3
+ submitEvent(event: IncomingEvent): Promise<void>;
4
+ mountRoutes(router: Hono): void;
5
+ mountConsolePanel(panel: ConsolePanel): void;
6
+ runMigrations(migrationsDir: string): Promise<void>;
7
+ getConfig<T>(): Promise<T>;
8
+ saveConfig<T>(config: T): Promise<void>;
9
+ logger: Logger;
10
+ }
11
+ export interface IncomingEvent {
12
+ source: string;
13
+ type: "issue_mention" | "project_status_change" | "push_to_main";
14
+ repo: string;
15
+ actor?: string;
16
+ payload: unknown;
17
+ receivedAt: Date;
18
+ deliveryId: string;
19
+ }
20
+ export interface OrchestratorPlugin {
21
+ id: string;
22
+ onInstall?(bridge: PluginBridge): Promise<void>;
23
+ onStart(bridge: PluginBridge): Promise<void>;
24
+ onStop(): Promise<void>;
25
+ }
26
+ export interface PluginManifest {
27
+ id: string;
28
+ name: string;
29
+ version: string;
30
+ description?: string;
31
+ provides: string[];
32
+ }
33
+ export interface ConsolePanel {
34
+ id: string;
35
+ navLabel: string;
36
+ icon: string;
37
+ mixinUrl: string;
38
+ templateUrl: string;
39
+ }
40
+ export interface Logger {
41
+ info(message: string): void;
42
+ warn(message: string): void;
43
+ error(message: string): void;
44
+ debug(message: string): void;
45
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@ama-work/plugin-contract",
3
+ "version": "1.0.0",
4
+ "description": "Neutral TypeScript contract package (PluginBridge, ConsolePanel, PluginManifest) shared between the orchestrator core and all mesh plugins",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "bun src/index.ts",
9
+ "build": "tsc --project tsconfig.build.json",
10
+ "lint": "tsc --noEmit && knip && eslint .",
11
+ "test": "vitest run",
12
+ "release": "semantic-release",
13
+ "prepublishOnly": "bun run build",
14
+ "prepare": "husky"
15
+ },
16
+ "dependencies": {
17
+ "hono": "^4.8.0"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "devDependencies": {
28
+ "@hono/node-server": "^1.14.0",
29
+ "@commitlint/cli": "^21.2.0",
30
+ "@commitlint/config-conventional": "^21.2.0",
31
+ "@commitlint/types": "^21.2.0",
32
+ "@semantic-release/commit-analyzer": "12",
33
+ "conventional-changelog-conventionalcommits": "^9.0.0",
34
+ "@semantic-release/git": "10",
35
+ "@semantic-release/github": "^12.0.9",
36
+ "@semantic-release/npm": "12",
37
+ "@semantic-release/release-notes-generator": "12",
38
+ "@types/bun": "^1.3.13",
39
+ "eslint": "^9.0.0",
40
+ "eslint-import-resolver-typescript": "^4.4.4",
41
+ "eslint-plugin-import": "^2.32.0",
42
+ "husky": "^9.1.7",
43
+ "knip": "^6.6.2",
44
+ "semantic-release": "24",
45
+ "tsx": "^4.19.1",
46
+ "typescript": "^5.5.4",
47
+ "typescript-eslint": "^8.59.3",
48
+ "vitest": "^2.0.5"
49
+ }
50
+ }