@cydm/happy-elves 0.1.0-beta.259 → 0.1.0-beta.260
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/apps/cli/package.json +1 -1
- package/apps/daemon/dist/runtime/external-provider.js +9 -1
- package/apps/daemon/package.json +1 -1
- package/package.json +1 -1
- package/packages/runtime-cli/dist/codex-app-server.js +1 -1
- package/packages/runtime-cli/dist/index.d.ts +1 -0
- package/packages/runtime-cli/dist/index.js +64 -5
package/apps/cli/package.json
CHANGED
|
@@ -169,6 +169,10 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
169
169
|
const clients = options.providers.map((config) => new ExternalProviderClient(config));
|
|
170
170
|
const clientsByAgent = new Map();
|
|
171
171
|
async function initialize() {
|
|
172
|
+
const fallback = options.fallback;
|
|
173
|
+
if (typeof fallback.initialize === "function") {
|
|
174
|
+
await fallback.initialize().catch(() => undefined);
|
|
175
|
+
}
|
|
172
176
|
await Promise.all(clients.map(async (client) => {
|
|
173
177
|
await client.initialize().catch(() => undefined);
|
|
174
178
|
for (const agent of client.listAgents())
|
|
@@ -273,7 +277,11 @@ export function createExternalAgentRuntimeProvider(options) {
|
|
|
273
277
|
return {
|
|
274
278
|
initialize,
|
|
275
279
|
diagnostics() {
|
|
276
|
-
|
|
280
|
+
const fallback = options.fallback;
|
|
281
|
+
const fallbackDiagnostics = typeof fallback.diagnostics === "function"
|
|
282
|
+
? fallback.diagnostics()
|
|
283
|
+
: [];
|
|
284
|
+
return [...fallbackDiagnostics, ...clients.map((client) => client.diagnostics())];
|
|
277
285
|
},
|
|
278
286
|
dispose() {
|
|
279
287
|
for (const client of clients)
|
package/apps/daemon/package.json
CHANGED
package/package.json
CHANGED
|
@@ -385,7 +385,7 @@ export class CodexAppServerSession {
|
|
|
385
385
|
}
|
|
386
386
|
const CODEX_MODEL_LIST_PAGE_LIMIT = 100;
|
|
387
387
|
const CODEX_MODEL_LIST_PAGE_SAFETY_LIMIT = 100;
|
|
388
|
-
const CODEX_PROVIDER_DISCOVERY_TIMEOUT_MS =
|
|
388
|
+
const CODEX_PROVIDER_DISCOVERY_TIMEOUT_MS = 20_000;
|
|
389
389
|
export async function discoverCodexRuntimeOptions(input) {
|
|
390
390
|
const discovery = new CodexAppServerSession(input.command, input.cwd);
|
|
391
391
|
const timeoutMs = Math.max(1, input.timeoutMs ?? CODEX_PROVIDER_DISCOVERY_TIMEOUT_MS);
|
|
@@ -11,5 +11,6 @@ export type CliRuntimeProviderOptions = {
|
|
|
11
11
|
};
|
|
12
12
|
export declare function createCliRuntimeProvider(options: CliRuntimeProviderOptions): HappyElvesRuntime & {
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
|
+
diagnostics(): Array<Record<string, unknown>>;
|
|
14
15
|
};
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -15,6 +15,14 @@ export function createCliRuntimeProvider(options) {
|
|
|
15
15
|
const codexCommand = options.codexCommand ?? process.env.HAPPY_ELVES_CODEX_COMMAND ?? "codex";
|
|
16
16
|
const claudeCommand = options.claudeCommand ?? process.env.HAPPY_ELVES_CLAUDE_COMMAND ?? "claude";
|
|
17
17
|
let codexOptions = codexAgentModels();
|
|
18
|
+
let codexModelDiscovery = {
|
|
19
|
+
provider: "cli",
|
|
20
|
+
component: "codex-model-discovery",
|
|
21
|
+
status: "not-run",
|
|
22
|
+
source: codexOptions.models && codexOptions.models.length > 0 ? "fallback" : undefined,
|
|
23
|
+
modelCount: codexOptions.models?.length ?? 0,
|
|
24
|
+
...(codexOptions.defaultModel ? { defaultModel: codexOptions.defaultModel } : {}),
|
|
25
|
+
};
|
|
18
26
|
const sessions = new CliSessionStore({ cwd: options.cwd, codexCommand });
|
|
19
27
|
const historySnapshotDir = path.join(options.stateDir, "history-snapshots");
|
|
20
28
|
async function listHistoricalSessionPage(input) {
|
|
@@ -72,19 +80,70 @@ export function createCliRuntimeProvider(options) {
|
|
|
72
80
|
const configured = agentModelsFromEnv("HAPPY_ELVES_CODEX");
|
|
73
81
|
if (configured.models && configured.models.length > 0) {
|
|
74
82
|
codexOptions = configured;
|
|
83
|
+
codexModelDiscovery = {
|
|
84
|
+
provider: "cli",
|
|
85
|
+
component: "codex-model-discovery",
|
|
86
|
+
status: "configured",
|
|
87
|
+
source: "env",
|
|
88
|
+
modelCount: configured.models.length,
|
|
89
|
+
...(configured.defaultModel ? { defaultModel: configured.defaultModel } : {}),
|
|
90
|
+
};
|
|
75
91
|
return;
|
|
76
92
|
}
|
|
93
|
+
const startedAt = Date.now();
|
|
77
94
|
const discovered = await discoverCodexRuntimeOptions({
|
|
78
95
|
command: codexCommand,
|
|
79
96
|
cwd: options.cwd,
|
|
80
97
|
timeoutMs: options.codexDiscoveryTimeoutMs,
|
|
81
|
-
}).catch(() =>
|
|
82
|
-
|
|
83
|
-
|
|
98
|
+
}).catch((error) => {
|
|
99
|
+
codexModelDiscovery = {
|
|
100
|
+
provider: "cli",
|
|
101
|
+
component: "codex-model-discovery",
|
|
102
|
+
status: "failed",
|
|
103
|
+
source: "provider",
|
|
104
|
+
elapsedMs: Date.now() - startedAt,
|
|
105
|
+
error: error instanceof Error ? error.message : String(error),
|
|
106
|
+
};
|
|
107
|
+
return undefined;
|
|
108
|
+
});
|
|
109
|
+
if (discovered?.models && discovered.models.length > 0) {
|
|
110
|
+
codexOptions = {
|
|
84
111
|
...(configured.defaultModel ? { defaultModel: configured.defaultModel } : discovered.defaultModel ? { defaultModel: discovered.defaultModel } : {}),
|
|
85
112
|
models: discovered.models,
|
|
86
|
-
}
|
|
87
|
-
|
|
113
|
+
};
|
|
114
|
+
codexModelDiscovery = {
|
|
115
|
+
provider: "cli",
|
|
116
|
+
component: "codex-model-discovery",
|
|
117
|
+
status: "ok",
|
|
118
|
+
source: "provider",
|
|
119
|
+
elapsedMs: Date.now() - startedAt,
|
|
120
|
+
modelCount: discovered.models.length,
|
|
121
|
+
...(codexOptions.defaultModel ? { defaultModel: codexOptions.defaultModel } : {}),
|
|
122
|
+
};
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
codexOptions = codexAgentModels();
|
|
126
|
+
if (codexModelDiscovery.status !== "failed") {
|
|
127
|
+
codexModelDiscovery = {
|
|
128
|
+
provider: "cli",
|
|
129
|
+
component: "codex-model-discovery",
|
|
130
|
+
status: "failed",
|
|
131
|
+
source: "provider",
|
|
132
|
+
elapsedMs: Date.now() - startedAt,
|
|
133
|
+
error: "Codex provider model/list returned no models",
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
if (codexOptions.models && codexOptions.models.length > 0) {
|
|
137
|
+
codexModelDiscovery = {
|
|
138
|
+
...codexModelDiscovery,
|
|
139
|
+
source: "fallback",
|
|
140
|
+
modelCount: codexOptions.models.length,
|
|
141
|
+
...(codexOptions.defaultModel ? { defaultModel: codexOptions.defaultModel } : {}),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
diagnostics() {
|
|
146
|
+
return [codexModelDiscovery];
|
|
88
147
|
},
|
|
89
148
|
getCapabilities() {
|
|
90
149
|
return {
|