@magnitudedev/pi-extension 0.0.1-alpha.2 → 0.0.1-alpha.4

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 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 and must support hosted setup; an incompatible version reports an
21
- update requirement rather than being silently replaced.
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
@@ -43,7 +44,7 @@ does all connection configuration and can be run safely after a standalone packa
43
44
 
44
45
  The extension bundles Magnitude's private SDK. Model status, loading, and stopping use the existing
45
46
  RPC endpoint at port 10100. When necessary the SDK runs `magnitude service start`; it does not use
46
- CLI output as a model API. If `/load-model` or `/stop-model` encounters a protocol mismatch, the
47
+ CLI output as a model API. If `/stop-model` encounters a protocol mismatch, the
47
48
  extension runs `magnitude connections sync pi` once to install the exact plugin version selected by
48
49
  the installed CLI, then reloads Pi. Retry your model command after reload; it is never replayed
49
50
  automatically. Failed sync reports the error without reloading or looping. Manually owned incompatible
@@ -56,7 +57,6 @@ latency, and token-weighted generation throughput. Pi extensions execute with yo
56
57
  Commands:
57
58
 
58
59
  - `/magnitude-setup` — open Magnitude's graphical model setup inside Pi
59
- - `/load-model [model-id]` — load an installed model
60
60
  - `/stop-model` — stop the active model
61
61
 
62
62
  Installed Magnitude models appear in Pi's built-in `/model` selector. To discover, compare, install,
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@magnitudedev/pi-extension",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "rpcVersion": 1,
5
- "contentFingerprint": "5661646da7080511725cdef888b7ce04148c99b56fbe6454619754ebc5235718",
5
+ "contentFingerprint": "d8a654678e1244761397d9bb6f30765c9d2a9c7813fdea7b024f4076dab494ef",
6
6
  "files": {
7
- "README.md": "0334364928717efd1b146486d6dc2d9ff0f28b77ff28b162d04351738170b581",
8
- "dist/magnitude.js": "915f1d6bb080180a774b1bd009b3d7bc6c5cbab94fd7ab067dd3345d638538ad",
7
+ "README.md": "26fa7e5b56c9b171946b7efec036703e258ab51607d1e20f00c45d6e96133a29",
8
+ "dist/magnitude.js": "b21c625dd7e2c0f00c6992845dad09cd753b4e85cf5b258d334ba4a4c6d065c3",
9
9
  "dist/skills/magnitude/SKILL.md": "37de67f0c7b831415f6298c8785b7ae97d5cfe454dc778651d96114840d2ace2"
10
10
  }
11
11
  }
