@cremini/skillpack 1.2.5-beta.1 → 1.2.6
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 -0
- package/dist/cli.js +65 -5
- package/package.json +2 -1
- package/templates/builtin-skills/skill-creator/SKILL.md +25 -99
- package/templates/start.bat +1 -1
- package/templates/start.sh +1 -1
- package/web/index.html +13 -0
- package/web/js/api-key-dialog.js +42 -0
package/README.md
CHANGED
|
@@ -126,6 +126,10 @@ The main use case is to **run local agents on your computer and integrate them w
|
|
|
126
126
|
|
|
127
127
|
Download [Company Deep Research](https://github.com/FinpeakInc/downloads/releases/download/v.0.0.1/Company-Deep-Research.zip) and try it! More examples can be found at [skillpack.sh](https://skillpack.sh)
|
|
128
128
|
|
|
129
|
+
## Questions?
|
|
130
|
+
|
|
131
|
+
Join our Discord at https://discord.gg/nj8Br4ePJc
|
|
132
|
+
|
|
129
133
|
## License
|
|
130
134
|
|
|
131
135
|
MIT
|
package/dist/cli.js
CHANGED
|
@@ -107,6 +107,12 @@ var init_config = __esm({
|
|
|
107
107
|
if (updates.baseUrl !== void 0) {
|
|
108
108
|
this.configData.baseUrl = updates.baseUrl?.trim() || void 0;
|
|
109
109
|
}
|
|
110
|
+
if (updates.modelId !== void 0) {
|
|
111
|
+
this.configData.modelId = updates.modelId?.trim() || void 0;
|
|
112
|
+
}
|
|
113
|
+
if (updates.apiProtocol !== void 0) {
|
|
114
|
+
this.configData.apiProtocol = updates.apiProtocol || void 0;
|
|
115
|
+
}
|
|
110
116
|
if (updates.adapters !== void 0) {
|
|
111
117
|
const merged = { ...this.configData.adapters || {} };
|
|
112
118
|
for (const [adapterKey, adapterVal] of Object.entries(updates.adapters)) {
|
|
@@ -5598,10 +5604,30 @@ var PackAgent = class {
|
|
|
5598
5604
|
const { rootDir, provider, modelId, baseUrl } = this.options;
|
|
5599
5605
|
const authStorage = this.authStorage;
|
|
5600
5606
|
const modelRegistry = new ModelRegistry(authStorage);
|
|
5607
|
+
if (baseUrl && modelId) {
|
|
5608
|
+
const apiProtocol = this.options.apiProtocol ?? "openai-completions";
|
|
5609
|
+
log(`[PackAgent] Registering custom model ${provider}/${modelId} api=${apiProtocol} baseUrl=${baseUrl}`);
|
|
5610
|
+
modelRegistry.registerProvider(provider, {
|
|
5611
|
+
baseUrl,
|
|
5612
|
+
apiKey: this.options.apiKey,
|
|
5613
|
+
models: [
|
|
5614
|
+
{
|
|
5615
|
+
id: modelId,
|
|
5616
|
+
name: modelId,
|
|
5617
|
+
api: apiProtocol,
|
|
5618
|
+
reasoning: false,
|
|
5619
|
+
input: ["text"],
|
|
5620
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
5621
|
+
contextWindow: 128e3,
|
|
5622
|
+
maxTokens: 4096
|
|
5623
|
+
}
|
|
5624
|
+
]
|
|
5625
|
+
});
|
|
5626
|
+
}
|
|
5601
5627
|
const resolvedModel = modelRegistry.find(provider, modelId);
|
|
5602
|
-
const model = resolvedModel && baseUrl ? { ...resolvedModel, baseUrl } : resolvedModel;
|
|
5628
|
+
const model = resolvedModel && baseUrl && !this.options.apiProtocol ? { ...resolvedModel, baseUrl } : resolvedModel;
|
|
5603
5629
|
if (resolvedModel && baseUrl) {
|
|
5604
|
-
log(`[PackAgent]
|
|
5630
|
+
log(`[PackAgent] Resolved ${provider}/${modelId} api=${resolvedModel.api} baseUrl=${baseUrl}`);
|
|
5605
5631
|
}
|
|
5606
5632
|
const sessionDir = path9.resolve(
|
|
5607
5633
|
rootDir,
|
|
@@ -5895,6 +5921,8 @@ function getRuntimeConfigSignature(config) {
|
|
|
5895
5921
|
apiKey: config.apiKey || "",
|
|
5896
5922
|
provider: config.provider || "openai",
|
|
5897
5923
|
baseUrl: config.baseUrl || "",
|
|
5924
|
+
modelId: config.modelId || "",
|
|
5925
|
+
apiProtocol: config.apiProtocol || "",
|
|
5898
5926
|
telegramToken: config.adapters?.telegram?.token || "",
|
|
5899
5927
|
slackBotToken: config.adapters?.slack?.botToken || "",
|
|
5900
5928
|
slackAppToken: config.adapters?.slack?.appToken || ""
|
|
@@ -5927,6 +5955,8 @@ var WebAdapter = class {
|
|
|
5927
5955
|
apiKey: conf.apiKey || "",
|
|
5928
5956
|
provider: currentProvider2,
|
|
5929
5957
|
baseUrl: conf.baseUrl || "",
|
|
5958
|
+
modelId: conf.modelId || "",
|
|
5959
|
+
apiProtocol: conf.apiProtocol || "",
|
|
5930
5960
|
adapters: conf.adapters || {},
|
|
5931
5961
|
supportedProviders: SUPPORTED_PROVIDERS,
|
|
5932
5962
|
oauthConnected
|
|
@@ -5937,7 +5967,7 @@ var WebAdapter = class {
|
|
|
5937
5967
|
res.json(config.skills || []);
|
|
5938
5968
|
});
|
|
5939
5969
|
app.post("/api/config/update", (req, res) => {
|
|
5940
|
-
const { key, provider, baseUrl, adapters } = req.body;
|
|
5970
|
+
const { key, provider, baseUrl, modelId, apiProtocol, adapters } = req.body;
|
|
5941
5971
|
const updates = {};
|
|
5942
5972
|
const beforeConfig = JSON.parse(JSON.stringify(configManager.getConfig()));
|
|
5943
5973
|
if (key !== void 0) {
|
|
@@ -5951,6 +5981,12 @@ var WebAdapter = class {
|
|
|
5951
5981
|
if (baseUrl !== void 0) {
|
|
5952
5982
|
updates.baseUrl = baseUrl;
|
|
5953
5983
|
}
|
|
5984
|
+
if (modelId !== void 0) {
|
|
5985
|
+
updates.modelId = modelId;
|
|
5986
|
+
}
|
|
5987
|
+
if (apiProtocol !== void 0) {
|
|
5988
|
+
updates.apiProtocol = apiProtocol;
|
|
5989
|
+
}
|
|
5954
5990
|
if (adapters !== void 0) {
|
|
5955
5991
|
updates.adapters = adapters;
|
|
5956
5992
|
}
|
|
@@ -6347,6 +6383,7 @@ var IpcAdapter = class {
|
|
|
6347
6383
|
rootDir = "";
|
|
6348
6384
|
adapterMap = null;
|
|
6349
6385
|
conversationService = null;
|
|
6386
|
+
createdChannels = /* @__PURE__ */ new Set();
|
|
6350
6387
|
messageListener;
|
|
6351
6388
|
started = false;
|
|
6352
6389
|
async start(ctx) {
|
|
@@ -6412,10 +6449,19 @@ var IpcAdapter = class {
|
|
|
6412
6449
|
switch (request.type) {
|
|
6413
6450
|
case "get_conversations": {
|
|
6414
6451
|
const activeChannels = new Set(this.agent.getActiveChannelIds());
|
|
6452
|
+
for (const channelId of this.createdChannels) {
|
|
6453
|
+
activeChannels.add(channelId);
|
|
6454
|
+
}
|
|
6415
6455
|
const conversations = this.conversationService.listConversations(activeChannels);
|
|
6416
6456
|
this.reply(request.id, conversations);
|
|
6417
6457
|
return;
|
|
6418
6458
|
}
|
|
6459
|
+
case "create_conversation": {
|
|
6460
|
+
const channelId = `web-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
6461
|
+
this.createdChannels.add(channelId);
|
|
6462
|
+
this.reply(request.id, { channelId });
|
|
6463
|
+
return;
|
|
6464
|
+
}
|
|
6419
6465
|
case "get_messages": {
|
|
6420
6466
|
if (!request.channelId || typeof request.channelId !== "string") {
|
|
6421
6467
|
this.replyError(request.id, "channelId is required");
|
|
@@ -6438,6 +6484,7 @@ var IpcAdapter = class {
|
|
|
6438
6484
|
return;
|
|
6439
6485
|
}
|
|
6440
6486
|
const platform = this.detectPlatform(request.channelId);
|
|
6487
|
+
this.createdChannels.add(request.channelId);
|
|
6441
6488
|
let fullText = "";
|
|
6442
6489
|
const result = await this.agent.handleMessage(
|
|
6443
6490
|
platform,
|
|
@@ -6802,7 +6849,8 @@ async function startServer(options) {
|
|
|
6802
6849
|
const canonicalRootDir = canonicalizeDir(rootDir);
|
|
6803
6850
|
const packConfig = loadConfig(canonicalRootDir);
|
|
6804
6851
|
const baseUrl = dataConfig.baseUrl?.trim() || void 0;
|
|
6805
|
-
const modelId = SUPPORTED_PROVIDERS[provider]?.defaultModelId ?? SUPPORTED_PROVIDERS.openai.defaultModelId;
|
|
6852
|
+
const modelId = dataConfig.modelId?.trim() || (SUPPORTED_PROVIDERS[provider]?.defaultModelId ?? SUPPORTED_PROVIDERS.openai.defaultModelId);
|
|
6853
|
+
const apiProtocol = dataConfig.apiProtocol;
|
|
6806
6854
|
const packageRoot = path14.resolve(__dirname, "..");
|
|
6807
6855
|
const webDir = fs15.existsSync(path14.join(rootDir, "web")) ? path14.join(rootDir, "web") : path14.join(packageRoot, "web");
|
|
6808
6856
|
const app = express();
|
|
@@ -6828,6 +6876,7 @@ async function startServer(options) {
|
|
|
6828
6876
|
provider,
|
|
6829
6877
|
modelId,
|
|
6830
6878
|
baseUrl,
|
|
6879
|
+
apiProtocol,
|
|
6831
6880
|
lifecycleHandler: lifecycle
|
|
6832
6881
|
});
|
|
6833
6882
|
const adapters = [];
|
|
@@ -7076,10 +7125,13 @@ async function runCommand(directory) {
|
|
|
7076
7125
|
|
|
7077
7126
|
// src/cli.ts
|
|
7078
7127
|
import fs17 from "fs";
|
|
7128
|
+
import path16 from "path";
|
|
7129
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
7079
7130
|
var packageJson = JSON.parse(
|
|
7080
7131
|
fs17.readFileSync(new URL("../package.json", import.meta.url), "utf-8")
|
|
7081
7132
|
);
|
|
7082
7133
|
var program = new Command();
|
|
7134
|
+
var cliFilePath = path16.resolve(fileURLToPath3(import.meta.url));
|
|
7083
7135
|
program.name("skillpack").description("Assemble, package, and run Agent Skills packs").version(packageJson.version);
|
|
7084
7136
|
program.command("create [directory]").description("Create a skills pack interactively").option("--config <path-or-url>", "Initialize from a local or remote skillpack.json").action(async (directory, options) => {
|
|
7085
7137
|
await createCommand(directory, options);
|
|
@@ -7097,4 +7149,12 @@ program.command("zip").description("Package the current pack as a zip file (skil
|
|
|
7097
7149
|
process.exit(1);
|
|
7098
7150
|
}
|
|
7099
7151
|
});
|
|
7100
|
-
|
|
7152
|
+
function normalizeUserArgs(argv) {
|
|
7153
|
+
if (argv.length === 0) return argv;
|
|
7154
|
+
const firstArg = argv[0];
|
|
7155
|
+
if (firstArg && path16.resolve(firstArg) === cliFilePath) {
|
|
7156
|
+
return argv.slice(1);
|
|
7157
|
+
}
|
|
7158
|
+
return argv;
|
|
7159
|
+
}
|
|
7160
|
+
program.parse(normalizeUserArgs(process.argv.slice(2)), { from: "user" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cremini/skillpack",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Pack AI Skills into Local Agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"dev": "tsup --watch",
|
|
30
30
|
"check": "tsc --noEmit",
|
|
31
31
|
"format": "prettier --write .",
|
|
32
|
+
"prepare": "npm run build",
|
|
32
33
|
"create": "tsup && node dist/cli.js create",
|
|
33
34
|
"run": "tsup && node dist/cli.js run",
|
|
34
35
|
"zip": "tsup && node dist/cli.js zip"
|
|
@@ -5,106 +5,55 @@ description: Create new skills, modify and improve existing skills, and measure
|
|
|
5
5
|
|
|
6
6
|
# Skill Creator
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
At a high level, the process of creating a skill goes like this:
|
|
11
|
-
|
|
12
|
-
- Decide what the skill should do and when it should trigger.
|
|
13
|
-
- Write a draft of the skill.
|
|
14
|
-
- Create a few realistic test prompts.
|
|
15
|
-
- Run the tests, review the results with the user, and improve the skill.
|
|
16
|
-
- Repeat until the skill is good enough for the user's needs.
|
|
17
|
-
|
|
18
|
-
Your job when using this skill is to figure out where the user is in this process and help them move forward without overcomplicating things.
|
|
19
|
-
|
|
20
|
-
## Communicating with the user
|
|
21
|
-
|
|
22
|
-
Adjust your language to the user's level of familiarity. Avoid unnecessary jargon. Briefly explain terms like "frontmatter", "assertion", or "benchmark" if the user does not appear comfortable with them.
|
|
23
|
-
|
|
24
|
-
If the user clearly wants a lightweight collaboration rather than a full evaluation loop, keep things simple and iterate directly with them.
|
|
8
|
+
Create new skills and iteratively improve them inside this SkillPack. Determine where the user is in the create → draft → test → improve cycle and help them move forward.
|
|
25
9
|
|
|
26
10
|
## Pack-specific rules
|
|
27
11
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- Skills directory: `{{SKILLS_PATH}}`
|
|
31
|
-
- SkillPack config: `{{PACK_CONFIG_PATH}}`
|
|
32
|
-
|
|
33
|
-
These paths override any generic advice you may know from other environments.
|
|
34
|
-
|
|
35
|
-
When creating or updating skills in this SkillPack:
|
|
36
|
-
|
|
37
|
-
- Always place the skill under `{{SKILLS_PATH}}/<skill-name>/`.
|
|
38
|
-
- Always write the main skill file to `{{SKILLS_PATH}}/<skill-name>/SKILL.md`.
|
|
39
|
-
- Treat `skill-name` as the canonical directory name unless the user explicitly asks to preserve an existing directory layout.
|
|
40
|
-
- Never create new skills inside the current workspace directory just because the active cwd is elsewhere.
|
|
12
|
+
All skills live under `{{SKILLS_PATH}}/<skill-name>/SKILL.md` and config is at `{{PACK_CONFIG_PATH}}`. These paths override any generic advice. Never create skills in the current workspace directory — always use `{{SKILLS_PATH}}`.
|
|
41
13
|
|
|
42
14
|
## Creating a skill
|
|
43
15
|
|
|
44
16
|
### Capture intent
|
|
45
17
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Confirm these points before writing the first draft:
|
|
18
|
+
Extract answers from the current conversation first, then fill gaps with targeted questions. Confirm before writing the first draft:
|
|
49
19
|
|
|
50
20
|
1. What should this skill enable the model to do?
|
|
51
21
|
2. When should this skill trigger?
|
|
52
22
|
3. What output should it produce?
|
|
53
23
|
4. Does the user want a lightweight draft, or a tested and iterated skill?
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Ask about:
|
|
58
|
-
|
|
59
|
-
- edge cases
|
|
60
|
-
- input/output formats
|
|
61
|
-
- example prompts or files
|
|
62
|
-
- success criteria
|
|
63
|
-
- dependencies or required tools
|
|
64
|
-
|
|
65
|
-
Wait to write test prompts until these basics are clear enough.
|
|
25
|
+
Clarify edge cases, input/output formats, success criteria, and dependencies as needed before writing test prompts.
|
|
66
26
|
|
|
67
27
|
### Write the skill
|
|
68
28
|
|
|
69
|
-
Create the skill
|
|
70
|
-
|
|
71
|
-
Create `SKILL.md` with YAML frontmatter. The frontmatter must include:
|
|
72
|
-
|
|
73
|
-
- `name`
|
|
74
|
-
- `description`
|
|
29
|
+
Create the skill at `{{SKILLS_PATH}}/<skill-name>/SKILL.md`. Example template:
|
|
75
30
|
|
|
76
|
-
|
|
31
|
+
```yaml
|
|
32
|
+
---
|
|
33
|
+
name: example-skill
|
|
34
|
+
description: "Analyze competitor pricing pages and generate a comparison matrix. Use when the user wants to benchmark pricing tiers, feature gaps, or positioning against specific competitors."
|
|
35
|
+
---
|
|
77
36
|
|
|
78
|
-
|
|
37
|
+
# Example Skill
|
|
79
38
|
|
|
80
|
-
|
|
81
|
-
- Keep the body focused on the workflow, decisions, and output expectations.
|
|
82
|
-
- If the skill needs deterministic helpers, place them under `scripts/`.
|
|
83
|
-
- If the skill needs long reference material, place it under `references/` and tell the model when to read it.
|
|
39
|
+
## Workflow
|
|
84
40
|
|
|
85
|
-
|
|
41
|
+
1. Collect the target URLs from the user.
|
|
42
|
+
2. Extract pricing tiers, features, and limits from each page.
|
|
43
|
+
3. Generate a comparison matrix as a markdown table.
|
|
86
44
|
|
|
87
|
-
|
|
45
|
+
## Output
|
|
88
46
|
|
|
89
|
-
|
|
90
|
-
{{SKILLS_PATH}}/example-skill/
|
|
91
|
-
{{SKILLS_PATH}}/example-skill/SKILL.md
|
|
47
|
+
Return a markdown table with one column per competitor and one row per feature.
|
|
92
48
|
```
|
|
93
49
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
### Update skillpack.json
|
|
50
|
+
The `description` is the primary triggering mechanism — make it concrete with both what the skill does and when to use it. Keep the body focused on workflow, decisions, and output expectations. Place deterministic helpers under `scripts/` and long reference material under `references/`.
|
|
97
51
|
|
|
98
|
-
|
|
52
|
+
Preserve the existing skill name when improving unless the user explicitly requests a rename.
|
|
99
53
|
|
|
100
|
-
|
|
54
|
+
### Sync skillpack.json
|
|
101
55
|
|
|
102
|
-
|
|
103
|
-
2. Parse the YAML frontmatter.
|
|
104
|
-
3. Extract:
|
|
105
|
-
- `name`
|
|
106
|
-
- `description`
|
|
107
|
-
4. Upsert an entry into the `skills` array in `{{PACK_CONFIG_PATH}}`:
|
|
56
|
+
After creating or updating a skill, sync `{{PACK_CONFIG_PATH}}`. Read the final `SKILL.md`, parse the YAML frontmatter, and upsert into the `skills` array:
|
|
108
57
|
|
|
109
58
|
```json
|
|
110
59
|
{
|
|
@@ -114,40 +63,17 @@ Do not guess the metadata from memory. Instead:
|
|
|
114
63
|
}
|
|
115
64
|
```
|
|
116
65
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- `name` must come from `frontmatter.name`.
|
|
120
|
-
- `description` must come from `frontmatter.description`.
|
|
121
|
-
- `source` must be `./skills/<frontmatter.name>`.
|
|
122
|
-
- If an entry for the same skill already exists, update it instead of creating a duplicate.
|
|
66
|
+
All three fields must come from frontmatter — do not guess from memory. Update existing entries instead of creating duplicates.
|
|
123
67
|
|
|
124
68
|
### Writing guide
|
|
125
69
|
|
|
126
|
-
Prefer imperative
|
|
127
|
-
|
|
128
|
-
Useful structure:
|
|
129
|
-
|
|
130
|
-
- purpose
|
|
131
|
-
- trigger guidance
|
|
132
|
-
- required inputs
|
|
133
|
-
- step-by-step workflow
|
|
134
|
-
- output format
|
|
135
|
-
- edge cases
|
|
136
|
-
|
|
137
|
-
If the skill supports multiple domains or frameworks, organize the references by variant and tell the model how to choose the right one.
|
|
70
|
+
Prefer imperative instructions. Structure skills as: purpose, trigger guidance, required inputs, step-by-step workflow, output format, edge cases. For multi-domain skills, organize references by variant and tell the model how to choose.
|
|
138
71
|
|
|
139
72
|
## Test and iterate
|
|
140
73
|
|
|
141
|
-
After drafting the skill, propose 2
|
|
142
|
-
|
|
143
|
-
If the user wants evaluation:
|
|
144
|
-
|
|
145
|
-
- run the test prompts with the skill
|
|
146
|
-
- compare the outputs against the user's expectations
|
|
147
|
-
- note what worked and what failed
|
|
148
|
-
- revise the skill
|
|
74
|
+
After drafting the skill, propose 2–3 realistic test prompts phrased as a real user would.
|
|
149
75
|
|
|
150
|
-
If the user
|
|
76
|
+
If the user wants evaluation, run the prompts, compare outputs against expectations, note failures, and revise. Otherwise, do at least a lightweight sanity check before calling the skill complete.
|
|
151
77
|
|
|
152
78
|
## Improving an existing skill
|
|
153
79
|
|
package/templates/start.bat
CHANGED
package/templates/start.sh
CHANGED
package/web/index.html
CHANGED
|
@@ -96,6 +96,19 @@
|
|
|
96
96
|
<label>Custom Base URL <span class="label-hint">(optional)</span></label>
|
|
97
97
|
<input type="text" id="apikey-baseurl-input" placeholder="https://api.openai.com/v1" class="form-input" />
|
|
98
98
|
</div>
|
|
99
|
+
<div class="form-group" id="apikey-modelid-group" style="display: none;">
|
|
100
|
+
<label>Custom Model Name <span class="label-hint">(optional)</span></label>
|
|
101
|
+
<input type="text" id="apikey-modelid-input" placeholder="e.g. gpt-4o, llama-3-70b" class="form-input" />
|
|
102
|
+
</div>
|
|
103
|
+
<div class="form-group" id="apikey-protocol-group" style="display: none;">
|
|
104
|
+
<label>API Protocol</label>
|
|
105
|
+
<div class="provider-select-wrapper">
|
|
106
|
+
<select id="apikey-protocol-select" class="form-input">
|
|
107
|
+
<option value="openai-completions">Chat Completions API (most proxies)</option>
|
|
108
|
+
<option value="openai-responses">Responses API (native OpenAI)</option>
|
|
109
|
+
</select>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
99
112
|
</div>
|
|
100
113
|
|
|
101
114
|
<!-- OAuth Section -->
|
package/web/js/api-key-dialog.js
CHANGED
|
@@ -16,6 +16,10 @@ let providerSelect;
|
|
|
16
16
|
let apiKeyInput;
|
|
17
17
|
let baseUrlInput;
|
|
18
18
|
let baseUrlGroup;
|
|
19
|
+
let modelIdInput;
|
|
20
|
+
let modelIdGroup;
|
|
21
|
+
let protocolSelect;
|
|
22
|
+
let protocolGroup;
|
|
19
23
|
let apikeySection;
|
|
20
24
|
let oauthSection;
|
|
21
25
|
let oauthLoginBtn;
|
|
@@ -36,6 +40,10 @@ export function initApiKeyDialog() {
|
|
|
36
40
|
apiKeyInput = document.getElementById("apikey-input");
|
|
37
41
|
baseUrlInput = document.getElementById("apikey-baseurl-input");
|
|
38
42
|
baseUrlGroup = document.getElementById("apikey-baseurl-group");
|
|
43
|
+
modelIdInput = document.getElementById("apikey-modelid-input");
|
|
44
|
+
modelIdGroup = document.getElementById("apikey-modelid-group");
|
|
45
|
+
protocolSelect = document.getElementById("apikey-protocol-select");
|
|
46
|
+
protocolGroup = document.getElementById("apikey-protocol-group");
|
|
39
47
|
apikeySection = document.getElementById("apikey-apikey-section");
|
|
40
48
|
oauthSection = document.getElementById("apikey-oauth-section");
|
|
41
49
|
oauthLoginBtn = document.getElementById("oauth-login-btn");
|
|
@@ -67,6 +75,9 @@ export function initApiKeyDialog() {
|
|
|
67
75
|
if (oauthLogoutBtn) {
|
|
68
76
|
oauthLogoutBtn.addEventListener("click", handleOAuthLogout);
|
|
69
77
|
}
|
|
78
|
+
if (baseUrlInput) {
|
|
79
|
+
baseUrlInput.addEventListener("input", updateModelIdVisibility);
|
|
80
|
+
}
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
/**
|
|
@@ -126,6 +137,12 @@ function populateForm() {
|
|
|
126
137
|
if (baseUrlInput) {
|
|
127
138
|
baseUrlInput.value = config.baseUrl || "";
|
|
128
139
|
}
|
|
140
|
+
if (modelIdInput) {
|
|
141
|
+
modelIdInput.value = config.modelId || "";
|
|
142
|
+
}
|
|
143
|
+
if (protocolSelect) {
|
|
144
|
+
protocolSelect.value = config.apiProtocol || "openai-completions";
|
|
145
|
+
}
|
|
129
146
|
|
|
130
147
|
// OAuth Status
|
|
131
148
|
if (config.oauthConnected) {
|
|
@@ -163,6 +180,9 @@ function updateProviderUI() {
|
|
|
163
180
|
baseUrlInput.placeholder =
|
|
164
181
|
meta.baseUrlPlaceholder || "https://api.openai.com/v1";
|
|
165
182
|
}
|
|
183
|
+
|
|
184
|
+
// Show model name field only when a custom base URL is filled in
|
|
185
|
+
updateModelIdVisibility();
|
|
166
186
|
|
|
167
187
|
// Update placeholder
|
|
168
188
|
if (apiKeyInput) {
|
|
@@ -171,10 +191,21 @@ function updateProviderUI() {
|
|
|
171
191
|
}
|
|
172
192
|
}
|
|
173
193
|
|
|
194
|
+
function updateModelIdVisibility() {
|
|
195
|
+
if (!modelIdGroup) return;
|
|
196
|
+
const hasCustomUrl = baseUrlInput && baseUrlInput.value.trim().length > 0;
|
|
197
|
+
modelIdGroup.style.display = hasCustomUrl ? "" : "none";
|
|
198
|
+
if (protocolGroup) {
|
|
199
|
+
protocolGroup.style.display = hasCustomUrl ? "" : "none";
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
174
203
|
async function handleSave() {
|
|
175
204
|
const key = apiKeyInput.value.trim();
|
|
176
205
|
const provider = providerSelect.value;
|
|
177
206
|
const baseUrl = baseUrlInput.value.trim();
|
|
207
|
+
const modelId = modelIdInput ? modelIdInput.value.trim() : "";
|
|
208
|
+
const apiProtocol = protocolSelect ? protocolSelect.value : "";
|
|
178
209
|
|
|
179
210
|
// If OAuth is selected, we don't handle it here but it shouldn't happen as save button is hidden
|
|
180
211
|
const meta = state.config?.supportedProviders?.[provider];
|
|
@@ -184,6 +215,15 @@ async function handleSave() {
|
|
|
184
215
|
if (baseUrl !== state.config.baseUrl) {
|
|
185
216
|
updates.baseUrl = baseUrl;
|
|
186
217
|
}
|
|
218
|
+
if (modelId !== (state.config.modelId || "")) {
|
|
219
|
+
updates.modelId = modelId;
|
|
220
|
+
}
|
|
221
|
+
const hasCustomUrl = baseUrl.length > 0;
|
|
222
|
+
if (hasCustomUrl && apiProtocol !== (state.config.apiProtocol || "openai-completions")) {
|
|
223
|
+
updates.apiProtocol = apiProtocol;
|
|
224
|
+
} else if (!hasCustomUrl && state.config.apiProtocol) {
|
|
225
|
+
updates.apiProtocol = "";
|
|
226
|
+
}
|
|
187
227
|
|
|
188
228
|
if (key && key !== "***************************************************" && key !== state.config.apiKey) {
|
|
189
229
|
updates.key = key;
|
|
@@ -195,6 +235,8 @@ async function handleSave() {
|
|
|
195
235
|
|
|
196
236
|
state.config.provider = res.provider;
|
|
197
237
|
state.config.baseUrl = res.baseUrl || "";
|
|
238
|
+
state.config.modelId = res.modelId || "";
|
|
239
|
+
state.config.apiProtocol = res.apiProtocol || "";
|
|
198
240
|
if (updates.key) {
|
|
199
241
|
state.config.hasApiKey = true;
|
|
200
242
|
state.config.apiKey = updates.key;
|