@magnitudedev/pi-extension 0.0.1-alpha.2 → 0.0.1-alpha.3
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/README.md +3 -2
- package/dist/magnitude-plugin.json +4 -4
- package/dist/magnitude.js +38 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,8 +17,9 @@ are needed. If Magnitude is missing, accepting setup installs the CLI with
|
|
|
17
17
|
`npm install --global @magnitudedev/cli` before opening onboarding. Pi stays visible with its native
|
|
18
18
|
spinner: “Installing Magnitude…”. Installer output is suppressed; failures
|
|
19
19
|
show a concise diagnostic. Escape cancels preparation, and `/magnitude-setup` retries.
|
|
20
|
-
An existing CLI is preserved
|
|
21
|
-
update
|
|
20
|
+
An existing CLI is preserved. The extension invokes `magnitude setup --host pi`; `--host` is hidden from help.
|
|
21
|
+
If an older CLI does not recognize that option, update it explicitly and retry; it is never silently
|
|
22
|
+
replaced.
|
|
22
23
|
|
|
23
24
|
No or Escape leaves “You can set up local models anytime with `/magnitude-setup`.” in the conversation.
|
|
24
25
|
The offer is remembered per Pi profile across restarts, reloads, and package updates. Existing
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnitudedev/pi-extension",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.3",
|
|
4
4
|
"rpcVersion": 1,
|
|
5
|
-
"contentFingerprint": "
|
|
5
|
+
"contentFingerprint": "5d348e366e4c95b29edba024aae7756e7e941695537923bd3e82b1ddc54b9566",
|
|
6
6
|
"files": {
|
|
7
|
-
"README.md": "
|
|
8
|
-
"dist/magnitude.js": "
|
|
7
|
+
"README.md": "c4536c32bc79ddaee7d09536f79c845c2189e8ddc721e583836eb399d9322053",
|
|
8
|
+
"dist/magnitude.js": "14723faa27101270992397f22fcef2ca0f8cd55753e717250f0c92f921653e07",
|
|
9
9
|
"dist/skills/magnitude/SKILL.md": "37de67f0c7b831415f6298c8785b7ae97d5cfe454dc778651d96114840d2ace2"
|
|
10
10
|
}
|
|
11
11
|
}
|
package/dist/magnitude.js
CHANGED
|
@@ -5853,9 +5853,10 @@ import * as Command2 from "@effect/platform/Command";
|
|
|
5853
5853
|
import * as CommandExecutor3 from "@effect/platform/CommandExecutor";
|
|
5854
5854
|
import * as FileSystem from "@effect/platform/FileSystem";
|
|
5855
5855
|
import * as NodeContext from "@effect/platform-node/NodeContext";
|
|
5856
|
+
import { FetchHttpClient as FetchHttpClient2 } from "@effect/platform";
|
|
5856
5857
|
import { delimiter, join } from "node:path";
|
|
5857
5858
|
import { stripVTControlCharacters } from "node:util";
|
|
5858
|
-
import { Context as Context7, Effect as Effect12, Exit as Exit3, Fiber as Fiber2, Layer as Layer6, ManagedRuntime as ManagedRuntime2, Schema as
|
|
5859
|
+
import { Context as Context7, Effect as Effect12, Exit as Exit3, Fiber as Fiber2, Layer as Layer6, ManagedRuntime as ManagedRuntime2, Schema as Schema52, Scope as Scope4, Stream as Stream7 } from "effect";
|
|
5859
5860
|
import { CancellableLoader } from "@earendil-works/pi-tui";
|
|
5860
5861
|
|
|
5861
5862
|
// ../../packages/utils/src/process/interactive-process.ts
|
|
@@ -5962,22 +5963,9 @@ var terminateAndReap = ({ child, termination }) => Effect11.gen(function* () {
|
|
|
5962
5963
|
yield* Deferred3.await(termination).pipe(Effect11.ignore, Effect11.timeout(Duration2.seconds(2)), Effect11.ignore);
|
|
5963
5964
|
});
|
|
5964
5965
|
var runInteractiveProcess = (input) => Effect11.acquireUseRelease(acquireInteractiveProcess(input), awaitWithSignalForwarding, terminateAndReap);
|
|
5965
|
-
// ../../packages/client-common/src/harness-connections/hosted-setup.ts
|
|
5966
|
-
import { Schema as Schema52 } from "effect";
|
|
5967
|
-
var HOSTED_SETUP_PROTOCOL_VERSION = 1;
|
|
5968
|
-
var HOSTED_SETUP_MAX_RESULT_BYTES = 16 * 1024;
|
|
5969
|
-
var HostedSetupCapability = Schema52.Struct({
|
|
5970
|
-
protocolVersion: Schema52.Literal(HOSTED_SETUP_PROTOCOL_VERSION)
|
|
5971
|
-
});
|
|
5972
|
-
var version = Schema52.Literal(HOSTED_SETUP_PROTOCOL_VERSION);
|
|
5973
|
-
var HostedSetupResult = Schema52.Union(Schema52.TaggedStruct("Completed", { protocolVersion: version, modelId: ModelIdSchema }), Schema52.TaggedStruct("Cancelled", { protocolVersion: version }), Schema52.TaggedStruct("Failed", {
|
|
5974
|
-
protocolVersion: version,
|
|
5975
|
-
message: Schema52.String.pipe(Schema52.filter((message) => new TextEncoder().encode(message).length <= 4096))
|
|
5976
|
-
}));
|
|
5977
|
-
|
|
5978
5966
|
// extensions/setup.ts
|
|
5979
|
-
class PiSetupFailed extends
|
|
5980
|
-
message:
|
|
5967
|
+
class PiSetupFailed extends Schema52.TaggedError()("PiSetupFailed", {
|
|
5968
|
+
message: Schema52.String
|
|
5981
5969
|
}) {
|
|
5982
5970
|
}
|
|
5983
5971
|
var failure = (message) => new PiSetupFailed({ message });
|
|
@@ -5986,17 +5974,16 @@ var prepareMagnitudeCli = (cwd, setMessage = () => Effect12.void) => Effect12.ge
|
|
|
5986
5974
|
const override = process.env.MAGNITUDE_CLI?.trim();
|
|
5987
5975
|
const executable = override || "magnitude";
|
|
5988
5976
|
const probe = Effect12.scoped(Effect12.gen(function* () {
|
|
5989
|
-
const child = yield* Command2.make(executable, "
|
|
5990
|
-
const [code,
|
|
5977
|
+
const child = yield* Command2.make(executable, "--version").pipe(Command2.start);
|
|
5978
|
+
const [code, , stderr] = yield* Effect12.all([
|
|
5991
5979
|
child.exitCode,
|
|
5992
|
-
|
|
5980
|
+
Stream7.runDrain(child.stdout),
|
|
5993
5981
|
child.stderr.pipe(Stream7.decodeText(), Stream7.runFold("", (text2, part) => (text2 + part).slice(-4096)))
|
|
5994
5982
|
], { concurrency: "unbounded" });
|
|
5995
|
-
if (code !== 0
|
|
5996
|
-
return yield* failure(`Magnitude
|
|
5997
|
-
return output;
|
|
5983
|
+
if (code !== 0)
|
|
5984
|
+
return yield* failure(`Magnitude could not run at ${executable} (exit ${code}). ${stripVTControlCharacters(stderr).trim().slice(-600)}${override ? " Check MAGNITUDE_CLI." : ""}`);
|
|
5998
5985
|
}));
|
|
5999
|
-
|
|
5986
|
+
yield* probe.pipe(Effect12.catchIf((error) => !override && error._tag === "SystemError" && error.reason === "NotFound", (error) => Effect12.gen(function* () {
|
|
6000
5987
|
for (const directory of (process.env.PATH ?? "").split(delimiter)) {
|
|
6001
5988
|
if (yield* fs.exists(join(directory || cwd, executable)))
|
|
6002
5989
|
return yield* error;
|
|
@@ -6014,7 +6001,6 @@ var prepareMagnitudeCli = (cwd, setMessage = () => Effect12.void) => Effect12.ge
|
|
|
6014
6001
|
}));
|
|
6015
6002
|
return yield* probe;
|
|
6016
6003
|
})), Effect12.timeout("10 minutes"), Effect12.mapError((error) => error instanceof PiSetupFailed ? error : failure(`Could not prepare Magnitude: ${String(error)}. Run /magnitude-setup to retry${override ? ", or check MAGNITUDE_CLI" : ""}.`)));
|
|
6017
|
-
yield* Schema53.decodeUnknown(Schema53.parseJson(HostedSetupCapability))(capability).pipe(Effect12.mapError(() => failure(`The Magnitude CLI at ${executable} does not support hosted setup. Update @magnitudedev/cli${override ? ", or check MAGNITUDE_CLI" : ""}.`)));
|
|
6018
6004
|
return executable;
|
|
6019
6005
|
});
|
|
6020
6006
|
var withPiPreparation = (ctx, work) => Effect12.acquireUseRelease(Effect12.async((resume, signal) => {
|
|
@@ -6060,39 +6046,38 @@ var withPiTerminal = (ctx, work) => Effect12.acquireUseRelease(Effect12.async((r
|
|
|
6060
6046
|
finish();
|
|
6061
6047
|
}
|
|
6062
6048
|
}).pipe(Effect12.zipRight(Effect12.promise(closed))));
|
|
6063
|
-
var validateSetupTermination = (
|
|
6064
|
-
if (termination._tag
|
|
6065
|
-
return Effect12.fail(failure(
|
|
6049
|
+
var validateSetupTermination = (termination) => {
|
|
6050
|
+
if (termination._tag === "Signaled") {
|
|
6051
|
+
return termination.signal === "SIGINT" ? Effect12.succeed(false) : Effect12.fail(failure(`Magnitude setup stopped unexpectedly (${termination.signal}). Run /magnitude-setup to retry.`));
|
|
6066
6052
|
}
|
|
6067
|
-
|
|
6053
|
+
if (termination.code === 130)
|
|
6054
|
+
return Effect12.succeed(false);
|
|
6055
|
+
return termination.code === 0 ? Effect12.succeed(true) : Effect12.fail(failure(`Magnitude setup failed (exit ${termination.code}). Check the terminal error above; if setup --host pi is unsupported, update @magnitudedev/cli. Run /magnitude-setup to retry.`));
|
|
6068
6056
|
};
|
|
6057
|
+
var readSetupModel = Effect12.gen(function* () {
|
|
6058
|
+
const client = yield* MagnitudeClient;
|
|
6059
|
+
const { slots } = yield* client.models.getSlots({}).pipe(Effect12.mapError((error) => failure(`Magnitude setup completed, but the selected model could not be read: ${error._tag === "RpcClientError" ? error.message : formatConnectionError(error)}. Run /reload and select it with /model.`)));
|
|
6060
|
+
if (slots.primary._tag !== "ConfiguredLocal")
|
|
6061
|
+
return yield* failure("Magnitude setup completed, but no local primary model is configured. Run /reload and select a Magnitude model with /model.");
|
|
6062
|
+
return slots.primary.selection.providerModelId;
|
|
6063
|
+
});
|
|
6069
6064
|
var PiSetup = Context7.GenericTag("pi/PiSetup");
|
|
6070
6065
|
var PiSetupLive = Layer6.effect(PiSetup, Effect12.gen(function* () {
|
|
6071
6066
|
const fs = yield* FileSystem.FileSystem;
|
|
6072
6067
|
const executor = yield* CommandExecutor3.CommandExecutor;
|
|
6073
6068
|
return {
|
|
6074
6069
|
run: (ctx) => Effect12.scoped(Effect12.gen(function* () {
|
|
6075
|
-
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "magnitude-pi-setup-" });
|
|
6076
|
-
const resultPath = `${directory}/result.json`;
|
|
6077
6070
|
const executable = yield* withPiPreparation(ctx, (setMessage) => prepareMagnitudeCli(ctx.cwd, setMessage));
|
|
6078
6071
|
const termination = yield* withPiTerminal(ctx, runInteractiveProcess({
|
|
6079
6072
|
executable,
|
|
6080
|
-
args: ["setup", "--host", "pi"
|
|
6073
|
+
args: ["setup", "--host", "pi"],
|
|
6081
6074
|
environment: process.env,
|
|
6082
6075
|
workingDirectory: ctx.cwd
|
|
6083
6076
|
}));
|
|
6084
|
-
if (
|
|
6085
|
-
return {
|
|
6086
|
-
}
|
|
6087
|
-
|
|
6088
|
-
return yield* failure(`Magnitude setup stopped unexpectedly (${termination.signal}). Run /magnitude-setup to retry.`);
|
|
6089
|
-
}
|
|
6090
|
-
const stat = yield* fs.stat(resultPath).pipe(Effect12.mapError(() => failure("Magnitude setup exited without a completion result. Run /magnitude-setup to retry.")));
|
|
6091
|
-
if (stat.type !== "File" || stat.size > BigInt(HOSTED_SETUP_MAX_RESULT_BYTES)) {
|
|
6092
|
-
return yield* failure("Magnitude setup returned an invalid or oversized result");
|
|
6093
|
-
}
|
|
6094
|
-
const result = yield* fs.readFileString(resultPath).pipe(Effect12.flatMap(Schema53.decodeUnknown(Schema53.parseJson(HostedSetupResult))), Effect12.mapError(() => failure("Magnitude setup did not return a valid completion result. Run /magnitude-setup to retry.")));
|
|
6095
|
-
return yield* validateSetupTermination(result, termination);
|
|
6077
|
+
if (!(yield* validateSetupTermination(termination)))
|
|
6078
|
+
return { _tag: "Cancelled" };
|
|
6079
|
+
const modelId = yield* readSetupModel.pipe(Effect12.provide(MagnitudeClient.layer({ autoStart: false }).pipe(Layer6.provide(FetchHttpClient2.layer))));
|
|
6080
|
+
return { _tag: "Completed", modelId };
|
|
6096
6081
|
})).pipe(Effect12.provideService(CommandExecutor3.CommandExecutor, executor), Effect12.provideService(FileSystem.FileSystem, fs), Effect12.mapError((error) => error instanceof PiSetupFailed ? error : failure(`Magnitude setup could not finish: ${String(error)}`)))
|
|
6097
6082
|
};
|
|
6098
6083
|
}));
|
|
@@ -6198,15 +6183,15 @@ function registerMagnitudeOnboarding(pi) {
|
|
|
6198
6183
|
}
|
|
6199
6184
|
|
|
6200
6185
|
// extensions/observing-fetch.ts
|
|
6201
|
-
import { Effect as Effect14, Either as Either3, Schema as
|
|
6186
|
+
import { Effect as Effect14, Either as Either3, Schema as Schema54 } from "effect";
|
|
6202
6187
|
|
|
6203
6188
|
// extensions/protocol.ts
|
|
6204
|
-
import { Either as Either2, Schema as
|
|
6205
|
-
var ProgressChunkSchema =
|
|
6206
|
-
var TimingsChunkSchema =
|
|
6189
|
+
import { Either as Either2, Schema as Schema53 } from "effect";
|
|
6190
|
+
var ProgressChunkSchema = Schema53.Struct({ progress: MagnitudeProgressSchema });
|
|
6191
|
+
var TimingsChunkSchema = Schema53.Struct({ timings: MagnitudeTimingsSchema });
|
|
6207
6192
|
var decodeMagnitudeObservation = (value) => {
|
|
6208
|
-
const progress =
|
|
6209
|
-
const timings =
|
|
6193
|
+
const progress = Schema53.decodeUnknownEither(ProgressChunkSchema)(value);
|
|
6194
|
+
const timings = Schema53.decodeUnknownEither(TimingsChunkSchema)(value);
|
|
6210
6195
|
if (Either2.isLeft(progress) && Either2.isLeft(timings))
|
|
6211
6196
|
return;
|
|
6212
6197
|
return {
|
|
@@ -6217,7 +6202,7 @@ var decodeMagnitudeObservation = (value) => {
|
|
|
6217
6202
|
|
|
6218
6203
|
// extensions/observing-fetch.ts
|
|
6219
6204
|
var MAGNITUDE_PROGRESS_HEADER = "Magnitude-Include-Progress";
|
|
6220
|
-
var JsonDocumentSchema =
|
|
6205
|
+
var JsonDocumentSchema = Schema54.parseJson(Schema54.Unknown);
|
|
6221
6206
|
|
|
6222
6207
|
class SseDataParser {
|
|
6223
6208
|
#buffer = "";
|
|
@@ -6264,7 +6249,7 @@ class SseDataParser {
|
|
|
6264
6249
|
this.#dataLines = [];
|
|
6265
6250
|
if (data === "[DONE]")
|
|
6266
6251
|
return;
|
|
6267
|
-
const decoded =
|
|
6252
|
+
const decoded = Schema54.decodeUnknownEither(JsonDocumentSchema)(data);
|
|
6268
6253
|
if (Either3.isRight(decoded))
|
|
6269
6254
|
observe(decoded.right);
|
|
6270
6255
|
}
|
|
@@ -6335,9 +6320,9 @@ var makeObservingFetch = (fetchImplementation, begin, scope) => {
|
|
|
6335
6320
|
|
|
6336
6321
|
// extensions/progress.ts
|
|
6337
6322
|
import { Text } from "@earendil-works/pi-tui";
|
|
6338
|
-
import { Data as Data3, Effect as Effect15, Fiber as Fiber3, Option as Option18, Queue, Schema as
|
|
6323
|
+
import { Data as Data3, Effect as Effect15, Fiber as Fiber3, Option as Option18, Queue, Schema as Schema55 } from "effect";
|
|
6339
6324
|
var MAGNITUDE_SUMMARY_WIDGET_KEY = "magnitude-inference-summary";
|
|
6340
|
-
var RequestId =
|
|
6325
|
+
var RequestId = Schema55.Number.pipe(Schema55.int(), Schema55.brand("ProgressRequestId"));
|
|
6341
6326
|
|
|
6342
6327
|
class Observing extends Data3.TaggedClass("Observing") {
|
|
6343
6328
|
}
|