@code-yeongyu/senpi 2026.8.11-2 → 2026.8.11-3
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 +66 -1
- package/dist/cli-main.d.ts +1 -1
- package/dist/cli-main.d.ts.map +1 -1
- package/dist/cli-main.js +1 -0
- package/dist/cli-main.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -0
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-session.d.ts +8 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +63 -7
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts +2 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.d.ts.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js +24 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/availability.js.map +1 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts +4 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.js +5 -2
- package/dist/core/extensions/builtin/claude-sdk-oauth/index.js.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts +6 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.d.ts.map +1 -1
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js +16 -0
- package/dist/core/extensions/builtin/claude-sdk-oauth/oauth-login.js.map +1 -1
- package/dist/core/extensions/builtin/goal/transitions.js +2 -1
- package/dist/core/extensions/builtin/goal/transitions.js.map +1 -1
- package/dist/core/extensions/builtin/imagegen/auth.d.ts +45 -0
- package/dist/core/extensions/builtin/imagegen/auth.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/auth.js +137 -0
- package/dist/core/extensions/builtin/imagegen/auth.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/index.d.ts +5 -0
- package/dist/core/extensions/builtin/imagegen/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/index.js +46 -0
- package/dist/core/extensions/builtin/imagegen/index.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/paths.d.ts +26 -0
- package/dist/core/extensions/builtin/imagegen/paths.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/paths.js +52 -0
- package/dist/core/extensions/builtin/imagegen/paths.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/skill/SKILL.md +67 -0
- package/dist/core/extensions/builtin/imagegen/state.d.ts +26 -0
- package/dist/core/extensions/builtin/imagegen/state.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/state.js +35 -0
- package/dist/core/extensions/builtin/imagegen/state.js.map +1 -0
- package/dist/core/extensions/builtin/imagegen/tool.d.ts +31 -0
- package/dist/core/extensions/builtin/imagegen/tool.d.ts.map +1 -0
- package/dist/core/extensions/builtin/imagegen/tool.js +174 -0
- package/dist/core/extensions/builtin/imagegen/tool.js.map +1 -0
- package/dist/core/extensions/builtin/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/index.js +9 -1
- package/dist/core/extensions/builtin/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/control-inventory.d.ts +14 -0
- package/dist/core/extensions/builtin/mcp/control-inventory.d.ts.map +1 -0
- package/dist/core/extensions/builtin/mcp/control-inventory.js +22 -0
- package/dist/core/extensions/builtin/mcp/control-inventory.js.map +1 -0
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts +2 -44
- package/dist/core/extensions/builtin/mcp/expose/native-search.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/native-search.js +3 -97
- package/dist/core/extensions/builtin/mcp/expose/native-search.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/proxy.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/proxy.js +15 -4
- package/dist/core/extensions/builtin/mcp/expose/proxy.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts +2 -1
- package/dist/core/extensions/builtin/mcp/expose/session.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/session.js +2 -2
- package/dist/core/extensions/builtin/mcp/expose/session.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts +13 -11
- package/dist/core/extensions/builtin/mcp/expose/tier-b.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js +58 -59
- package/dist/core/extensions/builtin/mcp/expose/tier-b.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/index.js +28 -36
- package/dist/core/extensions/builtin/mcp/index.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.d.ts +2 -1
- package/dist/core/extensions/builtin/mcp/service-register.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-register.js +2 -2
- package/dist/core/extensions/builtin/mcp/service-register.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.d.ts +4 -0
- package/dist/core/extensions/builtin/mcp/service-types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service-types.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.d.ts +6 -11
- package/dist/core/extensions/builtin/mcp/service.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/service.js +79 -41
- package/dist/core/extensions/builtin/mcp/service.js.map +1 -1
- package/dist/core/extensions/builtin/mcp/wrap.d.ts +2 -0
- package/dist/core/extensions/builtin/mcp/wrap.d.ts.map +1 -1
- package/dist/core/extensions/builtin/mcp/wrap.js +3 -0
- package/dist/core/extensions/builtin/mcp/wrap.js.map +1 -1
- package/dist/core/extensions/builtin/openai-image-gen/externalize.d.ts +27 -0
- package/dist/core/extensions/builtin/openai-image-gen/externalize.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/externalize.js +133 -0
- package/dist/core/extensions/builtin/openai-image-gen/externalize.js.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.d.ts +21 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.js +63 -0
- package/dist/core/extensions/builtin/openai-image-gen/gate.js.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.d.ts +14 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.js +77 -0
- package/dist/core/extensions/builtin/openai-image-gen/index.js.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.d.ts +15 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.d.ts.map +1 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.js +42 -0
- package/dist/core/extensions/builtin/openai-image-gen/inject.js.map +1 -0
- package/dist/core/extensions/builtin/terminal/monitor-notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js +8 -1
- package/dist/core/extensions/builtin/terminal/monitor-notify.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts +3 -1
- package/dist/core/extensions/builtin/terminal/notify.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/notify.js +4 -1
- package/dist/core/extensions/builtin/terminal/notify.js.map +1 -1
- package/dist/core/extensions/builtin/tool-search/engine/bm25.d.ts +22 -0
- package/dist/core/extensions/builtin/tool-search/engine/bm25.d.ts.map +1 -0
- package/dist/core/extensions/builtin/{mcp/expose → tool-search/engine}/bm25.js +16 -31
- package/dist/core/extensions/builtin/tool-search/engine/bm25.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.d.ts +14 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.js +2 -0
- package/dist/core/extensions/builtin/tool-search/engine/document.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.d.ts +55 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.js +189 -0
- package/dist/core/extensions/builtin/tool-search/engine/marker.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/index.d.ts +7 -0
- package/dist/core/extensions/builtin/tool-search/index.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/index.js +71 -0
- package/dist/core/extensions/builtin/tool-search/index.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts +52 -0
- package/dist/core/extensions/builtin/tool-search/native-search.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/native-search.js +116 -0
- package/dist/core/extensions/builtin/tool-search/native-search.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/service.d.ts +38 -0
- package/dist/core/extensions/builtin/tool-search/service.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/service.js +200 -0
- package/dist/core/extensions/builtin/tool-search/service.js.map +1 -0
- package/dist/core/extensions/builtin/tool-search/tool.d.ts +21 -0
- package/dist/core/extensions/builtin/tool-search/tool.d.ts.map +1 -0
- package/dist/core/extensions/builtin/tool-search/tool.js +95 -0
- package/dist/core/extensions/builtin/tool-search/tool.js.map +1 -0
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +3 -0
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +44 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js +11 -0
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/provider-composer.d.ts +10 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +9 -0
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/modes/provider-native-rendering.d.ts.map +1 -1
- package/dist/modes/provider-native-rendering.js +33 -0
- package/dist/modes/provider-native-rendering.js.map +1 -1
- package/dist/modes/rpc/connection-handler.d.ts.map +1 -1
- package/dist/modes/rpc/connection-handler.js +130 -4
- package/dist/modes/rpc/connection-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +31 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/senpi +1 -0
- package/dist/valid-cwd.d.ts +2 -0
- package/dist/valid-cwd.d.ts.map +1 -0
- package/dist/valid-cwd.js +14 -0
- package/dist/valid-cwd.js.map +1 -0
- package/docs/environment-variables.md +7 -0
- package/docs/extensions.md +50 -13
- package/docs/mcp.md +2 -0
- package/docs/rpc.md +54 -0
- package/docs/skills.md +8 -0
- package/examples/extensions/searchable-tools.ts +49 -0
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +5 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts +4 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js +2 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/agent.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts +9 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +2 -2
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js +7 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts +8 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js +222 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.js +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-images.lazy.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js +113 -4
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses-shared.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts +10 -0
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/auth/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts +32 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js +32 -0
- package/node_modules/@earendil-works/pi-ai/dist/image-models.generated.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/models.js +36 -13
- package/node_modules/@earendil-works/pi-ai/dist/models.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts +2 -0
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/openai-responses-compat.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/all.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/amazon-bedrock.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/google.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/opencode.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js +18 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/images/register-builtins.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.d.ts +3 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.d.ts.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.js +16 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/openai-images.js.map +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/retry.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +1 -1
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +8 -8
- package/dist/core/extensions/builtin/mcp/expose/bm25.d.ts +0 -30
- package/dist/core/extensions/builtin/mcp/expose/bm25.d.ts.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/bm25.js.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.d.ts +0 -15
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.d.ts.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.js +0 -33
- package/dist/core/extensions/builtin/mcp/expose/lazy-activate.js.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts +0 -43
- package/dist/core/extensions/builtin/mcp/expose/tool-search.d.ts.map +0 -1
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js +0 -125
- package/dist/core/extensions/builtin/mcp/expose/tool-search.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1D,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC;AAC5D,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAIlC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CA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CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;IACpD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO;QACN,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC;KACvG,CAAC;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,QAAgB;IACxD,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC7C,OAAO,YAAY,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC9G,CAAC","sourcesContent":["import { isAbsolute, relative, resolve } from \"node:path\";\n\nexport const GENERATED_IMAGE_DIRECTORY = \"generated-images\";\nconst DEFAULT_DIRECTORY = GENERATED_IMAGE_DIRECTORY;\nconst MAX_TOOL_CALL_ID_CHARS = 64;\n\nexport type TargetPaths = { ok: true; paths: string[] } | { ok: false; error: string };\n\n/**\n * Reduces a provider-supplied identifier to a safe file stem: path separators and\n * any other unexpected character collapse to `_`, the result is length-capped, and\n * an identifier that sanitizes to nothing falls back to `image`.\n */\nexport function sanitizeImageStem(identifier: string): string {\n\tconst sanitized = identifier.replace(/[^A-Za-z0-9_-]/g, \"_\").slice(0, MAX_TOOL_CALL_ID_CHARS);\n\treturn sanitized.length > 0 ? sanitized : \"image\";\n}\n\nfunction sanitizeToolCallId(toolCallId: string): string {\n\treturn sanitizeImageStem(toolCallId);\n}\n\n/**\n * Resolves the absolute destination paths for a generation call.\n *\n * A relative output_path resolves against the working directory. An omitted path\n * falls back to generated-images/<sanitized tool call id>.png. An extensionless\n * path gains .png; any other extension is rejected. With more than one image a\n * zero-padded index is inserted before the extension.\n */\nexport function resolveTargets(\n\tcwd: string,\n\ttoolCallId: string,\n\tcount: number,\n\toutputPath: string | undefined,\n): TargetPaths {\n\tconst requested = outputPath?.trim();\n\tlet base: string;\n\tif (requested === undefined || requested.length === 0) {\n\t\tbase = resolve(cwd, DEFAULT_DIRECTORY, `${sanitizeToolCallId(toolCallId)}.png`);\n\t} else {\n\t\tconst absolute = isAbsolute(requested) ? requested : resolve(cwd, requested);\n\t\tconst extensionMatch = /\\.[^./\\\\]+$/.exec(absolute);\n\t\tif (extensionMatch && extensionMatch[0].toLowerCase() !== \".png\") {\n\t\t\treturn { ok: false, error: `Error: output_path must end in .png (got \"${requested}\").` };\n\t\t}\n\t\tbase = extensionMatch ? absolute : `${absolute}.png`;\n\t}\n\tif (count === 1) return { ok: true, paths: [base] };\n\tconst stem = base.slice(0, -\".png\".length);\n\treturn {\n\t\tok: true,\n\t\tpaths: Array.from({ length: count }, (_, index) => `${stem}-${String(index + 1).padStart(2, \"0\")}.png`),\n\t};\n}\n\n/** Prefers a path relative to the working directory, falling back to absolute. */\nexport function displayPath(cwd: string, absolute: string): string {\n\tconst relativePath = relative(cwd, absolute);\n\treturn relativePath && !relativePath.startsWith(\"..\") && !isAbsolute(relativePath) ? relativePath : absolute;\n}\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gpt-image-gen
|
|
3
|
+
description: MUST read before generating images. Detailed prompt-crafting guide for gpt-image models, covering tool routing (native image_generation server tool vs the generate_image tool), prompt structure from subject to background, verbatim text rendering, anti-patterns, and the revised_prompt feedback loop for iteration.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GPT Image Generation
|
|
7
|
+
|
|
8
|
+
How to write image prompts that come back right the first time, and how to fix them fast when they don't. Read this before your first generation call.
|
|
9
|
+
|
|
10
|
+
## Which tool
|
|
11
|
+
|
|
12
|
+
When image generation tooling is present in your tool set, pick the surface that actually exists right now:
|
|
13
|
+
|
|
14
|
+
- If a native `image_generation` server tool is available, use it. The provider runs generation server-side and returns the image in the response stream.
|
|
15
|
+
- Otherwise, call the `generate_image` tool. It sends your prompt to the configured OpenAI-compatible endpoint and saves the result to a file.
|
|
16
|
+
|
|
17
|
+
Check your current tool set before choosing. Skill visibility refreshes on reload, but tool state can change mid-session (model switch, credential change), so trust the tools you can see over what this page said at startup. If both surfaces ever appear, prefer the native server tool.
|
|
18
|
+
|
|
19
|
+
## Prompt crafting
|
|
20
|
+
|
|
21
|
+
This section is the core of the skill. gpt-image models reward detail, and the single most common failure mode is a one-line prompt.
|
|
22
|
+
|
|
23
|
+
Build each prompt from six parts, in this order:
|
|
24
|
+
|
|
25
|
+
1. Subject. Who or what, with concrete physical detail. "A middle-aged baker with flour on her forearms and a gray-streaked braid" beats "a baker".
|
|
26
|
+
2. Medium and style. One style, stated plainly: "35mm film photograph", "watercolor illustration", "flat vector poster". Pick one lane.
|
|
27
|
+
3. Composition and camera. Framing, angle, focal length or its visual equivalent. "Eye-level medium close-up, shallow depth of field, subject left of center".
|
|
28
|
+
4. Lighting and color. Direction, quality, palette. "Soft window light from the left, warm amber tones against deep shadow".
|
|
29
|
+
5. Mood. The emotional register: quiet, tense, celebratory, clinical.
|
|
30
|
+
6. Background. What sits behind the subject, and how much of it is in focus.
|
|
31
|
+
|
|
32
|
+
A good prompt reads as a short paragraph, not a list and not a lone sentence. If your prompt fits on one line, it is under-specified, and the model will fill the gaps with whatever it likes.
|
|
33
|
+
|
|
34
|
+
### Rendering text in the image
|
|
35
|
+
|
|
36
|
+
When the image must contain readable text (a sign, a label, a headline), put the exact string in double quotes and state the font style and placement:
|
|
37
|
+
|
|
38
|
+
A weathered wooden sign above the door reads "OPEN TIL LATE" in hand-painted white serif letters, centered, slightly faded.
|
|
39
|
+
|
|
40
|
+
Keep on-image text short. Long passages smear. If the layout matters, say where each string sits.
|
|
41
|
+
|
|
42
|
+
### Anti-patterns
|
|
43
|
+
|
|
44
|
+
- Contradictory instructions. "Photorealistic watercolor" or "minimalist scene packed with detail" forces the model to average two opposing goals, and you get neither.
|
|
45
|
+
- Element overcrowding. Every named object competes for pixels and attention. Past roughly five or six distinct elements, small ones get dropped or mangled. Cut before you add.
|
|
46
|
+
- Style-list collisions. "In the style of anime, oil painting, and pixel art" is three prompts in a trench coat. Choose one style per image and generate variants separately.
|
|
47
|
+
|
|
48
|
+
### The revised_prompt loop
|
|
49
|
+
|
|
50
|
+
Both surfaces can return a `revised_prompt`: the prompt the model actually used after its own rewrite. Always read it.
|
|
51
|
+
|
|
52
|
+
1. Diff it against your intent. Note what the model added, dropped, or reinterpreted.
|
|
53
|
+
2. Fold the delta into your next prompt explicitly. If the rewrite dropped "overcast sky", put "overcast sky, no direct sunlight" back with more weight. If it added something you dislike, name the exclusion ("no lens flare").
|
|
54
|
+
3. Regenerate. Treat each round as a conversation with the rewriter, not a fresh roll of the dice.
|
|
55
|
+
|
|
56
|
+
## Editing and masks
|
|
57
|
+
|
|
58
|
+
v1 has no editing surface. The `generate_image` tool is text-only: it accepts a prompt and returns new images. There is no image input, no mask, no inpainting, no variation mode. The native `image_generation` server tool may perform provider-side edits on its own (action=auto), but no edit controls are exposed here.
|
|
59
|
+
|
|
60
|
+
Don't build workflows around editing. If the user asks to change an existing image, say that v1 generates from text only, then offer the closest text-only path: describe the desired end state as a full new prompt. Editing, masks, and image input are planned for a future version.
|
|
61
|
+
|
|
62
|
+
## Iteration workflow
|
|
63
|
+
|
|
64
|
+
- Generate one image first. Inspect the result against every clause of your prompt before spending more.
|
|
65
|
+
- Correct deviations by editing the prompt, not by hoping. Name what was wrong and what stays fixed.
|
|
66
|
+
- Batch with `n` only after the prompt is proven. `n` variants of a bad prompt is `n` bad images.
|
|
67
|
+
- Keep the full prompt text in the conversation. It is your reproducibility record: anyone can re-run the exact call later, and you can diff prompt versions when results drift.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-tool availability state for the imagegen builtin.
|
|
3
|
+
*
|
|
4
|
+
* The generate_image tool is registered once and gated at call time so a
|
|
5
|
+
* mid-session login or model switch takes effect without a reload. Credentials
|
|
6
|
+
* are re-resolved inside every execute; this module only carries the native
|
|
7
|
+
* bypass seam, which the sibling openai-image-gen builtin wires live once the
|
|
8
|
+
* native server tool ships. Until then it stays false and the client tool owns
|
|
9
|
+
* every image request.
|
|
10
|
+
*/
|
|
11
|
+
import type { ImageGenAuthRegistry } from "./auth.ts";
|
|
12
|
+
export declare const NATIVE_BYPASS_MESSAGE = "Image generation is handled by the provider's native server-side tool for the current model. Call the native image_generation tool instead of generate_image.";
|
|
13
|
+
/** Enables or disables deferral to a provider-native image generation tool. */
|
|
14
|
+
export declare function setNativeBypass(enabled: boolean): void;
|
|
15
|
+
/** Whether generate_image should defer to a provider-native image generation tool. */
|
|
16
|
+
export declare function isNativeBypass(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides the registry the tool resolves credentials from. Tests and the
|
|
19
|
+
* arbitration suite use this to force a credential direction, because the
|
|
20
|
+
* builtin provider catalog always contains credential-resolvable gateways and
|
|
21
|
+
* the ambient session registry is therefore never credential-free.
|
|
22
|
+
*/
|
|
23
|
+
export declare function setImageGenRegistry(registry: ImageGenAuthRegistry | undefined): void;
|
|
24
|
+
/** The registry override, when one is installed. */
|
|
25
|
+
export declare function imageGenRegistryOverride(): ImageGenAuthRegistry | undefined;
|
|
26
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,eAAO,MAAM,qBAAqB,kKAC8H,CAAC;AAKjK,+EAA+E;AAC/E,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED,sFAAsF;AACtF,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,SAAS,GAAG,IAAI,CAEpF;AAED,oDAAoD;AACpD,wBAAgB,wBAAwB,IAAI,oBAAoB,GAAG,SAAS,CAE3E"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-tool availability state for the imagegen builtin.
|
|
3
|
+
*
|
|
4
|
+
* The generate_image tool is registered once and gated at call time so a
|
|
5
|
+
* mid-session login or model switch takes effect without a reload. Credentials
|
|
6
|
+
* are re-resolved inside every execute; this module only carries the native
|
|
7
|
+
* bypass seam, which the sibling openai-image-gen builtin wires live once the
|
|
8
|
+
* native server tool ships. Until then it stays false and the client tool owns
|
|
9
|
+
* every image request.
|
|
10
|
+
*/
|
|
11
|
+
export const NATIVE_BYPASS_MESSAGE = "Image generation is handled by the provider's native server-side tool for the current model. Call the native image_generation tool instead of generate_image.";
|
|
12
|
+
let nativeBypass = false;
|
|
13
|
+
let registryOverride;
|
|
14
|
+
/** Enables or disables deferral to a provider-native image generation tool. */
|
|
15
|
+
export function setNativeBypass(enabled) {
|
|
16
|
+
nativeBypass = enabled;
|
|
17
|
+
}
|
|
18
|
+
/** Whether generate_image should defer to a provider-native image generation tool. */
|
|
19
|
+
export function isNativeBypass() {
|
|
20
|
+
return nativeBypass;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Overrides the registry the tool resolves credentials from. Tests and the
|
|
24
|
+
* arbitration suite use this to force a credential direction, because the
|
|
25
|
+
* builtin provider catalog always contains credential-resolvable gateways and
|
|
26
|
+
* the ambient session registry is therefore never credential-free.
|
|
27
|
+
*/
|
|
28
|
+
export function setImageGenRegistry(registry) {
|
|
29
|
+
registryOverride = registry;
|
|
30
|
+
}
|
|
31
|
+
/** The registry override, when one is installed. */
|
|
32
|
+
export function imageGenRegistryOverride() {
|
|
33
|
+
return registryOverride;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,MAAM,CAAC,MAAM,qBAAqB,GACjC,+JAA+J,CAAC;AAEjK,IAAI,YAAY,GAAG,KAAK,CAAC;AACzB,IAAI,gBAAkD,CAAC;AAEvD,+EAA+E;AAC/E,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC/C,YAAY,GAAG,OAAO,CAAC;AACxB,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,cAAc;IAC7B,OAAO,YAAY,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA0C;IAC7E,gBAAgB,GAAG,QAAQ,CAAC;AAC7B,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,wBAAwB;IACvC,OAAO,gBAAgB,CAAC;AACzB,CAAC","sourcesContent":["/**\n * Client-tool availability state for the imagegen builtin.\n *\n * The generate_image tool is registered once and gated at call time so a\n * mid-session login or model switch takes effect without a reload. Credentials\n * are re-resolved inside every execute; this module only carries the native\n * bypass seam, which the sibling openai-image-gen builtin wires live once the\n * native server tool ships. Until then it stays false and the client tool owns\n * every image request.\n */\n\nimport type { ImageGenAuthRegistry } from \"./auth.ts\";\n\nexport const NATIVE_BYPASS_MESSAGE =\n\t\"Image generation is handled by the provider's native server-side tool for the current model. Call the native image_generation tool instead of generate_image.\";\n\nlet nativeBypass = false;\nlet registryOverride: ImageGenAuthRegistry | undefined;\n\n/** Enables or disables deferral to a provider-native image generation tool. */\nexport function setNativeBypass(enabled: boolean): void {\n\tnativeBypass = enabled;\n}\n\n/** Whether generate_image should defer to a provider-native image generation tool. */\nexport function isNativeBypass(): boolean {\n\treturn nativeBypass;\n}\n\n/**\n * Overrides the registry the tool resolves credentials from. Tests and the\n * arbitration suite use this to force a credential direction, because the\n * builtin provider catalog always contains credential-resolvable gateways and\n * the ambient session registry is therefore never credential-free.\n */\nexport function setImageGenRegistry(registry: ImageGenAuthRegistry | undefined): void {\n\tregistryOverride = registry;\n}\n\n/** The registry override, when one is installed. */\nexport function imageGenRegistryOverride(): ImageGenAuthRegistry | undefined {\n\treturn registryOverride;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import { type ImageGenAuthRegistry } from "./auth.ts";
|
|
3
|
+
export interface GenerateImageDetails {
|
|
4
|
+
paths: string[];
|
|
5
|
+
model: string;
|
|
6
|
+
source: string;
|
|
7
|
+
size: string;
|
|
8
|
+
quality: string;
|
|
9
|
+
requested: number;
|
|
10
|
+
generated: number;
|
|
11
|
+
revisedPrompts: string[];
|
|
12
|
+
error?: string;
|
|
13
|
+
reason?: "missing_config" | "provider_native_bypass" | "invalid_params" | "write_failed" | "provider_error";
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Only the registry surface the credential resolver needs. The session passes its
|
|
17
|
+
* full ModelRegistry, which satisfies this structurally.
|
|
18
|
+
*/
|
|
19
|
+
export interface GenerateImageToolContext {
|
|
20
|
+
cwd: string;
|
|
21
|
+
modelRegistry: ImageGenAuthRegistry;
|
|
22
|
+
}
|
|
23
|
+
export declare const GENERATE_IMAGE_TOOL_NAME = "generate_image";
|
|
24
|
+
export declare const generateImageTool: import("../../types.ts").ToolDefinition<Type.TObject<{
|
|
25
|
+
prompt: Type.TString;
|
|
26
|
+
size: Type.TOptional<Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"1024x1024">, Type.TLiteral<"1024x1536">, Type.TLiteral<"1536x1024">]>>;
|
|
27
|
+
quality: Type.TOptional<Type.TUnion<[Type.TLiteral<"auto">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">]>>;
|
|
28
|
+
n: Type.TOptional<Type.TInteger>;
|
|
29
|
+
output_path: Type.TOptional<Type.TString>;
|
|
30
|
+
}>, GenerateImageDetails, any> & import("../../types.ts").ToolDefinition<any, any, any>;
|
|
31
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/tool.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,KAAK,oBAAoB,EAAoD,MAAM,WAAW,CAAC;AAuCxG,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,gBAAgB,GAAG,wBAAwB,GAAG,gBAAgB,GAAG,cAAc,GAAG,gBAAgB,CAAC;CAC5G;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,oBAAoB,CAAC;CACpC;AA6ED,eAAO,MAAM,wBAAwB,mBAAmB,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;;;uFA4F5B,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { mkdir, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { dirname } from "node:path";
|
|
4
|
+
import { generateImages } from "@earendil-works/pi-ai/compat";
|
|
5
|
+
import { Type } from "typebox";
|
|
6
|
+
import { defineTool } from "../../types.js";
|
|
7
|
+
import { resolveImageGenAuth } from "./auth.js";
|
|
8
|
+
import { displayPath, resolveTargets } from "./paths.js";
|
|
9
|
+
import { imageGenRegistryOverride, isNativeBypass, NATIVE_BYPASS_MESSAGE } from "./state.js";
|
|
10
|
+
const MODEL_ID = "gpt-image-2";
|
|
11
|
+
const Params = Type.Object({
|
|
12
|
+
prompt: Type.String({
|
|
13
|
+
minLength: 1,
|
|
14
|
+
maxLength: 32_000,
|
|
15
|
+
description: "Detailed description of the image to generate.",
|
|
16
|
+
}),
|
|
17
|
+
size: Type.Optional(Type.Union([Type.Literal("auto"), Type.Literal("1024x1024"), Type.Literal("1024x1536"), Type.Literal("1536x1024")], { default: "auto", description: "Output resolution. Defaults to auto." })),
|
|
18
|
+
quality: Type.Optional(Type.Union([Type.Literal("auto"), Type.Literal("low"), Type.Literal("medium"), Type.Literal("high")], {
|
|
19
|
+
default: "auto",
|
|
20
|
+
description: "Rendering quality. Defaults to auto.",
|
|
21
|
+
})),
|
|
22
|
+
n: Type.Optional(Type.Integer({ minimum: 1, maximum: 10, default: 1, description: "How many images to generate." })),
|
|
23
|
+
output_path: Type.Optional(Type.String({
|
|
24
|
+
minLength: 1,
|
|
25
|
+
description: "Where to write the image, relative to the working directory. Must end in .png. Defaults to generated-images/.",
|
|
26
|
+
})),
|
|
27
|
+
}, { additionalProperties: false });
|
|
28
|
+
function failure(message, reason, base) {
|
|
29
|
+
const details = {
|
|
30
|
+
...base,
|
|
31
|
+
paths: [],
|
|
32
|
+
model: MODEL_ID,
|
|
33
|
+
generated: 0,
|
|
34
|
+
revisedPrompts: [],
|
|
35
|
+
error: message,
|
|
36
|
+
reason,
|
|
37
|
+
};
|
|
38
|
+
return { content: [{ type: "text", text: message }], details };
|
|
39
|
+
}
|
|
40
|
+
function sourceLabel(auth) {
|
|
41
|
+
if (auth.kind === "none")
|
|
42
|
+
return "none";
|
|
43
|
+
if (auth.provenance === "env")
|
|
44
|
+
return "env:OPENAI_API_KEY";
|
|
45
|
+
return `${auth.provenance}:${auth.providerId ?? auth.kind}`;
|
|
46
|
+
}
|
|
47
|
+
function synthesizeModel(auth) {
|
|
48
|
+
const model = {
|
|
49
|
+
id: MODEL_ID,
|
|
50
|
+
name: "GPT Image 2",
|
|
51
|
+
api: "openai-images",
|
|
52
|
+
provider: auth.providerId ?? "openai",
|
|
53
|
+
baseUrl: auth.baseUrl,
|
|
54
|
+
input: ["text"],
|
|
55
|
+
output: ["image"],
|
|
56
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
57
|
+
};
|
|
58
|
+
return model;
|
|
59
|
+
}
|
|
60
|
+
function collectImages(images) {
|
|
61
|
+
const collected = [];
|
|
62
|
+
let pendingText;
|
|
63
|
+
for (const block of images.output) {
|
|
64
|
+
if (block.type === "text") {
|
|
65
|
+
const text = block.text.trim();
|
|
66
|
+
pendingText = text.length > 0 ? text : undefined;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
collected.push({ data: block.data, ...(pendingText === undefined ? {} : { revisedPrompt: pendingText }) });
|
|
70
|
+
pendingText = undefined;
|
|
71
|
+
}
|
|
72
|
+
return collected;
|
|
73
|
+
}
|
|
74
|
+
async function writeImages(paths, images) {
|
|
75
|
+
const written = [];
|
|
76
|
+
for (const [index, image] of images.entries()) {
|
|
77
|
+
const target = paths[index];
|
|
78
|
+
if (target === undefined)
|
|
79
|
+
break;
|
|
80
|
+
try {
|
|
81
|
+
await mkdir(dirname(target), { recursive: true });
|
|
82
|
+
await writeFile(target, Buffer.from(image.data, "base64"), { flag: "wx" });
|
|
83
|
+
written.push(target);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
for (const path of written)
|
|
87
|
+
await rm(path, { force: true }).catch(() => undefined);
|
|
88
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
89
|
+
return `Error: failed to write generated image to ${target}: ${reason}`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
export const GENERATE_IMAGE_TOOL_NAME = "generate_image";
|
|
95
|
+
export const generateImageTool = defineTool({
|
|
96
|
+
name: GENERATE_IMAGE_TOOL_NAME,
|
|
97
|
+
label: "Generate Image",
|
|
98
|
+
description: "Generate an image from a text prompt with gpt-image-2 and save it as a PNG file. Returns the saved file paths.",
|
|
99
|
+
promptSnippet: "Generate images from text prompts and save them as PNG files.",
|
|
100
|
+
parameters: Params,
|
|
101
|
+
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
102
|
+
const size = params.size ?? "auto";
|
|
103
|
+
const quality = params.quality ?? "auto";
|
|
104
|
+
const requested = params.n ?? 1;
|
|
105
|
+
const context = { size, quality, requested, source: "none" };
|
|
106
|
+
const prompt = params.prompt.trim();
|
|
107
|
+
if (prompt.length === 0) {
|
|
108
|
+
return failure("Error: prompt must contain non-whitespace text.", "invalid_params", context);
|
|
109
|
+
}
|
|
110
|
+
if (isNativeBypass()) {
|
|
111
|
+
return failure(NATIVE_BYPASS_MESSAGE, "provider_native_bypass", context);
|
|
112
|
+
}
|
|
113
|
+
const auth = await resolveImageGenAuth({ modelRegistry: imageGenRegistryOverride() ?? ctx.modelRegistry });
|
|
114
|
+
if (auth.kind === "none") {
|
|
115
|
+
return failure(auth.reason, "missing_config", context);
|
|
116
|
+
}
|
|
117
|
+
const source = sourceLabel(auth);
|
|
118
|
+
const targets = resolveTargets(ctx.cwd, toolCallId, requested, params.output_path);
|
|
119
|
+
if (!targets.ok) {
|
|
120
|
+
return failure(targets.error, "invalid_params", { ...context, source });
|
|
121
|
+
}
|
|
122
|
+
for (const target of targets.paths) {
|
|
123
|
+
if (existsSync(target)) {
|
|
124
|
+
return failure(`Error: ${displayPath(ctx.cwd, target)} already exists. Choose another output_path.`, "invalid_params", { ...context, source });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const images = await generateImages(synthesizeModel(auth), { input: [{ type: "text", text: prompt }] }, {
|
|
128
|
+
...(auth.apiKey === undefined ? {} : { apiKey: auth.apiKey }),
|
|
129
|
+
...(auth.headers === undefined ? {} : { headers: auth.headers }),
|
|
130
|
+
...(signal === undefined ? {} : { signal }),
|
|
131
|
+
size,
|
|
132
|
+
quality,
|
|
133
|
+
n: requested,
|
|
134
|
+
});
|
|
135
|
+
if (images.stopReason !== "stop") {
|
|
136
|
+
const message = images.errorMessage ?? `Image generation ${images.stopReason}.`;
|
|
137
|
+
return failure(`Error: ${message}`, "provider_error", { ...context, source });
|
|
138
|
+
}
|
|
139
|
+
const generated = collectImages(images);
|
|
140
|
+
if (generated.length === 0) {
|
|
141
|
+
return failure("Error: the provider returned no images.", "provider_error", { ...context, source });
|
|
142
|
+
}
|
|
143
|
+
const writeError = await writeImages(targets.paths, generated);
|
|
144
|
+
if (writeError !== undefined) {
|
|
145
|
+
return failure(writeError, "write_failed", { ...context, source });
|
|
146
|
+
}
|
|
147
|
+
const savedPaths = targets.paths.slice(0, generated.length).map((target) => displayPath(ctx.cwd, target));
|
|
148
|
+
const revisedPrompts = generated.flatMap((image) => (image.revisedPrompt ? [image.revisedPrompt] : []));
|
|
149
|
+
const details = {
|
|
150
|
+
paths: savedPaths,
|
|
151
|
+
model: MODEL_ID,
|
|
152
|
+
source,
|
|
153
|
+
size,
|
|
154
|
+
quality,
|
|
155
|
+
requested,
|
|
156
|
+
generated: generated.length,
|
|
157
|
+
revisedPrompts,
|
|
158
|
+
};
|
|
159
|
+
const summary = [
|
|
160
|
+
`Generated ${generated.length} image${generated.length === 1 ? "" : "s"}:`,
|
|
161
|
+
...savedPaths.map((path) => `- ${path}`),
|
|
162
|
+
...revisedPrompts.map((revised) => `Revised prompt: ${revised}`),
|
|
163
|
+
].join("\n");
|
|
164
|
+
return {
|
|
165
|
+
content: [
|
|
166
|
+
{ type: "text", text: summary },
|
|
167
|
+
...generated.map((image) => ({ type: "image", data: image.data, mimeType: "image/png" })),
|
|
168
|
+
],
|
|
169
|
+
details,
|
|
170
|
+
...(images.usage === undefined ? {} : { usage: images.usage }),
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/imagegen/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAA0D,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACxG,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE7F,MAAM,QAAQ,GAAG,aAAa,CAAC;AAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CACzB;IACC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,MAAM;QACjB,WAAW,EAAE,gDAAgD;KAC7D,CAAC;IACF,IAAI,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,KAAK,CACT,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,WA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AO,GAAG;YACf,aAAa,SAAS,CAAC,MAAM,SAAS,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;YAC1E,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;YACxC,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,OAAO,EAAE,CAAC;SAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,OAAO;YACN,OAAO,EAAE;gBACR,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE;gBACxC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAgB,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,CAAC;aAClG;YACD,OAAO;YACP,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;SAC9D,CAAC;IACH,CAAC;CACD,CAAC,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { mkdir, rm, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport type { AssistantImages, ImagesModel } from \"@earendil-works/pi-ai/compat\";\nimport { generateImages } from \"@earendil-works/pi-ai/compat\";\nimport { Type } from \"typebox\";\nimport { defineTool } from \"../../types.ts\";\nimport { type ImageGenAuthRegistry, type ImageGenAuthResolution, resolveImageGenAuth } from \"./auth.ts\";\nimport { displayPath, resolveTargets } from \"./paths.ts\";\nimport { imageGenRegistryOverride, isNativeBypass, NATIVE_BYPASS_MESSAGE } from \"./state.ts\";\n\nconst MODEL_ID = \"gpt-image-2\";\n\nconst Params = Type.Object(\n\t{\n\t\tprompt: Type.String({\n\t\t\tminLength: 1,\n\t\t\tmaxLength: 32_000,\n\t\t\tdescription: \"Detailed description of the image to generate.\",\n\t\t}),\n\t\tsize: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[Type.Literal(\"auto\"), Type.Literal(\"1024x1024\"), Type.Literal(\"1024x1536\"), Type.Literal(\"1536x1024\")],\n\t\t\t\t{ default: \"auto\", description: \"Output resolution. Defaults to auto.\" },\n\t\t\t),\n\t\t),\n\t\tquality: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"auto\"), Type.Literal(\"low\"), Type.Literal(\"medium\"), Type.Literal(\"high\")], {\n\t\t\t\tdefault: \"auto\",\n\t\t\t\tdescription: \"Rendering quality. Defaults to auto.\",\n\t\t\t}),\n\t\t),\n\t\tn: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, maximum: 10, default: 1, description: \"How many images to generate.\" }),\n\t\t),\n\t\toutput_path: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tminLength: 1,\n\t\t\t\tdescription:\n\t\t\t\t\t\"Where to write the image, relative to the working directory. Must end in .png. Defaults to generated-images/.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport interface GenerateImageDetails {\n\tpaths: string[];\n\tmodel: string;\n\tsource: string;\n\tsize: string;\n\tquality: string;\n\trequested: number;\n\tgenerated: number;\n\trevisedPrompts: string[];\n\terror?: string;\n\treason?: \"missing_config\" | \"provider_native_bypass\" | \"invalid_params\" | \"write_failed\" | \"provider_error\";\n}\n\n/**\n * Only the registry surface the credential resolver needs. The session passes its\n * full ModelRegistry, which satisfies this structurally.\n */\nexport interface GenerateImageToolContext {\n\tcwd: string;\n\tmodelRegistry: ImageGenAuthRegistry;\n}\n\nfunction failure(\n\tmessage: string,\n\treason: NonNullable<GenerateImageDetails[\"reason\"]>,\n\tbase: Pick<GenerateImageDetails, \"size\" | \"quality\" | \"requested\" | \"source\">,\n) {\n\tconst details: GenerateImageDetails = {\n\t\t...base,\n\t\tpaths: [],\n\t\tmodel: MODEL_ID,\n\t\tgenerated: 0,\n\t\trevisedPrompts: [],\n\t\terror: message,\n\t\treason,\n\t};\n\treturn { content: [{ type: \"text\" as const, text: message }], details };\n}\n\nfunction sourceLabel(auth: ImageGenAuthResolution): string {\n\tif (auth.kind === \"none\") return \"none\";\n\tif (auth.provenance === \"env\") return \"env:OPENAI_API_KEY\";\n\treturn `${auth.provenance}:${auth.providerId ?? auth.kind}`;\n}\n\nfunction synthesizeModel(auth: Extract<ImageGenAuthResolution, { kind: \"native-openai\" | \"gateway\" }>) {\n\tconst model: ImagesModel<\"openai-images\"> = {\n\t\tid: MODEL_ID,\n\t\tname: \"GPT Image 2\",\n\t\tapi: \"openai-images\",\n\t\tprovider: auth.providerId ?? \"openai\",\n\t\tbaseUrl: auth.baseUrl,\n\t\tinput: [\"text\"],\n\t\toutput: [\"image\"],\n\t\tcost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },\n\t};\n\treturn model;\n}\n\ninterface GeneratedImage {\n\tdata: string;\n\trevisedPrompt?: string;\n}\n\nfunction collectImages(images: AssistantImages): GeneratedImage[] {\n\tconst collected: GeneratedImage[] = [];\n\tlet pendingText: string | undefined;\n\tfor (const block of images.output) {\n\t\tif (block.type === \"text\") {\n\t\t\tconst text = block.text.trim();\n\t\t\tpendingText = text.length > 0 ? text : undefined;\n\t\t\tcontinue;\n\t\t}\n\t\tcollected.push({ data: block.data, ...(pendingText === undefined ? {} : { revisedPrompt: pendingText }) });\n\t\tpendingText = undefined;\n\t}\n\treturn collected;\n}\n\nasync function writeImages(paths: string[], images: GeneratedImage[]): Promise<string | undefined> {\n\tconst written: string[] = [];\n\tfor (const [index, image] of images.entries()) {\n\t\tconst target = paths[index];\n\t\tif (target === undefined) break;\n\t\ttry {\n\t\t\tawait mkdir(dirname(target), { recursive: true });\n\t\t\tawait writeFile(target, Buffer.from(image.data, \"base64\"), { flag: \"wx\" });\n\t\t\twritten.push(target);\n\t\t} catch (error) {\n\t\t\tfor (const path of written) await rm(path, { force: true }).catch(() => undefined);\n\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\treturn `Error: failed to write generated image to ${target}: ${reason}`;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport const GENERATE_IMAGE_TOOL_NAME = \"generate_image\";\n\nexport const generateImageTool = defineTool<typeof Params, GenerateImageDetails>({\n\tname: GENERATE_IMAGE_TOOL_NAME,\n\tlabel: \"Generate Image\",\n\tdescription:\n\t\t\"Generate an image from a text prompt with gpt-image-2 and save it as a PNG file. Returns the saved file paths.\",\n\tpromptSnippet: \"Generate images from text prompts and save them as PNG files.\",\n\tparameters: Params,\n\tasync execute(toolCallId, params, signal, _onUpdate, ctx: GenerateImageToolContext) {\n\t\tconst size = params.size ?? \"auto\";\n\t\tconst quality = params.quality ?? \"auto\";\n\t\tconst requested = params.n ?? 1;\n\t\tconst context = { size, quality, requested, source: \"none\" };\n\n\t\tconst prompt = params.prompt.trim();\n\t\tif (prompt.length === 0) {\n\t\t\treturn failure(\"Error: prompt must contain non-whitespace text.\", \"invalid_params\", context);\n\t\t}\n\t\tif (isNativeBypass()) {\n\t\t\treturn failure(NATIVE_BYPASS_MESSAGE, \"provider_native_bypass\", context);\n\t\t}\n\n\t\tconst auth = await resolveImageGenAuth({ modelRegistry: imageGenRegistryOverride() ?? ctx.modelRegistry });\n\t\tif (auth.kind === \"none\") {\n\t\t\treturn failure(auth.reason, \"missing_config\", context);\n\t\t}\n\t\tconst source = sourceLabel(auth);\n\t\tconst targets = resolveTargets(ctx.cwd, toolCallId, requested, params.output_path);\n\t\tif (!targets.ok) {\n\t\t\treturn failure(targets.error, \"invalid_params\", { ...context, source });\n\t\t}\n\t\tfor (const target of targets.paths) {\n\t\t\tif (existsSync(target)) {\n\t\t\t\treturn failure(\n\t\t\t\t\t`Error: ${displayPath(ctx.cwd, target)} already exists. Choose another output_path.`,\n\t\t\t\t\t\"invalid_params\",\n\t\t\t\t\t{ ...context, source },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tconst images = await generateImages(\n\t\t\tsynthesizeModel(auth),\n\t\t\t{ input: [{ type: \"text\", text: prompt }] },\n\t\t\t{\n\t\t\t\t...(auth.apiKey === undefined ? {} : { apiKey: auth.apiKey }),\n\t\t\t\t...(auth.headers === undefined ? {} : { headers: auth.headers }),\n\t\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t\t\tsize,\n\t\t\t\tquality,\n\t\t\t\tn: requested,\n\t\t\t},\n\t\t);\n\t\tif (images.stopReason !== \"stop\") {\n\t\t\tconst message = images.errorMessage ?? `Image generation ${images.stopReason}.`;\n\t\t\treturn failure(`Error: ${message}`, \"provider_error\", { ...context, source });\n\t\t}\n\n\t\tconst generated = collectImages(images);\n\t\tif (generated.length === 0) {\n\t\t\treturn failure(\"Error: the provider returned no images.\", \"provider_error\", { ...context, source });\n\t\t}\n\t\tconst writeError = await writeImages(targets.paths, generated);\n\t\tif (writeError !== undefined) {\n\t\t\treturn failure(writeError, \"write_failed\", { ...context, source });\n\t\t}\n\n\t\tconst savedPaths = targets.paths.slice(0, generated.length).map((target) => displayPath(ctx.cwd, target));\n\t\tconst revisedPrompts = generated.flatMap((image) => (image.revisedPrompt ? [image.revisedPrompt] : []));\n\t\tconst details: GenerateImageDetails = {\n\t\t\tpaths: savedPaths,\n\t\t\tmodel: MODEL_ID,\n\t\t\tsource,\n\t\t\tsize,\n\t\t\tquality,\n\t\t\trequested,\n\t\t\tgenerated: generated.length,\n\t\t\trevisedPrompts,\n\t\t};\n\t\tconst summary = [\n\t\t\t`Generated ${generated.length} image${generated.length === 1 ? \"\" : \"s\"}:`,\n\t\t\t...savedPaths.map((path) => `- ${path}`),\n\t\t\t...revisedPrompts.map((revised) => `Revised prompt: ${revised}`),\n\t\t].join(\"\\n\");\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{ type: \"text\" as const, text: summary },\n\t\t\t\t...generated.map((image) => ({ type: \"image\" as const, data: image.data, mimeType: \"image/png\" })),\n\t\t\t],\n\t\t\tdetails,\n\t\t\t...(images.usage === undefined ? {} : { usage: images.usage }),\n\t\t};\n\t},\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AASpD,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;AAiBxC,OAAO,wBAAwB,MAAM,wBAAwB,CAAC;AAS9D,OAAO,YAAY,MAAM,UAAU,CAAC;AAMpC,MAAM,WAAW,uBAAuB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,gBAAgB,CAAC;CAC1B;AAED,eAAO,MAAM,yBAAyB,YAAI,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,KAAK,CAAU,CAAC;AAEhG,eAAO,MAAM,+BAA+B;;;;;CAKoC,CAAC;AAEjF,eAAO,MAAM,iBAAiB,EAAE,uBAAuB,EA4CtD,CAAC"}
|
|
@@ -13,12 +13,14 @@ import gptApplyPatchExtension from "./gpt-apply-patch/index.js";
|
|
|
13
13
|
import helpExtension from "./help/index.js";
|
|
14
14
|
import historySearchExtension from "./history-search/index.js";
|
|
15
15
|
import hooksExtension from "./hooks/index.js";
|
|
16
|
+
import imageGenExtension from "./imagegen/index.js";
|
|
16
17
|
import importReproExtension from "./import-repro.js";
|
|
17
18
|
import lookAtExtension from "./look-at/index.js";
|
|
18
19
|
import loopGuardExtension from "./loop-guard/index.js";
|
|
19
20
|
import mcpExtension from "./mcp/index.js";
|
|
20
21
|
import modelFallbackExtension from "./model-fallback/index.js";
|
|
21
22
|
import nestedAgentsMdExtension from "./nested-agents-md/index.js";
|
|
23
|
+
import openaiImageGenExtension from "./openai-image-gen/index.js";
|
|
22
24
|
import openaiWebSearchExtension from "./openai-web-search/index.js";
|
|
23
25
|
import permissionSystemExtension from "./permission-system/index.js";
|
|
24
26
|
import promptPresetExtension from "./prompt-preset/index.js";
|
|
@@ -30,6 +32,7 @@ import serviceTierExtension from "./service-tier.js";
|
|
|
30
32
|
import terminalExtension from "./terminal/index.js";
|
|
31
33
|
import todowriteExtension from "./todotools/index.js";
|
|
32
34
|
import toolPairGuardExtension from "./tool-pair-guard/index.js";
|
|
35
|
+
import toolSearchExtension from "./tool-search/index.js";
|
|
33
36
|
import tpsExtension from "./tps.js";
|
|
34
37
|
import ttsrExtension from "./ttsr/index.js";
|
|
35
38
|
import videoInExtension from "./video-in/index.js";
|
|
@@ -46,6 +49,9 @@ export const builtinExtensions = [
|
|
|
46
49
|
{ id: "hooks", factory: hooksExtension },
|
|
47
50
|
{ id: "permission-system", factory: permissionSystemExtension },
|
|
48
51
|
{ id: "gpt-apply-patch", factory: gptApplyPatchExtension },
|
|
52
|
+
{ id: "imagegen", factory: imageGenExtension },
|
|
53
|
+
// Follows imagegen so the native injector's bypass wiring observes the registered client tool.
|
|
54
|
+
{ id: "openai-image-gen", factory: openaiImageGenExtension },
|
|
49
55
|
{ id: "prompt-preset", factory: promptPresetExtension },
|
|
50
56
|
{ id: "todowrite", factory: todowriteExtension },
|
|
51
57
|
{ id: "redraws", factory: redrawsExtension },
|
|
@@ -77,8 +83,10 @@ export const builtinExtensions = [
|
|
|
77
83
|
{ id: "claude-sdk-oauth", factory: claudeSdkOauthExtension },
|
|
78
84
|
// Loop guard is a pure observer of tool_execution_start; it never mutates payloads, so it slots before config-reload and leaves MCP last.
|
|
79
85
|
{ id: "loop-guard", factory: loopGuardExtension },
|
|
80
|
-
// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before
|
|
86
|
+
// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before catalog feeders observe them.
|
|
81
87
|
{ id: "config-reload", factory: configReloadExtension },
|
|
88
|
+
// Shared catalog wiring loads before MCP, which feeds its tools into the shared catalog as the final builtin.
|
|
89
|
+
{ id: "tool-search", factory: toolSearchExtension },
|
|
82
90
|
// Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.
|
|
83
91
|
{ id: "mcp", factory: mcpExtension },
|
|
84
92
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/extensions/builtin/index.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,2BAA2B,MAAM,iCAAiC,CAAC;AAC1E,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAC3D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AACjE,OAAO,uBAAuB,MAAM,6BAA6B,CAAC;AAClE,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,aAAa,MAAM,WAAW,CAAC;AACtC,OAAO,cAAc,MAAM,YAAY,CAAC;AACxC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,sBAAsB,MAAM,4BAA4B,CAAC;AAChE,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,sBAAsB,MAAM,2BAA2B,CAAC;AAC/D,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,oBAAoB,MAAM,mBAAmB,CAAC;AACrD,OAAO,eAAe,MAAM,oBAAoB,CAAC;AACjD,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,OAAO,YAAY,MAAM,g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;IACnD,iGAAiG;IACjG,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE;CACpC,CAAC","sourcesContent":["import type { ExtensionFactory } from \"../types.ts\";\nimport anthropicBashExtension from \"./anthropic-bash/index.ts\";\nimport anthropicWebSearchExtension from \"./anthropic-web-search/index.ts\";\nimport bashTimeoutExtension from \"./bash-timeout/index.ts\";\nimport btwExtension from \"./btw/index.ts\";\nimport cacheKeepAliveExtension from \"./cache-keepalive/index.ts\";\nimport claudeSdkOauthExtension from \"./claude-sdk-oauth/index.ts\";\nimport compactionExtension from \"./compaction/index.ts\";\nimport configReloadExtension from \"./config-reload/index.ts\";\nimport diffExtension from \"./diff.ts\";\nimport filesExtension from \"./files.ts\";\nimport goalExtension from \"./goal/index.ts\";\nimport gptApplyPatchExtension from \"./gpt-apply-patch/index.ts\";\nimport helpExtension from \"./help/index.ts\";\nimport historySearchExtension from \"./history-search/index.ts\";\nimport hooksExtension from \"./hooks/index.ts\";\nimport imageGenExtension from \"./imagegen/index.ts\";\nimport importReproExtension from \"./import-repro.ts\";\nimport lookAtExtension from \"./look-at/index.ts\";\nimport loopGuardExtension from \"./loop-guard/index.ts\";\nimport mcpExtension from \"./mcp/index.ts\";\nimport modelFallbackExtension from \"./model-fallback/index.ts\";\nimport nestedAgentsMdExtension from \"./nested-agents-md/index.ts\";\nimport openaiImageGenExtension from \"./openai-image-gen/index.ts\";\nimport openaiWebSearchExtension from \"./openai-web-search/index.ts\";\nimport permissionSystemExtension from \"./permission-system/index.ts\";\nimport promptPresetExtension from \"./prompt-preset/index.ts\";\nimport promptUrlWidgetExtension from \"./prompt-url-widget.ts\";\nimport recommendedModelsExtension from \"./recommended-models/index.ts\";\nimport redrawsExtension from \"./redraws.ts\";\nimport piRulesExtension from \"./rules/index.ts\";\nimport serviceTierExtension from \"./service-tier.ts\";\nimport terminalExtension from \"./terminal/index.ts\";\nimport todowriteExtension from \"./todotools/index.ts\";\nimport toolPairGuardExtension from \"./tool-pair-guard/index.ts\";\nimport toolSearchExtension from \"./tool-search/index.ts\";\nimport tpsExtension from \"./tps.ts\";\nimport ttsrExtension from \"./ttsr/index.ts\";\nimport videoInExtension from \"./video-in/index.ts\";\nimport webfetchExtension from \"./webfetch/index.ts\";\nimport websearchExtension from \"./websearch/index.ts\";\n\nexport interface BuiltinExtensionFactory {\n\tid: string;\n\tfactory: ExtensionFactory;\n}\n\nexport const globalDefaultExtensionIds = [\"diff\", \"files\", \"prompt-url-widget\", \"tps\"] as const;\n\nexport const globalDefaultExtensionFactories = {\n\tdiff: diffExtension,\n\tfiles: filesExtension,\n\t\"prompt-url-widget\": promptUrlWidgetExtension,\n\ttps: tpsExtension,\n} satisfies Record<(typeof globalDefaultExtensionIds)[number], ExtensionFactory>;\n\nexport const builtinExtensions: BuiltinExtensionFactory[] = [\n\t{ id: \"hooks\", factory: hooksExtension },\n\t{ id: \"permission-system\", factory: permissionSystemExtension },\n\t{ id: \"gpt-apply-patch\", factory: gptApplyPatchExtension },\n\t{ id: \"imagegen\", factory: imageGenExtension },\n\t// Follows imagegen so the native injector's bypass wiring observes the registered client tool.\n\t{ id: \"openai-image-gen\", factory: openaiImageGenExtension },\n\t{ id: \"prompt-preset\", factory: promptPresetExtension },\n\t{ id: \"todowrite\", factory: todowriteExtension },\n\t{ id: \"redraws\", factory: redrawsExtension },\n\t{ id: \"anthropic-web-search\", factory: anthropicWebSearchExtension },\n\t{ id: \"anthropic-bash\", factory: anthropicBashExtension },\n\t{ id: \"openai-web-search\", factory: openaiWebSearchExtension },\n\t{ id: \"service-tier\", factory: serviceTierExtension },\n\t{ id: \"model-fallback\", factory: modelFallbackExtension },\n\t{ id: \"recommended-models\", factory: recommendedModelsExtension },\n\t{ id: \"bash-timeout\", factory: bashTimeoutExtension },\n\t// Terminal follows bash-timeout so its injected default reaches the PTY bash, and follows\n\t// anthropic-bash so mutual-exclusion (companion step-aside) is evaluated after it registers.\n\t{ id: \"terminal\", factory: terminalExtension },\n\t{ id: \"tool-pair-guard\", factory: toolPairGuardExtension },\n\t{ id: \"compaction\", factory: compactionExtension },\n\t{ id: \"history-search\", factory: historySearchExtension },\n\t{ id: \"help\", factory: helpExtension },\n\t{ id: \"import-repro\", factory: importReproExtension },\n\t{ id: \"websearch\", factory: websearchExtension },\n\t{ id: \"webfetch\", factory: webfetchExtension },\n\t{ id: \"video-in\", factory: videoInExtension },\n\t{ id: \"look-at\", factory: lookAtExtension },\n\t{ id: \"nested-agents-md\", factory: nestedAgentsMdExtension },\n\t{ id: \"rules\", factory: piRulesExtension },\n\t{ id: \"goal\", factory: goalExtension },\n\t{ id: \"cache-keepalive\", factory: cacheKeepAliveExtension },\n\t{ id: \"ttsr\", factory: ttsrExtension },\n\t{ id: \"btw\", factory: btwExtension },\n\t{ id: \"claude-sdk-oauth\", factory: claudeSdkOauthExtension },\n\t// Loop guard is a pure observer of tool_execution_start; it never mutates payloads, so it slots before config-reload and leaves MCP last.\n\t{ id: \"loop-guard\", factory: loopGuardExtension },\n\t// Config reload follows settings-dependent builtins so reloads rebuild their resolved settings before catalog feeders observe them.\n\t{ id: \"config-reload\", factory: configReloadExtension },\n\t// Shared catalog wiring loads before MCP, which feeds its tools into the shared catalog as the final builtin.\n\t{ id: \"tool-search\", factory: toolSearchExtension },\n\t// Keep MCP last so its eventual provider-payload tap observes all co-resident builtin mutations.\n\t{ id: \"mcp\", factory: mcpExtension },\n];\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { McpWireStatusSnapshot } from "./service-types.ts";
|
|
2
|
+
export declare const MCP_CONTROL_INVENTORY_REQUEST_EVENT = "senpi.rpc.mcp_inventory.request";
|
|
3
|
+
export declare const MCP_CONTROL_INVENTORY_CHANGED_EVENT = "senpi.rpc.mcp_inventory.changed";
|
|
4
|
+
export interface McpControlInventoryRequest {
|
|
5
|
+
readonly sessionId: string;
|
|
6
|
+
respond(snapshot: Promise<McpWireStatusSnapshot>): void;
|
|
7
|
+
}
|
|
8
|
+
export interface McpControlInventoryChanged {
|
|
9
|
+
readonly sessionId: string;
|
|
10
|
+
readonly snapshot: McpWireStatusSnapshot;
|
|
11
|
+
}
|
|
12
|
+
export declare function isMcpControlInventoryRequest(value: unknown): value is McpControlInventoryRequest;
|
|
13
|
+
export declare function isMcpControlInventoryChanged(value: unknown): value is McpControlInventoryChanged;
|
|
14
|
+
//# sourceMappingURL=control-inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-inventory.d.ts","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/control-inventory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,eAAO,MAAM,mCAAmC,oCAAoC,CAAC;AACrF,eAAO,MAAM,mCAAmC,oCAAoC,CAAC;AAErF,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;CACxD;AAED,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;CACzC;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,0BAA0B,CAShG;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,0BAA0B,CAShG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const MCP_CONTROL_INVENTORY_REQUEST_EVENT = "senpi.rpc.mcp_inventory.request";
|
|
2
|
+
export const MCP_CONTROL_INVENTORY_CHANGED_EVENT = "senpi.rpc.mcp_inventory.changed";
|
|
3
|
+
export function isMcpControlInventoryRequest(value) {
|
|
4
|
+
return (typeof value === "object" &&
|
|
5
|
+
value !== null &&
|
|
6
|
+
"sessionId" in value &&
|
|
7
|
+
typeof value.sessionId === "string" &&
|
|
8
|
+
"respond" in value &&
|
|
9
|
+
typeof value.respond === "function");
|
|
10
|
+
}
|
|
11
|
+
export function isMcpControlInventoryChanged(value) {
|
|
12
|
+
return (typeof value === "object" &&
|
|
13
|
+
value !== null &&
|
|
14
|
+
"sessionId" in value &&
|
|
15
|
+
typeof value.sessionId === "string" &&
|
|
16
|
+
"snapshot" in value &&
|
|
17
|
+
isMcpWireStatusSnapshot(value.snapshot));
|
|
18
|
+
}
|
|
19
|
+
function isMcpWireStatusSnapshot(value) {
|
|
20
|
+
return typeof value === "object" && value !== null && "servers" in value && Array.isArray(value.servers);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=control-inventory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-inventory.js","sourceRoot":"","sources":["../../../../../src/core/extensions/builtin/mcp/control-inventory.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mCAAmC,GAAG,iCAAiC,CAAC;AACrF,MAAM,CAAC,MAAM,mCAAmC,GAAG,iCAAiC,CAAC;AAYrF,MAAM,UAAU,4BAA4B,CAAC,KAAc;IAC1D,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,WAAW,IAAI,KAAK;QACpB,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;QACnC,SAAS,IAAI,KAAK;QAClB,OAAO,KAAK,CAAC,OAAO,KAAK,UAAU,CACnC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAc;IAC1D,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,WAAW,IAAI,KAAK;QACpB,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ;QACnC,UAAU,IAAI,KAAK;QACnB,uBAAuB,CAAC,KAAK,CAAC,QAAQ,CAAC,CACvC,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC1G,CAAC","sourcesContent":["import type { McpWireStatusSnapshot } from \"./service-types.ts\";\n\nexport const MCP_CONTROL_INVENTORY_REQUEST_EVENT = \"senpi.rpc.mcp_inventory.request\";\nexport const MCP_CONTROL_INVENTORY_CHANGED_EVENT = \"senpi.rpc.mcp_inventory.changed\";\n\nexport interface McpControlInventoryRequest {\n\treadonly sessionId: string;\n\trespond(snapshot: Promise<McpWireStatusSnapshot>): void;\n}\n\nexport interface McpControlInventoryChanged {\n\treadonly sessionId: string;\n\treadonly snapshot: McpWireStatusSnapshot;\n}\n\nexport function isMcpControlInventoryRequest(value: unknown): value is McpControlInventoryRequest {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"sessionId\" in value &&\n\t\ttypeof value.sessionId === \"string\" &&\n\t\t\"respond\" in value &&\n\t\ttypeof value.respond === \"function\"\n\t);\n}\n\nexport function isMcpControlInventoryChanged(value: unknown): value is McpControlInventoryChanged {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\t\"sessionId\" in value &&\n\t\ttypeof value.sessionId === \"string\" &&\n\t\t\"snapshot\" in value &&\n\t\tisMcpWireStatusSnapshot(value.snapshot)\n\t);\n}\n\nfunction isMcpWireStatusSnapshot(value: unknown): value is McpWireStatusSnapshot {\n\treturn typeof value === \"object\" && value !== null && \"servers\" in value && Array.isArray(value.servers);\n}\n"]}
|
|
@@ -1,45 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
/** Anthropic caps a request at 10k tools; beyond that native search is invalid. */
|
|
4
|
-
export declare const ANTHROPIC_MAX_TOOLS = 10000;
|
|
5
|
-
export interface AnthropicNativeInjectionConfig {
|
|
6
|
-
/** Never defer this tool (our custom tool_search), and it is non-deferrable. */
|
|
7
|
-
readonly searchToolName?: string;
|
|
8
|
-
/** True for MCP catalog tools eligible for deferral. */
|
|
9
|
-
readonly isDeferrable: (toolName: string) => boolean;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Pure payload transform. Adds exactly one native tool-search tool (idempotent)
|
|
13
|
-
* and sets `defer_loading:true` on eligible MCP tools, enforcing the HARD RULES:
|
|
14
|
-
* never defer the search tool, never combine defer_loading with cache_control
|
|
15
|
-
* (400), keep >=1 non-deferred tool (the native search tool guarantees this),
|
|
16
|
-
* and skip entirely above the 10k tool cap.
|
|
17
|
-
*/
|
|
18
|
-
export declare function addAnthropicNativeToolSearch(api: string | undefined, payload: unknown, config: AnthropicNativeInjectionConfig): unknown;
|
|
19
|
-
/** `tool_reference` blocks emitted inside a tool_result so the API expands the
|
|
20
|
-
* referenced (deferred) tools — the cache-prefix-safe custom-search path. */
|
|
21
|
-
export declare function buildToolReferenceBlocks(names: readonly string[]): {
|
|
22
|
-
type: "tool_reference";
|
|
23
|
-
name: string;
|
|
24
|
-
}[];
|
|
25
|
-
export interface AnthropicNativeAdapterDeps extends AnthropicNativeInjectionConfig {
|
|
26
|
-
/** Resolved config gate (nativeToolSearch auto|true AND provider supports). */
|
|
27
|
-
enabled(): boolean;
|
|
28
|
-
/** Invoked once when a 400 forces the local-search fallback. */
|
|
29
|
-
onFallback?(reason: string): void;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Stateful adapter driving the before_provider_request injection and the
|
|
33
|
-
* after_provider_response 400 detector. Once a 400 lands on a request we
|
|
34
|
-
* injected, native search is disabled for the rest of the session and the
|
|
35
|
-
* extension falls back to local Tier-B (which is always registered).
|
|
36
|
-
*/
|
|
37
|
-
export declare class AnthropicNativeToolSearchAdapter {
|
|
38
|
-
#private;
|
|
39
|
-
constructor(deps: AnthropicNativeAdapterDeps);
|
|
40
|
-
applyBeforeRequest(api: string | undefined, payload: unknown): unknown;
|
|
41
|
-
noteResponseStatus(status: number): void;
|
|
42
|
-
get disabled(): boolean;
|
|
43
|
-
get fallbackReason(): string | null;
|
|
44
|
-
}
|
|
1
|
+
export type { AnthropicNativeAdapterDeps, AnthropicNativeInjectionConfig, NativeToolDefinition, } from "../../tool-search/native-search.ts";
|
|
2
|
+
export { ANTHROPIC_MAX_TOOLS, ANTHROPIC_TOOL_SEARCH_NAME, ANTHROPIC_TOOL_SEARCH_TYPE, AnthropicNativeToolSearchAdapter, addAnthropicNativeToolSearch, buildToolReferenceBlocks, } from "../../tool-search/native-search.ts";
|
|
45
3
|
//# sourceMappingURL=native-search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/native-search.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"native-search.d.ts","sourceRoot":"","sources":["../../../../../../src/core/extensions/builtin/mcp/expose/native-search.ts"],"names":[],"mappings":"AAGA,YAAY,EACX,0BAA0B,EAC1B,8BAA8B,EAC9B,oBAAoB,GACpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,gCAAgC,EAChC,4BAA4B,EAC5B,wBAAwB,GACxB,MAAM,oCAAoC,CAAC"}
|