@yoloship/ai 0.2.0-beta.5 → 0.2.0-beta.6
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/dist/index.d.mts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.mjs +147 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -25,7 +25,7 @@ interface RunOptions {
|
|
|
25
25
|
/**
|
|
26
26
|
* Response language for textual outputs (logs, PR comments, reviews).
|
|
27
27
|
* Forwarded to the underlying runtime which injects a "respond in X"
|
|
28
|
-
* directive into the system prompt. Code identifiers must stay in English
|
|
28
|
+
* directive into the system prompt. Code identifiers must stay in English -
|
|
29
29
|
* enforced by an invariant injected from `@yoloship/action` agent prompts.
|
|
30
30
|
*
|
|
31
31
|
* Future runtimes (opencode, Codex) implement their own mapping or prompt
|
|
@@ -95,7 +95,7 @@ declare const PROVIDER_ENV_VAR: Record<RuntimeProvider, string | undefined>;
|
|
|
95
95
|
* shared is `private: true` and @yoloship/ai is published, so a workspace
|
|
96
96
|
* dep here would break the publish chain. Drift protection lives in
|
|
97
97
|
* @yoloship/action's `validateRunLevelModel` (which DOES check the catalog)
|
|
98
|
-
* and in `agentProviderOverrideSchema` for per-agent overrides
|
|
98
|
+
* and in `agentProviderOverrideSchema` for per-agent overrides - by the
|
|
99
99
|
* time these defaults are observed, the run-level model has already been
|
|
100
100
|
* validated upstream.
|
|
101
101
|
*/
|
|
@@ -104,8 +104,8 @@ declare const DEFAULT_MODEL_BY_PROVIDER: Record<RuntimeProvider, string | undefi
|
|
|
104
104
|
* Resolve the effective model for a run.
|
|
105
105
|
*
|
|
106
106
|
* Precedence (highest to lowest):
|
|
107
|
-
* 1. `runOverride`
|
|
108
|
-
* 2. `agentModel`
|
|
107
|
+
* 1. `runOverride` - CLI flag / `model` from yolo.config.ts
|
|
108
|
+
* 2. `agentModel` - per-agent `model` in `AgentConfig`
|
|
109
109
|
* 3. Provider default from `DEFAULT_MODEL_BY_PROVIDER`
|
|
110
110
|
*
|
|
111
111
|
* Returns `undefined` only when the provider has no default and nothing
|
|
@@ -122,7 +122,7 @@ interface ClaudeRuntimeOptions {
|
|
|
122
122
|
ci?: boolean;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* Shape returned by `buildMcpConfig` for Claude
|
|
125
|
+
* Shape returned by `buildMcpConfig` for Claude - the exact wire payload
|
|
126
126
|
* the Claude CLI expects for `--mcp-config`. Exposed as a distinct type so
|
|
127
127
|
* callers that serialise the config themselves have something to bind to.
|
|
128
128
|
*/
|
|
@@ -149,7 +149,7 @@ declare class ClaudeRuntime implements Runtime {
|
|
|
149
149
|
* serialised payload directly (e.g. writing an mcp-config file).
|
|
150
150
|
*/
|
|
151
151
|
buildMcpConfig(servers: Record<string, McpServerConfig>): ClaudeMcpConfig;
|
|
152
|
-
/** Claude Code consumes `allowedTools` in its native shape
|
|
152
|
+
/** Claude Code consumes `allowedTools` in its native shape - pass through. */
|
|
153
153
|
translateAllowedTools(tools: string[]): string[];
|
|
154
154
|
}
|
|
155
155
|
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface RunOptions {
|
|
|
25
25
|
/**
|
|
26
26
|
* Response language for textual outputs (logs, PR comments, reviews).
|
|
27
27
|
* Forwarded to the underlying runtime which injects a "respond in X"
|
|
28
|
-
* directive into the system prompt. Code identifiers must stay in English
|
|
28
|
+
* directive into the system prompt. Code identifiers must stay in English -
|
|
29
29
|
* enforced by an invariant injected from `@yoloship/action` agent prompts.
|
|
30
30
|
*
|
|
31
31
|
* Future runtimes (opencode, Codex) implement their own mapping or prompt
|
|
@@ -95,7 +95,7 @@ declare const PROVIDER_ENV_VAR: Record<RuntimeProvider, string | undefined>;
|
|
|
95
95
|
* shared is `private: true` and @yoloship/ai is published, so a workspace
|
|
96
96
|
* dep here would break the publish chain. Drift protection lives in
|
|
97
97
|
* @yoloship/action's `validateRunLevelModel` (which DOES check the catalog)
|
|
98
|
-
* and in `agentProviderOverrideSchema` for per-agent overrides
|
|
98
|
+
* and in `agentProviderOverrideSchema` for per-agent overrides - by the
|
|
99
99
|
* time these defaults are observed, the run-level model has already been
|
|
100
100
|
* validated upstream.
|
|
101
101
|
*/
|
|
@@ -104,8 +104,8 @@ declare const DEFAULT_MODEL_BY_PROVIDER: Record<RuntimeProvider, string | undefi
|
|
|
104
104
|
* Resolve the effective model for a run.
|
|
105
105
|
*
|
|
106
106
|
* Precedence (highest to lowest):
|
|
107
|
-
* 1. `runOverride`
|
|
108
|
-
* 2. `agentModel`
|
|
107
|
+
* 1. `runOverride` - CLI flag / `model` from yolo.config.ts
|
|
108
|
+
* 2. `agentModel` - per-agent `model` in `AgentConfig`
|
|
109
109
|
* 3. Provider default from `DEFAULT_MODEL_BY_PROVIDER`
|
|
110
110
|
*
|
|
111
111
|
* Returns `undefined` only when the provider has no default and nothing
|
|
@@ -122,7 +122,7 @@ interface ClaudeRuntimeOptions {
|
|
|
122
122
|
ci?: boolean;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* Shape returned by `buildMcpConfig` for Claude
|
|
125
|
+
* Shape returned by `buildMcpConfig` for Claude - the exact wire payload
|
|
126
126
|
* the Claude CLI expects for `--mcp-config`. Exposed as a distinct type so
|
|
127
127
|
* callers that serialise the config themselves have something to bind to.
|
|
128
128
|
*/
|
|
@@ -149,7 +149,7 @@ declare class ClaudeRuntime implements Runtime {
|
|
|
149
149
|
* serialised payload directly (e.g. writing an mcp-config file).
|
|
150
150
|
*/
|
|
151
151
|
buildMcpConfig(servers: Record<string, McpServerConfig>): ClaudeMcpConfig;
|
|
152
|
-
/** Claude Code consumes `allowedTools` in its native shape
|
|
152
|
+
/** Claude Code consumes `allowedTools` in its native shape - pass through. */
|
|
153
153
|
translateAllowedTools(tools: string[]): string[];
|
|
154
154
|
}
|
|
155
155
|
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1,147 @@
|
|
|
1
|
-
|
|
1
|
+
import { ensureClaude, spawnClaude, spawnClaudeBidirectional } from '@yoloship/claude-sdk';
|
|
2
|
+
export { EventStream, classifyEvent, extractFileChange, isErrorEvent, isFileChangedEvent, isOutputEvent, isResultEvent, isThinkingEvent, isToolResultEvent, isToolUseEvent, normalizeEvent } from '@yoloship/claude-sdk';
|
|
3
|
+
|
|
4
|
+
const CI_DEFAULTS = {
|
|
5
|
+
dangerouslySkipPermissions: true,
|
|
6
|
+
attribution: { commit: "", pr: "" },
|
|
7
|
+
autoMemoryEnabled: false
|
|
8
|
+
};
|
|
9
|
+
const CI_PAGER_ENV = {
|
|
10
|
+
GIT_PAGER: "cat",
|
|
11
|
+
GH_PAGER: "cat",
|
|
12
|
+
PAGER: "cat"
|
|
13
|
+
};
|
|
14
|
+
function toClaudeAuth(auth) {
|
|
15
|
+
if (!auth) {
|
|
16
|
+
return void 0;
|
|
17
|
+
}
|
|
18
|
+
return { apiKey: auth.apiKey };
|
|
19
|
+
}
|
|
20
|
+
class ClaudeRuntime {
|
|
21
|
+
id = "claude-code";
|
|
22
|
+
#ci;
|
|
23
|
+
constructor(opts = {}) {
|
|
24
|
+
this.#ci = opts.ci ?? false;
|
|
25
|
+
}
|
|
26
|
+
async ensure(options) {
|
|
27
|
+
await ensureClaude(options);
|
|
28
|
+
}
|
|
29
|
+
run(opts) {
|
|
30
|
+
const claudeOpts = this.#ci ? { ...CI_DEFAULTS, ...this.#toClaudeOptions(opts) } : this.#toClaudeOptions(opts);
|
|
31
|
+
const emitter = spawnClaude(claudeOpts, toClaudeAuth(opts.auth));
|
|
32
|
+
if (opts.onEvent) {
|
|
33
|
+
emitter.events.on(opts.onEvent);
|
|
34
|
+
}
|
|
35
|
+
return emitter.result;
|
|
36
|
+
}
|
|
37
|
+
runBidirectional(opts) {
|
|
38
|
+
const sessionOpts = this.#ci ? { ...CI_DEFAULTS, ...this.#toClaudeSessionOptions(opts) } : this.#toClaudeSessionOptions(opts);
|
|
39
|
+
const bidi = spawnClaudeBidirectional(sessionOpts, toClaudeAuth(opts.auth));
|
|
40
|
+
if (opts.onEvent) {
|
|
41
|
+
bidi.events.on(opts.onEvent);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
events: bidi.events,
|
|
45
|
+
sendTurn: (message) => bidi.sendMessage(message),
|
|
46
|
+
cancel: () => {
|
|
47
|
+
try {
|
|
48
|
+
bidi.process.kill();
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
close: () => bidi.close(),
|
|
53
|
+
result: bidi.result
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Canonical wire format for `--mcp-config`. Called internally by
|
|
58
|
+
* `#toClaudeSessionOptions` when `opts.mcpServers` is provided; also
|
|
59
|
+
* exposed on the `Runtime` interface for callers that need the
|
|
60
|
+
* serialised payload directly (e.g. writing an mcp-config file).
|
|
61
|
+
*/
|
|
62
|
+
buildMcpConfig(servers) {
|
|
63
|
+
return { mcpServers: servers };
|
|
64
|
+
}
|
|
65
|
+
/** Claude Code consumes `allowedTools` in its native shape - pass through. */
|
|
66
|
+
translateAllowedTools(tools) {
|
|
67
|
+
return tools;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Translate the runtime-agnostic `RunOptions` into Claude's native
|
|
71
|
+
* `ClaudeSessionOptions`. Routes `allowedTools` through
|
|
72
|
+
* `translateAllowedTools()` and `mcpServers` through `buildMcpConfig()`
|
|
73
|
+
* so the public interface methods are load-bearing on the internal
|
|
74
|
+
* execution path.
|
|
75
|
+
*/
|
|
76
|
+
#toClaudeSessionOptions(opts) {
|
|
77
|
+
const rest = {};
|
|
78
|
+
if (opts.systemPrompt !== void 0) {
|
|
79
|
+
rest.systemPrompt = opts.systemPrompt;
|
|
80
|
+
}
|
|
81
|
+
if (opts.model !== void 0) {
|
|
82
|
+
rest.model = opts.model;
|
|
83
|
+
}
|
|
84
|
+
if (opts.maxTurns !== void 0) {
|
|
85
|
+
rest.maxTurns = opts.maxTurns;
|
|
86
|
+
}
|
|
87
|
+
if (opts.allowedTools !== void 0) {
|
|
88
|
+
rest.allowedTools = this.translateAllowedTools(opts.allowedTools);
|
|
89
|
+
}
|
|
90
|
+
if (opts.mcpServers !== void 0) {
|
|
91
|
+
rest.mcpServers = this.buildMcpConfig(opts.mcpServers).mcpServers;
|
|
92
|
+
}
|
|
93
|
+
if (opts.cwd !== void 0) {
|
|
94
|
+
rest.cwd = opts.cwd;
|
|
95
|
+
}
|
|
96
|
+
if (this.#ci) {
|
|
97
|
+
rest.env = { ...CI_PAGER_ENV, ...opts.env ?? {} };
|
|
98
|
+
} else if (opts.env !== void 0) {
|
|
99
|
+
rest.env = opts.env;
|
|
100
|
+
}
|
|
101
|
+
if (opts.sessionId !== void 0) {
|
|
102
|
+
rest.sessionId = opts.sessionId;
|
|
103
|
+
}
|
|
104
|
+
if (opts.resume !== void 0) {
|
|
105
|
+
rest.resume = opts.resume;
|
|
106
|
+
}
|
|
107
|
+
if (opts.language !== void 0) {
|
|
108
|
+
rest.language = opts.language;
|
|
109
|
+
}
|
|
110
|
+
rest.settingSources = ["project", "local"];
|
|
111
|
+
return rest;
|
|
112
|
+
}
|
|
113
|
+
#toClaudeOptions(opts) {
|
|
114
|
+
return { prompt: opts.prompt, ...this.#toClaudeSessionOptions(opts) };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getRuntime(runtime = "claude-code", opts = {}) {
|
|
119
|
+
switch (runtime) {
|
|
120
|
+
case "claude-code":
|
|
121
|
+
return new ClaudeRuntime({ ci: opts.ci });
|
|
122
|
+
case "opencode":
|
|
123
|
+
throw new Error("opencode runtime is not yet implemented - see YOL-204");
|
|
124
|
+
default: {
|
|
125
|
+
const unknown = runtime;
|
|
126
|
+
throw new Error(`Unknown runtime: ${String(unknown)}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const PROVIDER_ENV_VAR = {
|
|
132
|
+
"anthropic": "ANTHROPIC_API_KEY",
|
|
133
|
+
"openai": "OPENAI_API_KEY",
|
|
134
|
+
"openai-compatible": void 0,
|
|
135
|
+
"custom": void 0
|
|
136
|
+
};
|
|
137
|
+
const DEFAULT_MODEL_BY_PROVIDER = {
|
|
138
|
+
"anthropic": "claude-sonnet-4-6",
|
|
139
|
+
"openai": "gpt-4o-mini",
|
|
140
|
+
"openai-compatible": void 0,
|
|
141
|
+
"custom": void 0
|
|
142
|
+
};
|
|
143
|
+
function resolveModel(opts) {
|
|
144
|
+
return opts.runOverride ?? opts.agentModel ?? DEFAULT_MODEL_BY_PROVIDER[opts.provider];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export { ClaudeRuntime, DEFAULT_MODEL_BY_PROVIDER, PROVIDER_ENV_VAR, getRuntime, resolveModel };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoloship/ai",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.0-beta.
|
|
4
|
+
"version": "0.2.0-beta.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Yoloship AI — runtime-agnostic coding-agent orchestration layer (consumes @yoloship/claude-sdk today, opencode next)",
|
|
7
7
|
"author": "Yoloship Team <team@yoloship.dev>",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"zod": "^4.4.3",
|
|
36
|
-
"@yoloship/claude-sdk": "0.2.0-beta.
|
|
36
|
+
"@yoloship/claude-sdk": "0.2.0-beta.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"cross-env": "^10.1.0",
|