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 CHANGED
@@ -1,4 +1,4 @@
1
- # PI-useReq/pi-usereq (0.78.0)
1
+ # PI-useReq/pi-usereq (0.79.0)
2
2
 
3
3
  <p align="center">
4
4
  <img src="https://img.shields.io/badge/python-3.11%2B-3776AB?style=flat-square&logo=python&logoColor=white" alt="Python 3.11+">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-usereq",
3
- "version": "0.78.0",
3
+ "version": "0.79.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Ogekuri/PI-useReq.git"
@@ -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 both pi `formatProviderError` display shapes (`"<status>: <body>"` and `"<prefix> (<status>): <body>"`) 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.
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 statusText = unprefixedStatus ?? prefixedStatus;
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 on `agent_start`, promotes pending prompt-request metadata into the active run, 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.
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
- controller.state.activePromptRequest = controller.state.pendingPromptRequest;
873
- controller.state.pendingPromptRequest = undefined;
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 (