@computesdk/pi-morph 0.0.0-stage → 1.0.0
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 +36 -2
- package/index.ts +64 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 computesdk
|
|
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,3 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @computesdk/pi-morph
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Morph](https://www.morphllm.com) as a Pi provider: the open-weight coding models on Morph's OpenAI-compatible API.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pi install npm:@computesdk/pi-morph # or: pi -e /path/to/pi-extensions/packages/pi-morph
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Set `MORPH_API_KEY` in your environment and the models show up in `/model` as `morph/morph-kimik3` and friends.
|
|
10
|
+
|
|
11
|
+
| Model | Input | Context | $/1M in | $/1M out |
|
|
12
|
+
| --- | --- | --- | --- | --- |
|
|
13
|
+
| `morph-kimik3` — Kimi K3 | text | 1M | 2.50 | 14.00 |
|
|
14
|
+
| `morph-kimik3-fast` — Kimi K3 Fast | text | 1M | 6.00 | 22.50 |
|
|
15
|
+
| `morph-glm53-744b` — GLM-5.3 744B | text | 1M | 1.19 | 6.00 |
|
|
16
|
+
| `morph-glm53flash` — GLM-5.3 Flash | text, image | 1M | 0.20 | 0.70 |
|
|
17
|
+
| `morph-dsv41flash` — DeepSeek V4.1 Flash | text, image | 1M | 0.12 | 0.80 |
|
|
18
|
+
| `morph-dsv41flash-1017` — DeepSeek V4.1 Flash 1017 | text, image | 1M | 0.12 | 0.80 |
|
|
19
|
+
| `morph-dsv4flash` — DeepSeek V4 Flash 0731 | text | 1M | 0.14 | 0.40 |
|
|
20
|
+
|
|
21
|
+
Endpoint `https://api.morphllm.com/v1`, bearer auth, `api: "openai-completions"` — Pi's built-in implementation does the request, stream and tool-call plumbing, so the whole extension is one `pi.registerProvider` call with the catalog above. Prices are per 1M tokens from [morphllm.com/pricing](https://www.morphllm.com/pricing); `cacheWrite` is not billed. `service_tier: "standby"` halves the price on supported models — Pi can send it through `samplingParams`.
|
|
22
|
+
|
|
23
|
+
Pi's thinking levels map onto Morph's `reasoning_effort` ladder (`none | low | high | xhigh | max`). DeepSeek documents `none`, so `off` maps to it; for the other models `off` is marked unsupported (`null`) rather than sent.
|
|
24
|
+
|
|
25
|
+
## Not included
|
|
26
|
+
|
|
27
|
+
Morph's single-purpose models — Fast Apply (`morph-v3-fast`, `morph-v3-large`, `auto`), WarpGrep (`morph-warp-grep-v2.1`), Compact and the Router — take bespoke request shapes (XML-edit bodies, `POST /v1/code/apply`, `POST /v1/compact`) rather than chat completions, so they are not chat models and are left out. If they come back it will be as tools in this package, not as models.
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pnpm test # tsc --noEmit && node test.ts
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`test.ts` loads the extension with a fake Pi and checks every registered model: id, name, modalities, context/output limits, costs, uniqueness, and that every Pi thinking level is either mapped to a provider value or explicitly unsupported.
|
|
36
|
+
|
|
37
|
+
MIT licensed.
|
package/index.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Morph — open-weight coding models on an OpenAI-compatible API, plus specialized apply/grep/compact models.
|
|
2
|
+
// Base URL: https://api.morphllm.com/v1 · Auth: Authorization: Bearer <MORPH_API_KEY>.
|
|
3
|
+
// Docs: https://docs.morphllm.com · Models: https://docs.morphllm.com/sdk/components/fast-models
|
|
4
|
+
//
|
|
5
|
+
// This is a Pi provider extension: `pi.registerProvider` adds the endpoint and its model catalog, and Pi's
|
|
6
|
+
// built-in `openai-completions` implementation handles the request/stream/tool-call plumbing. Load it with
|
|
7
|
+
// `pi -e ./index.ts` or install the package (`pi install npm:@computesdk/pi-morph`).
|
|
8
|
+
//
|
|
9
|
+
// Only the general chat models are registered. Morph's single-purpose models — Fast Apply (`morph-v3-fast`,
|
|
10
|
+
// `morph-v3-large`, `auto`), WarpGrep (`morph-warp-grep-v2.1`), Compact and the Router — take bespoke request
|
|
11
|
+
// shapes and are not chat models, so they are left out. `service_tier: "standby"` halves the price on
|
|
12
|
+
// supported models; Pi can send it via `samplingParams` if you want it on.
|
|
13
|
+
//
|
|
14
|
+
// Prices are USD per 1M tokens from https://www.morphllm.com/pricing (live at /api/models/json). Update them
|
|
15
|
+
// there when they change.
|
|
16
|
+
|
|
17
|
+
import type { ExtensionAPI, ProviderModelConfig } from "@earendil-works/pi-coding-agent";
|
|
18
|
+
|
|
19
|
+
/** Pi's chat-model shape: the chat arm of the provider model union. */
|
|
20
|
+
type ChatModel = Extract<ProviderModelConfig, { type?: "chat" }>;
|
|
21
|
+
type ThinkingLevelMap = NonNullable<ChatModel["thinkingLevelMap"]>;
|
|
22
|
+
// Pi thinking levels (off/minimal/low/medium/high/xhigh/max) → the provider's `reasoning_effort` value.
|
|
23
|
+
// Morph documents the ladder for DeepSeek: none | low | high | xhigh | max (`medium`→high, `minimal`→low).
|
|
24
|
+
// For the other models `off` is not documented, so it is marked unsupported (`null`) rather than sent.
|
|
25
|
+
const EFFORT_DEEPSEEK: ThinkingLevelMap = { off: "none", minimal: "low", low: "low", medium: "high", high: "high", xhigh: "xhigh", max: "max" };
|
|
26
|
+
const EFFORT_OTHER: ThinkingLevelMap = { off: null, minimal: "low", low: "low", medium: "high", high: "high", xhigh: "high", max: "max" };
|
|
27
|
+
|
|
28
|
+
const CONTEXT = 1_048_576; // every Fast Model: 1M tokens
|
|
29
|
+
const MAX_TOKENS = 32_768; // conservative output cap; Morph does not publish a per-model ceiling
|
|
30
|
+
|
|
31
|
+
/** Prices are per 1M tokens; `cacheWrite` is not billed and is filled in below. */
|
|
32
|
+
type Cost = { input: number; output: number; cacheRead: number };
|
|
33
|
+
|
|
34
|
+
const model = (id: string, name: string, { input = ["text"], cost, effort = EFFORT_OTHER }: { input?: ("text" | "image")[]; cost: Cost; effort?: ThinkingLevelMap }): ChatModel => ({
|
|
35
|
+
type: "chat",
|
|
36
|
+
id,
|
|
37
|
+
name,
|
|
38
|
+
reasoning: true,
|
|
39
|
+
thinkingLevelMap: effort,
|
|
40
|
+
input,
|
|
41
|
+
cost: { cacheWrite: 0, ...cost },
|
|
42
|
+
contextWindow: CONTEXT,
|
|
43
|
+
maxTokens: MAX_TOKENS,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const MODELS: ChatModel[] = [
|
|
47
|
+
model("morph-kimik3", "Kimi K3", { cost: { input: 2.5, output: 14.0, cacheRead: 0.29 } }),
|
|
48
|
+
model("morph-kimik3-fast", "Kimi K3 Fast", { cost: { input: 6.0, output: 22.5, cacheRead: 0.6 } }),
|
|
49
|
+
model("morph-glm53-744b", "GLM-5.3 744B", { cost: { input: 1.19, output: 6.0, cacheRead: 0.1955 } }),
|
|
50
|
+
model("morph-glm53flash", "GLM-5.3 Flash", { input: ["text", "image"], cost: { input: 0.2, output: 0.7, cacheRead: 0.04 } }),
|
|
51
|
+
model("morph-dsv41flash", "DeepSeek V4.1 Flash", { input: ["text", "image"], effort: EFFORT_DEEPSEEK, cost: { input: 0.12, output: 0.8, cacheRead: 0.008 } }),
|
|
52
|
+
model("morph-dsv41flash-1017", "DeepSeek V4.1 Flash 1017", { input: ["text", "image"], effort: EFFORT_DEEPSEEK, cost: { input: 0.12, output: 0.8, cacheRead: 0.008 } }),
|
|
53
|
+
model("morph-dsv4flash", "DeepSeek V4 Flash 0731", { effort: EFFORT_DEEPSEEK, cost: { input: 0.141953125, output: 0.399625, cacheRead: 0.0359375 } }),
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export default function morphProvider(pi: ExtensionAPI) {
|
|
57
|
+
pi.registerProvider("morph", {
|
|
58
|
+
name: "Morph",
|
|
59
|
+
baseUrl: "https://api.morphllm.com/v1",
|
|
60
|
+
apiKey: "$MORPH_API_KEY",
|
|
61
|
+
api: "openai-completions",
|
|
62
|
+
models: MODELS,
|
|
63
|
+
});
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/pi-morph",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Morph provider for Pi: open-weight coding models (Kimi K3, GLM 5.3, DeepSeek V4) on Morph's OpenAI-compatible API.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"pi-extension",
|
|
9
|
+
"provider",
|
|
10
|
+
"morph",
|
|
11
|
+
"morphllm",
|
|
12
|
+
"openai-compatible"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/computesdk/pi-extensions.git",
|
|
19
|
+
"directory": "packages/pi-morph"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/computesdk/pi-extensions/tree/main/packages/pi-morph#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/computesdk/pi-extensions/issues"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.18.0"
|
|
30
|
+
},
|
|
31
|
+
"pi": {
|
|
32
|
+
"extensions": [
|
|
33
|
+
"./index.ts"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"index.ts",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"check": "tsc --noEmit",
|
|
43
|
+
"test": "tsc --noEmit && node test.ts"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@earendil-works/pi-coding-agent": "catalog:",
|
|
50
|
+
"@types/node": "catalog:",
|
|
51
|
+
"typescript": "catalog:"
|
|
52
|
+
}
|
|
53
|
+
}
|