package/dist/magnitude.js CHANGED
@@ -17,7 +17,7 @@ var __export = (target, all) => {
17
17
  import { openAICompletionsApi } from "@earendil-works/pi-ai/compat";
18
18
 
19
19
  // extensions/commands.ts
20
- import { Context as Context6, Effect as Effect10, Exit as Exit2, Fiber, Layer as Layer5, ManagedRuntime, Match as Match2, Option as Option16, Ref, Schema as Schema50, Scope as Scope3 } from "effect";
20
+ import { Context as Context6, Effect as Effect10, Exit as Exit2, Fiber, Layer as Layer5, ManagedRuntime, Ref, Schema as Schema50, Scope as Scope3 } from "effect";
21
21
  import { FetchHttpClient } from "@effect/platform";
22
22
  import * as NodeCommandExecutor from "@effect/platform-node/NodeCommandExecutor";
23
23
  import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
@@ -1366,10 +1366,6 @@ var LowMemoryModelInstanceFailureSchema = Schema20.TaggedStruct("LowMemory", {
1366
1366
  });
1367
1367
  var ModelInstanceFailureSchema = Schema20.Union(ModelFailureSchema, LowMemoryModelInstanceFailureSchema);
1368
1368
  var ModelVariantLabelSchema = NonEmptyString.pipe(Schema20.brand("ModelVariantLabel"));
1369
- var formatModelDisplayName = (displayName, variantLabel) => Option5.match(variantLabel, {
1370
- onNone: () => displayName,
1371
- onSome: (label) => `${displayName} (${label})`
1372
- });
1373
1369
  var ModelLoadPlanSchema = Schema20.Struct({
1374
1370
  contextWindowTokens: PositiveSafeInteger2,
1375
1371
  parallelSequences: PositiveSafeInteger2,
@@ -1552,7 +1548,6 @@ var LocalModelAcquisitionStateSchema = Schema20.Union(Schema20.TaggedStruct("Not
1552
1548
  ...InstalledModelFields,
1553
1549
  failure: ModelFailureSchema
1554
1550
  }));
1555
- var installedAcquisition = (state) => state._tag === "Installed" || state._tag === "UpdateAvailable" || state._tag === "Updating" || state._tag === "UpdateFailed" || state._tag === "Removing" || state._tag === "RemoveFailed" ? state : undefined;
1556
1551
  var ProviderModelDisabledReasonSchema2 = Schema20.Literal("insufficient_resources", "provider_unavailable", "model_unavailable", "installation_unavailable", "incompatible_runtime", "invalid_configuration");
1557
1552
  var ProviderModelCatalogEntrySchema = Schema20.Struct({
1558
1553
  providerId: ProviderIdSchema,
@@ -2082,7 +2077,6 @@ var ChangeSchema = Schema25.Struct({
2082
2077
  import { Option as Option6 } from "effect";
2083
2078
  // ../../packages/acn-protocol/src/schemas/local-model-projection.ts
2084
2079
  import { Option as Option7 } from "effect";
2085
- var localModelIsInstalled = (model) => model._tag === "Discovered" ? true : installedAcquisition(model.acquisitionState) !== undefined;
2086
2080
  // ../../packages/acn-protocol/src/schemas/inference-projection.ts
2087
2081
  import { Data, Effect, Match, Option as Option8 } from "effect";
2088
2082
  class InferenceHardwareProjectionError extends Data.TaggedError("InferenceHardwareProjectionError") {
@@ -5714,52 +5708,10 @@ var commandFailure = (error) => Schema50.is(ProtocolMismatch)(error) ? error : n
5714
5708
  var ModelCommands = Context6.GenericTag("pi/ModelCommands");
5715
5709
  var commandsLayer = Layer5.effect(ModelCommands, Effect10.gen(function* () {
5716
5710
  const client = yield* MagnitudeClient;
5717
- const [cached, invalidate] = yield* Effect10.cachedInvalidateWithTTL(client.models.getCatalog({}).pipe(Effect10.mapError(commandFailure)), "30 seconds");
5718
5711
  return {
5719
- status: (fresh) => Effect10.gen(function* () {
5720
- if (fresh)
5721
- yield* invalidate;
5722
- const result = yield* cached.pipe(Effect10.tapError(() => invalidate));
5723
- if (result._tag === "Initializing")
5724
- yield* invalidate;
5725
- return result;
5726
- }),
5727
- load: (input) => Schema50.decodeUnknown(ModelIdSchema)(input).pipe(Effect10.flatMap((modelId) => client.models.load({ modelId }).pipe(Effect10.as(modelId))), Effect10.tap(() => invalidate), Effect10.mapError(commandFailure)),
5728
- stop: client.models.stop({}).pipe(Effect10.tap(() => invalidate), Effect10.asVoid, Effect10.mapError(commandFailure))
5712
+ stop: client.models.stop({}).pipe(Effect10.asVoid, Effect10.mapError(commandFailure))
5729
5713
  };
5730
5714
  }));
5731
- var displayName = (model2) => formatModelDisplayName(model2.presentation.displayName, Option16.some(model2.presentation.variantLabel));
5732
- var residencyLabel = (state) => Match2.value(state).pipe(Match2.tagsExhaustive({
5733
- Unloaded: () => "unloaded",
5734
- Requested: () => "loading",
5735
- Loading: () => "loading",
5736
- Ready: () => "ready",
5737
- Stopping: () => "stopping",
5738
- Failed: () => "failed"
5739
- }));
5740
- var stateLabel = (model2) => Match2.value(model2).pipe(Match2.tagsExhaustive({
5741
- Discovered: ({ state }) => Match2.value(state).pipe(Match2.tagsExhaustive({
5742
- Ready: ({ residencyState }) => residencyLabel(residencyState),
5743
- Unavailable: () => "unavailable"
5744
- })),
5745
- Catalog: ({ acquisitionState }) => Match2.value(acquisitionState).pipe(Match2.tagsExhaustive({
5746
- NotInstalled: () => "not installed",
5747
- Installing: () => "installing",
5748
- InstallFailed: () => "installation failed",
5749
- Installed: ({ residencyState }) => residencyLabel(residencyState),
5750
- UpdateAvailable: ({ residencyState }) => residencyLabel(residencyState),
5751
- Updating: ({ residencyState }) => residencyLabel(residencyState),
5752
- UpdateFailed: ({ residencyState }) => residencyLabel(residencyState),
5753
- Removing: () => "removing",
5754
- RemoveFailed: () => "removal failed"
5755
- }))
5756
- }));
5757
- var loadable = (catalog) => catalog._tag === "Initializing" ? [] : catalog.models.flatMap((entry) => {
5758
- if (entry._tag !== "Local")
5759
- return [];
5760
- const model2 = entry.product;
5761
- return localModelIsInstalled(model2) && (model2._tag === "Discovered" ? model2.state._tag === "Ready" : model2.acquisitionState._tag !== "Removing" && model2.acquisitionState._tag !== "RemoveFailed") ? [model2] : [];
5762
- }).sort((a, b) => displayName(a).localeCompare(displayName(b)) || a.modelId.localeCompare(b.modelId));
5763
5715
  var magnitudeExecutable = () => process.env.MAGNITUDE_CLI?.trim() || "magnitude";
5764
5716
  var clientLayer2 = () => MagnitudeClient.layer().pipe(Layer5.provide([
5765
5717
  FetchHttpClient.layer,
@@ -5794,39 +5746,6 @@ var registerMagnitudeCommands = (pi, sdk = clientLayer2()) => {
5794
5746
  if (reload)
5795
5747
  await ctx.reload();
5796
5748
  };
5797
- pi.registerCommand("load-model", {
5798
- description: "Load a Magnitude model",
5799
- getArgumentCompletions: (prefix) => run(Effect10.gen(function* () {
5800
- const commands = yield* ModelCommands;
5801
- const status = yield* commands.status(false);
5802
- return loadable(status).filter((model2) => model2.modelId.toLowerCase().includes(prefix.trim().toLowerCase())).map((model2) => ({ value: model2.modelId, label: displayName(model2), description: stateLabel(model2) }));
5803
- }).pipe(Effect10.catchAll(() => Effect10.succeed(null)))),
5804
- handler: (args, ctx) => invoke(ctx, Effect10.gen(function* () {
5805
- const commands = yield* ModelCommands;
5806
- let modelId = args.trim();
5807
- if (!modelId) {
5808
- const status = yield* commands.status(true);
5809
- if (status._tag === "Initializing") {
5810
- yield* Effect10.sync(() => ctx.ui.notify("Magnitude is discovering local models. Try again shortly.", "info"));
5811
- return;
5812
- }
5813
- const eligible = loadable(status);
5814
- if (!eligible.length) {
5815
- yield* Effect10.sync(() => ctx.ui.notify("No installed Magnitude models are available.", "info"));
5816
- return;
5817
- }
5818
- const labels = eligible.map((model2) => `${displayName(model2)} · ${stateLabel(model2)} · ${model2.modelId}`);
5819
- const selected = yield* Effect10.promise(() => ctx.ui.select("Load Magnitude model", labels));
5820
- if (selected === undefined)
5821
- return;
5822
- modelId = eligible[labels.indexOf(selected)]?.modelId ?? "";
5823
- }
5824
- if (!modelId)
5825
- return;
5826
- const loaded = yield* commands.load(modelId);
5827
- yield* Effect10.sync(() => ctx.ui.notify(`Loaded ${loaded}.`, "info"));
5828
- }))
5829
- });
5830
5749
  pi.registerCommand("stop-model", {
5831
5750
  description: "Stop the active Magnitude model",
5832
5751
  handler: (_args, ctx) => invoke(ctx, Effect10.gen(function* () {
@@ -5853,14 +5772,15 @@ import * as Command2 from "@effect/platform/Command";
5853
5772
  import * as CommandExecutor3 from "@effect/platform/CommandExecutor";
5854
5773
  import * as FileSystem from "@effect/platform/FileSystem";
5855
5774
  import * as NodeContext from "@effect/platform-node/NodeContext";
5775
+ import { FetchHttpClient as FetchHttpClient2 } from "@effect/platform";
5856
5776
  import { delimiter, join } from "node:path";
5857
5777
  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 Schema53, Scope as Scope4, Stream as Stream7 } from "effect";
5778
+ 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
5779
  import { CancellableLoader } from "@earendil-works/pi-tui";
5860
5780
 
5861
5781
  // ../../packages/utils/src/process/interactive-process.ts
5862
5782
  import { spawn } from "node:child_process";
5863
- import { Deferred as Deferred3, Duration as Duration2, Effect as Effect11, Option as Option17, Schema as Schema51 } from "effect";
5783
+ import { Deferred as Deferred3, Duration as Duration2, Effect as Effect11, Option as Option16, Schema as Schema51 } from "effect";
5864
5784
 
5865
5785
  class InteractiveProcessFailed extends Schema51.TaggedError()("InteractiveProcessFailed", {
5866
5786
  operation: Schema51.Literal("spawn", "run"),
@@ -5952,7 +5872,7 @@ var terminateAndReap = ({ child, termination }) => Effect11.gen(function* () {
5952
5872
  } catch {}
5953
5873
  });
5954
5874
  const graceful = yield* Deferred3.await(termination).pipe(Effect11.ignore, Effect11.timeoutOption(Duration2.seconds(2)));
5955
- if (Option17.isSome(graceful))
5875
+ if (Option16.isSome(graceful))
5956
5876
  return;
5957
5877
  yield* Effect11.sync(() => {
5958
5878
  try {
@@ -5962,22 +5882,9 @@ var terminateAndReap = ({ child, termination }) => Effect11.gen(function* () {
5962
5882
  yield* Deferred3.await(termination).pipe(Effect11.ignore, Effect11.timeout(Duration2.seconds(2)), Effect11.ignore);
5963
5883
  });
5964
5884
  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
5885
  // extensions/setup.ts
5979
- class PiSetupFailed extends Schema53.TaggedError()("PiSetupFailed", {
5980
- message: Schema53.String
5886
+ class PiSetupFailed extends Schema52.TaggedError()("PiSetupFailed", {
5887
+ message: Schema52.String
5981
5888
  }) {
5982
5889
  }
5983
5890
  var failure = (message) => new PiSetupFailed({ message });
@@ -5986,17 +5893,16 @@ var prepareMagnitudeCli = (cwd, setMessage = () => Effect12.void) => Effect12.ge
5986
5893
  const override = process.env.MAGNITUDE_CLI?.trim();
5987
5894
  const executable = override || "magnitude";
5988
5895
  const probe = Effect12.scoped(Effect12.gen(function* () {
5989
- const child = yield* Command2.make(executable, "setup", "--host-protocol").pipe(Command2.start);
5990
- const [code, output, stderr] = yield* Effect12.all([
5896
+ const child = yield* Command2.make(executable, "--version").pipe(Command2.start);
5897
+ const [code, , stderr] = yield* Effect12.all([
5991
5898
  child.exitCode,
5992
- child.stdout.pipe(Stream7.decodeText(), Stream7.runFold("", (text2, part) => (text2 + part).slice(0, 4097))),
5899
+ Stream7.runDrain(child.stdout),
5993
5900
  child.stderr.pipe(Stream7.decodeText(), Stream7.runFold("", (text2, part) => (text2 + part).slice(-4096)))
5994
5901
  ], { concurrency: "unbounded" });
5995
- if (code !== 0 || output.length > 4096)
5996
- return yield* failure(`Magnitude's setup capability check failed at ${executable} (exit ${code}). ${stripVTControlCharacters(stderr).trim().slice(-600)}${override ? " Check MAGNITUDE_CLI." : ""}`);
5997
- return output;
5902
+ if (code !== 0)
5903
+ return yield* failure(`Magnitude could not run at ${executable} (exit ${code}). ${stripVTControlCharacters(stderr).trim().slice(-600)}${override ? " Check MAGNITUDE_CLI." : ""}`);
5998
5904
  }));
5999
- const capability = yield* probe.pipe(Effect12.catchIf((error) => !override && error._tag === "SystemError" && error.reason === "NotFound", (error) => Effect12.gen(function* () {
5905
+ yield* probe.pipe(Effect12.catchIf((error) => !override && error._tag === "SystemError" && error.reason === "NotFound", (error) => Effect12.gen(function* () {
6000
5906
  for (const directory of (process.env.PATH ?? "").split(delimiter)) {
6001
5907
  if (yield* fs.exists(join(directory || cwd, executable)))
6002
5908
  return yield* error;
@@ -6014,7 +5920,6 @@ var prepareMagnitudeCli = (cwd, setMessage = () => Effect12.void) => Effect12.ge
6014
5920
  }));
6015
5921
  return yield* probe;
6016
5922
  })), 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
5923
  return executable;
6019
5924
  });
6020
5925
  var withPiPreparation = (ctx, work) => Effect12.acquireUseRelease(Effect12.async((resume, signal) => {
@@ -6060,39 +5965,38 @@ var withPiTerminal = (ctx, work) => Effect12.acquireUseRelease(Effect12.async((r
6060
5965
  finish();
6061
5966
  }
6062
5967
  }).pipe(Effect12.zipRight(Effect12.promise(closed))));
6063
- var validateSetupTermination = (result, termination) => {
6064
- if (termination._tag !== "Exited" || termination.code === 0 !== (result._tag !== "Failed")) {
6065
- return Effect12.fail(failure("Magnitude setup exited without a consistent completion result. Run /magnitude-setup to retry."));
5968
+ var validateSetupTermination = (termination) => {
5969
+ if (termination._tag === "Signaled") {
5970
+ return termination.signal === "SIGINT" ? Effect12.succeed(false) : Effect12.fail(failure(`Magnitude setup stopped unexpectedly (${termination.signal}). Run /magnitude-setup to retry.`));
6066
5971
  }
6067
- return result._tag === "Failed" ? Effect12.fail(failure(result.message)) : Effect12.succeed(result);
5972
+ if (termination.code === 130)
5973
+ return Effect12.succeed(false);
5974
+ 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
5975
  };
5976
+ var readSetupModel = Effect12.gen(function* () {
5977
+ const client = yield* MagnitudeClient;
5978
+ 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.`)));
5979
+ if (slots.primary._tag !== "ConfiguredLocal")
5980
+ return yield* failure("Magnitude setup completed, but no local primary model is configured. Run /reload and select a Magnitude model with /model.");
5981
+ return slots.primary.selection.providerModelId;
5982
+ });
6069
5983
  var PiSetup = Context7.GenericTag("pi/PiSetup");
6070
5984
  var PiSetupLive = Layer6.effect(PiSetup, Effect12.gen(function* () {
6071
5985
  const fs = yield* FileSystem.FileSystem;
6072
5986
  const executor = yield* CommandExecutor3.CommandExecutor;
6073
5987
  return {
6074
5988
  run: (ctx) => Effect12.scoped(Effect12.gen(function* () {
6075
- const directory = yield* fs.makeTempDirectoryScoped({ prefix: "magnitude-pi-setup-" });
6076
- const resultPath = `${directory}/result.json`;
6077
5989
  const executable = yield* withPiPreparation(ctx, (setMessage) => prepareMagnitudeCli(ctx.cwd, setMessage));
6078
5990
  const termination = yield* withPiTerminal(ctx, runInteractiveProcess({
6079
5991
  executable,
6080
- args: ["setup", "--host", "pi", "--result-file", resultPath],
5992
+ args: ["setup", "--host", "pi"],
6081
5993
  environment: process.env,
6082
5994
  workingDirectory: ctx.cwd
6083
5995
  }));
6084
- if (termination._tag === "Signaled" && termination.signal === "SIGINT") {
6085
- return { protocolVersion: HOSTED_SETUP_PROTOCOL_VERSION, _tag: "Cancelled" };
6086
- }
6087
- if (termination._tag === "Signaled") {
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);
5996
+ if (!(yield* validateSetupTermination(termination)))
5997
+ return { _tag: "Cancelled" };
5998
+ const modelId = yield* readSetupModel.pipe(Effect12.provide(MagnitudeClient.layer({ autoStart: false }).pipe(Layer6.provide(FetchHttpClient2.layer))));
5999
+ return { _tag: "Completed", modelId };
6096
6000
  })).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
6001
  };
6098
6002
  }));
@@ -6198,15 +6102,15 @@ function registerMagnitudeOnboarding(pi) {
6198
6102
  }
6199
6103
 
6200
6104
  // extensions/observing-fetch.ts
6201
- import { Effect as Effect14, Either as Either3, Schema as Schema55 } from "effect";
6105
+ import { Effect as Effect14, Either as Either3, Schema as Schema54 } from "effect";
6202
6106
 
6203
6107
  // extensions/protocol.ts
6204
- import { Either as Either2, Schema as Schema54 } from "effect";
6205
- var ProgressChunkSchema = Schema54.Struct({ progress: MagnitudeProgressSchema });
6206
- var TimingsChunkSchema = Schema54.Struct({ timings: MagnitudeTimingsSchema });
6108
+ import { Either as Either2, Schema as Schema53 } from "effect";
6109
+ var ProgressChunkSchema = Schema53.Struct({ progress: MagnitudeProgressSchema });
6110
+ var TimingsChunkSchema = Schema53.Struct({ timings: MagnitudeTimingsSchema });
6207
6111
  var decodeMagnitudeObservation = (value) => {
6208
- const progress = Schema54.decodeUnknownEither(ProgressChunkSchema)(value);
6209
- const timings = Schema54.decodeUnknownEither(TimingsChunkSchema)(value);
6112
+ const progress = Schema53.decodeUnknownEither(ProgressChunkSchema)(value);
6113
+ const timings = Schema53.decodeUnknownEither(TimingsChunkSchema)(value);
6210
6114
  if (Either2.isLeft(progress) && Either2.isLeft(timings))
6211
6115
  return;
6212
6116
  return {
@@ -6217,7 +6121,7 @@ var decodeMagnitudeObservation = (value) => {
6217
6121
 
6218
6122
  // extensions/observing-fetch.ts
6219
6123
  var MAGNITUDE_PROGRESS_HEADER = "Magnitude-Include-Progress";
6220
- var JsonDocumentSchema = Schema55.parseJson(Schema55.Unknown);
6124
+ var JsonDocumentSchema = Schema54.parseJson(Schema54.Unknown);
6221
6125
 
6222
6126
  class SseDataParser {
6223
6127
  #buffer = "";
@@ -6264,7 +6168,7 @@ class SseDataParser {
6264
6168
  this.#dataLines = [];
6265
6169
  if (data === "[DONE]")
6266
6170
  return;
6267
- const decoded = Schema55.decodeUnknownEither(JsonDocumentSchema)(data);
6171
+ const decoded = Schema54.decodeUnknownEither(JsonDocumentSchema)(data);
6268
6172
  if (Either3.isRight(decoded))
6269
6173
  observe(decoded.right);
6270
6174
  }
@@ -6335,9 +6239,9 @@ var makeObservingFetch = (fetchImplementation, begin, scope) => {
6335
6239
 
6336
6240
  // extensions/progress.ts
6337
6241
  import { Text } from "@earendil-works/pi-tui";
6338
- import { Data as Data3, Effect as Effect15, Fiber as Fiber3, Option as Option18, Queue, Schema as Schema56 } from "effect";
6242
+ import { Data as Data3, Effect as Effect15, Fiber as Fiber3, Option as Option17, Queue, Schema as Schema55 } from "effect";
6339
6243
  var MAGNITUDE_SUMMARY_WIDGET_KEY = "magnitude-inference-summary";
6340
- var RequestId = Schema56.Number.pipe(Schema56.int(), Schema56.brand("ProgressRequestId"));
6244
+ var RequestId = Schema55.Number.pipe(Schema55.int(), Schema55.brand("ProgressRequestId"));
6341
6245
 
6342
6246
  class Observing extends Data3.TaggedClass("Observing") {
6343
6247
  }
@@ -6409,14 +6313,14 @@ var makeProgressTracker = (ui, now = () => performance.now()) => Effect15.gen(fu
6409
6313
  const finalize = Effect15.gen(function* () {
6410
6314
  if (state._tag !== "Settled")
6411
6315
  return;
6412
- if ([...state.run.responses.values()].some(Option18.isNone))
6316
+ if ([...state.run.responses.values()].some(Option17.isNone))
6413
6317
  return;
6414
6318
  if ([...state.run.requests.values()].some((r) => r._tag === "Observing"))
6415
6319
  return;
6416
6320
  const settled = state;
6417
6321
  state = runMachine.transition(settled, "Idle", {});
6418
6322
  const timings = [...settled.run.completed.entries()].filter(([id]) => settled.run.accepted.has(id)).sort(([a], [b]) => a - b).map(([, value]) => value);
6419
- if ([...settled.run.responses.values()].some((outcome) => !Option18.getOrElse(outcome, () => false)) || timings.length === 0) {
6323
+ if ([...settled.run.responses.values()].some((outcome) => !Option17.getOrElse(outcome, () => false)) || timings.length === 0) {
6420
6324
  yield* clearSummary;
6421
6325
  return;
6422
6326
  }
@@ -6471,12 +6375,12 @@ var makeProgressTracker = (ui, now = () => performance.now()) => Effect15.gen(fu
6471
6375
  const run = state._tag === "Working" ? state.run : undefined;
6472
6376
  const responseId = ++nextResponseId;
6473
6377
  const requests = [];
6474
- run?.responses.set(responseId, Option18.none());
6378
+ run?.responses.set(responseId, Option17.none());
6475
6379
  const belongs = () => run !== undefined && (state._tag === "Working" || state._tag === "Settled") && state.run === run;
6476
6380
  const end = (successful) => Effect15.gen(function* () {
6477
- if (!belongs() || Option18.isSome(run.responses.get(responseId)))
6381
+ if (!belongs() || Option17.isSome(run.responses.get(responseId)))
6478
6382
  return;
6479
- run.responses.set(responseId, Option18.some(successful));
6383
+ run.responses.set(responseId, Option17.some(successful));
6480
6384
  const last = requests.at(-1);
6481
6385
  if (successful && last !== undefined)
6482
6386
  run.accepted.add(last);
@@ -6496,13 +6400,13 @@ var makeProgressTracker = (ui, now = () => performance.now()) => Effect15.gen(fu
6496
6400
  yield* finalize;
6497
6401
  });
6498
6402
  const begin = Effect15.gen(function* () {
6499
- if (!belongs() || Option18.isSome(run.responses.get(responseId)))
6403
+ if (!belongs() || Option17.isSome(run.responses.get(responseId)))
6500
6404
  return { observe: () => Effect15.void, finish: Effect15.void, fail: Effect15.void };
6501
6405
  const id = RequestId.make(++nextId);
6502
6406
  requests.push(id);
6503
6407
  latest = id;
6504
6408
  active = undefined;
6505
- run?.requests.set(id, new Observing({ timings: Option18.none() }));
6409
+ run?.requests.set(id, new Observing({ timings: Option17.none() }));
6506
6410
  yield* resetRow;
6507
6411
  const close = (failed) => Effect15.gen(function* () {
6508
6412
  if (!belongs())
@@ -6514,7 +6418,7 @@ var makeProgressTracker = (ui, now = () => performance.now()) => Effect15.gen(fu
6514
6418
  run.requests.set(id, requestMachine.transition(request, "Closed", {}));
6515
6419
  else {
6516
6420
  run.requests.set(id, requestMachine.transition(request, "Observed", {}));
6517
- if (Option18.isSome(request.timings))
6421
+ if (Option17.isSome(request.timings))
6518
6422
  run.completed.set(id, request.timings.value);
6519
6423
  }
6520
6424
  if (latest === id) {
@@ -6531,7 +6435,7 @@ var makeProgressTracker = (ui, now = () => performance.now()) => Effect15.gen(fu
6531
6435
  if (request._tag !== "Observing")
6532
6436
  return;
6533
6437
  if (observation.timings)
6534
- run.requests.set(id, requestMachine.hold(request, { timings: Option18.some(observation.timings) }));
6438
+ run.requests.set(id, requestMachine.hold(request, { timings: Option17.some(observation.timings) }));
6535
6439
  if (latest !== id || !observation.progress)
6536
6440
  return;
6537
6441
  const progress = observation.progress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magnitudedev/pi-extension",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.4",
4
4
  "description": "Magnitude model controls and inference progress for Pi",
5
5
  "type": "module",
6
6
  "license": "MIT",