@aifight/aifight 0.1.0-alpha.6 → 0.1.0-alpha.8
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 +73 -6
- package/dist/bin.mjs +193 -144
- package/dist/index.mjs +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +3 -2
- package/dist/types/agents/agent.d.ts +0 -82
- package/dist/types/agents/state-machine.d.ts +0 -96
- package/dist/types/bridge/auto-update.d.ts +0 -53
- package/dist/types/bridge/config.d.ts +0 -35
- package/dist/types/bridge/hermes-provider.d.ts +0 -9
- package/dist/types/bridge/openclaw-provider.d.ts +0 -9
- package/dist/types/bridge/pairing.d.ts +0 -18
- package/dist/types/bridge/provider.d.ts +0 -18
- package/dist/types/bridge/runner.d.ts +0 -30
- package/dist/types/bridge/service.d.ts +0 -55
- package/dist/types/bridge/update-check.d.ts +0 -23
- package/dist/types/cli/agent-resolver.d.ts +0 -25
- package/dist/types/cli/argv.d.ts +0 -13
- package/dist/types/cli/commands/agent-list.d.ts +0 -2
- package/dist/types/cli/commands/agent-status.d.ts +0 -2
- package/dist/types/cli/commands/bridge-accept.d.ts +0 -2
- package/dist/types/cli/commands/bridge-challenge.d.ts +0 -2
- package/dist/types/cli/commands/bridge-connect.d.ts +0 -2
- package/dist/types/cli/commands/bridge-register.d.ts +0 -7
- package/dist/types/cli/commands/bridge-run.d.ts +0 -7
- package/dist/types/cli/commands/bridge-service.d.ts +0 -5
- package/dist/types/cli/commands/bridge-set.d.ts +0 -2
- package/dist/types/cli/commands/bridge-start.d.ts +0 -2
- package/dist/types/cli/commands/bridge-status.d.ts +0 -2
- package/dist/types/cli/commands/bridge-uninstall.d.ts +0 -4
- package/dist/types/cli/commands/bridge-update.d.ts +0 -2
- package/dist/types/cli/commands/config-init.d.ts +0 -2
- package/dist/types/cli/commands/config-probe.d.ts +0 -2
- package/dist/types/cli/commands/config-validate.d.ts +0 -2
- package/dist/types/cli/commands/daily-off.d.ts +0 -2
- package/dist/types/cli/commands/daily-on.d.ts +0 -2
- package/dist/types/cli/commands/daily-set.d.ts +0 -2
- package/dist/types/cli/commands/daily-show.d.ts +0 -2
- package/dist/types/cli/commands/doctor.d.ts +0 -2
- package/dist/types/cli/commands/init.d.ts +0 -2
- package/dist/types/cli/commands/join.d.ts +0 -2
- package/dist/types/cli/commands/leave.d.ts +0 -2
- package/dist/types/cli/commands/mcp.d.ts +0 -2
- package/dist/types/cli/commands/runtime-management.d.ts +0 -18
- package/dist/types/cli/commands/runtime-setup-state.d.ts +0 -21
- package/dist/types/cli/commands/runtime-setup.d.ts +0 -25
- package/dist/types/cli/commands/serve.d.ts +0 -2
- package/dist/types/cli/commands/service/launchd.d.ts +0 -71
- package/dist/types/cli/commands/service/platform.d.ts +0 -69
- package/dist/types/cli/commands/service/systemd.d.ts +0 -55
- package/dist/types/cli/commands/service/types.d.ts +0 -64
- package/dist/types/cli/commands/service-install.d.ts +0 -29
- package/dist/types/cli/commands/setup.d.ts +0 -2
- package/dist/types/cli/commands/shutdown.d.ts +0 -2
- package/dist/types/cli/commands/stubs.d.ts +0 -24
- package/dist/types/cli/commands/version.d.ts +0 -2
- package/dist/types/cli/control-client.d.ts +0 -59
- package/dist/types/cli/format.d.ts +0 -52
- package/dist/types/cli/main.d.ts +0 -18
- package/dist/types/cli/runtime-files.d.ts +0 -11
- package/dist/types/cli/shared.d.ts +0 -74
- package/dist/types/controlapi/profile-routes.d.ts +0 -49
- package/dist/types/controlapi/server.d.ts +0 -3
- package/dist/types/controlapi/types.d.ts +0 -136
- package/dist/types/daemon/agent-decision-adapter.d.ts +0 -40
- package/dist/types/daemon/lifecycle.d.ts +0 -85
- package/dist/types/daemon/router.d.ts +0 -97
- package/dist/types/daemon/runtime-files-write.d.ts +0 -76
- package/dist/types/identity/identity-manager.d.ts +0 -59
- package/dist/types/llm/adapter-registry.d.ts +0 -27
- package/dist/types/llm/adapters/anthropic-messages.d.ts +0 -2
- package/dist/types/llm/adapters/deepseek-chat-completions.d.ts +0 -2
- package/dist/types/llm/adapters/openai-chat-compat.d.ts +0 -2
- package/dist/types/llm/adapters/openai-chat-completions.d.ts +0 -2
- package/dist/types/llm/adapters/openai-responses.d.ts +0 -2
- package/dist/types/llm/adapters/types.d.ts +0 -128
- package/dist/types/llm/capabilities/validate-capabilities.d.ts +0 -68
- package/dist/types/mcp/control-client.d.ts +0 -54
- package/dist/types/mcp/profile-tools.d.ts +0 -10
- package/dist/types/mcp/server.d.ts +0 -10
- package/dist/types/mcp/tools.d.ts +0 -31
- package/dist/types/mcp/types.d.ts +0 -27
- package/dist/types/profile/config-schema.d.ts +0 -199
- package/dist/types/profile/identity-schema.d.ts +0 -75
- package/dist/types/profile/index.d.ts +0 -7
- package/dist/types/profile/migrate.d.ts +0 -16
- package/dist/types/profile/profile-loader.d.ts +0 -64
- package/dist/types/profile/secret-ref.d.ts +0 -82
- package/dist/types/profile/soul.d.ts +0 -46
- package/dist/types/profile/strategy-schema.d.ts +0 -70
- package/dist/types/reflection/proposal-store.d.ts +0 -50
- package/dist/types/reflection/reflection-engine.d.ts +0 -81
- package/dist/types/scheduler/daily.d.ts +0 -47
- package/dist/types/scheduler/types.d.ts +0 -42
- package/dist/types/session/match-session-manager.d.ts +0 -113
- package/dist/types/session/session-context-builder.d.ts +0 -68
package/dist/index.mjs
CHANGED
|
@@ -104,4 +104,4 @@ ${vs}`:vs;if(c=a(l,y),c.length<=n)return c}return c=a(l,""),c.length<=n||(c=a(""
|
|
|
104
104
|
`)}function nb(t){switch(t){case"texas_holdem":return["Phase:","Hand ","Your hand:","Board:","Your chips:","Pot:"];case"liars_dice":return["Phase:","Round ","Your dice:","Current bid:"];case"coup":return["Phase:","Your unrevealed cards:","Your coins:","Pending action:"]}}var jt=class extends Error{provider;cause;constructor(e,r,n){super(r),this.provider=e,this.cause=n}},ut=class extends jt{name="DirectModelNetworkError";kind="direct_model_network";constructor(e,r,n){super(e,r,n)}},Me=class extends jt{name="DirectModelHttpError";kind="direct_model_http";status;bodySnippet;constructor(e,r,n,s,o){super(e,n,o),this.status=r,this.bodySnippet=s}},be=class extends jt{name="DirectModelAbortedError";kind="direct_model_aborted";constructor(e,r,n){super(e,r,n)}},we=class extends jt{name="DirectModelInvalidResponseError";kind="direct_model_invalid_response";responseSnippet;constructor(e,r,n,s){super(e,r,s),this.responseSnippet=n}},J=class extends jt{name="DirectModelUnsupportedError";kind="direct_model_unsupported";field;constructor(e,r,n){super(e,n),this.field=r}},Md=2048,Id="[REDACTED]";function fn(t,e){let r=t;for(let n of e){if(!n)continue;let s=r.indexOf(n);for(;s>=0;)r=r.slice(0,s)+Id+r.slice(s+n.length),s=r.indexOf(n,s+Id.length)}return r}function sb(t,e=Md){if(e<=0)return"";if(t.length<=e)return t;let r=e,n="";for(let s=0;s<8;s++){let i=`...[truncated ${t.length-r} chars]`,a=Math.max(0,e-i.length);if(i===n&&a===r)break;n=i,r=a}return e<n.length?n.slice(0,e):t.slice(0,r)+n}function dt(t,e){if(t===void 0||t==="")return;let r=fn(t,e);return sb(r,Md)}var Ee="anthropic",ob="https://api.anthropic.com",ib="2023-06-01";function Dd(t){if(!t.apiKey)throw new J(Ee,"apiKey","apiKey must be a non-empty string");if(!t.model)throw new J(Ee,"model","model must be a non-empty string");let e=t.apiKey,r=t.model,n=(t.baseURL??ob).replace(/\/+$/,""),s=t.anthropicVersion??ib,o=t.fetchImpl??globalThis.fetch;if(typeof o!="function")throw new J(Ee,"fetchImpl","fetch is unavailable; pass fetchImpl explicitly");let i=`${n}/v1/messages`,a=[e];return{provider:Ee,model:r,generate:async l=>{if(!Number.isFinite(l.maxTokens)||l.maxTokens<=0)throw new J(Ee,"maxTokens","maxTokens must be a positive integer");let u=l.signal;if(u?.aborted)throw new be(Ee,"request aborted before send",u.reason);let d={model:r,system:l.systemPrompt,messages:[{role:"user",content:l.userPrompt}],max_tokens:l.maxTokens};l.temperature!==void 0&&(d.temperature=l.temperature);let f={"x-api-key":e,"anthropic-version":s,"content-type":"application/json"},p=performance.now(),h;try{h=await o(i,{method:"POST",headers:f,body:JSON.stringify(d),signal:u})}catch(v){if(ab(v))throw new be(Ee,"request aborted",v);let D=fn(cb(v),a);throw new ut(Ee,`fetch failed: ${D}`,v)}let m=Math.max(0,performance.now()-p);if(!h.ok){let v=await Ld(h),D=dt(v,a);throw new Me(Ee,h.status,`Anthropic returned HTTP ${h.status}`,D,h)}let y=await Ld(h),g;try{g=JSON.parse(y)}catch(v){throw new we(Ee,"response body is not valid JSON",dt(y,a),v)}let b=lb(g);if(b===null)throw new we(Ee,"response missing content[0].text or content[0].type !== 'text'",dt(y,a));let{inputTokens:E,outputTokens:S}=ub(g);return{text:b,inputTokens:E,outputTokens:S,latencyMs:m,raw:g}}}}function ab(t){if(t===null||typeof t!="object")return!1;let e=t;return e.name==="AbortError"||e.code==="ABORT_ERR"||e.code===20}function cb(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return String(t)}catch{return"unknown"}}async function Ld(t){try{return await t.text()}catch{return""}}function lb(t){if(!bs(t))return null;let e=t.content;if(!Array.isArray(e)||e.length===0)return null;let r=e[0];if(!bs(r)||r.type!=="text")return null;let n=r.text;return typeof n!="string"?null:n}function ub(t){if(!bs(t))return{};let e=t.usage;if(!bs(e))return{};let r=e.input_tokens,n=e.output_tokens;return{inputTokens:typeof r=="number"?r:void 0,outputTokens:typeof n=="number"?n:void 0}}function bs(t){return typeof t=="object"&&t!==null}var Se="openai",db="https://api.openai.com/v1";function qd(t){if(!t.apiKey)throw new J(Se,"apiKey","apiKey must be a non-empty string");if(!t.model)throw new J(Se,"model","model must be a non-empty string");let e=t.apiKey,r=t.model,n=(t.baseURL??db).replace(/\/+$/,""),s=t.organization,o=t.fetchImpl??globalThis.fetch;if(typeof o!="function")throw new J(Se,"fetchImpl","fetch is unavailable; pass fetchImpl explicitly");let i=`${n}/chat/completions`,a=[e];return{provider:Se,model:r,generate:async l=>{if(!Number.isFinite(l.maxTokens)||l.maxTokens<=0)throw new J(Se,"maxTokens","maxTokens must be a positive integer");let u=l.signal;if(u?.aborted)throw new be(Se,"request aborted before send",u.reason);let d={model:r,messages:[{role:"system",content:l.systemPrompt},{role:"user",content:l.userPrompt}],max_completion_tokens:l.maxTokens};l.temperature!==void 0&&(d.temperature=l.temperature);let f={Authorization:`Bearer ${e}`,"content-type":"application/json"};s&&(f["OpenAI-Organization"]=s);let p=performance.now(),h;try{h=await o(i,{method:"POST",headers:f,body:JSON.stringify(d),signal:u})}catch(v){if(fb(v))throw new be(Se,"request aborted",v);let D=fn(hb(v),a);throw new ut(Se,`fetch failed: ${D}`,v)}let m=Math.max(0,performance.now()-p);if(!h.ok){let v=await jd(h),D=dt(v,a);throw new Me(Se,h.status,`OpenAI returned HTTP ${h.status}`,D,h)}let y=await jd(h),g;try{g=JSON.parse(y)}catch(v){throw new we(Se,"response body is not valid JSON",dt(y,a),v)}let b=pb(g);if(b===null)throw new we(Se,"response missing choices[0].message.content (or content is not a string)",dt(y,a));let{inputTokens:E,outputTokens:S}=mb(g);return{text:b,inputTokens:E,outputTokens:S,latencyMs:m,raw:g}}}}function fb(t){if(t===null||typeof t!="object")return!1;let e=t;return e.name==="AbortError"||e.code==="ABORT_ERR"||e.code===20}function hb(t){if(t instanceof Error)return t.message;if(typeof t=="string")return t;try{return String(t)}catch{return"unknown"}}async function jd(t){try{return await t.text()}catch{return""}}function pb(t){if(!hn(t))return null;let e=t.choices;if(!Array.isArray(e)||e.length===0)return null;let r=e[0];if(!hn(r))return null;let n=r.message;if(!hn(n))return null;let s=n.content;return typeof s!="string"?null:s}function mb(t){if(!hn(t))return{};let e=t.usage;if(!hn(e))return{};let r=e.prompt_tokens,n=e.completion_tokens;return{inputTokens:typeof r=="number"?r:void 0,outputTokens:typeof n=="number"?n:void 0}}function hn(t){return typeof t=="object"&&t!==null}var W=class extends Error{name="DecisionProviderError";kind;cause;constructor(e,r,n){super(r),this.kind=e,this.cause=n}},yb=2,gb=500;function _b(t){let e=t.retryBudget??yb,r=t.parseRetryHintCharCap??gb;if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new W("fatal_caller_bug",`retryBudget must be a non-negative integer (got ${String(t.retryBudget)})`);if(!Number.isFinite(r)||!Number.isInteger(r)||r<=0)throw new W("fatal_caller_bug",`parseRetryHintCharCap must be a positive integer (got ${String(t.parseRetryHintCharCap)})`);let n=new Map;function s(c,l){let u=`${c}:${l}`,d=n.get(u);if(d)return d;let f;try{f=t.apiKeyResolver(c,l)}catch(h){throw new W("fatal_unsupported",`apiKeyResolver threw for ${c}:${l}`,h)}if(typeof f!="string"||!f)throw new W("fatal_unsupported",`apiKeyResolver returned empty key for ${c}:${l}`);let p;try{c==="anthropic"?p=(t.clientFactory?.anthropic??Dd)({apiKey:f,model:l,fetchImpl:t.fetchImpl}):p=(t.clientFactory?.openai??qd)({apiKey:f,model:l,fetchImpl:t.fetchImpl})}catch(h){throw h instanceof J?new W("fatal_unsupported",h.message,h):new W("fatal_caller_bug",`clientFactory.${c} threw unexpected error`,h)}return n.set(u,p),p}async function o(c){if(typeof c.decisionBudgetMs!="number"||!Number.isFinite(c.decisionBudgetMs)||c.decisionBudgetMs<=0)throw new W("fatal_caller_bug","decisionBudgetMs must be a positive finite number");if(!bb(c.game))throw new W("fatal_caller_bug",`unsupported game: ${String(c.game)}`);let l=new AbortController,u=setTimeout(()=>{l.abort()},c.decisionBudgetMs);try{return await i(c,l.signal)}finally{clearTimeout(u)}}async function i(c,l){if(l.aborted)throw new W("fatal_aborted","decisionBudgetMs already elapsed before decide started");let u=s(c.strategyProfile.provider,c.strategyProfile.model),d=Cd(c),f,p,h=0,m;for(let g=0;g<=e;g++){if(l.aborted)throw new W("fatal_aborted","decisionBudgetMs elapsed mid-attempt");let b=g===0?d.userPrompt:d.userPrompt+`
|
|
105
105
|
|
|
106
106
|
`+Tb(g,f,p,r),E;try{E=await u.generate({systemPrompt:d.systemPrompt,userPrompt:b,temperature:c.strategyProfile.temperature,maxTokens:c.strategyProfile.maxTokens,signal:l})}catch(v){if($b(v))throw kb(v);if(Sb(v)){f=`direct_model_${v.kind}`,p=Pb(v);continue}throw new W("fatal_caller_bug","client.generate threw unexpected error",v)}h+=E.latencyMs,m=E;let S=wb(c.game,E.text,c.legalActions,r);if(S.kind==="ok")return vb(c,S,E,h,g);f=`parse_${S.reason}`,p=S.rawSnippet}let y;try{y=Eb(c)}catch(g){throw new W("fatal_caller_bug",g instanceof Error?`fallback dispatch failed: ${g.message}`:"fallback dispatch failed",g)}return{action:y.type,params:Fd(y.data),summary:`(fallback: ${f??"unknown"})`,providerMetadata:{provider:c.strategyProfile.provider,model:c.strategyProfile.model,inputTokens:m?.inputTokens,outputTokens:m?.outputTokens,latencyMs:h,retries:e,fallback:!0}}}async function a(){if(!t.healthCheckProfile)return!1;try{return await s(t.healthCheckProfile.provider,t.healthCheckProfile.model).generate({systemPrompt:"ping",userPrompt:"respond with the word OK",maxTokens:10}),!0}catch{return!1}}return{name:t.name,decide:o,healthCheck:a}}function vb(t,e,r,n,s){let o=Fd(e.action.data),i={action:e.action.type,providerMetadata:{provider:t.strategyProfile.provider,model:t.strategyProfile.model,inputTokens:r.inputTokens,outputTokens:r.outputTokens,latencyMs:n,retries:s,fallback:!1}};return o!==void 0&&e.summary!==void 0?{...i,params:o,summary:e.summary}:o!==void 0?{...i,params:o}:e.summary!==void 0?{...i,summary:e.summary}:i}function bb(t){return t==="texas_holdem"||t==="liars_dice"||t==="coup"}function wb(t,e,r,n){switch(t){case"texas_holdem":return Sd(e,r,n);case"liars_dice":return $d(e,r,n);case"coup":return Pd(e,r,n)}}function Eb(t){switch(t.game){case"texas_holdem":return bd({publicState:t.publicState,legalActions:t.legalActions,yourPlayerId:t.playerId});case"liars_dice":return wd({publicState:t.publicState,legalActions:t.legalActions,yourPlayerId:t.playerId});case"coup":return Ed({publicState:t.publicState,legalActions:t.legalActions,yourPlayerId:t.playerId})}}function Fd(t){if(t!=null&&typeof t=="object"&&!Array.isArray(t))return t}function Sb(t){return t instanceof we||t instanceof ut?!0:t instanceof Me?t.status===429||t.status>=500:!1}function $b(t){return t instanceof be||t instanceof J?!0:t instanceof Me?!(t.status===429||t.status>=500):!1}function kb(t){return t instanceof be?new W("fatal_aborted",t.message,t):t instanceof J?new W("fatal_unsupported",t.message,t):new W("fatal_http",t.message,t)}function Pb(t){if(t instanceof Me)return t.bodySnippet;if(t instanceof we)return t.responseSnippet}function Tb(t,e,r,n){let s=[];if(s.push(`Retry attempt ${t}: previous output failed validation.`),e&&s.push(`Reason: ${e}.`),r!==void 0&&r!==""){let o=r.length>n?r.slice(0,n):r;s.push(`Previous output (truncated to ${n} chars): ${o}`)}return s.push("Please retry. Respond with a single JSON object exactly matching the schema in the system prompt."),s.join(`
|
|
107
|
-
`)}var Rb="0.1.0-alpha.
|
|
107
|
+
`)}var Rb="0.1.0-alpha.8",TS="v1.0.0";function xS(){let t=Ft(),e=ft(),r=Es();return{ok:!0,runtimeVersion:Rb,schemaCount:e.size,messageTypeCount:r.length,schemasRoot:t}}export{tn as AIFIGHT_CRYPTO_V1_PREFIX,en as AIFIGHT_KEYCHAIN_V1_PREFIX,nu as AIFIGHT_RUNTIME_SERVICE,Ae as CredentialsCorruptError,ue as CredentialsCryptoError,or as CredentialsError,ir as CredentialsKeychainUnavailableError,W as DecisionProviderError,TS as PROTOCOL_VERSION,Rb as RUNTIME_VERSION,_r as ReconnectStoppedError,sr as RegisterError,Xr as RegisterHttpError,St as RegisterNetworkError,$t as RegisterSchemaError,rt as StoreError,lr as StoreMigrationError,cr as StoreOpenError,nt as StoreQueryError,Ke as WSAbortedError,Y as WSClientError,Ct as WSClosedError,it as WSConnectError,at as WSHandshakeError,Ie as WSOutboundSchemaError,At as WSProtocolVersionError,se as WSSchemaError,ze as WSUnknownMessageError,ct as WSWelcomeInvalidError,Nt as WSWelcomeTimeoutError,_b as createDirectModelProvider,rv as createReconnectingWSClient,Xi as createWSClient,f_ as decryptFromStorage,h_ as deleteFromStorage,l_ as encryptForStorage,Zr as ensureRuntimeHome,Ft as findSchemasRoot,ou as getCredentialsBackend,_i as getDefaultDbPath,Qr as getRuntimeHome,xS as hello,iu as isKeychainAvailable,ft as loadAllSchemas,Ss as loadRestSchema,Jd as loadSchema,Es as messageTypes,Xg as openDatabase,Hg as registerAgent};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export { createDirectModelProvider, DecisionProviderError, } from "./decision/pr
|
|
|
18
18
|
export type { DecisionProvider, DirectModelProviderOptions, DirectModelProviderName, DecisionProviderErrorKind, } from "./decision/provider";
|
|
19
19
|
export type { DecisionRequest, DecisionResponse, DecisionResponseProviderMetadata, StrategyProfile, GameSpecificProfile, GameType, GameRules, LegalAction, } from "./decision/types";
|
|
20
20
|
export type { ParseResult, ParseInvalidReason, } from "./decision/parser-types";
|
|
21
|
-
export declare const RUNTIME_VERSION = "0.1.0-alpha.
|
|
21
|
+
export declare const RUNTIME_VERSION = "0.1.0-alpha.8";
|
|
22
22
|
export declare const PROTOCOL_VERSION = "v1.0.0";
|
|
23
23
|
export interface HelloResult {
|
|
24
24
|
ok: true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aifight/aifight",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"description": "AIFight CLI — local outbound bridge that connects AIFight to user-selected Agent runtimes.",
|
|
5
5
|
"license": "MIT-0",
|
|
6
6
|
"type": "module",
|
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "./build.sh",
|
|
43
43
|
"gen:schema": "node scripts/bundle-schema.mjs",
|
|
44
|
+
"readme:check": "node scripts/verify-readme-commands.mjs",
|
|
44
45
|
"pack:check": "node scripts/verify-packlist.mjs",
|
|
45
|
-
"prepublishOnly": "npm run build && npm run pack:check",
|
|
46
|
+
"prepublishOnly": "npm run build && npm run readme:check && npm run pack:check",
|
|
46
47
|
"test": "npm run gen:schema && vitest run",
|
|
47
48
|
"check-types": "npm run gen:schema && tsc --noEmit -p tsconfig.json"
|
|
48
49
|
},
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { MsgActionRequest, MsgGameOver } from "../protocol/types";
|
|
2
|
-
import { type ReconnectingWSClient, type ReconnectingWSClientOptions } from "../wsclient/reconnect";
|
|
3
|
-
import { type AgentFSMEffect, type AgentFSMState } from "./state-machine";
|
|
4
|
-
export interface AgentDecisionContext {
|
|
5
|
-
readonly actionRequest: MsgActionRequest;
|
|
6
|
-
readonly matchId: string;
|
|
7
|
-
readonly game?: string;
|
|
8
|
-
readonly state: AgentFSMState;
|
|
9
|
-
}
|
|
10
|
-
export interface AgentDecisionProvider {
|
|
11
|
-
decide(ctx: AgentDecisionContext): Promise<unknown>;
|
|
12
|
-
}
|
|
13
|
-
export interface AgentInstanceNotify {
|
|
14
|
-
readonly level: "info" | "warning" | "error";
|
|
15
|
-
readonly code: string;
|
|
16
|
-
readonly message: string;
|
|
17
|
-
readonly cause?: unknown;
|
|
18
|
-
}
|
|
19
|
-
export interface AgentInstanceSnapshot {
|
|
20
|
-
readonly name: string;
|
|
21
|
-
readonly state: AgentFSMState | null;
|
|
22
|
-
readonly transport: ReconnectingWSClient["state"] | "idle";
|
|
23
|
-
readonly started: boolean;
|
|
24
|
-
readonly stopped: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface AgentInstanceOptions {
|
|
27
|
-
readonly name: string;
|
|
28
|
-
readonly ws: ReconnectingWSClientOptions;
|
|
29
|
-
readonly autoConfirmMatches?: boolean;
|
|
30
|
-
readonly decisionProvider: AgentDecisionProvider;
|
|
31
|
-
readonly connect?: (opts: ReconnectingWSClientOptions) => Promise<ReconnectingWSClient>;
|
|
32
|
-
readonly now?: () => number;
|
|
33
|
-
readonly onNotify?: (event: AgentInstanceNotify) => void;
|
|
34
|
-
readonly onReadinessCheck?: (data: unknown) => Promise<unknown> | unknown;
|
|
35
|
-
readonly onResult?: (gameOver: MsgGameOver, context: {
|
|
36
|
-
readonly game?: string;
|
|
37
|
-
}) => void;
|
|
38
|
-
readonly onFallbackRequired?: (effect: Extract<AgentFSMEffect, {
|
|
39
|
-
type: "fallback_required";
|
|
40
|
-
}>) => void;
|
|
41
|
-
}
|
|
42
|
-
export type AgentInstanceErrorKind = "agent_start" | "agent_not_started" | "agent_stopped" | "agent_effect";
|
|
43
|
-
export declare abstract class AgentInstanceError extends Error {
|
|
44
|
-
abstract readonly kind: AgentInstanceErrorKind;
|
|
45
|
-
readonly cause: unknown;
|
|
46
|
-
protected constructor(message: string, cause?: unknown);
|
|
47
|
-
}
|
|
48
|
-
export declare class AgentInstanceStartError extends AgentInstanceError {
|
|
49
|
-
readonly name = "AgentInstanceStartError";
|
|
50
|
-
readonly kind: "agent_start";
|
|
51
|
-
constructor(message: string, cause?: unknown);
|
|
52
|
-
}
|
|
53
|
-
export declare class AgentInstanceNotStartedError extends AgentInstanceError {
|
|
54
|
-
readonly name = "AgentInstanceNotStartedError";
|
|
55
|
-
readonly kind: "agent_not_started";
|
|
56
|
-
constructor(message: string, cause?: unknown);
|
|
57
|
-
}
|
|
58
|
-
export declare class AgentInstanceStoppedError extends AgentInstanceError {
|
|
59
|
-
readonly name = "AgentInstanceStoppedError";
|
|
60
|
-
readonly kind: "agent_stopped";
|
|
61
|
-
constructor(message: string, cause?: unknown);
|
|
62
|
-
}
|
|
63
|
-
export declare class AgentInstanceEffectError extends AgentInstanceError {
|
|
64
|
-
readonly name = "AgentInstanceEffectError";
|
|
65
|
-
readonly kind: "agent_effect";
|
|
66
|
-
constructor(message: string, cause?: unknown);
|
|
67
|
-
}
|
|
68
|
-
type StateHandler = (snapshot: AgentInstanceSnapshot) => void;
|
|
69
|
-
export declare class AgentInstance {
|
|
70
|
-
#private;
|
|
71
|
-
constructor(opts: AgentInstanceOptions);
|
|
72
|
-
start(): Promise<AgentInstanceSnapshot>;
|
|
73
|
-
stop(reason?: string): Promise<void>;
|
|
74
|
-
joinQueue(game: string, mode?: string, opts?: {
|
|
75
|
-
readonly oneShot?: boolean;
|
|
76
|
-
}): void;
|
|
77
|
-
leaveQueue(): void;
|
|
78
|
-
confirmMatch(confirmId?: string): void;
|
|
79
|
-
snapshot(): AgentInstanceSnapshot;
|
|
80
|
-
onState(handler: StateHandler): () => void;
|
|
81
|
-
}
|
|
82
|
-
export {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { MsgActionRequest, MsgGameOver, MsgMatchConfirmRequest } from "../protocol/types";
|
|
2
|
-
import type { ServerMessageEnvelope } from "../wsclient/frame-handler";
|
|
3
|
-
import type { WSClientMessage, WSWelcome } from "../wsclient/client";
|
|
4
|
-
import type { ReconnectCloseInfo, ReconnectEvent } from "../wsclient/reconnect";
|
|
5
|
-
export type AgentPhase = "connected" | "queuing" | "confirming" | "matching" | "in_match" | "deciding" | "reporting" | "closed";
|
|
6
|
-
export type AgentTransportState = "connected" | "backoff" | "closed";
|
|
7
|
-
export interface AgentFSMState {
|
|
8
|
-
readonly phase: AgentPhase;
|
|
9
|
-
readonly transport: AgentTransportState;
|
|
10
|
-
readonly agentId: string;
|
|
11
|
-
readonly agentName: string;
|
|
12
|
-
readonly availableGames: readonly string[];
|
|
13
|
-
readonly autoConfirmMatches: boolean;
|
|
14
|
-
readonly queue?: {
|
|
15
|
-
readonly game: string;
|
|
16
|
-
readonly mode: string;
|
|
17
|
-
readonly one_shot?: boolean;
|
|
18
|
-
};
|
|
19
|
-
readonly pendingConfirm?: MsgMatchConfirmRequest["data"];
|
|
20
|
-
readonly activeMatch?: {
|
|
21
|
-
readonly sessionId: string;
|
|
22
|
-
readonly game: string;
|
|
23
|
-
readonly startedAt: number;
|
|
24
|
-
};
|
|
25
|
-
readonly pendingAction?: MsgActionRequest;
|
|
26
|
-
readonly lastGameOver?: MsgGameOver;
|
|
27
|
-
readonly lastError?: string;
|
|
28
|
-
}
|
|
29
|
-
export type AgentFSMInput = {
|
|
30
|
-
type: "start";
|
|
31
|
-
welcome: WSWelcome;
|
|
32
|
-
autoConfirmMatches?: boolean;
|
|
33
|
-
now?: number;
|
|
34
|
-
} | {
|
|
35
|
-
type: "command.join_queue";
|
|
36
|
-
game: string;
|
|
37
|
-
mode?: string;
|
|
38
|
-
oneShot?: boolean;
|
|
39
|
-
} | {
|
|
40
|
-
type: "command.leave_queue";
|
|
41
|
-
} | {
|
|
42
|
-
type: "command.confirm_match";
|
|
43
|
-
confirmId?: string;
|
|
44
|
-
} | {
|
|
45
|
-
type: "ws.message";
|
|
46
|
-
message: ServerMessageEnvelope;
|
|
47
|
-
now?: number;
|
|
48
|
-
} | {
|
|
49
|
-
type: "decision.ready";
|
|
50
|
-
action: unknown;
|
|
51
|
-
} | {
|
|
52
|
-
type: "decision.failed";
|
|
53
|
-
reason: unknown;
|
|
54
|
-
} | {
|
|
55
|
-
type: "reconnect.event";
|
|
56
|
-
event: ReconnectEvent;
|
|
57
|
-
} | {
|
|
58
|
-
type: "reconnect.close";
|
|
59
|
-
info: ReconnectCloseInfo;
|
|
60
|
-
} | {
|
|
61
|
-
type: "stop";
|
|
62
|
-
reason?: string;
|
|
63
|
-
};
|
|
64
|
-
export type AgentFSMEffect = {
|
|
65
|
-
type: "send";
|
|
66
|
-
message: WSClientMessage;
|
|
67
|
-
} | {
|
|
68
|
-
type: "request_decision";
|
|
69
|
-
actionRequest: MsgActionRequest;
|
|
70
|
-
matchId: string;
|
|
71
|
-
game?: string;
|
|
72
|
-
} | {
|
|
73
|
-
type: "fallback_required";
|
|
74
|
-
actionRequest: MsgActionRequest;
|
|
75
|
-
reason: unknown;
|
|
76
|
-
} | {
|
|
77
|
-
type: "record_result";
|
|
78
|
-
gameOver: MsgGameOver;
|
|
79
|
-
game?: string;
|
|
80
|
-
} | {
|
|
81
|
-
type: "notify";
|
|
82
|
-
level: "info" | "warning" | "error";
|
|
83
|
-
code: string;
|
|
84
|
-
message: string;
|
|
85
|
-
};
|
|
86
|
-
export interface AgentFSMTransition {
|
|
87
|
-
readonly state: AgentFSMState;
|
|
88
|
-
readonly effects: readonly AgentFSMEffect[];
|
|
89
|
-
}
|
|
90
|
-
export interface CreateInitialAgentFSMInput {
|
|
91
|
-
readonly welcome: WSWelcome;
|
|
92
|
-
readonly autoConfirmMatches?: boolean;
|
|
93
|
-
readonly now?: number;
|
|
94
|
-
}
|
|
95
|
-
export declare function createInitialAgentFSM(input: CreateInitialAgentFSMInput): AgentFSMState;
|
|
96
|
-
export declare function transitionAgentFSM(state: AgentFSMState, input: AgentFSMInput): AgentFSMTransition;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { AgentInstanceSnapshot } from "../agents/agent";
|
|
2
|
-
import { type BridgeUpdateCheck } from "./update-check";
|
|
3
|
-
export declare const DEFAULT_AUTO_UPDATE_INITIAL_DELAY_MS: number;
|
|
4
|
-
export declare const DEFAULT_AUTO_UPDATE_INTERVAL_MS: number;
|
|
5
|
-
interface UpdateExecResult {
|
|
6
|
-
readonly stdout: string;
|
|
7
|
-
readonly stderr: string;
|
|
8
|
-
}
|
|
9
|
-
type UpdateExecFile = (file: string, args: readonly string[]) => Promise<UpdateExecResult>;
|
|
10
|
-
type AutoUpdateLogLevel = "info" | "warning";
|
|
11
|
-
export interface BridgeAutoUpdateLogEvent {
|
|
12
|
-
readonly level: AutoUpdateLogLevel;
|
|
13
|
-
readonly code: string;
|
|
14
|
-
readonly message: string;
|
|
15
|
-
}
|
|
16
|
-
export type BridgeAutoUpdateResult = {
|
|
17
|
-
readonly status: "current" | "unknown";
|
|
18
|
-
readonly update: BridgeUpdateCheck;
|
|
19
|
-
} | {
|
|
20
|
-
readonly status: "busy";
|
|
21
|
-
readonly phase: string | null;
|
|
22
|
-
readonly update: BridgeUpdateCheck;
|
|
23
|
-
} | {
|
|
24
|
-
readonly status: "updated";
|
|
25
|
-
readonly update: BridgeUpdateCheck;
|
|
26
|
-
} | {
|
|
27
|
-
readonly status: "failed";
|
|
28
|
-
readonly update: BridgeUpdateCheck;
|
|
29
|
-
readonly error: string;
|
|
30
|
-
};
|
|
31
|
-
export interface RunBridgeAutoUpdateCheckOptions {
|
|
32
|
-
readonly baseUrl: string;
|
|
33
|
-
readonly fetchImpl?: typeof fetch;
|
|
34
|
-
readonly snapshot: () => AgentInstanceSnapshot | null;
|
|
35
|
-
readonly execFile?: UpdateExecFile;
|
|
36
|
-
readonly onRestartRequired?: () => void;
|
|
37
|
-
readonly onLog?: (event: BridgeAutoUpdateLogEvent) => void;
|
|
38
|
-
}
|
|
39
|
-
export interface StartBridgeAutoUpdaterOptions extends RunBridgeAutoUpdateCheckOptions {
|
|
40
|
-
readonly initialDelayMs?: number;
|
|
41
|
-
readonly intervalMs?: number;
|
|
42
|
-
}
|
|
43
|
-
export interface BridgeAutoUpdater {
|
|
44
|
-
readonly stop: () => void;
|
|
45
|
-
readonly triggerNow: () => Promise<BridgeAutoUpdateResult | null>;
|
|
46
|
-
}
|
|
47
|
-
export declare function startBridgeAutoUpdater(opts: StartBridgeAutoUpdaterOptions): BridgeAutoUpdater;
|
|
48
|
-
export declare function runBridgeAutoUpdateCheck(opts: RunBridgeAutoUpdateCheckOptions): Promise<BridgeAutoUpdateResult>;
|
|
49
|
-
export declare function performBridgePackageUpdate(opts?: {
|
|
50
|
-
readonly execFile?: UpdateExecFile;
|
|
51
|
-
}): Promise<void>;
|
|
52
|
-
export declare function isSafeAutoUpdatePhase(phase: string | null): boolean;
|
|
53
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export type BridgeRuntimeType = "openclaw" | "hermes" | "mock";
|
|
2
|
-
export declare class RuntimeLocalUrlError extends Error {
|
|
3
|
-
readonly name = "RuntimeLocalUrlError";
|
|
4
|
-
}
|
|
5
|
-
export interface BridgeConfig {
|
|
6
|
-
readonly version: 1;
|
|
7
|
-
readonly baseUrl: string;
|
|
8
|
-
readonly wsUrl: string;
|
|
9
|
-
readonly agentId: string;
|
|
10
|
-
readonly agentName: string;
|
|
11
|
-
readonly suggestedName?: string;
|
|
12
|
-
readonly apiKey: string;
|
|
13
|
-
readonly claimUrl?: string;
|
|
14
|
-
readonly claimToken?: string;
|
|
15
|
-
readonly runtimeType: BridgeRuntimeType;
|
|
16
|
-
readonly runtimeLocalUrl: string;
|
|
17
|
-
readonly runtimeLocalToken?: string;
|
|
18
|
-
readonly runtimeModel?: string;
|
|
19
|
-
readonly autoDailyLimit?: number;
|
|
20
|
-
readonly autoGames?: readonly string[];
|
|
21
|
-
readonly updatedAt: string;
|
|
22
|
-
}
|
|
23
|
-
export interface RedactedBridgeConfig extends Omit<BridgeConfig, "apiKey" | "runtimeLocalToken" | "claimToken"> {
|
|
24
|
-
readonly apiKey: string;
|
|
25
|
-
readonly runtimeLocalToken?: string;
|
|
26
|
-
readonly claimToken?: string;
|
|
27
|
-
}
|
|
28
|
-
export declare function defaultRuntimeLocalUrl(runtimeType: BridgeRuntimeType): string;
|
|
29
|
-
export declare function normalizeRuntimeLocalUrl(raw: string, runtimeType: BridgeRuntimeType): string;
|
|
30
|
-
export declare function defaultRuntimeModel(runtimeType: BridgeRuntimeType): string;
|
|
31
|
-
export declare function getBridgeConfigPath(): string;
|
|
32
|
-
export declare function removeBridgeConfig(): void;
|
|
33
|
-
export declare function writeBridgeConfig(config: BridgeConfig): void;
|
|
34
|
-
export declare function readBridgeConfig(): BridgeConfig;
|
|
35
|
-
export declare function redactBridgeConfig(config: BridgeConfig): RedactedBridgeConfig;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { BridgeRuntimeProvider } from "./provider";
|
|
2
|
-
export interface HermesRuntimeProviderOptions {
|
|
3
|
-
readonly agentId: string;
|
|
4
|
-
readonly baseUrl?: string;
|
|
5
|
-
readonly token?: string;
|
|
6
|
-
readonly model?: string;
|
|
7
|
-
readonly fetchImpl?: typeof fetch;
|
|
8
|
-
}
|
|
9
|
-
export declare function createHermesRuntimeProvider(opts: HermesRuntimeProviderOptions): BridgeRuntimeProvider;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { BridgeRuntimeProvider } from "./provider";
|
|
2
|
-
export interface OpenClawRuntimeProviderOptions {
|
|
3
|
-
readonly agentId: string;
|
|
4
|
-
readonly baseUrl?: string;
|
|
5
|
-
readonly token?: string;
|
|
6
|
-
readonly model?: string;
|
|
7
|
-
readonly fetchImpl?: typeof fetch;
|
|
8
|
-
}
|
|
9
|
-
export declare function createOpenClawRuntimeProvider(opts: OpenClawRuntimeProviderOptions): BridgeRuntimeProvider;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type BridgeConfig, type BridgeRuntimeType } from "./config";
|
|
2
|
-
export interface BridgePairExchangeResponse {
|
|
3
|
-
readonly agent: {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly api_key: string;
|
|
7
|
-
readonly runtime_type: BridgeRuntimeType;
|
|
8
|
-
};
|
|
9
|
-
readonly ws_url: string;
|
|
10
|
-
readonly message?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ExchangePairingCodeOptions {
|
|
13
|
-
readonly pairingCode: string;
|
|
14
|
-
readonly baseUrl?: string;
|
|
15
|
-
readonly fetchImpl?: typeof fetch;
|
|
16
|
-
readonly now?: () => Date;
|
|
17
|
-
}
|
|
18
|
-
export declare function exchangePairingCode(opts: ExchangePairingCodeOptions): Promise<BridgeConfig>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AgentDecisionProvider } from "../agents/agent";
|
|
2
|
-
import type { GameType, LegalAction } from "../decision/types";
|
|
3
|
-
export interface BridgeRuntimeDecisionRequest {
|
|
4
|
-
readonly game: GameType;
|
|
5
|
-
readonly matchId: string;
|
|
6
|
-
readonly playerId?: string;
|
|
7
|
-
readonly legalActions: readonly LegalAction[];
|
|
8
|
-
readonly publicState: unknown;
|
|
9
|
-
readonly timeoutMs: number;
|
|
10
|
-
}
|
|
11
|
-
export interface BridgeRuntimeProvider {
|
|
12
|
-
readonly name: string;
|
|
13
|
-
decide(req: BridgeRuntimeDecisionRequest): Promise<string | LegalAction>;
|
|
14
|
-
healthCheck?(): Promise<boolean>;
|
|
15
|
-
}
|
|
16
|
-
export declare function buildBridgeDecisionProvider(runtimeProvider: BridgeRuntimeProvider): AgentDecisionProvider;
|
|
17
|
-
export declare function createMockRuntimeProvider(): BridgeRuntimeProvider;
|
|
18
|
-
export declare function createUnavailableRuntimeProvider(name: string): BridgeRuntimeProvider;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AgentInstance, type AgentInstanceSnapshot } from "../agents/agent";
|
|
2
|
-
import type { BridgeConfig } from "./config";
|
|
3
|
-
import { type BridgeRuntimeProvider } from "./provider";
|
|
4
|
-
export interface BridgeRunnerOptions {
|
|
5
|
-
readonly config: BridgeConfig;
|
|
6
|
-
readonly runtimeProvider?: BridgeRuntimeProvider;
|
|
7
|
-
readonly autoJoinGame?: "texas_holdem" | "liars_dice" | "coup";
|
|
8
|
-
readonly autoJoinMode?: string;
|
|
9
|
-
readonly autoJoinOneShot?: boolean;
|
|
10
|
-
readonly connect?: ConstructorParameters<typeof AgentInstance>[0]["connect"];
|
|
11
|
-
readonly onLog?: (event: BridgeRunnerLogEvent) => void;
|
|
12
|
-
}
|
|
13
|
-
export interface BridgeRunnerLogEvent {
|
|
14
|
-
readonly level: "info" | "warning" | "error";
|
|
15
|
-
readonly code: string;
|
|
16
|
-
readonly message: string;
|
|
17
|
-
}
|
|
18
|
-
export declare class BridgeRunner {
|
|
19
|
-
#private;
|
|
20
|
-
constructor(opts: BridgeRunnerOptions);
|
|
21
|
-
start(): Promise<AgentInstanceSnapshot>;
|
|
22
|
-
stop(): Promise<void>;
|
|
23
|
-
snapshot(): AgentInstanceSnapshot | null;
|
|
24
|
-
joinQueue(game: "texas_holdem" | "liars_dice" | "coup", mode?: string, opts?: {
|
|
25
|
-
readonly oneShot?: boolean;
|
|
26
|
-
readonly count?: number;
|
|
27
|
-
}): void;
|
|
28
|
-
leaveQueue(): void;
|
|
29
|
-
requestManualMatches(game: "texas_holdem" | "liars_dice" | "coup", mode?: string, count?: number): void;
|
|
30
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export declare const AIFIGHT_SERVICE_NAME = "aifight.service";
|
|
2
|
-
export type BridgeServicePlatform = "linux-systemd-system" | "linux-systemd-user" | "darwin-launchd-user";
|
|
3
|
-
export interface ServiceExecResult {
|
|
4
|
-
readonly stdout: string;
|
|
5
|
-
readonly stderr: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ServiceExecError extends Error {
|
|
8
|
-
readonly code?: string;
|
|
9
|
-
readonly stdout?: string;
|
|
10
|
-
readonly stderr?: string;
|
|
11
|
-
}
|
|
12
|
-
export type ServiceExecFile = (file: string, args: readonly string[]) => Promise<ServiceExecResult>;
|
|
13
|
-
export interface BridgeServiceDeps {
|
|
14
|
-
readonly execFile?: ServiceExecFile;
|
|
15
|
-
readonly platform?: NodeJS.Platform;
|
|
16
|
-
readonly uid?: number;
|
|
17
|
-
readonly username?: string;
|
|
18
|
-
readonly homeDir?: string;
|
|
19
|
-
readonly aifightExec?: string;
|
|
20
|
-
readonly nodeExec?: string;
|
|
21
|
-
readonly runtimeHome?: string;
|
|
22
|
-
readonly systemdSystemUnitPath?: string;
|
|
23
|
-
readonly systemdUserUnitPath?: string;
|
|
24
|
-
readonly launchdPlistPath?: string;
|
|
25
|
-
readonly launchdLogDir?: string;
|
|
26
|
-
}
|
|
27
|
-
export interface BridgeServiceTarget {
|
|
28
|
-
readonly platform: BridgeServicePlatform;
|
|
29
|
-
readonly unitPath: string;
|
|
30
|
-
readonly nodeExec: string;
|
|
31
|
-
readonly aifightExec: string;
|
|
32
|
-
readonly runtimeHome: string;
|
|
33
|
-
}
|
|
34
|
-
export interface BridgeServiceInstallResult extends BridgeServiceTarget {
|
|
35
|
-
readonly linger: "not_needed" | "enabled" | "failed" | "skipped";
|
|
36
|
-
readonly warning?: string;
|
|
37
|
-
}
|
|
38
|
-
export interface BridgeServiceStatus extends BridgeServiceTarget {
|
|
39
|
-
readonly installed: boolean;
|
|
40
|
-
readonly running: boolean | null;
|
|
41
|
-
readonly detail: string;
|
|
42
|
-
}
|
|
43
|
-
export declare class BridgeServiceError extends Error {
|
|
44
|
-
readonly code: string;
|
|
45
|
-
readonly hint?: string;
|
|
46
|
-
constructor(code: string, message: string, hint?: string);
|
|
47
|
-
}
|
|
48
|
-
export declare const defaultServiceExecFile: ServiceExecFile;
|
|
49
|
-
export declare function installBridgeService(deps?: BridgeServiceDeps): Promise<BridgeServiceInstallResult>;
|
|
50
|
-
export declare function uninstallBridgeService(deps?: BridgeServiceDeps): Promise<BridgeServiceTarget>;
|
|
51
|
-
export declare function startBridgeService(deps?: BridgeServiceDeps): Promise<BridgeServiceTarget>;
|
|
52
|
-
export declare function stopBridgeService(deps?: BridgeServiceDeps): Promise<BridgeServiceTarget>;
|
|
53
|
-
export declare function restartBridgeService(deps?: BridgeServiceDeps): Promise<BridgeServiceTarget>;
|
|
54
|
-
export declare function statusBridgeService(deps?: BridgeServiceDeps): Promise<BridgeServiceStatus>;
|
|
55
|
-
export declare function resolveBridgeServiceTarget(deps?: BridgeServiceDeps): Promise<BridgeServiceTarget>;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type BridgeUpdateStatus = "current" | "update_recommended" | "unsupported" | "unknown";
|
|
2
|
-
export interface BridgeVersionPolicy {
|
|
3
|
-
readonly minimumSupportedVersion: string;
|
|
4
|
-
readonly recommendedVersion: string;
|
|
5
|
-
readonly latestVersion: string;
|
|
6
|
-
readonly updateCommand: string;
|
|
7
|
-
readonly releaseNotesUrl?: string;
|
|
8
|
-
readonly policy?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface BridgeUpdateCheck {
|
|
11
|
-
readonly status: BridgeUpdateStatus;
|
|
12
|
-
readonly currentVersion: string;
|
|
13
|
-
readonly policy?: BridgeVersionPolicy;
|
|
14
|
-
readonly message: string;
|
|
15
|
-
}
|
|
16
|
-
export interface CheckBridgeUpdateOptions {
|
|
17
|
-
readonly baseUrl: string;
|
|
18
|
-
readonly currentVersion: string;
|
|
19
|
-
readonly fetchImpl?: typeof fetch;
|
|
20
|
-
readonly timeoutMs?: number;
|
|
21
|
-
}
|
|
22
|
-
export declare function checkBridgeUpdate(opts: CheckBridgeUpdateOptions): Promise<BridgeUpdateCheck>;
|
|
23
|
-
export declare function evaluatePolicy(currentVersion: string, policy: BridgeVersionPolicy): BridgeUpdateCheck;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ControlClient } from "./control-client";
|
|
2
|
-
export type AgentResolverErrorKind = "no_agents" | "ambiguous";
|
|
3
|
-
export declare class AgentResolverError extends Error {
|
|
4
|
-
readonly name = "AgentResolverError";
|
|
5
|
-
readonly kind: AgentResolverErrorKind;
|
|
6
|
-
readonly availableNames?: readonly string[];
|
|
7
|
-
constructor(kind: AgentResolverErrorKind, message: string, availableNames?: readonly string[]);
|
|
8
|
-
}
|
|
9
|
-
export interface AgentResolverOptions {
|
|
10
|
-
/** Only the .get(...) method is used — typed via Pick so tests can
|
|
11
|
-
* inject minimal mocks without implementing post/delete. */
|
|
12
|
-
readonly client: Pick<ControlClient, "get">;
|
|
13
|
-
/** When non-empty, used as-is without contacting the daemon. */
|
|
14
|
-
readonly explicitAgent?: string;
|
|
15
|
-
/** Default true. --json mode passes false so the implicit-choice log
|
|
16
|
-
* doesn't pollute machine-readable output. */
|
|
17
|
-
readonly logImplicitChoice?: boolean;
|
|
18
|
-
/** stderr sink for the implicit-choice log line. Default
|
|
19
|
-
* process.stderr.write. */
|
|
20
|
-
readonly onLog?: (message: string) => void;
|
|
21
|
-
}
|
|
22
|
-
export interface AgentResolver {
|
|
23
|
-
resolve(): Promise<string>;
|
|
24
|
-
}
|
|
25
|
-
export declare function createAgentResolver(opts: AgentResolverOptions): AgentResolver;
|
package/dist/types/cli/argv.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export type FlagValue = string | number | boolean;
|
|
2
|
-
export interface FlagSpec {
|
|
3
|
-
readonly name: string;
|
|
4
|
-
readonly type: "string" | "number" | "boolean";
|
|
5
|
-
readonly required?: boolean;
|
|
6
|
-
readonly default?: FlagValue;
|
|
7
|
-
}
|
|
8
|
-
export interface ParsedArgv {
|
|
9
|
-
readonly positional: readonly string[];
|
|
10
|
-
readonly flags: Readonly<Record<string, FlagValue>>;
|
|
11
|
-
readonly errors: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
export declare function parseArgs(argv: readonly string[], spec: readonly FlagSpec[]): ParsedArgv;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type BridgeRuntimeType } from "../../bridge/config";
|
|
2
|
-
import type { HandlerArgs, HandlerEnv } from "../shared";
|
|
3
|
-
export declare function runBridgeRegister(args: HandlerArgs, env: HandlerEnv): Promise<number>;
|
|
4
|
-
export declare function detectRuntimeTypeForApprovedSetup(env: HandlerEnv): Promise<{
|
|
5
|
-
readonly runtimeType?: BridgeRuntimeType;
|
|
6
|
-
readonly detail: string;
|
|
7
|
-
}>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type BridgeConfig } from "../../bridge/config";
|
|
2
|
-
import type { HandlerArgs, HandlerEnv } from "../shared";
|
|
3
|
-
export declare function runBridgeRun(args: HandlerArgs, env: HandlerEnv): Promise<number>;
|
|
4
|
-
export declare function runBridgeWithConfig(opts: {
|
|
5
|
-
readonly config: BridgeConfig;
|
|
6
|
-
readonly env: HandlerEnv;
|
|
7
|
-
}): Promise<number>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { HandlerArgs, HandlerEnv } from "../shared";
|
|
2
|
-
export declare function runBridgeService(args: HandlerArgs, env: HandlerEnv): Promise<number>;
|
|
3
|
-
export declare function offerBridgeServiceInstall(env: HandlerEnv, opts?: {
|
|
4
|
-
readonly approvedLocalSetup?: boolean;
|
|
5
|
-
}): Promise<"installed" | "declined" | "unavailable">;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { HandlerArgs, HandlerEnv } from "../shared";
|
|
2
|
-
import { type EnvKeyPrevious } from "./runtime-setup-state";
|
|
3
|
-
export declare function runBridgeUninstall(args: HandlerArgs, env: HandlerEnv): Promise<number>;
|
|
4
|
-
export declare function restoreEnvText(existing: string, previous: Record<string, EnvKeyPrevious>): string;
|