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.
Files changed (72) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +3 -0
  3. package/dist/auth-profiles-5CHn7vq1.js +4 -2
  4. package/dist/compact-B247y5Qt.js +28 -69
  5. package/dist/config-koj5M_EO.js +4 -2
  6. package/dist/daemon-cli.js +4 -2
  7. package/dist/model-selection-BGlGpPgM.js +4 -2
  8. package/dist/model-selection-BU6wl1le.js +4 -2
  9. package/dist/model-selection-L7RMwsG-.js +4 -2
  10. package/dist/pi-embedded-C6ITuRXf.js +29 -84
  11. package/dist/pi-embedded-DoQsYfIY.js +29 -84
  12. package/dist/plugin-sdk/bluebubbles.js +2 -1
  13. package/dist/plugin-sdk/config/types.models.d.ts +1 -0
  14. package/dist/plugin-sdk/config/zod-schema.core.d.ts +3 -0
  15. package/dist/plugin-sdk/config/zod-schema.d.ts +1 -0
  16. package/dist/plugin-sdk/config-4Fgm-yEH.js +4 -2
  17. package/dist/plugin-sdk/config-Di-lyCdh.js +4 -2
  18. package/dist/plugin-sdk/discord.js +4 -2
  19. package/dist/plugin-sdk/dispatch-BP0viZiL.js +29 -84
  20. package/dist/plugin-sdk/dispatch-CQsjmw7g.js +29 -84
  21. package/dist/plugin-sdk/dispatch-Cerq29sy.js +29 -84
  22. package/dist/plugin-sdk/dispatch-Cndjtt0g.js +29 -84
  23. package/dist/plugin-sdk/dispatch-UogiJYul.js +29 -84
  24. package/dist/plugin-sdk/feishu.js +2 -1
  25. package/dist/plugin-sdk/googlechat.js +2 -1
  26. package/dist/plugin-sdk/imessage.js +2 -1
  27. package/dist/plugin-sdk/model-auth-CX9cPHdC.js +4 -2
  28. package/dist/plugin-sdk/model-auth-Ciehz0x5.js +4 -2
  29. package/dist/plugin-sdk/model-auth-DVyo6JSX.js +4 -2
  30. package/dist/plugin-sdk/model-auth-kiHYHGrs.js +4 -2
  31. package/dist/plugin-sdk/model-selection-Dbj4jDYM.js +4 -2
  32. package/dist/plugin-sdk/nostr.js +2 -1
  33. package/dist/plugin-sdk/reply-DbZnH8-h.js +29 -84
  34. package/dist/plugin-sdk/signal.js +2 -1
  35. package/dist/plugin-sdk/slack.js +2 -1
  36. package/dist/plugin-sdk/telegram.js +2 -1
  37. package/dist/plugin-sdk/tlon.js +2 -1
  38. package/dist/plugin-sdk/twitch.js +2 -1
  39. package/dist/plugin-sdk/utils/usage-format.d.ts +1 -0
  40. package/dist/plugin-sdk/voice-call.js +2 -1
  41. package/dist/plugin-sdk/zalo.js +2 -1
  42. package/dist/plugin-sdk/zalouser.js +2 -1
  43. package/dist/reply-C5LKjXcC.js +28 -69
  44. package/dist/session-cost-usage-5CCZbVhO.js +4 -19
  45. package/dist/session-cost-usage-CkCo2kVx.js +4 -19
  46. package/dist/usage-billing.js +88 -0
  47. package/dist/usage-format-CNGi1eHQ.js +6 -11
  48. package/dist/usage-format-CvaU1ntA.js +6 -11
  49. package/docs/PATCHES.md +13 -1
  50. package/docs/providers/anthropic.md +8 -2
  51. package/docs/reference/token-use.md +11 -1
  52. package/models/models.json +33 -33
  53. package/node_modules/@mariozechner/pi-ai/dist/models.d.ts +1 -0
  54. package/node_modules/@mariozechner/pi-ai/dist/models.generated.js +32 -32
  55. package/node_modules/@mariozechner/pi-ai/dist/models.js +16 -5
  56. package/node_modules/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
  57. package/node_modules/@mariozechner/pi-ai/dist/providers/google-vertex.js +1 -1
  58. package/node_modules/@mariozechner/pi-ai/dist/providers/google.js +1 -1
  59. package/node_modules/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
  60. package/node_modules/@mariozechner/pi-ai/dist/types.d.ts +3 -0
  61. package/node_modules/@mariozechner/pi-coding-agent/dist/core/model-registry.js +3 -0
  62. package/package.json +1 -1
  63. package/scripts/models-sync.mjs +1 -0
  64. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.d.ts +25 -0
  65. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.generated.js +32 -32
  66. package/vendor/patched-deps/@mariozechner/pi-ai/dist/models.js +16 -5
  67. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/anthropic.js +15 -0
  68. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google-vertex.js +371 -0
  69. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/google.js +1 -1
  70. package/vendor/patched-deps/@mariozechner/pi-ai/dist/providers/openai-completions.js +5 -5
  71. package/vendor/patched-deps/@mariozechner/pi-ai/dist/types.d.ts +282 -0
  72. 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