@prismshadow/penguin-core 0.0.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.
- package/LICENSE +201 -0
- package/README.md +41 -0
- package/dist/chunk-FX4CCIN7.js +379 -0
- package/dist/chunk-FX4CCIN7.js.map +1 -0
- package/dist/chunk-HRIXWKKE.js +1 -0
- package/dist/chunk-HRIXWKKE.js.map +1 -0
- package/dist/chunk-JC6SC6KF.js +336 -0
- package/dist/chunk-JC6SC6KF.js.map +1 -0
- package/dist/index.d.ts +1462 -0
- package/dist/index.js +5187 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces-CMSN7-pO.d.ts +487 -0
- package/dist/interfaces.d.ts +2 -0
- package/dist/interfaces.js +2 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/model-catalog-DTu0IPjs.d.ts +266 -0
- package/dist/omnimessage/index.d.ts +110 -0
- package/dist/omnimessage/index.js +69 -0
- package/dist/omnimessage/index.js.map +1 -0
- package/dist/state/model-catalog.d.ts +1 -0
- package/dist/state/model-catalog.js +19 -0
- package/dist/state/model-catalog.js.map +1 -0
- package/dist/types-D6FERSdT.d.ts +293 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @prismshadow/penguin-core
|
|
2
|
+
|
|
3
|
+
The PenguinHarness SDK and execution engine: the ReAct loop (`context_engine`), the OmniMessage protocol, the LLM / Environment interface contracts, Agent State and append-only Traces.
|
|
4
|
+
|
|
5
|
+
The engine speaks only OmniMessage and delegates everything else through two swappable interfaces — `LLMInterface` (models, via the [`@prismshadow/agenthub`](https://www.npmjs.com/package/@prismshadow/agenthub) gateway) and `EnvironmentInterface` (tool execution). The SDK caller is the Human boundary: one entry point, `session.run`, streams the whole loop.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createAgent, isCompleteModelMessage, userText } from "@prismshadow/penguin-core";
|
|
9
|
+
|
|
10
|
+
const agent = await createAgent({ agentId: "default_agent" });
|
|
11
|
+
const session = await agent.createSession({ workspaceDir: process.cwd() });
|
|
12
|
+
|
|
13
|
+
for await (const output of session.run([userText("Create hello.txt containing hi")], {
|
|
14
|
+
approve: async () => "allow", // per-tool-call approval
|
|
15
|
+
})) {
|
|
16
|
+
if (isCompleteModelMessage(output) && output.payload.type === "text") {
|
|
17
|
+
console.log(output.payload.text);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
A single `run` drives a complete Task: streaming output, per-call approvals, concurrent tool execution, interrupt carry-over, automatic reconnect and context compaction. State lives under `~/.penguin/data` (`PENGUIN_HOME`); every Session restores fully from its Trace.
|
|
23
|
+
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
- [Architecture](https://penguin.ooo/docs/architecture)
|
|
27
|
+
- [The OmniMessage Protocol](https://penguin.ooo/docs/omni-message)
|
|
28
|
+
- [Core Interfaces](https://penguin.ooo/docs/interfaces)
|
|
29
|
+
- [The Agent Loop](https://penguin.ooo/docs/agent-loop)
|
|
30
|
+
- [Sessions & Traces](https://penguin.ooo/docs/sessions-and-traces)
|
|
31
|
+
|
|
32
|
+
## Development
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pnpm --filter @prismshadow/penguin-core build # tsup → dist/ (exports point at dist)
|
|
36
|
+
pnpm --filter @prismshadow/penguin-core typecheck
|
|
37
|
+
pnpm --filter @prismshadow/penguin-core test
|
|
38
|
+
pnpm test:e2e # live-model e2e (needs DEEPSEEK_API_KEY)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Part of [PenguinHarness](https://github.com/Prism-Shadow/penguin-harness) · Apache-2.0
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
// src/state/model-catalog.ts
|
|
2
|
+
var OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
3
|
+
var SILICONFLOW_BASE_URL = "https://api.siliconflow.cn/v1";
|
|
4
|
+
var MODEL_PROVIDERS = [
|
|
5
|
+
{
|
|
6
|
+
id: "deepseek",
|
|
7
|
+
label: "DeepSeek",
|
|
8
|
+
envKey: "DEEPSEEK_API_KEY",
|
|
9
|
+
envBaseUrlKey: "DEEPSEEK_BASE_URL",
|
|
10
|
+
apiKeyUrl: "https://platform.deepseek.com/api_keys",
|
|
11
|
+
modelsUrl: "https://api-docs.deepseek.com/quick_start/pricing"
|
|
12
|
+
},
|
|
13
|
+
// Gateways (their model ids can't be auto-routed by AgentHub, so they always use
|
|
14
|
+
// client_type=openai + a preset base URL): they go through AgentHub's OpenAI client, so when
|
|
15
|
+
// credential is blank the SDK reads **OPENAI_API_KEY / OPENAI_BASE_URL** (not the provider's
|
|
16
|
+
// own var names) - the env fallback hint must reflect that accurately.
|
|
17
|
+
{
|
|
18
|
+
id: "openrouter",
|
|
19
|
+
label: "OpenRouter",
|
|
20
|
+
envKey: "OPENAI_API_KEY",
|
|
21
|
+
envBaseUrlKey: "OPENAI_BASE_URL",
|
|
22
|
+
apiKeyUrl: "https://openrouter.ai/workspaces/default/keys",
|
|
23
|
+
modelsUrl: "https://openrouter.ai/models",
|
|
24
|
+
gatewayBaseUrl: OPENROUTER_BASE_URL
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "siliconflow",
|
|
28
|
+
label: "SiliconFlow",
|
|
29
|
+
envKey: "OPENAI_API_KEY",
|
|
30
|
+
envBaseUrlKey: "OPENAI_BASE_URL",
|
|
31
|
+
apiKeyUrl: "https://cloud.siliconflow.cn/me/account/ak",
|
|
32
|
+
modelsUrl: "https://cloud.siliconflow.cn/models",
|
|
33
|
+
gatewayBaseUrl: SILICONFLOW_BASE_URL
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "google",
|
|
37
|
+
label: "Google Gemini",
|
|
38
|
+
envKey: "GEMINI_API_KEY",
|
|
39
|
+
envBaseUrlKey: "GEMINI_BASE_URL",
|
|
40
|
+
apiKeyUrl: "https://aistudio.google.com/api-keys",
|
|
41
|
+
modelsUrl: "https://ai.google.dev/gemini-api/docs/models"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "anthropic",
|
|
45
|
+
label: "Anthropic",
|
|
46
|
+
envKey: "ANTHROPIC_API_KEY",
|
|
47
|
+
envBaseUrlKey: "ANTHROPIC_BASE_URL",
|
|
48
|
+
apiKeyUrl: "https://platform.claude.com/settings/keys",
|
|
49
|
+
modelsUrl: "https://docs.claude.com/en/docs/about-claude/models/overview"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: "openai",
|
|
53
|
+
label: "OpenAI",
|
|
54
|
+
envKey: "OPENAI_API_KEY",
|
|
55
|
+
envBaseUrlKey: "OPENAI_BASE_URL",
|
|
56
|
+
apiKeyUrl: "https://platform.openai.com/api-keys",
|
|
57
|
+
modelsUrl: "https://platform.openai.com/docs/models"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "zhipu",
|
|
61
|
+
label: "Z.AI (GLM)",
|
|
62
|
+
envKey: "ZAI_API_KEY",
|
|
63
|
+
envBaseUrlKey: "ZAI_BASE_URL",
|
|
64
|
+
apiKeyUrl: "https://open.bigmodel.cn/apikey/platform",
|
|
65
|
+
modelsUrl: "https://docs.z.ai/guides/overview/pricing"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "moonshot",
|
|
69
|
+
label: "Moonshot (Kimi)",
|
|
70
|
+
envKey: "MOONSHOT_API_KEY",
|
|
71
|
+
envBaseUrlKey: "MOONSHOT_BASE_URL",
|
|
72
|
+
apiKeyUrl: "https://platform.kimi.com/console/api-keys",
|
|
73
|
+
modelsUrl: "https://platform.kimi.com/docs/pricing"
|
|
74
|
+
},
|
|
75
|
+
{ id: "custom", label: "Custom", envKey: "OPENAI_API_KEY", envBaseUrlKey: "OPENAI_BASE_URL" }
|
|
76
|
+
];
|
|
77
|
+
function cny(cacheRead, cacheWrite, output) {
|
|
78
|
+
const r = (v) => Math.round(v / 7 * 1e6) / 1e6;
|
|
79
|
+
return usd(r(cacheRead), r(cacheWrite), r(output));
|
|
80
|
+
}
|
|
81
|
+
function usd(cacheRead, cacheWrite, output) {
|
|
82
|
+
return { unit: "usd_per_mtok", cache_read: cacheRead, cache_write: cacheWrite, output };
|
|
83
|
+
}
|
|
84
|
+
var MODEL_CATALOG = [
|
|
85
|
+
// -- DeepSeek (official CNY pricing: cache hit / cache miss / output) --
|
|
86
|
+
{
|
|
87
|
+
modelId: "deepseek-v4-pro",
|
|
88
|
+
displayName: "DeepSeek V4 Pro",
|
|
89
|
+
provider: "deepseek",
|
|
90
|
+
contextWindow: 1e6,
|
|
91
|
+
pricing: cny(0.025, 3, 6),
|
|
92
|
+
supportsVision: false
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
modelId: "deepseek-v4-flash",
|
|
96
|
+
displayName: "DeepSeek V4 Flash",
|
|
97
|
+
provider: "deepseek",
|
|
98
|
+
contextWindow: 1e6,
|
|
99
|
+
pricing: cny(0.02, 1, 2),
|
|
100
|
+
supportsVision: false
|
|
101
|
+
},
|
|
102
|
+
// —— Anthropic ——
|
|
103
|
+
{
|
|
104
|
+
modelId: "claude-opus-4-8",
|
|
105
|
+
displayName: "Claude Opus 4.8",
|
|
106
|
+
provider: "anthropic",
|
|
107
|
+
contextWindow: 1e6,
|
|
108
|
+
pricing: usd(0.5, 6.25, 25),
|
|
109
|
+
supportsVision: true
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
modelId: "claude-opus-4-7",
|
|
113
|
+
displayName: "Claude Opus 4.7",
|
|
114
|
+
provider: "anthropic",
|
|
115
|
+
contextWindow: 1e6,
|
|
116
|
+
pricing: usd(0.5, 6.25, 25),
|
|
117
|
+
supportsVision: true
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
modelId: "claude-sonnet-4-6",
|
|
121
|
+
displayName: "Claude Sonnet 4.6",
|
|
122
|
+
provider: "anthropic",
|
|
123
|
+
contextWindow: 1e6,
|
|
124
|
+
pricing: usd(0.3, 3.75, 15),
|
|
125
|
+
supportsVision: true
|
|
126
|
+
},
|
|
127
|
+
// —— OpenAI ——
|
|
128
|
+
{
|
|
129
|
+
modelId: "gpt-5.5",
|
|
130
|
+
displayName: "GPT-5.5",
|
|
131
|
+
provider: "openai",
|
|
132
|
+
contextWindow: 105e4,
|
|
133
|
+
pricing: usd(0.5, 5, 30),
|
|
134
|
+
supportsVision: true
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
// No official cache discount: cache_read uses the standard input price.
|
|
138
|
+
modelId: "gpt-5.5-pro",
|
|
139
|
+
displayName: "GPT-5.5 Pro",
|
|
140
|
+
provider: "openai",
|
|
141
|
+
contextWindow: 105e4,
|
|
142
|
+
pricing: usd(30, 30, 180),
|
|
143
|
+
supportsVision: true
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
modelId: "gpt-5.4",
|
|
147
|
+
displayName: "GPT-5.4",
|
|
148
|
+
provider: "openai",
|
|
149
|
+
contextWindow: 105e4,
|
|
150
|
+
pricing: usd(0.25, 2.5, 15),
|
|
151
|
+
supportsVision: true
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
modelId: "gpt-5.4-mini",
|
|
155
|
+
displayName: "GPT-5.4 mini",
|
|
156
|
+
provider: "openai",
|
|
157
|
+
contextWindow: 4e5,
|
|
158
|
+
pricing: usd(0.075, 0.75, 4.5),
|
|
159
|
+
supportsVision: true
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
modelId: "gpt-5.4-nano",
|
|
163
|
+
displayName: "GPT-5.4 nano",
|
|
164
|
+
provider: "openai",
|
|
165
|
+
contextWindow: 4e5,
|
|
166
|
+
pricing: usd(0.02, 0.2, 1.25),
|
|
167
|
+
supportsVision: true
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
// No official cache discount: cache_read uses the standard input price.
|
|
171
|
+
modelId: "gpt-5.4-pro",
|
|
172
|
+
displayName: "GPT-5.4 Pro",
|
|
173
|
+
provider: "openai",
|
|
174
|
+
contextWindow: 105e4,
|
|
175
|
+
pricing: usd(30, 30, 180),
|
|
176
|
+
supportsVision: true
|
|
177
|
+
},
|
|
178
|
+
// —— Google Gemini ——
|
|
179
|
+
{
|
|
180
|
+
// ≤200K input tier; >200K has official surcharge pricing (see file header comment).
|
|
181
|
+
modelId: "gemini-3.1-pro-preview",
|
|
182
|
+
displayName: "Gemini 3.1 Pro (Preview)",
|
|
183
|
+
provider: "google",
|
|
184
|
+
contextWindow: 1048576,
|
|
185
|
+
pricing: usd(0.2, 2, 12),
|
|
186
|
+
supportsVision: true
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
modelId: "gemini-3.5-flash",
|
|
190
|
+
displayName: "Gemini 3.5 Flash",
|
|
191
|
+
provider: "google",
|
|
192
|
+
contextWindow: 1048576,
|
|
193
|
+
pricing: usd(0.15, 1.5, 9),
|
|
194
|
+
supportsVision: true
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
modelId: "gemini-3-flash-preview",
|
|
198
|
+
displayName: "Gemini 3 Flash (Preview)",
|
|
199
|
+
provider: "google",
|
|
200
|
+
contextWindow: 1048576,
|
|
201
|
+
pricing: usd(0.05, 0.5, 3),
|
|
202
|
+
supportsVision: true
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
modelId: "gemini-3.1-flash-lite",
|
|
206
|
+
displayName: "Gemini 3.1 Flash-Lite",
|
|
207
|
+
provider: "google",
|
|
208
|
+
contextWindow: 1048576,
|
|
209
|
+
pricing: usd(0.025, 0.25, 1.5),
|
|
210
|
+
supportsVision: true
|
|
211
|
+
},
|
|
212
|
+
// —— Z.AI (GLM) ——
|
|
213
|
+
{
|
|
214
|
+
modelId: "glm-5.2",
|
|
215
|
+
displayName: "GLM-5.2",
|
|
216
|
+
provider: "zhipu",
|
|
217
|
+
contextWindow: 1e6,
|
|
218
|
+
pricing: usd(0.26, 1.4, 4.4),
|
|
219
|
+
supportsVision: false
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
modelId: "glm-5.1",
|
|
223
|
+
displayName: "GLM-5.1",
|
|
224
|
+
provider: "zhipu",
|
|
225
|
+
contextWindow: 2e5,
|
|
226
|
+
pricing: usd(0.26, 1.4, 4.4),
|
|
227
|
+
supportsVision: false
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
modelId: "glm-5",
|
|
231
|
+
displayName: "GLM-5",
|
|
232
|
+
provider: "zhipu",
|
|
233
|
+
contextWindow: 2e5,
|
|
234
|
+
pricing: usd(0.2, 1, 3.2),
|
|
235
|
+
supportsVision: false
|
|
236
|
+
},
|
|
237
|
+
// -- Moonshot (Kimi) (official CNY pricing) --
|
|
238
|
+
{
|
|
239
|
+
modelId: "kimi-k2.6",
|
|
240
|
+
displayName: "Kimi K2.6",
|
|
241
|
+
provider: "moonshot",
|
|
242
|
+
contextWindow: 262144,
|
|
243
|
+
pricing: cny(1.1, 6.5, 27),
|
|
244
|
+
supportsVision: true
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
modelId: "kimi-k2.5",
|
|
248
|
+
displayName: "Kimi K2.5",
|
|
249
|
+
provider: "moonshot",
|
|
250
|
+
contextWindow: 262144,
|
|
251
|
+
pricing: cny(0.7, 4, 21),
|
|
252
|
+
supportsVision: true
|
|
253
|
+
},
|
|
254
|
+
// -- OpenRouter (gateway: uses OpenAI-compatible protocol, preset base URL) --
|
|
255
|
+
{
|
|
256
|
+
modelId: "xiaomi/mimo-v2.5",
|
|
257
|
+
displayName: "MiMo-V2.5",
|
|
258
|
+
provider: "openrouter",
|
|
259
|
+
contextWindow: 1048576,
|
|
260
|
+
pricing: usd(28e-4, 0.14, 0.28),
|
|
261
|
+
supportsVision: true,
|
|
262
|
+
clientType: "openai",
|
|
263
|
+
baseUrl: OPENROUTER_BASE_URL
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
modelId: "tencent/hy3",
|
|
267
|
+
displayName: "Hy3",
|
|
268
|
+
provider: "openrouter",
|
|
269
|
+
contextWindow: 262144,
|
|
270
|
+
pricing: usd(0.035, 0.14, 0.58),
|
|
271
|
+
supportsVision: false,
|
|
272
|
+
clientType: "openai",
|
|
273
|
+
baseUrl: OPENROUTER_BASE_URL
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
// No official separate cache price published: cache_read uses the standard input price (no discount assumed).
|
|
277
|
+
modelId: "minimax/minimax-m3",
|
|
278
|
+
displayName: "MiniMax M3",
|
|
279
|
+
provider: "openrouter",
|
|
280
|
+
contextWindow: 1048576,
|
|
281
|
+
pricing: usd(0.06, 0.3, 1.2),
|
|
282
|
+
supportsVision: true,
|
|
283
|
+
clientType: "openai",
|
|
284
|
+
baseUrl: OPENROUTER_BASE_URL
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
// No official separate cache price published: cache_read uses the standard input price.
|
|
288
|
+
modelId: "stepfun/step-3.7-flash",
|
|
289
|
+
displayName: "Step 3.7 Flash",
|
|
290
|
+
provider: "openrouter",
|
|
291
|
+
contextWindow: 256e3,
|
|
292
|
+
pricing: usd(0.04, 0.2, 1.15),
|
|
293
|
+
supportsVision: true,
|
|
294
|
+
clientType: "openai",
|
|
295
|
+
baseUrl: OPENROUTER_BASE_URL
|
|
296
|
+
},
|
|
297
|
+
// -- SiliconFlow (gateway, official CNY pricing: cache hit / input / output) --
|
|
298
|
+
{
|
|
299
|
+
modelId: "zai-org/GLM-5.2",
|
|
300
|
+
displayName: "GLM-5.2",
|
|
301
|
+
provider: "siliconflow",
|
|
302
|
+
contextWindow: 1e6,
|
|
303
|
+
pricing: cny(2, 8, 28),
|
|
304
|
+
supportsVision: false,
|
|
305
|
+
clientType: "openai",
|
|
306
|
+
baseUrl: SILICONFLOW_BASE_URL
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
modelId: "deepseek-ai/DeepSeek-V4-Pro",
|
|
310
|
+
displayName: "DeepSeek V4 Pro",
|
|
311
|
+
provider: "siliconflow",
|
|
312
|
+
contextWindow: 1e6,
|
|
313
|
+
pricing: cny(0.1, 12, 24),
|
|
314
|
+
supportsVision: false,
|
|
315
|
+
clientType: "openai",
|
|
316
|
+
baseUrl: SILICONFLOW_BASE_URL
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
modelId: "meituan-longcat/LongCat-2.0",
|
|
320
|
+
displayName: "LongCat 2.0",
|
|
321
|
+
provider: "siliconflow",
|
|
322
|
+
contextWindow: 1e6,
|
|
323
|
+
pricing: cny(0.1, 5, 20),
|
|
324
|
+
supportsVision: false,
|
|
325
|
+
clientType: "openai",
|
|
326
|
+
baseUrl: SILICONFLOW_BASE_URL
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
function catalogEntryFor(provider, upstreamId) {
|
|
330
|
+
return MODEL_CATALOG.find((m) => m.provider === provider && m.modelId === upstreamId);
|
|
331
|
+
}
|
|
332
|
+
function inferProviderForUpstream(upstreamId) {
|
|
333
|
+
return MODEL_CATALOG.find((m) => m.modelId === upstreamId)?.provider ?? "custom";
|
|
334
|
+
}
|
|
335
|
+
function providerInfo(providerId) {
|
|
336
|
+
return MODEL_PROVIDERS.find((p) => p.id === providerId);
|
|
337
|
+
}
|
|
338
|
+
function resolveModelEnv(modelId, clientType) {
|
|
339
|
+
const t = (clientType || modelId).toLowerCase();
|
|
340
|
+
const env = (prefix) => ({
|
|
341
|
+
envKey: `${prefix}_API_KEY`,
|
|
342
|
+
envBaseUrlKey: `${prefix}_BASE_URL`
|
|
343
|
+
});
|
|
344
|
+
if (t.includes("gemini-3") || t.includes("gemini-embedding")) return env("GEMINI");
|
|
345
|
+
if (t.includes("claude") && (t.includes("4-7") || t.includes("4-8") || t.includes("-5") || t.includes("4-6"))) {
|
|
346
|
+
return env("ANTHROPIC");
|
|
347
|
+
}
|
|
348
|
+
if (t.includes("gpt-5.4") || t.includes("gpt-5.5")) return env("OPENAI");
|
|
349
|
+
if (t.includes("glm-5")) return env("ZAI");
|
|
350
|
+
if (t.includes("kimi-k2.5") || t.includes("kimi-k2.6")) return env("MOONSHOT");
|
|
351
|
+
if (t.includes("deepseek-v4")) return env("DEEPSEEK");
|
|
352
|
+
if (t.includes("openai")) return env("OPENAI");
|
|
353
|
+
return void 0;
|
|
354
|
+
}
|
|
355
|
+
function presetModelEntries() {
|
|
356
|
+
return MODEL_CATALOG.map((m) => ({
|
|
357
|
+
provider: m.provider,
|
|
358
|
+
model_id: m.modelId,
|
|
359
|
+
...m.contextWindow !== void 0 ? { context_window: m.contextWindow } : {},
|
|
360
|
+
...m.clientType !== void 0 ? { client_type: m.clientType } : {},
|
|
361
|
+
...m.pricing ? { pricing: { ...m.pricing } } : {},
|
|
362
|
+
// ModelEntry.vision defaults to supported: only models that don't support images
|
|
363
|
+
// explicitly persist false (drives the read_image / describe_image choice and input
|
|
364
|
+
// image hand-off, see project-config.ts).
|
|
365
|
+
...m.supportsVision ? {} : { vision: false },
|
|
366
|
+
...m.baseUrl !== void 0 ? { base_url: m.baseUrl } : {}
|
|
367
|
+
}));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
export {
|
|
371
|
+
MODEL_PROVIDERS,
|
|
372
|
+
MODEL_CATALOG,
|
|
373
|
+
catalogEntryFor,
|
|
374
|
+
inferProviderForUpstream,
|
|
375
|
+
providerInfo,
|
|
376
|
+
resolveModelEnv,
|
|
377
|
+
presetModelEntries
|
|
378
|
+
};
|
|
379
|
+
//# sourceMappingURL=chunk-FX4CCIN7.js.map
|