@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.
Files changed (37) hide show
  1. package/CHANGELOG.md +4 -6
  2. package/package.json +73 -79
  3. package/src/agent-loop.ts +80 -15
  4. package/src/compaction/compaction-v2-streaming.ts +43 -32
  5. package/src/compaction/compaction.ts +88 -17
  6. package/src/compaction/openai.ts +3 -0
  7. package/src/telemetry.ts +2 -2
  8. package/src/types.ts +34 -7
  9. package/THIRD-PARTY-NOTICES.txt +0 -22909
  10. package/dist/types/agent-loop.d.ts +0 -150
  11. package/dist/types/agent.d.ts +0 -472
  12. package/dist/types/append-only-context.d.ts +0 -131
  13. package/dist/types/compaction/branch-summarization.d.ts +0 -102
  14. package/dist/types/compaction/compaction-v2-streaming.d.ts +0 -85
  15. package/dist/types/compaction/compaction.d.ts +0 -341
  16. package/dist/types/compaction/entries.d.ts +0 -120
  17. package/dist/types/compaction/errors.d.ts +0 -38
  18. package/dist/types/compaction/index.d.ts +0 -14
  19. package/dist/types/compaction/message-cache.d.ts +0 -25
  20. package/dist/types/compaction/messages.d.ts +0 -103
  21. package/dist/types/compaction/openai.d.ts +0 -118
  22. package/dist/types/compaction/pruning.d.ts +0 -106
  23. package/dist/types/compaction/shake.d.ts +0 -104
  24. package/dist/types/compaction/tool-protection.d.ts +0 -19
  25. package/dist/types/compaction/transcript-tokens.d.ts +0 -76
  26. package/dist/types/compaction/utils.d.ts +0 -63
  27. package/dist/types/compaction.d.ts +0 -1
  28. package/dist/types/index.d.ts +0 -13
  29. package/dist/types/pause.d.ts +0 -46
  30. package/dist/types/proxy.d.ts +0 -91
  31. package/dist/types/replay-policy.d.ts +0 -5
  32. package/dist/types/run-collector.d.ts +0 -196
  33. package/dist/types/telemetry.d.ts +0 -625
  34. package/dist/types/thinking.d.ts +0 -18
  35. package/dist/types/tokenizer.d.ts +0 -78
  36. package/dist/types/types.d.ts +0 -786
  37. package/dist/types/utils/yield.d.ts +0 -71
@@ -1,78 +0,0 @@
1
- import type { Model } from "@linxiraos/pi-ai";
2
- import * as natives from "@linxiraos/pi-natives";
3
- import type { AgentMessage } from "./types.js";
4
- /** Maps the catalog-resolved tokenizer family to its native implementation. */
5
- export declare function tokenizerEncodingForModel(model: Pick<Model, "tokenizer"> | null | undefined): natives.Encoding | null;
6
- /**
7
- * `strict` always tries an exact native count (the catalog-resolved tokenizer
8
- * when known, o200k_base otherwise), falling back to the byte upper bound when
9
- * the loaded addon does not recognize that encoding. `approximate` and
10
- * `upperbound` prefer the same exact count for known tokenizer families or
11
- * when `PI_TOKENIZER_ACCURATE=1` is set; otherwise they use a cheap heuristic:
12
- * `approximate` a bytes/4 guess, `upperbound` the raw byte length (never
13
- * undercounts).
14
- */
15
- export type TokenCountMode = "strict" | "approximate" | "upperbound";
16
- /** Options for {@link Tokenizer.countMessage} / {@link Tokenizer.countMessages}. */
17
- export interface MessageCountOptions {
18
- /**
19
- * Drop opaque provider reasoning payloads (`thinkingSignature`,
20
- * `redactedThinking`, native server-tool blocks) from the estimate. Those
21
- * are billed by the provider on replay, so the default counts them — but
22
- * their *local* byte size can diverge wildly from what the provider
23
- * charges, so the compaction floor (which only needs the reliably-countable,
24
- * on-wire-compressible content) excludes them to avoid false triggers on
25
- * thinking-heavy turns.
26
- */
27
- excludeEncryptedReasoning?: boolean;
28
- }
29
- /** Verdict from {@link Tokenizer.checkTokenBudget}. */
30
- export interface TokenBudgetCheck {
31
- /** Whether the text fits the budget. */
32
- fits: boolean;
33
- /**
34
- * Token count behind the verdict: the exact native count when `exact` is
35
- * set, otherwise the conservative byte upper bound.
36
- */
37
- tokens: number;
38
- /** Whether `tokens` came from the exact native tokenizer. */
39
- exact: boolean;
40
- }
41
- /**
42
- * Model-aware local token counter. Immutable: the catalog-resolved encoding
43
- * is fixed at construction, so a cached count can never straddle two
44
- * encodings. An `Agent` owns one for its active model (swapping the instance
45
- * when the model's encoding changes); one-shot flows construct their own for
46
- * the model that will be billed. Known tokenizer families use exact native
47
- * counts; unknown models keep the fast byte estimate (or o200k when
48
- * `PI_TOKENIZER_ACCURATE=1`).
49
- */
50
- export declare class Tokenizer {
51
- #private;
52
- constructor(model?: Pick<Model, "tokenizer"> | null);
53
- get encoding(): natives.Encoding | null;
54
- countTokens(text: string | string[], mode?: TokenCountMode): number;
55
- /**
56
- * Cheap-first budget probe — the way to ask "does this fit in `budget`
57
- * tokens?" without tokenizing the world.
58
- *
59
- * Byte length is a hard upper bound on token count (every token consumes at
60
- * least one input byte), so text whose raw bytes already fit the budget
61
- * cannot possibly exceed it — that verdict is returned without tokenizing at
62
- * all. Only text that busts the bound is ambiguous, and only that case pays
63
- * for the exact count. Since the bound overshoots ~4x on ordinary prose, the
64
- * common "comfortably under budget" answer is free.
65
- */
66
- checkTokenBudget(text: string | string[], budget: number): TokenBudgetCheck;
67
- /**
68
- * Token estimate for one message under this tokenizer's encoding.
69
- *
70
- * Settled historical messages are counted once and reused until an owner
71
- * (prune/shake/strip-images) calls `invalidateMessageCache`; streaming
72
- * assistants bypass the memo entirely (see the message-cache settle-gate
73
- * invariant). Image blocks charge a fixed per-image estimate.
74
- */
75
- countMessage(message: AgentMessage, options?: MessageCountOptions): number;
76
- /** Sum of {@link countMessage} over `messages`. */
77
- countMessages(messages: readonly AgentMessage[], options?: MessageCountOptions): number;
78
- }