@matatbread/matbot-plugin-api 0.3.0 → 0.3.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.
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "node",
5
5
  "browser"
6
6
  ],
7
- "version": "0.3.0",
7
+ "version": "0.3.1",
8
8
  "engines": {
9
9
  "node": ">=24.0.0"
10
10
  },
package/src/plugin.ts CHANGED
@@ -2,7 +2,7 @@ import type {
2
2
  FileStore, Vault, Message, ModelParameters,
3
3
  ProviderAdapter, ProviderConfig, ProviderRegistry, Tool, ToolRegistry, FrontendInfo,
4
4
  Store, Session, SystemContextRegistry, KnowledgeIndex, PromptFn, SessionRunner, Usage,
5
- TypeScriptStripper, ToolTypeIndex,
5
+ TypeScriptStripper, ToolTypeIndex, ToolPresenter,
6
6
  } from './types.js';
7
7
  import type { HookRegistry } from './hooks.js';
8
8
 
@@ -101,6 +101,11 @@ export interface MatbotServices {
101
101
  * reference held across a swap keeps resolving to the live backend. Always present (boot default). */
102
102
  readonly Vault: Vault;
103
103
  readonly KnowledgeIndex: KnowledgeIndex;
104
+ /** Optional tool-presentation policy: chooses which tools are advertised to the model per provider
105
+ * call (a large-library search/deferral plugin registers one). Absent ⇒ the runner advertises the
106
+ * whole turn snapshot. A plain registered service (not a swap-member); consumed as a member. See
107
+ * {@link ToolPresenter}. */
108
+ readonly ToolPresenter?: ToolPresenter | undefined;
104
109
  }
105
110
 
106
111
  /** The assembled machine: registry services wired to the fixed runtime — what `setup()` receives. */
package/src/types.ts CHANGED
@@ -802,6 +802,32 @@ export interface ToolRegistry {
802
802
  watch(signal?: AbortSignal): AsyncIterable<ToolRegistryEvent>;
803
803
  }
804
804
 
805
+ /** What the runner tells a {@link ToolPresenter} about the call it's about to make. */
806
+ export interface PresentContext {
807
+ /** The session as of this provider call — the persisted user turn plus any assistant/tool turns
808
+ * taken so far this turn. A presenter ranks the tool set against this. */
809
+ session: Session;
810
+ /** The provider profile name this turn runs under, so a presenter can tailor to provider
811
+ * capabilities (e.g. Anthropic's in-context tool_reference expansion). */
812
+ provider: string;
813
+ }
814
+
815
+ /**
816
+ * Chooses which tools are advertised to the model for a single provider call — a read-only *view* over
817
+ * the turn's tool snapshot, NOT tool management. Presentation is orthogonal to the {@link ToolRegistry},
818
+ * which stays the single source of registration, resolution, and type-contracts (its fragile, load-bearing
819
+ * machinery is never a swap surface). The runner consults the presenter before *every* provider call, so
820
+ * an impl may present a subset (deferring a large library behind a search tool) and grow it mid-turn as the
821
+ * model discovers tools. Executor resolution is unaffected — a tool withheld here stays callable by name
822
+ * through the live registry — so presentation only ever changes what the model is *told about*.
823
+ *
824
+ * Optional {@link MatbotServices} member (offer-loosely): absent ⇒ the runner advertises the whole
825
+ * snapshot, byte-identical to today. `present` may return synchronously or async (a reranker).
826
+ */
827
+ export interface ToolPresenter {
828
+ present(tools: readonly Tool[], ctx: PresentContext): readonly Tool[] | Promise<readonly Tool[]>;
829
+ }
830
+
805
831
  /**
806
832
  * The named provider profiles the runtime resolves by name. A `ReadonlyMap` for the many read-only
807
833
  * consumers (`services.providers.get`/`has`/`keys`/…), plus a sanctioned write path so a plugin can