@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.
- package/README.md +4 -4
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +28 -27
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +6 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/config.ts +16 -27
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/config/panel.ts +49 -48
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/compact-thinking.ts +2 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/context.ts +0 -60
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/reference/index.ts +2 -3
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer-layout.ts +105 -23
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/footer.ts +59 -43
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/feature/shell/prompt-editor.ts +96 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/index.ts +6 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +36 -34
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/default-mode.ts +7 -4
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/scroll.ts +23 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/sticky-prompt.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +24 -12
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/codemode.ts +121 -6
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-limits.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-palette.ts +39 -8
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/diff-presentation.ts +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +13 -13
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/message-display.ts +3 -2
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/names.ts +49 -49
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/result.ts +24 -0
- package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-state.ts +51 -2
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark.json +71 -70
- package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light.json +71 -70
- package/node_modules/@tifan/pi-inline-skills/package.json +5 -1
- package/node_modules/@tifan/pi-inline-skills/src/index.ts +5 -2
- package/node_modules/pi-provider-qoder/dist/index.js +136 -31
- package/node_modules/pi-provider-qoder/package.json +1 -1
- package/node_modules/pi-typesafe/README.md +3 -3
- package/node_modules/pi-typesafe/dist/backends.d.ts +7 -2
- package/node_modules/pi-typesafe/dist/backends.js +42 -0
- package/node_modules/pi-typesafe/dist/batch.d.ts +10 -6
- package/node_modules/pi-typesafe/dist/batch.js +20 -9
- package/node_modules/pi-typesafe/dist/client.d.ts +4 -1
- package/node_modules/pi-typesafe/dist/client.js +5 -4
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/dist/schema.d.ts +18 -3
- package/node_modules/pi-typesafe/dist/schema.js +29 -3
- package/node_modules/pi-typesafe/package.json +1 -1
- package/node_modules/pi-web-access/CHANGELOG.md +16 -0
- package/node_modules/pi-web-access/README.md +5 -2
- package/node_modules/pi-web-access/dist/index.js +13 -2
- package/node_modules/pi-web-access/dist/mcp-cli.js +14 -3
- package/node_modules/pi-web-access/extract.ts +4 -2
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/searxng.ts +2 -1
- package/node_modules/pi-web-access/ssrf-protection.ts +11 -0
- 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
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
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": "
|
|
30
|
+
"accent": "blue",
|
|
33
31
|
"border": "border",
|
|
34
|
-
"borderAccent": "
|
|
32
|
+
"borderAccent": "blue",
|
|
35
33
|
"borderMuted": "borderMuted",
|
|
36
34
|
"success": "green",
|
|
37
35
|
"error": "red",
|
|
38
36
|
"warning": "yellow",
|
|
39
|
-
"muted": "
|
|
40
|
-
"dim": "
|
|
41
|
-
"text": "
|
|
42
|
-
"thinkingText": "
|
|
43
|
-
"selectedBg": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
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": "
|
|
62
|
-
"mdQuoteBorder": "
|
|
63
|
-
"mdHr": "
|
|
64
|
-
"mdListBullet": "
|
|
62
|
+
"mdQuote": "fgMuted",
|
|
63
|
+
"mdQuoteBorder": "#2a4060",
|
|
64
|
+
"mdHr": "border",
|
|
65
|
+
"mdListBullet": "blueBright",
|
|
65
66
|
"toolDiffAdded": "green",
|
|
66
67
|
"toolDiffRemoved": "red",
|
|
67
|
-
"toolDiffContext": "
|
|
68
|
-
"syntaxComment": "
|
|
69
|
-
"syntaxKeyword": "
|
|
70
|
-
"syntaxFunction": "
|
|
71
|
-
"syntaxVariable": "
|
|
72
|
-
"syntaxString": "
|
|
73
|
-
"syntaxNumber": "
|
|
74
|
-
"syntaxType": "
|
|
75
|
-
"syntaxOperator": "
|
|
76
|
-
"syntaxPunctuation": "
|
|
77
|
-
"thinkingOff": "
|
|
78
|
-
"thinkingMinimal": "
|
|
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": "
|
|
81
|
-
"thinkingHigh": "
|
|
82
|
-
"thinkingXhigh": "
|
|
81
|
+
"thinkingMedium": "blue",
|
|
82
|
+
"thinkingHigh": "blueBright",
|
|
83
|
+
"thinkingXhigh": "cyan",
|
|
83
84
|
"thinkingMax": "cyan",
|
|
84
85
|
"bashMode": "green"
|
|
85
86
|
},
|
|
86
87
|
"export": {
|
|
87
|
-
"pageBg": "
|
|
88
|
-
"cardBg": "
|
|
89
|
-
"infoBg": "
|
|
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
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
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": "
|
|
30
|
+
"accent": "blue",
|
|
33
31
|
"border": "border",
|
|
34
|
-
"borderAccent": "
|
|
32
|
+
"borderAccent": "blue",
|
|
35
33
|
"borderMuted": "borderMuted",
|
|
36
34
|
"success": "green",
|
|
37
35
|
"error": "red",
|
|
38
36
|
"warning": "yellow",
|
|
39
|
-
"muted": "
|
|
40
|
-
"dim": "
|
|
41
|
-
"text": "
|
|
42
|
-
"thinkingText": "
|
|
43
|
-
"selectedBg": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
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": "
|
|
62
|
-
"mdQuoteBorder": "
|
|
63
|
-
"mdHr": "
|
|
64
|
-
"mdListBullet": "
|
|
62
|
+
"mdQuote": "fgMuted",
|
|
63
|
+
"mdQuoteBorder": "#6d8dbe",
|
|
64
|
+
"mdHr": "border",
|
|
65
|
+
"mdListBullet": "blueBright",
|
|
65
66
|
"toolDiffAdded": "green",
|
|
66
67
|
"toolDiffRemoved": "red",
|
|
67
|
-
"toolDiffContext": "
|
|
68
|
-
"syntaxComment": "
|
|
69
|
-
"syntaxKeyword": "
|
|
70
|
-
"syntaxFunction": "
|
|
71
|
-
"syntaxVariable": "
|
|
72
|
-
"syntaxString": "
|
|
73
|
-
"syntaxNumber": "
|
|
74
|
-
"syntaxType": "
|
|
75
|
-
"syntaxOperator": "
|
|
76
|
-
"syntaxPunctuation": "
|
|
77
|
-
"thinkingOff": "
|
|
78
|
-
"thinkingMinimal": "
|
|
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": "
|
|
81
|
-
"thinkingHigh": "
|
|
82
|
-
"thinkingXhigh": "
|
|
81
|
+
"thinkingMedium": "blue",
|
|
82
|
+
"thinkingHigh": "blueBright",
|
|
83
|
+
"thinkingXhigh": "cyan",
|
|
83
84
|
"thinkingMax": "cyan",
|
|
84
85
|
"bashMode": "green"
|
|
85
86
|
},
|
|
86
87
|
"export": {
|
|
87
|
-
"pageBg": "
|
|
88
|
-
"cardBg": "
|
|
89
|
-
"infoBg": "
|
|
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.
|
|
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
|
|
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/
|
|
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
|
|
53
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
155
|
+
function getHomeDir2() {
|
|
156
|
+
return process.env.HOME || process.env.USERPROFILE || homedir2();
|
|
54
157
|
}
|
|
55
158
|
function getMachineId() {
|
|
56
|
-
const home =
|
|
57
|
-
const paths = [
|
|
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 (
|
|
162
|
+
if (existsSync2(p)) {
|
|
60
163
|
try {
|
|
61
|
-
const val =
|
|
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
|
-
|
|
71
|
-
|
|
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
|
|
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":
|
|
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
|
|
208
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
311
|
+
function getHomeDir3() {
|
|
312
|
+
return process.env.HOME || process.env.USERPROFILE || homedir3();
|
|
209
313
|
}
|
|
210
314
|
function getQoderCachePath(mode) {
|
|
211
|
-
return
|
|
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 (!
|
|
323
|
+
if (!existsSync3(cachePath)) {
|
|
220
324
|
modelCacheMem.set(cachePath, null);
|
|
221
325
|
return null;
|
|
222
326
|
}
|
|
223
327
|
try {
|
|
224
|
-
const data = JSON.parse(
|
|
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
|
-
|
|
235
|
-
|
|
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
|
|
1015
|
-
return process.env.HOME || process.env.USERPROFILE ||
|
|
1119
|
+
function getHomeDir4() {
|
|
1120
|
+
return process.env.HOME || process.env.USERPROFILE || homedir4();
|
|
1016
1121
|
}
|
|
1017
1122
|
function getAuthFilePath() {
|
|
1018
|
-
return
|
|
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 (!
|
|
1132
|
+
if (!existsSync4(authPath)) {
|
|
1028
1133
|
authFileMem = null;
|
|
1029
1134
|
return null;
|
|
1030
1135
|
}
|
|
1031
1136
|
try {
|
|
1032
|
-
const data = JSON.parse(
|
|
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 =
|
|
1051
|
-
if (!
|
|
1052
|
-
|
|
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
|
-
|
|
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) {
|