johns-harness 2026.10.21 → 2026.10.22
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 +8 -0
- package/README.md +3 -0
- package/dist/auth-profiles-5CHn7vq1.js +4 -2
- package/dist/compact-B247y5Qt.js +28 -69
- package/dist/config-koj5M_EO.js +4 -2
- package/dist/daemon-cli.js +4 -2
- package/dist/model-selection-BGlGpPgM.js +4 -2
- package/dist/model-selection-BU6wl1le.js +4 -2
- package/dist/model-selection-L7RMwsG-.js +4 -2
- package/dist/pi-embedded-C6ITuRXf.js +29 -84
- package/dist/pi-embedded-DoQsYfIY.js +29 -84
- package/dist/plugin-sdk/bluebubbles.js +2 -1
- package/dist/plugin-sdk/config/types.models.d.ts +1 -0
- package/dist/plugin-sdk/config/zod-schema.core.d.ts +3 -0
- package/dist/plugin-sdk/config/zod-schema.d.ts +1 -0
- package/dist/plugin-sdk/config-4Fgm-yEH.js +4 -2
- package/dist/plugin-sdk/config-Di-lyCdh.js +4 -2
- package/dist/plugin-sdk/discord.js +4 -2
- package/dist/plugin-sdk/dispatch-BP0viZiL.js +29 -84
- package/dist/plugin-sdk/dispatch-CQsjmw7g.js +29 -84
- package/dist/plugin-sdk/dispatch-Cerq29sy.js +29 -84
- package/dist/plugin-sdk/dispatch-Cndjtt0g.js +29 -84
- package/dist/plugin-sdk/dispatch-UogiJYul.js +29 -84
- package/dist/plugin-sdk/feishu.js +2 -1
- package/dist/plugin-sdk/googlechat.js +2 -1
- package/dist/plugin-sdk/imessage.js +2 -1
- package/dist/plugin-sdk/model-auth-CX9cPHdC.js +4 -2
- package/dist/plugin-sdk/model-auth-Ciehz0x5.js +4 -2
- package/dist/plugin-sdk/model-auth-DVyo6JSX.js +4 -2
- package/dist/plugin-sdk/model-auth-kiHYHGrs.js +4 -2
- package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +4 -2
- package/dist/plugin-sdk/nostr.js +2 -1
- package/dist/plugin-sdk/reply-DbZnH8-h.js +29 -84
- package/dist/plugin-sdk/signal.js +2 -1
- package/dist/plugin-sdk/slack.js +2 -1
- package/dist/plugin-sdk/telegram.js +2 -1
- package/dist/plugin-sdk/tlon.js +2 -1
- package/dist/plugin-sdk/twitch.js +2 -1
- package/dist/plugin-sdk/utils/usage-format.d.ts +1 -0
- package/dist/plugin-sdk/voice-call.js +2 -1
- package/dist/plugin-sdk/zalo.js +2 -1
- package/dist/plugin-sdk/zalouser.js +2 -1
- package/dist/reply-C5LKjXcC.js +28 -69
- package/dist/session-cost-usage-5CCZbVhO.js +4 -19
- package/dist/session-cost-usage-CkCo2kVx.js +4 -19
- package/dist/usage-billing.js +88 -0
- package/dist/usage-format-CNGi1eHQ.js +6 -11
- package/dist/usage-format-CvaU1ntA.js +6 -11
- package/docs/PATCHES.md +13 -1
- package/docs/providers/anthropic.md +8 -2
- package/docs/reference/token-use.md +11 -1
- package/models/models.json +33 -33
- package/node_modules/@mariozechner/pi-ai/dist/models.d.ts +1 -0
- package/node_modules/@mariozechner/pi-ai/dist/models.generated.js +32 -32
- package/node_modules/@mariozechner/pi-ai/dist/models.js +16 -5
- package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
- package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +1 -1
- package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +1 -1
- package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
- package/node_modules/@mariozechner/pi-ai/dist/types.d.ts +3 -0
- package/node_modules/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
- package/package.json +1 -1
- package/scripts/models-sync.mjs +1 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.d.ts +25 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.generated.js +32 -32
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.js +16 -5
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google-vertex.js +371 -0
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google.js +1 -1
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
- package/vendor/patched-deps/@mariozechner/pi-ai/dist/types.d.ts +282 -0
- package/vendor/patched-deps/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { AssistantMessageEventStream } from "./utils/event-stream.js";
|
|
2
|
+
export type { AssistantMessageEventStream } from "./utils/event-stream.js";
|
|
3
|
+
export type KnownApi = "openai-completions" | "openai-responses" | "azure-openai-responses" | "openai-codex-responses" | "anthropic-messages" | "bedrock-converse-stream" | "google-generative-ai" | "google-gemini-cli" | "google-vertex";
|
|
4
|
+
export type Api = KnownApi | (string & {});
|
|
5
|
+
export type KnownProvider = "amazon-bedrock" | "anthropic" | "google" | "google-gemini-cli" | "google-antigravity" | "google-vertex" | "openai" | "azure-openai-responses" | "openai-codex" | "github-copilot" | "xai" | "groq" | "cerebras" | "openrouter" | "vercel-ai-gateway" | "zai" | "mistral" | "minimax" | "minimax-cn" | "huggingface" | "opencode" | "kimi-coding";
|
|
6
|
+
export type Provider = KnownProvider | string;
|
|
7
|
+
export type ThinkingLevel = "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
8
|
+
/** Token budgets for each thinking level (token-based providers only) */
|
|
9
|
+
export interface ThinkingBudgets {
|
|
10
|
+
minimal?: number;
|
|
11
|
+
low?: number;
|
|
12
|
+
medium?: number;
|
|
13
|
+
high?: number;
|
|
14
|
+
}
|
|
15
|
+
export type CacheRetention = "none" | "short" | "long";
|
|
16
|
+
export type Transport = "sse" | "websocket" | "auto";
|
|
17
|
+
export interface StreamOptions {
|
|
18
|
+
temperature?: number;
|
|
19
|
+
maxTokens?: number;
|
|
20
|
+
signal?: AbortSignal;
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Preferred transport for providers that support multiple transports.
|
|
24
|
+
* Providers that do not support this option ignore it.
|
|
25
|
+
*/
|
|
26
|
+
transport?: Transport;
|
|
27
|
+
/**
|
|
28
|
+
* Prompt cache retention preference. Providers map this to their supported values.
|
|
29
|
+
* Default: "short".
|
|
30
|
+
*/
|
|
31
|
+
cacheRetention?: CacheRetention;
|
|
32
|
+
/**
|
|
33
|
+
* Optional session identifier for providers that support session-based caching.
|
|
34
|
+
* Providers can use this to enable prompt caching, request routing, or other
|
|
35
|
+
* session-aware features. Ignored by providers that don't support it.
|
|
36
|
+
*/
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Optional callback for inspecting provider payloads before sending.
|
|
40
|
+
*/
|
|
41
|
+
onPayload?: (payload: unknown) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Optional custom HTTP headers to include in API requests.
|
|
44
|
+
* Merged with provider defaults; can override default headers.
|
|
45
|
+
* Not supported by all providers (e.g., AWS Bedrock uses SDK auth).
|
|
46
|
+
*/
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum delay in milliseconds to wait for a retry when the server requests a long wait.
|
|
50
|
+
* If the server's requested delay exceeds this value, the request fails immediately
|
|
51
|
+
* with an error containing the requested delay, allowing higher-level retry logic
|
|
52
|
+
* to handle it with user visibility.
|
|
53
|
+
* Default: 60000 (60 seconds). Set to 0 to disable the cap.
|
|
54
|
+
*/
|
|
55
|
+
maxRetryDelayMs?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Optional metadata to include in API requests.
|
|
58
|
+
* Providers extract the fields they understand and ignore the rest.
|
|
59
|
+
* For example, Anthropic uses `user_id` for abuse tracking and rate limiting.
|
|
60
|
+
*/
|
|
61
|
+
metadata?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
export type ProviderStreamOptions = StreamOptions & Record<string, unknown>;
|
|
64
|
+
export interface SimpleStreamOptions extends StreamOptions {
|
|
65
|
+
reasoning?: ThinkingLevel;
|
|
66
|
+
/** Custom token budgets for thinking levels (token-based providers only) */
|
|
67
|
+
thinkingBudgets?: ThinkingBudgets;
|
|
68
|
+
}
|
|
69
|
+
export type StreamFunction<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> = (model: Model<TApi>, context: Context, options?: TOptions) => AssistantMessageEventStream;
|
|
70
|
+
export interface TextContent {
|
|
71
|
+
type: "text";
|
|
72
|
+
text: string;
|
|
73
|
+
textSignature?: string;
|
|
74
|
+
}
|
|
75
|
+
export interface ThinkingContent {
|
|
76
|
+
type: "thinking";
|
|
77
|
+
thinking: string;
|
|
78
|
+
thinkingSignature?: string;
|
|
79
|
+
/** When true, the thinking content was redacted by safety filters. The opaque
|
|
80
|
+
* encrypted payload is stored in `thinkingSignature` so it can be passed back
|
|
81
|
+
* to the API for multi-turn continuity. */
|
|
82
|
+
redacted?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface ImageContent {
|
|
85
|
+
type: "image";
|
|
86
|
+
data: string;
|
|
87
|
+
mimeType: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ToolCall {
|
|
90
|
+
type: "toolCall";
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
arguments: Record<string, any>;
|
|
94
|
+
thoughtSignature?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface Usage {
|
|
97
|
+
input: number;
|
|
98
|
+
output: number;
|
|
99
|
+
cacheRead: number;
|
|
100
|
+
cacheWrite: number;
|
|
101
|
+
cacheWrite5m?: number;
|
|
102
|
+
cacheWrite1h?: number;
|
|
103
|
+
totalTokens: number;
|
|
104
|
+
cost: {
|
|
105
|
+
input: number;
|
|
106
|
+
output: number;
|
|
107
|
+
cacheRead: number;
|
|
108
|
+
cacheWrite: number;
|
|
109
|
+
total: number;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export type StopReason = "stop" | "length" | "toolUse" | "error" | "aborted";
|
|
113
|
+
export interface UserMessage {
|
|
114
|
+
role: "user";
|
|
115
|
+
content: string | (TextContent | ImageContent)[];
|
|
116
|
+
timestamp: number;
|
|
117
|
+
}
|
|
118
|
+
export interface AssistantMessage {
|
|
119
|
+
role: "assistant";
|
|
120
|
+
content: (TextContent | ThinkingContent | ToolCall)[];
|
|
121
|
+
api: Api;
|
|
122
|
+
provider: Provider;
|
|
123
|
+
model: string;
|
|
124
|
+
usage: Usage;
|
|
125
|
+
stopReason: StopReason;
|
|
126
|
+
errorMessage?: string;
|
|
127
|
+
timestamp: number;
|
|
128
|
+
}
|
|
129
|
+
export interface ToolResultMessage<TDetails = any> {
|
|
130
|
+
role: "toolResult";
|
|
131
|
+
toolCallId: string;
|
|
132
|
+
toolName: string;
|
|
133
|
+
content: (TextContent | ImageContent)[];
|
|
134
|
+
details?: TDetails;
|
|
135
|
+
isError: boolean;
|
|
136
|
+
timestamp: number;
|
|
137
|
+
}
|
|
138
|
+
export type Message = UserMessage | AssistantMessage | ToolResultMessage;
|
|
139
|
+
import type { TSchema } from "@sinclair/typebox";
|
|
140
|
+
export interface Tool<TParameters extends TSchema = TSchema> {
|
|
141
|
+
name: string;
|
|
142
|
+
description: string;
|
|
143
|
+
parameters: TParameters;
|
|
144
|
+
}
|
|
145
|
+
export interface Context {
|
|
146
|
+
systemPrompt?: string;
|
|
147
|
+
messages: Message[];
|
|
148
|
+
tools?: Tool[];
|
|
149
|
+
}
|
|
150
|
+
export type AssistantMessageEvent = {
|
|
151
|
+
type: "start";
|
|
152
|
+
partial: AssistantMessage;
|
|
153
|
+
} | {
|
|
154
|
+
type: "text_start";
|
|
155
|
+
contentIndex: number;
|
|
156
|
+
partial: AssistantMessage;
|
|
157
|
+
} | {
|
|
158
|
+
type: "text_delta";
|
|
159
|
+
contentIndex: number;
|
|
160
|
+
delta: string;
|
|
161
|
+
partial: AssistantMessage;
|
|
162
|
+
} | {
|
|
163
|
+
type: "text_end";
|
|
164
|
+
contentIndex: number;
|
|
165
|
+
content: string;
|
|
166
|
+
partial: AssistantMessage;
|
|
167
|
+
} | {
|
|
168
|
+
type: "thinking_start";
|
|
169
|
+
contentIndex: number;
|
|
170
|
+
partial: AssistantMessage;
|
|
171
|
+
} | {
|
|
172
|
+
type: "thinking_delta";
|
|
173
|
+
contentIndex: number;
|
|
174
|
+
delta: string;
|
|
175
|
+
partial: AssistantMessage;
|
|
176
|
+
} | {
|
|
177
|
+
type: "thinking_end";
|
|
178
|
+
contentIndex: number;
|
|
179
|
+
content: string;
|
|
180
|
+
partial: AssistantMessage;
|
|
181
|
+
} | {
|
|
182
|
+
type: "toolcall_start";
|
|
183
|
+
contentIndex: number;
|
|
184
|
+
partial: AssistantMessage;
|
|
185
|
+
} | {
|
|
186
|
+
type: "toolcall_delta";
|
|
187
|
+
contentIndex: number;
|
|
188
|
+
delta: string;
|
|
189
|
+
partial: AssistantMessage;
|
|
190
|
+
} | {
|
|
191
|
+
type: "toolcall_end";
|
|
192
|
+
contentIndex: number;
|
|
193
|
+
toolCall: ToolCall;
|
|
194
|
+
partial: AssistantMessage;
|
|
195
|
+
} | {
|
|
196
|
+
type: "done";
|
|
197
|
+
reason: Extract<StopReason, "stop" | "length" | "toolUse">;
|
|
198
|
+
message: AssistantMessage;
|
|
199
|
+
} | {
|
|
200
|
+
type: "error";
|
|
201
|
+
reason: Extract<StopReason, "aborted" | "error">;
|
|
202
|
+
error: AssistantMessage;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Compatibility settings for OpenAI-compatible completions APIs.
|
|
206
|
+
* Use this to override URL-based auto-detection for custom providers.
|
|
207
|
+
*/
|
|
208
|
+
export interface OpenAICompletionsCompat {
|
|
209
|
+
/** Whether the provider supports the `store` field. Default: auto-detected from URL. */
|
|
210
|
+
supportsStore?: boolean;
|
|
211
|
+
/** Whether the provider supports the `developer` role (vs `system`). Default: auto-detected from URL. */
|
|
212
|
+
supportsDeveloperRole?: boolean;
|
|
213
|
+
/** Whether the provider supports `reasoning_effort`. Default: auto-detected from URL. */
|
|
214
|
+
supportsReasoningEffort?: boolean;
|
|
215
|
+
/** Whether the provider supports `stream_options: { include_usage: true }` for token usage in streaming responses. Default: true. */
|
|
216
|
+
supportsUsageInStreaming?: boolean;
|
|
217
|
+
/** Which field to use for max tokens. Default: auto-detected from URL. */
|
|
218
|
+
maxTokensField?: "max_completion_tokens" | "max_tokens";
|
|
219
|
+
/** Whether tool results require the `name` field. Default: auto-detected from URL. */
|
|
220
|
+
requiresToolResultName?: boolean;
|
|
221
|
+
/** Whether a user message after tool results requires an assistant message in between. Default: auto-detected from URL. */
|
|
222
|
+
requiresAssistantAfterToolResult?: boolean;
|
|
223
|
+
/** Whether thinking blocks must be converted to text blocks with <thinking> delimiters. Default: auto-detected from URL. */
|
|
224
|
+
requiresThinkingAsText?: boolean;
|
|
225
|
+
/** Whether tool call IDs must be normalized to Mistral format (exactly 9 alphanumeric chars). Default: auto-detected from URL. */
|
|
226
|
+
requiresMistralToolIds?: boolean;
|
|
227
|
+
/** Format for reasoning/thinking parameter. "openai" uses reasoning_effort, "zai" uses thinking: { type: "enabled" }, "qwen" uses enable_thinking: boolean. Default: "openai". */
|
|
228
|
+
thinkingFormat?: "openai" | "zai" | "qwen";
|
|
229
|
+
/** OpenRouter-specific routing preferences. Only used when baseUrl points to OpenRouter. */
|
|
230
|
+
openRouterRouting?: OpenRouterRouting;
|
|
231
|
+
/** Vercel AI Gateway routing preferences. Only used when baseUrl points to Vercel AI Gateway. */
|
|
232
|
+
vercelGatewayRouting?: VercelGatewayRouting;
|
|
233
|
+
/** Whether the provider supports the `strict` field in tool definitions. Default: true. */
|
|
234
|
+
supportsStrictMode?: boolean;
|
|
235
|
+
}
|
|
236
|
+
/** Compatibility settings for OpenAI Responses APIs. */
|
|
237
|
+
export interface OpenAIResponsesCompat {
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* OpenRouter provider routing preferences.
|
|
241
|
+
* Controls which upstream providers OpenRouter routes requests to.
|
|
242
|
+
* @see https://openrouter.ai/docs/provider-routing
|
|
243
|
+
*/
|
|
244
|
+
export interface OpenRouterRouting {
|
|
245
|
+
/** List of provider slugs to exclusively use for this request (e.g., ["amazon-bedrock", "anthropic"]). */
|
|
246
|
+
only?: string[];
|
|
247
|
+
/** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
|
|
248
|
+
order?: string[];
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Vercel AI Gateway routing preferences.
|
|
252
|
+
* Controls which upstream providers the gateway routes requests to.
|
|
253
|
+
* @see https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
|
|
254
|
+
*/
|
|
255
|
+
export interface VercelGatewayRouting {
|
|
256
|
+
/** List of provider slugs to exclusively use for this request (e.g., ["bedrock", "anthropic"]). */
|
|
257
|
+
only?: string[];
|
|
258
|
+
/** List of provider slugs to try in order (e.g., ["anthropic", "openai"]). */
|
|
259
|
+
order?: string[];
|
|
260
|
+
}
|
|
261
|
+
export interface Model<TApi extends Api> {
|
|
262
|
+
id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
api: TApi;
|
|
265
|
+
provider: Provider;
|
|
266
|
+
baseUrl: string;
|
|
267
|
+
reasoning: boolean;
|
|
268
|
+
input: ("text" | "image")[];
|
|
269
|
+
cost: {
|
|
270
|
+
input: number;
|
|
271
|
+
output: number;
|
|
272
|
+
cacheRead: number;
|
|
273
|
+
cacheWrite: number;
|
|
274
|
+
cacheWrite1h?: number;
|
|
275
|
+
};
|
|
276
|
+
contextWindow: number;
|
|
277
|
+
maxTokens: number;
|
|
278
|
+
headers?: Record<string, string>;
|
|
279
|
+
/** Compatibility overrides for OpenAI-compatible APIs. If not set, auto-detected from baseUrl. */
|
|
280
|
+
compat?: TApi extends "openai-completions" ? OpenAICompletionsCompat : TApi extends "openai-responses" ? OpenAIResponsesCompat : never;
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -51,6 +51,7 @@ const ModelDefinitionSchema = Type.Object({
|
|
|
51
51
|
output: Type.Number(),
|
|
52
52
|
cacheRead: Type.Number(),
|
|
53
53
|
cacheWrite: Type.Number(),
|
|
54
|
+
cacheWrite1h: Type.Optional(Type.Number({ minimum: 0 })), // JOHNNESS_PATCH_USAGE_BILLING_91
|
|
54
55
|
})),
|
|
55
56
|
contextWindow: Type.Optional(Type.Number()),
|
|
56
57
|
maxTokens: Type.Optional(Type.Number()),
|
|
@@ -67,6 +68,7 @@ const ModelOverrideSchema = Type.Object({
|
|
|
67
68
|
output: Type.Optional(Type.Number()),
|
|
68
69
|
cacheRead: Type.Optional(Type.Number()),
|
|
69
70
|
cacheWrite: Type.Optional(Type.Number()),
|
|
71
|
+
cacheWrite1h: Type.Optional(Type.Number({ minimum: 0 })),
|
|
70
72
|
})),
|
|
71
73
|
contextWindow: Type.Optional(Type.Number()),
|
|
72
74
|
maxTokens: Type.Optional(Type.Number()),
|
|
@@ -137,6 +139,7 @@ function applyModelOverride(model, override) {
|
|
|
137
139
|
output: override.cost.output ?? model.cost.output,
|
|
138
140
|
cacheRead: override.cost.cacheRead ?? model.cost.cacheRead,
|
|
139
141
|
cacheWrite: override.cost.cacheWrite ?? model.cost.cacheWrite,
|
|
142
|
+
...(override.cost.cacheWrite1h !== undefined ? { cacheWrite1h: override.cost.cacheWrite1h } : model.api === "anthropic-messages" && override.cost.input !== undefined ? { cacheWrite1h: override.cost.input * 2 } : model.cost.cacheWrite1h !== undefined ? { cacheWrite1h: model.cost.cacheWrite1h } : {}),
|
|
140
143
|
};
|
|
141
144
|
}
|
|
142
145
|
// Merge headers
|