@averyyy/pi-coding-agent 1.4.0-piclient.13 → 1.4.0-piclient.14
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/bundle/chunks/{chunk-YC2BMI5R.js → chunk-AFR3MIYD.js} +1 -1
- package/dist/bundle/chunks/{chunk-2SN6JEAC.js → chunk-J2L5V6ES.js} +4 -4
- package/dist/bundle/chunks/{virtual-modules-USOIN465.js → virtual-modules-N6G7JXII.js} +1 -1
- 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/pi-server-client.d.ts +5 -0
- package/dist/core/pi-server-client.d.ts.map +1 -1
- package/dist/core/pi-server-client.js +74 -0
- package/dist/core/pi-server-client.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +21 -0
- package/dist/core/sdk.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{dist_exports as dist_exports3}from"./chunk-
|
|
2
|
+
import{dist_exports as dist_exports3}from"./chunk-AFR3MIYD.js";import{all_exports,compat_exports,compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-J2L5V6ES.js";import{build_exports}from"./chunk-BRYV63PL.js";import"./chunk-3EGEEHMN.js";import{dist_exports}from"./chunk-H2UJDH5M.js";import"./chunk-PG7P2LUM.js";import"./chunk-VYYRESZJ.js";import"./chunk-H2AI7MFJ.js";import"./chunk-6QGV3IWD.js";import"./chunk-3LTMO2WY.js";import"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import"./chunk-3V45WARH.js";import{models_exports}from"./chunk-D3OXAPLU.js";import"./chunk-LPXNMA2W.js";import"./chunk-H76KZMOI.js";import"./chunk-JXWJOIH4.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,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
3
|
-
import{configureHttpDispatcher,main}from"./chunks/chunk-
|
|
3
|
+
import{configureHttpDispatcher,main}from"./chunks/chunk-J2L5V6ES.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";function setupCli(){process.title=APP_NAME,process.env.PI_CODING_AGENT="true",process.env.AI_AGENT="pi",process.emitWarning=(()=>{}),configureHttpDispatcher()}setupCli();main(process.argv.slice(2));
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
2
|
-
import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-
|
|
2
|
+
import{ShowImagesSelectorComponent,ThemeSelectorComponent}from"./chunks/chunk-AFR3MIYD.js";import{AgentSession,AgentSessionRuntime,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,SkillInvocationMessageComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,getLatestCompactionEntry,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-J2L5V6ES.js";import{DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,formatReadLineRange,formatSize,truncateHead,truncateLine,truncateTail,truncateToVisualLines}from"./chunks/chunk-BRYV63PL.js";import{ArminComponent}from"./chunks/chunk-3EGEEHMN.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme,keyHint,keyText,rawKeyHint}from"./chunks/chunk-H2UJDH5M.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-PG7P2LUM.js";import{readStoredCredential}from"./chunks/chunk-VYYRESZJ.js";import{getShellConfig}from"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,ProjectTrustStore,RpcClient,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,VERSION,VIRTUAL_MODEL_STATE_ENTRY,buildContextEntries,buildSessionContext,buildSessionProjection,calculateContextTokens,collectEntriesForBranchSummary,compact,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodemodeExtension,createCodingToolDefinitions,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createMcpExtension,createReadOnlyToolDefinitions,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createToolSearchExtension,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatReadLineRange,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,keyHint,keyText,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,parseArgs,parseFrontmatter,parseSessionEntries,parseSkillBlock,prepareBranchEntries,rawKeyHint,readStoredCredential,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,runRpcMode,serializeConversation,sessionEntryToContextMessages,shouldCompact,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
|
package/dist/bundle/rpc-entry.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
|
|
3
|
-
import{configureHttpDispatcher,main}from"./chunks/chunk-
|
|
3
|
+
import{configureHttpDispatcher,main}from"./chunks/chunk-J2L5V6ES.js";import"./chunks/chunk-BRYV63PL.js";import"./chunks/chunk-3EGEEHMN.js";import"./chunks/chunk-H2UJDH5M.js";import"./chunks/chunk-PG7P2LUM.js";import"./chunks/chunk-VYYRESZJ.js";import"./chunks/chunk-H2AI7MFJ.js";import"./chunks/chunk-6QGV3IWD.js";import{APP_NAME}from"./chunks/chunk-3LTMO2WY.js";import"./chunks/chunk-USJZMAIR.js";import"./chunks/chunk-5AGIVGSV.js";import"./chunks/chunk-UKVNB6C4.js";import"./chunks/chunk-TMTOQ7H7.js";import"./chunks/chunk-7DDKXS2Q.js";import"./chunks/chunk-3V45WARH.js";import"./chunks/chunk-D3OXAPLU.js";import"./chunks/chunk-LPXNMA2W.js";import"./chunks/chunk-H76KZMOI.js";import"./chunks/chunk-JXWJOIH4.js";process.title=`${APP_NAME}-rpc`;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT="pi";process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
|
|
@@ -26,6 +26,11 @@ export interface PiServerHistorySnapshot {
|
|
|
26
26
|
messages: Message[];
|
|
27
27
|
}
|
|
28
28
|
export interface PiServerStreamOptions extends SimpleStreamOptions {
|
|
29
|
+
/** Monotonic start of run preparation or the last top-level tool completion; kept client-local. */
|
|
30
|
+
clientTiming?: {
|
|
31
|
+
startedAt: number;
|
|
32
|
+
boundary: "run_accepted" | "tool_end" | "message_start";
|
|
33
|
+
};
|
|
29
34
|
requireCacheRetention?: boolean;
|
|
30
35
|
onCacheRetentionResolved?: (retention: CacheRetention) => void | Promise<void>;
|
|
31
36
|
requestKind?: "api" | "simple" | "deferred";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-server-client.d.ts","sourceRoot":"","sources":["../../src/core/pi-server-client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,4BAA4B,EAC5B,mBAAmB,EAEnB,gBAAgB,EAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,KAAK,QAAQ,EACb,KAAK,eAAe,EAGpB,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,OAAO,EAEZ,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,cA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AAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAetC,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,OAAO,CAAC;QAAC,cAAc,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAC7E;AAED,wBAAsB,mBAAmB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAGvG;AAED,wBAAsB,sBAAsB,CAC3C,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,EAC3B,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,eAAe,CAAC,CAqB1B;AAED,wBAAsB,gBAAgB,CACrC,KAAK,EAAE,eAAe,CAAC,aAAa,CAAC,EACrC,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAqB3B"}
|
|
@@ -761,6 +761,9 @@ export async function compactPiServer(model, context, options) {
|
|
|
761
761
|
}
|
|
762
762
|
}
|
|
763
763
|
export async function streamPiServer(model, context, options) {
|
|
764
|
+
const observeTiming = process.env.PI_TIMING === "1";
|
|
765
|
+
const startedAt = observeTiming ? performance.now() : 0;
|
|
766
|
+
const clientTiming = options?.clientTiming;
|
|
764
767
|
assertNoCustomPiServerFetch(options);
|
|
765
768
|
assertNoCustomPiServerFetch(options?.apiOptions);
|
|
766
769
|
const sessionId = options?.sessionId ?? randomUUID();
|
|
@@ -791,6 +794,41 @@ export async function streamPiServer(model, context, options) {
|
|
|
791
794
|
let observerFailed = false;
|
|
792
795
|
let callbackFailed = false;
|
|
793
796
|
let cacheRetention;
|
|
797
|
+
let sessionInitMs;
|
|
798
|
+
let requestStartedAt = startedAt;
|
|
799
|
+
let requestToHeadersMs;
|
|
800
|
+
let firstContentMs;
|
|
801
|
+
let timingPrinted = false;
|
|
802
|
+
let serverTiming;
|
|
803
|
+
const recordTiming = (message) => {
|
|
804
|
+
if (!observeTiming)
|
|
805
|
+
return;
|
|
806
|
+
const details = {
|
|
807
|
+
runId,
|
|
808
|
+
provider: model.provider,
|
|
809
|
+
model: model.id,
|
|
810
|
+
...(clientTiming
|
|
811
|
+
? {
|
|
812
|
+
clientPrepareMs: Math.round(startedAt - clientTiming.startedAt),
|
|
813
|
+
clientPrepareFrom: clientTiming.boundary,
|
|
814
|
+
}
|
|
815
|
+
: {}),
|
|
816
|
+
...(sessionInitMs === undefined ? {} : { sessionInitMs }),
|
|
817
|
+
...(requestToHeadersMs === undefined ? {} : { requestToHeadersMs }),
|
|
818
|
+
...(firstContentMs === undefined ? {} : { firstContentMs }),
|
|
819
|
+
...(serverTiming ? { server: serverTiming } : {}),
|
|
820
|
+
};
|
|
821
|
+
if (!timingPrinted) {
|
|
822
|
+
timingPrinted = true;
|
|
823
|
+
console.error(`[pi-server timing] ${JSON.stringify(details)}`);
|
|
824
|
+
}
|
|
825
|
+
if (message) {
|
|
826
|
+
message.diagnostics = [
|
|
827
|
+
...(message.diagnostics ?? []),
|
|
828
|
+
{ type: "pi_server_timing", timestamp: Date.now(), details },
|
|
829
|
+
];
|
|
830
|
+
}
|
|
831
|
+
};
|
|
794
832
|
const requireCacheRetention = options?.requireCacheRetention || options?.onCacheRetentionResolved !== undefined;
|
|
795
833
|
const applyCachePolicy = async (retention) => {
|
|
796
834
|
try {
|
|
@@ -813,9 +851,12 @@ export async function streamPiServer(model, context, options) {
|
|
|
813
851
|
try {
|
|
814
852
|
const request = createPiServerRequest(options?.signal);
|
|
815
853
|
await ensureSessionInit(sessionId, context, request);
|
|
854
|
+
if (observeTiming)
|
|
855
|
+
sessionInitMs = Math.round(performance.now() - startedAt);
|
|
816
856
|
const makeBody = () => ({
|
|
817
857
|
sessionId,
|
|
818
858
|
runId,
|
|
859
|
+
...(observeTiming ? { observeTiming: true } : {}),
|
|
819
860
|
model,
|
|
820
861
|
options: options?.requestKind === "api" || options?.requestKind === "deferred"
|
|
821
862
|
? serializeApiOptions(options.apiOptions ?? {})
|
|
@@ -830,13 +871,21 @@ export async function streamPiServer(model, context, options) {
|
|
|
830
871
|
],
|
|
831
872
|
});
|
|
832
873
|
phase = "provider_stream";
|
|
874
|
+
if (observeTiming)
|
|
875
|
+
requestStartedAt = performance.now();
|
|
833
876
|
let response = await request.postJson("/api/stream", makeBody());
|
|
877
|
+
if (observeTiming)
|
|
878
|
+
requestToHeadersMs = Math.round(performance.now() - requestStartedAt);
|
|
834
879
|
if (!response.ok) {
|
|
835
880
|
let failure = await readPiServerFailure(response);
|
|
836
881
|
if (!options?.signal?.aborted && isRecoverableMissingServerState(response, failure.code)) {
|
|
837
882
|
resetSessionTracking(sessionId);
|
|
838
883
|
await ensureSessionInit(sessionId, context, request);
|
|
884
|
+
if (observeTiming)
|
|
885
|
+
requestStartedAt = performance.now();
|
|
839
886
|
response = await request.postJson("/api/stream", makeBody());
|
|
887
|
+
if (observeTiming)
|
|
888
|
+
requestToHeadersMs = Math.round(performance.now() - requestStartedAt);
|
|
840
889
|
if (response.ok) {
|
|
841
890
|
failure = { details: "", code: undefined };
|
|
842
891
|
}
|
|
@@ -856,6 +905,11 @@ export async function streamPiServer(model, context, options) {
|
|
|
856
905
|
let terminalReceived = false;
|
|
857
906
|
const consumeEvents = async (events) => {
|
|
858
907
|
for (const serverEvent of events) {
|
|
908
|
+
if (serverEvent.event === "timing") {
|
|
909
|
+
if (observeTiming)
|
|
910
|
+
serverTiming = parseServerSentEventData(serverEvent, "pi-server timing");
|
|
911
|
+
continue;
|
|
912
|
+
}
|
|
859
913
|
if (serverEvent.event === "cache_policy") {
|
|
860
914
|
try {
|
|
861
915
|
const policy = parseServerSentEventData(serverEvent, "pi-server cache policy");
|
|
@@ -895,6 +949,23 @@ export async function streamPiServer(model, context, options) {
|
|
|
895
949
|
const event = processProxyEvent(proxyEvent, partial);
|
|
896
950
|
if (!event)
|
|
897
951
|
continue;
|
|
952
|
+
const finalMessage = event.type === "done" ? event.message : event.type === "error" ? event.error : undefined;
|
|
953
|
+
if (observeTiming &&
|
|
954
|
+
firstContentMs === undefined &&
|
|
955
|
+
(((event.type === "text_delta" ||
|
|
956
|
+
event.type === "thinking_delta" ||
|
|
957
|
+
event.type === "toolcall_delta") &&
|
|
958
|
+
event.delta.length > 0) ||
|
|
959
|
+
finalMessage?.content.some((block) => block.type === "text"
|
|
960
|
+
? block.text.length > 0
|
|
961
|
+
: block.type === "thinking"
|
|
962
|
+
? block.thinking.length > 0
|
|
963
|
+
: block.name.length > 0))) {
|
|
964
|
+
firstContentMs = Math.round(performance.now() - requestStartedAt);
|
|
965
|
+
recordTiming();
|
|
966
|
+
}
|
|
967
|
+
if (finalMessage)
|
|
968
|
+
recordTiming(finalMessage);
|
|
898
969
|
if (event.type === "done" || event.type === "error")
|
|
899
970
|
terminalReceived = true;
|
|
900
971
|
stream.push(event);
|
|
@@ -940,6 +1011,7 @@ export async function streamPiServer(model, context, options) {
|
|
|
940
1011
|
await applyCachePolicy(recoveredRun?.cacheRetention);
|
|
941
1012
|
}
|
|
942
1013
|
if (recoveredRun?.status === "completed" && recoveredRun.message) {
|
|
1014
|
+
recordTiming(recoveredRun.message);
|
|
943
1015
|
switch (recoveredRun.message.stopReason) {
|
|
944
1016
|
case "stop":
|
|
945
1017
|
case "length":
|
|
@@ -963,6 +1035,7 @@ export async function streamPiServer(model, context, options) {
|
|
|
963
1035
|
}
|
|
964
1036
|
if (recoveredRun?.status === "failed" && recoveredRun.errorMessage) {
|
|
965
1037
|
if (recoveredRun.message) {
|
|
1038
|
+
recordTiming(recoveredRun.message);
|
|
966
1039
|
stream.push({ type: "error", reason: "error", error: recoveredRun.message });
|
|
967
1040
|
stream.end();
|
|
968
1041
|
return;
|
|
@@ -1004,6 +1077,7 @@ export async function streamPiServer(model, context, options) {
|
|
|
1004
1077
|
},
|
|
1005
1078
|
},
|
|
1006
1079
|
];
|
|
1080
|
+
recordTiming(partial);
|
|
1007
1081
|
stream.push({
|
|
1008
1082
|
type: "error",
|
|
1009
1083
|
reason,
|