@yoloship/ai 0.1.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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { EventStream, ClaudeEvent, SpawnResult, McpServerConfig } from '@yoloship/claude-sdk';
2
- export { EventStream, ClaudeEvent as RuntimeEvent, SpawnResult, classifyEvent, extractFileChange, isErrorEvent, isFileChangedEvent, isOutputEvent, isResultEvent, isThinkingEvent, isToolUseEvent, normalizeEvent } from '@yoloship/claude-sdk';
1
+ import { EventStream, ClaudeEvent, SpawnResult, McpServerConfig, ClaudeLanguage } from '@yoloship/claude-sdk';
2
+ export { EventStream, ClaudeEvent as RuntimeEvent, SpawnResult, ToolResultEvent, ToolUseEvent, classifyEvent, extractFileChange, isErrorEvent, isFileChangedEvent, isOutputEvent, isResultEvent, isThinkingEvent, isToolResultEvent, isToolUseEvent, normalizeEvent } from '@yoloship/claude-sdk';
3
3
 
4
4
  type RuntimeEvent = ClaudeEvent;
5
5
  type RuntimeProvider = 'anthropic' | 'openai' | 'openai-compatible' | 'custom';
@@ -22,6 +22,16 @@ interface RunOptions {
22
22
  sessionId?: string;
23
23
  /** Resume a prior CLI session by id (Claude `--resume`). */
24
24
  resume?: string;
25
+ /**
26
+ * Response language for textual outputs (logs, PR comments, reviews).
27
+ * Forwarded to the underlying runtime which injects a "respond in X"
28
+ * directive into the system prompt. Code identifiers must stay in English —
29
+ * enforced by an invariant injected from `@yoloship/action` agent prompts.
30
+ *
31
+ * Future runtimes (opencode, Codex) implement their own mapping or prompt
32
+ * injection; the field stays at the runtime-agnostic level.
33
+ */
34
+ language?: ClaudeLanguage;
25
35
  /** Called for every event emitted while the run is in progress. */
26
36
  onEvent?: (event: RuntimeEvent) => void;
27
37
  }
@@ -80,6 +90,14 @@ declare const PROVIDER_ENV_VAR: Record<RuntimeProvider, string | undefined>;
80
90
  /**
81
91
  * Default model id for each provider. Used when neither the per-agent
82
92
  * `model` nor the run-level `model` override is set.
93
+ *
94
+ * NOT typed against `AnthropicModel`/`OpenaiModel` from @yoloship/shared:
95
+ * shared is `private: true` and @yoloship/ai is published, so a workspace
96
+ * dep here would break the publish chain. Drift protection lives in
97
+ * @yoloship/action's `validateRunLevelModel` (which DOES check the catalog)
98
+ * and in `agentProviderOverrideSchema` for per-agent overrides — by the
99
+ * time these defaults are observed, the run-level model has already been
100
+ * validated upstream.
83
101
  */
84
102
  declare const DEFAULT_MODEL_BY_PROVIDER: Record<RuntimeProvider, string | undefined>;
85
103
  /**
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { EventStream, ClaudeEvent, SpawnResult, McpServerConfig } from '@yoloship/claude-sdk';
2
- export { EventStream, ClaudeEvent as RuntimeEvent, SpawnResult, classifyEvent, extractFileChange, isErrorEvent, isFileChangedEvent, isOutputEvent, isResultEvent, isThinkingEvent, isToolUseEvent, normalizeEvent } from '@yoloship/claude-sdk';
1
+ import { EventStream, ClaudeEvent, SpawnResult, McpServerConfig, ClaudeLanguage } from '@yoloship/claude-sdk';
2
+ export { EventStream, ClaudeEvent as RuntimeEvent, SpawnResult, ToolResultEvent, ToolUseEvent, classifyEvent, extractFileChange, isErrorEvent, isFileChangedEvent, isOutputEvent, isResultEvent, isThinkingEvent, isToolResultEvent, isToolUseEvent, normalizeEvent } from '@yoloship/claude-sdk';
3
3
 
4
4
  type RuntimeEvent = ClaudeEvent;
5
5
  type RuntimeProvider = 'anthropic' | 'openai' | 'openai-compatible' | 'custom';
@@ -22,6 +22,16 @@ interface RunOptions {
22
22
  sessionId?: string;
23
23
  /** Resume a prior CLI session by id (Claude `--resume`). */
