@caplets/pi 0.7.0 → 0.7.1

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.
Files changed (3) hide show
  1. package/README.md +4 -8
  2. package/dist/index.js +22 -37
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -56,11 +56,9 @@ options are supplied:
56
56
  "packages": ["npm:@caplets/pi"],
57
57
  "caplets": {
58
58
  "mode": "remote",
59
- "server": {
60
- "url": "https://caplets.example.com/caplets",
61
- "user": "caplets"
62
- },
63
59
  "remote": {
60
+ "url": "https://caplets.example.com/caplets",
61
+ "user": "caplets",
64
62
  "pollIntervalMs": 5000
65
63
  },
66
64
  "statusWidget": true,
@@ -84,17 +82,15 @@ import { createCapletsPiExtension } from "@caplets/pi";
84
82
  export default createCapletsPiExtension({
85
83
  args: {
86
84
  mode: "remote",
87
- server: {
85
+ remote: {
88
86
  url: "https://caplets.example.com/caplets",
89
87
  user: "caplets",
90
- },
91
- remote: {
92
88
  pollIntervalMs: 5_000,
93
89
  },
94
90
  },
95
91
  });
96
92
  ```
97
93
 
98
- The explicit config shape is `{ mode, server: { url, user }, remote: { pollIntervalMs } }`.
94
+ The explicit config shape is `{ mode, remote: { url, user, pollIntervalMs } }`.
99
95
  Prefer environment variables for `CAPLETS_REMOTE_TOKEN` or `CAPLETS_REMOTE_PASSWORD` rather than storing passwords in
100
96
  settings files or source code.
package/dist/index.js CHANGED
@@ -3463,27 +3463,42 @@ function topLevelCapletsOptions(settings, writeWarning, path) {
3463
3463
  return parsed;
3464
3464
  }
3465
3465
  }
3466
- function parsePiNativeOptions(value, writeWarning, path = "settings.caplets") {
3466
+ function parsePiNativeOptions(value, _writeWarning, _path = "settings.caplets") {
3467
3467
  if (!value || typeof value !== "object" || Array.isArray(value)) return;
3468
+ const raw = value;
3468
3469
  const result = {};
3469
- const mode = value.mode;
3470
+ const mode = raw.mode;
3470
3471
  if (mode !== void 0) {
3471
3472
  if (mode !== "auto" && mode !== "local" && mode !== "remote" && mode !== "cloud") return;
3472
3473
  result.mode = mode;
3473
3474
  }
3474
- const statusWidget = value.statusWidget;
3475
+ const statusWidget = raw.statusWidget;
3475
3476
  if (statusWidget !== void 0) {
3476
3477
  if (typeof statusWidget !== "boolean") return void 0;
3477
3478
  result.statusWidget = statusWidget;
3478
3479
  }
3479
- const nerdFontIcons = value.nerdFontIcons;
3480
+ const nerdFontIcons = raw.nerdFontIcons;
3480
3481
  if (nerdFontIcons !== void 0) {
3481
3482
  if (typeof nerdFontIcons !== "boolean") return void 0;
3482
3483
  result.nerdFontIcons = nerdFontIcons;
3483
3484
  }
3484
3485
  const remote = objectProperty(value, "remote");
3486
+ if (raw.remote !== void 0 && !remote) return;
3485
3487
  if (remote) {
3486
3488
  const parsedRemote = {};
3489
+ for (const key of [
3490
+ "url",
3491
+ "user",
3492
+ "password",
3493
+ "token",
3494
+ "workspace"
3495
+ ]) {
3496
+ const field = remote[key];
3497
+ if (field !== void 0) {
3498
+ if (typeof field !== "string") return void 0;
3499
+ parsedRemote[key] = field;
3500
+ }
3501
+ }
3487
3502
  const pollIntervalMs = remote.pollIntervalMs;
3488
3503
  if (pollIntervalMs !== void 0) {
3489
3504
  if (typeof pollIntervalMs !== "number" || !Number.isFinite(pollIntervalMs)) return void 0;
@@ -3491,37 +3506,9 @@ function parsePiNativeOptions(value, writeWarning, path = "settings.caplets") {
3491
3506
  }
3492
3507
  result.remote = parsedRemote;
3493
3508
  }
3494
- const server = objectProperty(value, "server");
3495
- const parsedServer = parsePiServerOptions(server);
3496
- if (parsedServer === void 0 && server) return;
3497
- const legacyServer = parsePiServerOptions(remote);
3498
- if (legacyServer === void 0 && remote && hasLegacyRemoteServerFields(remote)) return;
3499
- if (legacyServer && !parsedServer) writeWarning?.(`[caplets/pi] ${path}.remote.url is deprecated; move remote.url/user/password to server.url/user/password.`);
3500
- if (legacyServer || parsedServer) result.server = {
3501
- ...legacyServer,
3502
- ...parsedServer
3503
- };
3509
+ if (raw.server !== void 0) return;
3504
3510
  return result;
3505
3511
  }
3506
- function parsePiServerOptions(value) {
3507
- if (!value) return;
3508
- const parsedServer = {};
3509
- for (const key of [
3510
- "url",
3511
- "user",
3512
- "password"
3513
- ]) {
3514
- const field = value[key];
3515
- if (field !== void 0) {
3516
- if (typeof field !== "string") return void 0;
3517
- parsedServer[key] = field;
3518
- }
3519
- }
3520
- return Object.keys(parsedServer).length > 0 ? parsedServer : void 0;
3521
- }
3522
- function hasLegacyRemoteServerFields(remote) {
3523
- return remote.url !== void 0 || remote.user !== void 0 || remote.password !== void 0;
3524
- }
3525
3512
  function capletsRemoteStatusText(status, nerdFontIcons) {
3526
3513
  if (nerdFontIcons) return status === "connected" ? "󰖟 caplets ✓" : "󰖟 caplets ×";
3527
3514
  return status === "connected" ? "caplets ✓" : "caplets ×";
@@ -3529,14 +3516,13 @@ function capletsRemoteStatusText(status, nerdFontIcons) {
3529
3516
  function nativeServiceOptions(options) {
3530
3517
  return {
3531
3518
  ...options.mode ? { mode: options.mode } : {},
3532
- ...options.server ? { server: options.server } : {},
3533
3519
  ...options.remote ? { remote: options.remote } : {}
3534
3520
  };
3535
3521
  }
3536
3522
  function shouldShowStatusWidget(options, statusWidget) {
3537
3523
  if (statusWidget === false) return false;
3538
3524
  if (options.mode === "local") return false;
3539
- return options.mode === "remote" || options.mode === "cloud" || !!options.server?.url || process.env.CAPLETS_SERVER_URL !== void 0;
3525
+ return options.mode === "remote" || options.mode === "cloud" || !!options.remote?.url || process.env.CAPLETS_REMOTE_URL !== void 0;
3540
3526
  }
3541
3527
  async function readFileUtf8(path) {
3542
3528
  return readFile(path, "utf8");
@@ -3724,8 +3710,7 @@ function codeModeAgentContent(result) {
3724
3710
  if (diagnostics.length > 0) compact.diagnostics = diagnostics;
3725
3711
  const logSummary = codeModeLogSummary(logs);
3726
3712
  if (logSummary) compact.logs = logSummary;
3727
- const durationMs = meta?.durationMs;
3728
- if (typeof durationMs === "number") compact.durationMs = durationMs;
3713
+ if (meta) compact.meta = meta;
3729
3714
  return [{
3730
3715
  type: "text",
3731
3716
  text: JSON.stringify(compact) ?? "null"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caplets/pi",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Native Pi extension for Caplets.",
5
5
  "homepage": "https://github.com/spiritledsoftware/caplets#readme",
6
6
  "bugs": {
@@ -26,7 +26,7 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@caplets/core": "0.23.0"
29
+ "@caplets/core": "0.24.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@jitl/quickjs-wasmfile-release-sync": "^0.32.0",