@matatbread/matbot-plugin-api 0.2.7 → 0.2.9
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/package.json +1 -1
- package/src/plugin.ts +14 -3
- package/src/types.ts +21 -0
package/package.json
CHANGED
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
FileStore, Vault, Message, ModelParameters,
|
|
3
|
-
ProviderAdapter, ProviderConfig, Tool, ToolRegistry, FrontendInfo,
|
|
3
|
+
ProviderAdapter, ProviderConfig, ProviderRegistry, Tool, ToolRegistry, FrontendInfo,
|
|
4
4
|
Store, Session, SystemContextRegistry, KnowledgeIndex, PromptFn, SessionRunner, Usage,
|
|
5
5
|
} from './types.js';
|
|
6
6
|
import type { HookRegistry } from './hooks.js';
|
|
@@ -56,6 +56,13 @@ export type Runtime = 'node' | 'browser';
|
|
|
56
56
|
*/
|
|
57
57
|
export interface PluginResolver {
|
|
58
58
|
identify(specifier: string): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* The plugin's package.json `version`, or `undefined` when it can't be read (no package.json, or a
|
|
61
|
+
* remote specifier whose version isn't baked). Read from the same nearest-named-package.json boundary
|
|
62
|
+
* as {@link identify}, so it lives here (host-specific: fs walk on node, baked manifest in the browser)
|
|
63
|
+
* rather than in the platform-neutral loader. Stamped onto {@link MatbotPlugin.version} at load.
|
|
64
|
+
*/
|
|
65
|
+
version?(specifier: string): Promise<string | undefined>;
|
|
59
66
|
/**
|
|
60
67
|
* The runtimes a plugin declares support for via its package.json `matbotRuntime`
|
|
61
68
|
* (e.g. `["node"]`, `["browser"]`, `["node","browser"]`), or `undefined` when the field is
|
|
@@ -97,7 +104,7 @@ export type MatbotMachine = MatbotServices & MatbotRuntime;
|
|
|
97
104
|
/**
|
|
98
105
|
* The fixed runtime — microcode, not a service: the agentic loop's primitives (`complete`,
|
|
99
106
|
* `createStore`), the registries you mutate but never swap wholesale (`hooks`, `tools`,
|
|
100
|
-
* `systemContext`), plugin lifecycle, and the registry API itself. Not augmentable, not registerable.
|
|
107
|
+
* `systemContext`, `providers`), plugin lifecycle, and the registry API itself. Not augmentable, not registerable.
|
|
101
108
|
*/
|
|
102
109
|
export interface MatbotRuntime {
|
|
103
110
|
complete(req: CompletionRequest): Promise<CompletionResponse>;
|
|
@@ -198,7 +205,7 @@ export interface MatbotRuntime {
|
|
|
198
205
|
/** The calling plugin's own loader-established identity. Bound per-plugin inside setup(). */
|
|
199
206
|
readonly self?: PluginSelf;
|
|
200
207
|
|
|
201
|
-
readonly providers:
|
|
208
|
+
readonly providers: ProviderRegistry;
|
|
202
209
|
readonly sessions?: Store<Session>;
|
|
203
210
|
/** Per-session turn serialiser. Frontends submit and observe through this rather than calling
|
|
204
211
|
* runSession directly, so concurrent submits queue instead of clobbering the session. */
|
|
@@ -504,4 +511,8 @@ export interface MatbotPlugin extends MatbotPluginSpec {
|
|
|
504
511
|
// than re-derived so `list` can report it offline and for remote plugins, whose config-entry
|
|
505
512
|
// specifier (a github:/https URL) can't be resolved back to a package.json after the fact.
|
|
506
513
|
readonly matbotRuntime?: readonly Runtime[];
|
|
514
|
+
// The plugin's package.json `version`, read by the resolver at load (fs walk on node; baked manifest
|
|
515
|
+
// in the browser). Absent ⇒ couldn't be read (no package.json, or a remote whose version isn't baked).
|
|
516
|
+
// Loader-established provenance, like `name`/`matbotRuntime` — not the author's to declare.
|
|
517
|
+
readonly version?: string;
|
|
507
518
|
}
|
package/src/types.ts
CHANGED
|
@@ -718,6 +718,27 @@ export interface ToolRegistry {
|
|
|
718
718
|
watch(signal?: AbortSignal): AsyncIterable<ToolRegistryEvent>;
|
|
719
719
|
}
|
|
720
720
|
|
|
721
|
+
/**
|
|
722
|
+
* The named provider profiles the runtime resolves by name. A `ReadonlyMap` for the many read-only
|
|
723
|
+
* consumers (`services.providers.get`/`has`/`keys`/…), plus a sanctioned write path so a plugin can
|
|
724
|
+
* *contribute* profiles live — a storage backend replaying provider definitions it captured in its own
|
|
725
|
+
* medium, or the built-in `provider` tool — exactly as a plugin contributes tools via {@link ToolRegistry}.
|
|
726
|
+
* Keyed by `config.name`; `register` upserts.
|
|
727
|
+
*/
|
|
728
|
+
export interface ProviderRegistry extends ReadonlyMap<string, ProviderConfig> {
|
|
729
|
+
register(config: ProviderConfig): void;
|
|
730
|
+
/** Explicit delete (the `provider` tool's `remove`) — removes the profile outright. */
|
|
731
|
+
remove(name: string): boolean;
|
|
732
|
+
/**
|
|
733
|
+
* Undo a contribution: restore the boot-baseline profile for `name` if one existed (a plugin-supplied
|
|
734
|
+
* profile that shadowed a configured one), otherwise delete it. A plugin that registers providers
|
|
735
|
+
* (e.g. a storage backend replaying them from its medium) calls this for each in its `teardown()`, so
|
|
736
|
+
* unloading it reverts the provider set to the host's boot condition — the multi-valued analogue of a
|
|
737
|
+
* swap-member reverting to its captured boot default.
|
|
738
|
+
*/
|
|
739
|
+
revert(name: string): void;
|
|
740
|
+
}
|
|
741
|
+
|
|
721
742
|
export type PluginRegistryEvent =
|
|
722
743
|
| { type: 'loaded'; name: string }
|
|
723
744
|
| { type: 'unloaded'; name: string };
|