24
24
  resume?: string;
25
+ /**
26
+ * Response language for textual outputs (logs, PR comments, reviews).
27
+ * Forwarded to the underlying runtime which injects a "respond in X"
28
+ * directive into the system prompt. Code identifiers must stay in English —
29
+ * enforced by an invariant injected from `@yoloship/action` agent prompts.
30
+ *
31
+ * Future runtimes (opencode, Codex) implement their own mapping or prompt
32
+ * injection; the field stays at the runtime-agnostic level.
33
+ */
34
+ language?: ClaudeLanguage;
25
35
  /** Called for every event emitted while the run is in progress. */
26
36
  onEvent?: (event: RuntimeEvent) => void;
27
37
  }
@@ -80,6 +90,14 @@ declare const PROVIDER_ENV_VAR: Record<RuntimeProvider, string | undefined>;
80
90
  /**
81
91
  * Default model id for each provider. Used when neither the per-agent
82
92
  * `model` nor the run-level `model` override is set.
93
+ *
94
+ * NOT typed against `AnthropicModel`/`OpenaiModel` from @yoloship/shared:
95
+ * shared is `private: true` and @yoloship/ai is published, so a workspace
96
+ * dep here would break the publish chain. Drift protection lives in
97
+ * @yoloship/action's `validateRunLevelModel` (which DOES check the catalog)
98
+ * and in `agentProviderOverrideSchema` for per-agent overrides — by the
99
+ * time these defaults are observed, the run-level model has already been
100
+ * validated upstream.
83
101
  */
84
102
  declare const DEFAULT_MODEL_BY_PROVIDER: Record<RuntimeProvider, string | undefined>;
