@oh-my-pi/pi-agent-core 18.13.3 → 18.14.1

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.
@@ -19,7 +19,6 @@ import { attach, create, Flag, ProviderHttpError } from "@oh-my-pi/pi-ai/error";
19
19
  import { getCodexAttestationHeader } from "@oh-my-pi/pi-ai/providers/openai-codex-attestation";
20
20
  import { createOpenAICodexCompactionRequestContext } from "@oh-my-pi/pi-ai/providers/openai-codex-compaction";
21
21
  import { applyCodexResponsesLiteShape } from "@oh-my-pi/pi-ai/providers/openai-codex/request-transformer";
22
- import { createOpenAICodexCompatibilityMetadata } from "@oh-my-pi/pi-ai/providers/openai-codex-responses";
23
22
  import {
24
23
  applyInferenceHeaders,
25
24
  applySessionHeader,
@@ -950,6 +949,9 @@ export async function requestOpenAiRemoteCompaction(
950
949
 
951
950
  // Codex endpoints require additional auth headers
952
951
  if (isCodexResponses) {
952
+ // Keep transport loading on the actual Codex request path, not compaction policy inspection.
953
+ const { createOpenAICodexCompatibilityMetadata } =
954
+ await import("@oh-my-pi/pi-ai/providers/openai-codex-responses");
953
955
  const accountId = getCodexAccountId(apiKey);
954
956
  if (accountId) {
955
957
  headers[OPENAI_HEADERS.ACCOUNT_ID] = accountId;
@@ -2,7 +2,6 @@ The conversation above is the complete history to summarize. The API replaces ev
2
2
 
3
3
  {{#if extraContext}}
4
4
  {{extraContext}}
5
-
6
5
  {{/if}}
7
6
  {{basePrompt}}
8
7
  {{#if customInstructions}}
@@ -10,4 +9,4 @@ The conversation above is the complete history to summarize. The API replaces ev
10
9
  Additional focus: {{customInstructions}}
11
10
  {{/if}}
12
11
 
13
- You MUST NOT call any tools while writing the summary; respond with the summary text only.
12
+ You MUST NOT call any tools while writing the summary; respond with the summary text only.
package/src/index.ts CHANGED
@@ -32,5 +32,3 @@ export * from "./tokenizer";
32
32
  export * from "./tool-arguments";
33
33
  // Types
34
34
  export * from "./types";
35
- // Yield utilities for Bun event-loop busy-wait prevention
36
- export * from "./utils/yield";
@@ -1,4 +1,4 @@
1
- import type { Message, Tool } from "@oh-my-pi/pi-ai";
1
+ import type { Context, Message, Tool } from "@oh-my-pi/pi-ai";
2
2
 
3
3
  /**
4
4
  * Last wire definition this Agent sent for each tool name, so a provider that keeps
@@ -14,11 +14,18 @@ export class SentToolDefinitions {
14
14
  }
15
15
 
16
16
  /**
17
- * Definitions for names the latest `requestControls.tools.declared` in `messages` holds
18
- * that are not in `active`; undefined when none. Names never sent by this Agent are
19
- * skipped: the provider drops them from the declaration.
17
+ * `context` with {@link Context.inactiveTools} set to the definitions for names the latest
18
+ * `requestControls.tools.declared` in its messages holds that are not in its `tools`; cleared when
19
+ * there are none or the request declares no tools. Names never sent by this Agent are skipped: the
20
+ * provider drops them from the declaration.
20
21
  */
21
- inactiveFor(messages: readonly Message[], active: readonly Tool[]): Tool[] | undefined {
22
+ withInactiveTools(context: Context): Context {
23
+ const inactiveTools = context.tools?.length ? this.#inactiveFor(context.messages, context.tools) : undefined;
24
+ if (!inactiveTools && !context.inactiveTools) return context;
25
+ return { ...context, inactiveTools };
26
+ }
27
+
28
+ #inactiveFor(messages: readonly Message[], active: readonly Tool[]): Tool[] | undefined {
22
29
  let declared: readonly string[] | undefined;
23
30
  for (let index = messages.length - 1; index >= 0; index--) {
24
31
  const message = messages[index];
package/src/telemetry.ts CHANGED
@@ -51,7 +51,6 @@ import {
51
51
  } from "@opentelemetry/api";
52
52
  import { AgentRunCollector, type AgentRunCoverage, type AgentRunSummary, type ToolStatus } from "./run-collector";
53
53
  import type { AgentTool } from "./types";
54
- import { EventLoopKeepalive } from "./utils/yield";
55
54
 
56
55
  /** Default tracer name. Override via {@link AgentTelemetryConfig.tracerName}. */
57
56
  export const DEFAULT_TRACER_NAME = "@oh-my-pi/pi-agent-core";
@@ -1840,13 +1839,6 @@ export async function instrumentedCompleteSimple<TApi extends Api>(
1840
1839
  options: SimpleStreamOptions,
1841
1840
  span: InstrumentedChatSpanOptions,
1842
1841
  ): Promise<AssistantMessage> {
1843
- // Oneshot LLM calls (handoff, compaction/branch summaries) run outside the
1844
- // agent `#runLoop`, which is where the EventLoopKeepalive normally lives.
1845
- // Without it, Bun's JSC loop stops servicing timers while parked on the
1846
- // long-lived completion promise, freezing any host spinner (e.g. the
1847
- // `/handoff` Loader) until an unrelated I/O event (a terminal resize)
1848
- // pokes the loop. Keep the loop healthy for the duration of the call.
1849
- using _keepalive = new EventLoopKeepalive();
1850
1842
  const { telemetry, parent, oneshotKind } = span;
1851
1843
  const stepNumber = span.stepNumber ?? -1;
1852
1844
  const reasoning = options.reasoning;
package/src/types.ts CHANGED
@@ -1253,6 +1253,12 @@ export interface AgentTool<
1253
1253
  */
1254
1254
  approvalCacheTargets?: (args: unknown) => readonly string[] | undefined;
1255
1255
 
1256
+ /**
1257
+ * Paths a call reads beyond its working directory, matched against restricted folders when it
1258
+ * reports no `approvalCacheTargets`. Unlike cache targets they never key a remembered grant.
1259
+ */
1260
+ approvalRestrictionPaths?: (args: unknown) => readonly string[] | undefined;
1261
+
1256
1262
  /** The main execution callback for this tool. */
1257
1263
  execute: AgentToolExecFn<TParameters, TDetails, TTheme>;
1258
1264