@herbertgao/pi-extensions 2026.10.7 → 2026.10.8

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 (56) hide show
  1. package/README.md +4 -4
  2. package/THIRD_PARTY_NOTICES.md +2 -2
  3. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +28 -27
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.md +6 -6
  5. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +16 -27
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +49 -48
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +2 -3
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +0 -60
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +2 -3
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer-layout.ts +105 -23
  11. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +59 -43
  12. package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +96 -0
  13. package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +6 -0
  14. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +36 -34
  15. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +7 -4
  16. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +3 -2
  17. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +23 -8
  18. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +2 -2
  19. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +24 -12
  20. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +121 -6
  21. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts +3 -2
  22. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-palette.ts +39 -8
  23. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-presentation.ts +2 -2
  24. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -13
  25. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/message-display.ts +3 -2
  26. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +49 -49
  27. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +24 -0
  28. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-state.ts +51 -2
  29. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  30. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +71 -70
  31. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +71 -70
  32. package/node_modules/@tifan/pi-inline-skills/package.json +5 -1
  33. package/node_modules/@tifan/pi-inline-skills/src/index.ts +5 -2
  34. package/node_modules/pi-provider-qoder/dist/index.js +136 -31
  35. package/node_modules/pi-provider-qoder/package.json +1 -1
  36. package/node_modules/pi-typesafe/README.md +3 -3
  37. package/node_modules/pi-typesafe/dist/backends.d.ts +7 -2
  38. package/node_modules/pi-typesafe/dist/backends.js +42 -0
  39. package/node_modules/pi-typesafe/dist/batch.d.ts +10 -6
  40. package/node_modules/pi-typesafe/dist/batch.js +20 -9
  41. package/node_modules/pi-typesafe/dist/client.d.ts +4 -1
  42. package/node_modules/pi-typesafe/dist/client.js +5 -4
  43. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  44. package/node_modules/pi-typesafe/dist/index.js +1 -1
  45. package/node_modules/pi-typesafe/dist/schema.d.ts +18 -3
  46. package/node_modules/pi-typesafe/dist/schema.js +29 -3
  47. package/node_modules/pi-typesafe/package.json +1 -1
  48. package/node_modules/pi-web-access/CHANGELOG.md +16 -0
  49. package/node_modules/pi-web-access/README.md +5 -2
  50. package/node_modules/pi-web-access/dist/index.js +13 -2
  51. package/node_modules/pi-web-access/dist/mcp-cli.js +14 -3
  52. package/node_modules/pi-web-access/extract.ts +4 -2
  53. package/node_modules/pi-web-access/package.json +1 -1
  54. package/node_modules/pi-web-access/searxng.ts +2 -1
  55. package/node_modules/pi-web-access/ssrf-protection.ts +11 -0
  56. package/package.json +6 -6