85
103
  /**
package/dist/index.mjs CHANGED
@@ -1 +1,147 @@
1
- const _0x3ae0b4=_0x4a30;(function(_0x69388a,_0x5724e8){const _0x527072=_0x4a30,_0x13e561=_0x69388a();while(!![]){try{const _0x5a2fea=-parseInt(_0x527072(0x1ad,'2i0I'))/0x1*(-parseInt(_0x527072(0x1ab,'KweD'))/0x2)+parseInt(_0x527072(0x1d5,'f*eX'))/0x3*(-parseInt(_0x527072(0x1f6,'Ve57'))/0x4)+-parseInt(_0x527072(0x1e0,'c!Ta'))/0x5+parseInt(_0x527072(0x1b9,'uyBp'))/0x6*(-parseInt(_0x527072(0x1d8,'OBaR'))/0x7)+parseInt(_0x527072(0x1d7,'NfTK'))/0x8+-parseInt(_0x527072(0x1f3,'2i0I'))/0x9+parseInt(_0x527072(0x1d0,'p@*i'))/0xa;if(_0x5a2fea===_0x5724e8)break;else _0x13e561['push'](_0x13e561['shift']());}catch(_0x4bb921){_0x13e561['push'](_0x13e561['shift']());}}}(_0x2932,0x6458e));import{ensureClaude,spawnClaude,spawnClaudeBidirectional}from'@yoloship/claude-sdk';export{EventStream,classifyEvent,extractFileChange,isErrorEvent,isFileChangedEvent,isOutputEvent,isResultEvent,isThinkingEvent,isToolUseEvent,normalizeEvent}from'@yoloship/claude-sdk';const CI_DEFAULTS={'dangerouslySkipPermissions':!![],'attribution':{'commit':'','pr':''},'autoMemoryEnabled':![]},CI_PAGER_ENV={'GIT_PAGER':_0x3ae0b4(0x1c8,'8afo'),'GH_PAGER':'cat','PAGER':_0x3ae0b4(0x1de,'idxG')};function toClaudeAuth(_0x1a703e){const _0x31e7d0=_0x3ae0b4;if(!_0x1a703e)return void 0x0;return{'apiKey':_0x1a703e[_0x31e7d0(0x1b8,'Ve57')]};}function _0x4a30(_0x164afb,_0x5b7e6f){_0x164afb=_0x164afb-0x1a9;const _0x2932b4=_0x2932();let _0x4a3012=_0x2932b4[_0x164afb];if(_0x4a30['IHfpJD']===undefined){var _0x4bdd42=function(_0x6210ca){const _0x4cece5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4a8999='',_0xc61985='';for(let _0x164d87=0x0,_0x56d5aa,_0x2980b9,_0x20ba2b=0x0;_0x2980b9=_0x6210ca['charAt'](_0x20ba2b++);~_0x2980b9&&(_0x56d5aa=_0x164d87%0x4?_0x56d5aa*0x40+_0x2980b9:_0x2980b9,_0x164d87++%0x4)?_0x4a8999+=String['fromCharCode'](0xff&_0x56d5aa>>(-0x2*_0x164d87&0x6)):0x0){_0x2980b9=_0x4cece5['indexOf'](_0x2980b9);}for(let _0xd9a872=0x0,_0x391307=_0x4a8999['length'];_0xd9a872<_0x391307;_0xd9a872++){_0xc61985+='%'+('00'+_0x4a8999['charCodeAt'](_0xd9a872)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xc61985);};const _0xb6020c=function(_0x50a4a9,_0x2eb2fc){let _0x3c1669=[],_0x1619a3=0x0,_0xefd408,_0x1144f9='';_0x50a4a9=_0x4bdd42(_0x50a4a9);let _0x1f63fa;for(_0x1f63fa=0x0;_0x1f63fa<0x100;_0x1f63fa++){_0x3c1669[_0x1f63fa]=_0x1f63fa;}for(_0x1f63fa=0x0;_0x1f63fa<0x100;_0x1f63fa++){_0x1619a3=(_0x1619a3+_0x3c1669[_0x1f63fa]+_0x2eb2fc['charCodeAt'](_0x1f63fa%_0x2eb2fc['length']))%0x100,_0xefd408=_0x3c1669[_0x1f63fa],_0x3c1669[_0x1f63fa]=_0x3c1669[_0x1619a3],_0x3c1669[_0x1619a3]=_0xefd408;}_0x1f63fa=0x0,_0x1619a3=0x0;for(let _0x7c9d22=0x0;_0x7c9d22<_0x50a4a9['length'];_0x7c9d22++){_0x1f63fa=(_0x1f63fa+0x1)%0x100,_0x1619a3=(_0x1619a3+_0x3c1669[_0x1f63fa])%0x100,_0xefd408=_0x3c1669[_0x1f63fa],_0x3c1669[_0x1f63fa]=_0x3c1669[_0x1619a3],_0x3c1669[_0x1619a3]=_0xefd408,_0x1144f9+=String['fromCharCode'](_0x50a4a9['charCodeAt'](_0x7c9d22)^_0x3c1669[(_0x3c1669[_0x1f63fa]+_0x3c1669[_0x1619a3])%0x100]);}return _0x1144f9;};_0x4a30['XjoFiM']=_0xb6020c,_0x4a30['bJmnAz']={},_0x4a30['IHfpJD']=!![];}const _0x4c417b=_0x2932b4[0x0],_0x26f86a=_0x164afb+_0x4c417b,_0x214373=_0x4a30['bJmnAz'][_0x26f86a];return!_0x214373?(_0x4a30['iRYChe']===undefined&&(_0x4a30['iRYChe']=!![]),_0x4a3012=_0x4a30['XjoFiM'](_0x4a3012,_0x5b7e6f),_0x4a30['bJmnAz'][_0x26f86a]=_0x4a3012):_0x4a3012=_0x214373,_0x4a3012;}class ClaudeRuntime{['id']=_0x3ae0b4(0x1da,'5lkq');#ci;constructor(_0x336c56={}){this.#ci=_0x336c56['ci']??![];}async[_0x3ae0b4(0x1d2,'lhtD')](_0x427cdc){await ensureClaude(_0x427cdc);}[_0x3ae0b4(0x1f5,'hTSx')](_0x26d920){const _0x17640b=_0x3ae0b4,_0x31a8c3={'emAVs':function(_0x29fe9d,_0x10d3e3,_0x585a09){return _0x29fe9d(_0x10d3e3,_0x585a09);},'VzMaL':function(_0x188461,_0x71c672){return _0x188461(_0x71c672);}},_0x506002=this.#ci?{...CI_DEFAULTS,...this.#toClaudeOptions(_0x26d920)}:this.#toClaudeOptions(_0x26d920),_0x3795b2=_0x31a8c3['emAVs'](spawnClaude,_0x506002,_0x31a8c3[_0x17640b(0x1b6,'g&2h')](toClaudeAuth,_0x26d920['auth']));return _0x26d920[_0x17640b(0x1bc,'zvtt')]&&_0x3795b2[_0x17640b(0x1af,'$S8r')]['on'](_0x26d920[_0x17640b(0x1e2,'g&2h')]),_0x3795b2[_0x17640b(0x1db,'AJ]H')];}[_0x3ae0b4(0x1d9,'MUId')](_0x45e320){const _0xaa51de=_0x3ae0b4,_0xad6ae5={'Yqefa':function(_0x1c13bc,_0xec5223,_0x5669d2){return _0x1c13bc(_0xec5223,_0x5669d2);}},_0x14d875=this.#ci?{...CI_DEFAULTS,...this.#toClaudeSessionOptions(_0x45e320)}:this.#toClaudeSessionOptions(_0x45e320),_0x2c1a3a=_0xad6ae5[_0xaa51de(0x1c6,'$S8r')](spawnClaudeBidirectional,_0x14d875,toClaudeAuth(_0x45e320[_0xaa51de(0x1e8,'4$ac')]));return _0x45e320['onEvent']&&_0x2c1a3a[_0xaa51de(0x1c7,'zwAi')]['on'](_0x45e320[_0xaa51de(0x1cc,'PPv)')]),{'events':_0x2c1a3a[_0xaa51de(0x1df,'Qnt8')],'sendTurn':_0x1b7f29=>_0x2c1a3a[_0xaa51de(0x1f0,'Qnt8')](_0x1b7f29),'cancel':()=>{const _0x4de8ac=_0xaa51de;try{_0x2c1a3a['process'][_0x4de8ac(0x1c1,'g&2h')]();}catch{}},'close':()=>_0x2c1a3a[_0xaa51de(0x1f7,']W#@')](),'result':_0x2c1a3a[_0xaa51de(0x1f4,'PPv)')]};}[_0x3ae0b4(0x1b3,'w^(%')](_0xc2ec03){return{'mcpServers':_0xc2ec03};}['translateAllowedTools'](_0x5b8c75){return _0x5b8c75;}#toClaudeSessionOptions(_0x236a38){const _0x71bb40=_0x3ae0b4,_0x201d03={'GYZtF':function(_0x339fea,_0x6c086e){return _0x339fea!==_0x6c086e;},'jMoUT':function(_0x3e6f55,_0xe56a89){return _0x3e6f55!==_0xe56a89;}},_0x5ac921={};_0x201d03[_0x71bb40(0x1e3,'idxG')](_0x236a38[_0x71bb40(0x1e1,']W#@')],void 0x0)&&(_0x5ac921[_0x71bb40(0x1c2,'c!Ta')]=_0x236a38[_0x71bb40(0x1bf,'h(M8')]);_0x236a38[_0x71bb40(0x1aa,'DFtY')]!==void 0x0&&(_0x5ac921[_0x71bb40(0x1b0,'ecpl')]=_0x236a38['model']);_0x201d03['GYZtF'](_0x236a38['maxTurns'],void 0x0)&&(_0x5ac921[_0x71bb40(0x1c9,'NfTK')]=_0x236a38[_0x71bb40(0x1e4,']W#@')]);_0x201d03[_0x71bb40(0x1d6,'w^(%')](_0x236a38[_0x71bb40(0x1d1,'DFtY')],void 0x0)&&(_0x5ac921[_0x71bb40(0x1dc,'POWZ')]=this[_0x71bb40(0x1c4,'$S8r')](_0x236a38[_0x71bb40(0x1ee,'h(M8')]));_0x236a38[_0x71bb40(0x1ae,'ecpl')]!==void 0x0&&(_0x5ac921[_0x71bb40(0x1ae,'ecpl')]=this['buildMcpConfig'](_0x236a38[_0x71bb40(0x1a9,'3gq[')])[_0x71bb40(0x1e9,'Iy3*')]);_0x201d03[_0x71bb40(0x1ba,'MUId')](_0x236a38[_0x71bb40(0x1b5,'q9r*')],void 0x0)&&(_0x5ac921[_0x71bb40(0x1f1,'*3s2')]=_0x236a38[_0x71bb40(0x1ef,'zwAi')]);if(this.#ci)_0x5ac921['env']={...CI_PAGER_ENV,..._0x236a38[_0x71bb40(0x1e7,'V8X]')]??{}};else _0x201d03['GYZtF'](_0x236a38[_0x71bb40(0x1d3,'MUId')],void 0x0)&&(_0x5ac921[_0x71bb40(0x1cf,'AJ]H')]=_0x236a38['env']);return _0x236a38[_0x71bb40(0x1ac,'Iy3*')]!==void 0x0&&(_0x5ac921[_0x71bb40(0x1c3,'1$Mg')]=_0x236a38[_0x71bb40(0x1cd,'2i0I')]),_0x201d03[_0x71bb40(0x1ec,'p@*i')](_0x236a38[_0x71bb40(0x1ed,'YT2X')],void 0x0)&&(_0x5ac921['resume']=_0x236a38[_0x71bb40(0x1b2,'$!E6')]),_0x5ac921[_0x71bb40(0x1cb,'CI*e')]=[_0x71bb40(0x1bd,'AJ]H'),'local'],_0x5ac921;}#toClaudeOptions(_0x216c37){const _0x3675fb=_0x3ae0b4;return{'prompt':_0x216c37[_0x3675fb(0x1eb,'idd^')],...this.#toClaudeSessionOptions(_0x216c37)};}}function getRuntime(_0x5ed5bd=_0x3ae0b4(0x1e6,'p@*i'),_0x5f39f6={}){const _0x3bb403=_0x3ae0b4,_0x2323b9={'rOdOb':'opencode','LOKxi':function(_0x2e2da0,_0xc25f80){return _0x2e2da0(_0xc25f80);}};switch(_0x5ed5bd){case _0x3bb403(0x1ce,'OBaR'):return new ClaudeRuntime({'ci':_0x5f39f6['ci']});case _0x2323b9['rOdOb']:throw new Error(_0x3bb403(0x1bb,'g&2h'));default:{const _0x5e5f86=_0x5ed5bd;throw new Error('Unknown\x20runtime:\x20'+_0x2323b9['LOKxi'](String,_0x5e5f86));}}}const PROVIDER_ENV_VAR={'anthropic':_0x3ae0b4(0x1b1,'V8X]'),'openai':_0x3ae0b4(0x1c5,'YT2X'),'openai-compatible':void 0x0,'custom':void 0x0},DEFAULT_MODEL_BY_PROVIDER={'anthropic':_0x3ae0b4(0x1c0,'CI*e'),'openai':_0x3ae0b4(0x1b7,'PPv)'),'openai-compatible':void 0x0,'custom':void 0x0};function _0x2932(){const _0x18134f=['EcBcPSoBsG','WPFcKJFdPtBcM8oSW5q','W4VcVHdcUshdSJpcOCoQw0bxdq','BcvQWRNdI8k7WOm6lcVcMW','WPFdJ1C','tmoGW6Hl','qJroq1ynEmoDW4FcTa','qHxdVueBp8k0E8ofhCoSqa','rtCJWRjUW5C','zqrKWPNdUW','daJdKe3dLx8','WRSgWR5GhCkEWPJdG1FcOGi7','mJhcJq','bCkAoJz+rSoGW4ZcVSkSFq','WPPTWRy','WR0JqmkYWQJdQCoYW5VdO1y','WPxdUb3cKCo8W4RdPHm0dJlcNHS','buhcUa1gEq','WQ4XsW','f1RdI8k7AY9eWRH5WQSu','WPNcNYddGIy','W6X8WPyvW6BcK8oGhZdcOG','q8kIWRqrzq','W6CwBCoxhCoEW4mVW7rpW5i','xdjny1OqymoXW5e','WPxdTMJdGSkAWPxcUt4','oCkbWQdcKL1PsZqAyG','xCkpW7hdRmkjWQ8','oCknWRtcPfq','WRpdR3xdTIxcMmkDsmoRWO7cQSopytddGazH','vmojWP/cJsqZ','wxaoqMDMWOmqW5VcN0HiACo+','BZJdTGiaWQFdVSkB','brO5','W7y1W4LdiG','eftcV1uF','rb3cKCoanJ8','ixFdLvFdMexcUYxcK8o5','W7WyW4tdUSo5','W48/W6fmdCozW43dMw7cLtBdQeVdHKz3vmocx8ofW6BcJSoNk8kpWQtdLCoHddDqsf8IzCkOWO5OW5XE4OkPW6uQjr7cI2TvW6lcGGzTAG','W7RdVdL5W4L7mq','W61YWQ4/W7VdTKO','W67dPSo4W7KRwSoQW65vWPy','WQKtWQf7d8kwWQZdPvFcOb48','wCkGWRddHNxdTcuEwCoxWPVdNIzMxCkdfW','W4SMW6Ho','ueZdSctdSdKCW6yzj8k3W4O','yYBdS8oNWOJdM8opWQLK','tmklW7xdRmkoWRddJSkLW6KrW6nDuSk8W4TTW4/cNYRdP8oP','mt3dPNBdUvpdOLqaW7KPW7hcJSoz','yCkiW7hdPmkC','nddcJmk3smoX','xeuf','gmkLE8k8W5tcOHfM','W4pcLbldIXVcPCkzA8oK','sCkPWQxdH3JdV28+wComWOFdMdC4','geRcJG5py8kI','W5FcPfZdK8kHWPxcUtii','WPNdOetdV3lcPY7cKColCgG','W7HUWRC','pNO4W73cMCoQWPXPedVcNwDsDq','t8kHWRWBFI/dISkzFCkNxdm','WRZcSmk/WRSata','W54VW6G','rHFdUeKCoCoKmSoZbmofE8kWWOO','W7JcLCkzjdtdTr7cKMO','uuGiE1C','qmo1nCorWPddOH1SW5JcLZRcVa','W43cTbhcVu/cSuhcUmo8qa','W4K0W7ddJmowW68Nv8kRW4jXnmo6W5qxWPi','f8kTWPVdOSkzuMTJW47dGNC','W69LWRiGW7ldOq','W6tcTaBdICowW60OWQO8WQS4W6e','bhX8W61hW7ekW4JdI1u','xb7cIa','e8kjmtXhua','eGFcTMpcOMr8W4C4bCkkW5Hl','WONcIJZdHsBcHmosW5v5BSk6WQa','W48HW4fuc8oyW50'];_0x2932=function(){return _0x18134f;};return _0x2932();}function resolveModel(_0x46c2d9){const _0x2bae81=_0x3ae0b4;return _0x46c2d9['runOverride']??_0x46c2d9[_0x2bae81(0x1f2,'hTSx')]??DEFAULT_MODEL_BY_PROVIDER[_0x46c2d9[_0x2bae81(0x1b4,'b9Vo')]];}export{ClaudeRuntime,DEFAULT_MODEL_BY_PROVIDER,PROVIDER_ENV_VAR,getRuntime,resolveModel};
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 \u2014 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.1.0",
4
+ "version": "0.2.0-beta.1",
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,15 +33,13 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "zod": "^4.4.3",
36
- "@yoloship/claude-sdk": "0.1.0"
36
+ "@yoloship/claude-sdk": "0.2.0-beta.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@vitest/coverage-v8": "^4.1.4",
40
39
  "cross-env": "^10.1.0",
41
- "javascript-obfuscator": "^5.4.1",
40
+ "javascript-obfuscator": "^5.4.2",
42
41
  "typescript": "^5.9.3",
43
- "unbuild": "^3.5.0",
44
- "vitest": "^4.1.4"
42
+ "unbuild": "^3.5.0"
45
43
  },
46
44
  "lint-staged": {
47
45
  "*.{js,ts,vue,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"