pi-usereq 0.78.0 → 0.79.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/README.md +1 -1
- package/package.json +1 -1
- package/src/core/debug-runtime.ts +3 -2
- package/src/core/extension-status.ts +14 -4
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -893,7 +893,7 @@ export function formatPromptDebugErrorFileName(
|
|
|
893
893
|
|
|
894
894
|
/**
|
|
895
895
|
* @brief Resolves the failing HTTP status carried by one finalized agent message.
|
|
896
|
-
* @details Extracts the leading provider error status from one `message_end` assistant message whose `stopReason` equals `error`, accepting
|
|
896
|
+
* @details Extracts the leading provider error status from one `message_end` assistant message whose `stopReason` equals `error`, accepting the pi `formatProviderError` display shapes (`"<status>: <body>"` and `"<prefix> (<status>): <body>"`) plus the raw SDK `error.message` shape (`"<status> <body>"`) surfaced unchanged by the agent run-failure path, so provider APIs whose SDK clients throw before emitting `after_provider_response` for non-2xx statuses (the OpenAI-compatible family, including `zai`) still flush the captured provider request payload through the message lifecycle channel. Runtime is O(n) in the inspected error-message prefix length. No external state is mutated.
|
|
897
897
|
* @param[in] message {unknown} Finalized agent message forwarded by one `message_end` lifecycle event.
|
|
898
898
|
* @return {number | undefined} Failing HTTP status greater than or equal to `400`, or `undefined` when the message carries no provider error status.
|
|
899
899
|
* @satisfies REQ-422, REQ-423, REQ-425
|
|
@@ -911,7 +911,8 @@ export function resolveProviderErrorFlushStatusFromMessage(message: unknown): nu
|
|
|
911
911
|
}
|
|
912
912
|
const unprefixedStatus = /^(\d{3}):/.exec(candidateMessage.errorMessage)?.[1];
|
|
913
913
|
const prefixedStatus = /^[^(]+\((\d{3})\): /.exec(candidateMessage.errorMessage)?.[1];
|
|
914
|
-
const
|
|
914
|
+
const rawSdkStatus = /^(\d{3})\s/.exec(candidateMessage.errorMessage)?.[1];
|
|
915
|
+
const statusText = unprefixedStatus ?? prefixedStatus ?? rawSdkStatus;
|
|
915
916
|
if (statusText === undefined) {
|
|
916
917
|
return undefined;
|
|
917
918
|
}
|
|
@@ -824,13 +824,13 @@ export function setPiUsereqWorkflowState(
|
|
|
824
824
|
|
|
825
825
|
/**
|
|
826
826
|
* @brief Updates mutable status state for one intercepted lifecycle hook.
|
|
827
|
-
* @details Refreshes stored context usage on every hook, resets or restores persisted elapsed counters during `session_start`, loads the active runtime sound level from persisted config during `session_start`, restores persisted prompt-command metadata when the active session matches a forked execution session, resynchronizes that metadata on later lifecycle hooks so post-switch workflow transitions performed by the initiating command handler become visible to the replacement-session runtime, resets workflow state to `idle` for documented session-start reasons, starts run timing
|
|
827
|
+
* @details Refreshes stored context usage on every hook, resets or restores persisted elapsed counters during `session_start`, loads the active runtime sound level from persisted config during `session_start`, restores persisted prompt-command metadata when the active session matches a forked execution session, resynchronizes that metadata on later lifecycle hooks so post-switch workflow transitions performed by the initiating command handler become visible to the replacement-session runtime, resets workflow state to `idle` for documented session-start reasons, starts run timing and promotes the pending prompt-request metadata into the active run on `agent_start` while preserving an already-promoted active request across pi-host agent-run restarts such as overflow compact-and-retry recovery, captures non-aborted run duration on `agent_end` or `agent_settled`, accumulates successful runtime into `Σ`, preserves in-memory prompt-command state plus process-scoped persistence across switch-triggered `session_shutdown`, tolerates stale post-replacement render contexts, synchronizes the live ticker, and re-renders the status bar with the runtime extension identity prefix when configuration is available. Runtime is O(n) in `agent_end` message count and otherwise O(1). Side effects include in-memory state mutation, interval scheduling, process-scoped persistence mutation, and footer-status updates.
|
|
828
828
|
* @param[in,out] controller {PiUsereqStatusController} Mutable status controller.
|
|
829
829
|
* @param[in] hookName {PiUsereqStatusHookName} Intercepted hook name.
|
|
830
830
|
* @param[in] event {unknown} Hook payload forwarded from the wrapper.
|
|
831
831
|
* @param[in] ctx {ExtensionContext} Active extension context.
|
|
832
832
|
* @return {void} No return value.
|
|
833
|
-
* @satisfies REQ-009, REQ-117, REQ-118, REQ-119, REQ-123, REQ-124, REQ-125, REQ-159, REQ-169, REQ-217, REQ-221, REQ-278, REQ-279, REQ-280, REQ-285
|
|
833
|
+
* @satisfies REQ-009, REQ-117, REQ-118, REQ-119, REQ-123, REQ-124, REQ-125, REQ-159, REQ-169, REQ-217, REQ-221, REQ-278, REQ-279, REQ-280, REQ-285, REQ-421
|
|
834
834
|
*/
|
|
835
835
|
export function updateExtensionStatus(
|
|
836
836
|
controller: PiUsereqStatusController,
|
|
@@ -869,8 +869,18 @@ export function updateExtensionStatus(
|
|
|
869
869
|
|
|
870
870
|
if (hookName === "agent_start") {
|
|
871
871
|
controller.state.runStartTimeMs = nowMs;
|
|
872
|
-
|
|
873
|
-
|
|
872
|
+
// Promote only when a pending request exists: the pi host restarts the agent run for
|
|
873
|
+
// overflow compact-and-retry recovery (agent_end -> session_before_compact ->
|
|
874
|
+
// session_compact -> agent_start -> retried provider request) while the originating
|
|
875
|
+
// prompt-command orchestration stays in flight. Overwriting the already-promoted
|
|
876
|
+
// active request with an undefined pending request would drop the run from controller
|
|
877
|
+
// state and process-scoped persistence, silencing every retried before_provider_request
|
|
878
|
+
// capture (REQ-421) and the later matched-success or matched-failure closure handling.
|
|
879
|
+
const pendingPromptRequest = controller.state.pendingPromptRequest;
|
|
880
|
+
if (pendingPromptRequest !== undefined) {
|
|
881
|
+
controller.state.activePromptRequest = pendingPromptRequest;
|
|
882
|
+
controller.state.pendingPromptRequest = undefined;
|
|
883
|
+
}
|
|
874
884
|
}
|
|
875
885
|
|
|
876
886
|
if (
|