@@ -1,91 +1,92 @@
1
1
  {
2
2
  "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "cc-dark",
4
+ "appearance": "dark",
4
5
  "vars": {
5
- "bg": "#131217",
6
- "panel": "#1b1922",
7
- "surface": "#211e2b",
8
- "surfaceRaised": "#292533",
9
- "border": "#36313f",
10
- "borderMuted": "#292631",
11
- "accent": "#5e9cff",
12
- "accentBright": "#8ab4ff",
13
- "purple": "#c084fc",
14
- "pink": "#f472b6",
15
- "cyan": "#67e8f9",
16
- "blue": "#60a5fa",
17
- "green": "#4ade80",
18
- "red": "#fb7185",
19
- "yellow": "#facc15",
20
- "orange": "#fb923c",
21
- "text": "#e4e4e7",
22
- "muted": "#a1a1aa",
23
- "dim": "#71717a",
24
- "selectedBg": "#252035",
25
- "userMessageBg": "#1e1e2e",
26
- "toolPendingBg": "#1b1924",
27
- "toolSuccessBg": "#1e1e2e",
28
- "toolErrorBg": "#2a1b22",
29
- "customMessageBg": "#211c30"
6
+ "fg": "#d6dde3",
7
+ "fgMuted": "#929eab",
8
+ "fgSubtle": "#768494",
9
+ "canvas": "#0d1117",
10
+ "canvasSubtle": "#1c2033",
11
+ "canvasInset": "#161a2b",
12
+ "border": "#1c2d44",
13
+ "borderMuted": "#16233a",
14
+ "blue": "#4f9eff",
15
+ "blueBright": "#79c0ff",
16
+ "green": "#37b34a",
17
+ "red": "#ff6e62",
18
+ "redSoft": "#ff7b72",
19
+ "yellow": "#cb9214",
20
+ "orange": "#f0883e",
21
+ "orangeSoft": "#ffa657",
22
+ "purple": "#be8fff",
23
+ "pink": "#f778ba",
24
+ "cyan": "#39c5cf",
25
+ "selection": "#1a4480",
26
+ "diffAddBg": "#0f2a24",
27
+ "diffDelBg": "#261418"
30
28
  },
31
29
  "colors": {
32
- "accent": "accent",
30
+ "accent": "blue",
33
31
  "border": "border",
34
- "borderAccent": "accent",
32
+ "borderAccent": "blue",
35
33
  "borderMuted": "borderMuted",
36
34
  "success": "green",
37
35
  "error": "red",
38
36
  "warning": "yellow",
39
- "muted": "muted",
40
- "dim": "dim",
41
- "text": "text",
42
- "thinkingText": "muted",
43
- "selectedBg": "selectedBg",
44
- "scrollbarThumb": "selectedBg",
45
- "userMessageBg": "userMessageBg",
46
- "userMessageText": "text",
47
- "customMessageBg": "customMessageBg",
48
- "customMessageText": "text",
49
- "customMessageLabel": "purple",
50
- "toolPendingBg": "toolPendingBg",
51
- "toolSuccessBg": "toolSuccessBg",
52
- "toolErrorBg": "toolErrorBg",
53
- "toolTitle": "accentBright",
54
- "toolOutput": "muted",
55
- "mdHeading": "accentBright",
56
- "mdLink": "cyan",
57
- "mdLinkUrl": "muted",
58
- "mdCode": "accentBright",
59
- "mdCodeBlock": "text",
37
+ "muted": "fgMuted",
38
+ "dim": "#71717a",
39
+ "text": "fg",
40
+ "thinkingText": "fgMuted",
41
+ "selectedBg": "selection",
42
+ "scrollbarTrack": "borderMuted",
43
+ "scrollbarThumb": "#3a5274",
44
+ "searchMatchBg": "#1e1800",
45
+ "searchMatchText": "fg",
46
+ "userMessageBg": "canvasSubtle",
47
+ "userMessageText": "fg",
48
+ "customMessageBg": "borderMuted",
49
+ "customMessageText": "fgMuted",
50
+ "customMessageLabel": "blue",
51
+ "toolPendingBg": "canvasSubtle",
52
+ "toolSuccessBg": "diffAddBg",
53
+ "toolErrorBg": "diffDelBg",
54
+ "toolTitle": "fg",
55
+ "toolOutput": "fgMuted",
56
+ "mdHeading": "blueBright",
57
+ "mdLink": "blue",
58
+ "mdLinkUrl": "fgMuted",
59
+ "mdCode": "#a5d6ff",
60
+ "mdCodeBlock": "fg",
60
61
  "mdCodeBlockBorder": "border",
61
- "mdQuote": "muted",
62
- "mdQuoteBorder": "accent",
63
- "mdHr": "borderMuted",
64
- "mdListBullet": "accent",
62
+ "mdQuote": "fgMuted",
63
+ "mdQuoteBorder": "#2a4060",
64
+ "mdHr": "border",
65
+ "mdListBullet": "blueBright",
65
66
  "toolDiffAdded": "green",
66
67
  "toolDiffRemoved": "red",
67
- "toolDiffContext": "muted",
68
- "syntaxComment": "#6b7280",
69
- "syntaxKeyword": "pink",
70
- "syntaxFunction": "accentBright",
71
- "syntaxVariable": "blue",
72
- "syntaxString": "green",
73
- "syntaxNumber": "orange",
74
- "syntaxType": "cyan",
75
- "syntaxOperator": "text",
76
- "syntaxPunctuation": "muted",
77
- "thinkingOff": "muted",
78
- "thinkingMinimal": "dim",
68
+ "toolDiffContext": "fgMuted",
69
+ "syntaxComment": "fgMuted",
70
+ "syntaxKeyword": "redSoft",
71
+ "syntaxFunction": "purple",
72
+ "syntaxVariable": "orangeSoft",
73
+ "syntaxString": "#a5d6ff",
74
+ "syntaxNumber": "blueBright",
75
+ "syntaxType": "orange",
76
+ "syntaxOperator": "redSoft",
77
+ "syntaxPunctuation": "fg",
78
+ "thinkingOff": "fgMuted",
79
+ "thinkingMinimal": "fgSubtle",
79
80
  "thinkingLow": "blue",
80
- "thinkingMedium": "accent",
81
- "thinkingHigh": "accentBright",
82
- "thinkingXhigh": "#4db9cd",
81
+ "thinkingMedium": "blue",
82
+ "thinkingHigh": "blueBright",
83
+ "thinkingXhigh": "cyan",
83
84
  "thinkingMax": "cyan",
84
85
  "bashMode": "green"
85
86
  },
86
87
  "export": {
87
- "pageBg": "bg",
88
- "cardBg": "panel",
89
- "infoBg": "surface"
88
+ "pageBg": "#0a1424",
89
+ "cardBg": "canvasSubtle",
90
+ "infoBg": "#122544"
90
91
  }
91
92
  }
