@telepath-computer/autofile 0.3.0 → 0.5.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/dist/server.js CHANGED
@@ -5,15 +5,20 @@
5
5
  */
6
6
  import { createRequire } from "node:module";
7
7
  import { fromJsonSchema, McpServer, ProtocolError, ProtocolErrorCode, ResourceNotFoundError, } from "@modelcontextprotocol/server";
8
- import { isResourceUri, } from "./store.js";
9
- const SERVER_DESCRIPTION = "Typed records that agents file and retrieve, kept as JSON files in a folder the user owns.";
8
+ import { buildTools, } from "./mcp-tools.js";
9
+ import { buildResources, isResourceUri } from "./mcp-resources.js";
10
+ const SERVER_DESCRIPTION = "Typed records that agents file and retrieve.";
10
11
  const BASE_INSTRUCTIONS = "Autofile is where the user keeps durable information, as typed records. When information should outlive the current task, file it here. Call `list_types` to see the types and what belongs in each, and `get_type` for the schema of one. Search with `find_records` before creating a record, so the same thing is not filed twice. If no type fits, propose a new type to the user and create it only once they agree.";
11
12
  const RESOURCE_PAGE_SIZE = 100;
12
13
  const packageJson = createRequire(import.meta.url)("../package.json");
13
14
  const findRecordsSchema = fromJsonSchema({
14
15
  type: "object",
15
16
  properties: {
16
- type: { type: "string", description: "The type to search." },
17
+ type: {
18
+ type: ["string", "array"],
19
+ items: { type: "string" },
20
+ description: "The type or types to search. All types when absent.",
21
+ },
17
22
  q: {
18
23
  type: "string",
19
24
  description: "Words that must all appear, ignoring case, in the string values of a record at any depth.",
@@ -36,10 +41,9 @@ const findRecordsSchema = fromJsonSchema({
36
41
  },
37
42
  cursor: {
38
43
  type: "string",
39
- description: "An opaque cursor returned by the previous page. The next page starts after the last record file that page read, even if that file was deleted.",
44
+ description: "An opaque cursor returned by the previous page. The next page starts after the last record that page considered, even if that record was deleted.",
40
45
  },
41
46
  },
42
- required: ["type"],
43
47
  additionalProperties: false,
44
48
  });
45
49
  const getRecordSchema = fromJsonSchema({
@@ -58,7 +62,7 @@ const createRecordSchema = fromJsonSchema({
58
62
  },
59
63
  record: {
60
64
  type: "object",
61
- description: "The full record, which must match the schema of its type. A blob field may hold the absolute path of a local file or a `data:` URI with base64 contents; Autofile stores the file and puts its blob URI in the field.",
65
+ description: "The full record, which must match the schema of its type. Blob fields hold existing blob URIs returned by `upload_blob`; the same URI may be used by multiple records.",
62
66
  },
63
67
  },
64
68
  required: ["type", "record"],
@@ -70,12 +74,21 @@ const updateRecordSchema = fromJsonSchema({
70
74
  uri: { type: "string", description: "The URI of the record." },
71
75
  patch: {
72
76
  type: "object",
73
- description: "A [JSON Merge Patch](https://www.rfc-editor.org/rfc/rfc7396): fields in the patch are set, a field set to `null` is removed, nested objects are merged, and arrays are replaced whole. A blob field may hold the absolute path of a local file or a `data:` URI with base64 contents; Autofile stores the file and puts its blob URI in the field.",
77
+ description: "A [JSON Merge Patch](https://www.rfc-editor.org/rfc/rfc7396): fields in the patch are set, a field set to `null` is removed, nested objects are merged, and arrays are replaced whole. Blob fields hold existing blob URIs returned by `upload_blob`; the same URI may be used by multiple records.",
74
78
  },
75
79
  },
76
80
  required: ["uri", "patch"],
77
81
  additionalProperties: false,
78
82
  });
83
+ const uploadBlobSchema = fromJsonSchema({
84
+ type: "object",
85
+ properties: {
86
+ base64: { type: "string", description: "Canonical base64 contents. Requires mediaType; cannot be combined with path." },
87
+ path: { type: "string", description: "An absolute local file path, accepted only over stdio. Cannot be combined with base64." },
88
+ mediaType: { type: "string", description: "The media type of the contents. Required for base64; inferred from the file extension for a path when absent, falling back to application/octet-stream." },
89
+ },
90
+ additionalProperties: false,
91
+ });
79
92
  const deleteRecordSchema = fromJsonSchema({
80
93
  type: "object",
81
94
  properties: { uri: { type: "string", description: "The URI of the record." } },
@@ -97,12 +110,16 @@ const createTypeSchema = fromJsonSchema({
97
110
  type: "object",
98
111
  properties: {
99
112
  type: { type: "string", description: "The name of the type." },
100
- description: { type: "string", description: "What belongs in the folder." },
113
+ description: { type: "string", description: "What belongs in the type." },
101
114
  schema: { type: "object", description: "The JSON Schema for records of the type." },
102
115
  titleField: {
103
116
  type: "string",
104
117
  description: "A top-level field of the record whose string value is shown as its title.",
105
118
  },
119
+ title: {
120
+ type: "string",
121
+ description: "The name of the type in words, in the singular, such as \"Journal entry\", shown to people in place of the type name.",
122
+ },
106
123
  },
107
124
  required: ["type", "description", "schema"],
108
125
  additionalProperties: false,
@@ -117,6 +134,10 @@ const updateTypeSchema = fromJsonSchema({
117
134
  type: ["string", "null"],
118
135
  description: "The new title field; `null` removes it.",
119
136
  },
137
+ title: {
138
+ type: ["string", "null"],
139
+ description: "The new title; `null` removes it.",
140
+ },
120
141
  },
121
142
  required: ["type"],
122
143
  additionalProperties: false,
@@ -128,8 +149,10 @@ const deleteTypeSchema = fromJsonSchema({
128
149
  additionalProperties: false,
129
150
  });
130
151
  /** Builds one MCP server around a store, without choosing its transport. */
131
- export async function buildServer(store) {
132
- const { types } = await store.listTypes({});
152
+ export async function buildServer(autofile, options = {}) {
153
+ const tools = buildTools(autofile);
154
+ const resources = buildResources(autofile, options);
155
+ const { types } = await tools.listTypes({});
133
156
  const typeNames = types.map(({ type }) => type).sort();
134
157
  const typeSummary = typeNames.length === 0 ? "none yet" : typeNames.join(", ");
135
158
  const server = new McpServer({
@@ -140,43 +163,43 @@ export async function buildServer(store) {
140
163
  instructions: `${BASE_INSTRUCTIONS}\n\nTypes: ${typeSummary}. This list was taken when the session began; call \`list_types\` for types created since.`,
141
164
  });
142
165
  server.registerTool("find_records", {
143
- description: "Searches the records of one type and returns matching records in URI order. It reads past nonmatching files until the page has `limit` results, reaches 64 KB of JSON, or no files remain; the size cap never prevents the first result. `fields` selects top-level fields to return, while matching uses the whole record. A schema-invalid record is listed in `errors` only when it matches the search; a file that cannot be read or parsed as JSON is always listed. Autofile is where the user keeps durable information.",
166
+ description: "Searches records and returns matching records in URI order. It skips nonmatching records until the page has `limit` results, reaches 64 KB of JSON, or no records remain; the size cap never prevents the first result. `fields` selects top-level fields to return, while matching uses the whole record. A schema-invalid record is listed in `errors` only when it matches the search; a record that cannot be read is always listed. Autofile is where the user keeps durable information.",
144
167
  inputSchema: findRecordsSchema,
145
- }, async (input) => toolResult(await store.findRecords(input)));
168
+ }, async (input) => toolResult(await tools.findRecords(input)));
146
169
  server.registerTool("get_record", {
147
- description: "Returns one record by URI: its `uri`, `createdAt` and `updatedAt` times, and `value`. A record that does not match its type is still returned, with what must change in `error`.",
170
+ description: "Returns one record by URI: its `uri`, optional `title`, `createdAt` and `updatedAt` times, and `value`. A record that does not match its type is still returned, with what must change in `error`.",
148
171
  inputSchema: getRecordSchema,
149
- }, async (input) => toolResult(await store.getRecord(input)));
172
+ }, async (input) => toolResult(await tools.getRecord(input)));
150
173
  server.registerTool("create_record", {
151
174
  description: "Creates a record and returns its URI. `record` is the full record and must match the schema of its type, which `get_type` returns. `key` is optional and generated when absent. Autofile is where the user keeps durable information.",
152
175
  inputSchema: createRecordSchema,
153
- }, async (input, context) => toolResult(await store.createRecord(input, {
154
- allowLocalPaths: context.http === undefined,
155
- })));
156
- server.registerTool("update_record", { description: "Changes a record and returns its URI.", inputSchema: updateRecordSchema }, async (input, context) => toolResult(await store.updateRecord(input, {
157
- allowLocalPaths: context.http === undefined,
158
- })));
176
+ }, async (input) => toolResult(await tools.createRecord(input)));
177
+ server.registerTool("update_record", { description: "Changes a record and returns its URI.", inputSchema: updateRecordSchema }, async (input) => toolResult(await tools.updateRecord(input)));
178
+ server.registerTool("upload_blob", {
179
+ description: "Uploads bytes and returns their blob URI for use in records. Supply canonical base64 and a media type, up to 7 MiB, or an absolute local path over stdio with no size limit.",
180
+ inputSchema: uploadBlobSchema,
181
+ }, async (input, context) => toolResult(await tools.uploadBlob(input, { allowLocalPaths: context.http === undefined })));
159
182
  server.registerTool("delete_record", {
160
183
  description: "Deletes a record, removes the links to it from other records, and returns its URI.",
161
184
  inputSchema: deleteRecordSchema,
162
- }, async (input) => toolResult(await store.deleteRecord(input)));
185
+ }, async (input) => toolResult(await tools.deleteRecord(input)));
163
186
  server.registerTool("list_types", {
164
- description: "Returns every type, ordered by name, with the URI of its declaration and its description.",
187
+ description: "Returns every type, ordered by name, with the URI of its declaration, its description, and its `title` when it has one.",
165
188
  inputSchema: listTypesSchema,
166
- }, async (input) => toolResult(await store.listTypes(input)));
167
- server.registerTool("get_type", { description: "Returns the declaration of a type with its URI added.", inputSchema: getTypeSchema }, async (input) => toolResult(await store.getType(input)));
168
- server.registerTool("create_type", { description: "Declares a type and returns the URI of its declaration.", inputSchema: createTypeSchema }, async (input) => toolResult(await store.createType(input)));
189
+ }, async (input) => toolResult(await tools.listTypes(input)));
190
+ server.registerTool("get_type", { description: "Returns the declaration of a type with its URI added.", inputSchema: getTypeSchema }, async (input) => toolResult(await tools.getType(input)));
191
+ server.registerTool("create_type", { description: "Declares a type and returns the URI of its declaration.", inputSchema: createTypeSchema }, async (input) => toolResult(await tools.createType(input)));
169
192
  server.registerTool("update_type", {
170
- description: "Replaces the description, schema or title field of a type, or any of them.",
193
+ description: "Replaces the description, schema, title field or title of a type, or any of them.",
171
194
  inputSchema: updateTypeSchema,
172
- }, async (input) => toolResult(await store.updateType(input)));
173
- server.registerTool("delete_type", { description: "Deletes a type and returns its URI.", inputSchema: deleteTypeSchema }, async (input) => toolResult(await store.deleteType(input)));
195
+ }, async (input) => toolResult(await tools.updateType(input)));
196
+ server.registerTool("delete_type", { description: "Deletes a type and returns its URI.", inputSchema: deleteTypeSchema }, async (input) => toolResult(await tools.deleteType(input)));
174
197
  // The high-level resource API returns every resource at once. These
