@deepagents/experimental 7.2.0 → 7.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.
Files changed (36) hide show
  1. package/dist/coding-agent-reminders/index.js +4 -4
  2. package/dist/coding-agent-reminders/index.js.map +2 -2
  3. package/dist/coding-agent-reminders/io.d.ts.map +1 -1
  4. package/dist/index.js +12 -13
  5. package/dist/index.js.map +3 -3
  6. package/dist/providers/claude/index.d.ts +9 -1
  7. package/dist/providers/claude/index.d.ts.map +1 -1
  8. package/dist/providers/claude/index.js +24 -14
  9. package/dist/providers/claude/index.js.map +2 -2
  10. package/dist/providers/claude/local-credentials.d.ts +1 -1
  11. package/dist/providers/claude/local-credentials.d.ts.map +1 -1
  12. package/dist/providers/codex/index.js +3 -1
  13. package/dist/providers/codex/index.js.map +2 -2
  14. package/dist/providers/codex/local-credentials.d.ts.map +1 -1
  15. package/dist/zukhruf/agent.d.ts +3 -1
  16. package/dist/zukhruf/agent.d.ts.map +1 -1
  17. package/dist/zukhruf/index.js +8 -9
  18. package/dist/zukhruf/index.js.map +3 -3
  19. package/dist/zukhruf/mailbox/ddl.sqlite.d.ts +1 -1
  20. package/dist/zukhruf/mailbox/ddl.sqlite.d.ts.map +1 -1
  21. package/dist/zukhruf/mailbox/sqlite.store.d.ts.map +1 -1
  22. package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts.map +1 -1
  23. package/dist/zukhruf/plugins/conversation-scheduling/index.js +8 -11
  24. package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +2 -2
  25. package/dist/zukhruf/plugins/http/index.d.ts.map +1 -1
  26. package/dist/zukhruf/plugins/http/index.js +40 -20
  27. package/dist/zukhruf/plugins/http/index.js.map +2 -2
  28. package/dist/zukhruf/plugins/schedules/http.js.map +1 -1
  29. package/dist/zukhruf/plugins/schedules/index.d.ts.map +1 -1
  30. package/dist/zukhruf/plugins/schedules/index.js +15 -16
  31. package/dist/zukhruf/plugins/schedules/index.js.map +3 -3
  32. package/dist/zukhruf/plugins/uploads/http.js.map +1 -1
  33. package/dist/zukhruf/plugins/uploads/index.js +7 -8
  34. package/dist/zukhruf/plugins/uploads/index.js.map +2 -2
  35. package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
  36. package/package.json +10 -12