@@ -1,91 +1,92 @@
1
1
  {
2
2
  "$schema": "https://pi.dev/schemas/theme.schema.json",
3
3
  "name": "cc-light",
4
+ "appearance": "light",
4
5
  "vars": {
5
- "bg": "#f7f7f8",
6
- "panel": "#ffffff",
7
- "surface": "#f3f1f7",
8
- "surfaceRaised": "#ebe8f0",
9
- "border": "#d4d0db",
10
- "borderMuted": "#e5e2e9",
11
- "accent": "#2563eb",
12
- "accentBright": "#1d4ed8",
13
- "purple": "#7e22ce",
14
- "pink": "#be185d",
15
- "cyan": "#0e7490",
16
- "blue": "#2563eb",
17
- "green": "#15803d",
18
- "red": "#dc2626",
19
- "yellow": "#a16207",
20
- "orange": "#c2410c",
21
- "text": "#282530",
22
- "muted": "#625f68",
23
- "dim": "#76717d",
24
- "selectedBg": "#e3e8f5",
25
- "userMessageBg": "#f0eef4",
26
- "toolPendingBg": "#f1f3f9",
27
- "toolSuccessBg": "#edf7f0",
28
- "toolErrorBg": "#fceff1",
29
- "customMessageBg": "#f4effa"
6
+ "fg": "#1e252a",
7
+ "fgMuted": "#3e4a56",
8
+ "fgSubtle": "#46525e",
9
+ "canvas": "#ffffff",
10
+ "canvasSubtle": "#d6e1f1",
11
+ "canvasInset": "#e3ebf5",
12
+ "border": "#7391c2",
13
+ "borderMuted": "#a8bdd9",
14
+ "blue": "#0058ad",
15
+ "blueBright": "#004776",
16
+ "green": "#005a16",
17
+ "red": "#a81417",
18
+ "redSoft": "#9b1b1f",
19
+ "yellow": "#765300",
20
+ "orange": "#843f00",
21
+ "orangeSoft": "#663600",
22
+ "purple": "#65339c",
23
+ "pink": "#931662",
24
+ "cyan": "#005359",
25
+ "selection": "#c5d6ee",
26
+ "diffAddBg": "#c3dcd0",
27
+ "diffDelBg": "#f0d5d8"
30
28
  },
31
29
  "colors": {
32
- "accent": "accent",
30
+ "accent": "blue",
33
31
  "border": "border",
34
- "borderAccent": "accent",
32
+ "borderAccent": "blue",
35
33
  "borderMuted": "borderMuted",
36
34
  "success": "green",
37
35
  "error": "red",
38
36
  "warning": "yellow",
39
- "muted": "muted",
40
- "dim": "dim",
41
- "text": "text",
42
- "thinkingText": "muted",
43
- "selectedBg": "selectedBg",
44
- "scrollbarThumb": "selectedBg",
45
- "userMessageBg": "userMessageBg",
46
- "userMessageText": "text",
47
- "customMessageBg": "customMessageBg",
48
- "customMessageText": "text",
49
- "customMessageLabel": "purple",
50
- "toolPendingBg": "toolPendingBg",
51
- "toolSuccessBg": "toolSuccessBg",
52
- "toolErrorBg": "toolErrorBg",
53
- "toolTitle": "accentBright",
54
- "toolOutput": "muted",
55
- "mdHeading": "accentBright",
56
- "mdLink": "cyan",
57
- "mdLinkUrl": "muted",
58
- "mdCode": "accentBright",
59
- "mdCodeBlock": "text",
37
+ "muted": "fgMuted",
38
+ "dim": "#4e5966",
39
+ "text": "fg",
40
+ "thinkingText": "fgMuted",
41
+ "selectedBg": "selection",
42
+ "scrollbarTrack": "borderMuted",
43
+ "scrollbarThumb": "#5d84b8",
44
+ "searchMatchBg": "#f3e4b0",
45
+ "searchMatchText": "fg",
46
+ "userMessageBg": "canvasSubtle",
47
+ "userMessageText": "fg",
48
+ "customMessageBg": "#c5d3e6",
49
+ "customMessageText": "fgMuted",
50
+ "customMessageLabel": "blue",
51
+ "toolPendingBg": "canvasSubtle",
52
+ "toolSuccessBg": "diffAddBg",
53
+ "toolErrorBg": "diffDelBg",
54
+ "toolTitle": "fg",
55
+ "toolOutput": "fgMuted",
56
+ "mdHeading": "blueBright",
57
+ "mdLink": "blue",
58
+ "mdLinkUrl": "fgMuted",
59
+ "mdCode": "#053859",
60
+ "mdCodeBlock": "fg",
60
61
  "mdCodeBlockBorder": "border",
61
- "mdQuote": "muted",
62
- "mdQuoteBorder": "accent",
63
- "mdHr": "borderMuted",
64
- "mdListBullet": "accent",
62
+ "mdQuote": "fgMuted",
63
+ "mdQuoteBorder": "#6d8dbe",
64
+ "mdHr": "border",
65
+ "mdListBullet": "blueBright",
65
66
  "toolDiffAdded": "green",
66
67
  "toolDiffRemoved": "red",
67
- "toolDiffContext": "muted",
68
- "syntaxComment": "#6b7280",
69
- "syntaxKeyword": "pink",
70
- "syntaxFunction": "accentBright",
71
- "syntaxVariable": "blue",
72
- "syntaxString": "green",
73
- "syntaxNumber": "orange",
74
- "syntaxType": "cyan",
75
- "syntaxOperator": "text",
76
- "syntaxPunctuation": "muted",
77
- "thinkingOff": "muted",
78
- "thinkingMinimal": "dim",
68
+ "toolDiffContext": "fgMuted",
69
+ "syntaxComment": "fgMuted",
70
+ "syntaxKeyword": "redSoft",
71
+ "syntaxFunction": "purple",
72
+ "syntaxVariable": "orangeSoft",
73
+ "syntaxString": "#053859",
74
+ "syntaxNumber": "blueBright",
75
+ "syntaxType": "orange",
76
+ "syntaxOperator": "redSoft",
77
+ "syntaxPunctuation": "fg",
78
+ "thinkingOff": "fgMuted",
79
+ "thinkingMinimal": "fgSubtle",
79
80
  "thinkingLow": "blue",
80
- "thinkingMedium": "accent",
81
- "thinkingHigh": "accentBright",
82
- "thinkingXhigh": "#0e7490",
81
+ "thinkingMedium": "blue",
82
+ "thinkingHigh": "blueBright",
83
+ "thinkingXhigh": "cyan",
83
84
  "thinkingMax": "cyan",
84
85
  "bashMode": "green"
85
86
  },
86
87
  "export": {
87
- "pageBg": "bg",
88
- "cardBg": "panel",
89
- "infoBg": "surface"
88
+ "pageBg": "#f4f7fb",
89
+ "cardBg": "canvasSubtle",
90
+ "infoBg": "#d0dff2"
90
91
  }
91
92
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tifan/pi-inline-skills",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Inline /skill autocomplete in the pi editor.",
5
5
  "keywords": [
6
6
  "autocomplete",
@@ -20,6 +20,7 @@
20
20
  },
21
21
  "files": [
22
22
  "src/**/*.ts",
23
+ "!src/**/*.test.ts",
23
24
  "README.md",
24
25
  "LICENSE"
25
26
  ],
@@ -28,6 +29,9 @@
28
29
  "access": "public",
29
30
  "provenance": true
30
31
  },
