@sift-wiki/conductor 0.0.0 → 0.2.0-beta.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/README.md +105 -1
- package/THIRD_PARTY_NOTICES.md +38 -0
- package/dist/adapters/claudeAgent.d.ts +23 -0
- package/dist/adapters/claudeAgent.js +164 -0
- package/dist/adapters/claudeAgent.js.map +1 -0
- package/dist/adapters/claudeParser.d.ts +5 -0
- package/dist/adapters/claudeParser.js +120 -0
- package/dist/adapters/claudeParser.js.map +1 -0
- package/dist/adapters/codexAgent.d.ts +28 -0
- package/dist/adapters/codexAgent.js +152 -0
- package/dist/adapters/codexAgent.js.map +1 -0
- package/dist/adapters/codexParser.d.ts +5 -0
- package/dist/adapters/codexParser.js +106 -0
- package/dist/adapters/codexParser.js.map +1 -0
- package/dist/adapters/config.d.ts +29 -0
- package/dist/adapters/config.js +286 -0
- package/dist/adapters/config.js.map +1 -0
- package/dist/adapters/doctor.d.ts +12 -0
- package/dist/adapters/doctor.js +20 -0
- package/dist/adapters/doctor.js.map +1 -0
- package/dist/adapters/errors.d.ts +7 -0
- package/dist/adapters/errors.js +19 -0
- package/dist/adapters/errors.js.map +1 -0
- package/dist/adapters/fakeAgent.d.ts +11 -0
- package/dist/adapters/fakeAgent.js +149 -0
- package/dist/adapters/fakeAgent.js.map +1 -0
- package/dist/adapters/httpAgent.d.ts +19 -0
- package/dist/adapters/httpAgent.js +164 -0
- package/dist/adapters/httpAgent.js.map +1 -0
- package/dist/adapters/output.d.ts +16 -0
- package/dist/adapters/output.js +48 -0
- package/dist/adapters/output.js.map +1 -0
- package/dist/adapters/processAgent.d.ts +21 -0
- package/dist/adapters/processAgent.js +166 -0
- package/dist/adapters/processAgent.js.map +1 -0
- package/dist/adapters/provider/discovery.d.ts +31 -0
- package/dist/adapters/provider/discovery.js +102 -0
- package/dist/adapters/provider/discovery.js.map +1 -0
- package/dist/adapters/provider/json.d.ts +4 -0
- package/dist/adapters/provider/json.js +21 -0
- package/dist/adapters/provider/json.js.map +1 -0
- package/dist/adapters/provider/lineStream.d.ts +8 -0
- package/dist/adapters/provider/lineStream.js +28 -0
- package/dist/adapters/provider/lineStream.js.map +1 -0
- package/dist/adapters/provider/outputSchemaFile.d.ts +5 -0
- package/dist/adapters/provider/outputSchemaFile.js +16 -0
- package/dist/adapters/provider/outputSchemaFile.js.map +1 -0
- package/dist/adapters/provider/prompt.d.ts +2 -0
- package/dist/adapters/provider/prompt.js +52 -0
- package/dist/adapters/provider/prompt.js.map +1 -0
- package/dist/adapters/provider/result.d.ts +23 -0
- package/dist/adapters/provider/result.js +116 -0
- package/dist/adapters/provider/result.js.map +1 -0
- package/dist/adapters/provider/runProvider.d.ts +16 -0
- package/dist/adapters/provider/runProvider.js +110 -0
- package/dist/adapters/provider/runProvider.js.map +1 -0
- package/dist/adapters/provider/setup.d.ts +50 -0
- package/dist/adapters/provider/setup.js +180 -0
- package/dist/adapters/provider/setup.js.map +1 -0
- package/dist/adapters/provider/store.d.ts +19 -0
- package/dist/adapters/provider/store.js +92 -0
- package/dist/adapters/provider/store.js.map +1 -0
- package/dist/adapters/provider/types.d.ts +58 -0
- package/dist/adapters/provider/types.js +2 -0
- package/dist/adapters/provider/types.js.map +1 -0
- package/dist/adapters/provider/version.d.ts +2 -0
- package/dist/adapters/provider/version.js +25 -0
- package/dist/adapters/provider/version.js.map +1 -0
- package/dist/adapters/types.d.ts +40 -0
- package/dist/adapters/types.js +2 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/bridge/handler.d.ts +15 -0
- package/dist/bridge/handler.js +125 -0
- package/dist/bridge/handler.js.map +1 -0
- package/dist/bridge/localBridge.d.ts +49 -0
- package/dist/bridge/localBridge.js +157 -0
- package/dist/bridge/localBridge.js.map +1 -0
- package/dist/bridge/server.d.ts +11 -0
- package/dist/bridge/server.js +86 -0
- package/dist/bridge/server.js.map +1 -0
- package/dist/bridge/sessionRegistry.d.ts +23 -0
- package/dist/bridge/sessionRegistry.js +65 -0
- package/dist/bridge/sessionRegistry.js.map +1 -0
- package/dist/cli.d.ts +23 -0
- package/dist/cli.js +245 -0
- package/dist/cli.js.map +1 -0
- package/dist/conductorClient.d.ts +443 -0
- package/dist/conductorClient.js +281 -0
- package/dist/conductorClient.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon.d.ts +52 -0
- package/dist/daemon.js +324 -0
- package/dist/daemon.js.map +1 -0
- package/dist/desktop/adapterSetupView.d.ts +16 -0
- package/dist/desktop/adapterSetupView.js +13 -0
- package/dist/desktop/adapterSetupView.js.map +1 -0
- package/dist/desktop/app/contracts.d.ts +71 -0
- package/dist/desktop/app/contracts.js +19 -0
- package/dist/desktop/app/contracts.js.map +1 -0
- package/dist/desktop/app/controller.d.ts +58 -0
- package/dist/desktop/app/controller.js +161 -0
- package/dist/desktop/app/controller.js.map +1 -0
- package/dist/desktop/app/runtimeController.d.ts +22 -0
- package/dist/desktop/app/runtimeController.js +44 -0
- package/dist/desktop/app/runtimeController.js.map +1 -0
- package/dist/desktop/manifest.d.ts +17 -0
- package/dist/desktop/manifest.js +24 -0
- package/dist/desktop/manifest.js.map +1 -0
- package/dist/desktop/pairing.d.ts +13 -0
- package/dist/desktop/pairing.js +20 -0
- package/dist/desktop/pairing.js.map +1 -0
- package/dist/desktop/recovery.d.ts +33 -0
- package/dist/desktop/recovery.js +71 -0
- package/dist/desktop/recovery.js.map +1 -0
- package/dist/desktop/workBoardView.d.ts +41 -0
- package/dist/desktop/workBoardView.js +133 -0
- package/dist/desktop/workBoardView.js.map +1 -0
- package/dist/desktop/workGovernanceView.d.ts +70 -0
- package/dist/desktop/workGovernanceView.js +159 -0
- package/dist/desktop/workGovernanceView.js.map +1 -0
- package/dist/localApi/authorizedPairing.d.ts +12 -0
- package/dist/localApi/authorizedPairing.js +18 -0
- package/dist/localApi/authorizedPairing.js.map +1 -0
- package/dist/localApi/contracts.d.ts +253 -0
- package/dist/localApi/contracts.js +173 -0
- package/dist/localApi/contracts.js.map +1 -0
- package/dist/localApi/server.d.ts +20 -0
- package/dist/localApi/server.js +412 -0
- package/dist/localApi/server.js.map +1 -0
- package/dist/localApi/workConsole.d.ts +74 -0
- package/dist/localApi/workConsole.js +342 -0
- package/dist/localApi/workConsole.js.map +1 -0
- package/dist/localApi/workContracts.d.ts +213 -0
- package/dist/localApi/workContracts.js +130 -0
- package/dist/localApi/workContracts.js.map +1 -0
- package/dist/localApp/platform.d.ts +2 -0
- package/dist/localApp/platform.js +57 -0
- package/dist/localApp/platform.js.map +1 -0
- package/dist/localApp/service.d.ts +25 -0
- package/dist/localApp/service.js +114 -0
- package/dist/localApp/service.js.map +1 -0
- package/dist/pairing.d.ts +27 -0
- package/dist/pairing.js +45 -0
- package/dist/pairing.js.map +1 -0
- package/dist/redaction.d.ts +2 -0
- package/dist/redaction.js +34 -0
- package/dist/redaction.js.map +1 -0
- package/dist/release/validateDistribution.d.ts +51 -0
- package/dist/release/validateDistribution.js +54 -0
- package/dist/release/validateDistribution.js.map +1 -0
- package/dist/runtime/localLogSpool.d.ts +47 -0
- package/dist/runtime/localLogSpool.js +105 -0
- package/dist/runtime/localLogSpool.js.map +1 -0
- package/dist/runtime/localRunQueue.d.ts +31 -0
- package/dist/runtime/localRunQueue.js +76 -0
- package/dist/runtime/localRunQueue.js.map +1 -0
- package/dist/runtime/localSessionCache.d.ts +26 -0
- package/dist/runtime/localSessionCache.js +35 -0
- package/dist/runtime/localSessionCache.js.map +1 -0
- package/dist/runtime/process.d.ts +27 -0
- package/dist/runtime/process.js +128 -0
- package/dist/runtime/process.js.map +1 -0
- package/dist/runtime/runEnvironment.d.ts +12 -0
- package/dist/runtime/runEnvironment.js +59 -0
- package/dist/runtime/runEnvironment.js.map +1 -0
- package/dist/runtime/runEventRetryBuffer.d.ts +42 -0
- package/dist/runtime/runEventRetryBuffer.js +118 -0
- package/dist/runtime/runEventRetryBuffer.js.map +1 -0
- package/dist/runtime/runtimeService.d.ts +27 -0
- package/dist/runtime/runtimeService.js +112 -0
- package/dist/runtime/runtimeService.js.map +1 -0
- package/dist/runtime/sleep.d.ts +2 -0
- package/dist/runtime/sleep.js +21 -0
- package/dist/runtime/sleep.js.map +1 -0
- package/dist/runtime/taskExecution.d.ts +16 -0
- package/dist/runtime/taskExecution.js +74 -0
- package/dist/runtime/taskExecution.js.map +1 -0
- package/dist/runtime/wakeEnvelope.d.ts +76 -0
- package/dist/runtime/wakeEnvelope.js +60 -0
- package/dist/runtime/wakeEnvelope.js.map +1 -0
- package/dist/types.d.ts +121 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/userAuth/service.d.ts +26 -0
- package/dist/userAuth/service.js +170 -0
- package/dist/userAuth/service.js.map +1 -0
- package/dist/userAuth/store.d.ts +42 -0
- package/dist/userAuth/store.js +160 -0
- package/dist/userAuth/store.js.map +1 -0
- package/dist/userAuth/types.d.ts +63 -0
- package/dist/userAuth/types.js +29 -0
- package/dist/userAuth/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/workTypes.d.ts +313 -0
- package/dist/workTypes.js +106 -0
- package/dist/workTypes.js.map +1 -0
- package/dist-web/assets/index-CWfnzdLn.css +1 -0
- package/dist-web/assets/index-D5X9InfE.js +72 -0
- package/dist-web/index.html +15 -0
- package/docs/provider-setup.md +81 -0
- package/docs/quickstart.md +62 -0
- package/docs/troubleshooting.md +63 -0
- package/package.json +75 -6
package/README.md
CHANGED
|
@@ -1,3 +1,107 @@
|
|
|
1
1
|
# Sift Conductor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Sift Conductor is the optional local execution plane for Sift. One npm command
|
|
4
|
+
opens a local browser app for connecting Codex CLI or Claude Code, managing
|
|
5
|
+
shared work, and observing agent progress and results. Sift remains the
|
|
6
|
+
canonical source of project, task, run, artifact, and approval state.
|
|
7
|
+
|
|
8
|
+
Provider credentials and working-directory paths stay on the local machine.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- Node.js 20 or newer.
|
|
13
|
+
- A Sift workspace and a short-lived computer pairing code.
|
|
14
|
+
- Codex CLI `0.100.0` or newer and/or Claude Code `2.1.0` or newer.
|
|
15
|
+
- The selected provider already installed or installed through its official
|
|
16
|
+
setup flow.
|
|
17
|
+
|
|
18
|
+
## Start The Local App
|
|
19
|
+
|
|
20
|
+
Run the exact version you want to use:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npx @sift-wiki/conductor@latest start
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Conductor opens a loopback-only browser app. Enter the pairing code from Sift,
|
|
27
|
+
add an agent from **Agents**, and start the local runtime. Closing the browser
|
|
28
|
+
does not stop active work; keep the terminal process open and press `Ctrl+C` to
|
|
29
|
+
stop Conductor.
|
|
30
|
+
|
|
31
|
+
See the [complete quickstart](docs/quickstart.md),
|
|
32
|
+
[provider setup](docs/provider-setup.md), and
|
|
33
|
+
[troubleshooting guide](docs/troubleshooting.md).
|
|
34
|
+
|
|
35
|
+
## Headless CLI
|
|
36
|
+
|
|
37
|
+
Persistent headless installation:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install --global @sift-wiki/conductor
|
|
41
|
+
sift-conductor --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Pair and run without the browser interface:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
sift-conductor pair --api https://api.sift.wiki --code SC-... --display-name "My computer"
|
|
48
|
+
sift-conductor run --adapters ./agents.json
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Example provider configuration:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"adapters": [
|
|
56
|
+
{
|
|
57
|
+
"type": "codex",
|
|
58
|
+
"localKey": "product-codex",
|
|
59
|
+
"displayName": "Product engineer",
|
|
60
|
+
"workspacePath": "/absolute/path/to/project",
|
|
61
|
+
"accessProfile": "workspace",
|
|
62
|
+
"enabled": true
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"type": "claude-code",
|
|
66
|
+
"localKey": "review-claude",
|
|
67
|
+
"displayName": "Code reviewer",
|
|
68
|
+
"workspacePath": "/absolute/path/to/project",
|
|
69
|
+
"accessProfile": "inspect",
|
|
70
|
+
"enabled": true
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Use a stable `localKey`. Do not place API keys, OAuth tokens, or the Sift
|
|
77
|
+
Conductor credential in this file.
|
|
78
|
+
|
|
79
|
+
## Runtime Contract
|
|
80
|
+
|
|
81
|
+
For each claimed job Conductor:
|
|
82
|
+
|
|
83
|
+
1. checks out task-linked work and opens a run-scoped local bridge;
|
|
84
|
+
2. renders the Sift wake envelope into a bounded provider prompt;
|
|
85
|
+
3. invokes the provider noninteractively in the selected workspace;
|
|
86
|
+
4. normalizes allowlisted provider actions into concise progress events;
|
|
87
|
+
5. validates one structured `done`, `in_review`, or `blocked` result;
|
|
88
|
+
6. settles the Sift task/run/job and closes the run-scoped bridge.
|
|
89
|
+
|
|
90
|
+
The generic fake, process, and HTTP adapters remain available. Codex and Claude
|
|
91
|
+
Code do not require a user-authored shell wrapper.
|
|
92
|
+
|
|
93
|
+
## Security
|
|
94
|
+
|
|
95
|
+
- Conductor never stores Codex or Claude Code credentials.
|
|
96
|
+
- The long-lived Sift machine credential is never passed to an agent process.
|
|
97
|
+
- Provider processes receive only an expiring run-scoped bridge token.
|
|
98
|
+
- Local workspace paths are not advertised to Sift or exposed to browser code.
|
|
99
|
+
- Raw prompts, hidden reasoning, full provider streams, and environment dumps
|
|
100
|
+
are not sent to Sift.
|
|
101
|
+
- The initial desktop wizard does not offer dangerous bypass/full-machine
|
|
102
|
+
permission modes.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
Apache-2.0. Paperclip-derived behavioral references and notices are recorded in
|
|
107
|
+
[`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
## Paperclip
|
|
4
|
+
|
|
5
|
+
Parts of the Sift Conductor provider adapter design and parsing behavior were
|
|
6
|
+
adapted from Paperclip adapter utilities and its Codex Local and Claude Local
|
|
7
|
+
adapters.
|
|
8
|
+
|
|
9
|
+
- Project: https://github.com/paperclipai/paperclip
|
|
10
|
+
- Reference revision: `d166069bc4da847357b2a5b82241048fd4563b83`
|
|
11
|
+
- Copyright: Copyright (c) 2025 Paperclip AI
|
|
12
|
+
- License: MIT
|
|
13
|
+
|
|
14
|
+
MIT License
|
|
15
|
+
|
|
16
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
17
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
18
|
+
the Software without restriction, including without limitation the rights to
|
|
19
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
20
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
21
|
+
subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all
|
|
24
|
+
copies or substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
27
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
28
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
29
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
30
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
31
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
32
|
+
SOFTWARE.
|
|
33
|
+
|
|
34
|
+
The Sift/Paperclip visual prototype was used as an interface reference rather
|
|
35
|
+
than copied as a backend or bundled dependency:
|
|
36
|
+
|
|
37
|
+
- Project: https://github.com/Sift-wiki/paperclip-sift-visual-prototype
|
|
38
|
+
- Reference revision: `70788a1faf0909c490eb0c4ea928f8cb623f5ce0`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AdapterReadiness, LocalAgentAdapter } from "./types.js";
|
|
2
|
+
import { type ProviderProbeDeps } from "./provider/discovery.js";
|
|
3
|
+
import type { ProviderAgentConfig } from "./provider/types.js";
|
|
4
|
+
export declare const MINIMUM_CLAUDE_CODE_VERSION = "2.1.0";
|
|
5
|
+
export type ClaudeAgentConfig = ProviderAgentConfig & {
|
|
6
|
+
type: "claude-code";
|
|
7
|
+
};
|
|
8
|
+
export type ClaudeAgentDeps = ProviderProbeDeps;
|
|
9
|
+
export declare function createClaudeAgentAdapter(config: ClaudeAgentConfig, deps?: ClaudeAgentDeps): LocalAgentAdapter;
|
|
10
|
+
export declare function checkClaudeAgent(config: ClaudeAgentConfig, deps?: ClaudeAgentDeps): Promise<AdapterReadiness>;
|
|
11
|
+
export declare function buildClaudeInvocation(input: {
|
|
12
|
+
config: ClaudeAgentConfig;
|
|
13
|
+
executablePath: string;
|
|
14
|
+
prompt: string;
|
|
15
|
+
env?: Record<string, string> | undefined;
|
|
16
|
+
remainingCostMicros?: number | undefined;
|
|
17
|
+
}): {
|
|
18
|
+
command: string;
|
|
19
|
+
args: string[];
|
|
20
|
+
cwd: string;
|
|
21
|
+
env: Record<string, string>;
|
|
22
|
+
stdin: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { createClaudeStreamParser } from "./claudeParser.js";
|
|
2
|
+
import { probeCommand, resolveProviderExecutable, safeExecutableLabel, validateWorkspace, } from "./provider/discovery.js";
|
|
3
|
+
import { composeProviderPrompt } from "./provider/prompt.js";
|
|
4
|
+
import { providerTerminalJsonSchema } from "./provider/result.js";
|
|
5
|
+
import { runProviderAdapter } from "./provider/runProvider.js";
|
|
6
|
+
import { extractVersion, versionAtLeast } from "./provider/version.js";
|
|
7
|
+
export const MINIMUM_CLAUDE_CODE_VERSION = "2.1.0";
|
|
8
|
+
export function createClaudeAgentAdapter(config, deps = {}) {
|
|
9
|
+
return {
|
|
10
|
+
localKey: config.localKey,
|
|
11
|
+
displayName: config.displayName,
|
|
12
|
+
adapterType: "claude-code",
|
|
13
|
+
enabled: config.enabled,
|
|
14
|
+
capabilities: {
|
|
15
|
+
provider: "anthropic",
|
|
16
|
+
streaming: true,
|
|
17
|
+
structuredOutput: true,
|
|
18
|
+
cancellation: "process-tree",
|
|
19
|
+
accessProfile: config.accessProfile,
|
|
20
|
+
},
|
|
21
|
+
check: () => checkClaudeAgent(config, deps),
|
|
22
|
+
run: (input) => runClaudeAgent(input, config, deps),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export async function checkClaudeAgent(config, deps = {}) {
|
|
26
|
+
if (!config.enabled) {
|
|
27
|
+
return {
|
|
28
|
+
status: "error",
|
|
29
|
+
message: "Claude Code agent is paused.",
|
|
30
|
+
hint: "Resume it before assigning work.",
|
|
31
|
+
remediation: "resume",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const workspace = await validateWorkspace(config);
|
|
35
|
+
if (!workspace.ok) {
|
|
36
|
+
return { status: "error", message: workspace.message, remediation: "select-folder" };
|
|
37
|
+
}
|
|
38
|
+
const executablePath = await resolveProviderExecutable({
|
|
39
|
+
provider: "claude-code",
|
|
40
|
+
executablePath: config.executablePath,
|
|
41
|
+
cwd: config.workspacePath,
|
|
42
|
+
env: deps.env,
|
|
43
|
+
});
|
|
44
|
+
if (executablePath === undefined) {
|
|
45
|
+
return {
|
|
46
|
+
status: "error",
|
|
47
|
+
message: "Claude Code was not found.",
|
|
48
|
+
hint: "Install Claude Code or choose its executable in Sift Conductor.",
|
|
49
|
+
remediation: "install",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const versionProbe = await probeCommand({
|
|
53
|
+
command: executablePath,
|
|
54
|
+
args: ["--version"],
|
|
55
|
+
cwd: config.workspacePath,
|
|
56
|
+
deps,
|
|
57
|
+
});
|
|
58
|
+
const version = extractVersion(`${versionProbe.stdout}\n${versionProbe.stderr}`);
|
|
59
|
+
if (version === undefined || !versionAtLeast(version, MINIMUM_CLAUDE_CODE_VERSION)) {
|
|
60
|
+
return {
|
|
61
|
+
status: "error",
|
|
62
|
+
message: "Claude Code version is unsupported.",
|
|
63
|
+
hint: `Upgrade Claude Code to ${MINIMUM_CLAUDE_CODE_VERSION} or newer.`,
|
|
64
|
+
remediation: "upgrade",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const authProbe = await probeCommand({
|
|
68
|
+
command: executablePath,
|
|
69
|
+
args: ["auth", "status", "--json"],
|
|
70
|
+
cwd: config.workspacePath,
|
|
71
|
+
deps,
|
|
72
|
+
});
|
|
73
|
+
if (!claudeAuthReady(authProbe.stdout, authProbe.exitCode)) {
|
|
74
|
+
return {
|
|
75
|
+
status: "error",
|
|
76
|
+
message: "Claude Code authentication is required.",
|
|
77
|
+
hint: "Sign in through the Claude Code login flow, then retest this agent.",
|
|
78
|
+
remediation: "login",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
status: "ready",
|
|
83
|
+
message: `${safeExecutableLabel(executablePath)} ${version} is ready.`,
|
|
84
|
+
metadata: { providerVersion: version, accessProfile: config.accessProfile },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function buildClaudeInvocation(input) {
|
|
88
|
+
const args = [
|
|
89
|
+
"--print",
|
|
90
|
+
"--input-format",
|
|
91
|
+
"text",
|
|
92
|
+
"--output-format",
|
|
93
|
+
"stream-json",
|
|
94
|
+
"--verbose",
|
|
95
|
+
"--no-session-persistence",
|
|
96
|
+
"--json-schema",
|
|
97
|
+
JSON.stringify(providerTerminalJsonSchema),
|
|
98
|
+
];
|
|
99
|
+
if (input.config.accessProfile === "inspect") {
|
|
100
|
+
args.push("--permission-mode", "plan", "--tools", "Read,Glob,Grep");
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
args.push("--permission-mode", "acceptEdits", "--tools", "Read,Glob,Grep,Edit,Write", "--disallowedTools", "Bash,WebFetch,WebSearch");
|
|
104
|
+
}
|
|
105
|
+
if (input.config.model !== undefined)
|
|
106
|
+
args.push("--model", input.config.model);
|
|
107
|
+
if (input.remainingCostMicros !== undefined && input.remainingCostMicros > 0) {
|
|
108
|
+
args.push("--max-budget-usd", String(input.remainingCostMicros / 1_000_000));
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
command: input.executablePath,
|
|
112
|
+
args,
|
|
113
|
+
cwd: input.config.workspacePath,
|
|
114
|
+
env: input.env ?? {},
|
|
115
|
+
stdin: input.prompt,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function runClaudeAgent(input, config, deps) {
|
|
119
|
+
return runProviderAdapter({
|
|
120
|
+
provider: "claude-code",
|
|
121
|
+
runInput: input,
|
|
122
|
+
timeoutMs: config.timeoutMs,
|
|
123
|
+
graceMs: config.graceMs,
|
|
124
|
+
outputLimitBytes: config.outputLimitBytes,
|
|
125
|
+
...(deps.runProcess === undefined ? {} : { runProcess: deps.runProcess }),
|
|
126
|
+
prepare: async () => buildClaudeInvocation({
|
|
127
|
+
config,
|
|
128
|
+
executablePath: await requiredExecutable(config, deps),
|
|
129
|
+
prompt: composeProviderPrompt(input),
|
|
130
|
+
env: input.env,
|
|
131
|
+
remainingCostMicros: input.wakeEnvelope?.limits.remainingCostMicros,
|
|
132
|
+
}),
|
|
133
|
+
createParser: () => createClaudeStreamParser({
|
|
134
|
+
emit: (event) => input.emit(event),
|
|
135
|
+
outputLimitBytes: config.outputLimitBytes,
|
|
136
|
+
}),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function claudeAuthReady(stdout, exitCode) {
|
|
140
|
+
if ((exitCode ?? 1) !== 0)
|
|
141
|
+
return false;
|
|
142
|
+
try {
|
|
143
|
+
const parsed = JSON.parse(stdout);
|
|
144
|
+
return typeof parsed === "object"
|
|
145
|
+
&& parsed !== null
|
|
146
|
+
&& !Array.isArray(parsed)
|
|
147
|
+
&& parsed.loggedIn === true;
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function requiredExecutable(config, deps) {
|
|
154
|
+
const resolved = await resolveProviderExecutable({
|
|
155
|
+
provider: "claude-code",
|
|
156
|
+
executablePath: config.executablePath,
|
|
157
|
+
cwd: config.workspacePath,
|
|
158
|
+
env: deps.env,
|
|
159
|
+
});
|
|
160
|
+
if (resolved === undefined)
|
|
161
|
+
throw new Error("Claude Code was not found.");
|
|
162
|
+
return resolved;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=claudeAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeAgent.js","sourceRoot":"","sources":["../../src/adapters/claudeAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EACL,YAAY,EACZ,yBAAyB,EACzB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvE,MAAM,CAAC,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAKnD,MAAM,UAAU,wBAAwB,CACtC,MAAyB,EACzB,OAA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H,CAAC;AAED,KAAK,UAAU,kBAAkB,CAC/B,MAAyB,EACzB,IAAuB;IAEvB,MAAM,QAAQ,GAAG,MAAM,yBAAyB,CAAC;QAC/C,QAAQ,EAAE,aAAa;QACvB,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,GAAG,EAAE,MAAM,CAAC,aAAa;QACzB,GAAG,EAAE,IAAI,CAAC,GAAG;KACd,CAAC,CAAC;IACH,IAAI,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC1E,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ParsedProviderOutput, ProviderParserInput } from "./provider/types.js";
|
|
2
|
+
export declare function createClaudeStreamParser(input: ProviderParserInput): {
|
|
3
|
+
push: (stream: "stdout" | "stderr", chunk: string) => Promise<void>;
|
|
4
|
+
finish(): Promise<ParsedProviderOutput>;
|
|
5
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { boundAndRedactText } from "./output.js";
|
|
2
|
+
import { asRecord, numberValue, parseJsonRecord, stringValue } from "./provider/json.js";
|
|
3
|
+
import { ProviderLineStream } from "./provider/lineStream.js";
|
|
4
|
+
import { parseProviderTerminalResult } from "./provider/result.js";
|
|
5
|
+
export function createClaudeStreamParser(input) {
|
|
6
|
+
let sessionId;
|
|
7
|
+
let model;
|
|
8
|
+
let terminalRaw;
|
|
9
|
+
let errorMessage;
|
|
10
|
+
let stderrDiagnostic;
|
|
11
|
+
let usage;
|
|
12
|
+
const lines = new ProviderLineStream(async (stream, rawLine) => {
|
|
13
|
+
const line = rawLine.trim();
|
|
14
|
+
if (line.length === 0)
|
|
15
|
+
return;
|
|
16
|
+
if (stream === "stderr") {
|
|
17
|
+
stderrDiagnostic ??= boundAndRedactText(line, 2_000).text;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const event = parseJsonRecord(line);
|
|
21
|
+
if (event === undefined)
|
|
22
|
+
return;
|
|
23
|
+
const type = stringValue(event.type);
|
|
24
|
+
sessionId = stringValue(event.session_id) ?? sessionId;
|
|
25
|
+
if (type === "system" && stringValue(event.subtype) === "init") {
|
|
26
|
+
model = stringValue(event.model) ?? model;
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (type === "assistant") {
|
|
30
|
+
const message = asRecord(event.message);
|
|
31
|
+
const content = Array.isArray(message?.content) ? message.content : [];
|
|
32
|
+
for (const blockValue of content) {
|
|
33
|
+
const block = asRecord(blockValue);
|
|
34
|
+
if (stringValue(block?.type) !== "tool_use")
|
|
35
|
+
continue;
|
|
36
|
+
const toolName = stringValue(block?.name);
|
|
37
|
+
await input.emit({
|
|
38
|
+
eventType: "progress",
|
|
39
|
+
payload: { summary: claudeToolSummary(toolName) },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (type !== "result")
|
|
45
|
+
return;
|
|
46
|
+
const rawUsage = asRecord(event.usage);
|
|
47
|
+
const costUsd = numberValue(event.total_cost_usd);
|
|
48
|
+
usage = {
|
|
49
|
+
...(numberValue(rawUsage?.input_tokens) === undefined
|
|
50
|
+
? {}
|
|
51
|
+
: { inputTokens: numberValue(rawUsage?.input_tokens) }),
|
|
52
|
+
...(numberValue(rawUsage?.cache_read_input_tokens) === undefined
|
|
53
|
+
? {}
|
|
54
|
+
: { cachedInputTokens: numberValue(rawUsage?.cache_read_input_tokens) }),
|
|
55
|
+
...(numberValue(rawUsage?.output_tokens) === undefined
|
|
56
|
+
? {}
|
|
57
|
+
: { outputTokens: numberValue(rawUsage?.output_tokens) }),
|
|
58
|
+
...(costUsd === undefined ? {} : { costMicros: Math.round(costUsd * 1_000_000) }),
|
|
59
|
+
};
|
|
60
|
+
if (event.is_error === true) {
|
|
61
|
+
errorMessage = boundAndRedactText(stringValue(event.result) ?? claudeErrors(event) ?? "Claude Code reported an error.", 2_000).text;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
terminalRaw = event.structured_output ?? event.result;
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
push: (stream, chunk) => lines.push(stream, chunk),
|
|
68
|
+
async finish() {
|
|
69
|
+
await lines.finish();
|
|
70
|
+
let terminalResult;
|
|
71
|
+
if (terminalRaw !== undefined) {
|
|
72
|
+
try {
|
|
73
|
+
terminalResult = parseProviderTerminalResult(terminalRaw);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
errorMessage ??= error instanceof Error ? error.message : "Claude Code terminal result is invalid.";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (terminalResult === undefined)
|
|
80
|
+
errorMessage ??= stderrDiagnostic;
|
|
81
|
+
return {
|
|
82
|
+
...(terminalResult === undefined ? {} : { terminalResult }),
|
|
83
|
+
...(usage === undefined ? {} : { usage }),
|
|
84
|
+
...(sessionId === undefined ? {} : { sessionId }),
|
|
85
|
+
...(model === undefined ? {} : { model }),
|
|
86
|
+
...(errorMessage === undefined ? {} : { errorMessage }),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function claudeToolSummary(toolName) {
|
|
92
|
+
switch (toolName) {
|
|
93
|
+
case "Read":
|
|
94
|
+
case "Glob":
|
|
95
|
+
case "Grep":
|
|
96
|
+
return "Inspecting workspace context.";
|
|
97
|
+
case "Edit":
|
|
98
|
+
case "Write":
|
|
99
|
+
case "NotebookEdit":
|
|
100
|
+
return "Updating workspace files.";
|
|
101
|
+
case "Bash":
|
|
102
|
+
return "Running a local workspace command.";
|
|
103
|
+
default:
|
|
104
|
+
return "Using a local agent tool.";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function claudeErrors(event) {
|
|
108
|
+
if (!Array.isArray(event.errors))
|
|
109
|
+
return undefined;
|
|
110
|
+
for (const value of event.errors) {
|
|
111
|
+
if (typeof value === "string" && value.trim().length > 0)
|
|
112
|
+
return value;
|
|
113
|
+
const error = asRecord(value);
|
|
114
|
+
const message = stringValue(error?.message) ?? stringValue(error?.error);
|
|
115
|
+
if (message !== undefined)
|
|
116
|
+
return message;
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=claudeParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claudeParser.js","sourceRoot":"","sources":["../../src/adapters/claudeParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGnE,MAAM,UAAU,wBAAwB,CAAC,KAA0B;IACjE,IAAI,SAA6B,CAAC;IAClC,IAAI,KAAyB,CAAC;IAC9B,IAAI,WAAoB,CAAC;IACzB,IAAI,YAAgC,CAAC;IACrC,IAAI,gBAAoC,CAAC;IACzC,IAAI,KAAgC,CAAC;IAErC,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAC7D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC9B,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxB,gBAAgB,KAAK,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC;YAC1D,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC,KAA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,YAAY,CAAC,KAA8B;IAClD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IACnD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QACvE,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC9B,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACzE,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AdapterReadiness, LocalAgentAdapter } from "./types.js";
|
|
2
|
+
import { type ProviderProbeDeps } from "./provider/discovery.js";
|
|
3
|
+
import { type PreparedOutputSchema } from "./provider/outputSchemaFile.js";
|
|
4
|
+
import type { ProviderAgentConfig } from "./provider/types.js";
|
|
5
|
+
import type { RunProcess } from "../runtime/process.js";
|
|
6
|
+
export declare const MINIMUM_CODEX_VERSION = "0.100.0";
|
|
7
|
+
export type CodexAgentConfig = ProviderAgentConfig & {
|
|
8
|
+
type: "codex";
|
|
9
|
+
};
|
|
10
|
+
export type CodexAgentDeps = ProviderProbeDeps & {
|
|
11
|
+
prepareOutputSchema?: (() => Promise<PreparedOutputSchema>) | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare function createCodexAgentAdapter(config: CodexAgentConfig, deps?: CodexAgentDeps): LocalAgentAdapter;
|
|
14
|
+
export declare function checkCodexAgent(config: CodexAgentConfig, deps?: CodexAgentDeps): Promise<AdapterReadiness>;
|
|
15
|
+
export declare function buildCodexInvocation(input: {
|
|
16
|
+
config: CodexAgentConfig;
|
|
17
|
+
executablePath: string;
|
|
18
|
+
schemaPath: string;
|
|
19
|
+
prompt: string;
|
|
20
|
+
env?: Record<string, string> | undefined;
|
|
21
|
+
}): {
|
|
22
|
+
command: string;
|
|
23
|
+
args: string[];
|
|
24
|
+
cwd: string;
|
|
25
|
+
env: Record<string, string>;
|
|
26
|
+
stdin: string;
|
|
27
|
+
};
|
|
28
|
+
export type { RunProcess };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createCodexStreamParser } from "./codexParser.js";
|
|
2
|
+
import { composeProviderPrompt } from "./provider/prompt.js";
|
|
3
|
+
import { probeCommand, resolveProviderExecutable, safeExecutableLabel, validateWorkspace, } from "./provider/discovery.js";
|
|
4
|
+
import { prepareProviderOutputSchema, } from "./provider/outputSchemaFile.js";
|
|
5
|
+
import { runProviderAdapter } from "./provider/runProvider.js";
|
|
6
|
+
import { extractVersion, versionAtLeast } from "./provider/version.js";
|
|
7
|
+
export const MINIMUM_CODEX_VERSION = "0.100.0";
|
|
8
|
+
export function createCodexAgentAdapter(config, deps = {}) {
|
|
9
|
+
return {
|
|
10
|
+
localKey: config.localKey,
|
|
11
|
+
displayName: config.displayName,
|
|
12
|
+
adapterType: "codex",
|
|
13
|
+
enabled: config.enabled,
|
|
14
|
+
capabilities: {
|
|
15
|
+
provider: "openai",
|
|
16
|
+
streaming: true,
|
|
17
|
+
structuredOutput: true,
|
|
18
|
+
cancellation: "process-tree",
|
|
19
|
+
accessProfile: config.accessProfile,
|
|
20
|
+
},
|
|
21
|
+
check: () => checkCodexAgent(config, deps),
|
|
22
|
+
run: (input) => runCodexAgent(input, config, deps),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export async function checkCodexAgent(config, deps = {}) {
|
|
26
|
+
if (!config.enabled) {
|
|
27
|
+
return {
|
|
28
|
+
status: "error",
|
|
29
|
+
message: "Codex agent is paused.",
|
|
30
|
+
hint: "Resume it before assigning work.",
|
|
31
|
+
remediation: "resume",
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const workspace = await validateWorkspace(config);
|
|
35
|
+
if (!workspace.ok) {
|
|
36
|
+
return { status: "error", message: workspace.message, remediation: "select-folder" };
|
|
37
|
+
}
|
|
38
|
+
const executablePath = await resolveProviderExecutable({
|
|
39
|
+
provider: "codex",
|
|
40
|
+
executablePath: config.executablePath,
|
|
41
|
+
cwd: config.workspacePath,
|
|
42
|
+
env: deps.env,
|
|
43
|
+
});
|
|
44
|
+
if (executablePath === undefined) {
|
|
45
|
+
return {
|
|
46
|
+
status: "error",
|
|
47
|
+
message: "Codex CLI was not found.",
|
|
48
|
+
hint: "Install Codex CLI or choose its executable in Sift Conductor.",
|
|
49
|
+
remediation: "install",
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const versionProbe = await probeCommand({
|
|
53
|
+
command: executablePath,
|
|
54
|
+
args: ["--version"],
|
|
55
|
+
cwd: config.workspacePath,
|
|
56
|
+
deps,
|
|
57
|
+
});
|
|
58
|
+
const version = extractVersion(`${versionProbe.stdout}\n${versionProbe.stderr}`);
|
|
59
|
+
if (version === undefined || !versionAtLeast(version, MINIMUM_CODEX_VERSION)) {
|
|
60
|
+
return {
|
|
61
|
+
status: "error",
|
|
62
|
+
message: "Codex CLI version is unsupported.",
|
|
63
|
+
hint: `Upgrade Codex CLI to ${MINIMUM_CODEX_VERSION} or newer.`,
|
|
64
|
+
remediation: "upgrade",
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const authProbe = await probeCommand({
|
|
68
|
+
command: executablePath,
|
|
69
|
+
args: ["login", "status"],
|
|
70
|
+
cwd: config.workspacePath,
|
|
71
|
+
deps,
|
|
72
|
+
});
|
|
73
|
+
if ((authProbe.exitCode ?? 1) !== 0 || !/logged\s+in/iu.test(`${authProbe.stdout}\n${authProbe.stderr}`)) {
|
|
74
|
+
return {
|
|
75
|
+
status: "error",
|
|
76
|
+
message: "Codex CLI authentication is required.",
|
|
77
|
+
hint: "Sign in through the Codex login flow, then retest this agent.",
|
|
78
|
+
remediation: "login",
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
status: "ready",
|
|
83
|
+
message: `${safeExecutableLabel(executablePath)} ${version} is ready.`,
|
|
84
|
+
metadata: { providerVersion: version, accessProfile: config.accessProfile },
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export function buildCodexInvocation(input) {
|
|
88
|
+
const args = [
|
|
89
|
+
"exec",
|
|
90
|
+
"--json",
|
|
91
|
+
"--ephemeral",
|
|
92
|
+
"--skip-git-repo-check",
|
|
93
|
+
"--cd",
|
|
94
|
+
input.config.workspacePath,
|
|
95
|
+
"--sandbox",
|
|
96
|
+
input.config.accessProfile === "inspect" ? "read-only" : "workspace-write",
|
|
97
|
+
"--output-schema",
|
|
98
|
+
input.schemaPath,
|
|
99
|
+
];
|
|
100
|
+
if (input.config.model !== undefined)
|
|
101
|
+
args.push("--model", input.config.model);
|
|
102
|
+
args.push("-");
|
|
103
|
+
return {
|
|
104
|
+
command: input.executablePath,
|
|
105
|
+
args,
|
|
106
|
+
cwd: input.config.workspacePath,
|
|
107
|
+
env: input.env ?? {},
|
|
108
|
+
stdin: input.prompt,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
async function runCodexAgent(input, config, deps) {
|
|
112
|
+
let schema;
|
|
113
|
+
return runProviderAdapter({
|
|
114
|
+
provider: "codex",
|
|
115
|
+
runInput: input,
|
|
116
|
+
timeoutMs: config.timeoutMs,
|
|
117
|
+
graceMs: config.graceMs,
|
|
118
|
+
outputLimitBytes: config.outputLimitBytes,
|
|
119
|
+
...(deps.runProcess === undefined ? {} : { runProcess: deps.runProcess }),
|
|
120
|
+
prepare: async () => {
|
|
121
|
+
const executablePath = await requiredExecutable(config, deps);
|
|
122
|
+
schema = await (deps.prepareOutputSchema ?? prepareProviderOutputSchema)();
|
|
123
|
+
const preparedSchema = schema;
|
|
124
|
+
return {
|
|
125
|
+
...buildCodexInvocation({
|
|
126
|
+
config,
|
|
127
|
+
executablePath,
|
|
128
|
+
schemaPath: schema.path,
|
|
129
|
+
prompt: composeProviderPrompt(input),
|
|
130
|
+
env: input.env,
|
|
131
|
+
}),
|
|
132
|
+
cleanup: () => preparedSchema.cleanup(),
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
createParser: () => createCodexStreamParser({
|
|
136
|
+
emit: (event) => input.emit(event),
|
|
137
|
+
outputLimitBytes: config.outputLimitBytes,
|
|
138
|
+
}),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
async function requiredExecutable(config, deps) {
|
|
142
|
+
const resolved = await resolveProviderExecutable({
|
|
143
|
+
provider: "codex",
|
|
144
|
+
executablePath: config.executablePath,
|
|
145
|
+
cwd: config.workspacePath,
|
|
146
|
+
env: deps.env,
|
|
147
|
+
});
|
|
148
|
+
if (resolved === undefined)
|
|
149
|
+
throw new Error("Codex CLI was not found.");
|
|
150
|
+
return resolved;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=codexAgent.js.map
|