pi-openai-toolkit 0.3.0 → 0.4.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.
@@ -6,12 +6,17 @@ export {
6
6
  isResponsesCompatiblePayload,
7
7
  isSupportedApi,
8
8
  normalizeBaseUrl,
9
+ parseModelSpec,
9
10
  resolveNativeCompactionEnvironment,
11
+ resolveRemoteCompactionExecution,
10
12
  type NativeCompactionEnvironmentFailure,
11
13
  type NativeCompactionEnvironmentResolution,
12
14
  type NativeCompactionEnvironmentSuccess,
13
15
  type NativeCompactionRuntime,
14
16
  type NativeCompactionSupportOptions,
17
+ type RemoteCompactionExecution,
18
+ type RemoteCompactionExecutionResolution,
19
+ type RemoteCompactionExecutionSuccess,
15
20
  type ResponsesCompatibleRequestPayload,
16
21
  } from "./runtime.ts";
17
22
  export { RESPONSES_COMPACT_CAPABLE_APIS } from "./types.ts";
package/src/types.ts CHANGED
@@ -43,6 +43,11 @@ export type CompactionConfig = {
43
43
  * to restart native compaction from Pi's current serialized session context.
44
44
  */
45
45
  allowCompactionContinuityBreak: boolean;
46
+ /**
47
+ * "provider/model-id" used only for remote_compaction_v2. The active session model
48
+ * remains the checkpoint consumer and continues handling normal requests.
49
+ */
50
+ remoteCompactModel?: string;
46
51
  /**
47
52
  * "provider/model-id" used for native-method fallback compaction (non-Responses APIs,
48
53
  * or when the compact endpoint fails). Unset = current model via pi's default path.
@@ -132,6 +137,8 @@ export type NativeCompactionIdentity = {
132
137
 
133
138
  export type NativeCompactionDetails = NativeCompactionIdentity & {
134
139
  strategy: NativeCompactionStrategy;
140
+ /** Actual producer of the opaque checkpoint; absent on legacy same-model entries. */
141
+ compactionModel?: NativeCompactionIdentity;
135
142
  compactedWindow: unknown[];
136
143
  compactResponseId?: string;
137
144
  createdAt: string;
@@ -141,6 +148,7 @@ export type NativeCompactionDetails = NativeCompactionIdentity & {
141
148
  export type NativeCompactionEntry = CompactionEntry<NativeCompactionDetails>;
142
149
 
143
150
  export type CreateNativeCompactionDetailsInput = NativeCompactionIdentity & {
151
+ compactionModel?: NativeCompactionIdentity;
144
152
  compactedWindow: unknown[];
145
153
  compactResponseId?: string;
146
154
  createdAt?: string;
@@ -263,6 +271,7 @@ export function isNativeCompactionDetails(value: unknown): value is NativeCompac
263
271
  return (
264
272
  (candidate.strategy === LEGACY_NATIVE_COMPACTION_STRATEGY ||
265
273
  candidate.strategy === REMOTE_V2_COMPACTION_STRATEGY) &&
274
+ (candidate.compactionModel === undefined || isNativeCompactionIdentity(candidate.compactionModel)) &&
266
275
  Array.isArray(candidate.compactedWindow) &&
267
276
  candidate.compactedWindow.every(isCompactedWindowItem) &&
268
277
  isNonEmptyString(candidate.createdAt) &&
@@ -282,6 +291,14 @@ export function createNativeCompactionDetails(input: CreateNativeCompactionDetai
282
291
  api: normalizeString(input.api),
283
292
  model: normalizeString(input.model),
284
293
  baseUrl: normalizeString(input.baseUrl),
294
+ compactionModel: input.compactionModel
295
+ ? {
296
+ provider: normalizeString(input.compactionModel.provider),
297
+ api: normalizeString(input.compactionModel.api),
298
+ model: normalizeString(input.compactionModel.model),
299
+ baseUrl: normalizeString(input.compactionModel.baseUrl),
300
+ }
301
+ : undefined,
285
302
  compactedWindow: input.compactedWindow.map((item) => cloneStructuredValue(item)),
286
303
  compactResponseId: isNonEmptyString(input.compactResponseId) ? normalizeString(input.compactResponseId) : undefined,
287
304
  createdAt: isNonEmptyString(input.createdAt) ? normalizeString(input.createdAt) : new Date().toISOString(),
@@ -311,6 +328,7 @@ export function createNativeCompactionResult(
311
328
  export const DEFAULT_COMPACTION_CONFIG: CompactionConfig = {
312
329
  enabled: true,
313
330
  allowCompactionContinuityBreak: false,
331
+ remoteCompactModel: undefined,
314
332
  model: undefined,
315
333
  thinkingLevel: "off",
316
334
  responsesApis: [...RESPONSES_COMPACT_CAPABLE_APIS],
@@ -1,36 +1,36 @@
1
- {
2
- "compilerOptions": {
3
- "noEmit": true,
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "allowImportingTsExtensions": true,
7
- "target": "ES2022",
8
- "lib": ["ES2022", "DOM", "DOM.Iterable"],
9
- "skipLibCheck": true,
10
- "strict": true,
11
- "baseUrl": ".",
12
- "typeRoots": ["./node_modules/@types"]
13
- },
14
- "include": [
15
- "extensions/compaction.ts",
16
- "extensions/web-search.ts",
17
- "src/compact-client.ts",
18
- "src/config.ts",
19
- "src/debug.ts",
20
- "src/details-store.ts",
21
- "src/extension-runtime.ts",
22
- "src/native-fallback.ts",
23
- "src/payload-rewrite.ts",
24
- "src/provider-headers.ts",
25
- "src/remote-v2-client.ts",
26
- "src/request-context-cache.ts",
27
- "src/runtime.ts",
28
- "src/serializer.ts",
29
- "src/supported-environment.ts",
30
- "src/types.ts",
31
- "src/web-search/extension.ts",
32
- "src/web-search/payload.ts",
33
- "src/web-search/prompt.ts",
34
- "src/web-search/types.ts"
35
- ]
36
- }
1
+ {
2
+ "compilerOptions": {
3
+ "noEmit": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "target": "ES2022",
8
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
9
+ "skipLibCheck": true,
10
+ "strict": true,
11
+ "baseUrl": ".",
12
+ "typeRoots": ["./node_modules/@types"]
13
+ },
14
+ "include": [
15
+ "extensions/compaction.ts",
16
+ "extensions/web-search.ts",
17
+ "src/compact-client.ts",
18
+ "src/config.ts",
19
+ "src/debug.ts",
20
+ "src/details-store.ts",
21
+ "src/extension-runtime.ts",
22
+ "src/native-fallback.ts",
23
+ "src/payload-rewrite.ts",
24
+ "src/provider-headers.ts",
25
+ "src/remote-v2-client.ts",
26
+ "src/request-context-cache.ts",
27
+ "src/runtime.ts",
28
+ "src/serializer.ts",
29
+ "src/supported-environment.ts",
30
+ "src/types.ts",
31
+ "src/web-search/extension.ts",
32
+ "src/web-search/payload.ts",
33
+ "src/web-search/prompt.ts",
34
+ "src/web-search/types.ts"
35
+ ]
36
+ }