pi-gigachat-models 0.2.0 → 0.2.2
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/LICENSE +21 -0
- package/README.md +34 -14
- package/package.json +11 -6
- package/eslint.config.js +0 -15
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anton Kholodkov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
# pi-gigachat-models
|
|
2
2
|
|
|
3
|
+
**Author:** [Anton Kholodkov](mailto:khanton@yandex.ru)
|
|
4
|
+
|
|
3
5
|
GigaChat provider (models and chat completions) for [pi](https://pi.dev). The package registers a `gigachat` provider with
|
|
4
6
|
Authorization-key login (`/login gigachat`), live model discovery, SSE token
|
|
5
7
|
streaming and function calling.
|
|
6
8
|
|
|
9
|
+
**Install in Pi:** `pi install npm:pi-gigachat-models`
|
|
10
|
+
|
|
7
11
|
The wire protocol follows the public GigaChat OpenAPI description:
|
|
8
12
|
<https://developers.sber.ru/docs/files/openapi/gigachat/api.yml>
|
|
9
13
|
|
|
10
14
|
## Install
|
|
11
15
|
|
|
12
16
|
```bash
|
|
13
|
-
# Try it without installing
|
|
14
|
-
pi -e /path/to/gigachat
|
|
15
|
-
|
|
16
|
-
# Install as a personal package
|
|
17
|
-
pi install /path/to/gigachat
|
|
18
|
-
|
|
19
|
-
# Or from npm once published
|
|
20
17
|
pi install npm:pi-gigachat-models
|
|
21
18
|
```
|
|
22
19
|
|
|
20
|
+
Requires Node.js >=22.19.0 and Pi. TypeScript sources are loaded directly by Pi;
|
|
21
|
+
no build step is required.
|
|
22
|
+
|
|
23
23
|
## Sign in
|
|
24
24
|
|
|
25
25
|
```bash
|
|
@@ -28,8 +28,7 @@ pi install npm:pi-gigachat-models
|
|
|
28
28
|
|
|
29
29
|
The flow asks for:
|
|
30
30
|
|
|
31
|
-
1. **API scope** — `GIGACHAT_API_PERS` (individual)
|
|
32
|
-
`GIGACHAT_API_CORP` (legal entities).
|
|
31
|
+
1. **API scope** — `GIGACHAT_API_PERS` (individual). **Note:** Only `GIGACHAT_API_PERS` is currently tested and supported. `GIGACHAT_API_B2B` and `GIGACHAT_API_CORP` are not supported yet.
|
|
33
32
|
2. **Authorization key** — the Base64 `client_id:client_secret` value from the
|
|
34
33
|
GigaChat API console. Pasting a full `Basic ...` header or a quoted value is
|
|
35
34
|
fine; it is normalized.
|
|
@@ -51,10 +50,11 @@ After login:
|
|
|
51
50
|
|
|
52
51
|
`/logout gigachat` removes the stored key.
|
|
53
52
|
|
|
54
|
-
Legal-entity scopes (`B2B`, `CORP`)
|
|
55
|
-
certificate (mTLS) on the token endpoint
|
|
56
|
-
uses `fetch`, which has no portable way to present a
|
|
57
|
-
|
|
53
|
+
Legal-entity scopes (`B2B`, `CORP`) are not supported yet. They would require a
|
|
54
|
+
GigaChat API client certificate (mTLS) on the token endpoint, which is not
|
|
55
|
+
implemented: the provider uses `fetch`, which has no portable way to present a
|
|
56
|
+
client certificate. Only `GIGACHAT_API_PERS` (individual) keys are tested and
|
|
57
|
+
supported.
|
|
58
58
|
|
|
59
59
|
## TLS and certificates
|
|
60
60
|
|
|
@@ -153,7 +153,7 @@ Not supported yet:
|
|
|
153
153
|
## Development
|
|
154
154
|
|
|
155
155
|
```bash
|
|
156
|
-
npm install #
|
|
156
|
+
npm install # install dependencies
|
|
157
157
|
npm run typecheck # strict TypeScript check, no emit
|
|
158
158
|
npm test # node --test, no network access required
|
|
159
159
|
npm run coverage # node's built-in coverage report for the test suite
|
|
@@ -172,6 +172,26 @@ Layout:
|
|
|
172
172
|
| `src/stream.ts` | `streamSimple` implementation and event emission |
|
|
173
173
|
| `certs/` | Bundled Russian Trusted Root CA and Sub CA (public certificates) |
|
|
174
174
|
|
|
175
|
+
## Publishing
|
|
176
|
+
|
|
177
|
+
Run these commands from the repository root:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npm login --registry=https://registry.npmjs.org/
|
|
181
|
+
npm run prepublishOnly # typecheck, lint and tests
|
|
182
|
+
npm pack --dry-run # inspect files before publishing
|
|
183
|
+
npm publish # repeats checks via prepublishOnly
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The published package includes `src/`, `certs/`, `README.md` and `LICENSE`.
|
|
187
|
+
Pi loads `src/index.ts` through the `pi.extensions` manifest; no `dist/` is
|
|
188
|
+
needed. The `pi-package` keyword enables discovery in the
|
|
189
|
+
[Pi package catalog](https://pi.dev/packages) after npm indexing.
|
|
190
|
+
|
|
191
|
+
For subsequent releases, increment `version` in `package.json` before publishing;
|
|
192
|
+
npm does not allow overwriting an existing version. Do not include credentials
|
|
193
|
+
or private keys in the package. The bundled CA certificates are public.
|
|
194
|
+
|
|
175
195
|
## Troubleshooting
|
|
176
196
|
|
|
177
197
|
- **`401 Unauthorized` during login** — the value is probably the client secret
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-gigachat-models",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "GigaChat provider for pi: Authorization-key login, streaming chat completions and function calling",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"typecheck": "tsc -p tsconfig.json",
|
|
25
25
|
"test": "node --test test/*.test.ts",
|
|
26
26
|
"coverage": "node --experimental-test-coverage --test test/*.test.ts",
|
|
27
|
-
"lint": "eslint src test"
|
|
27
|
+
"lint": "eslint src test",
|
|
28
|
+
"prepublishOnly": "npm run typecheck && npm run lint && npm test"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"@earendil-works/pi-ai": "*",
|
|
@@ -42,15 +43,19 @@
|
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"undici": "^8.12.4"
|
|
44
45
|
},
|
|
45
|
-
"main": "
|
|
46
|
-
"
|
|
47
|
-
"
|
|
46
|
+
"main": "./src/index.ts",
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22.19.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
48
53
|
},
|
|
49
54
|
"repository": {
|
|
50
55
|
"type": "git",
|
|
51
56
|
"url": "git+https://github.com/khanton/pi-gigachat-models.git"
|
|
52
57
|
},
|
|
53
|
-
"author": "",
|
|
58
|
+
"author": "Anton Kholodkov <khanton@yandex.ru>",
|
|
54
59
|
"bugs": {
|
|
55
60
|
"url": "https://github.com/khanton/pi-gigachat-models/issues"
|
|
56
61
|
},
|
package/eslint.config.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import js from "@eslint/js";
|
|
2
|
-
import tseslint from "typescript-eslint";
|
|
3
|
-
|
|
4
|
-
export default tseslint.config(
|
|
5
|
-
{ ignores: ["node_modules/**"] },
|
|
6
|
-
js.configs.recommended,
|
|
7
|
-
...tseslint.configs.recommended,
|
|
8
|
-
{
|
|
9
|
-
files: ["src/**/*.ts", "test/**/*.ts"],
|
|
10
|
-
rules: {
|
|
11
|
-
"no-unused-vars": "off",
|
|
12
|
-
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
);
|