@yeaft/webchat-agent 0.1.979 → 0.1.981
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/package.json +1 -1
- package/providers/base.js +1 -1
- package/providers/copilot.js +8 -28
package/package.json
CHANGED
package/providers/base.js
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* @property {boolean} [subagents] provider drives subagent watcher events
|
|
42
42
|
* @property {boolean} [attachments] provider accepts file / image attachments in prompts
|
|
43
43
|
* @property {boolean} [askUser] provider supports the round-trip ask-user permission prompt
|
|
44
|
-
* @property {boolean} [modelPicker] provider supports
|
|
44
|
+
* @property {boolean} [modelPicker] provider supports selecting a model from the web UI
|
|
45
45
|
*
|
|
46
46
|
* @typedef {Object} StartOpts
|
|
47
47
|
* @property {string} conversationId
|
package/providers/copilot.js
CHANGED
|
@@ -6,7 +6,7 @@ import { join } from 'path';
|
|
|
6
6
|
import { DatabaseSync } from 'node:sqlite';
|
|
7
7
|
import ctx from '../context.js';
|
|
8
8
|
import { AcpClient } from './acp-client.js';
|
|
9
|
-
import {
|
|
9
|
+
import { cacheCopilotModelsFromAcp } from './copilot-models.js';
|
|
10
10
|
|
|
11
11
|
export const name = 'copilot';
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ export const capabilities = Object.freeze({
|
|
|
18
18
|
subagents: false,
|
|
19
19
|
attachments: true, // ACP promptCapabilities.image + embeddedContext
|
|
20
20
|
askUser: true, // session/request_permission round-trip
|
|
21
|
-
modelPicker:
|
|
21
|
+
modelPicker: false,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const COPILOT_BIN = process.env.COPILOT_BIN || 'copilot';
|
|
@@ -41,7 +41,6 @@ export async function start(opts) {
|
|
|
41
41
|
dispose(prior, 'replaced');
|
|
42
42
|
|
|
43
43
|
const providerOptions = opts.providerOptions || prior?.providerOptions || {};
|
|
44
|
-
const model = providerOptions.model || DEFAULT_COPILOT_MODEL;
|
|
45
44
|
const allowAllTools = YOLO || !!providerOptions.allowAllTools;
|
|
46
45
|
|
|
47
46
|
const state = {
|
|
@@ -56,7 +55,7 @@ export async function start(opts) {
|
|
|
56
55
|
abortController: null,
|
|
57
56
|
tools: [],
|
|
58
57
|
slashCommands: [],
|
|
59
|
-
model,
|
|
58
|
+
model: null,
|
|
60
59
|
userId: opts.userId,
|
|
61
60
|
username: opts.username,
|
|
62
61
|
disallowedTools: prior?.disallowedTools || null,
|
|
@@ -74,7 +73,7 @@ export async function start(opts) {
|
|
|
74
73
|
// Best-effort start; failures emit a result envelope and leave state in place
|
|
75
74
|
// so the next sendInput retries.
|
|
76
75
|
try {
|
|
77
|
-
await _bootAcp(state, opts.resumeSessionId || null
|
|
76
|
+
await _bootAcp(state, opts.resumeSessionId || null);
|
|
78
77
|
} catch (err) {
|
|
79
78
|
sendOutput(conversationId, {
|
|
80
79
|
type: 'result',
|
|
@@ -87,11 +86,8 @@ export async function start(opts) {
|
|
|
87
86
|
return state;
|
|
88
87
|
}
|
|
89
88
|
|
|
90
|
-
async function _bootAcp(state, resumeSessionId
|
|
89
|
+
async function _bootAcp(state, resumeSessionId) {
|
|
91
90
|
const args = ['--acp'];
|
|
92
|
-
// ACP doesn't yet expose a per-session model param in its public schema, so
|
|
93
|
-
// pass --model at spawn for the lifetime of this child.
|
|
94
|
-
if (model) args.push('--model', String(model));
|
|
95
91
|
if (Array.isArray(state.providerOptions?.addDirs)) {
|
|
96
92
|
for (const d of state.providerOptions.addDirs) args.push('--add-dir', String(d));
|
|
97
93
|
}
|
|
@@ -204,7 +200,7 @@ export async function sendInput(state, prompt, opts = {}) {
|
|
|
204
200
|
// Ensure ACP child + session are up; reboot if a prior crash dropped them.
|
|
205
201
|
if (!state.initialized || !state.acpClient) {
|
|
206
202
|
try {
|
|
207
|
-
await _bootAcp(state, state.sessionId || null
|
|
203
|
+
await _bootAcp(state, state.sessionId || null);
|
|
208
204
|
} catch (err) {
|
|
209
205
|
_sendTurnError(state, `copilot ACP reinit failed: ${err?.message || err}`);
|
|
210
206
|
_completeTurn(state, conversationId);
|
|
@@ -212,14 +208,6 @@ export async function sendInput(state, prompt, opts = {}) {
|
|
|
212
208
|
}
|
|
213
209
|
}
|
|
214
210
|
|
|
215
|
-
// Per-turn provider option overrides (e.g. updated model). If the model
|
|
216
|
-
// changed we don't restart the child; ACP doesn't expose model switch yet,
|
|
217
|
-
// so we leave a warning rather than silently drop the request.
|
|
218
|
-
const po = { ...(state.providerOptions || {}), ...(opts.providerOptions || {}) };
|
|
219
|
-
if (po.model && po.model !== state.model) {
|
|
220
|
-
if (ctx?.CONFIG?.debug) console.warn('[copilot] mid-conversation model switch not supported; ignoring');
|
|
221
|
-
}
|
|
222
|
-
|
|
223
211
|
const abortController = new AbortController();
|
|
224
212
|
state.abortController = abortController;
|
|
225
213
|
state.turnActive = true;
|
|
@@ -327,7 +315,7 @@ export async function clear(state) {
|
|
|
327
315
|
if (!state) return;
|
|
328
316
|
if (!state.initialized || !state.acpClient) {
|
|
329
317
|
try {
|
|
330
|
-
await _bootAcp(state, null
|
|
318
|
+
await _bootAcp(state, null);
|
|
331
319
|
return;
|
|
332
320
|
} catch (err) {
|
|
333
321
|
_sendTurnError(state, `copilot ACP reinit failed during clear: ${err?.message || err}`);
|
|
@@ -635,15 +623,7 @@ function _knownCopilotTools() {
|
|
|
635
623
|
];
|
|
636
624
|
}
|
|
637
625
|
|
|
638
|
-
|
|
639
|
-
* Exported for the model picker UI. Async — hits Copilot's /models endpoint
|
|
640
|
-
* (cached) and falls back to a static list if auth/network fails.
|
|
641
|
-
*/
|
|
642
|
-
export async function listModels() {
|
|
643
|
-
return await listCopilotModels();
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
export default { name, capabilities, start, sendInput, abort, clear, listFolders, listSessions, loadHistory, listModels, respondToPermissionRequest };
|
|
626
|
+
export default { name, capabilities, start, sendInput, abort, clear, listFolders, listSessions, loadHistory, respondToPermissionRequest };
|
|
647
627
|
|
|
648
628
|
|
|
649
629
|
// ---------- history surface (reads ~/.copilot/session-store.db) ----------
|