@codemieai/code 0.12.0 → 0.13.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/README.md +109 -56
- package/bin/codemie-copilot.js +224 -0
- package/bin/codemie-pi.js +18 -0
- package/dist/agents/core/AgentCLI.d.ts.map +1 -1
- package/dist/agents/core/AgentCLI.js +16 -10
- package/dist/agents/core/AgentCLI.js.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.d.ts.map +1 -1
- package/dist/agents/core/BaseAgentAdapter.js +43 -19
- package/dist/agents/core/BaseAgentAdapter.js.map +1 -1
- package/dist/agents/core/agent-aliases.d.ts +17 -0
- package/dist/agents/core/agent-aliases.d.ts.map +1 -0
- package/dist/agents/core/agent-aliases.js +41 -0
- package/dist/agents/core/agent-aliases.js.map +1 -0
- package/dist/agents/core/session/session-origin-audit.d.ts +13 -0
- package/dist/agents/core/session/session-origin-audit.d.ts.map +1 -1
- package/dist/agents/core/session/session-origin-audit.js +34 -0
- package/dist/agents/core/session/session-origin-audit.js.map +1 -1
- package/dist/agents/core/session/stale-session-reconciliation.d.ts +42 -0
- package/dist/agents/core/session/stale-session-reconciliation.d.ts.map +1 -0
- package/dist/agents/core/session/stale-session-reconciliation.js +141 -0
- package/dist/agents/core/session/stale-session-reconciliation.js.map +1 -0
- package/dist/agents/core/session/types.d.ts +19 -0
- package/dist/agents/core/session/types.d.ts.map +1 -1
- package/dist/agents/core/session/types.js +17 -1
- package/dist/agents/core/session/types.js.map +1 -1
- package/dist/agents/core/types.d.ts +1 -0
- package/dist/agents/core/types.d.ts.map +1 -1
- package/dist/agents/plugins/codex/codex.reconciliation.d.ts +15 -35
- package/dist/agents/plugins/codex/codex.reconciliation.d.ts.map +1 -1
- package/dist/agents/plugins/codex/codex.reconciliation.js +8 -139
- package/dist/agents/plugins/codex/codex.reconciliation.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts +4 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js +4 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.constants.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts +8 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.d.ts.map +1 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.js +195 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.models.js.map +1 -0
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts +4 -20
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js +237 -38
- package/dist/agents/plugins/copilot-cli/copilot-cli.plugin.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.session.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/copilot-cli.session.js +14 -2
- package/dist/agents/plugins/copilot-cli/copilot-cli.session.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/index.d.ts +2 -1
- package/dist/agents/plugins/copilot-cli/index.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/index.js +2 -1
- package/dist/agents/plugins/copilot-cli/index.js.map +1 -1
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts +6 -3
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.d.ts.map +1 -1
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js +298 -5
- package/dist/agents/plugins/copilot-cli/session/processors/copilot-cli.conversations-processor.js.map +1 -1
- package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts +12 -0
- package/dist/agents/plugins/pi/__tests__/home-redirect.d.ts.map +1 -0
- package/dist/agents/plugins/pi/__tests__/home-redirect.js +27 -0
- package/dist/agents/plugins/pi/__tests__/home-redirect.js.map +1 -0
- package/dist/agents/plugins/pi/extension/README.md +68 -0
- package/dist/agents/plugins/pi/extension/index.js +161 -0
- package/dist/agents/plugins/pi/extension/package.json +8 -0
- package/dist/agents/plugins/pi/index.d.ts +3 -0
- package/dist/agents/plugins/pi/index.d.ts.map +1 -0
- package/dist/agents/plugins/pi/index.js +3 -0
- package/dist/agents/plugins/pi/index.js.map +1 -0
- package/dist/agents/plugins/pi/pi.extension.d.ts +60 -0
- package/dist/agents/plugins/pi/pi.extension.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.extension.js +201 -0
- package/dist/agents/plugins/pi/pi.extension.js.map +1 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.d.ts +63 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.js +266 -0
- package/dist/agents/plugins/pi/pi.incremental-sync.js.map +1 -0
- package/dist/agents/plugins/pi/pi.models.d.ts +20 -0
- package/dist/agents/plugins/pi/pi.models.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.models.js +201 -0
- package/dist/agents/plugins/pi/pi.models.js.map +1 -0
- package/dist/agents/plugins/pi/pi.packages.d.ts +11 -0
- package/dist/agents/plugins/pi/pi.packages.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.packages.js +35 -0
- package/dist/agents/plugins/pi/pi.packages.js.map +1 -0
- package/dist/agents/plugins/pi/pi.paths.d.ts +37 -0
- package/dist/agents/plugins/pi/pi.paths.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.paths.js +146 -0
- package/dist/agents/plugins/pi/pi.paths.js.map +1 -0
- package/dist/agents/plugins/pi/pi.plugin.d.ts +30 -0
- package/dist/agents/plugins/pi/pi.plugin.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.plugin.js +453 -0
- package/dist/agents/plugins/pi/pi.plugin.js.map +1 -0
- package/dist/agents/plugins/pi/pi.session.d.ts +114 -0
- package/dist/agents/plugins/pi/pi.session.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.session.js +388 -0
- package/dist/agents/plugins/pi/pi.session.js.map +1 -0
- package/dist/agents/plugins/pi/pi.setup.d.ts +2 -0
- package/dist/agents/plugins/pi/pi.setup.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.setup.js +33 -0
- package/dist/agents/plugins/pi/pi.setup.js.map +1 -0
- package/dist/agents/plugins/pi/pi.types.d.ts +143 -0
- package/dist/agents/plugins/pi/pi.types.d.ts.map +1 -0
- package/dist/agents/plugins/pi/pi.types.js +74 -0
- package/dist/agents/plugins/pi/pi.types.js.map +1 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.d.ts +17 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.js +98 -0
- package/dist/agents/plugins/pi/session/pi-file-operations.js.map +1 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts +52 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.js +189 -0
- package/dist/agents/plugins/pi/session/pi-named-invocations.js.map +1 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts +14 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.js +51 -0
- package/dist/agents/plugins/pi/session/pi-user-prompt.js.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts +52 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js +716 -0
- package/dist/agents/plugins/pi/session/processors/pi.conversations-processor.js.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts +104 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.d.ts.map +1 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js +595 -0
- package/dist/agents/plugins/pi/session/processors/pi.metrics-processor.js.map +1 -0
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +2 -2
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/analytics/agent-labels.d.ts.map +1 -1
- package/dist/cli/commands/analytics/agent-labels.js +1 -0
- package/dist/cli/commands/analytics/agent-labels.js.map +1 -1
- package/dist/cli/commands/analytics/cost/usage-readers.d.ts +24 -0
- package/dist/cli/commands/analytics/cost/usage-readers.d.ts.map +1 -1
- package/dist/cli/commands/analytics/cost/usage-readers.js +199 -54
- package/dist/cli/commands/analytics/cost/usage-readers.js.map +1 -1
- package/dist/cli/commands/analytics/index.js +1 -0
- package/dist/cli/commands/analytics/index.js.map +1 -1
- package/dist/cli/commands/analytics/native-loader.d.ts +21 -4
- package/dist/cli/commands/analytics/native-loader.d.ts.map +1 -1
- package/dist/cli/commands/analytics/native-loader.js +250 -96
- package/dist/cli/commands/analytics/native-loader.js.map +1 -1
- package/dist/cli/commands/analytics/report/client/app.js +47 -3
- package/dist/cli/commands/analytics/report/payload-builder.d.ts.map +1 -1
- package/dist/cli/commands/analytics/report/payload-builder.js +25 -2
- package/dist/cli/commands/analytics/report/payload-builder.js.map +1 -1
- package/dist/cli/commands/analytics/report/types.d.ts +1 -0
- package/dist/cli/commands/analytics/report/types.d.ts.map +1 -1
- package/dist/cli/commands/hook.d.ts.map +1 -1
- package/dist/cli/commands/hook.js +71 -29
- package/dist/cli/commands/hook.js.map +1 -1
- package/dist/cli/commands/install.d.ts.map +1 -1
- package/dist/cli/commands/install.js +7 -5
- package/dist/cli/commands/install.js.map +1 -1
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +3 -1
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/uninstall.d.ts.map +1 -1
- package/dist/cli/commands/uninstall.js +5 -3
- package/dist/cli/commands/uninstall.js.map +1 -1
- package/dist/cli/commands/update.d.ts.map +1 -1
- package/dist/cli/commands/update.js +5 -3
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/first-time.d.ts.map +1 -1
- package/dist/cli/first-time.js +7 -6
- package/dist/cli/first-time.js.map +1 -1
- package/dist/providers/core/auth-validation.d.ts +7 -2
- package/dist/providers/core/auth-validation.d.ts.map +1 -1
- package/dist/providers/core/auth-validation.js +11 -5
- package/dist/providers/core/auth-validation.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts +8 -3
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js +46 -11
- package/dist/providers/plugins/sso/proxy/plugins/claude-request-normalizer.plugin.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts +23 -13
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js +75 -18
- package/dist/providers/plugins/sso/proxy/plugins/codex-encrypted-content-sanitizer.plugin.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts +21 -0
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.d.ts.map +1 -0
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js +133 -0
- package/dist/providers/plugins/sso/proxy/plugins/copilot-encrypted-content-sanitizer.plugin.js.map +1 -0
- package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/header-injection.plugin.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +2 -1
- package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/index.js +4 -2
- package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
- package/dist/providers/plugins/sso/proxy/plugins/types.d.ts +11 -0
- package/dist/providers/plugins/sso/proxy/plugins/types.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +2 -0
- package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
- package/dist/providers/plugins/sso/proxy/sso.proxy.js +37 -1
- package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
- package/dist/providers/plugins/sso/session/SessionSyncer.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/SessionSyncer.js +13 -0
- package/dist/providers/plugins/sso/session/SessionSyncer.js.map +1 -1
- package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js +6 -0
- package/dist/providers/plugins/sso/session/processors/conversations/syncProcessor.js.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts +0 -6
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.d.ts.map +1 -1
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js +28 -19
- package/dist/providers/plugins/sso/session/processors/metrics/metrics-post-processor.js.map +1 -1
- package/dist/utils/interactive.d.ts +14 -0
- package/dist/utils/interactive.d.ts.map +1 -0
- package/dist/utils/interactive.js +16 -0
- package/dist/utils/interactive.js.map +1 -0
- package/package.json +6 -4
- package/scripts/copy-plugins.js +6 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { fetchCodeMieLlmModels } from '../../../providers/plugins/sso/sso.http-client.js';
|
|
2
|
+
import { CodeMieSSO } from '../../../providers/plugins/sso/sso.auth.js';
|
|
3
|
+
import { ConfigurationError } from '../../../utils/errors.js';
|
|
4
|
+
import { logger } from '../../../utils/logger.js';
|
|
5
|
+
const COPILOT_INCOMPATIBLE_MODEL_PATTERNS = [
|
|
6
|
+
/embedding/i,
|
|
7
|
+
/rerank/i,
|
|
8
|
+
/whisper/i,
|
|
9
|
+
/tts/i,
|
|
10
|
+
/moderation/i,
|
|
11
|
+
/image/i,
|
|
12
|
+
/vision-only/i,
|
|
13
|
+
];
|
|
14
|
+
const GPT_FAMILY_PATTERNS = [
|
|
15
|
+
/\bgpt\b/i,
|
|
16
|
+
];
|
|
17
|
+
const CLAUDE_FAMILY_PATTERNS = [
|
|
18
|
+
/claude/i,
|
|
19
|
+
/anthropic/i,
|
|
20
|
+
/sonnet/i,
|
|
21
|
+
/opus/i,
|
|
22
|
+
/haiku/i,
|
|
23
|
+
];
|
|
24
|
+
function getModelId(model) {
|
|
25
|
+
return model.deployment_name || model.base_name || model.label;
|
|
26
|
+
}
|
|
27
|
+
function getSearchText(model) {
|
|
28
|
+
return [
|
|
29
|
+
model.deployment_name,
|
|
30
|
+
model.base_name,
|
|
31
|
+
model.label,
|
|
32
|
+
model.provider,
|
|
33
|
+
].filter(Boolean).join(' ').toLowerCase();
|
|
34
|
+
}
|
|
35
|
+
export function isCopilotCompatibleModelName(modelName) {
|
|
36
|
+
if (!modelName)
|
|
37
|
+
return false;
|
|
38
|
+
if (COPILOT_INCOMPATIBLE_MODEL_PATTERNS.some((pattern) => pattern.test(modelName))) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return GPT_FAMILY_PATTERNS.some((pattern) => pattern.test(modelName))
|
|
42
|
+
|| CLAUDE_FAMILY_PATTERNS.some((pattern) => pattern.test(modelName));
|
|
43
|
+
}
|
|
44
|
+
function isCopilotCompatibleModel(model) {
|
|
45
|
+
if (!model.enabled)
|
|
46
|
+
return false;
|
|
47
|
+
if (model.features?.tools === false || model.features?.streaming === false) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const id = getModelId(model);
|
|
51
|
+
if (!id || !isCopilotCompatibleModelName(id)) {
|
|
52
|
+
const searchText = getSearchText(model);
|
|
53
|
+
if (!isCopilotCompatibleModelName(searchText)) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
function extractVersionParts(text) {
|
|
60
|
+
const lower = text.toLowerCase();
|
|
61
|
+
const gptMatch = lower.match(/gpt[-.]?(\d+)(?:[-.](\d+))?(?:[-.](\d+))?/);
|
|
62
|
+
const claudeDateMatch = lower.match(/(20\d{2})[-.]?(\d{2})[-.]?(\d{2})/);
|
|
63
|
+
const claudeGenMatch = lower.match(/claude(?:[-_.]?(\d+))?(?:[-_.](\d+))?/);
|
|
64
|
+
const version = [
|
|
65
|
+
gptMatch?.[1] ?? claudeGenMatch?.[1],
|
|
66
|
+
gptMatch?.[2] ?? claudeGenMatch?.[2],
|
|
67
|
+
gptMatch?.[3],
|
|
68
|
+
].map((part) => (part ? Number(part) : 0));
|
|
69
|
+
if (claudeDateMatch) {
|
|
70
|
+
version.push(Number(claudeDateMatch[1]), Number(claudeDateMatch[2]), Number(claudeDateMatch[3]));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
version.push(0, 0, 0);
|
|
74
|
+
}
|
|
75
|
+
return version;
|
|
76
|
+
}
|
|
77
|
+
function rankModel(model) {
|
|
78
|
+
const id = getModelId(model);
|
|
79
|
+
if (!id) {
|
|
80
|
+
throw new ConfigurationError('Cannot rank Copilot model without a model identifier');
|
|
81
|
+
}
|
|
82
|
+
const searchText = getSearchText(model);
|
|
83
|
+
const preferredGpt55Bonus = /gpt[-_.]?5[-_.]?5(?:[-_.]|$)/i.test(searchText) ? 1 : 0;
|
|
84
|
+
const preferredGpt54Bonus = /gpt[-_.]?5[-_.]?4(?:[-_.]|$)/i.test(searchText) ? 1 : 0;
|
|
85
|
+
const preferredGptCodexBonus = /gpt[-_.]?5[-_.]?[23].*codex/i.test(searchText) ? 1 : 0;
|
|
86
|
+
const preferredClaudeBonus = /claude[-_.]?(?:sonnet[-_.]?)?(?:4(?:[-_.]5|[-_.]6)?|5)(?:[-_.]|$)/i.test(searchText) ? 1 : 0;
|
|
87
|
+
const gptFamilyBonus = GPT_FAMILY_PATTERNS.some((pattern) => pattern.test(searchText)) ? 1 : 0;
|
|
88
|
+
const claudeFamilyBonus = CLAUDE_FAMILY_PATTERNS.some((pattern) => pattern.test(searchText)) ? 1 : 0;
|
|
89
|
+
const defaultBonus = model.default ? 1 : 0;
|
|
90
|
+
const toolBonus = model.features?.tools === false ? 0 : 1;
|
|
91
|
+
const streamingBonus = model.features?.streaming === false ? 0 : 1;
|
|
92
|
+
const temperatureBonus = model.features?.temperature === false ? 1 : 0;
|
|
93
|
+
return {
|
|
94
|
+
model,
|
|
95
|
+
id,
|
|
96
|
+
score: [
|
|
97
|
+
preferredGpt55Bonus,
|
|
98
|
+
preferredGpt54Bonus,
|
|
99
|
+
preferredGptCodexBonus,
|
|
100
|
+
gptFamilyBonus,
|
|
101
|
+
preferredClaudeBonus,
|
|
102
|
+
claudeFamilyBonus,
|
|
103
|
+
temperatureBonus,
|
|
104
|
+
toolBonus,
|
|
105
|
+
streamingBonus,
|
|
106
|
+
...extractVersionParts(searchText),
|
|
107
|
+
defaultBonus,
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function compareRankedModels(a, b) {
|
|
112
|
+
const max = Math.max(a.score.length, b.score.length);
|
|
113
|
+
for (let i = 0; i < max; i++) {
|
|
114
|
+
const diff = (b.score[i] ?? 0) - (a.score[i] ?? 0);
|
|
115
|
+
if (diff !== 0)
|
|
116
|
+
return diff;
|
|
117
|
+
}
|
|
118
|
+
return a.id.localeCompare(b.id);
|
|
119
|
+
}
|
|
120
|
+
async function fetchCodeMieModelsForCopilot(env) {
|
|
121
|
+
const jwtToken = env.CODEMIE_JWT_TOKEN;
|
|
122
|
+
const baseUrl = env.CODEMIE_BASE_URL;
|
|
123
|
+
if (jwtToken && baseUrl) {
|
|
124
|
+
logger.debug('[copilot-cli-models] Fetching CodeMie model list via JWT auth');
|
|
125
|
+
return fetchCodeMieLlmModels(baseUrl, jwtToken);
|
|
126
|
+
}
|
|
127
|
+
const codeMieUrl = env.CODEMIE_URL;
|
|
128
|
+
if (codeMieUrl) {
|
|
129
|
+
const sso = new CodeMieSSO();
|
|
130
|
+
const credentials = await sso.getStoredCredentials(codeMieUrl);
|
|
131
|
+
if (!credentials) {
|
|
132
|
+
throw new ConfigurationError(`SSO credentials not found for ${codeMieUrl}. Run: codemie setup or codemie profile login --url ${codeMieUrl}`);
|
|
133
|
+
}
|
|
134
|
+
logger.debug('[copilot-cli-models] Fetching CodeMie model list via SSO auth');
|
|
135
|
+
return fetchCodeMieLlmModels(credentials.apiUrl, credentials.cookies);
|
|
136
|
+
}
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
export async function resolveCopilotModel(env) {
|
|
140
|
+
const currentModel = env.CODEMIE_MODEL;
|
|
141
|
+
const modelSource = (env.CODEMIE_MODEL_SOURCE || 'default');
|
|
142
|
+
let rawModels = [];
|
|
143
|
+
try {
|
|
144
|
+
rawModels = await fetchCodeMieModelsForCopilot(env);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (isCopilotCompatibleModelName(currentModel)) {
|
|
148
|
+
const configuredModel = currentModel;
|
|
149
|
+
logger.debug('[copilot-cli-models] Failed to fetch CodeMie models; keeping compatible configured model', {
|
|
150
|
+
error: error instanceof Error ? error.message : String(error),
|
|
151
|
+
model: configuredModel,
|
|
152
|
+
});
|
|
153
|
+
return { selectedModel: configuredModel, availableModels: [configuredModel] };
|
|
154
|
+
}
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
const rankedModels = rawModels
|
|
158
|
+
.filter(isCopilotCompatibleModel)
|
|
159
|
+
.map(rankModel)
|
|
160
|
+
.sort(compareRankedModels);
|
|
161
|
+
if (rankedModels.length === 0) {
|
|
162
|
+
if (isCopilotCompatibleModelName(currentModel)) {
|
|
163
|
+
const configuredModel = currentModel;
|
|
164
|
+
logger.debug('[copilot-cli-models] CodeMie returned no explicitly compatible Copilot models; keeping configured model');
|
|
165
|
+
return { selectedModel: configuredModel, availableModels: [configuredModel] };
|
|
166
|
+
}
|
|
167
|
+
throw new ConfigurationError('No CodeMie model compatible with GitHub Copilot CLI is available. ' +
|
|
168
|
+
'Use a model with tool calling and streaming support, such as gpt-5.5 or claude-sonnet-4.6.');
|
|
169
|
+
}
|
|
170
|
+
const selectedModel = rankedModels[0].id;
|
|
171
|
+
const rankedIds = rankedModels.map((entry) => entry.id);
|
|
172
|
+
const shouldPreserveConfiguredModel = modelSource === 'cli' || modelSource === 'env';
|
|
173
|
+
const effectiveModel = shouldPreserveConfiguredModel && currentModel && rankedIds.includes(currentModel)
|
|
174
|
+
? currentModel
|
|
175
|
+
: selectedModel;
|
|
176
|
+
if (currentModel && currentModel !== effectiveModel) {
|
|
177
|
+
logger.info(`[copilot-cli-models] Using ${effectiveModel} for Copilot instead of profile model ${currentModel}`);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
selectedModel: effectiveModel,
|
|
181
|
+
availableModels: rankedModels.map((entry) => entry.id),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
export function assertExplicitCopilotModelAllowed(model, availableModels) {
|
|
185
|
+
if (!isCopilotCompatibleModelName(model)) {
|
|
186
|
+
throw new ConfigurationError(`Model "${model}" is not compatible with codemie-copilot. ` +
|
|
187
|
+
`Use a GPT-family or Claude-family model with tool calling and streaming support` +
|
|
188
|
+
`${availableModels.length ? ` such as: ${availableModels.join(', ')}` : '.'}`);
|
|
189
|
+
}
|
|
190
|
+
if (availableModels.length > 0 && !availableModels.includes(model)) {
|
|
191
|
+
throw new ConfigurationError(`Model "${model}" is not available in CodeMie for codemie-copilot. ` +
|
|
192
|
+
`Available models: ${availableModels.join(', ')}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=copilot-cli.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-cli.models.js","sourceRoot":"","sources":["../../../../src/agents/plugins/copilot-cli/copilot-cli.models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,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ot CLI — analytics-only agent plugin.
|
|
3
|
-
*
|
|
4
|
-
* CodeMie does NOT install, launch, configure, or proxy Copilot. This plugin exists solely
|
|
5
|
-
* so `AgentRegistry` can hand the analytics pipeline a `SessionAdapter`: `native-loader.ts`
|
|
6
|
-
* resolves adapters via `AgentRegistry.getAgent(name)?.getSessionAdapter?.()`, and there is
|
|
7
|
-
* no analytics-only bypass around the registry.
|
|
8
|
-
*
|
|
9
|
-
* The mutating lifecycle methods inherited from `BaseAgentAdapter` are therefore overridden
|
|
10
|
-
* to refuse. Left inherited, `install()` would npm-install `@github/copilot` and `run()`
|
|
11
|
-
* would launch it — both outside this integration's remit.
|
|
12
|
-
*/
|
|
13
1
|
import type { AgentMetadata } from '../../core/types.js';
|
|
14
2
|
import { BaseAgentAdapter } from '../../core/BaseAgentAdapter.js';
|
|
15
3
|
import type { SessionAdapter } from '../../core/session/BaseSessionAdapter.js';
|
|
16
|
-
|
|
17
|
-
export { COPILOT_CLI_AGENT_NAME, COPILOT_CLI_DISPLAY_NAME };
|
|
4
|
+
export { COPILOT_CLI_AGENT_NAME, COPILOT_CLI_CLIENT_TYPE, COPILOT_CLI_DISPLAY_NAME, } from './copilot-cli.constants.js';
|
|
18
5
|
export declare const CopilotCliPluginMetadata: AgentMetadata;
|
|
19
6
|
export declare class CopilotCliPlugin extends BaseAgentAdapter {
|
|
20
7
|
private sessionAdapter;
|
|
21
8
|
constructor();
|
|
22
9
|
getSessionAdapter(): SessionAdapter;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
uninstall(): Promise<void>;
|
|
27
|
-
/** Refused: analytics-only. See {@link NOT_MANAGED}. */
|
|
28
|
-
run(_args: string[], _env?: Record<string, string>): Promise<void>;
|
|
10
|
+
protected setupProxy(env: NodeJS.ProcessEnv): Promise<void>;
|
|
11
|
+
isInstalled(): Promise<boolean>;
|
|
12
|
+
getVersion(): Promise<string | null>;
|
|
29
13
|
}
|
|
30
14
|
//# sourceMappingURL=copilot-cli.plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-cli.plugin.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/copilot-cli/copilot-cli.plugin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"copilot-cli.plugin.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/copilot-cli/copilot-cli.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAe/E,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAoEpC,eAAO,MAAM,wBAAwB,EAAE,aAyKtC,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,gBAAgB;IACpD,OAAO,CAAC,cAAc,CAA+B;;IAMrD,iBAAiB,IAAI,cAAc;cAOV,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB3D,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAO/B,UAAU,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAapD"}
|
|
@@ -1,41 +1,213 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GitHub Copilot CLI — analytics-only agent plugin.
|
|
3
|
-
*
|
|
4
|
-
* CodeMie does NOT install, launch, configure, or proxy Copilot. This plugin exists solely
|
|
5
|
-
* so `AgentRegistry` can hand the analytics pipeline a `SessionAdapter`: `native-loader.ts`
|
|
6
|
-
* resolves adapters via `AgentRegistry.getAgent(name)?.getSessionAdapter?.()`, and there is
|
|
7
|
-
* no analytics-only bypass around the registry.
|
|
8
|
-
*
|
|
9
|
-
* The mutating lifecycle methods inherited from `BaseAgentAdapter` are therefore overridden
|
|
10
|
-
* to refuse. Left inherited, `install()` would npm-install `@github/copilot` and `run()`
|
|
11
|
-
* would launch it — both outside this integration's remit.
|
|
12
|
-
*/
|
|
13
1
|
import { BaseAgentAdapter } from '../../core/BaseAgentAdapter.js';
|
|
14
2
|
import { CopilotCliSessionAdapter } from './copilot-cli.session.js';
|
|
15
3
|
import { ConfigurationError } from '../../../utils/errors.js';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
import { commandExists, exec } from '../../../utils/processes.js';
|
|
5
|
+
import { logger } from '../../../utils/logger.js';
|
|
6
|
+
import { COPILOT_CLI_AGENT_NAME, COPILOT_CLI_CLIENT_TYPE, COPILOT_CLI_DISPLAY_NAME, } from './copilot-cli.constants.js';
|
|
7
|
+
import { assertExplicitCopilotModelAllowed, resolveCopilotModel, } from './copilot-cli.models.js';
|
|
8
|
+
export { COPILOT_CLI_AGENT_NAME, COPILOT_CLI_CLIENT_TYPE, COPILOT_CLI_DISPLAY_NAME, } from './copilot-cli.constants.js';
|
|
9
|
+
const COPILOT_SUPPORTED_VERSION = '1.0.79';
|
|
10
|
+
const COPILOT_MINIMUM_SUPPORTED_VERSION = '1.0.70';
|
|
11
|
+
const COPILOT_COMPATIBLE_PROVIDERS = ['ai-run-sso', 'litellm'];
|
|
12
|
+
const COPILOT_RECOMMENDED_MODELS = ['gpt-5.5', 'claude-sonnet-4.6', 'gpt-5.4'];
|
|
13
|
+
function buildCopilotHookConfig(env, sessionId) {
|
|
14
|
+
return {
|
|
15
|
+
agentName: env.CODEMIE_AGENT || COPILOT_CLI_AGENT_NAME,
|
|
16
|
+
sessionId,
|
|
17
|
+
provider: env.CODEMIE_PROVIDER,
|
|
18
|
+
apiBaseUrl: env.CODEMIE_BASE_URL,
|
|
19
|
+
ssoUrl: env.CODEMIE_URL,
|
|
20
|
+
syncApiUrl: env.CODEMIE_SYNC_API_URL,
|
|
21
|
+
version: env.CODEMIE_CLI_VERSION,
|
|
22
|
+
profileName: env.CODEMIE_PROFILE_NAME,
|
|
23
|
+
project: env.CODEMIE_PROJECT,
|
|
24
|
+
model: env.CODEMIE_MODEL,
|
|
25
|
+
clientType: COPILOT_CLI_CLIENT_TYPE,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function buildCopilotProviderEnv(env) {
|
|
29
|
+
if (!env.CODEMIE_BASE_URL) {
|
|
30
|
+
throw new ConfigurationError('CodeMie base URL is not configured for Copilot CLI. Run codemie setup and try again.');
|
|
31
|
+
}
|
|
32
|
+
if (!env.CODEMIE_MODEL) {
|
|
33
|
+
throw new ConfigurationError('No CodeMie model is configured for Copilot CLI. Run codemie setup or pass --model.');
|
|
34
|
+
}
|
|
35
|
+
const providerType = /^claude/i.test(env.CODEMIE_MODEL) ? 'anthropic' : 'openai';
|
|
36
|
+
const providerEnv = {
|
|
37
|
+
COPILOT_PROVIDER_BASE_URL: env.CODEMIE_BASE_URL,
|
|
38
|
+
COPILOT_PROVIDER_TYPE: providerType,
|
|
39
|
+
COPILOT_MODEL: env.CODEMIE_MODEL,
|
|
40
|
+
COPILOT_PROVIDER_MODEL_ID: env.CODEMIE_MODEL,
|
|
41
|
+
COPILOT_PROVIDER_WIRE_MODEL: env.CODEMIE_MODEL,
|
|
42
|
+
COPILOT_OFFLINE: 'true',
|
|
43
|
+
};
|
|
44
|
+
if (/^gpt[-_.]?5/i.test(env.CODEMIE_MODEL)) {
|
|
45
|
+
providerEnv.COPILOT_PROVIDER_WIRE_API = 'responses';
|
|
46
|
+
}
|
|
47
|
+
if (env.CODEMIE_API_KEY) {
|
|
48
|
+
providerEnv.COPILOT_PROVIDER_API_KEY = env.CODEMIE_API_KEY;
|
|
49
|
+
providerEnv.COPILOT_PROVIDER_BEARER_TOKEN = env.CODEMIE_API_KEY;
|
|
50
|
+
}
|
|
51
|
+
return providerEnv;
|
|
52
|
+
}
|
|
53
|
+
function assertCopilotProviderSupported(config) {
|
|
54
|
+
const provider = config.provider;
|
|
55
|
+
if (!provider || !COPILOT_COMPATIBLE_PROVIDERS.includes(provider)) {
|
|
56
|
+
throw new ConfigurationError('GitHub Copilot CLI via CodeMie currently supports only AI/Run SSO and LiteLLM profiles. ' +
|
|
57
|
+
'Run codemie setup to choose a supported provider.');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
20
60
|
export const CopilotCliPluginMetadata = {
|
|
21
61
|
name: COPILOT_CLI_AGENT_NAME,
|
|
22
62
|
displayName: COPILOT_CLI_DISPLAY_NAME,
|
|
23
|
-
description: 'GitHub Copilot CLI
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// defense in depth behind the getManageableAgents() exclusion.
|
|
29
|
-
npmPackage: null,
|
|
30
|
-
cliCommand: 'copilot',
|
|
63
|
+
description: 'GitHub Copilot CLI - AI coding agent managed by CodeMie',
|
|
64
|
+
npmPackage: '@github/copilot',
|
|
65
|
+
cliCommand: process.env.CODEMIE_COPILOT_BIN || 'copilot',
|
|
66
|
+
supportedVersion: COPILOT_SUPPORTED_VERSION,
|
|
67
|
+
minimumSupportedVersion: COPILOT_MINIMUM_SUPPORTED_VERSION,
|
|
31
68
|
dataPaths: {
|
|
32
69
|
home: '.copilot',
|
|
33
70
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
71
|
+
extensionsConfig: {
|
|
72
|
+
project: '.github',
|
|
73
|
+
global: '~/.copilot',
|
|
74
|
+
skillsEntryFile: 'SKILL.md',
|
|
75
|
+
dirNames: {
|
|
76
|
+
agents: ['agents'],
|
|
77
|
+
commands: [],
|
|
78
|
+
skills: ['skills'],
|
|
79
|
+
hooks: ['hooks'],
|
|
80
|
+
rules: [],
|
|
81
|
+
},
|
|
82
|
+
extraProjectDirs: ['.github/copilot'],
|
|
83
|
+
},
|
|
84
|
+
mcpConfig: {
|
|
85
|
+
project: {
|
|
86
|
+
path: ['.mcp.json', '.github/mcp.json'],
|
|
87
|
+
jsonPath: 'mcpServers',
|
|
88
|
+
},
|
|
89
|
+
user: {
|
|
90
|
+
path: '~/.copilot/mcp-config.json',
|
|
91
|
+
jsonPath: 'mcpServers',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
hookConfig: {
|
|
95
|
+
eventNameMapping: {
|
|
96
|
+
SessionStart: 'SessionStart',
|
|
97
|
+
SessionEnd: 'SessionEnd',
|
|
98
|
+
UserPromptSubmit: 'UserPromptSubmit',
|
|
99
|
+
PreToolUse: 'UserPromptSubmit',
|
|
100
|
+
PostToolUse: 'Stop',
|
|
101
|
+
Notification: 'PermissionRequest',
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
envMapping: {
|
|
105
|
+
baseUrl: [],
|
|
106
|
+
apiKey: [],
|
|
107
|
+
model: [],
|
|
108
|
+
},
|
|
109
|
+
supportedProviders: [...COPILOT_COMPATIBLE_PROVIDERS],
|
|
110
|
+
blockedModelPatterns: [/embedding/i, /rerank/i, /whisper/i, /tts/i, /image/i],
|
|
111
|
+
recommendedModels: [...COPILOT_RECOMMENDED_MODELS],
|
|
112
|
+
ssoConfig: {
|
|
113
|
+
enabled: true,
|
|
114
|
+
clientType: COPILOT_CLI_CLIENT_TYPE,
|
|
115
|
+
},
|
|
116
|
+
sessionAnalyticsReport: true,
|
|
117
|
+
flagMappings: {
|
|
118
|
+
'--task': { type: 'flag', target: '--prompt' },
|
|
119
|
+
},
|
|
120
|
+
lifecycle: {
|
|
121
|
+
async onSessionStart(sessionId, env) {
|
|
122
|
+
try {
|
|
123
|
+
const { processEvent } = await import('../../../cli/commands/hook.js');
|
|
124
|
+
await processEvent({
|
|
125
|
+
hook_event_name: 'SessionStart',
|
|
126
|
+
session_id: sessionId,
|
|
127
|
+
transcript_path: '',
|
|
128
|
+
permission_mode: 'default',
|
|
129
|
+
cwd: process.cwd(),
|
|
130
|
+
source: 'startup',
|
|
131
|
+
}, buildCopilotHookConfig(env, sessionId));
|
|
132
|
+
logger.info(`[copilot-cli] SessionStart hook completed for session ${sessionId}`);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
136
|
+
logger.error(`[copilot-cli] SessionStart hook failed (non-blocking): ${message}`);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async beforeRun(env, config) {
|
|
140
|
+
assertCopilotProviderSupported(config);
|
|
141
|
+
// Prevent fallback to GitHub-native auth even when GitHub credentials exist.
|
|
142
|
+
delete env.GH_TOKEN;
|
|
143
|
+
delete env.GITHUB_TOKEN;
|
|
144
|
+
delete env.COPILOT_TOKEN;
|
|
145
|
+
if (!env.COPILOT_HOME) {
|
|
146
|
+
env.COPILOT_HOME = this.resolveDataPath();
|
|
147
|
+
}
|
|
148
|
+
await this.ensureDirectory(env.COPILOT_HOME);
|
|
149
|
+
const availableModels = (env.CODEMIE_COPILOT_AVAILABLE_MODELS || '')
|
|
150
|
+
.split(',')
|
|
151
|
+
.map((entry) => entry.trim())
|
|
152
|
+
.filter(Boolean);
|
|
153
|
+
if (env.CODEMIE_MODEL) {
|
|
154
|
+
assertExplicitCopilotModelAllowed(env.CODEMIE_MODEL, availableModels);
|
|
155
|
+
}
|
|
156
|
+
const providerEnv = buildCopilotProviderEnv(env);
|
|
157
|
+
Object.assign(env, providerEnv);
|
|
158
|
+
logger.debug('[copilot-cli] Prepared provider env for managed Copilot session', {
|
|
159
|
+
provider: config.provider,
|
|
160
|
+
model: env.CODEMIE_MODEL,
|
|
161
|
+
providerType: providerEnv.COPILOT_PROVIDER_TYPE,
|
|
162
|
+
clientType: COPILOT_CLI_CLIENT_TYPE,
|
|
163
|
+
});
|
|
164
|
+
return env;
|
|
165
|
+
},
|
|
166
|
+
enrichArgs(args, _config) {
|
|
167
|
+
const enriched = [...args];
|
|
168
|
+
const hasPrompt = enriched.includes('-p') || enriched.includes('--prompt');
|
|
169
|
+
const hasAutoApproval = enriched.includes('--allow-all') || enriched.includes('--allow-all-tools') || enriched.includes('--yolo');
|
|
170
|
+
const hasModel = enriched.includes('--model');
|
|
171
|
+
if (hasPrompt && !hasAutoApproval) {
|
|
172
|
+
enriched.push('--allow-all-tools');
|
|
173
|
+
}
|
|
174
|
+
if (!hasModel && process.env.CODEMIE_MODEL) {
|
|
175
|
+
enriched.push('--model', process.env.CODEMIE_MODEL);
|
|
176
|
+
}
|
|
177
|
+
return enriched;
|
|
178
|
+
},
|
|
179
|
+
async onSessionEnd(exitCode, env) {
|
|
180
|
+
const sessionId = env.CODEMIE_SESSION_ID;
|
|
181
|
+
if (!sessionId) {
|
|
182
|
+
logger.debug('[copilot-cli] No CODEMIE_SESSION_ID in environment, skipping session end');
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
const adapter = new CopilotCliSessionAdapter(CopilotCliPluginMetadata);
|
|
187
|
+
const sessions = await adapter.discoverSessions({
|
|
188
|
+
maxAgeDays: 1,
|
|
189
|
+
limit: 1,
|
|
190
|
+
cwd: process.cwd(),
|
|
191
|
+
});
|
|
192
|
+
const transcriptPath = sessions[0]?.filePath ?? '';
|
|
193
|
+
const agentSessionId = sessions[0]?.sessionId ?? sessionId;
|
|
194
|
+
const { processEvent } = await import('../../../cli/commands/hook.js');
|
|
195
|
+
await processEvent({
|
|
196
|
+
hook_event_name: 'SessionEnd',
|
|
197
|
+
session_id: agentSessionId,
|
|
198
|
+
transcript_path: transcriptPath,
|
|
199
|
+
permission_mode: 'default',
|
|
200
|
+
cwd: process.cwd(),
|
|
201
|
+
reason: exitCode === 0 ? 'exit' : `exit(${exitCode})`,
|
|
202
|
+
}, buildCopilotHookConfig(env, sessionId));
|
|
203
|
+
logger.info(`[copilot-cli] SessionEnd hook completed for session ${sessionId}`);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
207
|
+
logger.error(`[copilot-cli] SessionEnd hook failed (non-blocking): ${message}`);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
},
|
|
39
211
|
};
|
|
40
212
|
export class CopilotCliPlugin extends BaseAgentAdapter {
|
|
41
213
|
sessionAdapter = null;
|
|
@@ -48,17 +220,44 @@ export class CopilotCliPlugin extends BaseAgentAdapter {
|
|
|
48
220
|
}
|
|
49
221
|
return this.sessionAdapter;
|
|
50
222
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
223
|
+
async setupProxy(env) {
|
|
224
|
+
if (env.CODEMIE_PROVIDER !== 'ai-run-sso' && env.CODEMIE_AUTH_METHOD !== 'jwt') {
|
|
225
|
+
await super.setupProxy(env);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const modelSource = env.CODEMIE_MODEL_SOURCE;
|
|
229
|
+
const explicitModel = env.CODEMIE_MODEL && (modelSource === 'cli' || modelSource === 'env')
|
|
230
|
+
? env.CODEMIE_MODEL
|
|
231
|
+
: undefined;
|
|
232
|
+
const { selectedModel, availableModels } = await resolveCopilotModel(env);
|
|
233
|
+
if (explicitModel) {
|
|
234
|
+
assertExplicitCopilotModelAllowed(explicitModel, availableModels);
|
|
235
|
+
env.CODEMIE_MODEL = explicitModel;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
env.CODEMIE_MODEL = selectedModel;
|
|
239
|
+
}
|
|
240
|
+
env.CODEMIE_COPILOT_AVAILABLE_MODELS = availableModels.join(',');
|
|
241
|
+
await super.setupProxy(env);
|
|
54
242
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
243
|
+
async isInstalled() {
|
|
244
|
+
if (!this.metadata.cliCommand) {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
return commandExists(this.metadata.cliCommand);
|
|
58
248
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
249
|
+
async getVersion() {
|
|
250
|
+
if (!this.metadata.cliCommand) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const result = await exec(this.metadata.cliCommand, ['--version']);
|
|
255
|
+
const match = result.stdout.trim().match(/(\d+\.\d+\.\d+)/);
|
|
256
|
+
return match ? match[1] : result.stdout.trim() || null;
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
62
261
|
}
|
|
63
262
|
}
|
|
64
263
|
//# sourceMappingURL=copilot-cli.plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-cli.plugin.js","sourceRoot":"","sources":["../../../../src/agents/plugins/copilot-cli/copilot-cli.plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copilot-cli.plugin.js","sourceRoot":"","sources":["../../../../src/agents/plugins/copilot-cli/copilot-cli.plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iCAAiC,EACjC,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,yBAAyB,GAAG,QAAQ,CAAC;AAC3C,MAAM,iCAAiC,GAAG,QAAQ,CAAC;AACnD,MAAM,4BAA4B,GAAG,CAAC,YAAY,EAAE,SAAS,CAAU,CAAC;AACxE,MAAM,0BAA0B,GAAG,CAAC,SAAS,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;AAE/E,SAAS,sBAAsB,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AMG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"copilot-cli.session.d.ts","sourceRoot":"","sources":["../../../../src/agents/plugins/copilot-cli/copilot-cli.session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAmCzD,qBAAa,wBAAyB,YAAW,cAAc;IAIjD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,QAAQ,CAAC,SAAS,iBAA0B;IAC5C,OAAO,CAAC,UAAU,CAA0B;gBAEf,QAAQ,EAAE,aAAa;IAKpD,iBAAiB,CAAC,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAQpD;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAuEvF;;;;;;OAMG;IACG,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAmMnF,yEAAyE;IACnE,cAAc,CAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC;CAwC7B"}
|
|
@@ -191,7 +191,12 @@ export class CopilotCliSessionAdapter {
|
|
|
191
191
|
break;
|
|
192
192
|
}
|
|
193
193
|
case 'user.message': {
|
|
194
|
-
const
|
|
194
|
+
const data = event.data ?? {};
|
|
195
|
+
const text = typeof data.text === 'string' && data.text.trim()
|
|
196
|
+
? data.text
|
|
197
|
+
: typeof data.content === 'string'
|
|
198
|
+
? data.content
|
|
199
|
+
: undefined;
|
|
195
200
|
if (typeof text === 'string' && text.trim()) {
|
|
196
201
|
userPrompts.push({ count: 1, text });
|
|
197
202
|
}
|
|
@@ -218,7 +223,14 @@ export class CopilotCliSessionAdapter {
|
|
|
218
223
|
timestamp: event.timestamp,
|
|
219
224
|
cwd,
|
|
220
225
|
gitBranch: branch,
|
|
221
|
-
message: {
|
|
226
|
+
message: {
|
|
227
|
+
role: 'assistant',
|
|
228
|
+
model: data.model ?? currentModel,
|
|
229
|
+
content: typeof data.content === 'string'
|
|
230
|
+
? data.content
|
|
231
|
+
: '',
|
|
232
|
+
toolRequests: Array.isArray(data.toolRequests) ? data.toolRequests : [],
|
|
233
|
+
},
|
|
222
234
|
};
|
|
223
235
|
if (!record.message.model) {
|
|
224
236
|
unlabelledTurns.push(record);
|