trinity-config 1.2.3 → 1.2.4
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/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import pc from "picocolors";
|
|
|
5
5
|
|
|
6
6
|
// src/constants.ts
|
|
7
7
|
var PACKAGE_NAME = "trinity-config";
|
|
8
|
-
var PACKAGE_VERSION = "1.2.
|
|
8
|
+
var PACKAGE_VERSION = "1.2.4";
|
|
9
9
|
var TRINITY_BASE_URL = "https://api.trinitydesk.ai";
|
|
10
10
|
var DEFAULT_CLAUDE_MODEL = "claude-sonnet-4-6";
|
|
11
11
|
var DEFAULT_CLAUDE_FAST_MODEL = "claude-sonnet-4-6";
|
|
@@ -442,7 +442,7 @@ async function configureOpenClaw(apiKey, openClawBaseUrl, model, modelIds, proto
|
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
async function configureZCode(apiKey, zcodeBaseUrl, model, modelIds, protocol) {
|
|
445
|
-
const { configureZCodeDirect } = await import("./merge-zcode-config-
|
|
445
|
+
const { configureZCodeDirect } = await import("./merge-zcode-config-PTPY6RXN.js");
|
|
446
446
|
return configureZCodeDirect({
|
|
447
447
|
apiKey,
|
|
448
448
|
baseUrl: zcodeBaseUrl,
|
|
@@ -19,6 +19,38 @@ function zcodeConfigPath() {
|
|
|
19
19
|
}
|
|
20
20
|
return path.join(zcodeHome(), "v2", "config.json");
|
|
21
21
|
}
|
|
22
|
+
function zcodeProtocolBinding(protocol = "chat_completions") {
|
|
23
|
+
switch (protocol) {
|
|
24
|
+
case "anthropic_messages":
|
|
25
|
+
return {
|
|
26
|
+
kind: "anthropic",
|
|
27
|
+
apiFormat: "anthropic-messages",
|
|
28
|
+
npm: "@ai-sdk/anthropic",
|
|
29
|
+
modelFormat: "anthropic",
|
|
30
|
+
pathKey: "anthropic",
|
|
31
|
+
pathSuffix: "/v1/messages"
|
|
32
|
+
};
|
|
33
|
+
case "responses":
|
|
34
|
+
return {
|
|
35
|
+
kind: "openai",
|
|
36
|
+
apiFormat: "openai-responses",
|
|
37
|
+
npm: "@ai-sdk/openai",
|
|
38
|
+
modelFormat: "responses",
|
|
39
|
+
pathKey: "openai",
|
|
40
|
+
pathSuffix: "/responses"
|
|
41
|
+
};
|
|
42
|
+
case "chat_completions":
|
|
43
|
+
default:
|
|
44
|
+
return {
|
|
45
|
+
kind: "openai-compatible",
|
|
46
|
+
apiFormat: "openai-chat-completions",
|
|
47
|
+
npm: "@ai-sdk/openai-compatible",
|
|
48
|
+
modelFormat: "openai",
|
|
49
|
+
pathKey: "openai-compatible",
|
|
50
|
+
pathSuffix: "/chat/completions"
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
22
54
|
function timestampLabel() {
|
|
23
55
|
const now = /* @__PURE__ */ new Date();
|
|
24
56
|
const pad = (n) => String(n).padStart(2, "0");
|
|
@@ -47,13 +79,24 @@ function readZCodeConfig() {
|
|
|
47
79
|
throw new Error(`\u65E0\u6CD5\u89E3\u6790 ${configPath}\uFF0C\u8BF7\u68C0\u67E5 JSON \u8BED\u6CD5\u540E\u91CD\u8BD5\u3002`);
|
|
48
80
|
}
|
|
49
81
|
}
|
|
50
|
-
function buildModels(primary, modelIds) {
|
|
82
|
+
function buildModels(primary, modelIds, binding) {
|
|
51
83
|
const models = {};
|
|
52
84
|
for (const id of filterTextModelIds(primary, modelIds)) {
|
|
53
|
-
models[id] = {
|
|
85
|
+
models[id] = {
|
|
86
|
+
name: id,
|
|
87
|
+
kinds: [binding.kind],
|
|
88
|
+
defaultKind: binding.kind
|
|
89
|
+
};
|
|
54
90
|
}
|
|
55
91
|
return models;
|
|
56
92
|
}
|
|
93
|
+
function buildModelSupportedFormats(primary, modelIds, modelFormat) {
|
|
94
|
+
const out = {};
|
|
95
|
+
for (const id of filterTextModelIds(primary, modelIds)) {
|
|
96
|
+
out[id] = [modelFormat];
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
57
100
|
function mergeZCodeConfig(options) {
|
|
58
101
|
const configPath = zcodeConfigPath();
|
|
59
102
|
const doc = readZCodeConfig();
|
|
@@ -69,22 +112,46 @@ function mergeZCodeConfig(options) {
|
|
|
69
112
|
const root = options.baseUrl.replace(/\/v1\/?$/, "").replace(/\/+$/, "");
|
|
70
113
|
const withV1 = `${root}/v1`;
|
|
71
114
|
const withoutV1 = root;
|
|
115
|
+
const binding = zcodeProtocolBinding(options.protocol);
|
|
72
116
|
const primaryBase = options.protocol === "anthropic_messages" ? withoutV1 : withV1;
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
const models = {
|
|
119
|
+
...existingModels,
|
|
120
|
+
...buildModels(options.model, options.modelIds, binding)
|
|
121
|
+
};
|
|
73
122
|
providers[TRINITY_ZCODE_PROVIDER] = {
|
|
74
123
|
...existing,
|
|
75
124
|
enabled: true,
|
|
76
125
|
name: "Trinity",
|
|
126
|
+
source: "custom",
|
|
127
|
+
kind: binding.kind,
|
|
128
|
+
defaultKind: binding.kind,
|
|
129
|
+
apiFormat: binding.apiFormat,
|
|
130
|
+
npm: binding.npm,
|
|
131
|
+
endpoints: {
|
|
132
|
+
anthropic: withoutV1,
|
|
133
|
+
openai: withV1,
|
|
134
|
+
baseURL: primaryBase,
|
|
135
|
+
paths: {
|
|
136
|
+
anthropic: "/v1/messages",
|
|
137
|
+
openai: "/responses",
|
|
138
|
+
"openai-compatible": "/chat/completions",
|
|
139
|
+
[binding.pathKey]: binding.pathSuffix
|
|
140
|
+
}
|
|
141
|
+
},
|
|
77
142
|
options: {
|
|
78
143
|
...existing.options ?? {},
|
|
79
144
|
baseURL: primaryBase,
|
|
80
|
-
apiKey: options.apiKey
|
|
81
|
-
openaiBaseURL: withV1,
|
|
82
|
-
anthropicBaseURL: withoutV1
|
|
145
|
+
apiKey: options.apiKey
|
|
83
146
|
},
|
|
84
|
-
models
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
147
|
+
models,
|
|
148
|
+
modelSupportedFormats: buildModelSupportedFormats(
|
|
149
|
+
options.model,
|
|
150
|
+
options.modelIds,
|
|
151
|
+
binding.modelFormat
|
|
152
|
+
),
|
|
153
|
+
createdAt: typeof existing.createdAt === "number" ? existing.createdAt : now,
|
|
154
|
+
updatedAt: now
|
|
88
155
|
};
|
|
89
156
|
doc.provider = providers;
|
|
90
157
|
doc.model = `${TRINITY_ZCODE_PROVIDER}/${options.model}`;
|
|
@@ -103,5 +170,6 @@ export {
|
|
|
103
170
|
configureZCodeDirect,
|
|
104
171
|
mergeZCodeConfig,
|
|
105
172
|
zcodeConfigPath,
|
|
106
|
-
zcodeHome
|
|
173
|
+
zcodeHome,
|
|
174
|
+
zcodeProtocolBinding
|
|
107
175
|
};
|