@linxiraos/pi-agent-core 1.1.8 → 1.1.9
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 +4 -6
- package/package.json +73 -79
- package/src/agent-loop.ts +80 -15
- package/src/compaction/compaction-v2-streaming.ts +43 -32
- package/src/compaction/compaction.ts +88 -17
- package/src/compaction/openai.ts +3 -0
- package/src/telemetry.ts +2 -2
- package/src/types.ts +34 -7
- package/THIRD-PARTY-NOTICES.txt +0 -22909
- package/dist/types/agent-loop.d.ts +0 -150
- package/dist/types/agent.d.ts +0 -472
- package/dist/types/append-only-context.d.ts +0 -131
- package/dist/types/compaction/branch-summarization.d.ts +0 -102
- package/dist/types/compaction/compaction-v2-streaming.d.ts +0 -85
- package/dist/types/compaction/compaction.d.ts +0 -341
- package/dist/types/compaction/entries.d.ts +0 -120
- package/dist/types/compaction/errors.d.ts +0 -38
- package/dist/types/compaction/index.d.ts +0 -14
- package/dist/types/compaction/message-cache.d.ts +0 -25
- package/dist/types/compaction/messages.d.ts +0 -103
- package/dist/types/compaction/openai.d.ts +0 -118
- package/dist/types/compaction/pruning.d.ts +0 -106
- package/dist/types/compaction/shake.d.ts +0 -104
- package/dist/types/compaction/tool-protection.d.ts +0 -19
- package/dist/types/compaction/transcript-tokens.d.ts +0 -76
- package/dist/types/compaction/utils.d.ts +0 -63
- package/dist/types/compaction.d.ts +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/pause.d.ts +0 -46
- package/dist/types/proxy.d.ts +0 -91
- package/dist/types/replay-policy.d.ts +0 -5
- package/dist/types/run-collector.d.ts +0 -196
- package/dist/types/telemetry.d.ts +0 -625
- package/dist/types/thinking.d.ts +0 -18
- package/dist/types/tokenizer.d.ts +0 -78
- package/dist/types/types.d.ts +0 -786
- package/dist/types/utils/yield.d.ts +0 -71
package/src/types.ts
CHANGED
|
@@ -245,8 +245,10 @@ export interface AgentLoopConfig extends SimpleStreamOptions {
|
|
|
245
245
|
/**
|
|
246
246
|
* Peeks whether steering messages are queued, without consuming them.
|
|
247
247
|
*
|
|
248
|
-
*
|
|
249
|
-
* whether to
|
|
248
|
+
* Polled while a tool batch runs (unless interruptMode is "wait") to decide
|
|
249
|
+
* whether to abort in-flight and skip not-yet-started *interruptible* waits;
|
|
250
|
+
* every other already-emitted call still executes and the message injects
|
|
251
|
+
* at the batch boundary. The queue keeps
|
|
250
252
|
* owning its messages until the loop reaches the next injection boundary and
|
|
251
253
|
* dequeues via {@link getSteeringMessages} — so callers can still cancel or
|
|
252
254
|
* restore queued messages while in-flight tools settle, and an external
|
|
@@ -758,11 +760,34 @@ export type AgentToolExecFn<TParameters extends TSchema = TSchema, TDetails = an
|
|
|
758
760
|
context?: AgentToolContext,
|
|
759
761
|
) => Promise<AgentToolResult<TDetails, TParameters>>;
|
|
760
762
|
|
|
763
|
+
/** Live receiver for a tool call's streamed arguments (see AgentTool.openArgStream). */
|
|
764
|
+
export interface AgentToolArgStream {
|
|
765
|
+
/** Raw wire fragment of the arguments (JSON text, or verbatim payload for custom-format tools). */
|
|
766
|
+
push(delta: string): void;
|
|
767
|
+
/** Arguments are complete; `args` is the final parsed object the loop will pass to `execute`. */
|
|
768
|
+
end(args: unknown): void;
|
|
769
|
+
/** The call will never execute (stream error, abort, blocked). Release resources. */
|
|
770
|
+
cancel(): void;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
export interface AgentToolArgStreamInit {
|
|
774
|
+
toolCallId: string;
|
|
775
|
+
toolName: string;
|
|
776
|
+
/** Wire-level name for custom-format tools; undefined for JSON function tools. */
|
|
777
|
+
customWireName?: string;
|
|
778
|
+
/** Push a serializable projection of the in-flight call (e.g. diff previews); surfaces as `tool_stream_update`. */
|
|
779
|
+
emit(update: unknown): void;
|
|
780
|
+
}
|
|
781
|
+
|
|
761
782
|
// AgentTool extends Tool but adds the execute function
|
|
762
783
|
export interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any, TTheme = unknown>
|
|
763
784
|
extends Tool<TParameters> {
|
|
764
785
|
// A human-readable label for the tool to be displayed in UI
|
|
765
786
|
label: string;
|
|
787
|
+
/**
|
|
788
|
+
* Called at `toolcall_start`, before any argument delta. Return `undefined` to opt out.
|
|
789
|
+
*/
|
|
790
|
+
openArgStream?: (init: AgentToolArgStreamInit) => AgentToolArgStream | undefined;
|
|
766
791
|
/** If true, tool is excluded unless explicitly listed in --tools or agent's tools field */
|
|
767
792
|
hidden?: boolean;
|
|
768
793
|
/** If true, tool can stage a pending action that requires explicit resolution via the resolve tool. */
|
|
@@ -781,14 +806,15 @@ export interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any
|
|
|
781
806
|
/** If true, argument validation errors are non-fatal: raw args are passed to execute() instead of returning an error to the LLM. */
|
|
782
807
|
lenientArgValidation?: boolean;
|
|
783
808
|
/**
|
|
784
|
-
* Whether the agent loop may abort this tool mid-execution
|
|
785
|
-
*
|
|
786
|
-
* pre-validation arguments.
|
|
809
|
+
* Whether the agent loop may abort this tool mid-execution — or skip it
|
|
810
|
+
* before it starts — to deliver a queued steering message. A function
|
|
811
|
+
* resolves this per call from the raw, pre-validation arguments.
|
|
787
812
|
*
|
|
788
813
|
* Enable only for calls that purely *wait* and observe their abort signal
|
|
789
814
|
* cleanly (e.g. `job` poll), so the abort surfaces the tool's current
|
|
790
|
-
* snapshot rather than corrupting a side effect.
|
|
791
|
-
*
|
|
815
|
+
* snapshot rather than corrupting a side effect. Every other call runs to
|
|
816
|
+
* completion even when steering is queued; the message lands at the next
|
|
817
|
+
* batch boundary. Honored only when `interruptMode` is "immediate".
|
|
792
818
|
*/
|
|
793
819
|
interruptible?: boolean | ((args: Partial<Static<TParameters>>) => boolean);
|
|
794
820
|
/**
|
|
@@ -882,4 +908,5 @@ export type AgentEvent =
|
|
|
882
908
|
// Tool execution lifecycle
|
|
883
909
|
| { type: "tool_execution_start"; toolCallId: string; toolName: string; args: any; intent?: string }
|
|
884
910
|
| { type: "tool_execution_update"; toolCallId: string; toolName: string; args: any; partialResult: any }
|
|
911
|
+
| { type: "tool_stream_update"; toolCallId: string; toolName: string; update: unknown }
|
|
885
912
|
| { type: "tool_execution_end"; toolCallId: string; toolName: string; result: any; isError?: boolean };
|