@punch-bot/cli 1.4.0 → 1.5.0
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/CHANGELOG.md +54 -0
- package/README.md +1 -1
- package/dist/bundle/chunks/anthropic-messages-WCANLUXE.js +6 -0
- package/dist/bundle/chunks/azure-openai-responses-46GRAI5B.js +2 -0
- package/dist/bundle/chunks/bedrock-converse-stream.js +8 -8
- package/dist/bundle/chunks/chunk-37OLNCAX.js +16 -0
- package/dist/bundle/chunks/{chunk-PYGXRV27.js → chunk-3V45WARH.js} +1 -1
- package/dist/bundle/chunks/chunk-4LBJE4YM.js +14 -0
- package/dist/bundle/chunks/{chunk-J7I2NFJ7.js → chunk-4NE64BTO.js} +1 -1
- package/dist/bundle/chunks/{chunk-S3GGRYIO.js → chunk-5AGIVGSV.js} +1 -1
- package/dist/bundle/chunks/{chunk-LP6WVVUV.js → chunk-5NXXRYVM.js} +1 -1
- package/dist/bundle/chunks/{chunk-MCGQGCDS.js → chunk-7BOHO7TR.js} +65 -63
- package/dist/bundle/chunks/{chunk-F5ZABL6Z.js → chunk-7CBJINYJ.js} +2 -2
- package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-7DDKXS2Q.js} +1 -1
- package/dist/bundle/chunks/chunk-7XECPCHN.js +2 -0
- package/dist/bundle/chunks/{chunk-OO6DJ3CL.js → chunk-A3Y7H47A.js} +1 -1
- package/dist/bundle/chunks/chunk-BRECMFDT.js +2 -0
- package/dist/bundle/chunks/chunk-HS7GCDEX.js +6 -0
- package/dist/bundle/chunks/{chunk-4L3WN2XY.js → chunk-JXWJOIH4.js} +1 -1
- package/dist/bundle/chunks/{chunk-6CYCI3EJ.js → chunk-LVVZS2NO.js} +1 -1
- package/dist/bundle/chunks/{chunk-6C5VKHGV.js → chunk-MYNHUMKE.js} +2 -2
- package/dist/bundle/chunks/{chunk-2M76JOVH.js → chunk-NJK3U3WK.js} +2 -2
- package/dist/bundle/chunks/chunk-NO2FNWW3.js +2 -0
- package/dist/bundle/chunks/chunk-PLK2QSUR.js +2 -0
- package/dist/bundle/chunks/{chunk-YGGF2ZM6.js → chunk-RFVYQ7ZX.js} +3 -3
- package/dist/bundle/chunks/{chunk-ZBURYEWF.js → chunk-TMTOQ7H7.js} +1 -1
- package/dist/bundle/chunks/{chunk-YWHGLBPB.js → chunk-UE7JCDFW.js} +1 -1
- package/dist/bundle/chunks/{chunk-22CYIUS4.js → chunk-UKVNB6C4.js} +1 -1
- package/dist/bundle/chunks/chunk-WZONBDPY.js +11 -0
- package/dist/bundle/chunks/{cli-QAQLORRY.js → cli-W5KJM7YB.js} +1 -1
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-FDCKYGTP.js +2 -0
- package/dist/bundle/chunks/{execute-2Z6BN5R3.js → execute-HXULRBCI.js} +9 -3
- package/dist/bundle/chunks/github-copilot.js +1 -1
- package/dist/bundle/chunks/google-generative-ai-2ESDEFYR.js +2 -0
- package/dist/bundle/chunks/google-vertex-YERBWL2T.js +2 -0
- package/dist/bundle/chunks/{https-proxy-agent-US7JVRJG.js → https-proxy-agent-VTEOYAYG.js} +1 -1
- package/dist/bundle/chunks/{jiti-loader-C3NU2SDH.js → jiti-loader-GL4HJFAD.js} +1 -1
- package/dist/bundle/chunks/{jiti-static-loader-E6ANQD5T.js → jiti-static-loader-2RCDI6B4.js} +1 -1
- package/dist/bundle/chunks/{lib-TEDK3E5I.js → lib-4AVRLBHM.js} +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-FYN623RH.js → llama-cpp-classify-M4KMJHPS.js} +2 -2
- package/dist/bundle/chunks/{mistral-conversations-VNJYBSRF.js → mistral-conversations-D6VQXE7C.js} +1 -1
- package/dist/bundle/chunks/{multipart-parser-SQ6GDJL7.js → multipart-parser-FMGQ7342.js} +1 -1
- package/dist/bundle/chunks/{node-TWVVAGPO.js → node-AUOGOBCN.js} +1 -1
- package/dist/bundle/chunks/{node-N5BSDOA5.js → node-KCMANYC2.js} +1 -1
- package/dist/bundle/chunks/openai-codex-responses-QSNSWBYG.js +10 -0
- package/dist/bundle/chunks/openai-completions-72VXSFHQ.js +7 -0
- package/dist/bundle/chunks/{openai-decisions-WVPMQ4JD.js → openai-decisions-PPJMQ3W4.js} +1 -1
- package/dist/bundle/chunks/openai-responses-PMTL72CY.js +4 -0
- package/dist/bundle/chunks/openrouter-images-WWPCCAPX.js +2 -0
- package/dist/bundle/chunks/pi-messages-WVCFUCBL.js +8 -0
- package/dist/bundle/chunks/{runtime-R6O72Q4R.js → runtime-R5GXO4CV.js} +1 -1
- package/dist/bundle/chunks/{src-UK77SYZE.js → src-QKGKDFSU.js} +1 -1
- package/dist/bundle/chunks/typesafe-system-one-NLWRPIRL.js +2 -0
- package/dist/bundle/chunks/virtual-modules-7Y5QW4VK.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +5 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +41 -12
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/client-identity.d.ts +8 -0
- package/dist/core/client-identity.d.ts.map +1 -0
- package/dist/core/client-identity.js +15 -0
- package/dist/core/client-identity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +1 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +2 -2
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +20 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/export-html/index.d.ts.map +1 -1
- package/dist/core/export-html/index.js +2 -0
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/template.html +1 -0
- package/dist/core/export-html/template.js +2 -1
- package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
- package/dist/core/export-html/vendor/marked.min.js +30 -29
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +3 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/model-config.d.ts +915 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +48 -24
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.js +2 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +6 -3
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/provider-composer.d.ts +2 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +7 -3
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -9
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +3 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +99 -24
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/mcp/config.d.ts.map +1 -1
- package/dist/extensions/mcp/config.js +3 -2
- package/dist/extensions/mcp/config.js.map +1 -1
- package/dist/extensions/punch/a2a-listen.d.ts.map +1 -1
- package/dist/extensions/punch/a2a-listen.js +1 -0
- package/dist/extensions/punch/a2a-listen.js.map +1 -1
- package/dist/extensions/punch/a2a.d.ts.map +1 -1
- package/dist/extensions/punch/a2a.js +12 -5
- package/dist/extensions/punch/a2a.js.map +1 -1
- package/dist/extensions/punch/auth.d.ts +4 -1
- package/dist/extensions/punch/auth.d.ts.map +1 -1
- package/dist/extensions/punch/auth.js +17 -2
- package/dist/extensions/punch/auth.js.map +1 -1
- package/dist/extensions/punch/collabs.d.ts.map +1 -1
- package/dist/extensions/punch/collabs.js +46 -40
- package/dist/extensions/punch/collabs.js.map +1 -1
- package/dist/extensions/punch/index.d.ts.map +1 -1
- package/dist/extensions/punch/index.js +2 -0
- package/dist/extensions/punch/index.js.map +1 -1
- package/dist/extensions/punch/plan-gate.d.ts +34 -0
- package/dist/extensions/punch/plan-gate.d.ts.map +1 -0
- package/dist/extensions/punch/plan-gate.js +149 -0
- package/dist/extensions/punch/plan-gate.js.map +1 -0
- package/dist/extensions/webfetch/index.d.ts.map +1 -1
- package/dist/extensions/webfetch/index.js +2 -1
- package/dist/extensions/webfetch/index.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +2 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/server/a2a/run-server.d.ts +2 -0
- package/dist/server/a2a/run-server.d.ts.map +1 -1
- package/dist/server/a2a/run-server.js +2 -0
- package/dist/server/a2a/run-server.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +3 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +3 -2
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +45 -13
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +4 -3
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/codemode.md +2 -2
- package/docs/compaction.md +3 -3
- package/docs/custom-provider.md +53 -1
- package/docs/docs.json +4 -0
- package/docs/environment-variables.md +3 -0
- package/docs/extensions.md +129 -10
- package/docs/models-configuration.md +196 -0
- package/docs/models.md +21 -5
- package/docs/settings.md +1 -1
- package/docs/windows.md +16 -2
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +5 -5
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +28 -24
- package/package.json +8 -7
- package/schemas/models.schema.json +83 -29
- package/dist/bundle/chunks/anthropic-messages-BUUFZMRE.js +0 -6
- package/dist/bundle/chunks/azure-openai-responses-WZ4GZHD2.js +0 -2
- package/dist/bundle/chunks/chunk-BYHXHV4K.js +0 -11
- package/dist/bundle/chunks/chunk-HACVPRBJ.js +0 -11
- package/dist/bundle/chunks/chunk-ITZNWD4K.js +0 -2
- package/dist/bundle/chunks/chunk-OWCYH5W2.js +0 -2
- package/dist/bundle/chunks/chunk-QQO2NSV6.js +0 -6
- package/dist/bundle/chunks/chunk-WUIPA42N.js +0 -14
- package/dist/bundle/chunks/chunk-XIX7LUWI.js +0 -2
- package/dist/bundle/chunks/cloudflare-workers-ai-system-one-UTBL2KOF.js +0 -2
- package/dist/bundle/chunks/google-generative-ai-S2KXX5PQ.js +0 -2
- package/dist/bundle/chunks/google-vertex-LQOUTFJN.js +0 -2
- package/dist/bundle/chunks/openai-codex-responses-E6BLZPYJ.js +0 -10
- package/dist/bundle/chunks/openai-completions-LUDIAWSG.js +0 -7
- package/dist/bundle/chunks/openai-responses-IOCBEIVC.js +0 -3
- package/dist/bundle/chunks/openrouter-images-YU24TD7D.js +0 -2
- package/dist/bundle/chunks/pi-messages-V27DSLVC.js +0 -8
- package/dist/bundle/chunks/typesafe-system-one-ZSK3RN4B.js +0 -2
- package/dist/bundle/chunks/virtual-modules-WOHWUS3S.js +0 -2
- package/dist/core/provider-attribution.d.ts +0 -4
- package/dist/core/provider-attribution.d.ts.map +0 -1
- package/dist/core/provider-attribution.js +0 -72
- package/dist/core/provider-attribution.js.map +0 -1
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{headersToRecord,providerHeadersToRecord}from"./chunk-UTB4DTYQ.js";import{getProviderEnvValue}from"./chunk-DRQDKNXA.js";import{parseStreamingJson}from"./chunk-PYGXRV27.js";import{AssistantMessageEventStream,appendAssistantMessageDiagnostic,createAssistantMessageDiagnostic}from"./chunk-LPXNMA2W.js";import"./chunk-4L3WN2XY.js";var PiMessagesResponseError=class extends Error{code;diagnosticDetails;constructor(message,code,diagnosticDetails){super(message),this.name="PiMessagesResponseError",this.code=code,this.diagnosticDetails=diagnosticDetails}};function parsePiMessagesErrorBody(body){try{let parsed=JSON.parse(body),error=parsed?.error;return parsed&&typeof error=="object"&&error!==null&&!Array.isArray(error)?parsed:void 0}catch{return}}function truncateDiagnosticString(value){return value.length>8192?`${value.slice(0,8192)}\u2026`:value}function formatPiMessagesResponseError(response,body,errorBody){let message=typeof errorBody?.error?.message=="string"?errorBody.error.message:void 0,code=typeof errorBody?.error?.code=="string"?errorBody.error.code:void 0,suffix=message??body,codeSuffix=code?` (${code})`:"";return`${response.status} ${response.statusText}: ${suffix}${codeSuffix}`}function createPiMessagesResponseError(model,url,response,body){let errorBody=parsePiMessagesErrorBody(body),code=typeof errorBody?.error?.code=="string"?errorBody.error.code:void 0;return new PiMessagesResponseError(formatPiMessagesResponseError(response,body,errorBody),code,{version:1,provider:model.provider,model:model.id,url:url.toString(),status:response.status,statusText:response.statusText,...errorBody?.error===void 0?{}:{error:errorBody.error},...errorBody?{}:{body:truncateDiagnosticString(body)},timestampMs:Date.now()})}function createEmptyUsage(){return{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}function appendRewriteDiagnostic(message,rewrite){rewrite&&appendAssistantMessageDiagnostic(message,{type:"pi_messages_rewrite",timestamp:Date.now(),details:{...rewrite}})}function createEventConverter(model){let partial={role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,usage:createEmptyUsage(),stopReason:"pending",timestamp:Date.now()},toolJson=new Map;return event=>{switch(event.type){case"done":return Object.assign(partial,{stopReason:event.reason,usage:event.usage,responseId:event.responseId}),event.providerThinkingLevel!==void 0&&(partial.providerThinkingLevel=event.providerThinkingLevel),appendRewriteDiagnostic(partial,event.rewrite),{type:"done",reason:event.reason,message:partial};case"error":return Object.assign(partial,{stopReason:event.reason,usage:event.usage,errorMessage:event.errorMessage,responseId:event.responseId}),event.providerThinkingLevel!==void 0&&(partial.providerThinkingLevel=event.providerThinkingLevel),appendRewriteDiagnostic(partial,event.rewrite),{type:"error",reason:event.reason,error:partial};case"start":break;case"text_start":partial.content[event.contentIndex]={type:"text",text:""};break;case"text_delta":partial.content[event.contentIndex].text+=event.delta;break;case"text_end":Object.assign(partial.content[event.contentIndex],{text:event.content,textSignature:event.contentSignature});break;case"thinking_start":partial.content[event.contentIndex]={type:"thinking",thinking:""};break;case"thinking_delta":partial.content[event.contentIndex].thinking+=event.delta;break;case"thinking_end":Object.assign(partial.content[event.contentIndex],{thinking:event.content,thinkingSignature:event.contentSignature,redacted:event.redacted});break;case"toolcall_start":partial.content[event.contentIndex]={type:"toolCall",id:event.id,name:event.toolName,arguments:{}},toolJson.set(event.contentIndex,"");break;case"toolcall_delta":{let json=`${toolJson.get(event.contentIndex)??""}${event.delta}`;toolJson.set(event.contentIndex,json),partial.content[event.contentIndex].arguments=parseStreamingJson(json);break}case"toolcall_end":return Object.assign(partial.content[event.contentIndex],event.toolCall),toolJson.delete(event.contentIndex),{type:"toolcall_end",contentIndex:event.contentIndex,toolCall:partial.content[event.contentIndex],partial}}return{...event,partial}}}async function*readPiMessagesEvents(stream2){let decoder=new TextDecoder,reader=stream2.getReader(),buffer="";try{for(;;){let{done,value}=await reader.read();buffer+=done?decoder.decode():decoder.decode(value,{stream:!0}),buffer=buffer.replace(/\r\n/g,`
|
|
3
|
-
`);let split=buffer.indexOf(`
|
|
4
|
-
|
|
5
|
-
`);for(;split!==-1;){let event=parsePiMessagesEvent(buffer.slice(0,split));event&&(yield event),buffer=buffer.slice(split+2),split=buffer.indexOf(`
|
|
6
|
-
|
|
7
|
-
`)}if(done)break}if(buffer.trim()){let event=parsePiMessagesEvent(buffer);event&&(yield event)}}finally{reader.releaseLock()}}function parsePiMessagesEvent(raw){let data=raw.split(`
|
|
8
|
-
`).find(line=>line.startsWith("data:"))?.slice(5).trim();return data&&data!=="[DONE]"?JSON.parse(data):void 0}function createErrorEvent(model,error,aborted){let reason=aborted?"aborted":"error",assistantMessage={role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,usage:createEmptyUsage(),stopReason:reason,errorMessage:error instanceof Error?error.message:String(error),timestamp:Date.now()};return!aborted&&error instanceof PiMessagesResponseError&&appendAssistantMessageDiagnostic(assistantMessage,createAssistantMessageDiagnostic("pi_messages_response_failure",error,error.diagnosticDetails)),{type:"error",reason,error:assistantMessage}}function resolveCacheRetention(cacheRetention,env){return cacheRetention||(getProviderEnvValue("PI_CACHE_RETENTION",env)==="long"?"long":void 0)}var stream=(model,context,options)=>{let eventStream=new AssistantMessageEventStream,convertEvent=createEventConverter(model);return(async()=>{try{let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key provided for provider "${model.provider}"`);let url=new URL(`${model.baseUrl.replace(/\/+$/u,"")}/messages`);options?.debug&&url.searchParams.set("debug","1");let payload={model:model.id,context,options:{temperature:options?.temperature,maxTokens:options?.maxTokens,reasoning:options?.reasoning,cacheRetention:resolveCacheRetention(options?.cacheRetention,options?.env),sessionId:options?.sessionId,toolChoice:options?.toolChoice}},nextPayload=await options?.onPayload?.(payload,model);nextPayload!==void 0&&(payload=nextPayload);let response=await(options?.fetch??globalThis.fetch)(url,{method:"POST",headers:{authorization:`Bearer ${apiKey}`,accept:"text/event-stream","content-type":"application/json",...providerHeadersToRecord(options?.headers)},body:JSON.stringify(payload),signal:options?.signal});if(await options?.onResponse?.({status:response.status,headers:headersToRecord(response.headers)},model),!response.ok){let body=await response.text();throw createPiMessagesResponseError(model,url,response,body)}if(!response.body)throw new Error(`${model.provider} response has no body`);for await(let piEvent of readPiMessagesEvents(response.body)){await options?.onProviderStreamEvent?.(piEvent,model);let event=convertEvent(piEvent);if(eventStream.push(event),event.type==="done"||event.type==="error")return}throw new Error(`${model.provider} stream ended without a terminal event`)}catch(error){eventStream.push(createErrorEvent(model,error,options?.signal?.aborted??!1))}})(),eventStream},streamSimple=(model,context,options)=>{let extra=options;return stream(model,context,{...options,reasoning:options?.reasoning,toolChoice:options?.toolChoice,debug:extra?.debug})};export{PiMessagesResponseError,stream,streamSimple};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{classifySystemOne}from"./chunk-ITZNWD4K.js";import{isRecord}from"./chunk-XIX7LUWI.js";import"./chunk-TEPMHNKQ.js";import"./chunk-PMRZO46Y.js";import"./chunk-UTB4DTYQ.js";import"./chunk-HACVPRBJ.js";import"./chunk-LPXNMA2W.js";import"./chunk-4L3WN2XY.js";var transport={api:"typesafe-system-one",label:"System One API",url:model=>new URL("systemone",`${model.baseUrl.replace(/\/+$/u,"")}/`),payload:(model,request)=>({model:model.id,...request}),output:body=>{if(!isRecord(body))throw new Error("System One API returned an unexpected response");return body}},classify=(model,context,options)=>classifySystemOne(transport,model,context,options);export{classify};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{dist_exports as dist_exports2}from"./chunk-LP6WVVUV.js";import{all_exports,compat_exports,compile_exports,dist_exports,value_exports}from"./chunk-MCGQGCDS.js";import{build_exports}from"./chunk-6C5VKHGV.js";import"./chunk-2M76JOVH.js";import"./chunk-WUIPA42N.js";import"./chunk-YWHGLBPB.js";import"./chunk-USJZMAIR.js";import"./chunk-S3GGRYIO.js";import"./chunk-QQO2NSV6.js";import"./chunk-22CYIUS4.js";import"./chunk-ZBURYEWF.js";import"./chunk-DRQDKNXA.js";import"./chunk-PYGXRV27.js";import"./chunk-HACVPRBJ.js";import"./chunk-LPXNMA2W.js";import"./chunk-4L3WN2XY.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@punch-bot/agent":dist_exports,"@punch-bot/ai":compat_exports,"@punch-bot/ai/compat":compat_exports,"@punch-bot/ai/oauth":oauth_exports,"@punch-bot/ai/providers/all":all_exports,"@punch-bot/cli":dist_exports2,"@mariozechner/pi-agent-core":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports2};export{VIRTUAL_MODULES};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Api, Model, ProviderHeaders } from "@punch-bot/ai";
|
|
2
|
-
import type { SettingsManager } from "./settings-manager.ts";
|
|
3
|
-
export declare function mergeProviderAttributionHeaders(model: Model<Api>, settingsManager: SettingsManager, sessionId: string | undefined, ...headerSources: Array<ProviderHeaders | undefined>): ProviderHeaders | undefined;
|
|
4
|
-
//# sourceMappingURL=provider-attribution.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-attribution.d.ts","sourceRoot":"","sources":["../../src/core/provider-attribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA6E7D,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,EACjB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,GAAG,aAAa,EAAE,KAAK,CAAC,eAAe,GAAG,SAAS,CAAC,GAClD,eAAe,GAAG,SAAS,CAa7B"}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { isInstallTelemetryEnabled } from "./telemetry.js";
|
|
2
|
-
const OPENROUTER_HOST = "openrouter.ai";
|
|
3
|
-
const NVIDIA_NIM_HOST = "integrate.api.nvidia.com";
|
|
4
|
-
const CLOUDFLARE_API_HOST = "api.cloudflare.com";
|
|
5
|
-
const CLOUDFLARE_AI_GATEWAY_HOST = "gateway.ai.cloudflare.com";
|
|
6
|
-
const OPENCODE_HOST = "opencode.ai";
|
|
7
|
-
function matchesHost(baseUrl, expectedHost) {
|
|
8
|
-
try {
|
|
9
|
-
return new URL(baseUrl).hostname === expectedHost;
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function isOpenRouterModel(model) {
|
|
16
|
-
return model.provider === "openrouter" || model.baseUrl.includes(OPENROUTER_HOST);
|
|
17
|
-
}
|
|
18
|
-
function isNvidiaNimModel(model) {
|
|
19
|
-
return model.provider === "nvidia" || matchesHost(model.baseUrl, NVIDIA_NIM_HOST);
|
|
20
|
-
}
|
|
21
|
-
function isCloudflareModel(model) {
|
|
22
|
-
return (model.provider === "cloudflare-workers-ai" ||
|
|
23
|
-
model.provider === "cloudflare-ai-gateway" ||
|
|
24
|
-
matchesHost(model.baseUrl, CLOUDFLARE_API_HOST) ||
|
|
25
|
-
matchesHost(model.baseUrl, CLOUDFLARE_AI_GATEWAY_HOST));
|
|
26
|
-
}
|
|
27
|
-
function getDefaultAttributionHeaders(model, settingsManager) {
|
|
28
|
-
if (!isInstallTelemetryEnabled(settingsManager)) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
if (isOpenRouterModel(model)) {
|
|
32
|
-
return {
|
|
33
|
-
"HTTP-Referer": "https://pi.dev",
|
|
34
|
-
"X-OpenRouter-Title": "pi",
|
|
35
|
-
"X-OpenRouter-Categories": "cli-agent",
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (isNvidiaNimModel(model)) {
|
|
39
|
-
return {
|
|
40
|
-
"X-BILLING-INVOKE-ORIGIN": "Pi",
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (isCloudflareModel(model)) {
|
|
44
|
-
return {
|
|
45
|
-
"User-Agent": "pi-coding-agent",
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
function getSessionHeaders(model, sessionId) {
|
|
51
|
-
if (!sessionId)
|
|
52
|
-
return undefined;
|
|
53
|
-
if (model.provider !== "opencode" &&
|
|
54
|
-
model.provider !== "opencode-go" &&
|
|
55
|
-
!matchesHost(model.baseUrl, OPENCODE_HOST)) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
return { "x-opencode-session": sessionId, "x-opencode-client": "pi" };
|
|
59
|
-
}
|
|
60
|
-
export function mergeProviderAttributionHeaders(model, settingsManager, sessionId, ...headerSources) {
|
|
61
|
-
const merged = {
|
|
62
|
-
...getSessionHeaders(model, sessionId),
|
|
63
|
-
...getDefaultAttributionHeaders(model, settingsManager),
|
|
64
|
-
};
|
|
65
|
-
for (const headers of headerSources) {
|
|
66
|
-
if (headers) {
|
|
67
|
-
Object.assign(merged, headers);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return Object.keys(merged).length > 0 ? merged : undefined;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=provider-attribution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider-attribution.js","sourceRoot":"","sources":["../../src/core/provider-attribution.ts"],"names":[],"mappings":"AAEA,O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C5D,CAAC","sourcesContent":["import type { Api, Model, ProviderHeaders } from \"@punch-bot/ai\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport { isInstallTelemetryEnabled } from \"./telemetry.ts\";\n\nconst OPENROUTER_HOST = \"openrouter.ai\";\nconst NVIDIA_NIM_HOST = \"integrate.api.nvidia.com\";\nconst CLOUDFLARE_API_HOST = \"api.cloudflare.com\";\nconst CLOUDFLARE_AI_GATEWAY_HOST = \"gateway.ai.cloudflare.com\";\nconst OPENCODE_HOST = \"opencode.ai\";\n\nfunction matchesHost(baseUrl: string, expectedHost: string): boolean {\n\ttry {\n\t\treturn new URL(baseUrl).hostname === expectedHost;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isOpenRouterModel(model: Model<Api>): boolean {\n\treturn model.provider === \"openrouter\" || model.baseUrl.includes(OPENROUTER_HOST);\n}\n\nfunction isNvidiaNimModel(model: Model<Api>): boolean {\n\treturn model.provider === \"nvidia\" || matchesHost(model.baseUrl, NVIDIA_NIM_HOST);\n}\n\nfunction isCloudflareModel(model: Model<Api>): boolean {\n\treturn (\n\t\tmodel.provider === \"cloudflare-workers-ai\" ||\n\t\tmodel.provider === \"cloudflare-ai-gateway\" ||\n\t\tmatchesHost(model.baseUrl, CLOUDFLARE_API_HOST) ||\n\t\tmatchesHost(model.baseUrl, CLOUDFLARE_AI_GATEWAY_HOST)\n\t);\n}\n\nfunction getDefaultAttributionHeaders(\n\tmodel: Model<Api>,\n\tsettingsManager: SettingsManager,\n): Record<string, string> | undefined {\n\tif (!isInstallTelemetryEnabled(settingsManager)) {\n\t\treturn undefined;\n\t}\n\n\tif (isOpenRouterModel(model)) {\n\t\treturn {\n\t\t\t\"HTTP-Referer\": \"https://pi.dev\",\n\t\t\t\"X-OpenRouter-Title\": \"pi\",\n\t\t\t\"X-OpenRouter-Categories\": \"cli-agent\",\n\t\t};\n\t}\n\n\tif (isNvidiaNimModel(model)) {\n\t\treturn {\n\t\t\t\"X-BILLING-INVOKE-ORIGIN\": \"Pi\",\n\t\t};\n\t}\n\n\tif (isCloudflareModel(model)) {\n\t\treturn {\n\t\t\t\"User-Agent\": \"pi-coding-agent\",\n\t\t};\n\t}\n\n\treturn undefined;\n}\n\nfunction getSessionHeaders(model: Model<Api>, sessionId: string | undefined): Record<string, string> | undefined {\n\tif (!sessionId) return undefined;\n\tif (\n\t\tmodel.provider !== \"opencode\" &&\n\t\tmodel.provider !== \"opencode-go\" &&\n\t\t!matchesHost(model.baseUrl, OPENCODE_HOST)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn { \"x-opencode-session\": sessionId, \"x-opencode-client\": \"pi\" };\n}\n\nexport function mergeProviderAttributionHeaders(\n\tmodel: Model<Api>,\n\tsettingsManager: SettingsManager,\n\tsessionId: string | undefined,\n\t...headerSources: Array<ProviderHeaders | undefined>\n): ProviderHeaders | undefined {\n\tconst merged: ProviderHeaders = {\n\t\t...getSessionHeaders(model, sessionId),\n\t\t...getDefaultAttributionHeaders(model, settingsManager),\n\t};\n\n\tfor (const headers of headerSources) {\n\t\tif (headers) {\n\t\t\tObject.assign(merged, headers);\n\t\t}\n\t}\n\n\treturn Object.keys(merged).length > 0 ? merged : undefined;\n}\n"]}
|