@covibes/zeroshot 5.3.0 → 5.4.1
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/LICENSE +1 -1
- package/README.md +8 -385
- package/cli/index.js +108 -4615
- package/package.json +16 -125
- package/CHANGELOG.md +0 -537
- package/cli/commands/providers.js +0 -150
- package/cli/lib/first-run.js +0 -211
- package/cli/lib/update-checker.js +0 -281
- package/cli/message-formatter-utils.js +0 -75
- package/cli/message-formatters-normal.js +0 -253
- package/cli/message-formatters-watch.js +0 -181
- package/cluster-templates/base-templates/debug-workflow.json +0 -375
- package/cluster-templates/base-templates/full-workflow.json +0 -697
- package/cluster-templates/base-templates/single-worker.json +0 -63
- package/cluster-templates/base-templates/worker-validator.json +0 -152
- package/cluster-templates/conductor-bootstrap.json +0 -124
- package/docker/zeroshot-cluster/Dockerfile +0 -152
- package/docker/zeroshot-cluster/pre-baked-deps.json +0 -28
- package/lib/completion.js +0 -174
- package/lib/docker-config.js +0 -212
- package/lib/id-detector.js +0 -53
- package/lib/provider-detection.js +0 -59
- package/lib/provider-names.js +0 -56
- package/lib/settings.js +0 -405
- package/lib/stream-json-parser.js +0 -10
- package/scripts/fix-node-pty-permissions.js +0 -75
- package/scripts/record-demo.sh +0 -279
- package/scripts/test-install.sh +0 -40
- package/scripts/validate-templates.js +0 -100
- package/src/agent/agent-config.js +0 -193
- package/src/agent/agent-context-builder.js +0 -335
- package/src/agent/agent-hook-executor.js +0 -402
- package/src/agent/agent-lifecycle.js +0 -683
- package/src/agent/agent-stuck-detector.js +0 -256
- package/src/agent/agent-task-executor.js +0 -1431
- package/src/agent/agent-trigger-evaluator.js +0 -67
- package/src/agent/output-extraction.js +0 -200
- package/src/agent/output-reformatter.js +0 -175
- package/src/agent/schema-utils.js +0 -111
- package/src/agent-wrapper.js +0 -570
- package/src/agents/git-pusher-agent.json +0 -20
- package/src/attach/attach-client.js +0 -438
- package/src/attach/attach-server.js +0 -543
- package/src/attach/index.js +0 -35
- package/src/attach/protocol.js +0 -220
- package/src/attach/ring-buffer.js +0 -121
- package/src/attach/socket-discovery.js +0 -267
- package/src/claude-task-runner.js +0 -523
- package/src/config-router.js +0 -80
- package/src/config-validator.js +0 -1660
- package/src/copy-worker.js +0 -43
- package/src/github.js +0 -139
- package/src/isolation-manager.js +0 -1381
- package/src/ledger.js +0 -614
- package/src/logic-engine.js +0 -223
- package/src/message-bus-bridge.js +0 -139
- package/src/message-bus.js +0 -249
- package/src/name-generator.js +0 -232
- package/src/orchestrator.js +0 -2519
- package/src/preflight.js +0 -485
- package/src/process-metrics.js +0 -566
- package/src/providers/anthropic/cli-builder.js +0 -45
- package/src/providers/anthropic/index.js +0 -134
- package/src/providers/anthropic/models.js +0 -23
- package/src/providers/anthropic/output-parser.js +0 -159
- package/src/providers/base-provider.js +0 -181
- package/src/providers/capabilities.js +0 -51
- package/src/providers/google/cli-builder.js +0 -55
- package/src/providers/google/index.js +0 -116
- package/src/providers/google/models.js +0 -24
- package/src/providers/google/output-parser.js +0 -92
- package/src/providers/index.js +0 -75
- package/src/providers/openai/cli-builder.js +0 -122
- package/src/providers/openai/index.js +0 -135
- package/src/providers/openai/models.js +0 -21
- package/src/providers/openai/output-parser.js +0 -129
- package/src/schemas/sub-cluster.js +0 -156
- package/src/status-footer.js +0 -980
- package/src/sub-cluster-wrapper.js +0 -560
- package/src/task-runner.js +0 -30
- package/src/template-resolver.js +0 -369
- package/src/tui/CHANGES.txt +0 -133
- package/src/tui/LAYOUT.md +0 -261
- package/src/tui/README.txt +0 -192
- package/src/tui/TWO-LEVEL-NAVIGATION.md +0 -186
- package/src/tui/data-poller.js +0 -325
- package/src/tui/demo.js +0 -208
- package/src/tui/formatters.js +0 -128
- package/src/tui/index.js +0 -193
- package/src/tui/keybindings.js +0 -383
- package/src/tui/layout.js +0 -334
- package/src/tui/renderer.js +0 -194
- package/task-lib/attachable-watcher.js +0 -272
- package/task-lib/claude-recovery.js +0 -119
- package/task-lib/commands/clean.js +0 -50
- package/task-lib/commands/get-log-path.js +0 -23
- package/task-lib/commands/kill.js +0 -32
- package/task-lib/commands/list.js +0 -105
- package/task-lib/commands/logs.js +0 -411
- package/task-lib/commands/resume.js +0 -42
- package/task-lib/commands/run.js +0 -57
- package/task-lib/commands/schedule.js +0 -105
- package/task-lib/commands/scheduler-cmd.js +0 -96
- package/task-lib/commands/schedules.js +0 -98
- package/task-lib/commands/status.js +0 -44
- package/task-lib/commands/unschedule.js +0 -16
- package/task-lib/completion.js +0 -9
- package/task-lib/config.js +0 -10
- package/task-lib/name-generator.js +0 -230
- package/task-lib/package.json +0 -3
- package/task-lib/runner.js +0 -144
- package/task-lib/scheduler.js +0 -252
- package/task-lib/store.js +0 -230
- package/task-lib/tui/formatters.js +0 -166
- package/task-lib/tui/index.js +0 -197
- package/task-lib/tui/layout.js +0 -111
- package/task-lib/tui/renderer.js +0 -119
- package/task-lib/tui.js +0 -384
- package/task-lib/watcher.js +0 -188
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
const BaseProvider = require('../base-provider');
|
|
2
|
-
const { commandExists, getCommandPath, getHelpOutput } = require('../../../lib/provider-detection');
|
|
3
|
-
const { buildCommand } = require('./cli-builder');
|
|
4
|
-
const { parseEvent } = require('./output-parser');
|
|
5
|
-
const {
|
|
6
|
-
MODEL_CATALOG,
|
|
7
|
-
LEVEL_MAPPING,
|
|
8
|
-
DEFAULT_LEVEL,
|
|
9
|
-
DEFAULT_MAX_LEVEL,
|
|
10
|
-
DEFAULT_MIN_LEVEL,
|
|
11
|
-
} = require('./models');
|
|
12
|
-
|
|
13
|
-
const warned = new Set();
|
|
14
|
-
|
|
15
|
-
class GoogleProvider extends BaseProvider {
|
|
16
|
-
constructor() {
|
|
17
|
-
super({ name: 'gemini', displayName: 'Gemini', cliCommand: 'gemini' });
|
|
18
|
-
this._cliFeatures = null;
|
|
19
|
-
this._unknownEventCounts = new Map();
|
|
20
|
-
this._parserState = { lastToolId: null };
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// SDK not implemented - uses CLI only
|
|
24
|
-
// See BaseProvider for SDK extension point documentation
|
|
25
|
-
|
|
26
|
-
isAvailable() {
|
|
27
|
-
return commandExists(this.cliCommand);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getCliPath() {
|
|
31
|
-
return getCommandPath(this.cliCommand) || this.cliCommand;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
getInstallInstructions() {
|
|
35
|
-
return 'npm install -g @google/gemini-cli';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getAuthInstructions() {
|
|
39
|
-
return 'gemini auth login';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getCliFeatures() {
|
|
43
|
-
if (this._cliFeatures) return this._cliFeatures;
|
|
44
|
-
const help = getHelpOutput(this.cliCommand);
|
|
45
|
-
const unknown = !help;
|
|
46
|
-
|
|
47
|
-
const features = {
|
|
48
|
-
supportsStreamJson: unknown ? true : /--output-format\b/.test(help),
|
|
49
|
-
supportsAutoApprove: unknown ? true : /--yolo\b/.test(help),
|
|
50
|
-
supportsCwd: unknown ? true : /--cwd\b/.test(help),
|
|
51
|
-
supportsModel: unknown ? true : /\s-m\b/.test(help) || /--model\b/.test(help),
|
|
52
|
-
unknown,
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
this._cliFeatures = features;
|
|
56
|
-
return features;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getCredentialPaths() {
|
|
60
|
-
return ['~/.config/gcloud', '~/.config/gemini', '~/.gemini'];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
buildCommand(context, options) {
|
|
64
|
-
const cliFeatures = options.cliFeatures || {};
|
|
65
|
-
|
|
66
|
-
if (options.autoApprove && cliFeatures.supportsAutoApprove === false) {
|
|
67
|
-
this._warnOnce(
|
|
68
|
-
'gemini-auto-approve',
|
|
69
|
-
'Gemini CLI does not support --yolo; continuing without auto-approve.'
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return buildCommand(context, { ...options, cliFeatures });
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
parseEvent(line) {
|
|
77
|
-
return parseEvent(line, this._parserState, {
|
|
78
|
-
onUnknown: (type) => this._logUnknown(type),
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getModelCatalog() {
|
|
83
|
-
return MODEL_CATALOG;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
getLevelMapping() {
|
|
87
|
-
return LEVEL_MAPPING;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getDefaultLevel() {
|
|
91
|
-
return DEFAULT_LEVEL;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
getDefaultMaxLevel() {
|
|
95
|
-
return DEFAULT_MAX_LEVEL;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getDefaultMinLevel() {
|
|
99
|
-
return DEFAULT_MIN_LEVEL;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
_warnOnce(key, message) {
|
|
103
|
-
if (warned.has(key)) return;
|
|
104
|
-
warned.add(key);
|
|
105
|
-
console.warn(`⚠️ ${message}`);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
_logUnknown(type) {
|
|
109
|
-
const current = this._unknownEventCounts.get(type) || 0;
|
|
110
|
-
if (current >= 5) return;
|
|
111
|
-
this._unknownEventCounts.set(type, current + 1);
|
|
112
|
-
console.debug(`[gemini] Unknown event type: ${type}`);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
module.exports = GoogleProvider;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Gemini CLI model names
|
|
2
|
-
// Model is optional - Gemini defaults to best available
|
|
3
|
-
const MODEL_CATALOG = {
|
|
4
|
-
'gemini-2.5-pro': { rank: 3 },
|
|
5
|
-
'gemini-2.0-flash': { rank: 1 },
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const LEVEL_MAPPING = {
|
|
9
|
-
level1: { rank: 1, model: null },
|
|
10
|
-
level2: { rank: 2, model: null },
|
|
11
|
-
level3: { rank: 3, model: null },
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const DEFAULT_LEVEL = 'level2';
|
|
15
|
-
const DEFAULT_MAX_LEVEL = 'level3';
|
|
16
|
-
const DEFAULT_MIN_LEVEL = 'level1';
|
|
17
|
-
|
|
18
|
-
module.exports = {
|
|
19
|
-
MODEL_CATALOG,
|
|
20
|
-
LEVEL_MAPPING,
|
|
21
|
-
DEFAULT_LEVEL,
|
|
22
|
-
DEFAULT_MAX_LEVEL,
|
|
23
|
-
DEFAULT_MIN_LEVEL,
|
|
24
|
-
};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
function normalizeMessageContent(content) {
|
|
2
|
-
if (typeof content === 'string') return content;
|
|
3
|
-
if (Array.isArray(content)) {
|
|
4
|
-
return content.map((item) => (typeof item === 'string' ? item : item?.text || '')).join('');
|
|
5
|
-
}
|
|
6
|
-
if (content && typeof content === 'object') {
|
|
7
|
-
if (typeof content.text === 'string') return content.text;
|
|
8
|
-
}
|
|
9
|
-
return '';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function parseEvent(line, state = {}, options = {}) {
|
|
13
|
-
let event;
|
|
14
|
-
try {
|
|
15
|
-
event = JSON.parse(line);
|
|
16
|
-
} catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
switch (event.type) {
|
|
21
|
-
case 'init':
|
|
22
|
-
return null;
|
|
23
|
-
|
|
24
|
-
case 'message':
|
|
25
|
-
if (event.role === 'assistant') {
|
|
26
|
-
const text = normalizeMessageContent(event.content);
|
|
27
|
-
if (text) {
|
|
28
|
-
return { type: 'text', text };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
|
|
33
|
-
case 'tool_use': {
|
|
34
|
-
const toolId = event.tool_call_id || event.tool_id || event.id || state.lastToolId;
|
|
35
|
-
const toolName = event.tool_name || event.name;
|
|
36
|
-
state.lastToolId = toolId;
|
|
37
|
-
return {
|
|
38
|
-
type: 'tool_call',
|
|
39
|
-
toolName,
|
|
40
|
-
toolId,
|
|
41
|
-
input: event.parameters || event.input || {},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
case 'tool_result': {
|
|
46
|
-
const toolId = event.tool_call_id || event.tool_id || event.id || state.lastToolId;
|
|
47
|
-
return {
|
|
48
|
-
type: 'tool_result',
|
|
49
|
-
toolId,
|
|
50
|
-
content: event.output ?? event.content ?? '',
|
|
51
|
-
isError: event.success === false,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
case 'result':
|
|
56
|
-
return {
|
|
57
|
-
type: 'result',
|
|
58
|
-
success: event.success !== false,
|
|
59
|
-
result: event.result || '',
|
|
60
|
-
error: event.success === false ? event.error || 'Result failed' : null,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
default:
|
|
64
|
-
if (options.onUnknown) {
|
|
65
|
-
options.onUnknown(event.type, event);
|
|
66
|
-
}
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function parseChunk(chunk, state = {}, options = {}) {
|
|
72
|
-
const events = [];
|
|
73
|
-
const lines = chunk.split('\n');
|
|
74
|
-
|
|
75
|
-
for (const line of lines) {
|
|
76
|
-
if (!line.trim()) continue;
|
|
77
|
-
const event = parseEvent(line, state, options);
|
|
78
|
-
if (!event) continue;
|
|
79
|
-
if (Array.isArray(event)) {
|
|
80
|
-
events.push(...event);
|
|
81
|
-
} else {
|
|
82
|
-
events.push(event);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return events;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = {
|
|
90
|
-
parseEvent,
|
|
91
|
-
parseChunk,
|
|
92
|
-
};
|
package/src/providers/index.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
const AnthropicProvider = require('./anthropic');
|
|
2
|
-
const OpenAIProvider = require('./openai');
|
|
3
|
-
const GoogleProvider = require('./google');
|
|
4
|
-
const { normalizeProviderName } = require('../../lib/provider-names');
|
|
5
|
-
|
|
6
|
-
const PROVIDERS = {
|
|
7
|
-
claude: AnthropicProvider,
|
|
8
|
-
codex: OpenAIProvider,
|
|
9
|
-
gemini: GoogleProvider,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function getProvider(name) {
|
|
13
|
-
const normalized = normalizeProviderName(name || '');
|
|
14
|
-
const Provider = PROVIDERS[normalized];
|
|
15
|
-
if (!Provider) {
|
|
16
|
-
throw new Error(`Unknown provider: ${name}. Valid: ${Object.keys(PROVIDERS).join(', ')}`);
|
|
17
|
-
}
|
|
18
|
-
return new Provider();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function detectProviders() {
|
|
22
|
-
const results = {};
|
|
23
|
-
for (const [name, Provider] of Object.entries(PROVIDERS)) {
|
|
24
|
-
const provider = new Provider();
|
|
25
|
-
results[name] = {
|
|
26
|
-
available: await provider.isAvailable(),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return results;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function listProviders() {
|
|
33
|
-
return Object.keys(PROVIDERS);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function stripTimestampPrefix(line) {
|
|
37
|
-
if (!line || typeof line !== 'string') return '';
|
|
38
|
-
const trimmed = line.trim().replace(/\r$/, '');
|
|
39
|
-
if (!trimmed) return '';
|
|
40
|
-
const match = trimmed.match(/^\[(\d{13})\](.*)$/);
|
|
41
|
-
return match ? match[2] : trimmed;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function parseChunkWithProvider(provider, chunk) {
|
|
45
|
-
if (!chunk) return [];
|
|
46
|
-
const events = [];
|
|
47
|
-
const lines = chunk.split('\n');
|
|
48
|
-
|
|
49
|
-
for (const line of lines) {
|
|
50
|
-
const content = stripTimestampPrefix(line);
|
|
51
|
-
if (!content) continue;
|
|
52
|
-
const event = provider.parseEvent(content);
|
|
53
|
-
if (!event) continue;
|
|
54
|
-
if (Array.isArray(event)) {
|
|
55
|
-
events.push(...event);
|
|
56
|
-
} else {
|
|
57
|
-
events.push(event);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return events;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function parseProviderChunk(providerName, chunk) {
|
|
65
|
-
const provider = getProvider(providerName || 'claude');
|
|
66
|
-
return parseChunkWithProvider(provider, chunk);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
module.exports = {
|
|
70
|
-
getProvider,
|
|
71
|
-
detectProviders,
|
|
72
|
-
listProviders,
|
|
73
|
-
parseProviderChunk,
|
|
74
|
-
parseChunkWithProvider,
|
|
75
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const os = require('os');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Codex structured outputs require additionalProperties: false on ALL object schemas.
|
|
7
|
-
* This function recursively adds that constraint to ensure schema validation passes.
|
|
8
|
-
* @param {Object} schema - JSON Schema object
|
|
9
|
-
* @returns {Object} - Modified schema with additionalProperties: false on all objects
|
|
10
|
-
*/
|
|
11
|
-
function enforceStrictSchema(schema) {
|
|
12
|
-
if (!schema || typeof schema !== 'object') return schema;
|
|
13
|
-
|
|
14
|
-
const result = { ...schema };
|
|
15
|
-
|
|
16
|
-
// Add additionalProperties: false to object types
|
|
17
|
-
if (result.type === 'object') {
|
|
18
|
-
result.additionalProperties = false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Recurse into properties
|
|
22
|
-
if (result.properties) {
|
|
23
|
-
result.properties = {};
|
|
24
|
-
for (const [key, value] of Object.entries(schema.properties)) {
|
|
25
|
-
result.properties[key] = enforceStrictSchema(value);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Recurse into items (arrays)
|
|
30
|
-
if (result.items) {
|
|
31
|
-
result.items = enforceStrictSchema(schema.items);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Recurse into anyOf/oneOf/allOf
|
|
35
|
-
for (const key of ['anyOf', 'oneOf', 'allOf']) {
|
|
36
|
-
if (Array.isArray(result[key])) {
|
|
37
|
-
result[key] = result[key].map(enforceStrictSchema);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Recurse into additionalProperties if it's a schema
|
|
42
|
-
if (result.additionalProperties && typeof result.additionalProperties === 'object') {
|
|
43
|
-
result.additionalProperties = enforceStrictSchema(result.additionalProperties);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function buildCommand(context, options = {}) {
|
|
50
|
-
const { modelSpec, outputFormat, jsonSchema, cwd, autoApprove, cliFeatures = {} } = options;
|
|
51
|
-
|
|
52
|
-
const args = ['exec'];
|
|
53
|
-
const cleanup = []; // Files to cleanup after command completes
|
|
54
|
-
|
|
55
|
-
if ((outputFormat === 'stream-json' || outputFormat === 'json') && cliFeatures.supportsJson) {
|
|
56
|
-
args.push('--json');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (modelSpec?.model) {
|
|
60
|
-
args.push('-m', modelSpec.model);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (modelSpec?.reasoningEffort && cliFeatures.supportsConfigOverride) {
|
|
64
|
-
args.push('--config', `model_reasoning_effort="${modelSpec.reasoningEffort}"`);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (cwd && cliFeatures.supportsCwd) {
|
|
68
|
-
args.push('-C', cwd);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (autoApprove && cliFeatures.supportsAutoApprove) {
|
|
72
|
-
args.push('--dangerously-bypass-approvals-and-sandbox');
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Augment context with schema if CLI doesn't support native --output-schema
|
|
76
|
-
let finalContext = context;
|
|
77
|
-
if (jsonSchema && cliFeatures.supportsOutputSchema) {
|
|
78
|
-
// CRITICAL: Codex --output-schema takes a FILE PATH, not a JSON string
|
|
79
|
-
// Write schema to temp file and pass the path
|
|
80
|
-
// Codex requires additionalProperties: false on all object schemas
|
|
81
|
-
const parsedSchema = typeof jsonSchema === 'string' ? JSON.parse(jsonSchema) : jsonSchema;
|
|
82
|
-
const strictSchema = enforceStrictSchema(parsedSchema);
|
|
83
|
-
const schemaStr = JSON.stringify(strictSchema, null, 2);
|
|
84
|
-
const schemaFile = path.join(
|
|
85
|
-
os.tmpdir(),
|
|
86
|
-
`zeroshot-schema-${Date.now()}-${Math.random().toString(36).slice(2)}.json`
|
|
87
|
-
);
|
|
88
|
-
fs.writeFileSync(schemaFile, schemaStr);
|
|
89
|
-
cleanup.push(schemaFile);
|
|
90
|
-
args.push('--output-schema', schemaFile);
|
|
91
|
-
} else if (jsonSchema) {
|
|
92
|
-
// CRITICAL: Inject schema into prompt when CLI doesn't support --output-schema
|
|
93
|
-
// Without this, model outputs free-form text instead of JSON
|
|
94
|
-
const schemaStr =
|
|
95
|
-
typeof jsonSchema === 'string' ? jsonSchema : JSON.stringify(jsonSchema, null, 2);
|
|
96
|
-
finalContext =
|
|
97
|
-
context +
|
|
98
|
-
`\n\n## OUTPUT FORMAT (CRITICAL - REQUIRED)
|
|
99
|
-
|
|
100
|
-
You MUST respond with a JSON object that exactly matches this schema. NO markdown, NO explanation, NO code blocks. ONLY the raw JSON object.
|
|
101
|
-
|
|
102
|
-
Schema:
|
|
103
|
-
\`\`\`json
|
|
104
|
-
${schemaStr}
|
|
105
|
-
\`\`\`
|
|
106
|
-
|
|
107
|
-
Your response must be ONLY valid JSON. Start with { and end with }. Nothing else.`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
args.push(finalContext);
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
binary: 'codex',
|
|
114
|
-
args,
|
|
115
|
-
env: {},
|
|
116
|
-
cleanup, // Temp files to delete after command completes
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
module.exports = {
|
|
121
|
-
buildCommand,
|
|
122
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
const BaseProvider = require('../base-provider');
|
|
2
|
-
const { commandExists, getCommandPath, getHelpOutput } = require('../../../lib/provider-detection');
|
|
3
|
-
const { buildCommand } = require('./cli-builder');
|
|
4
|
-
const { parseEvent } = require('./output-parser');
|
|
5
|
-
const {
|
|
6
|
-
MODEL_CATALOG,
|
|
7
|
-
LEVEL_MAPPING,
|
|
8
|
-
DEFAULT_LEVEL,
|
|
9
|
-
DEFAULT_MAX_LEVEL,
|
|
10
|
-
DEFAULT_MIN_LEVEL,
|
|
11
|
-
} = require('./models');
|
|
12
|
-
|
|
13
|
-
const warned = new Set();
|
|
14
|
-
|
|
15
|
-
class OpenAIProvider extends BaseProvider {
|
|
16
|
-
constructor() {
|
|
17
|
-
super({ name: 'codex', displayName: 'Codex', cliCommand: 'codex' });
|
|
18
|
-
this._cliFeatures = null;
|
|
19
|
-
this._unknownEventCounts = new Map();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// SDK not implemented - uses CLI only
|
|
23
|
-
// See BaseProvider for SDK extension point documentation
|
|
24
|
-
|
|
25
|
-
isAvailable() {
|
|
26
|
-
return commandExists(this.cliCommand);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
getCliPath() {
|
|
30
|
-
return getCommandPath(this.cliCommand) || this.cliCommand;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getInstallInstructions() {
|
|
34
|
-
return 'npm install -g @openai/codex';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getAuthInstructions() {
|
|
38
|
-
return 'codex login';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
getCliFeatures() {
|
|
42
|
-
if (this._cliFeatures) return this._cliFeatures;
|
|
43
|
-
// CRITICAL: Check 'codex exec --help' not 'codex --help'
|
|
44
|
-
// The --output-schema flag is on the exec subcommand, not the main command
|
|
45
|
-
const help = getHelpOutput(this.cliCommand, ['exec']);
|
|
46
|
-
const unknown = !help;
|
|
47
|
-
|
|
48
|
-
const features = {
|
|
49
|
-
supportsJson: unknown ? true : /--json\b/.test(help),
|
|
50
|
-
supportsOutputSchema: unknown ? true : /--output-schema\b/.test(help),
|
|
51
|
-
supportsAutoApprove: unknown
|
|
52
|
-
? true
|
|
53
|
-
: /--dangerously-bypass-approvals-and-sandbox\b/.test(help),
|
|
54
|
-
supportsCwd: unknown ? true : /\s-C\b/.test(help) || /--cwd\b/.test(help),
|
|
55
|
-
supportsConfigOverride: unknown ? true : /--config\b/.test(help),
|
|
56
|
-
supportsModel: unknown ? true : /\s-m\b/.test(help) || /--model\b/.test(help),
|
|
57
|
-
unknown,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
this._cliFeatures = features;
|
|
61
|
-
return features;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
getCredentialPaths() {
|
|
65
|
-
return ['~/.config/codex', '~/.codex'];
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
buildCommand(context, options) {
|
|
69
|
-
const cliFeatures = options.cliFeatures || {};
|
|
70
|
-
|
|
71
|
-
if (options.autoApprove && cliFeatures.supportsAutoApprove === false) {
|
|
72
|
-
this._warnOnce(
|
|
73
|
-
'codex-auto-approve',
|
|
74
|
-
'Codex CLI does not support auto-approve; continuing without bypass flag.'
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (options.jsonSchema && cliFeatures.supportsOutputSchema === false) {
|
|
79
|
-
this._warnOnce(
|
|
80
|
-
'codex-jsonschema',
|
|
81
|
-
'Codex CLI does not support --output-schema; skipping schema flag.'
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (options.modelSpec?.reasoningEffort && cliFeatures.supportsConfigOverride === false) {
|
|
86
|
-
this._warnOnce(
|
|
87
|
-
'codex-reasoning',
|
|
88
|
-
'Codex CLI does not support --config overrides; skipping reasoningEffort.'
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return buildCommand(context, { ...options, cliFeatures });
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
parseEvent(line) {
|
|
96
|
-
return parseEvent(line, {
|
|
97
|
-
onUnknown: (type) => this._logUnknown(type),
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
getModelCatalog() {
|
|
102
|
-
return MODEL_CATALOG;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getLevelMapping() {
|
|
106
|
-
return LEVEL_MAPPING;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
getDefaultLevel() {
|
|
110
|
-
return DEFAULT_LEVEL;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
getDefaultMaxLevel() {
|
|
114
|
-
return DEFAULT_MAX_LEVEL;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
getDefaultMinLevel() {
|
|
118
|
-
return DEFAULT_MIN_LEVEL;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
_warnOnce(key, message) {
|
|
122
|
-
if (warned.has(key)) return;
|
|
123
|
-
warned.add(key);
|
|
124
|
-
console.warn(`⚠️ ${message}`);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
_logUnknown(type) {
|
|
128
|
-
const current = this._unknownEventCounts.get(type) || 0;
|
|
129
|
-
if (current >= 5) return;
|
|
130
|
-
this._unknownEventCounts.set(type, current + 1);
|
|
131
|
-
console.debug(`[codex] Unknown event type: ${type}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
module.exports = OpenAIProvider;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Codex CLI - use null to let CLI pick its default model
|
|
2
|
-
// Levels vary by reasoning effort only
|
|
3
|
-
const MODEL_CATALOG = {};
|
|
4
|
-
|
|
5
|
-
const LEVEL_MAPPING = {
|
|
6
|
-
level1: { rank: 1, model: null, reasoningEffort: 'low' },
|
|
7
|
-
level2: { rank: 2, model: null, reasoningEffort: 'medium' },
|
|
8
|
-
level3: { rank: 3, model: null, reasoningEffort: 'high' },
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const DEFAULT_LEVEL = 'level2';
|
|
12
|
-
const DEFAULT_MAX_LEVEL = 'level3';
|
|
13
|
-
const DEFAULT_MIN_LEVEL = 'level1';
|
|
14
|
-
|
|
15
|
-
module.exports = {
|
|
16
|
-
MODEL_CATALOG,
|
|
17
|
-
LEVEL_MAPPING,
|
|
18
|
-
DEFAULT_LEVEL,
|
|
19
|
-
DEFAULT_MAX_LEVEL,
|
|
20
|
-
DEFAULT_MIN_LEVEL,
|
|
21
|
-
};
|