@@ -66,10 +66,10 @@ function resolveGuardReason(rule, input) {
66
66
 
67
67
  // packages/experimental/src/coding-agent-reminders/io.ts
68
68
  async function readStdin() {
69
- const chunks = [];
70
- for await (const chunk of process.stdin) {
71
- chunks.push(Buffer.from(chunk));
72
- }
69
+ const chunks = await Array.fromAsync(
70
+ process.stdin,
71
+ (chunk) => Buffer.from(chunk)
72
+ );
73
73
  return Buffer.concat(chunks).toString("utf8");
74
74
  }
75
75
  function writeOutput(output) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/coding-agent-reminders/evaluate.ts", "../../src/coding-agent-reminders/io.ts", "../../src/coding-agent-reminders/predicates/classifier.ts", "../../src/coding-agent-reminders/predicates/combinators.ts", "../../src/coding-agent-reminders/context.ts", "../../src/coding-agent-reminders/predicates/content.ts", "../../src/coding-agent-reminders/predicates/count.ts", "../../src/coding-agent-reminders/predicates/environment.ts", "../../src/coding-agent-reminders/predicates/event.ts", "../../src/coding-agent-reminders/predicates/tool.ts"],
4
- "sourcesContent": ["import type {\n ClaudeHookInput,\n ClaudeHookOutput,\n GuardRule,\n ReminderHookConfig,\n ReminderRule,\n} from './types.ts';\n\nexport async function evaluateReminderHook(\n input: ClaudeHookInput,\n config: ReminderHookConfig,\n): Promise<ClaudeHookOutput | undefined> {\n const guardMatch =\n input.hook_event_name === 'PreToolUse'\n ? await firstMatchingGuard(input, config.guards)\n : undefined;\n if (guardMatch) {\n return {\n hookSpecificOutput: {\n hookEventName: input.hook_event_name,\n permissionDecision: 'deny',\n permissionDecisionReason:\n guardMatch.errorReason ?? resolveGuardReason(guardMatch.rule, input),\n },\n };\n }\n\n if (\n input.stop_hook_active === true &&\n (input.hook_event_name === 'Stop' ||\n input.hook_event_name === 'SubagentStop')\n ) {\n return undefined;\n }\n\n const reminders = await matchingReminders(input, config.reminders);\n if (reminders.length === 0) return undefined;\n\n return {\n hookSpecificOutput: {\n hookEventName: input.hook_event_name,\n additionalContext: reminders.join('\\n\\n'),\n },\n };\n}\n\nasync function firstMatchingGuard(\n input: ClaudeHookInput,\n guards: GuardRule[],\n): Promise<{ rule: GuardRule; errorReason?: string } | undefined> {\n for (const rule of guards) {\n try {\n if (await rule.when(input)) return { rule };\n } catch (error) {\n console.error(`Guard \"${rule.id}\" predicate failed`, error);\n return {\n rule,\n errorReason: `Guard \"${rule.id}\" failed to evaluate; denying by default.`,\n };\n }\n }\n return undefined;\n}\n\nasync function matchingReminders(\n input: ClaudeHookInput,\n reminders: ReminderRule[],\n): Promise<string[]> {\n const matched: string[] = [];\n for (const rule of reminders) {\n if (!rule.events.some((event) => event === input.hook_event_name)) continue;\n try {\n if (!(await rule.when(input))) continue;\n matched.push(\n `[${rule.target}:${rule.id}]\\n${resolveText(rule.message, input)}`,\n );\n } catch (error) {\n console.error(`Reminder \"${rule.id}\" evaluation failed`, error);\n }\n }\n return matched;\n}\n\nfunction resolveText(\n value: string | ((ctx: ClaudeHookInput) => string),\n input: ClaudeHookInput,\n): string {\n return typeof value === 'function' ? value(input) : value;\n}\n\nfunction resolveGuardReason(rule: GuardRule, input: ClaudeHookInput): string {\n try {\n return resolveText(rule.deny, input);\n } catch (error) {\n console.error(`Guard \"${rule.id}\" denial message failed`, error);\n return `Guard \"${rule.id}\" matched but its denial message failed; denying by default.`;\n }\n}\n", "import type { ClaudeHookOutput } from './types.ts';\n\nexport async function readStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(Buffer.from(chunk));\n }\n return Buffer.concat(chunks).toString('utf8');\n}\n\nexport function writeOutput(output: ClaudeHookOutput): void {\n process.stdout.write(`${JSON.stringify(output)}\\n`);\n}\n", "import { Corpus } from 'tiny-tfidf';\n\nimport type {\n ClassifierMatch,\n ClassifierOptions,\n IClassifier,\n} from '../types.ts';\n\nexport class BM25Classifier<\n T extends { name: string; description: string },\n> implements IClassifier<T> {\n #corpus: Corpus;\n #itemsByName: Map<string, T>;\n\n constructor(items: T[]) {\n const names = items.map((item) => item.name);\n const texts = items.map((item) => `${item.name} ${item.description}`);\n this.#corpus = new Corpus(names, texts);\n this.#itemsByName = new Map(items.map((item) => [item.name, item]));\n }\n\n match(query: string, options?: ClassifierOptions): ClassifierMatch<T>[] {\n const topN = options?.topN ?? 5;\n const threshold = options?.threshold ?? 0;\n\n return this.#corpus\n .getResultsForQuery(query)\n .filter(([, score]: [string, number]) => score > threshold)\n .slice(0, topN)\n .map(([name, score]: [string, number]) => {\n const item = this.#itemsByName.get(name);\n if (!item) return null;\n return { item, score };\n })\n .filter((match): match is ClassifierMatch<T> => match !== null);\n }\n}\n", "import type { AsyncHookPredicate, HookPredicate } from '../types.ts';\n\nexport const always: HookPredicate = () => true;\n\nexport const and =\n (...predicates: HookPredicate[]): AsyncHookPredicate =>\n async (ctx) => {\n for (const predicate of predicates) {\n if (!(await predicate(ctx))) return false;\n }\n return true;\n };\n\nexport const or =\n (...predicates: HookPredicate[]): AsyncHookPredicate =>\n async (ctx) => {\n for (const predicate of predicates) {\n if (await predicate(ctx)) return true;\n }\n return false;\n };\n\nexport const not =\n (predicate: HookPredicate): AsyncHookPredicate =>\n async (ctx) =>\n !(await predicate(ctx));\n", "import type { ClaudeHookInput, ToolCallState, ToolNameSpec } from './types.ts';\n\nexport type NormalizedToolCall = {\n name: string;\n state: ToolCallState;\n input?: unknown;\n output?: unknown;\n errorText?: string;\n};\n\nexport function contentText(ctx: ClaudeHookInput): string {\n return [ctx.prompt, ctx.command_name, ctx.command_args]\n .filter((value): value is string => typeof value === 'string')\n .join(' ');\n}\n\nexport function bashCommand(ctx: ClaudeHookInput): string {\n if (ctx.tool_name !== 'Bash') return '';\n const command = ctx.tool_input?.command;\n return typeof command === 'string' ? command : '';\n}\n\nexport function outputText(ctx: ClaudeHookInput): string {\n if (ctx.hook_event_name === 'PostToolBatch' && ctx.tool_calls) {\n return ctx.tool_calls\n .map((call) => textOf(call.tool_response))\n .filter(Boolean)\n .join('\\n');\n }\n const output = ctx.tool_output ?? ctx.tool_response;\n return textOf(output);\n}\n\nexport function textOf(value: unknown): string {\n if (typeof value === 'string') return value;\n if (value === undefined) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nexport function toolCallsOf(ctx: ClaudeHookInput): NormalizedToolCall[] {\n if (ctx.hook_event_name === 'PostToolBatch' && ctx.tool_calls) {\n return ctx.tool_calls.map((call) => ({\n name: call.tool_name,\n state: 'output-available',\n input: call.tool_input,\n output: call.tool_response,\n }));\n }\n\n const calls: NormalizedToolCall[] = [];\n const toolName = ctx.tool_name;\n if (typeof toolName === 'string') {\n calls.push({\n name: toolName,\n state: stateOf(ctx.hook_event_name),\n input: ctx.tool_input,\n output: ctx.tool_output ?? ctx.tool_response,\n errorText: errorTextOf(ctx),\n });\n }\n return calls;\n}\n\nexport function matchesName(spec: ToolNameSpec, name: string): boolean {\n return typeof spec === 'function' ? spec(name) : spec === name;\n}\n\nfunction stateOf(eventName: string): ToolCallState {\n if (eventName === 'PostToolUseFailure') return 'output-error';\n if (eventName === 'PostToolUse') return 'output-available';\n return 'input-available';\n}\n\nfunction errorTextOf(ctx: ClaudeHookInput): string {\n const error =\n ctx.tool_error ??\n ctx.error ??\n ctx.reason ??\n ctx.tool_output ??\n ctx.tool_response;\n return textOf(error);\n}\n", "import { contentText } from '../context.ts';\nimport type {\n ClassifierOptions,\n ContentMatchesOptions,\n HookPredicate,\n IClassifier,\n} from '../types.ts';\nimport { BM25Classifier } from './classifier.ts';\n\nexport function contentMatches(\n topics: string[],\n options?: ContentMatchesOptions,\n): HookPredicate {\n const classifier = new BM25Classifier(\n topics.map((topic, index) => ({\n name: `t${index}`,\n description: topic,\n })),\n );\n return (ctx) =>\n classifier.match(contentText(ctx), {\n threshold: options?.threshold,\n }).length > 0;\n}\n\nexport function classifies<T>(\n classifier: IClassifier<T>,\n options?: ClassifierOptions,\n): HookPredicate {\n return (ctx) => classifier.match(contentText(ctx), options).length > 0;\n}\n\nexport function contentIncludes(keywords: string[]): HookPredicate {\n const lower = keywords.map((keyword) => keyword.toLowerCase());\n return (ctx) => {\n const text = contentText(ctx).toLowerCase();\n return lower.some((keyword) => text.includes(keyword));\n };\n}\n\nexport const contentPattern =\n (pattern: RegExp): HookPredicate =>\n (ctx) => {\n pattern.lastIndex = 0;\n return pattern.test(contentText(ctx));\n };\n\nexport const promptMatches = contentPattern;\n", "import type { CountSpec } from '../types.ts';\n\nexport function assertCountSpec(spec: CountSpec): void {\n const hasEq = spec.eq !== undefined;\n const hasRange = spec.gte !== undefined || spec.lte !== undefined;\n if (!hasEq && !hasRange) {\n throw new Error('CountSpec must include at least one of gte/lte/eq');\n }\n if (hasEq && hasRange) {\n throw new Error('CountSpec.eq cannot be combined with gte/lte');\n }\n}\n\nexport function checkCount(count: number, spec: CountSpec): boolean {\n if (spec.eq !== undefined) return count === spec.eq;\n if (spec.gte !== undefined && count < spec.gte) return false;\n if (spec.lte !== undefined && count > spec.lte) return false;\n return true;\n}\n", "import type { HookPredicate } from '../types.ts';\n\nexport const envFlag =\n (name: string): HookPredicate =>\n () =>\n process.env[name] === '1' || process.env[name] === 'true';\n", "import type { HookEventName, HookPredicate } from '../types.ts';\n\nexport const eventIs =\n (...events: HookEventName[]): HookPredicate =>\n (ctx) =>\n events.some((event) => event === ctx.hook_event_name);\n", "import {\n bashCommand,\n matchesName,\n outputText,\n textOf,\n toolCallsOf,\n} from '../context.ts';\nimport type {\n CountSpec,\n HookPredicate,\n ToolCallOptions,\n ToolNameSpec,\n} from '../types.ts';\nimport { assertCountSpec, checkCount } from './count.ts';\n\nexport const toolIs =\n (name: string): HookPredicate =>\n (ctx) =>\n ctx.tool_name === name;\n\nexport const bashCommandMatches =\n (pattern: RegExp): HookPredicate =>\n (ctx) => {\n pattern.lastIndex = 0;\n return pattern.test(bashCommand(ctx));\n };\n\nexport function toolCall(options: ToolCallOptions): HookPredicate {\n return (ctx) => {\n return toolCallsOf(ctx).some((call) => {\n if (options.state && call.state !== options.state) return false;\n if (options.name !== undefined && !matchesName(options.name, call.name)) {\n return false;\n }\n if (options.input && !options.input(call.input)) return false;\n if (options.output) {\n if (call.state !== 'output-available') return false;\n if (!options.output(call.output)) return false;\n }\n if (options.errorText) {\n if (call.state !== 'output-error') return false;\n if (!options.errorText(call.errorText ?? '')) return false;\n }\n return true;\n });\n };\n}\n\nexport function toolCalled(name: ToolNameSpec): HookPredicate {\n return toolCall({ name });\n}\n\nexport function toolFailed(name: ToolNameSpec): HookPredicate {\n return toolCall({ name, state: 'output-error' });\n}\n\nexport function anyToolCalled(): HookPredicate {\n return (ctx) => toolCallsOf(ctx).length > 0;\n}\n\nexport function toolCallCount(\n name: ToolNameSpec,\n spec: CountSpec,\n): HookPredicate {\n assertCountSpec(spec);\n return (ctx) =>\n checkCount(\n toolCallsOf(ctx).filter((call) => matchesName(name, call.name)).length,\n spec,\n );\n}\n\nexport const outputMatches =\n (pattern: RegExp): HookPredicate =>\n (ctx) => {\n pattern.lastIndex = 0;\n return pattern.test(outputText(ctx));\n };\n\nexport const toolOutputMatches = (pattern: RegExp): HookPredicate =>\n toolCall({\n output: (output) => {\n pattern.lastIndex = 0;\n return pattern.test(textOf(output));\n },\n });\n"],
5
- "mappings": ";AAQA,eAAsB,qBACpB,OACA,QACuC;AACvC,QAAM,aACJ,MAAM,oBAAoB,eACtB,MAAM,mBAAmB,OAAO,OAAO,MAAM,IAC7C;AACN,MAAI,YAAY;AACd,WAAO;AAAA,MACL,oBAAoB;AAAA,QAClB,eAAe,MAAM;AAAA,QACrB,oBAAoB;AAAA,QACpB,0BACE,WAAW,eAAe,mBAAmB,WAAW,MAAM,KAAK;AAAA,MACvE;AAAA,IACF;AAAA,EACF;AAEA,M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Q,MAAM,KAAK,IAAI,GAAG;AACvE,eAAO;AAAA,MACT;AACA,UAAI,QAAQ,SAAS,CAAC,QAAQ,MAAM,KAAK,KAAK,EAAG,QAAO;AACxD,UAAI,QAAQ,QAAQ;AAClB,YAAI,KAAK,UAAU,mBAAoB,QAAO;AAC9C,YAAI,CAAC,QAAQ,OAAO,KAAK,MAAM,EAAG,QAAO;AAAA,MAC3C;AACA,UAAI,QAAQ,WAAW;AACrB,YAAI,KAAK,UAAU,eAAgB,QAAO;AAC1C,YAAI,CAAC,QAAQ,UAAU,KAAK,aAAa,EAAE,EAAG,QAAO;AAAA,MACvD;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;AAEO,SAAS,WAAW,MAAmC;AAC5D,SAAO,SAAS,EAAE,KAAK,CAAC;AAC1B;AAEO,SAAS,WAAW,MAAmC;AAC5D,SAAO,SAAS,EAAE,MAAM,OAAO,eAAe,CAAC;AACjD;AAEO,SAAS,gBAA+B;AAC7C,SAAO,CAAC,QAAQ,YAAY,GAAG,EAAE,SAAS;AAC5C;AAEO,SAAS,cACd,MACA,MACe;AACf,kBAAgB,IAAI;AACpB,SAAO,CAAC,QACN;AAAA,IACE,YAAY,GAAG,EAAE,OAAO,CAAC,SAAS,YAAY,MAAM,KAAK,IAAI,CAAC,EAAE;AAAA,IAChE;AAAA,EACF;AACJ;AAEO,IAAM,gBACX,CAAC,YACD,CAAC,QAAQ;AACP,UAAQ,YAAY;AACpB,SAAO,QAAQ,KAAK,WAAW,GAAG,CAAC;AACrC;AAEK,IAAM,oBAAoB,CAAC,YAChC,SAAS;AAAA,EACP,QAAQ,CAAC,WAAW;AAClB,YAAQ,YAAY;AACpB,WAAO,QAAQ,KAAK,OAAO,MAAM,CAAC;AAAA,EACpC;AACF,CAAC;",
4
+ "sourcesContent": ["import type {\n ClaudeHookInput,\n ClaudeHookOutput,\n GuardRule,\n ReminderHookConfig,\n ReminderRule,\n} from './types.ts';\n\nexport async function evaluateReminderHook(\n input: ClaudeHookInput,\n config: ReminderHookConfig,\n): Promise<ClaudeHookOutput | undefined> {\n const guardMatch =\n input.hook_event_name === 'PreToolUse'\n ? await firstMatchingGuard(input, config.guards)\n : undefined;\n if (guardMatch) {\n return {\n hookSpecificOutput: {\n hookEventName: input.hook_event_name,\n permissionDecision: 'deny',\n permissionDecisionReason:\n guardMatch.errorReason ?? resolveGuardReason(guardMatch.rule, input),\n },\n };\n }\n\n if (\n input.stop_hook_active === true &&\n (input.hook_event_name === 'Stop' ||\n input.hook_event_name === 'SubagentStop')\n ) {\n return undefined;\n }\n\n const reminders = await matchingReminders(input, config.reminders);\n if (reminders.length === 0) return undefined;\n\n return {\n hookSpecificOutput: {\n hookEventName: input.hook_event_name,\n additionalContext: reminders.join('\\n\\n'),\n },\n };\n}\n\nasync function firstMatchingGuard(\n input: ClaudeHookInput,\n guards: GuardRule[],\n): Promise<{ rule: GuardRule; errorReason?: string } | undefined> {\n for (const rule of guards) {\n try {\n if (await rule.when(input)) return { rule };\n } catch (error) {\n console.error(`Guard \"${rule.id}\" predicate failed`, error);\n return {\n rule,\n errorReason: `Guard \"${rule.id}\" failed to evaluate; denying by default.`,\n };\n }\n }\n return undefined;\n}\n\nasync function matchingReminders(\n input: ClaudeHookInput,\n reminders: ReminderRule[],\n): Promise<string[]> {\n const matched: string[] = [];\n for (const rule of reminders) {\n if (!rule.events.some((event) => event === input.hook_event_name)) continue;\n try {\n if (!(await rule.when(input))) continue;\n matched.push(\n `[${rule.target}:${rule.id}]\\n${resolveText(rule.message, input)}`,\n );\n } catch (error) {\n console.error(`Reminder \"${rule.id}\" evaluation failed`, error);\n }\n }\n return matched;\n}\n\nfunction resolveText(\n value: string | ((ctx: ClaudeHookInput) => string),\n input: ClaudeHookInput,\n): string {\n return typeof value === 'function' ? value(input) : value;\n}\n\nfunction resolveGuardReason(rule: GuardRule, input: ClaudeHookInput): string {\n try {\n return resolveText(rule.deny, input);\n } catch (error) {\n console.error(`Guard \"${rule.id}\" denial message failed`, error);\n return `Guard \"${rule.id}\" matched but its denial message failed; denying by default.`;\n }\n}\n", "import type { ClaudeHookOutput } from './types.ts';\n\nexport async function readStdin(): Promise<string> {\n const chunks = await Array.fromAsync(process.stdin, (chunk) =>\n Buffer.from(chunk),\n );\n return Buffer.concat(chunks).toString('utf8');\n}\n\nexport function writeOutput(output: ClaudeHookOutput): void {\n process.stdout.write(`${JSON.stringify(output)}\\n`);\n}\n", "import { Corpus } from 'tiny-tfidf';\n\nimport type {\n ClassifierMatch,\n ClassifierOptions,\n IClassifier,\n} from '../types.ts';\n\nexport class BM25Classifier<\n T extends { name: string; description: string },\n> implements IClassifier<T> {\n #corpus: Corpus;\n #itemsByName: Map<string, T>;\n\n constructor(items: T[]) {\n const names = items.map((item) => item.name);\n const texts = items.map((item) => `${item.name} ${item.description}`);\n this.#corpus = new Corpus(names, texts);\n this.#itemsByName = new Map(items.map((item) => [item.name, item]));\n }\n\n match(query: string, options?: ClassifierOptions): ClassifierMatch<T>[] {\n const topN = options?.topN ?? 5;\n const threshold = options?.threshold ?? 0;\n\n return this.#corpus\n .getResultsForQuery(query)\n .filter(([, score]: [string, number]) => score > threshold)\n .slice(0, topN)\n .map(([name, score]: [string, number]) => {\n const item = this.#itemsByName.get(name);\n if (!item) return null;\n return { item, score };\n })\n .filter((match): match is ClassifierMatch<T> => match !== null);\n }\n}\n", "import type { AsyncHookPredicate, HookPredicate } from '../types.ts';\n\nexport const always: HookPredicate = () => true;\n\nexport const and =\n (...predicates: HookPredicate[]): AsyncHookPredicate =>\n async (ctx) => {\n for (const predicate of predicates) {\n if (!(await predicate(ctx))) return false;\n }\n return true;\n };\n\nexport const or =\n (...predicates: HookPredicate[]): AsyncHookPredicate =>\n async (ctx) => {\n for (const predicate of predicates) {\n if (await predicate(ctx)) return true;\n }\n return false;\n };\n\nexport const not =\n (predicate: HookPredicate): AsyncHookPredicate =>\n async (ctx) =>\n !(await predicate(ctx));\n", "import type { ClaudeHookInput, ToolCallState, ToolNameSpec } from './types.ts';\n\nexport type NormalizedToolCall = {\n name: string;\n state: ToolCallState;\n input?: unknown;\n output?: unknown;\n errorText?: string;\n};\n\nexport function contentText(ctx: ClaudeHookInput): string {\n return [ctx.prompt, ctx.command_name, ctx.command_args]\n .filter((value): value is string => typeof value === 'string')\n .join(' ');\n}\n\nexport function bashCommand(ctx: ClaudeHookInput): string {\n if (ctx.tool_name !== 'Bash') return '';\n const command = ctx.tool_input?.command;\n return typeof command === 'string' ? command : '';\n}\n\nexport function outputText(ctx: ClaudeHookInput): string {\n if (ctx.hook_event_name === 'PostToolBatch' && ctx.tool_calls) {\n return ctx.tool_calls\n .map((call) => textOf(call.tool_response))\n .filter(Boolean)\n .join('\\n');\n }\n const output = ctx.tool_output ?? ctx.tool_response;\n return textOf(output);\n}\n\nexport function textOf(value: unknown): string {\n if (typeof value === 'string') return value;\n if (value === undefined) return '';\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nexport function toolCallsOf(ctx: ClaudeHookInput): NormalizedToolCall[] {\n if (ctx.hook_event_name === 'PostToolBatch' && ctx.tool_calls) {\n return ctx.tool_calls.map((call) => ({\n name: call.tool_name,\n state: 'output-available',\n input: call.tool_input,\n output: call.tool_response,\n }));\n }\n\n const calls: NormalizedToolCall[] = [];\n const toolName = ctx.tool_name;\n if (typeof toolName === 'string') {\n calls.push({\n name: toolName,\n state: stateOf(ctx.hook_event_name),\n input: ctx.tool_input,\n output: ctx.tool_output ?? ctx.tool_response,\n errorText: errorTextOf(ctx),\n });\n }\n return calls;\n}\n\nexport function matchesName(spec: ToolNameSpec, name: string): boolean {\n return typeof spec === 'function' ? spec(name) : spec === name;\n}\n\nfunction stateOf(eventName: string): ToolCallState {\n if (eventName === 'PostToolUseFailure') return 'output-error';\n if (eventName === 'PostToolUse') return 'output-available';\n return 'input-available';\n}\n\nfunction errorTextOf(ctx: ClaudeHookInput): string {\n const error =\n ctx.tool_error ??\n ctx.error ??\n ctx.reason ??\n ctx.tool_output ??\n ctx.tool_response;\n return textOf(error);\n}\n", "import { contentText } from '../context.ts';\nimport type {\n ClassifierOptions,\n ContentMatchesOptions,\n HookPredicate,\n IClassifier,\n} from '../types.ts';\nimport { BM25Classifier } from './classifier.ts';\n\nexport function contentMatches(\n topics: string[],\n options?: ContentMatchesOptions,\n): HookPredicate {\n const classifier = new BM25Classifier(\n topics.map((topic, index) => ({\n name: `t${index}`,\n description: topic,\n })),\n );\n return (ctx) =>\n classifier.match(contentText(ctx), {\n threshold: options?.threshold,\n }).length > 0;\n}\n\nexport function classifies<T>(\n classifier: IClassifier<T>,\n options?: ClassifierOptions,\n): HookPredicate {\n return (ctx) => classifier.match(contentText(ctx), options).length > 0;\n}\n\nexport function contentIncludes(keywords: string[]): HookPredicate {\n const lower = keywords.map((keyword) => keyword.toLowerCase());\n return (ctx) => {\n const text = contentText(ctx).toLowerCase();\n return lower.some((keyword) => text.includes(keyword));\n };\n}\n\nexport const contentPattern =\n (pattern: RegExp): HookPredicate =>\n (ctx) => {\n pattern.lastIndex = 0;\n return pattern.test(contentText(ctx));\n };\n\nexport const promptMatches = contentPattern;\n", "import type { CountSpec } from '../types.ts';\n\nexport function assertCountSpec(spec: CountSpec): void {\n const hasEq = spec.eq !== undefined;\n const hasRange = spec.gte !== undefined || spec.lte !== undefined;\n if (!hasEq && !hasRange) {\n throw new Error('CountSpec must include at least one of gte/lte/eq');\n }\n if (hasEq && hasRange) {\n throw new Error('CountSpec.eq cannot be combined with gte/lte');\n }\n}\n\nexport function checkCount(count: number, spec: CountSpec): boolean {\n if (spec.eq !== undefined) return count === spec.eq;\n if (spec.gte !== undefined && count < spec.gte) return false;\n if (spec.lte !== undefined && count > spec.lte) return false;\n return true;\n}\n", "import type { HookPredicate } from '../types.ts';\n\nexport const envFlag =\n (name: string): HookPredicate =>\n () =>\n process.env[name] === '1' || process.env[name] === 'true';\n", "import type { HookEventName, HookPredicate } from '../types.ts';\n\nexport const eventIs =\n (...events: HookEventName[]): HookPredicate =>\n (ctx) =>\n events.some((event) => event === ctx.hook_event_name);\n", "import {\n bashCommand,\n matchesName,\n outputText,\n textOf,\n toolCallsOf,\n} from '../context.ts';\nimport type {\n CountSpec,\n HookPredicate,\n ToolCallOptions,\n ToolNameSpec,\n} from '../types.ts';\nimport { assertCountSpec, checkCount } from './count.ts';\n\nexport const toolIs =\n (name: string): HookPredicate =>\n (ctx) =>\n ctx.tool_name === name;\n\nexport const bashCommandMatches =\n (pattern: RegExp): HookPredicate =>\n (ctx) => {\n pattern.lastIndex = 0;\n return pattern.test(bashCommand(ctx));\n };\n\nexport function toolCall(options: ToolCallOptions): HookPredicate {\n return (ctx) => {\n return toolCallsOf(ctx).some((call) => {\n if (options.state && call.state !== options.state) return false;\n if (options.name !== undefined && !matchesName(options.name, call.name)) {\n return false;\n }\n if (options.input && !options.input(call.input)) return false;\n if (options.output) {\n if (call.state !== 'output-available') return false;\n if (!options.output(call.output)) return false;\n }\n if (options.errorText) {\n if (call.state !== 'output-error') return false;\n if (!options.errorText(call.errorText ?? '')) return false;\n }\n return true;\n });\n };\n}\n\nexport function toolCalled(name: ToolNameSpec): HookPredicate {\n return toolCall({ name });\n}\n\nexport function toolFailed(name: ToolNameSpec): HookPredicate {\n return toolCall({ name, state: 'output-error' });\n}\n\nexport function anyToolCalled(): HookPredicate {\n return (ctx) => toolCallsOf(ctx).length > 0;\n}\n\nexport function toolCallCount(\n name: ToolNameSpec,\n spec: CountSpec,\n): HookPredicate {\n assertCountSpec(spec);\n return (ctx) =>\n checkCount(\n toolCallsOf(ctx).filter((call) => matchesName(name, call.name)).length,\n spec,\n );\n}\n\nexport const outputMatches =\n (pattern: RegExp): HookPredicate =>\n (ctx) => {\n pattern.lastIndex = 0;\n return pattern.test(outputText(ctx));\n };\n\nexport const toolOutputMatches = (pattern: RegExp): HookPredicate =>\n toolCall({\n output: (output) => {\n pattern.lastIndex = 0;\n return pattern.test(textOf(output));\n },\n });\n"],
5
+ "mappings": ";AAQA,eAAsB,qBACpB,OACA,QACuC;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,YAChC,SAAS;AAAA,EACP,QAAQ,CAAC,WAAW;AAClB,YAAQ,YAAY;AACpB,WAAO,QAAQ,KAAK,OAAO,MAAM,CAAC;AAAA,EACpC;AACF,CAAC;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/coding-agent-reminders/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAMjD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAE1D"}
1
+ {"version":3,"file":"io.d.ts","sourceRoot":"","sources":["../../src/coding-agent-reminders/io.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAKjD;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAE1D"}
package/dist/index.js CHANGED
@@ -103,10 +103,10 @@ function resolveGuardReason(rule, input) {
103
103
 
104
104
  // packages/experimental/src/coding-agent-reminders/io.ts
105
105
  async function readStdin() {
106
- const chunks = [];
107
- for await (const chunk of process.stdin) {
108
- chunks.push(Buffer.from(chunk));
109
- }
106
+ const chunks = await Array.fromAsync(
107
+ process.stdin,
108
+ (chunk) => Buffer.from(chunk)
109
+ );
110
110
  return Buffer.concat(chunks).toString("utf8");
111
111
  }
112
112
  function writeOutput(output) {
@@ -533,13 +533,12 @@ function defineInstructions(...fragments) {
533
533
 
534
534
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
535
535
  import { Declaration } from "@zukhruf/sqlite-drift";
536
+ import { open } from "@zukhruf/sqlite-open";
536
537
  import { transaction } from "@zukhruf/sqlite-transaction";
537
- import { DatabaseSync } from "node:sqlite";
538
538
  import { z } from "zod";
539
539
 
540
540
  // packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
541
541
  var SETUP = `
542
- PRAGMA journal_mode = WAL;
543
542
  PRAGMA synchronous = NORMAL;
544
543
  `;
545
544
  var statements = [
@@ -623,7 +622,6 @@ function assertConversationId(value, label) {
623
622
 
624
623
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
625
624
  var tables = new Declaration(statements, { rows: "keep" });
626
- var BUSY_TIMEOUT_MS = 5e3;
627
625
  var conversationIdSchema = z.object({
628
626
  chatId: z.string(),
629
627
  userId: z.string()
@@ -648,7 +646,7 @@ var SqliteMailboxStore = class extends MailboxStore {
648
646
  #database;
649
647
  constructor(path3) {
650
648
  super();
651
- this.#database = new DatabaseSync(path3, { timeout: BUSY_TIMEOUT_MS });
649
+ this.#database = open(path3);
652
650
  this.#database.exec(SETUP);
653
651
  tables.apply(this.#database);
654
652
  }
@@ -2415,12 +2413,12 @@ function replacementRange(messages, keepLastMessages) {
2415
2413
  while (messages[start]?.role === "system") start++;
2416
2414
  let limit = messages.length - keepLastMessages;
2417
2415
  const links = /* @__PURE__ */ new Map();
2418
- const link = (key, index, open) => {
2416
+ const link = (key, index, open2) => {
2419
2417
  const previous = links.get(key);
2420
2418
  links.set(key, {
2421
2419
  first: previous?.first ?? index,
2422
2420
  last: index,
2423
- open: open ?? previous?.open ?? false
2421
+ open: open2 ?? previous?.open ?? false
2424
2422
  });
2425
2423
  };
2426
2424
  for (const [index, message] of messages.entries()) {
@@ -2449,8 +2447,8 @@ function replacementRange(messages, keepLastMessages) {
2449
2447
  }
2450
2448
  }
2451
2449
  const crossings = new Int32Array(messages.length + 1);
2452
- for (const { first, last, open } of links.values()) {
2453
- if (open) limit = Math.min(limit, first);
2450
+ for (const { first, last, open: open2 } of links.values()) {
2451
+ if (open2) limit = Math.min(limit, first);
2454
2452
  crossings[first + 1]++;
2455
2453
  crossings[last + 1]--;
2456
2454
  }
@@ -2541,7 +2539,7 @@ ${options.instructions}` : SUMMARY_PROMPT,
2541
2539
  abortSignal
2542
2540
  });
2543
2541
  abortSignal?.throwIfAborted();
2544
- const usage = generated.totalUsage;
2542
+ const { usage } = generated;
2545
2543
  if (generated.finishReason !== "stop" || generated.content.some(
2546
2544
  (part) => part.type !== "text" && part.type !== "reasoning"
2547
2545
  )) {
@@ -3158,6 +3156,7 @@ var AgentTurnExecutor = class {
3158
3156
  reasoning: declaration.reasoning,
3159
3157
  maxOutputTokens: declaration.maxOutputTokens,
3160
3158
  timeout: declaration.timeout,
3159
+ stopWhen: declaration.stopWhen,
3161
3160
  toolCallConcurrency: declaration.toolCallConcurrency,
3162
3161
  experimental_toolApprovalSecret: declaration.experimental_toolApprovalSecret,
3163
3162
  sandbox,