175
198
  // handlers stay at the low-level boundary where cursors remain explicit;
176
199
  // the process-level watcher supplies the advertised change notices.
177
200
  server.server.registerCapabilities({ resources: { subscribe: true, listChanged: true } });
178
201
  server.server.setRequestHandler("resources/list", async (request) => {
179
- const resources = await store.listResources();
202
+ const listed = await resources.listResources();
180
203
  const cursor = request.params?.cursor;
181
204
  let start = 0;
182
205
  if (cursor !== undefined) {
@@ -184,17 +207,14 @@ export async function buildServer(store) {
184
207
  if (previousUri === undefined) {
185
208
  throw new ProtocolError(ProtocolErrorCode.InvalidParams, "Invalid resource cursor");
186
209
  }
187
- const nextIndex = resources.findIndex(({ uri }) => uri > previousUri);
188
- start = nextIndex < 0 ? resources.length : nextIndex;
210
+ const nextIndex = listed.findIndex(({ uri }) => uri > previousUri);
211
+ start = nextIndex < 0 ? listed.length : nextIndex;
189
212
  }
190
- const page = resources.slice(start, start + RESOURCE_PAGE_SIZE);
213
+ const page = listed.slice(start, start + RESOURCE_PAGE_SIZE);
191
214
  const last = page.at(-1);
192
215
  return {
193
- resources: page.map(({ lastModified, ...resource }) => ({
194
- ...resource,
195
- ...(lastModified === undefined ? {} : { annotations: { lastModified } }),
196
- })),
197
- ...(last !== undefined && start + page.length < resources.length
216
+ resources: page,
217
+ ...(last !== undefined && start + page.length < listed.length
198
218
  ? { nextCursor: encodeCursor(last.uri) }
199
219
  : {}),
200
220
  ttlMs: 0,
@@ -202,7 +222,7 @@ export async function buildServer(store) {
202
222
  };
203
223
  });
204
224
  server.server.setRequestHandler("resources/read", async (request) => {
205
- const contents = await store.readResource(request.params.uri);
225
+ const contents = await resources.readResource(request.params.uri);
206
226
  if (contents === undefined)
207
227
  throw new ResourceNotFoundError(request.params.uri);
208
228
  return { contents: [contents], ttlMs: 0, cacheScope: "private" };
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EACL,cAAc,EACd,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,qBAAqB,GAItB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,aAAa,GAYd,MAAM,YAAY,CAAC;AAEpB,MAAM,kBAAkB,GAAG,4FAA4F,CAAC;AACxH,MAAM,iBAAiB,GAAG,2ZAA2Z,CAAC;AACtb,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,WAAW,GAAG,aAAa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AAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;QACvD,iBAAiB,EAAE,IAAI;QACvB,GAAG,CAAC,QAAQ,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC3F,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACxD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC/C,IAAI,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,MAAM;QAAE,OAAO,SAAS,CAAC;IAC7D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
package/dist/store.d.ts CHANGED
@@ -1,132 +1,126 @@
1
1
  /**
2
- * Reads and writes Autofile's on-disk types and records, and exposes recognized
3
- * records, declarations, and blobs as plain resource data. Each operation reads
4
- * current files and keeps protocol-specific behavior outside the store.
2
+ * Autofile owns one data folder: record and type operations, blob uploads and
3
+ * reads, and shared change subscriptions. Operations read current files;
4
+ * protocol adapters translate these values without owning a second persistence
5
+ * implementation.
5
6
  */
6
- import type { JsonObject } from "./json.js";
7
+ import { type JsonObject } from "./json.js";
8
+ import { type PreparedSchema } from "./schema.js";
7
9
  export type { JsonObject, JsonPrimitive, JsonValue } from "./json.js";
8
- export interface StoreError {
10
+ /** One reason an operation was refused, with an address when applicable. */
11
+ export interface AutofileProblem {
9
12
  uri?: string;
10
13
  message: string;
11
14
  }
12
- export interface Refusal {
13
- errors: StoreError[];
15
+ /** A refused operation, with every problem the caller can correct. */
16
+ export declare class AutofileError extends Error {
17
+ readonly problems: AutofileProblem[];
18
+ constructor(problems: AutofileProblem[]);
14
19
  }
15
- export interface OpenStoreOptions {
16
- dataFolder?: string;
17
- writeLockPath?: string;
18
- }
19
- /** Transport-sensitive permissions for a record write. */
20
- export interface RecordWriteOptions {
21
- allowLocalPaths?: boolean;
22
- }
23
- export interface Store {
24
- findRecords(input: FindRecordsInput): Promise<FindRecordsResult | Refusal>;
25
- getRecord(input: GetRecordInput): Promise<RecordResult | Refusal>;
26
- createRecord(input: CreateRecordInput, options?: RecordWriteOptions): Promise<UriResult | Refusal>;
27
- updateRecord(input: UpdateRecordInput, options?: RecordWriteOptions): Promise<UriResult | Refusal>;
28
- deleteRecord(input: DeleteRecordInput): Promise<UriResult | Refusal>;
29
- listTypes(input: Record<string, never>): Promise<ListTypesResult>;
30
- getType(input: GetTypeInput): Promise<TypeResult | Refusal>;
31
- createType(input: CreateTypeInput): Promise<UriResult | Refusal>;
32
- updateType(input: UpdateTypeInput): Promise<UpdateTypeResult | Refusal>;
33
- deleteType(input: DeleteTypeInput): Promise<UriResult | Refusal>;
34
- listResources(): Promise<StoreResource[]>;
35
- getResourceMetadata(uri: string): Promise<StoreResource | undefined>;
36
- listResourceFolder(folder: string): Promise<StoreResource[]>;
37
- listTypeResources(type: string): Promise<StoreResource[]>;
38
- readResource(uri: string): Promise<StoreResourceContents | undefined>;
39
- }
40
- export interface FindRecordsInput {
20
+ /** A record with its address, identity, and optional display title. */
21
+ export interface AutofileRecord {
22
+ uri: string;
41
23
  type: string;
24
+ key: string;
25
+ title?: string;
26
+ problems?: AutofileProblem[];
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ value: JsonObject;
30
+ }
31
+ /** Optional filters and paging controls; where and fields apply only to value. */
32
+ export interface RecordQuery {
33
+ type?: string | string[];
42
34
  q?: string;
43
35
  where?: JsonObject;
44
- limit?: number;
45
36
  fields?: string[];
37
+ limit?: number;
46
38
  cursor?: string;
47
39
  }
48
- export interface GetRecordInput {
49
- uri: string;
50
- }
51
- export interface CreateRecordInput {
52
- type: string;
53
- key?: string;
54
- record: JsonObject;
55
- }
56
- export interface UpdateRecordInput {
57
- uri: string;
58
- patch: JsonObject;
59
- }
60
- export interface DeleteRecordInput {
61
- uri: string;
62
- }
63
- export interface GetTypeInput {
64
- type: string;
40
+ /** One page of matching records and records that could not be returned. */
41
+ export interface RecordQueryResult {
42
+ records: AutofileRecord[];
43
+ unreadable: {
44
+ uri: string;
45
+ message: string;
46
+ }[];
47
+ cursor?: string;
65
48
  }
66
- export interface CreateTypeInput {
67
- type: string;
49
+ /** The fields stored in a type declaration. */
50
+ export interface TypeDefinition {
68
51
  description: string;
69
52
  schema: JsonObject;
70
53
  titleField?: string;
54
+ title?: string;
71
55
  }
72
- export interface UpdateTypeInput {
73
- type: string;
74
- description?: string;
75
- schema?: JsonObject;
76
- titleField?: string | null;
77
- }
78
- export interface DeleteTypeInput {
79
- type: string;
80
- }
81
- export interface UriResult {
56
+ /** A type declaration together with its name and address. */
57
+ export interface TypeDeclaration extends TypeDefinition {
82
58
  uri: string;
83
- }
84
- export interface FindRecordsResult {
85
- records: RecordResult[];
86
- errors: StoreError[];
87
- cursor?: string;
88
- }
89
- export interface RecordResult extends UriResult {
90
- createdAt: string;
91
- updatedAt: string;
92
- value: JsonObject;
93
- error?: string;
94
- }
95
- export interface TypeSummary extends UriResult {
96
59
  type: string;
97
- description: string;
60
+ problems?: AutofileProblem[];
98
61
  }
99
- export interface ListTypesResult {
100
- types: TypeSummary[];
101
- }
102
- export interface TypeResult extends UriResult {
103
- description: string;
104
- schema: JsonObject;
105
- titleField?: string;
106
- }
107
- export interface UpdateTypeResult extends UriResult {
108
- errors: StoreError[];
109
- }
110
- /** Plain metadata for one resource recognized in the data folder. */
111
- export interface StoreResource extends UriResult {
112
- name: string;
62
+ /** Changes to a declaration; null removes the title or title field. */
63
+ export type TypeChanges = Partial<Omit<TypeDefinition, "titleField" | "title">> & {
64
+ titleField?: string | null;
65
+ title?: string | null;
66
+ };
67
+ /** Metadata for a blob, including a read-only local file when available. */
68
+ export interface BlobStat {
69
+ size: number;
113
70
  mimeType: string;
114
- title?: string;
115
- description?: string;
116
- size?: number;
117
- lastModified?: string;
71
+ path?: string;
118
72
  }
119
- /** Exact contents of a recognized text or binary resource. */
120
- export type StoreResourceContents = {
121
- uri: string;
122
- mimeType: string;
123
- text: string;
124
- } | {
73
+ /** A half-open interval of attachment bytes, like Uint8Array.subarray. */
74
+ export interface BlobRange {
75
+ start: number;
76
+ end: number;
77
+ }
78
+ /** A record or type was created, changed, or deleted. */
79
+ export interface ChangeEvent {
125
80
  uri: string;
126
- mimeType: string;
127
- blob: string;
128
- };
129
- /** Opens a store, creating its data folder when it does not exist. */
130
- export declare function openStore(options?: OpenStoreOptions): Promise<Store>;
131
- /** Returns whether a string is the canonical URI of an Autofile resource. */
132
- export declare function isResourceUri(uri: string): boolean;
81
+ kind: "created" | "changed" | "deleted";
82
+ }
83
+ type ChangeListener = (changes: ChangeEvent[]) => void | Promise<void>;
84
+ /** Handles failures from this subscription or from change monitoring. */
85
+ export interface WatchOptions {
86
+ onError?: (error: Error) => void;
87
+ }
88
+ /** The store implementation. Construction resolves paths but performs no I/O. */
89
+ export declare class Autofile {
90
+ #private;
91
+ constructor(options: {
92
+ folder: string;
93
+ });
94
+ readonly records: {
95
+ find: (query?: RecordQuery) => Promise<RecordQueryResult>;
96
+ get: (uri: string) => Promise<AutofileRecord | undefined>;
97
+ create: (type: string, value: JsonObject, options?: {
98
+ key?: string;
99
+ }) => Promise<AutofileRecord>;
100
+ update: (uri: string, patch: JsonObject) => Promise<AutofileRecord>;
101
+ delete: (uri: string) => Promise<void>;
102
+ };
103
+ readonly types: {
104
+ list: () => Promise<TypeDeclaration[]>;
105
+ get: (name: string) => Promise<TypeDeclaration | undefined>;
106
+ create: (name: string, definition: TypeDefinition) => Promise<TypeDeclaration>;
107
+ update: (name: string, changes: TypeChanges) => Promise<TypeDeclaration>;
108
+ delete: (name: string) => Promise<void>;
109
+ };
110
+ readonly blobs: {
111
+ put: (bytes: Uint8Array, mediaType: string) => Promise<string>;
112
+ putStream: (chunks: AsyncIterable<Uint8Array>, mediaType: string) => Promise<string>;
113
+ get: (uri: string) => Promise<{
114
+ bytes: Uint8Array;
115
+ mimeType: string;
116
+ } | undefined>;
117
+ stat: (uri: string) => Promise<BlobStat | undefined>;
118
+ stream: (uri: string, range?: BlobRange) => Promise<ReadableStream<Uint8Array> | undefined>;
119
+ };
120
+ /** Checks a schema without accessing storage or checking link targets. */
121
+ static prepareSchema(schema: JsonObject): Promise<PreparedSchema>;
122
+ /** Subscribes after the shared watcher is ready; the returned function unsubscribes. */
123
+ watch(onChange: ChangeListener, options?: WatchOptions): Promise<() => Promise<void>>;
124
+ /** Stops change subscriptions. Future operations on this instance are refused. */
125
+ close(): Promise<void>;
126
+ }