@alisaitteke/photoshop-mcp 1.1.3 → 1.2.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.
- package/README.md +69 -18
- package/dist/ui/agent/api-key.d.ts +19 -0
- package/dist/ui/agent/api-key.d.ts.map +1 -0
- package/dist/ui/agent/api-key.js +113 -0
- package/dist/ui/agent/api-key.js.map +1 -0
- package/dist/ui/agent/claude-account.d.ts +16 -0
- package/dist/ui/agent/claude-account.d.ts.map +1 -0
- package/dist/ui/agent/claude-account.js +150 -0
- package/dist/ui/agent/claude-account.js.map +1 -0
- package/dist/ui/agent/gemini-account.d.ts +15 -0
- package/dist/ui/agent/gemini-account.d.ts.map +1 -0
- package/dist/ui/agent/gemini-account.js +212 -0
- package/dist/ui/agent/gemini-account.js.map +1 -0
- package/dist/ui/agent/mcp-transport.d.ts +9 -0
- package/dist/ui/agent/mcp-transport.d.ts.map +1 -0
- package/dist/ui/agent/mcp-transport.js +34 -0
- package/dist/ui/agent/mcp-transport.js.map +1 -0
- package/dist/ui/agent/shared.d.ts +30 -0
- package/dist/ui/agent/shared.d.ts.map +1 -0
- package/dist/ui/agent/shared.js +60 -0
- package/dist/ui/agent/shared.js.map +1 -0
- package/dist/ui/agent.d.ts +10 -26
- package/dist/ui/agent.d.ts.map +1 -1
- package/dist/ui/agent.js +49 -170
- package/dist/ui/agent.js.map +1 -1
- package/dist/ui/config.d.ts +7 -0
- package/dist/ui/config.d.ts.map +1 -1
- package/dist/ui/config.js +22 -0
- package/dist/ui/config.js.map +1 -1
- package/dist/ui/providers/anthropic.d.ts.map +1 -1
- package/dist/ui/providers/anthropic.js +24 -0
- package/dist/ui/providers/anthropic.js.map +1 -1
- package/dist/ui/providers/cli-utils.d.ts +12 -0
- package/dist/ui/providers/cli-utils.d.ts.map +1 -0
- package/dist/ui/providers/cli-utils.js +46 -0
- package/dist/ui/providers/cli-utils.js.map +1 -0
- package/dist/ui/providers/google.d.ts.map +1 -1
- package/dist/ui/providers/google.js +18 -0
- package/dist/ui/providers/google.js.map +1 -1
- package/dist/ui/providers/openai.d.ts.map +1 -1
- package/dist/ui/providers/openai.js +1 -0
- package/dist/ui/providers/openai.js.map +1 -1
- package/dist/ui/providers/openrouter.d.ts.map +1 -1
- package/dist/ui/providers/openrouter.js +1 -0
- package/dist/ui/providers/openrouter.js.map +1 -1
- package/dist/ui/providers/registry.d.ts +1 -1
- package/dist/ui/providers/registry.d.ts.map +1 -1
- package/dist/ui/providers/types.d.ts +11 -0
- package/dist/ui/providers/types.d.ts.map +1 -1
- package/dist/ui/server.d.ts.map +1 -1
- package/dist/ui/server.js +72 -11
- package/dist/ui/server.js.map +1 -1
- package/package.json +4 -2
- package/web/dist/assets/index-BN0tu4e6.css +1 -0
- package/web/dist/assets/index-Cf7sH5RM.js +138 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-4AnFityQ.css +0 -1
- package/web/dist/assets/index-CFTrtoOu.js +0 -138
package/README.md
CHANGED
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
[](https://www.typescriptlang.org/)
|
|
10
10
|
[]()
|
|
11
11
|
|
|
12
|
-
A Model Context Protocol (MCP) server that enables AI assistants like Claude and Cursor to control Adobe Photoshop programmatically. This allows you to create designs, manipulate images, and automate Photoshop workflows through natural language commands while working in your IDE.
|
|
12
|
+
A Model Context Protocol (MCP) server that enables AI assistants like Claude and Cursor to control Adobe Photoshop programmatically. This allows you to create designs, manipulate images, and automate Photoshop workflows through natural language commands while working in your IDE — or through the bundled **standalone web UI**, which supports both API keys and CLI subscription accounts (Claude Code / Gemini CLI).
|
|
13
13
|
|
|
14
14
|
## 🖥️ Standalone UI (no IDE required)
|
|
15
15
|
|
|
16
16
|
Don't want to wire this into Claude Desktop or Cursor? The same package ships a
|
|
17
17
|
fully local web UI that lets you chat with an AI model and drive Photoshop
|
|
18
|
-
through this MCP server underneath.
|
|
18
|
+
through this MCP server underneath. Connect with a provider API key **or**, for
|
|
19
|
+
Anthropic and Google, reuse the OAuth session from **Claude Code** or **Gemini
|
|
20
|
+
CLI** — no separate API key required.
|
|
19
21
|
|
|
20
22
|

|
|
21
23
|
|
|
@@ -28,26 +30,54 @@ default browser opens the chat UI automatically.
|
|
|
28
30
|
|
|
29
31
|
### Supported providers
|
|
30
32
|
|
|
31
|
-
Pick any of the following on first launch —
|
|
33
|
+
Pick any of the following on first launch — use an API key **or** your existing
|
|
34
|
+
CLI subscription account (Anthropic and Google):
|
|
32
35
|
|
|
33
|
-
| Provider | Models |
|
|
34
|
-
|
|
35
|
-
| **Anthropic** | Claude Sonnet / Opus / Haiku | [console.anthropic.com](https://console.anthropic.com/settings/keys) |
|
|
36
|
-
| **OpenAI** | GPT-5, GPT-4.1, o-series | [platform.openai.com](https://platform.openai.com/api-keys) |
|
|
37
|
-
| **Google** | Gemini 2.5 Pro / Flash / Flash-Lite | [aistudio.google.com](https://aistudio.google.com/apikey) |
|
|
38
|
-
| **OpenRouter** | 100+ models from any provider | [openrouter.ai](https://openrouter.ai/keys) |
|
|
36
|
+
| Provider | Models | API key | CLI account |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| **Anthropic** | Claude Sonnet / Opus / Haiku | [console.anthropic.com](https://console.anthropic.com/settings/keys) | `npm i -g @anthropic-ai/claude-code` → `claude auth login` |
|
|
39
|
+
| **OpenAI** | GPT-5, GPT-4.1, o-series | [platform.openai.com](https://platform.openai.com/api-keys) | — |
|
|
40
|
+
| **Google** | Gemini 2.5 Pro / Flash / Flash-Lite | [aistudio.google.com](https://aistudio.google.com/apikey) | `npm i -g @google/gemini-cli` → `gemini auth login` |
|
|
41
|
+
| **OpenRouter** | 100+ models from any provider | [openrouter.ai](https://openrouter.ai/keys) | — |
|
|
42
|
+
|
|
43
|
+
### Authentication modes
|
|
44
|
+
|
|
45
|
+
- **`api_key` (default)** — Vercel AI SDK + your provider API key. Usage is billed
|
|
46
|
+
per token at API rates; the UI shows estimated cost per chat.
|
|
47
|
+
- **`cli_account`** — Uses your local Claude Code or Gemini CLI OAuth session.
|
|
48
|
+
No API key is stored; the UI probes `claude auth status` / `gemini` headless
|
|
49
|
+
to verify login. Usage counts against your **subscription quota**, not API
|
|
50
|
+
billing — the status bar shows "Included in subscription".
|
|
51
|
+
|
|
52
|
+
You can switch auth method per provider in Settings without losing the other
|
|
53
|
+
credential (e.g. keep an API key while trying CLI account, then switch back).
|
|
39
54
|
|
|
40
55
|
### What happens on first launch
|
|
41
56
|
|
|
42
|
-
1. Pick a provider and
|
|
43
|
-
2.
|
|
44
|
-
`~/.photoshop-mcp/data.db` (SQLite, `chmod 600`).
|
|
45
|
-
machine
|
|
57
|
+
1. Pick a provider and choose **API key** or **Uses your account**.
|
|
58
|
+
2. Validate the key or check the CLI connection. Config is stored locally at
|
|
59
|
+
`~/.photoshop-mcp/data.db` (SQLite, `chmod 600`). API keys never leave your
|
|
60
|
+
machine; CLI mode inherits OAuth from `~/.claude/` or `~/.gemini/`.
|
|
46
61
|
3. Type natural-language prompts. The UI streams the model's reply, runs
|
|
47
62
|
Photoshop tool calls in real time, and renders each tool call as an
|
|
48
63
|
inspectable card (input + result).
|
|
49
|
-
4. Switch provider or model anytime from
|
|
50
|
-
tool history are persisted across sessions.
|
|
64
|
+
4. Switch provider, auth method, or model anytime from Settings / model selector
|
|
65
|
+
— chats, costs and tool history are persisted across sessions.
|
|
66
|
+
|
|
67
|
+
### Switching auth method later
|
|
68
|
+
|
|
69
|
+
Open **Settings** from the sidebar at any time:
|
|
70
|
+
|
|
71
|
+
| Action | API key mode | CLI account mode |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| Set up | Paste key → **Save** | Install CLI → `auth login` → **Check connection** |
|
|
74
|
+
| Switch away | Choose **API key** — stored key is kept | Choose **Uses your account** — key is not deleted |
|
|
75
|
+
| Custom binary | — | Optional **CLI path** if `claude` / `gemini` is not on `PATH` |
|
|
76
|
+
| Cost display | Per-token estimate in status bar | **Included in subscription** badge |
|
|
77
|
+
|
|
78
|
+
Auth method is stored per provider in `~/.photoshop-mcp/data.db` (`authMethod`:
|
|
79
|
+
`api_key` or `cli_account`). Existing configs without `authMethod` default to
|
|
80
|
+
`api_key` and keep working unchanged.
|
|
51
81
|
|
|
52
82
|
### CLI flags
|
|
53
83
|
|
|
@@ -60,9 +90,15 @@ photoshop-mcp-ui [--port 5174] [--host 127.0.0.1] [--no-open]
|
|
|
60
90
|
- The agent is restricted to Photoshop MCP tools only — built-in shell, file
|
|
61
91
|
and web tools are disabled.
|
|
62
92
|
- Tech stack: Vue 3 + Tailwind v4 + [shadcn-vue](https://www.shadcn-vue.com/)
|
|
63
|
-
on the frontend; [Hono](https://hono.dev/)
|
|
64
|
-
|
|
65
|
-
|
|
93
|
+
on the frontend; [Hono](https://hono.dev/) on the backend. API-key mode uses
|
|
94
|
+
the [Vercel AI SDK](https://sdk.vercel.ai/); CLI account mode uses the
|
|
95
|
+
[Claude Agent SDK](https://code.claude.com/docs/en/agent-sdk/mcp) (Anthropic)
|
|
96
|
+
or Gemini CLI headless `stream-json` (Google). All paths talk to this same
|
|
97
|
+
Photoshop MCP server over STDIO.
|
|
98
|
+
- **CLI account limitations:** Gemini headless may open a new session each turn
|
|
99
|
+
(history is prepended to the prompt). Anthropic CLI account consumes
|
|
100
|
+
subscription quota. OAuth login is macOS-first (`claude auth login` /
|
|
101
|
+
`gemini auth login` in Terminal).
|
|
66
102
|
|
|
67
103
|
---
|
|
68
104
|
|
|
@@ -388,6 +424,8 @@ Never guess — read get_state after a failure and propose the next single step.
|
|
|
388
424
|
|
|
389
425
|
## Features
|
|
390
426
|
|
|
427
|
+
- **Standalone web UI** — local chat interface (`photoshop-mcp-ui`); API key or CLI
|
|
428
|
+
subscription auth per provider (Anthropic, Google)
|
|
391
429
|
- **Works on both Windows and macOS**
|
|
392
430
|
- **Supports Photoshop 2012-2025+**
|
|
393
431
|
- **ExtendScript API**: Universal compatibility via AppleScript/COM automation
|
|
@@ -531,6 +569,9 @@ This context helps AI assistants remember what document and layer they're workin
|
|
|
531
569
|
- Uses AppleScript/OSA for Photoshop communication
|
|
532
570
|
- Spotlight-based auto-detection
|
|
533
571
|
- Supports multiple Photoshop versions installed simultaneously
|
|
572
|
+
- **CLI account auth** (standalone UI) is macOS-first: run `claude auth login` /
|
|
573
|
+
`gemini auth login` in Terminal; credentials live under `~/.claude/` and
|
|
574
|
+
`~/.gemini/`
|
|
534
575
|
|
|
535
576
|
## Supported Photoshop Versions
|
|
536
577
|
|
|
@@ -543,6 +584,16 @@ This context helps AI assistants remember what document and layer they're workin
|
|
|
543
584
|
Common connection, scripting, and logging issues:
|
|
544
585
|
[`docs/troubleshooting.md`](docs/troubleshooting.md).
|
|
545
586
|
|
|
587
|
+
### Standalone UI — CLI account auth
|
|
588
|
+
|
|
589
|
+
| Symptom | Likely cause | Fix |
|
|
590
|
+
|---|---|---|
|
|
591
|
+
| `cli_not_found` | Claude Code / Gemini CLI not installed | `npm i -g @anthropic-ai/claude-code` or `npm i -g @google/gemini-cli` |
|
|
592
|
+
| `not_authenticated` | No OAuth session | Run `claude auth login` or `gemini auth login` in Terminal |
|
|
593
|
+
| `claude` / `gemini` not on `PATH` | Custom install location | Settings → **CLI path** → **Check connection** |
|
|
594
|
+
| Chat works in IDE but not UI (CLI mode) | OAuth tokens are CLI-only | Use **CLI account** in UI; API keys and CLI sessions are separate |
|
|
595
|
+
| Gemini multi-turn feels forgetful | Headless CLI may start a fresh session each turn | Known limitation; history is prepended to the prompt (MVP) |
|
|
596
|
+
|
|
546
597
|
## Development
|
|
547
598
|
|
|
548
599
|
From-source setup, build, lint, integration tests (with latest results), and usage examples:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ProviderAdapter } from '../providers/registry.js';
|
|
2
|
+
import type { AuthMethod } from '../providers/types.js';
|
|
3
|
+
import type { ModelMessage } from 'ai';
|
|
4
|
+
import { type AssistantBuffer, type RunChatFinishInfo, type RunChatStreamEvent } from './shared.js';
|
|
5
|
+
export interface RunChatViaApiKeyOptions {
|
|
6
|
+
prompt: string;
|
|
7
|
+
history: ModelMessage[];
|
|
8
|
+
provider: ProviderAdapter;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
modelId: string;
|
|
11
|
+
chatId?: string;
|
|
12
|
+
authMethod?: AuthMethod;
|
|
13
|
+
systemPrompt: string;
|
|
14
|
+
abortSignal: AbortSignal;
|
|
15
|
+
onAssistantBuffer?: (buf: AssistantBuffer) => void;
|
|
16
|
+
onFinish?: (info: RunChatFinishInfo) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function runChatViaApiKey(opts: RunChatViaApiKeyOptions): AsyncGenerator<RunChatStreamEvent>;
|
|
19
|
+
//# sourceMappingURL=api-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.d.ts","sourceRoot":"","sources":["../../../src/ui/agent/api-key.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGvC,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAuB,gBAAgB,CACrC,IAAI,EAAE,uBAAuB,GAC5B,cAAc,CAAC,kBAAkB,CAAC,CA2GpC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { createMCPClient } from '@ai-sdk/mcp';
|
|
2
|
+
import { Experimental_StdioMCPTransport } from '@ai-sdk/mcp/mcp-stdio';
|
|
3
|
+
import { stepCountIs, streamText } from 'ai';
|
|
4
|
+
import { buildSpawnArgs, sanitizedEnv } from './mcp-transport.js';
|
|
5
|
+
import { PHOTOSHOP_EXPORT_CHAT_ID_ENV } from '../../lib/export-paths.js';
|
|
6
|
+
import { computeCost, stringifyToolOutput, } from './shared.js';
|
|
7
|
+
export async function* runChatViaApiKey(opts) {
|
|
8
|
+
let mcp;
|
|
9
|
+
const buffer = { text: '', toolCalls: [] };
|
|
10
|
+
try {
|
|
11
|
+
mcp = await createMCPClient({
|
|
12
|
+
transport: new Experimental_StdioMCPTransport({
|
|
13
|
+
command: process.execPath,
|
|
14
|
+
args: buildSpawnArgs(),
|
|
15
|
+
env: {
|
|
16
|
+
...sanitizedEnv(),
|
|
17
|
+
LOG_LEVEL: process.env.LOG_LEVEL ?? '2',
|
|
18
|
+
...(opts.chatId ? { [PHOTOSHOP_EXPORT_CHAT_ID_ENV]: opts.chatId } : {}),
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
const tools = await mcp.tools();
|
|
23
|
+
const result = streamText({
|
|
24
|
+
model: opts.provider.getLanguageModel({
|
|
25
|
+
apiKey: opts.apiKey,
|
|
26
|
+
modelId: opts.modelId,
|
|
27
|
+
}),
|
|
28
|
+
tools,
|
|
29
|
+
system: opts.systemPrompt,
|
|
30
|
+
messages: [...opts.history, { role: 'user', content: opts.prompt }],
|
|
31
|
+
stopWhen: stepCountIs(20),
|
|
32
|
+
abortSignal: opts.abortSignal,
|
|
33
|
+
});
|
|
34
|
+
for await (const part of result.fullStream) {
|
|
35
|
+
switch (part.type) {
|
|
36
|
+
case 'text-delta': {
|
|
37
|
+
buffer.text += part.text;
|
|
38
|
+
yield { type: 'text-delta', payload: { text: part.text } };
|
|
39
|
+
opts.onAssistantBuffer?.(buffer);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'tool-call': {
|
|
43
|
+
const tc = {
|
|
44
|
+
id: part.toolCallId,
|
|
45
|
+
name: part.toolName,
|
|
46
|
+
input: part.input,
|
|
47
|
+
status: 'pending',
|
|
48
|
+
};
|
|
49
|
+
buffer.toolCalls.push(tc);
|
|
50
|
+
yield {
|
|
51
|
+
type: 'tool-call',
|
|
52
|
+
payload: { id: tc.id, name: tc.name, input: tc.input },
|
|
53
|
+
};
|
|
54
|
+
opts.onAssistantBuffer?.(buffer);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case 'tool-result': {
|
|
58
|
+
const tc = buffer.toolCalls.find((c) => c.id === part.toolCallId);
|
|
59
|
+
const text = stringifyToolOutput(part.output);
|
|
60
|
+
if (tc) {
|
|
61
|
+
tc.result = { ok: true, content: text };
|
|
62
|
+
tc.status = 'success';
|
|
63
|
+
}
|
|
64
|
+
yield {
|
|
65
|
+
type: 'tool-result',
|
|
66
|
+
payload: { id: part.toolCallId, ok: true, content: text },
|
|
67
|
+
};
|
|
68
|
+
opts.onAssistantBuffer?.(buffer);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case 'tool-error': {
|
|
72
|
+
const tc = buffer.toolCalls.find((c) => c.id === part.toolCallId);
|
|
73
|
+
const text = part.error?.message ?? String(part.error);
|
|
74
|
+
if (tc) {
|
|
75
|
+
tc.result = { ok: false, content: text };
|
|
76
|
+
tc.status = 'error';
|
|
77
|
+
}
|
|
78
|
+
yield {
|
|
79
|
+
type: 'tool-result',
|
|
80
|
+
payload: { id: part.toolCallId, ok: false, content: text },
|
|
81
|
+
};
|
|
82
|
+
opts.onAssistantBuffer?.(buffer);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'finish': {
|
|
86
|
+
const usage = part.totalUsage;
|
|
87
|
+
const pricing = opts.provider.getModelPricing(opts.modelId);
|
|
88
|
+
const cost = pricing ? computeCost(usage, pricing) : undefined;
|
|
89
|
+
opts.onFinish?.({ usage, cost });
|
|
90
|
+
yield {
|
|
91
|
+
type: 'finish',
|
|
92
|
+
payload: { finishReason: part.finishReason, usage, cost },
|
|
93
|
+
};
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 'error': {
|
|
97
|
+
yield {
|
|
98
|
+
type: 'error',
|
|
99
|
+
payload: { message: part.error?.message ?? String(part.error) },
|
|
100
|
+
};
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
default:
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
if (mcp)
|
|
110
|
+
await mcp.close().catch(() => undefined);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=api-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key.js","sourceRoot":"","sources":["../../../src/ui/agent/api-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAI7C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EACL,WAAW,EACX,mBAAmB,GAIpB,MAAM,aAAa,CAAC;AAgBrB,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,gBAAgB,CACrC,IAA6B;IAE7B,IAAI,GAA0B,CAAC;IAC/B,MAAM,MAAM,GAAo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EAAE,IAAI,EAAE,CAAC,CAAC;oBACjC,MAAM;wBACJ,IAAI,EAAE,QAAQ;wBACd,OAAO,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE;qBAC1D,CAAC;oBACF,MAAM;gBACR,CAAC;gBACD,KAAK,OAAO,CAAC,CAAC,CAAC;oBACb,MAAM;wBACJ,IAAI,EAAE,OAAO;wBACb,OAAO,EAAE,EAAE,OAAO,EAAG,IAAI,CAAC,KAAe,EAAE,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;qBAC3E,CAAC;oBACF,MAAM;gBACR,CAAC;gBACD;oBACE,MAAM;YACV,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,GAAG;YAAE,MAAM,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ModelMessage } from 'ai';
|
|
2
|
+
import type { ProviderAdapter } from '../providers/registry.js';
|
|
3
|
+
import { type AssistantBuffer, type RunChatFinishInfo, type RunChatStreamEvent } from './shared.js';
|
|
4
|
+
export interface RunChatViaClaudeAccountOptions {
|
|
5
|
+
prompt: string;
|
|
6
|
+
history: ModelMessage[];
|
|
7
|
+
provider: ProviderAdapter;
|
|
8
|
+
modelId: string;
|
|
9
|
+
chatId?: string;
|
|
10
|
+
systemPrompt: string;
|
|
11
|
+
abortSignal: AbortSignal;
|
|
12
|
+
onAssistantBuffer?: (buf: AssistantBuffer) => void;
|
|
13
|
+
onFinish?: (info: RunChatFinishInfo) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function runChatViaClaudeAccount(opts: RunChatViaClaudeAccountOptions): AsyncGenerator<RunChatStreamEvent>;
|
|
16
|
+
//# sourceMappingURL=claude-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-account.d.ts","sourceRoot":"","sources":["../../../src/ui/agent/claude-account.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,QAAQ,EAAE,eAAe,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAuB,uBAAuB,CAC5C,IAAI,EAAE,8BAA8B,GACnC,cAAc,CAAC,kBAAkB,CAAC,CAgIpC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import { buildMcpServerConfig } from './mcp-transport.js';
|
|
3
|
+
import { buildPromptWithHistory, stringifyToolOutput, } from './shared.js';
|
|
4
|
+
export async function* runChatViaClaudeAccount(opts) {
|
|
5
|
+
const buffer = { text: '', toolCalls: [] };
|
|
6
|
+
const seenToolCalls = new Set();
|
|
7
|
+
const seenToolResults = new Set();
|
|
8
|
+
const abortController = new AbortController();
|
|
9
|
+
const onAbort = () => abortController.abort();
|
|
10
|
+
opts.abortSignal.addEventListener('abort', onAbort);
|
|
11
|
+
const prompt = buildPromptWithHistory(opts.history, opts.prompt);
|
|
12
|
+
const q = query({
|
|
13
|
+
prompt,
|
|
14
|
+
options: {
|
|
15
|
+
model: opts.modelId,
|
|
16
|
+
systemPrompt: opts.systemPrompt,
|
|
17
|
+
maxTurns: 20,
|
|
18
|
+
permissionMode: 'bypassPermissions',
|
|
19
|
+
allowDangerouslySkipPermissions: true,
|
|
20
|
+
strictMcpConfig: true,
|
|
21
|
+
mcpServers: {
|
|
22
|
+
photoshop: buildMcpServerConfig(opts.chatId),
|
|
23
|
+
},
|
|
24
|
+
allowedTools: ['mcp__photoshop__*'],
|
|
25
|
+
abortController,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
for await (const message of q) {
|
|
30
|
+
if (opts.abortSignal.aborted)
|
|
31
|
+
break;
|
|
32
|
+
if (message.type === 'assistant') {
|
|
33
|
+
if (message.error === 'authentication_failed') {
|
|
34
|
+
yield {
|
|
35
|
+
type: 'error',
|
|
36
|
+
payload: {
|
|
37
|
+
message: 'Claude account authentication failed. Run `claude auth login` and try again.',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
for (const block of message.message.content) {
|
|
43
|
+
if ('text' in block && typeof block.text === 'string' && block.text) {
|
|
44
|
+
buffer.text += block.text;
|
|
45
|
+
yield { type: 'text-delta', payload: { text: block.text } };
|
|
46
|
+
opts.onAssistantBuffer?.(buffer);
|
|
47
|
+
}
|
|
48
|
+
if (block.type === 'tool_use' && !seenToolCalls.has(block.id)) {
|
|
49
|
+
seenToolCalls.add(block.id);
|
|
50
|
+
const tc = {
|
|
51
|
+
id: block.id,
|
|
52
|
+
name: block.name,
|
|
53
|
+
input: block.input,
|
|
54
|
+
status: 'pending',
|
|
55
|
+
};
|
|
56
|
+
buffer.toolCalls.push(tc);
|
|
57
|
+
yield {
|
|
58
|
+
type: 'tool-call',
|
|
59
|
+
payload: { id: tc.id, name: tc.name, input: tc.input },
|
|
60
|
+
};
|
|
61
|
+
opts.onAssistantBuffer?.(buffer);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (message.type === 'user' && message.tool_use_result !== undefined) {
|
|
67
|
+
const toolUseId = typeof message.parent_tool_use_id === 'string'
|
|
68
|
+
? message.parent_tool_use_id
|
|
69
|
+
: extractToolUseId(message);
|
|
70
|
+
if (!toolUseId || seenToolResults.has(toolUseId))
|
|
71
|
+
continue;
|
|
72
|
+
seenToolResults.add(toolUseId);
|
|
73
|
+
const text = stringifyToolOutput(message.tool_use_result);
|
|
74
|
+
const tc = buffer.toolCalls.find((c) => c.id === toolUseId);
|
|
75
|
+
const ok = !isToolErrorResult(message.tool_use_result);
|
|
76
|
+
if (tc) {
|
|
77
|
+
tc.result = { ok, content: text };
|
|
78
|
+
tc.status = ok ? 'success' : 'error';
|
|
79
|
+
}
|
|
80
|
+
yield {
|
|
81
|
+
type: 'tool-result',
|
|
82
|
+
payload: { id: toolUseId, ok, content: text },
|
|
83
|
+
};
|
|
84
|
+
opts.onAssistantBuffer?.(buffer);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (message.type === 'result') {
|
|
88
|
+
const usage = {
|
|
89
|
+
inputTokens: message.usage.input_tokens,
|
|
90
|
+
outputTokens: message.usage.output_tokens,
|
|
91
|
+
totalTokens: message.usage.input_tokens + message.usage.output_tokens,
|
|
92
|
+
inputTokenDetails: {
|
|
93
|
+
noCacheTokens: message.usage.input_tokens,
|
|
94
|
+
cacheReadTokens: 0,
|
|
95
|
+
cacheWriteTokens: 0,
|
|
96
|
+
},
|
|
97
|
+
outputTokenDetails: {
|
|
98
|
+
textTokens: message.usage.output_tokens,
|
|
99
|
+
reasoningTokens: 0,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
opts.onFinish?.({ usage });
|
|
103
|
+
yield {
|
|
104
|
+
type: 'finish',
|
|
105
|
+
payload: {
|
|
106
|
+
finishReason: message.subtype === 'success' ? 'stop' : message.subtype,
|
|
107
|
+
usage,
|
|
108
|
+
subscription: true,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
if (message.subtype !== 'success') {
|
|
112
|
+
const errors = 'errors' in message && Array.isArray(message.errors) ? message.errors : [];
|
|
113
|
+
if (errors.length) {
|
|
114
|
+
yield { type: 'error', payload: { message: errors.join('; ') } };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
finally {
|
|
121
|
+
opts.abortSignal.removeEventListener('abort', onAbort);
|
|
122
|
+
q.close();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function extractToolUseId(message) {
|
|
126
|
+
const content = message.message.content;
|
|
127
|
+
if (!Array.isArray(content))
|
|
128
|
+
return null;
|
|
129
|
+
for (const block of content) {
|
|
130
|
+
if (typeof block === 'object' &&
|
|
131
|
+
block !== null &&
|
|
132
|
+
'type' in block &&
|
|
133
|
+
block.type === 'tool_result' &&
|
|
134
|
+
'tool_use_id' in block &&
|
|
135
|
+
typeof block.tool_use_id === 'string') {
|
|
136
|
+
return block.tool_use_id;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function isToolErrorResult(result) {
|
|
142
|
+
if (typeof result !== 'object' || result === null)
|
|
143
|
+
return false;
|
|
144
|
+
if ('is_error' in result && result.is_error === true)
|
|
145
|
+
return true;
|
|
146
|
+
if ('error' in result && result.error)
|
|
147
|
+
return true;
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=claude-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-account.js","sourceRoot":"","sources":["../../../src/ui/agent/claude-account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAGvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EACL,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,KAAK,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA0C;IAClE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IACE,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,MAAM,IAAI,KAAK;YACf,KAAK,CAAC,IAAI,KAAK,aAAa;YAC5B,aAAa,IAAI,KAAK;YACtB,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,EACrC,CAAC;YACD,OAAO,KAAK,CAAC,WAAW,CAAC;QAC3B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAe;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAChE,IAAI,UAAU,IAAI,MAAM,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAClE,IAAI,OAAO,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModelMessage } from 'ai';
|
|
2
|
+
import { type AssistantBuffer, type RunChatFinishInfo, type RunChatStreamEvent } from './shared.js';
|
|
3
|
+
export interface RunChatViaGeminiAccountOptions {
|
|
4
|
+
prompt: string;
|
|
5
|
+
history: ModelMessage[];
|
|
6
|
+
modelId: string;
|
|
7
|
+
chatId?: string;
|
|
8
|
+
cliPath?: string;
|
|
9
|
+
systemPrompt: string;
|
|
10
|
+
abortSignal: AbortSignal;
|
|
11
|
+
onAssistantBuffer?: (buf: AssistantBuffer) => void;
|
|
12
|
+
onFinish?: (info: RunChatFinishInfo) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function runChatViaGeminiAccount(opts: RunChatViaGeminiAccountOptions): AsyncGenerator<RunChatStreamEvent>;
|
|
15
|
+
//# sourceMappingURL=gemini-account.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gemini-account.d.ts","sourceRoot":"","sources":["../../../src/ui/agent/gemini-account.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGvC,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC9C;AAoBD,wBAAuB,uBAAuB,CAC5C,IAAI,EAAE,8BAA8B,GACnC,cAAc,CAAC,kBAAkB,CAAC,CAyEpC"}
|