aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
90 lines • 3.84 kB
TypeScript
/**
* Fortemi Storage Adapter
*
* Routes storage operations through Fortemi's MCP tool surface. Fortemi
* is the first-party AIWG semantic-memory project — Rust + PostgreSQL +
* pgvector + SKOS + W3C PROV — referenced as "Forte" in #934 and
* confirmed as Fortemi in #961.
*
* Tool surface (per `.aiwg/planning/training-framework/phase-4-fortemi-review.md`):
* capture_knowledge - create note (we use this for first writes)
* update_note - revise existing note (we use this for re-writes)
* get_note - retrieve full note (read)
* list_notes - filter/paginate (list)
* search - text/semantic/spatial/temporal search (query)
* manage_collection - organize notes in folders (we use folder=subsystem
* scope to mirror the StorageAdapter contract)
*
* Path semantics:
* note_id = `${subsystem}:${path}` — the adapter passes the
* subsystem-relative path; the registry-supplied `subsystem` is
* prepended to keep different subsystems' notes from colliding.
*
* Caveats:
* - This adapter ships with the parameter shapes documented in the
* planning doc, but those shapes have NOT yet been validated against
* a live Fortemi instance. Treat this as alpha. The
* `McpClientLike.callTool(name, args)` injection point lets tests
* stub freely; real-world parameter mismatches surface as MCP
* errors that bubble up to the consumer.
* - Delete is implemented via `update_note` with `archived: true`
* because Fortemi's MCP surface does not document a direct delete
* tool (immutability + versioning is core to the design).
*
* @design @.aiwg/architecture/storage-design.md (§5.6)
* @issue #934
* @issue #961
* @issue #972
*/
import type { FortemiBackendConfig, StorageAdapter, StorageEntry, WriteMeta } from '../types.js';
/**
* Minimal MCP client surface this adapter consumes. Tests provide a
* stub; production wires this to `@modelcontextprotocol/sdk/client/*`
* via `createDefaultMcpClient(serverName)`.
*/
export interface McpClientLike {
callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
close?(): Promise<void>;
}
/**
* Factory that, given a server name, returns a connected MCP client.
* The default factory uses the SDK's stdio transport and AIWG's MCP
* registry; tests inject a stub so no subprocess is spawned.
*/
export type McpClientFactory = (serverName: string) => Promise<McpClientLike>;
export interface FortemiAdapterOptions {
/** Subsystem this adapter is bound to. Used to scope note IDs. */
subsystem: string;
/** Backend config from storage.config. */
config: FortemiBackendConfig;
/** Optional override for tests. Defaults to the SDK-backed factory. */
clientFactory?: McpClientFactory;
}
export declare class FortemiAdapter implements StorageAdapter {
private readonly subsystem;
private readonly mcpServer;
private readonly scheme;
private readonly clientFactory;
private client;
constructor(opts: FortemiAdapterOptions);
init(): Promise<void>;
close(): Promise<void>;
private getClient;
private noteId;
read(path: string): Promise<string | null>;
write(path: string, content: string, meta?: WriteMeta): Promise<void>;
list(prefix: string): Promise<StorageEntry[]>;
delete(path: string): Promise<void>;
query(q: string): Promise<StorageEntry[]>;
private buildMetadata;
}
/**
* Default MCP client factory. Resolves the server config from AIWG's
* McpServerRegistry, spawns the stdio transport, and returns a
* connected client.
*
* Implemented as a lazy import so tests that inject a stub never load
* the SDK or touch the registry.
*/
export declare const createDefaultMcpClient: McpClientFactory;
//# sourceMappingURL=fortemi.d.ts.map