abtars 0.2.2 → 0.2.3-alpha.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/bundle/{_registry.generated-KYX63MGY.js → _registry.generated-KM6LXTNJ.js} +2 -2
- package/bundle/abtars-cli.js +6 -3
- package/bundle/abtars-cli.js.map +2 -2
- package/bundle/abtars.js +29 -28
- package/bundle/abtars.js.map +3 -3
- package/bundle/{agent-registry-PIS5XJHX.js → agent-registry-ABPFQXNL.js} +2 -2
- package/bundle/{chunk-QSC6QZ44.js → chunk-2SFN2VYD.js} +2 -2
- package/bundle/{chunk-BBTQKKDO.js → chunk-2W6JIHZ5.js} +2 -1
- package/bundle/chunk-2W6JIHZ5.js.map +7 -0
- package/bundle/{chunk-3IPMKYYH.js → chunk-6TSCOXF6.js} +56 -25
- package/bundle/chunk-6TSCOXF6.js.map +7 -0
- package/bundle/{chunk-7WFE2JI5.js → chunk-7B3GK5JQ.js} +2 -2
- package/bundle/{chunk-SMZQDMSZ.js → chunk-ENXQMPV3.js} +1 -2
- package/bundle/chunk-ENXQMPV3.js.map +7 -0
- package/bundle/{chunk-N24ROESF.js → chunk-HFPXN6NM.js} +1 -1
- package/bundle/chunk-HFPXN6NM.js.map +7 -0
- package/bundle/{chunk-Y2XBDQP3.js → chunk-SEXVA3GK.js} +144 -37
- package/bundle/chunk-SEXVA3GK.js.map +7 -0
- package/bundle/{commands-LAWVNQTO.js → commands-L6VIMPCR.js} +2 -2
- package/bundle/{direct-api-transport-QIWA5ES2.js → direct-api-transport-BK72AP3I.js} +1 -1
- package/bundle/{direct-api-transport-QIWA5ES2.js.map → direct-api-transport-BK72AP3I.js.map} +2 -2
- package/bundle/{discord-adapter-W6L5KJ6T.js → discord-adapter-DWIQRNDI.js} +3 -3
- package/bundle/{doctor-PIPSGI3H.js → doctor-WHTVSUOF.js} +36 -26
- package/bundle/doctor-WHTVSUOF.js.map +7 -0
- package/bundle/{install-I3CXVW52.js → install-Q4XNCPG7.js} +2 -2
- package/bundle/{message-pipeline-4CTBJ6K2.js → message-pipeline-GCSZCQWO.js} +2 -2
- package/bundle/meta.json +298 -279
- package/bundle/{phase-transport-INFD6ELA.js → phase-transport-F7GQRRYE.js} +3 -3
- package/bundle/{sleep-ENFZFUJJ.js → sleep-MYOZ73IU.js} +2 -2
- package/bundle/{subagent-runtime-5AYOXOU2.js → subagent-runtime-QA4LVU4C.js} +2 -2
- package/bundle/{system-status-7K2QTH3J.js → system-status-KMKPAC5Z.js} +4 -2
- package/bundle/system-status-KMKPAC5Z.js.map +7 -0
- package/bundle/{telegram-adapter-4KI4CJPG.js → telegram-adapter-TRMCC634.js} +7 -4
- package/bundle/telegram-adapter-TRMCC634.js.map +7 -0
- package/config/transport.default.json +2 -1
- package/install-manifest.json +0 -3
- package/package.json +1 -1
- package/scripts/abtars-daemon.service +0 -4
- package/scripts/abtars@.service +0 -4
- package/scripts/build-and-deploy.sh +15 -27
- package/bundle/agent-registry-5VL5KI6U.js +0 -19
- package/bundle/chunk-3IPMKYYH.js.map +0 -7
- package/bundle/chunk-4WKWPU6U.js +0 -1089
- package/bundle/chunk-4WKWPU6U.js.map +0 -7
- package/bundle/chunk-5WFIAUQC.js +0 -672
- package/bundle/chunk-5WFIAUQC.js.map +0 -7
- package/bundle/chunk-B52YRWR6.js +0 -257
- package/bundle/chunk-B52YRWR6.js.map +0 -7
- package/bundle/chunk-BBTQKKDO.js.map +0 -7
- package/bundle/chunk-HAS5NEK7.js +0 -189
- package/bundle/chunk-HAS5NEK7.js.map +0 -7
- package/bundle/chunk-HB54S5OY.js +0 -4036
- package/bundle/chunk-HB54S5OY.js.map +0 -7
- package/bundle/chunk-N24ROESF.js.map +0 -7
- package/bundle/chunk-N7UG4FID.js +0 -4036
- package/bundle/chunk-N7UG4FID.js.map +0 -7
- package/bundle/chunk-PUDGA4RR.js +0 -183
- package/bundle/chunk-QSC6QZ44.js.map +0 -7
- package/bundle/chunk-SMZQDMSZ.js.map +0 -7
- package/bundle/chunk-VY2BUO6L.js +0 -4035
- package/bundle/chunk-VY2BUO6L.js.map +0 -7
- package/bundle/chunk-Y2XBDQP3.js.map +0 -7
- package/bundle/chunk-YMGX6HNP.js +0 -131
- package/bundle/chunk-YMGX6HNP.js.map +0 -7
- package/bundle/commands-IGRSOSK6.js +0 -34
- package/bundle/commands-RBWY7YXB.js +0 -34
- package/bundle/commands-XFZNMZN6.js +0 -34
- package/bundle/direct-api-transport-OZICXTWQ.js +0 -889
- package/bundle/direct-api-transport-OZICXTWQ.js.map +0 -7
- package/bundle/discord-adapter-JFIIVG34.js +0 -589
- package/bundle/discord-adapter-U3FA5OTY.js +0 -589
- package/bundle/discord-adapter-U3FA5OTY.js.map +0 -7
- package/bundle/discord-adapter-W6L5KJ6T.js.map +0 -7
- package/bundle/discord-adapter-WWM6ROTW.js +0 -589
- package/bundle/discord-adapter-WWM6ROTW.js.map +0 -7
- package/bundle/doctor-PIPSGI3H.js.map +0 -7
- package/bundle/kanban-board-6Q5E5GEB.js +0 -31
- package/bundle/kanban-board-6Q5E5GEB.js.map +0 -7
- package/bundle/message-pipeline-4CTBJ6K2.js.map +0 -7
- package/bundle/message-pipeline-4KL7OWUH.js +0 -38
- package/bundle/message-pipeline-4KL7OWUH.js.map +0 -7
- package/bundle/message-pipeline-GFKSHRFU.js +0 -38
- package/bundle/message-pipeline-GFKSHRFU.js.map +0 -7
- package/bundle/message-pipeline-TGI2WJJM.js +0 -38
- package/bundle/message-pipeline-TGI2WJJM.js.map +0 -7
- package/bundle/phase-transport-INFD6ELA.js.map +0 -7
- package/bundle/phase-transport-KXFZ5BVF.js +0 -23
- package/bundle/phase-transport-KXFZ5BVF.js.map +0 -7
- package/bundle/sleep-ENFZFUJJ.js.map +0 -7
- package/bundle/subagent-runtime-5AYOXOU2.js.map +0 -7
- package/bundle/subagent-runtime-VKTX6Q2M.js +0 -13
- package/bundle/subagent-runtime-VKTX6Q2M.js.map +0 -7
- package/bundle/system-status-7K2QTH3J.js.map +0 -7
- package/bundle/telegram-adapter-4KI4CJPG.js.map +0 -7
- package/bundle/telegram-adapter-76B4JRJJ.js +0 -1080
- package/bundle/telegram-adapter-76B4JRJJ.js.map +0 -7
- package/bundle/telegram-adapter-VZA74EMT.js +0 -1080
- package/bundle/telegram-adapter-VZA74EMT.js.map +0 -7
- package/bundle/telegram-adapter-ZO2CLU22.js +0 -1080
- package/bundle/telegram-adapter-ZO2CLU22.js.map +0 -7
- package/bundle/tool-registry-TGNU5AMG.js +0 -43
- package/bundle/tool-registry-TGNU5AMG.js.map +0 -7
- /package/bundle/{_registry.generated-KYX63MGY.js.map → _registry.generated-KM6LXTNJ.js.map} +0 -0
- /package/bundle/{agent-registry-5VL5KI6U.js.map → agent-registry-ABPFQXNL.js.map} +0 -0
- /package/bundle/{chunk-PUDGA4RR.js.map → chunk-2SFN2VYD.js.map} +0 -0
- /package/bundle/{chunk-7WFE2JI5.js.map → chunk-7B3GK5JQ.js.map} +0 -0
- /package/bundle/{agent-registry-PIS5XJHX.js.map → commands-L6VIMPCR.js.map} +0 -0
- /package/bundle/{discord-adapter-JFIIVG34.js.map → discord-adapter-DWIQRNDI.js.map} +0 -0
- /package/bundle/{commands-IGRSOSK6.js.map → install-Q4XNCPG7.js.map} +0 -0
- /package/bundle/{commands-LAWVNQTO.js.map → message-pipeline-GCSZCQWO.js.map} +0 -0
- /package/bundle/{commands-RBWY7YXB.js.map → phase-transport-F7GQRRYE.js.map} +0 -0
- /package/bundle/{commands-XFZNMZN6.js.map → sleep-MYOZ73IU.js.map} +0 -0
- /package/bundle/{install-I3CXVW52.js.map → subagent-runtime-QA4LVU4C.js.map} +0 -0
package/bundle/chunk-HAS5NEK7.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __bundleCreateRequire } from 'node:module'; import { fileURLToPath as __bundleFileURLToPath } from 'node:url'; import { dirname as __bundleDirname } from 'node:path'; const require = __bundleCreateRequire(import.meta.url); const __chunk_filename = __bundleFileURLToPath(import.meta.url); const __chunk_dirname = __bundleDirname(__chunk_filename);
|
|
3
|
-
import {
|
|
4
|
-
AcpTransport
|
|
5
|
-
} from "./chunk-PKHYCNTT.js";
|
|
6
|
-
import {
|
|
7
|
-
getEnv,
|
|
8
|
-
init_env_schema
|
|
9
|
-
} from "./chunk-3OXQWII3.js";
|
|
10
|
-
import {
|
|
11
|
-
init_logger,
|
|
12
|
-
logInfo,
|
|
13
|
-
logWarn
|
|
14
|
-
} from "./chunk-GUTRAMK3.js";
|
|
15
|
-
|
|
16
|
-
// src/components/agent-registry.ts
|
|
17
|
-
init_env_schema();
|
|
18
|
-
init_logger();
|
|
19
|
-
var AGENT_ROLES = {
|
|
20
|
-
professor: { agent: "professor", model: null, persona: "persona/core/SOUL.md", autoReinit: true, tag: "acp-main", trust: 3 },
|
|
21
|
-
dreamy: { agent: "dreamy", model: null, persona: "persona/prompts/sleep/00-identity.md", autoReinit: false, tag: "acp-sleep", trust: 2 },
|
|
22
|
-
coding: { agent: "coding-agent", model: null, persona: null, autoReinit: true, tag: "acp-coding", trust: 2 },
|
|
23
|
-
browsie: { agent: "browsie", model: null, persona: null, autoReinit: false, tag: "acp-browsie", trust: 1 },
|
|
24
|
-
task: { agent: "professor", model: null, persona: null, autoReinit: false, tag: "acp-task", trust: 2 }
|
|
25
|
-
};
|
|
26
|
-
function resolveModel(role) {
|
|
27
|
-
switch (role) {
|
|
28
|
-
case "dreamy":
|
|
29
|
-
return getEnv().sleepModel;
|
|
30
|
-
case "browsie":
|
|
31
|
-
return getEnv().browsingAgent;
|
|
32
|
-
case "coding":
|
|
33
|
-
return getEnv().codingModel;
|
|
34
|
-
default:
|
|
35
|
-
return void 0;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function createAgentTransport(role, tc, overrides) {
|
|
39
|
-
const cfg = { ...AGENT_ROLES[role], ...overrides };
|
|
40
|
-
const cliArgs = tc.agentCli === "gemini" ? ["--acp", "-y"] : void 0;
|
|
41
|
-
const model = tc.model ?? resolveModel(role);
|
|
42
|
-
return new AcpTransport(tc.cliPath, tc.workingDir, {
|
|
43
|
-
agent: cfg.agent ?? void 0,
|
|
44
|
-
model,
|
|
45
|
-
autoReinit: cfg.autoReinit,
|
|
46
|
-
tag: cfg.tag,
|
|
47
|
-
cliArgs
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
var SUBAGENT_TO_AGENT = {
|
|
51
|
-
sleep: "dreamy",
|
|
52
|
-
browse: "browsie",
|
|
53
|
-
coding: "coding",
|
|
54
|
-
task: "professor"
|
|
55
|
-
};
|
|
56
|
-
var SUBAGENT_ACP_ROLE = {
|
|
57
|
-
sleep: "dreamy",
|
|
58
|
-
browse: "browsie",
|
|
59
|
-
coding: "coding",
|
|
60
|
-
task: "task"
|
|
61
|
-
};
|
|
62
|
-
async function createSubagentTransport(role, registry, currentModel) {
|
|
63
|
-
const { resolveAgent, getEnvFallback, loadTransport } = await import("./transport-config-JIKHB7GT.js");
|
|
64
|
-
const tc = loadTransport();
|
|
65
|
-
const agentName = SUBAGENT_TO_AGENT[role];
|
|
66
|
-
const resolved = tc ? resolveAgent(agentName, tc) : null;
|
|
67
|
-
const profResolved = resolved ?? (tc ? resolveAgent("professor", tc) : null);
|
|
68
|
-
const agent = profResolved ?? (() => {
|
|
69
|
-
const fb = getEnvFallback();
|
|
70
|
-
return { model: fb.model, provider: fb.provider, providerName: fb.providerName, contextWindow: fb.contextWindow, maxOutput: fb.maxOutput, fallbacks: [] };
|
|
71
|
-
})();
|
|
72
|
-
if (agent.provider.transport === "api") {
|
|
73
|
-
const { DirectApiTransport } = await import("./direct-api-transport-OZICXTWQ.js");
|
|
74
|
-
const { FallbackPolicy } = await import("./fallback-policy-SR6ED5I3.js");
|
|
75
|
-
const apiKey = getEnv().getApiKey(agent.provider.apiKeyEnv ?? "API_KEY");
|
|
76
|
-
const startModel = currentModel ?? agent.model;
|
|
77
|
-
const candidates = [
|
|
78
|
-
{ endpoint: agent.provider.endpoint ?? "http://localhost:11434/v1", apiKey, model: startModel, maxContext: agent.contextWindow }
|
|
79
|
-
];
|
|
80
|
-
if (agent.model !== startModel && !candidates.some((c) => c.model === agent.model)) {
|
|
81
|
-
candidates.push({ endpoint: agent.provider.endpoint ?? "http://localhost:11434/v1", apiKey, model: agent.model, maxContext: agent.contextWindow });
|
|
82
|
-
}
|
|
83
|
-
const profAgent = tc ? resolveAgent("professor", tc) : null;
|
|
84
|
-
const agentTransport = agent.provider.transport ?? "api";
|
|
85
|
-
if (profAgent && profAgent.model !== startModel && !candidates.some((c) => c.model === profAgent.model)) {
|
|
86
|
-
const profTransport = profAgent.provider.transport ?? "api";
|
|
87
|
-
if (profTransport === agentTransport && profAgent.provider.endpoint) {
|
|
88
|
-
candidates.push({
|
|
89
|
-
endpoint: profAgent.provider.endpoint,
|
|
90
|
-
apiKey: profAgent.provider.apiKeyEnv ? getEnv().getApiKey(profAgent.provider.apiKeyEnv) : apiKey,
|
|
91
|
-
model: profAgent.model,
|
|
92
|
-
maxContext: profAgent.contextWindow
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (profAgent) {
|
|
97
|
-
for (const fb of profAgent.fallbacks ?? []) {
|
|
98
|
-
if (candidates.some((c) => c.model === fb.model)) continue;
|
|
99
|
-
const fbProvider = tc?.providers[fb.provider];
|
|
100
|
-
const fbEndpoint = fbProvider?.endpoint ?? profAgent.provider.endpoint;
|
|
101
|
-
if (!fbEndpoint) {
|
|
102
|
-
logWarn("subagent", `Skipping fallback ${fb.model} \u2014 no endpoint configured`);
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
const fbApiKey = fbProvider?.apiKeyEnv ? getEnv().getApiKey(fbProvider.apiKeyEnv) : apiKey;
|
|
106
|
-
candidates.push({ endpoint: fbEndpoint, apiKey: fbApiKey, model: fb.model, maxContext: profAgent.contextWindow });
|
|
107
|
-
}
|
|
108
|
-
for (const chainModel of profAgent.provider.fallbackChain ?? []) {
|
|
109
|
-
if (candidates.some((c) => c.model === chainModel)) continue;
|
|
110
|
-
if (!profAgent.provider.endpoint) {
|
|
111
|
-
logWarn("subagent", `Skipping chain model ${chainModel} \u2014 no endpoint configured`);
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
candidates.push({ endpoint: profAgent.provider.endpoint, apiKey, model: chainModel, maxContext: profAgent.contextWindow });
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (const fb of agent.fallbacks) {
|
|
118
|
-
if (candidates.some((c) => c.model === fb.model)) continue;
|
|
119
|
-
const fbProvider = tc?.providers[fb.provider];
|
|
120
|
-
const fbEndpoint = fbProvider?.endpoint ?? agent.provider.endpoint;
|
|
121
|
-
if (!fbEndpoint) {
|
|
122
|
-
logWarn("subagent", `Skipping fallback ${fb.model} \u2014 no endpoint configured`);
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
const fbApiKey = fbProvider?.apiKeyEnv ? getEnv().getApiKey(fbProvider.apiKeyEnv) : apiKey;
|
|
126
|
-
candidates.push({ endpoint: fbEndpoint, apiKey: fbApiKey, model: fb.model, maxContext: agent.contextWindow });
|
|
127
|
-
}
|
|
128
|
-
const chain2 = agent.provider.fallbackChain ?? [];
|
|
129
|
-
for (const chainModel of chain2) {
|
|
130
|
-
if (!candidates.some((c) => c.model === chainModel)) {
|
|
131
|
-
if (!agent.provider.endpoint) {
|
|
132
|
-
logWarn("subagent", `Skipping chain model ${chainModel} \u2014 no endpoint configured`);
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
candidates.push({
|
|
136
|
-
endpoint: agent.provider.endpoint,
|
|
137
|
-
apiKey,
|
|
138
|
-
model: chainModel,
|
|
139
|
-
maxContext: agent.contextWindow
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const { ModelHealthRegistry } = await import("./model-health-registry-7ECZFCW4.js");
|
|
144
|
-
const policy = new FallbackPolicy(candidates, registry ?? new ModelHealthRegistry());
|
|
145
|
-
const transport = new DirectApiTransport({
|
|
146
|
-
endpoint: agent.provider.endpoint ?? "http://localhost:11434/v1",
|
|
147
|
-
apiKey,
|
|
148
|
-
model: startModel,
|
|
149
|
-
maxContext: agent.contextWindow,
|
|
150
|
-
maxOutput: agent.maxOutput,
|
|
151
|
-
maxTurns: tc?.maxTurns ?? 50
|
|
152
|
-
}, policy);
|
|
153
|
-
await transport.initialize();
|
|
154
|
-
logInfo("subagent", `${role} transport: DirectAPI ${agent.providerName} (model=${startModel}, ${candidates.length} candidates, shared registry: ${!!registry})`);
|
|
155
|
-
return { transport, model: agent.model };
|
|
156
|
-
}
|
|
157
|
-
const { loadAndValidateConfig } = await import("./config-NDEYF4AQ.js");
|
|
158
|
-
const config = await loadAndValidateConfig();
|
|
159
|
-
const chain = agent.provider.fallbackChain ?? [];
|
|
160
|
-
const modelsToTry = [agent.model, ...chain.filter((m) => m !== agent.model)];
|
|
161
|
-
for (let i = 0; i < modelsToTry.length; i++) {
|
|
162
|
-
const model = modelsToTry[i];
|
|
163
|
-
const transport = createAgentTransport(SUBAGENT_ACP_ROLE[role], {
|
|
164
|
-
cliPath: agent.provider.cli ?? config.transport.agentCliPath,
|
|
165
|
-
workingDir: config.transport.workingDir,
|
|
166
|
-
agentCli: agent.provider.cli ?? "kiro-cli",
|
|
167
|
-
model
|
|
168
|
-
});
|
|
169
|
-
try {
|
|
170
|
-
await transport.initialize();
|
|
171
|
-
if (i > 0) logWarn("subagent", `${role}: configured model failed, fell back to ${model}`);
|
|
172
|
-
logInfo("subagent", `${role} transport: ACP ${agent.providerName} (model=${model}${i > 0 ? ", fallback" : ""})`);
|
|
173
|
-
return { transport, model };
|
|
174
|
-
} catch (err) {
|
|
175
|
-
if (i < modelsToTry.length - 1) {
|
|
176
|
-
logWarn("subagent", `${role}: model ${model} init failed (${err instanceof Error ? err.message : String(err)}), trying ${modelsToTry[i + 1]}`);
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
throw err;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
throw new Error(`${role}: all models exhausted (tried ${modelsToTry.join(", ")})`);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export {
|
|
186
|
-
createAgentTransport,
|
|
187
|
-
createSubagentTransport
|
|
188
|
-
};
|
|
189
|
-
//# sourceMappingURL=chunk-HAS5NEK7.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/components/agent-registry.ts"],
|
|
4
|
-
"sourcesContent": ["import { getEnv } from \"./env-schema.js\";\n/**\n * agent-registry.ts \u2014 Centralized agent role configuration.\n * Single factory for all agent transports. Transport-agnostic.\n */\n\nimport { AcpTransport } from \"./transport/acp-transport.js\";\nimport { logInfo, logWarn } from \"./logger.js\";\nimport type { IKiroTransport } from \"./transport/kiro-transport.js\";\n\nexport type AgentRole = \"professor\" | \"dreamy\" | \"browsie\" | \"coding\" | \"task\";\n\nexport interface AgentRoleConfig {\n agent: string | null;\n model: string | null;\n persona: string | null;\n autoReinit: boolean;\n tag: string;\n trust: number;\n}\n\nconst AGENT_ROLES: Record<AgentRole, AgentRoleConfig> = {\n professor: { agent: \"professor\", model: null, persona: \"persona/core/SOUL.md\", autoReinit: true, tag: \"acp-main\", trust: 3 },\n dreamy: { agent: \"dreamy\", model: null, persona: \"persona/prompts/sleep/00-identity.md\", autoReinit: false, tag: \"acp-sleep\", trust: 2 },\n coding: { agent: \"coding-agent\", model: null, persona: null, autoReinit: true, tag: \"acp-coding\", trust: 2 },\n browsie: { agent: \"browsie\", model: null, persona: null, autoReinit: false, tag: \"acp-browsie\", trust: 1 },\n task: { agent: \"professor\", model: null, persona: null, autoReinit: false, tag: \"acp-task\", trust: 2 },\n};\n\nfunction resolveModel(role: AgentRole): string | undefined {\n switch (role) {\n case \"dreamy\": return getEnv().sleepModel;\n case \"browsie\": return getEnv().browsingAgent;\n case \"coding\": return getEnv().codingModel;\n default: return undefined;\n }\n}\n\nexport interface TransportConfig {\n cliPath: string;\n workingDir: string;\n agentCli?: string;\n model?: string;\n}\n\nexport function createAgentTransport(\n role: AgentRole,\n tc: TransportConfig,\n overrides?: Partial<AgentRoleConfig>,\n): AcpTransport {\n const cfg = { ...AGENT_ROLES[role], ...overrides };\n const cliArgs = tc.agentCli === \"gemini\" ? [\"--acp\", \"-y\"] : undefined;\n const model = tc.model ?? resolveModel(role);\n\n return new AcpTransport(tc.cliPath, tc.workingDir, {\n agent: cfg.agent ?? undefined,\n model,\n autoReinit: cfg.autoReinit,\n tag: cfg.tag,\n cliArgs,\n });\n}\n\nexport type SubagentRole = \"sleep\" | \"browse\" | \"coding\" | \"task\";\n\nconst SUBAGENT_TO_AGENT: Record<SubagentRole, string> = {\n sleep: \"dreamy\",\n browse: \"browsie\",\n coding: \"coding\",\n task: \"professor\",\n};\n\nconst SUBAGENT_ACP_ROLE: Record<SubagentRole, AgentRole> = {\n sleep: \"dreamy\",\n browse: \"browsie\",\n coding: \"coding\",\n task: \"task\",\n};\n\n/** Unified transport factory for all subagents. Reads from transport.json + models.json. */\n/** @internal Used only by SubagentRuntime. Do not call directly. */\nexport async function createSubagentTransport(role: SubagentRole, registry?: import(\"./transport/model-health-registry.js\").ModelHealthRegistry, currentModel?: string): Promise<{ transport: IKiroTransport; model: string }> {\n const { resolveAgent, getEnvFallback, loadTransport } = await import(\"./transport-config.js\");\n const tc = loadTransport();\n const agentName = SUBAGENT_TO_AGENT[role];\n const resolved = tc ? resolveAgent(agentName, tc) : null;\n\n // Fallback: use professor's config. If that also fails, use .env defaults.\n const profResolved = resolved ?? (tc ? resolveAgent(\"professor\", tc) : null);\n const agent = profResolved ?? (() => {\n const fb = getEnvFallback();\n return { model: fb.model, provider: fb.provider, providerName: fb.providerName, contextWindow: fb.contextWindow, maxOutput: fb.maxOutput, fallbacks: [] };\n })();\n\n if (agent.provider.transport === \"api\") {\n const { DirectApiTransport } = await import(\"./transport/direct-api-transport.js\");\n const { FallbackPolicy } = await import(\"./transport/fallback-policy.js\");\n const apiKey = getEnv().getApiKey(agent.provider.apiKeyEnv ?? \"API_KEY\");\n\n // Use main transport's active model if available, else static config\n const startModel = currentModel ?? agent.model;\n\n // Build per-agent candidate list\n const candidates: Array<{ model: string; endpoint: string; apiKey?: string; maxContext: number }> = [\n { endpoint: agent.provider.endpoint ?? \"http://localhost:11434/v1\", apiKey, model: startModel, maxContext: agent.contextWindow },\n ];\n\n // Add static config model if different from startModel\n if (agent.model !== startModel && !candidates.some(c => c.model === agent.model)) {\n candidates.push({ endpoint: agent.provider.endpoint ?? \"http://localhost:11434/v1\", apiKey, model: agent.model, maxContext: agent.contextWindow });\n }\n\n // Add professor's model as fallback if different and transport-compatible\n const profAgent = tc ? resolveAgent(\"professor\", tc) : null;\n const agentTransport = agent.provider.transport ?? \"api\";\n if (profAgent && profAgent.model !== startModel && !candidates.some(c => c.model === profAgent.model)) {\n const profTransport = profAgent.provider.transport ?? \"api\";\n if (profTransport === agentTransport && profAgent.provider.endpoint) {\n candidates.push({\n endpoint: profAgent.provider.endpoint,\n apiKey: profAgent.provider.apiKeyEnv ? getEnv().getApiKey(profAgent.provider.apiKeyEnv) : apiKey,\n model: profAgent.model,\n maxContext: profAgent.contextWindow,\n });\n }\n }\n\n // Inherit professor's full fallback chain (fb1\u2192fb2\u2192fb3)\n if (profAgent) {\n for (const fb of profAgent.fallbacks ?? []) {\n if (candidates.some(c => c.model === fb.model)) continue;\n const fbProvider = tc?.providers[fb.provider];\n const fbEndpoint = fbProvider?.endpoint ?? profAgent.provider.endpoint;\n if (!fbEndpoint) { logWarn(\"subagent\", `Skipping fallback ${fb.model} \u2014 no endpoint configured`); continue; }\n const fbApiKey = fbProvider?.apiKeyEnv ? getEnv().getApiKey(fbProvider.apiKeyEnv) : apiKey;\n candidates.push({ endpoint: fbEndpoint, apiKey: fbApiKey, model: fb.model, maxContext: profAgent.contextWindow });\n }\n for (const chainModel of profAgent.provider.fallbackChain ?? []) {\n if (candidates.some(c => c.model === chainModel)) continue;\n if (!profAgent.provider.endpoint) { logWarn(\"subagent\", `Skipping chain model ${chainModel} \u2014 no endpoint configured`); continue; }\n candidates.push({ endpoint: profAgent.provider.endpoint, apiKey, model: chainModel, maxContext: profAgent.contextWindow });\n }\n }\n\n // Append agent-level cross-provider fallbacks\n for (const fb of agent.fallbacks) {\n if (candidates.some(c => c.model === fb.model)) continue;\n const fbProvider = tc?.providers[fb.provider];\n const fbEndpoint = fbProvider?.endpoint ?? agent.provider.endpoint;\n if (!fbEndpoint) { logWarn(\"subagent\", `Skipping fallback ${fb.model} \u2014 no endpoint configured`); continue; }\n const fbApiKey = fbProvider?.apiKeyEnv ? getEnv().getApiKey(fbProvider.apiKeyEnv) : apiKey;\n candidates.push({ endpoint: fbEndpoint, apiKey: fbApiKey, model: fb.model, maxContext: agent.contextWindow });\n }\n\n // Append fallbackChain entries as last-resort candidates\n const chain = agent.provider.fallbackChain ?? [];\n for (const chainModel of chain) {\n if (!candidates.some(c => c.model === chainModel)) {\n if (!agent.provider.endpoint) { logWarn(\"subagent\", `Skipping chain model ${chainModel} \u2014 no endpoint configured`); continue; }\n candidates.push({\n endpoint: agent.provider.endpoint,\n apiKey, model: chainModel, maxContext: agent.contextWindow,\n });\n }\n }\n\n // Use shared registry if provided, otherwise create isolated one\n const { ModelHealthRegistry } = await import(\"./transport/model-health-registry.js\");\n const policy = new FallbackPolicy(candidates, registry ?? new ModelHealthRegistry());\n\n const transport = new DirectApiTransport({\n endpoint: agent.provider.endpoint ?? \"http://localhost:11434/v1\",\n apiKey, model: startModel,\n maxContext: agent.contextWindow, maxOutput: agent.maxOutput,\n maxTurns: tc?.maxTurns ?? 50,\n }, policy);\n await transport.initialize();\n logInfo(\"subagent\", `${role} transport: DirectAPI ${agent.providerName} (model=${startModel}, ${candidates.length} candidates, shared registry: ${!!registry})`);\n return { transport, model: agent.model };\n }\n\n // ACP path \u2014 try configured model, then fallbackChain on failure\n const { loadAndValidateConfig } = await import(\"./config.js\");\n const config = await loadAndValidateConfig();\n const chain = agent.provider.fallbackChain ?? [];\n const modelsToTry = [agent.model, ...chain.filter(m => m !== agent.model)];\n\n for (let i = 0; i < modelsToTry.length; i++) {\n const model = modelsToTry[i]!;\n const transport = createAgentTransport(SUBAGENT_ACP_ROLE[role], {\n cliPath: agent.provider.cli ?? config.transport.agentCliPath,\n workingDir: config.transport.workingDir,\n agentCli: agent.provider.cli ?? \"kiro-cli\",\n model,\n });\n try {\n await transport.initialize();\n if (i > 0) logWarn(\"subagent\", `${role}: configured model failed, fell back to ${model}`);\n logInfo(\"subagent\", `${role} transport: ACP ${agent.providerName} (model=${model}${i > 0 ? \", fallback\" : \"\"})`);\n return { transport, model };\n } catch (err) {\n if (i < modelsToTry.length - 1) {\n logWarn(\"subagent\", `${role}: model ${model} init failed (${err instanceof Error ? err.message : String(err)}), trying ${modelsToTry[i + 1]}`);\n continue;\n }\n throw err;\n }\n }\n throw new Error(`${role}: all models exhausted (tried ${modelsToTry.join(\", \")})`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAOA;AAcA,IAAM,cAAkD;AAAA,EACtD,WAAW,EAAE,OAAO,aAAa,OAAO,MAAM,SAAS,wBAAwB,YAAY,MAAM,KAAK,YAAY,OAAO,EAAE;AAAA,EAC3H,QAAQ,EAAE,OAAO,UAAU,OAAO,MAAM,SAAS,wCAAwC,YAAY,OAAO,KAAK,aAAa,OAAO,EAAE;AAAA,EACvI,QAAQ,EAAE,OAAO,gBAAgB,OAAO,MAAM,SAAS,MAAM,YAAY,MAAM,KAAK,cAAc,OAAO,EAAE;AAAA,EAC3G,SAAS,EAAE,OAAO,WAAW,OAAO,MAAM,SAAS,MAAM,YAAY,OAAO,KAAK,eAAe,OAAO,EAAE;AAAA,EACzG,MAAM,EAAE,OAAO,aAAa,OAAO,MAAM,SAAS,MAAM,YAAY,OAAO,KAAK,YAAY,OAAO,EAAE;AACvG;AAE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