@linxiraos/pi-agent-core 1.1.15 → 1.1.17
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 +194 -2
- package/THIRD-PARTY-NOTICES.txt +54 -25
- package/dist/types/agent.d.ts +5 -2
- package/dist/types/append-only-context.d.ts +0 -4
- package/dist/types/compaction/compaction.d.ts +26 -17
- package/dist/types/compaction/entries.d.ts +2 -0
- package/dist/types/compaction/openai.d.ts +2 -1
- package/dist/types/thinking.d.ts +1 -1
- package/dist/types/types.d.ts +9 -1
- package/package.json +10 -10
- package/src/agent-loop.ts +127 -10
- package/src/agent.ts +142 -17
- package/src/append-only-context.ts +122 -1
- package/src/compaction/compaction-v2-streaming.ts +2 -1
- package/src/compaction/compaction.ts +98 -66
- package/src/compaction/entries.ts +2 -0
- package/src/compaction/openai.ts +10 -3
- package/src/proxy.ts +49 -4
- package/src/telemetry.ts +1 -0
- package/src/thinking.ts +1 -1
- package/src/tokenizer.ts +1 -0
- package/src/types.ts +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,199 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
-
## [1.1.
|
|
5
|
+
## [1.1.16] - 2026-09-19
|
|
6
6
|
|
|
7
|
-
- 上游 v18.
|
|
7
|
+
- 上游 v18.2.5 同步:工具 schema 注入 stamp 记忆化、代理工具调用流式 JSON 解析。
|
|
8
8
|
|
|
9
|
+
## [9.2.2] - 2026-01-31
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Added toolChoice option to AgentPromptOptions for controlling tool selection
|
|
14
|
+
|
|
15
|
+
## [8.2.0] - 2026-01-24
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Updated TypeScript configuration for better publish-time configuration handling with tsconfig.publish.json
|
|
20
|
+
|
|
21
|
+
## [8.0.0] - 2026-01-23
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- Added `nonAbortable` option to tools to ignore abort signals during execution
|
|
26
|
+
|
|
27
|
+
## [6.8.0] - 2026-01-20
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- Updated proxy stream processing to use utility function for reading lines
|
|
32
|
+
|
|
33
|
+
## [6.2.0] - 2026-01-19
|
|
34
|
+
|
|
35
|
+
### Added
|
|
36
|
+
|
|
37
|
+
- Enhanced getToolContext to receive tool call batch information including batchId, index, total count, and tool call details
|
|
38
|
+
|
|
39
|
+
## [5.6.7] - 2026-01-18
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
|
|
43
|
+
- Added proper tool result messages for tool calls that are aborted or error out
|
|
44
|
+
- Ensured tool_use/tool_result pairing is maintained when tool execution fails
|
|
45
|
+
|
|
46
|
+
## [4.6.0] - 2026-01-12
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Modified assistant message handling to split messages around tool results for improved readability when using Cursor tools
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- Fixed tool result ordering in Cursor mode by buffering results and emitting them at the correct position within assistant messages
|
|
55
|
+
|
|
56
|
+
## [4.3.0] - 2026-01-11
|
|
57
|
+
|
|
58
|
+
### Added
|
|
59
|
+
|
|
60
|
+
- Added `cursorExecHandlers` and `cursorOnToolResult` options for local tool execution with cursor-based streaming
|
|
61
|
+
- Added `emitExternalEvent` method to allow external event injection into the agent state
|
|
62
|
+
|
|
63
|
+
## [4.0.0] - 2026-01-10
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
|
|
67
|
+
- Added `popLastSteer()` and `popLastFollowUp()` methods to remove and return the last queued message (LIFO) for dequeue operations
|
|
68
|
+
- `thinkingBudgets` option on `Agent` and `AgentOptions` to customize token budgets per thinking level
|
|
69
|
+
- `sessionId` option on `Agent` to forward session identifiers to LLM providers for session-based caching
|
|
70
|
+
|
|
71
|
+
### Fixed
|
|
72
|
+
|
|
73
|
+
- `minimal` thinking level now maps to `minimal` reasoning effort instead of being treated as `low`
|
|
74
|
+
|
|
75
|
+
## [3.33.0] - 2026-01-08
|
|
76
|
+
|
|
77
|
+
### Fixed
|
|
78
|
+
|
|
79
|
+
- Ensured aborted assistant responses always include an error message for callers.
|
|
80
|
+
- Filtered thinking blocks from Cerebras request context to keep multi-turn prompts compatible.
|
|
81
|
+
|
|
82
|
+
## [3.21.0] - 2026-01-06
|
|
83
|
+
|
|
84
|
+
### Changed
|
|
85
|
+
|
|
86
|
+
- Switched from local `@linxiraos/pi-ai` to upstream `@mariozechner/pi-ai` package
|
|
87
|
+
|
|
88
|
+
### Added
|
|
89
|
+
|
|
90
|
+
- Added `sessionId` option for provider caching (e.g., OpenAI Codex session-based prompt caching)
|
|
91
|
+
- Added `sessionId` getter/setter on Agent class for runtime session switching
|
|
92
|
+
|
|
93
|
+
## [3.20.0] - 2026-01-06
|
|
94
|
+
|
|
95
|
+
### Breaking Changes
|
|
96
|
+
|
|
97
|
+
- Replaced `queueMessage`/`queueMode` with steering + follow-up queues: use `steer`, `setSteeringMode`, and `getSteeringMode` for mid-run interruptions, and `followUp`, `setFollowUpMode`, and `getFollowUpMode` for post-turn messages
|
|
98
|
+
- Agent loop callbacks now use `getSteeringMessages` and `getFollowUpMessages` instead of `getQueuedMessages`
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
|
|
102
|
+
- Added follow-up message queue support so new user messages can continue a run after the agent would otherwise stop
|
|
103
|
+
- Added `RenderResultOptions.spinnerFrame` for animated tool-result rendering
|
|
104
|
+
|
|
105
|
+
### Changed
|
|
106
|
+
|
|
107
|
+
- `prompt()` and `continue()` now throw when the agent is already streaming; use steering or follow-up queues instead
|
|
108
|
+
|
|
109
|
+
## [3.4.1337] - 2026-01-03
|
|
110
|
+
|
|
111
|
+
### Added
|
|
112
|
+
|
|
113
|
+
- Added `popMessage()` method to Agent class for removing and retrieving the last message
|
|
114
|
+
- Added abort signal checks during response streaming for faster interruption handling
|
|
115
|
+
|
|
116
|
+
### Fixed
|
|
117
|
+
|
|
118
|
+
- Fixed abort handling to properly return aborted message state when stream is interrupted mid-response
|
|
119
|
+
|
|
120
|
+
## [1.341.0] - 2026-01-03
|
|
121
|
+
|
|
122
|
+
### Added
|
|
123
|
+
|
|
124
|
+
- Added `interruptMode` option to control when queued messages interrupt tool execution.
|
|
125
|
+
- Implemented "immediate" mode (default) to check queue after each tool and interrupt remaining tools.
|
|
126
|
+
- Implemented "wait" mode to defer queue processing until the entire turn completes.
|
|
127
|
+
- Added getter and setter methods for `interruptMode` on Agent class.
|
|
128
|
+
|
|
129
|
+
## [1.337.1] - 2026-01-02
|
|
130
|
+
|
|
131
|
+
### Changed
|
|
132
|
+
|
|
133
|
+
- Forked to @oh-my-pi scope with unified versioning across all packages
|
|
134
|
+
|
|
135
|
+
## [1.337.0] - 2026-01-02
|
|
136
|
+
|
|
137
|
+
Initial release under @oh-my-pi scope. See previous releases at [badlogic/pi-mono](https://github.com/badlogic/pi-mono).
|
|
138
|
+
|
|
139
|
+
## [0.38.0] - 2026-01-08
|
|
140
|
+
|
|
141
|
+
### Added
|
|
142
|
+
|
|
143
|
+
- `thinkingBudgets` option on `Agent` and `AgentOptions` to customize token budgets per thinking level ([#529](https://github.com/badlogic/pi-mono/pull/529) by [@melihmucuk](https://github.com/melihmucuk))
|
|
144
|
+
|
|
145
|
+
## [0.37.3] - 2026-01-06
|
|
146
|
+
|
|
147
|
+
### Added
|
|
148
|
+
|
|
149
|
+
- `sessionId` option on `Agent` to forward session identifiers to LLM providers for session-based caching.
|
|
150
|
+
|
|
151
|
+
## [0.37.0] - 2026-01-05
|
|
152
|
+
|
|
153
|
+
### Fixed
|
|
154
|
+
|
|
155
|
+
- `minimal` thinking level now maps to `minimal` reasoning effort instead of being treated as `low`.
|
|
156
|
+
|
|
157
|
+
## [0.32.0] - 2026-01-03
|
|
158
|
+
|
|
159
|
+
### Breaking Changes
|
|
160
|
+
|
|
161
|
+
- **Queue API replaced with steer/followUp**: The `queueMessage()` method has been split into two methods with different delivery semantics ([#403](https://github.com/badlogic/pi-mono/issues/403)):
|
|
162
|
+
- `steer(msg)`: Interrupts the agent mid-run. Delivered after current tool execution, skips remaining tools.
|
|
163
|
+
- `followUp(msg)`: Waits until the agent finishes. Delivered only when there are no more tool calls or steering messages.
|
|
164
|
+
- **Queue mode renamed**: `queueMode` option renamed to `steeringMode`. Added new `followUpMode` option. Both control whether messages are delivered one-at-a-time or all at once.
|
|
165
|
+
- **AgentLoopConfig callbacks renamed**: `getQueuedMessages` split into `getSteeringMessages` and `getFollowUpMessages`.
|
|
166
|
+
- **Agent methods renamed**:
|
|
167
|
+
- `queueMessage()` → `steer()` and `followUp()`
|
|
168
|
+
- `clearMessageQueue()` → `clearSteeringQueue()`, `clearFollowUpQueue()`, `clearAllQueues()`
|
|
169
|
+
- `setQueueMode()`/`getQueueMode()` → `setSteeringMode()`/`getSteeringMode()` and `setFollowUpMode()`/`getFollowUpMode()`
|
|
170
|
+
|
|
171
|
+
### Fixed
|
|
172
|
+
|
|
173
|
+
- `prompt()` and `continue()` now throw if called while the agent is already streaming, preventing race conditions and corrupted state. Use `steer()` or `followUp()` to queue messages during streaming, or `await` the previous call.
|
|
174
|
+
|
|
175
|
+
## [0.31.0] - 2026-01-02
|
|
176
|
+
|
|
177
|
+
### Breaking Changes
|
|
178
|
+
|
|
179
|
+
- **Transport abstraction removed**: `ProviderTransport`, `AppTransport`, and `AgentTransport` interface have been removed. Use the `streamFn` option directly for custom streaming implementations.
|
|
180
|
+
- **Agent options renamed**:
|
|
181
|
+
- `transport` → removed (use `streamFn` instead)
|
|
182
|
+
- `messageTransformer` → `convertToLlm`
|
|
183
|
+
- `preprocessor` → `transformContext`
|
|
184
|
+
- **`AppMessage` renamed to `AgentMessage`**: All references to `AppMessage` have been renamed to `AgentMessage` for consistency.
|
|
185
|
+
- **`CustomMessages` renamed to `CustomAgentMessages`**: The declaration merging interface has been renamed.
|
|
186
|
+
- **`UserMessageWithAttachments` and `Attachment` types removed**: Attachment handling is now the responsibility of the `convertToLlm` function.
|
|
187
|
+
- **Agent loop moved from `@linxiraos/pi-ai`**: The `agentLoop`, `agentLoopContinue`, and related types have moved to this package. Import from `@linxiraos/pi-agent` instead.
|
|
188
|
+
|
|
189
|
+
### Added
|
|
190
|
+
|
|
191
|
+
- `streamFn` option on `Agent` for custom stream implementations. Default uses `streamSimple` from pi-ai.
|
|
192
|
+
- `streamProxy()` utility function for browser apps that need to proxy LLM calls through a backend server. Replaces the removed `AppTransport`.
|
|
193
|
+
- `getApiKey` option for dynamic API key resolution (useful for expiring OAuth tokens like GitHub Copilot).
|
|
194
|
+
- `agentLoop()` and `agentLoopContinue()` low-level functions for running the agent loop without the `Agent` class wrapper.
|
|
195
|
+
- New exported types: `AgentLoopConfig`, `AgentContext`, `AgentTool`, `AgentToolResult`, `AgentToolUpdateCallback`, `StreamFn`.
|
|
196
|
+
|
|
197
|
+
### Changed
|
|
198
|
+
|
|
199
|
+
- `Agent` constructor now has all options optional (empty options use defaults).
|
|
200
|
+
- `queueMessage()` is now synchronous (no longer returns a Promise).
|
package/THIRD-PARTY-NOTICES.txt
CHANGED
|
@@ -10843,7 +10843,7 @@ RUST RUNTIME DEPENDENCY LICENSES
|
|
|
10843
10843
|
|
|
10844
10844
|
Generated from Cargo.lock by cargo-about 0.8.2 in locked, offline, workspace, all-feature, all-target mode, then restricted using cargo metadata to normal and build edges reachable from the workspace (development-only edges are excluded). cargo-deny independently evaluates the complete all-target graph.
|
|
10845
10845
|
|
|
10846
|
-
Native Opus (
|
|
10846
|
+
Native Opus (opus/opusic-sys) and PCRE2 (pcre2/pcre2-sys) are covered by the exact crate license payloads below. inferno 0.12.8 is package-scoped as CDDL-1.0: its CDDL-covered source remains available in the locked crates.io source archive at https://crates.io/crates/inferno/0.12.8 and https://github.com/jonhoo/inferno. The full locked license text follows below.
|
|
10847
10847
|
|
|
10848
10848
|
-------------------------------------------------------------------------------
|
|
10849
10849
|
License: Apache License 2.0 (Apache-2.0)
|
|
@@ -12509,6 +12509,58 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
12509
12509
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
12510
12510
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
12511
12511
|
|
|
12512
|
+
-------------------------------------------------------------------------------
|
|
12513
|
+
License: BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)
|
|
12514
|
+
Used by:
|
|
12515
|
+
- opusic-sys 0.7.5 (https://github.com/DoumanAsh/opusic-sys)
|
|
12516
|
+
|
|
12517
|
+
Full license text:
|
|
12518
|
+
|
|
12519
|
+
Copyright 2001-2023 Xiph.Org, Skype Limited, Octasic,
|
|
12520
|
+
Jean-Marc Valin, Timothy B. Terriberry,
|
|
12521
|
+
CSIRO, Gregory Maxwell, Mark Borgerding,
|
|
12522
|
+
Erik de Castro Lopo, Mozilla, Amazon
|
|
12523
|
+
|
|
12524
|
+
Redistribution and use in source and binary forms, with or without
|
|
12525
|
+
modification, are permitted provided that the following conditions
|
|
12526
|
+
are met:
|
|
12527
|
+
|
|
12528
|
+
- Redistributions of source code must retain the above copyright
|
|
12529
|
+
notice, this list of conditions and the following disclaimer.
|
|
12530
|
+
|
|
12531
|
+
- Redistributions in binary form must reproduce the above copyright
|
|
12532
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12533
|
+
documentation and/or other materials provided with the distribution.
|
|
12534
|
+
|
|
12535
|
+
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
|
12536
|
+
names of specific contributors, may be used to endorse or promote
|
|
12537
|
+
products derived from this software without specific prior written
|
|
12538
|
+
permission.
|
|
12539
|
+
|
|
12540
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
12541
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
12542
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
12543
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
12544
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
12545
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
12546
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
12547
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
12548
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
12549
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
12550
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
12551
|
+
|
|
12552
|
+
Opus is subject to the royalty-free patent licenses which are
|
|
12553
|
+
specified at:
|
|
12554
|
+
|
|
12555
|
+
Xiph.Org Foundation:
|
|
12556
|
+
https://datatracker.ietf.org/ipr/1524/
|
|
12557
|
+
|
|
12558
|
+
Microsoft Corporation:
|
|
12559
|
+
https://datatracker.ietf.org/ipr/1914/
|
|
12560
|
+
|
|
12561
|
+
Broadcom Corporation:
|
|
12562
|
+
https://datatracker.ietf.org/ipr/1526/
|
|
12563
|
+
|
|
12512
12564
|
-------------------------------------------------------------------------------
|
|
12513
12565
|
License: BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)
|
|
12514
12566
|
Used by:
|
|
@@ -13290,29 +13342,6 @@ jurisdiction of the Federal Courts of the Northern District of
|
|
|
13290
13342
|
California and the state courts of the State of California, with
|
|
13291
13343
|
venue lying in Santa Clara County, California.
|
|
13292
13344
|
|
|
13293
|
-
-------------------------------------------------------------------------------
|
|
13294
|
-
License: ISC License (ISC)
|
|
13295
|
-
Used by:
|
|
13296
|
-
- audiopus_sys 0.2.2 (https://github.com/lakelezz/audiopus_sys.git)
|
|
13297
|
-
|
|
13298
|
-
Full license text:
|
|
13299
|
-
|
|
13300
|
-
ISC License
|
|
13301
|
-
|
|
13302
|
-
Copyright (c) 2019, Lakelezz
|
|
13303
|
-
|
|
13304
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
13305
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
13306
|
-
copyright notice and this permission notice appear in all copies.
|
|
13307
|
-
|
|
13308
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
13309
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
13310
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
13311
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13312
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
13313
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13314
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
13315
|
-
|
|
13316
13345
|
-------------------------------------------------------------------------------
|
|
13317
13346
|
License: ISC License (ISC)
|
|
13318
13347
|
Used by:
|
|
@@ -18734,7 +18763,7 @@ DEALINGS IN THE SOFTWARE.
|
|
|
18734
18763
|
-------------------------------------------------------------------------------
|
|
18735
18764
|
License: MIT License (MIT)
|
|
18736
18765
|
Used by:
|
|
18737
|
-
- opus 0.
|
|
18766
|
+
- opus 0.4.0 (https://github.com/SpaceManiac/opus-rs)
|
|
18738
18767
|
|
|
18739
18768
|
Full license text:
|
|
18740
18769
|
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Dialect } from "@linxiraos/pi-ai/dialect";
|
|
|
3
3
|
import type { HarmonyAuditEvent } from "@linxiraos/pi-ai/utils/harmony-leak";
|
|
4
4
|
import type { AppendOnlyContextManager } from "./append-only-context.js";
|
|
5
5
|
import { Tokenizer } from "./tokenizer.js";
|
|
6
|
-
import type { AgentBeforeModelCall, AgentEvent, AgentLoopConfig, AgentMessage, AgentState, AgentTool, AgentToolContext, AgentTurnEndContext, AsideMessage, SpeculativeToolExecutionConfig, StreamFn, ToolCallContext, ToolChoiceDirective } from "./types.js";
|
|
6
|
+
import type { AgentBeforeModelCall, AgentEvent, AgentLoopConfig, AgentMessage, AgentState, AgentTool, AgentToolContext, AgentTurnEndContext, AsideMessage, PrepareQueuedMessages, SpeculativeToolExecutionConfig, StreamFn, ToolCallContext, ToolChoiceDirective } from "./types.js";
|
|
7
7
|
export declare class AgentBusyError extends Error {
|
|
8
8
|
constructor(message?: string);
|
|
9
9
|
}
|
|
@@ -235,6 +235,8 @@ export declare class Agent {
|
|
|
235
235
|
#private;
|
|
236
236
|
streamFn: StreamFn;
|
|
237
237
|
getApiKey?: (model: Model) => Promise<ApiKey | undefined> | ApiKey | undefined;
|
|
238
|
+
/** Prepare actual queue deliveries after dequeue gates; commit runs only while ownership remains valid. */
|
|
239
|
+
prepareQueuedMessages?: PrepareQueuedMessages;
|
|
238
240
|
/**
|
|
239
241
|
* Hook invoked after tool arguments are validated and before execution.
|
|
240
242
|
* Reassign at any time to swap the implementation (e.g. on extension reload).
|
|
@@ -452,7 +454,8 @@ export declare class Agent {
|
|
|
452
454
|
/** Non-consuming view of the pending steering queue (insertion order, newest
|
|
453
455
|
* last). The session layer derives its queued-message display/count from
|
|
454
456
|
* this live view instead of a mirror, so the agent-core queue stays the
|
|
455
|
-
* single source of truth.
|
|
457
|
+
* single source of truth. Includes exclusively claimed originals while
|
|
458
|
+
* preparation is pending, so editor restoration can cancel their delivery. */
|
|
456
459
|
peekSteeringQueue(): readonly AgentMessage[];
|
|
457
460
|
/** Non-consuming view of the pending follow-up queue. See
|
|
458
461
|
* {@link peekSteeringQueue}. */
|
|
@@ -41,10 +41,6 @@ export declare class StablePrefix {
|
|
|
41
41
|
get fingerprint(): string;
|
|
42
42
|
get version(): number;
|
|
43
43
|
get built(): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Build or rebuild from live context.
|
|
46
|
-
* Returns `true` if the prefix actually changed (cache miss imminent).
|
|
47
|
-
*/
|
|
48
44
|
build(context: AgentContext, options: BuildOptions): boolean;
|
|
49
45
|
/** Force rebuild on the next `build()` call. */
|
|
50
46
|
invalidate(): void;
|
|
@@ -124,6 +124,13 @@ export declare function shouldCompact(contextTokens: number, contextWindow: numb
|
|
|
124
124
|
*/
|
|
125
125
|
export declare function compactionContextTokens(providerContextTokens: number, storedConversationEstimate: number): number;
|
|
126
126
|
export declare function resolveThresholdTokens(contextWindow: number, settings: CompactionSettings): number;
|
|
127
|
+
/**
|
|
128
|
+
* True for entries that begin a conversational turn (a user request, a
|
|
129
|
+
* bash-execution card, a branch summary, or a custom user-role message).
|
|
130
|
+
* Compaction cut alignment, turn discovery, and the collapsed display
|
|
131
|
+
* transcript's orphan-head trim all share this boundary definition.
|
|
132
|
+
*/
|
|
133
|
+
export declare function isTurnStartEntry(entry: SessionEntry): boolean;
|
|
127
134
|
/**
|
|
128
135
|
* Find the user message (or bashExecution) that starts the turn containing the given entry index.
|
|
129
136
|
* Returns -1 if no turn start found before the index.
|
|
@@ -139,10 +146,11 @@ export interface CutPointResult {
|
|
|
139
146
|
isSplitTurn: boolean;
|
|
140
147
|
}
|
|
141
148
|
/**
|
|
142
|
-
* Find the
|
|
149
|
+
* Find the oldest complete recent-history suffix that fits `keepRecentTokens`.
|
|
143
150
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
151
|
+
* Walk backwards by valid cut points, measuring whole assistant/tool groups.
|
|
152
|
+
* Keep the newest group even when it alone exceeds the budget; never retain
|
|
153
|
+
* an additional older group that would push an otherwise fitting suffix over.
|
|
146
154
|
*
|
|
147
155
|
* Can cut at user OR assistant messages (never tool results). When cutting at an
|
|
148
156
|
* assistant message with tool calls, its tool results come after and will be kept.
|
|
@@ -304,24 +312,25 @@ export interface CompactionPreparation {
|
|
|
304
312
|
settings: CompactionSettings;
|
|
305
313
|
}
|
|
306
314
|
/**
|
|
307
|
-
* Whether
|
|
308
|
-
*
|
|
309
|
-
*
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
+
* Whether the active model's normal encoder can consume stored native history.
|
|
316
|
+
* Creating future compactions is a separate policy: disabling it does not disable
|
|
317
|
+
* Responses-family replay. Local summaries have no provider restriction.
|
|
318
|
+
*/
|
|
319
|
+
export declare function canReplayRemoteCompaction(preserveData: Record<string, unknown> | undefined, activeModel: Model): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Whether compaction preparation may reuse a native boundary instead of
|
|
322
|
+
* re-expanding its original messages. This is deliberately stricter than normal
|
|
323
|
+
* replay: the active model must both read the payload and remain eligible for
|
|
324
|
+
* native compaction under the current settings. Otherwise local summarization
|
|
325
|
+
* needs the originals, not an opaque placeholder.
|
|
315
326
|
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
* let the active model replay it, so keying reuse on "any candidate shares the
|
|
319
|
-
* provider" left a provider-switched session permanently context-less (#6343).
|
|
327
|
+
* Main-session preparation is judged against the active model, not any role
|
|
328
|
+
* candidate, so a provider switch cannot strand the original history (#6343).
|
|
320
329
|
*/
|
|
321
330
|
export declare function remotePreserveReusable(preserveData: Record<string, unknown> | undefined, activeModel: Model, settings: CompactionSettings): boolean;
|
|
322
331
|
/**
|
|
323
|
-
* Index of the newest compaction
|
|
324
|
-
* `-1` when none can.
|
|
332
|
+
* Index of the newest compaction boundary reusable under preparation policy,
|
|
333
|
+
* or `-1` when none can be reused (see {@link remotePreserveReusable}).
|
|
325
334
|
*
|
|
326
335
|
* A provider-native remote compaction (V2 or V1) stores an opaque replay payload
|
|
327
336
|
* and only a placeholder summary, so for any OTHER provider that entry
|
|
@@ -31,6 +31,8 @@ export interface CompactionEntry<T = unknown> extends SessionEntryBase {
|
|
|
31
31
|
shortSummary?: string;
|
|
32
32
|
firstKeptEntryId: string;
|
|
33
33
|
tokensBefore: number;
|
|
34
|
+
/** Last entry covered by native replay; later entries may precede the compaction record. */
|
|
35
|
+
providerReplayThroughEntryId?: string;
|
|
34
36
|
/** Extension-specific data (e.g., ArtifactIndex, version markers for structured compaction) */
|
|
35
37
|
details?: T;
|
|
36
38
|
/** Hook-provided data to persist across compaction */
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* summarization endpoints that accept `{ systemPrompt, prompt }` and reply
|
|
15
15
|
* with `{ summary, shortSummary? }`.
|
|
16
16
|
*/
|
|
17
|
-
import type { CodexCompactionContext, FetchImpl, Message, Model, ProviderSessionState } from "@linxiraos/pi-ai/types";
|
|
17
|
+
import type { Api, CodexCompactionContext, FetchImpl, Message, Model, ProviderSessionState } from "@linxiraos/pi-ai/types";
|
|
18
18
|
import { Tokenizer } from "../tokenizer.js";
|
|
19
19
|
export * from "./compaction-v2-streaming.js";
|
|
20
20
|
export declare const OPENAI_REMOTE_COMPACTION_PRESERVE_KEY = "openaiRemoteCompaction";
|
|
@@ -72,6 +72,7 @@ export interface RemoteCompactionResponse {
|
|
|
72
72
|
summary: string;
|
|
73
73
|
shortSummary?: string;
|
|
74
74
|
}
|
|
75
|
+
export declare function isOpenAiRemoteCompactionApi(api: Api | undefined): boolean;
|
|
75
76
|
export declare function shouldUseOpenAiRemoteCompaction(model: Model): boolean;
|
|
76
77
|
export declare function getPreservedOpenAiRemoteCompactionData(preserveData: Record<string, unknown> | undefined): OpenAiRemoteCompactionPreserveData | undefined;
|
|
77
78
|
export declare function withOpenAiRemoteCompactionPreserveData(preserveData: Record<string, unknown> | undefined, remoteCompaction: OpenAiRemoteCompactionPreserveData | undefined): Record<string, unknown> | undefined;
|
package/dist/types/thinking.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ import type { AgentRunCoverage, AgentRunSummary } from "./run-collector.js";
|
|
|
6
6
|
import type { AgentTelemetryConfig } from "./telemetry.js";
|
|
7
7
|
/** Stream function - can return sync or Promise for async config lookup */
|
|
8
8
|
export type StreamFn = (...args: Parameters<typeof streamSimple>) => AssistantMessageEventStream | Promise<AssistantMessageEventStream>;
|
|
9
|
+
/** Staged queue preparation; commit synchronously only while the batch is still owned. */
|
|
10
|
+
export interface QueuedMessagePreparation {
|
|
11
|
+
/** Append context after the originals; undefined stops this attempt, retaining originals unless explicitly removed. */
|
|
12
|
+
commit(): readonly AgentMessage[] | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Prepare an exclusively claimed batch. Undefined delivers unchanged; the signal also aborts when the claim is cancelled. */
|
|
15
|
+
export type PrepareQueuedMessages = (messages: readonly AgentMessage[], signal: AbortSignal) => QueuedMessagePreparation | undefined | Promise<QueuedMessagePreparation | undefined>;
|
|
9
16
|
/** Called once an aside has been inserted into the agent's live context. */
|
|
10
17
|
export declare const ASIDE_MESSAGE_COMMIT: unique symbol;
|
|
11
18
|
/** Symbol-keyed handoff for one finalized, tool-owned stream speculation session. */
|
|
@@ -874,8 +881,9 @@ export interface AgentTool<TParameters extends TSchema = TSchema, TDetails = any
|
|
|
874
881
|
* Called at `toolcall_start`, before any argument delta. Return `undefined` to opt out.
|
|
875
882
|
*/
|
|
876
883
|
openArgStream?: (init: AgentToolArgStreamInit) => AgentToolArgStream | undefined;
|
|
877
|
-
/** If true, tool is excluded unless explicitly listed in --tools or agent's tools field */
|
|
878
884
|
hidden?: boolean;
|
|
885
|
+
/** If true, the tool can read `skill://<name>` instruction content; prompt builders gate skill guidance on it. */
|
|
886
|
+
readsSkillUris?: boolean;
|
|
879
887
|
/** If true, tool can stage a pending action that requires explicit resolution via the resolve tool. */
|
|
880
888
|
deferrable?: boolean;
|
|
881
889
|
/** How an enabled tool is presented. See {@link ToolLoadMode}. Omitted is treated as `"essential"` for built-ins; custom-tool adapters normalize omission to `"discoverable"`. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@linxiraos/pi-agent-core",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.17",
|
|
5
5
|
"description": "General-purpose agent with transport abstraction, state management, and attachment support",
|
|
6
6
|
"homepage": "https://linxira-os.github.io/zeta/",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@linxiraos/pi-
|
|
40
|
-
"@linxiraos/pi-
|
|
41
|
-
"@linxiraos/pi-
|
|
42
|
-
"@linxiraos/pi-
|
|
43
|
-
"@linxiraos/pi-
|
|
44
|
-
"@
|
|
38
|
+
"@opentelemetry/api": "^1.9.1",
|
|
39
|
+
"@linxiraos/pi-ai": "1.1.17",
|
|
40
|
+
"@linxiraos/pi-catalog": "1.1.17",
|
|
41
|
+
"@linxiraos/pi-natives": "1.1.17",
|
|
42
|
+
"@linxiraos/pi-utils": "1.1.17",
|
|
43
|
+
"@linxiraos/pi-wire": "1.1.17",
|
|
44
|
+
"@linxiraos/pi-snapcompact": "1.1.17"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@linxiraos/pi-omptype": "1.1.15",
|
|
48
47
|
"@opentelemetry/context-async-hooks": "^2.9.0",
|
|
49
48
|
"@opentelemetry/sdk-trace-base": "^2.9.0",
|
|
50
|
-
"@types/bun": "^1.3.14"
|
|
49
|
+
"@types/bun": "^1.3.14",
|
|
50
|
+
"@linxiraos/pi-omptype": "1.1.17"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"bun": ">=1.3.14"
|