32
+ "scripts": {
33
+ "test": "node --experimental-strip-types --test src/index.test.ts"
34
+ },
31
35
  "engines": {
32
36
  "node": ">=20"
33
37
  },
@@ -351,7 +351,7 @@ function mergeAutocompleteItems(options: {
351
351
  })
352
352
 
353
353
  return {
354
- prefix: options.prefix,
354
+ prefix: options.current?.prefix ?? `/${options.prefix}`,
355
355
  items: items.slice(0, MAX_SUGGESTIONS),
356
356
  }
357
357
  }
@@ -452,7 +452,10 @@ function createSlashSkillAutocompleteProvider(
452
452
 
453
453
  applyCompletion(lines, cursorLine, cursorCol, item, prefix) {
454
454
  const currentLine = lines[cursorLine] ?? ""
455
- const slashPrefixStart = cursorCol - prefix.length - 1
455
+ const prefixStart = cursorCol - prefix.length
456
+ const slashPrefixStart = prefix.startsWith("/")
457
+ ? prefixStart
458
+ : prefixStart - 1
456
459
  const isSlashSkillCompletion =
457
460
  item.label.startsWith("skill:") &&
458
461
  item.value.startsWith("/") &&
@@ -1,26 +1,129 @@
1
1
  // src/auth/oauth.ts
2
+ import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
3
+ import { homedir as homedir4 } from "node:os";
4
+ import { dirname as dirname4, join as join4 } from "node:path";
5
+ import * as PiCodingAgent from "@earendil-works/pi-coding-agent";
6
+
7
+ // src/catalog.ts
2
8
  import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "node:fs";
3
9
  import { homedir as homedir3 } from "node:os";
4
10
  import { dirname as dirname3, join as join3 } from "node:path";
5
- import * as PiCodingAgent from "@earendil-works/pi-coding-agent";
6
11
 
7
- // src/catalog.ts
12
+ // src/cosy.ts
13
+ import crypto from "node:crypto";
8
14
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
9
15
  import { homedir as homedir2 } from "node:os";
10
16
  import { dirname as dirname2, join as join2 } from "node:path";
11
17
 
12
- // src/cosy.ts
13
- import crypto from "node:crypto";
18
+ // src/cosy-version.ts
14
19
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
15
20
  import { homedir } from "node:os";
16
21
  import { dirname, join } from "node:path";
22
+ var BUNDLED_GATEWAY_COSY_VERSION = "1.1.72";
23
+ var QODER_CLI_RELEASES_URL = "https://repo.qoder.com/repos/QoderAI/changelog-CLI/releases?per_page=5&page=1";
24
+ var CACHE_FILE = "qoder-cosy-version-cache.json";
25
+ var REFRESH_INTERVAL_MS = 24 * 60 * 60 * 1e3;
26
+ var FETCH_TIMEOUT_MS = 5e3;
27
+ function getHomeDir() {
28
+ return process.env.HOME || process.env.USERPROFILE || homedir();
29
+ }
30
+ function getCosyVersionCachePath() {
31
+ return join(getHomeDir(), ".pi", "agent", CACHE_FILE);
32
+ }
33
+ var cosyVersionMem = /* @__PURE__ */ new Map();
34
+ function readCosyVersionCache() {
35
+ const cachePath = getCosyVersionCachePath();
36
+ if (cosyVersionMem.has(cachePath)) {
37
+ return cosyVersionMem.get(cachePath) ?? null;
38
+ }
39
+ if (!existsSync(cachePath)) {
40
+ cosyVersionMem.set(cachePath, null);
41
+ return null;
42
+ }
43
+ try {
44
+ const data = JSON.parse(readFileSync(cachePath, "utf8"));
45
+ cosyVersionMem.set(cachePath, data);
46
+ return data;
47
+ } catch {
48
+ cosyVersionMem.set(cachePath, null);
49
+ return null;
50
+ }
51
+ }
52
+ function writeCosyVersionCache(data) {
53
+ const cachePath = getCosyVersionCachePath();
54
+ try {
55
+ mkdirSync(dirname(cachePath), { recursive: true });
56
+ writeFileSync(cachePath, JSON.stringify(data, null, 2), "utf-8");
57
+ } catch {
58
+ }
59
+ cosyVersionMem.set(cachePath, data);
60
+ }
61
+ function isCliVersion(value) {
62
+ return typeof value === "string" && /^\d+\.\d+\.\d+$/.test(value);
63
+ }
64
+ function compareCliVersions(a, b2) {
65
+ const pa = a.split(".").map(Number);
66
+ const pb = b2.split(".").map(Number);
67
+ for (let i = 0; i < 3; i++) {
68
+ if (pa[i] !== pb[i]) return pa[i] - pb[i];
69
+ }
70
+ return 0;
71
+ }
72
+ function getGatewayCosyVersion() {
73
+ const cached = readCosyVersionCache()?.version;
74
+ if (isCliVersion(cached) && compareCliVersions(cached, BUNDLED_GATEWAY_COSY_VERSION) >= 0) {
75
+ return cached;
76
+ }
77
+ return BUNDLED_GATEWAY_COSY_VERSION;
78
+ }
79
+ var refreshInFlight = null;
80
+ async function refreshGatewayCosyVersion(options) {
81
+ const now = options?.now ?? Date.now();
82
+ const checkedAt = readCosyVersionCache()?.checkedAt;
83
+ if (!options?.force && typeof checkedAt === "number" && now - checkedAt < REFRESH_INTERVAL_MS) {
84
+ return;
85
+ }
86
+ if (refreshInFlight) return refreshInFlight;
87
+ refreshInFlight = (async () => {
88
+ try {
89
+ const controller = new AbortController();
90
+ const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
91
+ let releases;
92
+ try {
93
+ const response = await fetch(QODER_CLI_RELEASES_URL, {
94
+ headers: { Accept: "application/vnd.github.v3+json" },
95
+ signal: controller.signal
96
+ });
97
+ if (!response.ok) return;
98
+ releases = await response.json();
99
+ } finally {
100
+ clearTimeout(timer);
101
+ }
102
+ if (!Array.isArray(releases)) return;
103
+ const latest = releases.find(
104
+ (release) => release && !release.draft && !release.prerelease && isCliVersion(release.tag_name)
105
+ );
106
+ const stampedAt = Date.now();
107
+ if (latest && compareCliVersions(latest.tag_name, getGatewayCosyVersion()) > 0) {
108
+ writeCosyVersionCache({ version: latest.tag_name, checkedAt: stampedAt });
109
+ } else {
110
+ writeCosyVersionCache({ version: readCosyVersionCache()?.version, checkedAt: stampedAt });
111
+ }
112
+ } catch {
113
+ } finally {
114
+ refreshInFlight = null;
115
+ }
116
+ })();
117
+ return refreshInFlight;
118
+ }
119
+
120
+ // src/cosy.ts
17
121
  var qoderRSAPublicKey = `-----BEGIN PUBLIC KEY-----
18
122
  MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA8iMH5c02LilrsERw9t6Pv5Nc
19
123
  4k6Pz1EaDicBMpdpxKduSZu5OANqUq8er4GM95omAGIOPOh+Nx0spthYA2BqGz+l
20
124
  6HRkPJ7S236FZz73In/KVuLnwI8JJ2CbuJap8kvheCCZpmAWpb/cPx/3Vr/J6I17
21
125
  XcW+ML9FoCI6AOvOzwIDAQAB
22
126
  -----END PUBLIC KEY-----`;
23
- var QODER_GATEWAY_COSY_VERSION = "1.1.38";
24
127
  var QODER_OPENAPI_COSY_VERSION = "1.0.1";
25
128
  var QODER_CLIENT_TYPE = "5";
26
129
  var QoderDataPolicy = "disagree";
@@ -49,16 +152,16 @@ function computeSigPath(urlStr) {
49
152
  }
50
153
  return sigPath;
51
154
  }
52
- function getHomeDir() {
53
- return process.env.HOME || process.env.USERPROFILE || homedir();
155
+ function getHomeDir2() {
156
+ return process.env.HOME || process.env.USERPROFILE || homedir2();
54
157
  }
55
158
  function getMachineId() {
56
- const home = getHomeDir();
57
- const paths = [join(home, ".qoder", ".auth", "machine_id"), join(home, ".pi", "agent", "qoder-machine-id")];
159
+ const home = getHomeDir2();
160
+ const paths = [join2(home, ".qoder", ".auth", "machine_id"), join2(home, ".pi", "agent", "qoder-machine-id")];
58
161
  for (const p of paths) {
59
- if (existsSync(p)) {
162
+ if (existsSync2(p)) {
60
163
  try {
61
- const val = readFileSync(p, "utf8").trim();
164
+ const val = readFileSync2(p, "utf8").trim();
62
165
  if (val) return val;
63
166
  } catch {
64
167
  }
@@ -67,8 +170,8 @@ function getMachineId() {
67
170
  const newId = crypto.randomUUID();
68
171
  try {
69
172
  const savePath = paths[1];
70
- mkdirSync(dirname(savePath), { recursive: true });
71
- writeFileSync(savePath, newId, "utf8");
173
+ mkdirSync2(dirname2(savePath), { recursive: true });
174
+ writeFileSync2(savePath, newId, "utf8");
72
175
  } catch {
73
176
  }
74
177
  return newId;
@@ -92,11 +195,12 @@ function buildAuthHeaders(body, requestURL, creds) {
92
195
  const cosyKey = rsaEncryptBase64(aesKey);
93
196
  const timestamp = Math.floor(Date.now() / 1e3).toString();
94
197
  const requestId = crypto.randomUUID();
198
+ const cosyVersion = getGatewayCosyVersion();
95
199
  const cosyPayload = {
96
200
  version: "v1",
97
201
  requestId,
98
202
  info: infoB64,
99
- cosyVersion: QODER_GATEWAY_COSY_VERSION,
203
+ cosyVersion,
100
204
  ideVersion: ""
101
205
  };
102
206
  const payloadB64 = Buffer.from(JSON.stringify(cosyPayload)).toString("base64");
@@ -111,7 +215,7 @@ function buildAuthHeaders(body, requestURL, creds) {
111
215
  "Cosy-Key": cosyKey,
112
216
  "Cosy-User": creds.userID,
113
217
  "Cosy-Date": timestamp,
114
- "Cosy-Version": QODER_GATEWAY_COSY_VERSION,
218
+ "Cosy-Version": cosyVersion,
115
219
  "Cosy-Machineid": machineID,
116
220
  "Cosy-Machinetoken": machineID,
117
221
  "Cosy-Machinetype": QoderMachineTypeMagic,
@@ -204,11 +308,11 @@ function getQoderDevicePollURL(nonce, codeVerifier) {
204
308
  var ZERO_COST = Object.freeze({ input: 0, output: 0, cacheRead: 0, cacheWrite: 0 });
205
309
  var MAX_OUTPUT_TOKENS = 131072;
206
310
  var DEFAULT_CONTEXT_WINDOW = 1e6;
207
- function getHomeDir2() {
208
- return process.env.HOME || process.env.USERPROFILE || homedir2();
311
+ function getHomeDir3() {
312
+ return process.env.HOME || process.env.USERPROFILE || homedir3();
209
313
  }
210
314
  function getQoderCachePath(mode) {
211
- return join2(getHomeDir2(), ".pi", "agent", getQoderRegionConfig(mode).modelCacheFile);
315
+ return join3(getHomeDir3(), ".pi", "agent", getQoderRegionConfig(mode).modelCacheFile);
212
316
  }
213
317
  var modelCacheMem = /* @__PURE__ */ new Map();
214
318
  function readParsedModelCache(mode) {
@@ -216,12 +320,12 @@ function readParsedModelCache(mode) {
216
320
  if (modelCacheMem.has(cachePath)) {
217
321
  return modelCacheMem.get(cachePath) ?? null;
218
322
  }
219
- if (!existsSync2(cachePath)) {
323
+ if (!existsSync3(cachePath)) {
220
324
  modelCacheMem.set(cachePath, null);
221
325
  return null;
222
326
  }
223
327
  try {
224
- const data = JSON.parse(readFileSync2(cachePath, "utf8"));
328
+ const data = JSON.parse(readFileSync3(cachePath, "utf8"));
225
329
  modelCacheMem.set(cachePath, data);
226
330
  return data;
227
331
  } catch {
@@ -231,8 +335,8 @@ function readParsedModelCache(mode) {
231
335
  }
232
336
  function writeParsedModelCache(mode, data) {
233
337
  const cachePath = getQoderCachePath(mode);
234
- mkdirSync2(dirname2(cachePath), { recursive: true });
235
- writeFileSync2(cachePath, JSON.stringify(data, null, 2), "utf-8");
338
+ mkdirSync3(dirname3(cachePath), { recursive: true });
339
+ writeFileSync3(cachePath, JSON.stringify(data, null, 2), "utf-8");
236
340
  modelCacheMem.set(cachePath, data);
237
341
  }
238
342
  function toQoderModelId(displayName) {
@@ -695,6 +799,7 @@ function isCacheStale(mode) {
695
799
  async function updateQoderModelsCache(authToken, userID, name, email, mode) {
696
800
  const modelListURL = getQoderModelListURL(mode);
697
801
  try {
802
+ await refreshGatewayCosyVersion();
698
803
  const headers = buildAuthHeaders(null, modelListURL, {
699
804
  userID,
700
805
  authToken,
@@ -1011,11 +1116,11 @@ async function runDeviceFlow(callbacks) {
1011
1116
  // src/auth/oauth.ts
1012
1117
  var AuthStorage2 = PiCodingAgent.AuthStorage;
1013
1118
  var identityCache = /* @__PURE__ */ new Map();
1014
- function getHomeDir3() {
1015
- return process.env.HOME || process.env.USERPROFILE || homedir3();
1119
+ function getHomeDir4() {
1120
+ return process.env.HOME || process.env.USERPROFILE || homedir4();
1016
1121
  }
1017
1122
  function getAuthFilePath() {
1018
- return join3(getHomeDir3(), ".pi", "agent", "auth.json");
1123
+ return join4(getHomeDir4(), ".pi", "agent", "auth.json");
1019
1124
  }
1020
1125
  var authFileMem;
1021
1126
  function readAuthFileCached() {
@@ -1024,12 +1129,12 @@ function readAuthFileCached() {
1024
1129
  if (authFileMem === null) return null;
1025
1130
  if (authFileMem.path === authPath) return authFileMem.data;
1026
1131
  }
1027
- if (!existsSync3(authPath)) {
1132
+ if (!existsSync4(authPath)) {
1028
1133
  authFileMem = null;
1029
1134
  return null;
1030
1135
  }
1031
1136
  try {
1032
- const data = JSON.parse(readFileSync3(authPath, "utf-8"));
1137
+ const data = JSON.parse(readFileSync4(authPath, "utf-8"));
1033
1138
  authFileMem = { path: authPath, data };
1034
1139
  return data;
1035
1140
  } catch {
@@ -1047,14 +1152,14 @@ function getQoderPatForMode(mode) {
1047
1152
  function saveCredentialsToAuthFile(providerID, credentials) {
1048
1153
  try {
1049
1154
  const authPath = getAuthFilePath();
1050
- const dir = dirname3(authPath);
1051
- if (!existsSync3(dir)) {
1052
- mkdirSync3(dir, { recursive: true, mode: 448 });
1155
+ const dir = dirname4(authPath);
1156
+ if (!existsSync4(dir)) {
1157
+ mkdirSync4(dir, { recursive: true, mode: 448 });
1053
1158
  }
1054
1159
  const existing = readAuthFileCached();
1055
1160
  const auth = existing ? { ...existing } : {};
1056
1161
  auth[providerID] = { type: "oauth", ...credentials };
1057
- writeFileSync3(authPath, JSON.stringify(auth, null, 2), { encoding: "utf-8", mode: 384 });
1162
+ writeFileSync4(authPath, JSON.stringify(auth, null, 2), { encoding: "utf-8", mode: 384 });
1058
1163
  authFileMem = { path: authPath, data: auth };
1059
1164
  const q2 = credentials;
1060
1165
  if (q2.access && q2.userID) {