/** * SdkStorage — the SDK's `AithosStorage` adapter (P1.1 of the MCP unification * plan). Lets the isomorphic `@aithos/mcp` server core run IN-PROCESS inside * the SDK, against the platform-backed {@link EthosClient}: * * - reads → lazy index snapshot + per-section fetch, decrypted locally * with the session's own key material (owner sphere keys or * delegate wrap key). `opts.identity` from the server is * IGNORED — the client's actor state is the source of truth. * - writes → staged on the EthosClient then published immediately * (1 write tool = 1 edition, iso-functional with the legacy * `dispatchAgentToolLocal`). Transactional `ethos_commit` * batching lands in P2 — this adapter is where it will plug. * * SELF-SIGNING HOST. Unlike `FilesystemStorage`, this backend never receives * key material from the MCP layer: `EthosClient` signs with its own session * keys (owner) or delegate keypair (mandate). Consequently: * * - `loadIdentity()` resolves to `undefined` (typed as `Identity` — see the * fat comment on the method). The server's read path treats a missing * identity as "decrypt what you can" (which we do anyway), and its write * path passes it back to us — where it is ignored. Returning `undefined` * instead of a synthetic key bundle means any FUTURE server code path * that actually dereferences it fails loudly instead of signing garbage. * @aithos/mcp 0.10 should formalize this with a `selfSigningWrites` * capability marker (noted in HANDOFF-MCP-P1). * * - Authorization is enforced by the EthosClient itself: delegate writes * are checked against the mandate's verb-scopes at staging/publish time * (`coversOperation`), anonymous writes throw. The in-process server adds * the coarse gate on top (mandate-scoped `tools/list` exposure). Same * defense-in-depth as the legacy dispatch (scope check + publish check). * * "handle" in this host is the subject DID — the natural addressing key of a * platform-backed ethos. The subject's human handle (from the manifest) is * accepted as an alias once known. */ import type { AithosStorage, ApplyEditsResult, DidDocument, EthosEdit, Identity, IdentityMetadata, Manifest, Mandate, Revocation, SectionDeleteResult, SectionFetchResult, SectionIndexEntry, SectionReadOpts, SectionWriteResult, Sphere, VerifyEthosResult, WriteAuth, ZoneDoc, AddSectionArgs, ModifySectionArgs } from "@aithos/protocol-core"; import type { IndexRow as IndexRowV03, ManifestV03, Section as SectionV03 } from "@aithos/protocol-client"; import type { ZoneName, PublishResult, UpdateSectionPatch, AddSectionInput } from "./ethos.js"; /** * The EXACT slice of {@link EthosClient} this adapter consumes — kept narrow * so T11 can drive the real MCP server over a pure in-memory fake (zero * network, zero crypto), and so the coupling surface is explicit. * `EthosClient` satisfies this structurally. */ export interface SdkStorageHost { readonly subjectDid: string; readonly mode: "owner" | "delegate" | "anonymous"; zone(name: ZoneName): { addSection(input: AddSectionInput): void; updateSection(sectionId: string, patch: UpdateSectionPatch): void; deleteSection(sectionId: string): void; }; publish(): Promise; _indexSnapshot(): Promise<{ readonly manifest: ManifestV03; readonly index: Record; } | null>; _readSection(zone: ZoneName, sectionId: string): Promise; } export declare class SdkStorage implements AithosStorage { #private; constructor(ethos: SdkStorageHost); listHandles(): Promise; loadIdentityMetadata(handle: string): Promise; /** * SELF-SIGNING HOST — resolves to `undefined` BY DESIGN (cast through the * `Identity` return type). The MCP server only ever (a) threads this value * back into OUR read/write methods, which ignore it and use the * EthosClient's own session keys, or (b) skips decryption when it is * falsy — which is exactly right here. A future @aithos/mcp with a * `selfSigningWrites` marker (formalized in @aithos/mcp 0.13 — declared * below) is what keeps this honest: without it the server would refuse * identity-less writes. */ loadIdentity(_handle: string): Promise; /** * Capability marker (@aithos/mcp 0.13): this storage signs writes with the * EthosClient's own session keys — `loadIdentity()` resolving `undefined` * is by design, not an error. */ readonly selfSigningWrites = true; loadDidDocument(_handle: string): Promise; isTrackedIdentity(handle: string): Promise; readManifest(handle: string): Promise; readZoneDoc(_handle: string, _zone: Sphere, _opts?: { identity?: Identity; manifest?: Manifest; }): Promise; readZoneBytes(_handle: string, _zone: Sphere): Promise; readSectionIndex(handle: string, zone: Sphere, _opts?: SectionReadOpts): Promise; readSections(handle: string, ids: string[], opts?: SectionReadOpts & { zone?: Sphere; }): Promise; addSection(args: Omit, _auth: WriteAuth): Promise; modifySection(args: Omit, _auth: WriteAuth): Promise; deleteSection(args: { handle: string; zone: Sphere; sectionId: string; reason?: string; }, _auth: WriteAuth): Promise; /** * The `applyEdits` capability (D3): net-compose the batch, stage the NET * result on the EthosClient buffer, publish ONCE. Same composition rules * as protocol-core's `editSectionsV03` (modify-after-add composes, * delete-after-add cancels, last upsert wins); the staging buffer receives * at most one operation per section, so the single `publish()` builds one * edition with one batched gamma anchor — T13. * * `_auth` is ignored (self-signing host: the EthosClient signs with the * session's own keys; delegate batches are bounded by the mandate at * publish, platform-checked). */ applyEdits(handle: string, edits: readonly EthosEdit[], _auth: WriteAuth): Promise; verifyEthos(_handle: string, _identity: Identity | null, _didDoc: DidDocument): Promise; loadMandate(_id: string): Promise; findRevocation(_mandateId: string): Promise; defaultHandle(): Promise; } //# sourceMappingURL=sdk-storage.d.ts.map