@livestore/cli 0.0.0-snapshot-29b38715366635e2fffea5f896089d326087c0f2 → 0.0.0-snapshot-efc9038147f4b62552a66cc6afa8e3825753b7ff
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/cli.d.ts +1 -15
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/mcp-tool-handlers.d.ts +1 -5
- package/dist/commands/mcp-tool-handlers.d.ts.map +1 -1
- package/dist/commands/mcp-tool-handlers.js +4 -37
- package/dist/commands/mcp-tool-handlers.js.map +1 -1
- package/dist/commands/mcp-tools-defs.d.ts +1 -31
- package/dist/commands/mcp-tools-defs.d.ts.map +1 -1
- package/dist/commands/mcp-tools-defs.js +5 -87
- package/dist/commands/mcp-tools-defs.js.map +1 -1
- package/dist/commands/new-project.d.ts +1 -1
- package/dist/mcp-runtime/runtime.d.ts +3 -4
- package/dist/mcp-runtime/runtime.d.ts.map +1 -1
- package/dist/mcp-runtime/runtime.js +53 -19
- package/dist/mcp-runtime/runtime.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/cli.ts +1 -2
- package/src/commands/mcp-tool-handlers.ts +5 -44
- package/src/commands/mcp-tools-defs.ts +4 -92
- package/src/mcp-runtime/runtime.ts +65 -32
- package/dist/commands/import-export.d.ts +0 -34
- package/dist/commands/import-export.d.ts.map +0 -1
- package/dist/commands/import-export.js +0 -123
- package/dist/commands/import-export.js.map +0 -1
- package/dist/module-loader.d.ts +0 -22
- package/dist/module-loader.d.ts.map +0 -1
- package/dist/module-loader.js +0 -75
- package/dist/module-loader.js.map +0 -1
- package/dist/sync-operations.d.ts +0 -118
- package/dist/sync-operations.d.ts.map +0 -1
- package/dist/sync-operations.js +0 -164
- package/dist/sync-operations.js.map +0 -1
- package/src/commands/import-export.ts +0 -262
- package/src/module-loader.ts +0 -93
- package/src/sync-operations.ts +0 -326
package/dist/cli.d.ts
CHANGED
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
import { Cli } from '@livestore/utils/node';
|
|
2
|
-
export declare const command: Cli.Command.Command<"livestore", import("@effect/platform/HttpClient").HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/
|
|
2
|
+
export declare const command: Cli.Command.Command<"livestore", import("@effect/platform/HttpClient").HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, {
|
|
3
3
|
readonly verbose: boolean;
|
|
4
4
|
readonly subcommand: import("effect/Option").Option<{
|
|
5
|
-
readonly subcommand: import("effect/Option").Option<{
|
|
6
|
-
readonly config: string;
|
|
7
|
-
readonly storeId: string;
|
|
8
|
-
readonly clientId: string;
|
|
9
|
-
readonly output: string;
|
|
10
|
-
} | {
|
|
11
|
-
readonly config: string;
|
|
12
|
-
readonly storeId: string;
|
|
13
|
-
readonly clientId: string;
|
|
14
|
-
readonly force: boolean;
|
|
15
|
-
readonly dryRun: boolean;
|
|
16
|
-
readonly input: string;
|
|
17
|
-
}>;
|
|
18
|
-
} | {
|
|
19
5
|
readonly subcommand: import("effect/Option").Option<{}>;
|
|
20
6
|
} | {
|
|
21
7
|
readonly example: import("effect/Option").Option<string>;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAI3C,eAAO,MAAM,OAAO;;;;;;;;;EAE6C,CAAA"}
|
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Cli } from '@livestore/utils/node';
|
|
2
|
-
import { syncCommand } from "./commands/import-export.js";
|
|
3
2
|
import { mcpCommand } from "./commands/mcp.js";
|
|
4
3
|
import { createCommand } from "./commands/new-project.js";
|
|
5
4
|
export const command = Cli.Command.make('livestore', {
|
|
6
5
|
verbose: Cli.Options.boolean('verbose').pipe(Cli.Options.withDefault(false)),
|
|
7
|
-
}).pipe(Cli.Command.withSubcommands([mcpCommand, createCommand
|
|
6
|
+
}).pipe(Cli.Command.withSubcommands([mcpCommand, createCommand]));
|
|
8
7
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE;IACnD,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;CAC7E,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { livestoreToolkit } from './mcp-tools-defs.ts';
|
|
3
|
-
type LivestoreToolHandlers = Toolkit.HandlersFrom<Toolkit.Tools<typeof livestoreToolkit>>;
|
|
4
|
-
export declare const toolHandlers: LivestoreToolHandlers;
|
|
5
|
-
export {};
|
|
1
|
+
export declare const toolHandlers: any;
|
|
6
2
|
//# sourceMappingURL=mcp-tool-handlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool-handlers.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-tool-handlers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-tool-handlers.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-tool-handlers.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,EAAE,GAoJzB,CAAA"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { Effect
|
|
2
|
-
import { PlatformNode } from '@livestore/utils/node';
|
|
1
|
+
import { Effect } from '@livestore/utils/effect';
|
|
3
2
|
import { blogSchemaContent } from "../mcp-content/schemas/blog.js";
|
|
4
3
|
import { ecommerceSchemaContent } from "../mcp-content/schemas/ecommerce.js";
|
|
5
4
|
import { socialSchemaContent } from "../mcp-content/schemas/social.js";
|
|
6
5
|
import { todoSchemaContent } from "../mcp-content/schemas/todo.js";
|
|
7
6
|
import * as Runtime from "../mcp-runtime/runtime.js";
|
|
8
|
-
import * as SyncOps from "../sync-operations.js";
|
|
9
7
|
import { coachToolHandler } from "./mcp-coach.js";
|
|
10
8
|
import { livestoreToolkit } from "./mcp-tools-defs.js";
|
|
11
|
-
|
|
12
|
-
const SyncOpsLayer = Layer.mergeAll(PlatformNode.NodeFileSystem.layer, FetchHttpClient.layer);
|
|
9
|
+
// Tool handlers using Tim Smart's pattern
|
|
13
10
|
export const toolHandlers = livestoreToolkit.of({
|
|
14
11
|
livestore_coach: coachToolHandler,
|
|
15
12
|
livestore_generate_schema: Effect.fnUntraced(function* ({ schemaType, customDescription }) {
|
|
@@ -113,13 +110,8 @@ export const schema = Schema.create({
|
|
|
113
110
|
return { schemaCode, description };
|
|
114
111
|
}),
|
|
115
112
|
// Connect the single in-process LiveStore instance from user module
|
|
116
|
-
livestore_instance_connect: Effect.fnUntraced(function* ({
|
|
117
|
-
const store = yield* Runtime.init({
|
|
118
|
-
configPath,
|
|
119
|
-
storeId,
|
|
120
|
-
...(clientId !== undefined ? { clientId } : {}),
|
|
121
|
-
...(sessionId !== undefined ? { sessionId } : {}),
|
|
122
|
-
}).pipe(Effect.orDie);
|
|
113
|
+
livestore_instance_connect: Effect.fnUntraced(function* ({ storePath, storeId, clientId, sessionId }) {
|
|
114
|
+
const store = yield* Runtime.init({ storePath, storeId, clientId, sessionId }).pipe(Effect.orDie);
|
|
123
115
|
const eventNames = Array.from(store.schema.eventsDefsMap.keys());
|
|
124
116
|
const tableNames = Array.from(store.schema.state.sqlite.tables.keys());
|
|
125
117
|
return {
|
|
@@ -148,30 +140,5 @@ export const schema = Schema.create({
|
|
|
148
140
|
livestore_instance_disconnect: Effect.fnUntraced(function* () {
|
|
149
141
|
return yield* Runtime.disconnect;
|
|
150
142
|
}),
|
|
151
|
-
// Sync export - pull all events from sync backend
|
|
152
|
-
livestore_sync_export: Effect.fnUntraced(function* ({ configPath, storeId, clientId }) {
|
|
153
|
-
const result = yield* SyncOps.pullEventsFromSyncBackend({
|
|
154
|
-
configPath,
|
|
155
|
-
storeId,
|
|
156
|
-
clientId: clientId ?? 'mcp-export',
|
|
157
|
-
}).pipe(Effect.scoped, Effect.provide(SyncOpsLayer), Effect.orDie);
|
|
158
|
-
return {
|
|
159
|
-
storeId: result.storeId,
|
|
160
|
-
eventCount: result.eventCount,
|
|
161
|
-
exportedAt: result.exportedAt,
|
|
162
|
-
data: result.data,
|
|
163
|
-
};
|
|
164
|
-
}),
|
|
165
|
-
// Sync import - push events to sync backend
|
|
166
|
-
livestore_sync_import: Effect.fnUntraced(function* ({ configPath, storeId, clientId, data, force, dryRun }) {
|
|
167
|
-
return yield* SyncOps.pushEventsToSyncBackend({
|
|
168
|
-
configPath,
|
|
169
|
-
storeId,
|
|
170
|
-
clientId: clientId ?? 'mcp-import',
|
|
171
|
-
data,
|
|
172
|
-
force: force ?? false,
|
|
173
|
-
dryRun: dryRun ?? false,
|
|
174
|
-
}).pipe(Effect.scoped, Effect.provide(SyncOpsLayer), Effect.orDie);
|
|
175
|
-
}),
|
|
176
143
|
});
|
|
177
144
|
//# sourceMappingURL=mcp-tool-handlers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tool-handlers.js","sourceRoot":"","sources":["../../src/commands/mcp-tool-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"mcp-tool-handlers.js","sourceRoot":"","sources":["../../src/commands/mcp-tool-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,0CAA0C;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAQ,gBAAgB,CAAC,EAAE,CAAC;IACnD,eAAe,EAAE,gBAAgB;IAEjC,yBAAyB,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE;QACvF,IAAI,UAAkB,CAAA;QACtB,IAAI,WAAmB,CAAA;QAEvB,QAAQ,U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,CAAC,CAAA"}
|
|
@@ -35,7 +35,7 @@ export declare const livestoreToolkit: Toolkit.Toolkit<{
|
|
|
35
35
|
}, never>;
|
|
36
36
|
readonly livestore_instance_connect: Tool.Tool<"livestore_instance_connect", {
|
|
37
37
|
readonly parameters: Schema.Struct<{
|
|
38
|
-
|
|
38
|
+
storePath: Schema.SchemaClass<string, string, never>;
|
|
39
39
|
storeId: Schema.SchemaClass<string, string, never>;
|
|
40
40
|
clientId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
41
41
|
sessionId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
@@ -89,35 +89,5 @@ export declare const livestoreToolkit: Toolkit.Toolkit<{
|
|
|
89
89
|
readonly success: Schema.TaggedStruct<"disconnected", {}>;
|
|
90
90
|
readonly failure: typeof Schema.Never;
|
|
91
91
|
}, never>;
|
|
92
|
-
readonly livestore_sync_export: Tool.Tool<"livestore_sync_export", {
|
|
93
|
-
readonly parameters: Schema.Struct<{
|
|
94
|
-
configPath: Schema.SchemaClass<string, string, never>;
|
|
95
|
-
storeId: Schema.SchemaClass<string, string, never>;
|
|
96
|
-
clientId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
97
|
-
}>;
|
|
98
|
-
readonly success: Schema.Struct<{
|
|
99
|
-
storeId: typeof Schema.String;
|
|
100
|
-
eventCount: typeof Schema.Number;
|
|
101
|
-
exportedAt: typeof Schema.String;
|
|
102
|
-
data: Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>;
|
|
103
|
-
}>;
|
|
104
|
-
readonly failure: typeof Schema.Never;
|
|
105
|
-
}, never>;
|
|
106
|
-
readonly livestore_sync_import: Tool.Tool<"livestore_sync_import", {
|
|
107
|
-
readonly parameters: Schema.Struct<{
|
|
108
|
-
configPath: Schema.SchemaClass<string, string, never>;
|
|
109
|
-
storeId: Schema.SchemaClass<string, string, never>;
|
|
110
|
-
clientId: Schema.optional<Schema.SchemaClass<string, string, never>>;
|
|
111
|
-
data: Schema.Schema<Schema.JsonValue, Schema.JsonValue, never>;
|
|
112
|
-
force: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
113
|
-
dryRun: Schema.optional<Schema.SchemaClass<boolean, boolean, never>>;
|
|
114
|
-
}>;
|
|
115
|
-
readonly success: Schema.Struct<{
|
|
116
|
-
storeId: typeof Schema.String;
|
|
117
|
-
eventCount: typeof Schema.Number;
|
|
118
|
-
dryRun: typeof Schema.Boolean;
|
|
119
|
-
}>;
|
|
120
|
-
readonly failure: typeof Schema.Never;
|
|
121
|
-
}, never>;
|
|
122
92
|
}>;
|
|
123
93
|
//# sourceMappingURL=mcp-tools-defs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tools-defs.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-tools-defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAG/D,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"mcp-tools-defs.d.ts","sourceRoot":"","sources":["../../src/commands/mcp-tools-defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAG/D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiO5B,CAAA"}
|
|
@@ -30,7 +30,7 @@ export const livestoreToolkit = Toolkit.make(coachTool, Tool.make('livestore_gen
|
|
|
30
30
|
Notes:
|
|
31
31
|
- Only one instance can be active at a time; calling connect again shuts down and replaces the previous instance.
|
|
32
32
|
- Reconnecting creates a fresh, in-memory client database. The state visible to queries is populated by your backend's initial sync behavior; depending on configuration, you may briefly observe empty or partial data until sync completes.
|
|
33
|
-
- \`
|
|
33
|
+
- \`storePath\` is resolved relative to the current working directory.
|
|
34
34
|
- \`syncBackend\` must be a function (factory) that returns a backend; \`syncPayload\` must be JSON-serializable.
|
|
35
35
|
|
|
36
36
|
Module contract (generic example):
|
|
@@ -50,13 +50,13 @@ export const syncPayload = { authToken: process.env.LIVESTORE_SYNC_AUTH_TOKEN ??
|
|
|
50
50
|
|
|
51
51
|
Connect parameters:
|
|
52
52
|
{
|
|
53
|
-
"
|
|
53
|
+
"storePath": "<path-to-your-mcp-module>.ts",
|
|
54
54
|
"storeId": "<store-id>"
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
Optional identifiers to group client state on the server:
|
|
58
58
|
{
|
|
59
|
-
"
|
|
59
|
+
"storePath": "<path-to-your-mcp-module>.ts",
|
|
60
60
|
"storeId": "<store-id>",
|
|
61
61
|
"clientId": "<client-id>",
|
|
62
62
|
"sessionId": "<session-id>"
|
|
@@ -73,7 +73,7 @@ Returns on success:
|
|
|
73
73
|
}
|
|
74
74
|
}`,
|
|
75
75
|
parameters: {
|
|
76
|
-
|
|
76
|
+
storePath: Schema.String.annotations({
|
|
77
77
|
description: 'Path to a module that exports named variables: schema and syncBackend',
|
|
78
78
|
}),
|
|
79
79
|
storeId: Schema.String.annotations({ description: 'Required store id for the LiveStore instance.' }),
|
|
@@ -192,87 +192,5 @@ Example success:
|
|
|
192
192
|
{ "_tag": "disconnected" }`,
|
|
193
193
|
parameters: {},
|
|
194
194
|
success: Schema.TaggedStruct('disconnected', {}),
|
|
195
|
-
})
|
|
196
|
-
description: `Export all events from a sync backend to JSON data.
|
|
197
|
-
|
|
198
|
-
This tool connects directly to the sync backend (without creating a full LiveStore instance) and pulls all events. Useful for backup, migration, and debugging.
|
|
199
|
-
|
|
200
|
-
Module contract (same as livestore_instance_connect):
|
|
201
|
-
\`\`\`ts
|
|
202
|
-
export { schema } from './src/livestore/schema.ts'
|
|
203
|
-
export const syncBackend = makeWsSync({ url: process.env.LIVESTORE_SYNC_URL ?? 'ws://localhost:8787' })
|
|
204
|
-
export const syncPayload = { authToken: process.env.LIVESTORE_SYNC_AUTH_TOKEN }
|
|
205
|
-
\`\`\`
|
|
206
|
-
|
|
207
|
-
Example parameters:
|
|
208
|
-
{
|
|
209
|
-
"configPath": "livestore-cli.config.ts",
|
|
210
|
-
"storeId": "my-store"
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
Returns on success:
|
|
214
|
-
{
|
|
215
|
-
"storeId": "my-store",
|
|
216
|
-
"eventCount": 127,
|
|
217
|
-
"exportedAt": "2024-01-15T10:30:00.000Z",
|
|
218
|
-
"data": { "version": 1, "storeId": "my-store", ... }
|
|
219
|
-
}`,
|
|
220
|
-
parameters: {
|
|
221
|
-
configPath: Schema.String.annotations({
|
|
222
|
-
description: 'Path to a module that exports schema and syncBackend',
|
|
223
|
-
}),
|
|
224
|
-
storeId: Schema.String.annotations({ description: 'Store identifier' }),
|
|
225
|
-
clientId: Schema.optional(Schema.String.annotations({ description: 'Client identifier (default: mcp-export)' })),
|
|
226
|
-
},
|
|
227
|
-
success: Schema.Struct({
|
|
228
|
-
storeId: Schema.String,
|
|
229
|
-
eventCount: Schema.Number,
|
|
230
|
-
exportedAt: Schema.String,
|
|
231
|
-
data: Schema.JsonValue.annotations({ description: 'The export file data (can be saved or passed to import)' }),
|
|
232
|
-
}),
|
|
233
|
-
}).annotate(Tool.Readonly, true), Tool.make('livestore_sync_import', {
|
|
234
|
-
description: `Import events from export data to a sync backend.
|
|
235
|
-
|
|
236
|
-
This tool connects directly to the sync backend and pushes events. The sync backend must be empty.
|
|
237
|
-
|
|
238
|
-
Example parameters:
|
|
239
|
-
{
|
|
240
|
-
"configPath": "livestore-cli.config.ts",
|
|
241
|
-
"storeId": "my-store",
|
|
242
|
-
"data": { "version": 1, "storeId": "my-store", "events": [...] }
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
With options:
|
|
246
|
-
{
|
|
247
|
-
"configPath": "livestore-cli.config.ts",
|
|
248
|
-
"storeId": "my-store",
|
|
249
|
-
"data": { ... },
|
|
250
|
-
"force": true, // Import even if store ID doesn't match
|
|
251
|
-
"dryRun": true // Validate without importing
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
Returns on success:
|
|
255
|
-
{
|
|
256
|
-
"storeId": "my-store",
|
|
257
|
-
"eventCount": 127,
|
|
258
|
-
"dryRun": false
|
|
259
|
-
}`,
|
|
260
|
-
parameters: {
|
|
261
|
-
configPath: Schema.String.annotations({
|
|
262
|
-
description: 'Path to a module that exports schema and syncBackend',
|
|
263
|
-
}),
|
|
264
|
-
storeId: Schema.String.annotations({ description: 'Store identifier' }),
|
|
265
|
-
clientId: Schema.optional(Schema.String.annotations({ description: 'Client identifier (default: mcp-import)' })),
|
|
266
|
-
data: Schema.JsonValue.annotations({
|
|
267
|
-
description: 'The export data to import (from livestore_sync_export or a file)',
|
|
268
|
-
}),
|
|
269
|
-
force: Schema.optional(Schema.Boolean.annotations({ description: 'Force import even if store ID does not match' })),
|
|
270
|
-
dryRun: Schema.optional(Schema.Boolean.annotations({ description: 'Validate without actually importing' })),
|
|
271
|
-
},
|
|
272
|
-
success: Schema.Struct({
|
|
273
|
-
storeId: Schema.String,
|
|
274
|
-
eventCount: Schema.Number,
|
|
275
|
-
dryRun: Schema.Boolean,
|
|
276
|
-
}),
|
|
277
|
-
}).annotate(Tool.Destructive, true));
|
|
195
|
+
}));
|
|
278
196
|
//# sourceMappingURL=mcp-tools-defs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tools-defs.js","sourceRoot":"","sources":["../../src/commands/mcp-tools-defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAC1C,SAAS,EAET,IAAI,CAAC,IAAI,CAAC,2BAA2B,E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AAC;CACrD,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAEnC,IAAI,CAAC,IAAI,CAAC,2BAA2B,EAAE;IACrC,WAAW,EAAE;;;;;;;;;;;;;;EAcf;IACE,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,MAAM,CAAC,KAAK,CACnB,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE;QAC/B,OAAO,EAAE,MAAM,CAAC,MAAM;QACtB,QAAQ,EAAE,MAAM,CAAC,MAAM;QACvB,SAAS,EAAE,MAAM,CAAC,MAAM;QACxB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC;YACnF,WAAW,EAAE,uDAAuD;SACrE,CAAC;KACH,CAAC,EACF,MAAM,CAAC,YAAY,CAAC,cAAc,EAAE,EAAE,CAAC,CACxC;CACF,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAEhC,IAAI,CAAC,IAAI,CAAC,+BAA+B,EAAE;IACzC,WAAW,EAAE;;;2BAGU;IACvB,UAAU,EAAE,EAAE;IACd,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,cAAc,EAAE,EAAE,CAAC;CACjD,CAAC,CACH,CAAA"}
|
|
@@ -25,7 +25,7 @@ declare const DirectoryExistsError_base: Schema.TaggedErrorClass<DirectoryExists
|
|
|
25
25
|
}>;
|
|
26
26
|
export declare class DirectoryExistsError extends DirectoryExistsError_base {
|
|
27
27
|
}
|
|
28
|
-
export declare const createCommand: Cli.Command.Command<"create", HttpClient.HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/
|
|
28
|
+
export declare const createCommand: Cli.Command.Command<"create", HttpClient.HttpClient | Cli.Prompt.Prompt.Environment | import("@effect/platform/CommandExecutor").CommandExecutor, Error | import("@effect/platform/HttpClientError").ResponseError | import("@effect/platform/Error").PlatformError, {
|
|
29
29
|
readonly example: Option.Option<string>;
|
|
30
30
|
readonly ref: string;
|
|
31
31
|
readonly path: Option.Option<string>;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type { UnknownError } from '@livestore/common';
|
|
2
1
|
import type { Store } from '@livestore/livestore';
|
|
3
2
|
import { Effect, Option, Schema } from '@livestore/utils/effect';
|
|
4
3
|
/**
|
|
5
4
|
* Dynamically imports a module that exports a `makeStore({ storeId }): Promise<Store>` function,
|
|
6
5
|
* calls it with the provided storeId, and caches the Store instance for subsequent tool calls.
|
|
7
6
|
*/
|
|
8
|
-
export declare const init: ({
|
|
9
|
-
|
|
7
|
+
export declare const init: ({ storePath, storeId, clientId, sessionId, }: {
|
|
8
|
+
storePath: string;
|
|
10
9
|
storeId: string;
|
|
11
10
|
clientId?: string;
|
|
12
11
|
sessionId?: string;
|
|
13
|
-
}) => Effect.Effect<Store<any>,
|
|
12
|
+
}) => Effect.Effect<Store<any, {}>, never, never>;
|
|
14
13
|
export declare const getStore: Effect.Effect<Option.Option<Store<any, {}>>, never, never>;
|
|
15
14
|
export declare const status: Effect.Effect<{
|
|
16
15
|
_tag: "disconnected";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/mcp-runtime/runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/mcp-runtime/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAGjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAKhE;;;GAGG;AACH,eAAO,MAAM,IAAI,GAAI,8CAKlB;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,gDAgFG,CAAA;AAEJ,eAAO,MAAM,QAAQ,4DAAgD,CAAA;AAErE,eAAO,MAAM,MAAM;;;;;;;;;;;;gBAyB2B,CAAA;AAE9C,eAAO,MAAM,KAAK,GAAI,qBAAqB;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE;;;;;gBAWlE,CAAA;AAE/C,eAAO,MAAM,MAAM,GAAI,YAAY;IAAE,MAAM,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAA;KAAE,CAAC,CAAA;CAAE;;gBAWtD,CAAA;AAEhD,eAAO,MAAM,UAAU;;gBAQ2B,CAAA"}
|
|
@@ -1,54 +1,88 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { pathToFileURL } from 'node:url';
|
|
1
11
|
import { makeAdapter as makeNodeAdapter } from '@livestore/adapter-node';
|
|
2
|
-
import { LiveStoreEvent, SystemTables } from '@livestore/common/schema';
|
|
12
|
+
import { isLiveStoreSchema, LiveStoreEvent, SystemTables } from '@livestore/common/schema';
|
|
3
13
|
import { createStorePromise } from '@livestore/livestore';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { loadModuleConfig } from "../module-loader.js";
|
|
14
|
+
import { shouldNeverHappen } from '@livestore/utils';
|
|
15
|
+
import { Effect, Option, Schema } from '@livestore/utils/effect';
|
|
7
16
|
/** Currently connected store */
|
|
8
17
|
let store;
|
|
9
|
-
/** Layer providing FileSystem and HttpClient for module loading */
|
|
10
|
-
const ModuleLoaderLayer = Layer.mergeAll(PlatformNode.NodeFileSystem.layer, FetchHttpClient.layer);
|
|
11
18
|
/**
|
|
12
19
|
* Dynamically imports a module that exports a `makeStore({ storeId }): Promise<Store>` function,
|
|
13
20
|
* calls it with the provided storeId, and caches the Store instance for subsequent tool calls.
|
|
14
21
|
*/
|
|
15
|
-
export const init = ({
|
|
22
|
+
export const init = ({ storePath, storeId, clientId, sessionId, }) => Effect.promise(async () => {
|
|
16
23
|
if (!storeId || typeof storeId !== 'string') {
|
|
17
|
-
|
|
24
|
+
throw new Error('Invalid storeId: expected a non-empty string');
|
|
25
|
+
}
|
|
26
|
+
// Resolve to absolute path and import as file URL
|
|
27
|
+
const abs = path.isAbsolute(storePath) ? storePath : path.resolve(process.cwd(), storePath);
|
|
28
|
+
const mod = await import(__rewriteRelativeImportExtension(pathToFileURL(abs).href));
|
|
29
|
+
// Validate required exports
|
|
30
|
+
const schema = mod?.schema;
|
|
31
|
+
if (!isLiveStoreSchema(schema)) {
|
|
32
|
+
throw new Error(`Module at ${abs} must export a valid LiveStore 'schema'. Ex: export { schema } from './src/livestore/schema.ts'`);
|
|
33
|
+
}
|
|
34
|
+
const syncBackend = mod?.syncBackend;
|
|
35
|
+
if (typeof syncBackend !== 'function') {
|
|
36
|
+
throw new Error(`Module at ${abs} must export a 'syncBackend' constructor (e.g., makeWsSync({ url })). Ex: export const syncBackend = makeWsSync({ url })`);
|
|
18
37
|
}
|
|
19
|
-
|
|
38
|
+
// Optional: syncPayload for authenticated backends
|
|
39
|
+
const syncPayloadSchemaExport = mod?.syncPayloadSchema;
|
|
40
|
+
const syncPayloadSchema = syncPayloadSchemaExport === undefined
|
|
41
|
+
? Schema.JsonValue
|
|
42
|
+
: Schema.isSchema(syncPayloadSchemaExport)
|
|
43
|
+
? syncPayloadSchemaExport
|
|
44
|
+
: shouldNeverHappen(`Exported 'syncPayloadSchema' from ${abs} must be an Effect Schema (received ${typeof syncPayloadSchemaExport}).`);
|
|
45
|
+
const syncPayloadExport = mod?.syncPayload;
|
|
46
|
+
const syncPayload = syncPayloadExport === undefined
|
|
47
|
+
? undefined
|
|
48
|
+
: (() => {
|
|
49
|
+
try {
|
|
50
|
+
return Schema.decodeSync(syncPayloadSchema)(syncPayloadExport);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Failed to decode 'syncPayload' from ${abs} using the provided schema: ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
20
56
|
// Build Node adapter internally
|
|
21
57
|
const adapter = makeNodeAdapter({
|
|
22
58
|
storage: { type: 'in-memory' },
|
|
23
59
|
...(clientId ? { clientId } : {}),
|
|
24
60
|
...(sessionId ? { sessionId } : {}),
|
|
25
61
|
sync: {
|
|
26
|
-
backend:
|
|
62
|
+
backend: syncBackend,
|
|
27
63
|
initialSyncOptions: { _tag: 'Blocking', timeout: 5000 },
|
|
28
64
|
onSyncError: 'shutdown',
|
|
29
65
|
},
|
|
30
66
|
});
|
|
31
67
|
// Create the store
|
|
32
|
-
const s =
|
|
68
|
+
const s = await createStorePromise({
|
|
33
69
|
schema,
|
|
34
70
|
storeId,
|
|
35
71
|
adapter,
|
|
36
72
|
disableDevtools: true,
|
|
37
73
|
syncPayload,
|
|
38
74
|
syncPayloadSchema,
|
|
39
|
-
})
|
|
75
|
+
});
|
|
40
76
|
// Replace existing store if any
|
|
41
77
|
if (store) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
catch { }
|
|
47
|
-
});
|
|
78
|
+
try {
|
|
79
|
+
await store.shutdownPromise();
|
|
80
|
+
}
|
|
81
|
+
catch { }
|
|
48
82
|
}
|
|
49
83
|
store = s;
|
|
50
84
|
return store;
|
|
51
|
-
})
|
|
85
|
+
});
|
|
52
86
|
export const getStore = Effect.sync(() => Option.fromNullable(store));
|
|
53
87
|
export const status = Effect.gen(function* () {
|
|
54
88
|
const opt = yield* getStore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/mcp-runtime/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/mcp-runtime/runtime.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhE,gCAAgC;AAChC,IAAI,KAA6B,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,EACnB,SAAS,EACT,OAAO,EACP,QAAQ,EACR,SAAS,GAMV,EAAE,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;IACxB,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA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