gpt-connector 0.1.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/LICENSE +21 -0
- package/README.md +163 -0
- package/dist/src/asset-discovery.d.ts +9 -0
- package/dist/src/asset-discovery.js +73 -0
- package/dist/src/asset-discovery.js.map +1 -0
- package/dist/src/cdp.d.ts +29 -0
- package/dist/src/cdp.js +182 -0
- package/dist/src/cdp.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +63 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/connector.d.ts +16 -0
- package/dist/src/connector.js +222 -0
- package/dist/src/connector.js.map +1 -0
- package/dist/src/contract.d.ts +36 -0
- package/dist/src/contract.js +16 -0
- package/dist/src/contract.js.map +1 -0
- package/dist/src/errors.d.ts +7 -0
- package/dist/src/errors.js +23 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +12 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp-server.d.ts +19 -0
- package/dist/src/mcp-server.js +96 -0
- package/dist/src/mcp-server.js.map +1 -0
- package/dist/src/mcp.d.ts +2 -0
- package/dist/src/mcp.js +17 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/model-catalog.d.ts +23 -0
- package/dist/src/model-catalog.js +61 -0
- package/dist/src/model-catalog.js.map +1 -0
- package/dist/src/page-bridge.d.ts +4 -0
- package/dist/src/page-bridge.js +364 -0
- package/dist/src/page-bridge.js.map +1 -0
- package/dist/src/redaction.d.ts +1 -0
- package/dist/src/redaction.js +17 -0
- package/dist/src/redaction.js.map +1 -0
- package/dist/src/runtime-evaluate.d.ts +2 -0
- package/dist/src/runtime-evaluate.js +14 -0
- package/dist/src/runtime-evaluate.js.map +1 -0
- package/dist/src/session-registry.d.ts +18 -0
- package/dist/src/session-registry.js +57 -0
- package/dist/src/session-registry.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { discoverRuntimeAssets, listLoadedAssetUrls } from "./asset-discovery.js";
|
|
4
|
+
import { CdpClient, discoverChatGptTarget } from "./cdp.js";
|
|
5
|
+
import { chatInputSchema, closeInputSchema, } from "./contract.js";
|
|
6
|
+
import { ConnectorError, connectorErrorCodes, } from "./errors.js";
|
|
7
|
+
import { validateModelSelection } from "./model-catalog.js";
|
|
8
|
+
import { bridgeBuildId, createBridgeBootstrapExpression, createBridgeCallExpression, } from "./page-bridge.js";
|
|
9
|
+
import { evaluateByValue } from "./runtime-evaluate.js";
|
|
10
|
+
import { SessionRegistry } from "./session-registry.js";
|
|
11
|
+
const operationStartSchema = z.object({ operationId: z.string().uuid() });
|
|
12
|
+
const operationErrorSchema = z.object({
|
|
13
|
+
code: z.string(),
|
|
14
|
+
message: z.string(),
|
|
15
|
+
});
|
|
16
|
+
const operationEnvelopeSchema = z.object({
|
|
17
|
+
state: z.enum(["pending", "succeeded", "failed"]),
|
|
18
|
+
result: z.unknown().nullable().optional(),
|
|
19
|
+
error: operationErrorSchema.nullable().optional(),
|
|
20
|
+
});
|
|
21
|
+
const modelCatalogSchema = z.object({
|
|
22
|
+
defaultModel: z.string().nullable(),
|
|
23
|
+
models: z.array(z.object({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
title: z.string(),
|
|
26
|
+
reasoningType: z.string().nullable(),
|
|
27
|
+
efforts: z.array(z.string()),
|
|
28
|
+
configurableEffort: z.boolean(),
|
|
29
|
+
maxTokens: z.number().nullable(),
|
|
30
|
+
})),
|
|
31
|
+
});
|
|
32
|
+
const chatResultSchema = z.object({
|
|
33
|
+
text: z.string().min(1),
|
|
34
|
+
status: z.string(),
|
|
35
|
+
endTurn: z.literal(true),
|
|
36
|
+
resolvedModel: z.string().nullable(),
|
|
37
|
+
resolvedEffort: z.string().nullable(),
|
|
38
|
+
sessionId: z.string().uuid().optional(),
|
|
39
|
+
});
|
|
40
|
+
const closeResultSchema = z.object({ archived: z.literal(true) });
|
|
41
|
+
export class GptConnector {
|
|
42
|
+
#client;
|
|
43
|
+
#sessions = new SessionRegistry();
|
|
44
|
+
#operationTimeoutMs;
|
|
45
|
+
#pollIntervalMs;
|
|
46
|
+
constructor(client, options) {
|
|
47
|
+
this.#client = client;
|
|
48
|
+
this.#operationTimeoutMs = options.operationTimeoutMs ?? 180_000;
|
|
49
|
+
this.#pollIntervalMs = options.pollIntervalMs ?? 250;
|
|
50
|
+
}
|
|
51
|
+
static async connect(options = {}) {
|
|
52
|
+
const endpoint = options.endpoint ?? "http://127.0.0.1:9223";
|
|
53
|
+
const target = await discoverChatGptTarget(endpoint);
|
|
54
|
+
const client = await CdpClient.connect(target.webSocketDebuggerUrl);
|
|
55
|
+
const connector = new GptConnector(client, options);
|
|
56
|
+
try {
|
|
57
|
+
await client.call("Runtime.enable");
|
|
58
|
+
await connector.#bootstrap();
|
|
59
|
+
return connector;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
client.close();
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async models() {
|
|
67
|
+
const result = await this.#runOperation("startModels", []);
|
|
68
|
+
return modelCatalogSchema.parse(result);
|
|
69
|
+
}
|
|
70
|
+
async chat(input) {
|
|
71
|
+
const parsed = chatInputSchema.parse(input);
|
|
72
|
+
const catalog = await this.models();
|
|
73
|
+
validateModelSelection(catalog, parsed.model, parsed.effort);
|
|
74
|
+
const existingSession = parsed.sessionId;
|
|
75
|
+
if (existingSession !== undefined)
|
|
76
|
+
this.#sessions.acquire(existingSession);
|
|
77
|
+
try {
|
|
78
|
+
const raw = await this.#runOperation("startChat", [parsed]);
|
|
79
|
+
const result = chatResultSchema.parse(raw);
|
|
80
|
+
if (existingSession !== undefined) {
|
|
81
|
+
if (parsed.keepOpen)
|
|
82
|
+
this.#sessions.release(existingSession);
|
|
83
|
+
else
|
|
84
|
+
this.#sessions.delete(existingSession);
|
|
85
|
+
}
|
|
86
|
+
else if (result.sessionId !== undefined) {
|
|
87
|
+
this.#sessions.register(result.sessionId);
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (existingSession !== undefined && this.#sessions.has(existingSession)) {
|
|
93
|
+
if (parsed.keepOpen ||
|
|
94
|
+
(error instanceof ConnectorError && error.code === "ARCHIVE_FAILED")) {
|
|
95
|
+
this.#sessions.release(existingSession);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
this.#sessions.delete(existingSession);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async closeSession(input) {
|
|
105
|
+
const parsed = closeInputSchema.parse(input);
|
|
106
|
+
this.#sessions.acquire(parsed.sessionId);
|
|
107
|
+
try {
|
|
108
|
+
const raw = await this.#runOperation("startClose", [parsed]);
|
|
109
|
+
const result = closeResultSchema.parse(raw);
|
|
110
|
+
this.#sessions.delete(parsed.sessionId);
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (this.#sessions.has(parsed.sessionId))
|
|
115
|
+
this.#sessions.release(parsed.sessionId);
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
close() {
|
|
120
|
+
this.#client.close();
|
|
121
|
+
}
|
|
122
|
+
async shutdown() {
|
|
123
|
+
const failures = [];
|
|
124
|
+
for (const sessionId of this.#sessions.ids()) {
|
|
125
|
+
try {
|
|
126
|
+
await this.closeSession({ sessionId });
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
failures.push(error instanceof ConnectorError ? error.code : "CHAT_FAILED");
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.#client.close();
|
|
133
|
+
if (failures.length > 0) {
|
|
134
|
+
throw new ConnectorError("ARCHIVE_FAILED", "shutdown時に一部sessionをarchiveできませんでした。", { failureCount: failures.length });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async #bootstrap() {
|
|
138
|
+
const auth = await evaluateByValue(this.#client, String.raw `(async () => {
|
|
139
|
+
const response = await fetch("/api/auth/session", { credentials: "include" });
|
|
140
|
+
let authenticated = false;
|
|
141
|
+
if (response.ok) {
|
|
142
|
+
const data = await response.json();
|
|
143
|
+
authenticated = Boolean(data?.user);
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
status: response.status,
|
|
147
|
+
authenticated,
|
|
148
|
+
officialOrigin: location.origin === "https://chatgpt.com"
|
|
149
|
+
};
|
|
150
|
+
})()`);
|
|
151
|
+
if (!auth.officialOrigin) {
|
|
152
|
+
throw new ConnectorError("RUNTIME_DRIFT", "page targetがChatGPT公式originではありません。");
|
|
153
|
+
}
|
|
154
|
+
if (!auth.authenticated) {
|
|
155
|
+
throw new ConnectorError("AUTH_REQUIRED", "専用ChromeでChatGPTへログインしてください。", {
|
|
156
|
+
status: auth.status,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
const existingBridge = await evaluateByValue(this.#client, `(() => {
|
|
160
|
+
const bridge = globalThis.__gptConnectorBridgeV1;
|
|
161
|
+
return bridge?.version === 1 &&
|
|
162
|
+
bridge?.buildId === ${JSON.stringify(bridgeBuildId)} &&
|
|
163
|
+
typeof bridge.summary === "function"
|
|
164
|
+
? bridge.summary()
|
|
165
|
+
: null;
|
|
166
|
+
})()`);
|
|
167
|
+
const existingBridgeResult = z
|
|
168
|
+
.object({
|
|
169
|
+
version: z.literal(1),
|
|
170
|
+
buildId: z.literal(bridgeBuildId),
|
|
171
|
+
ready: z.literal(true),
|
|
172
|
+
})
|
|
173
|
+
.safeParse(existingBridge);
|
|
174
|
+
if (existingBridgeResult.success)
|
|
175
|
+
return;
|
|
176
|
+
const urls = await listLoadedAssetUrls(this.#client);
|
|
177
|
+
const assets = await discoverRuntimeAssets(urls);
|
|
178
|
+
const summary = await evaluateByValue(this.#client, createBridgeBootstrapExpression(assets.coreUrl, assets.conversationUrl));
|
|
179
|
+
const parsed = z
|
|
180
|
+
.object({
|
|
181
|
+
version: z.literal(1),
|
|
182
|
+
buildId: z.literal(bridgeBuildId),
|
|
183
|
+
ready: z.literal(true),
|
|
184
|
+
})
|
|
185
|
+
.safeParse(summary);
|
|
186
|
+
if (!parsed.success) {
|
|
187
|
+
throw new ConnectorError("RUNTIME_DRIFT", "page bridgeを初期化できませんでした。", {
|
|
188
|
+
coreFingerprint: assets.coreFingerprint,
|
|
189
|
+
conversationFingerprint: assets.conversationFingerprint,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async #runOperation(method, args) {
|
|
194
|
+
const started = operationStartSchema.parse(await evaluateByValue(this.#client, createBridgeCallExpression(method, args), false));
|
|
195
|
+
const deadline = Date.now() + this.#operationTimeoutMs;
|
|
196
|
+
while (Date.now() < deadline) {
|
|
197
|
+
const envelope = operationEnvelopeSchema.parse(await evaluateByValue(this.#client, createBridgeCallExpression("poll", [started.operationId, false]), false));
|
|
198
|
+
if (envelope.state === "succeeded") {
|
|
199
|
+
await this.#consumeOperation(started.operationId);
|
|
200
|
+
return envelope.result;
|
|
201
|
+
}
|
|
202
|
+
if (envelope.state === "failed") {
|
|
203
|
+
await this.#consumeOperation(started.operationId);
|
|
204
|
+
const error = envelope.error;
|
|
205
|
+
throw new ConnectorError(toConnectorErrorCode(error?.code), error?.message ?? "ChatGPT runtime operationが失敗しました。");
|
|
206
|
+
}
|
|
207
|
+
await delay(this.#pollIntervalMs);
|
|
208
|
+
}
|
|
209
|
+
throw new ConnectorError("CHAT_FAILED", "ChatGPT runtime operationがtimeoutしました。", {
|
|
210
|
+
method,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async #consumeOperation(operationId) {
|
|
214
|
+
await evaluateByValue(this.#client, createBridgeCallExpression("poll", [operationId, true]), false);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function toConnectorErrorCode(value) {
|
|
218
|
+
return connectorErrorCodes.includes(value)
|
|
219
|
+
? value
|
|
220
|
+
: "CHAT_FAILED";
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.js","sourceRoot":"","sources":["../../src/connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,gBAAgB,GAMjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAE1E,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAC;AAEH,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,CAA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>;
|
|
5
|
+
effort: z.ZodOptional<z.ZodString>;
|
|
6
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
7
|
+
keepOpen: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
}, z.core.$strict>;
|
|
9
|
+
export type ChatInput = z.input<typeof chatInputSchema>;
|
|
10
|
+
export declare const closeInputSchema: z.ZodObject<{
|
|
11
|
+
sessionId: z.ZodString;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export type CloseInput = z.input<typeof closeInputSchema>;
|
|
14
|
+
export interface ModelChoice {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
readonly title: string;
|
|
17
|
+
readonly reasoningType: string | null;
|
|
18
|
+
readonly efforts: readonly string[];
|
|
19
|
+
readonly configurableEffort: boolean;
|
|
20
|
+
readonly maxTokens: number | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ModelCatalog {
|
|
23
|
+
readonly defaultModel: string | null;
|
|
24
|
+
readonly models: readonly ModelChoice[];
|
|
25
|
+
}
|
|
26
|
+
export interface ChatResult {
|
|
27
|
+
readonly text: string;
|
|
28
|
+
readonly status: string;
|
|
29
|
+
readonly endTurn: true;
|
|
30
|
+
readonly resolvedModel: string | null;
|
|
31
|
+
readonly resolvedEffort: string | null;
|
|
32
|
+
readonly sessionId?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CloseResult {
|
|
35
|
+
readonly archived: true;
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const chatInputSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
prompt: z.string().min(1),
|
|
5
|
+
model: z.string().min(1).optional(),
|
|
6
|
+
effort: z.string().min(1).optional(),
|
|
7
|
+
sessionId: z.string().uuid().optional(),
|
|
8
|
+
keepOpen: z.boolean().default(false),
|
|
9
|
+
})
|
|
10
|
+
.strict();
|
|
11
|
+
export const closeInputSchema = z
|
|
12
|
+
.object({
|
|
13
|
+
sessionId: z.string().uuid(),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
//# sourceMappingURL=contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,CAAC;IACN,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACvC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACrC,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;CAC7B,CAAC;KACD,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const connectorErrorCodes: readonly ["AUTH_REQUIRED", "CDP_UNAVAILABLE", "RUNTIME_DRIFT", "MODEL_NOT_AVAILABLE", "EFFORT_NOT_SUPPORTED", "CHAT_FAILED", "STREAM_INCOMPLETE", "SESSION_NOT_FOUND", "SESSION_BUSY", "ARCHIVE_FAILED"];
|
|
2
|
+
export type ConnectorErrorCode = (typeof connectorErrorCodes)[number];
|
|
3
|
+
export declare class ConnectorError extends Error {
|
|
4
|
+
readonly code: ConnectorErrorCode;
|
|
5
|
+
readonly details?: Readonly<Record<string, string | number | boolean | null>>;
|
|
6
|
+
constructor(code: ConnectorErrorCode, message: string, details?: Readonly<Record<string, string | number | boolean | null>>);
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const connectorErrorCodes = [
|
|
2
|
+
"AUTH_REQUIRED",
|
|
3
|
+
"CDP_UNAVAILABLE",
|
|
4
|
+
"RUNTIME_DRIFT",
|
|
5
|
+
"MODEL_NOT_AVAILABLE",
|
|
6
|
+
"EFFORT_NOT_SUPPORTED",
|
|
7
|
+
"CHAT_FAILED",
|
|
8
|
+
"STREAM_INCOMPLETE",
|
|
9
|
+
"SESSION_NOT_FOUND",
|
|
10
|
+
"SESSION_BUSY",
|
|
11
|
+
"ARCHIVE_FAILED",
|
|
12
|
+
];
|
|
13
|
+
export class ConnectorError extends Error {
|
|
14
|
+
code;
|
|
15
|
+
details;
|
|
16
|
+
constructor(code, message, details) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "ConnectorError";
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.details = details;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,eAAe;IACf,iBAAiB;IACjB,eAAe;IACf,qBAAqB;IACrB,sBAAsB;IACtB,aAAa;IACb,mBAAmB;IACnB,mBAAmB;IACnB,cAAc;IACd,gBAAgB;CACR,CAAC;AAIX,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,IAAI,CAAqB;IACzB,OAAO,CAA8D;IAE9E,YACE,IAAwB,EACxB,OAAe,EACf,OAAoE;QAEpE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./contract.js";
|
|
2
|
+
export * from "./connector.js";
|
|
3
|
+
export * from "./cdp.js";
|
|
4
|
+
export * from "./errors.js";
|
|
5
|
+
export * from "./asset-discovery.js";
|
|
6
|
+
export * from "./model-catalog.js";
|
|
7
|
+
export * from "./mcp-server.js";
|
|
8
|
+
export * from "./page-bridge.js";
|
|
9
|
+
export * from "./redaction.js";
|
|
10
|
+
export * from "./runtime-evaluate.js";
|
|
11
|
+
export * from "./session-registry.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./contract.js";
|
|
2
|
+
export * from "./connector.js";
|
|
3
|
+
export * from "./cdp.js";
|
|
4
|
+
export * from "./errors.js";
|
|
5
|
+
export * from "./asset-discovery.js";
|
|
6
|
+
export * from "./model-catalog.js";
|
|
7
|
+
export * from "./mcp-server.js";
|
|
8
|
+
export * from "./page-bridge.js";
|
|
9
|
+
export * from "./redaction.js";
|
|
10
|
+
export * from "./runtime-evaluate.js";
|
|
11
|
+
export * from "./session-registry.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { GptConnector } from "./connector.js";
|
|
3
|
+
import type { ChatInput, CloseInput } from "./contract.js";
|
|
4
|
+
interface ConnectorPort {
|
|
5
|
+
models(): ReturnType<GptConnector["models"]>;
|
|
6
|
+
chat(input: ChatInput): ReturnType<GptConnector["chat"]>;
|
|
7
|
+
closeSession(input: CloseInput): ReturnType<GptConnector["closeSession"]>;
|
|
8
|
+
close(): void;
|
|
9
|
+
shutdown(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare class LazyConnectorHost {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(endpoint?: string);
|
|
14
|
+
get(): Promise<ConnectorPort>;
|
|
15
|
+
shutdown(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const mcpToolNames: readonly ["chatgpt_models", "chatgpt_chat", "chatgpt_close"];
|
|
18
|
+
export declare function createGptConnectorMcpServer(host: LazyConnectorHost): McpServer;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { GptConnector } from "./connector.js";
|
|
4
|
+
import { ConnectorError } from "./errors.js";
|
|
5
|
+
export class LazyConnectorHost {
|
|
6
|
+
#endpoint;
|
|
7
|
+
#connectorPromise = null;
|
|
8
|
+
constructor(endpoint = "http://127.0.0.1:9223") {
|
|
9
|
+
this.#endpoint = endpoint;
|
|
10
|
+
}
|
|
11
|
+
get() {
|
|
12
|
+
this.#connectorPromise ??= GptConnector.connect({ endpoint: this.#endpoint }).catch((error) => {
|
|
13
|
+
this.#connectorPromise = null;
|
|
14
|
+
throw error;
|
|
15
|
+
});
|
|
16
|
+
return this.#connectorPromise;
|
|
17
|
+
}
|
|
18
|
+
async shutdown() {
|
|
19
|
+
if (this.#connectorPromise === null)
|
|
20
|
+
return;
|
|
21
|
+
try {
|
|
22
|
+
await (await this.#connectorPromise).shutdown();
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error instanceof ConnectorError && error.code === "ARCHIVE_FAILED")
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
this.#connectorPromise = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export const mcpToolNames = ["chatgpt_models", "chatgpt_chat", "chatgpt_close"];
|
|
34
|
+
export function createGptConnectorMcpServer(host) {
|
|
35
|
+
const server = new McpServer({ name: "gpt-connector", version: "0.1.0" }, {
|
|
36
|
+
instructions: "通常Chatを呼ぶ前に必要ならchatgpt_modelsでlive model/effortを確認する。継続時はchatgpt_chatが返すsessionIdを渡し、終了時はchatgpt_closeでarchiveする。",
|
|
37
|
+
});
|
|
38
|
+
server.registerTool("chatgpt_models", {
|
|
39
|
+
title: "通常Chatモデル一覧",
|
|
40
|
+
description: "ログイン中accountで利用可能な通常Chat modelとthinking effortを返す。",
|
|
41
|
+
inputSchema: z.object({}).strict(),
|
|
42
|
+
annotations: {
|
|
43
|
+
readOnlyHint: true,
|
|
44
|
+
destructiveHint: false,
|
|
45
|
+
idempotentHint: true,
|
|
46
|
+
},
|
|
47
|
+
}, async () => toolResult(async () => (await host.get()).models()));
|
|
48
|
+
server.registerTool("chatgpt_chat", {
|
|
49
|
+
title: "通常Chatへ送信",
|
|
50
|
+
description: "ChatGPT公式Web runtimeの通常ChatへUIなしで送信する。keepOpen=falseなら応答後archiveする。",
|
|
51
|
+
inputSchema: z
|
|
52
|
+
.object({
|
|
53
|
+
prompt: z.string().min(1),
|
|
54
|
+
model: z.string().min(1).optional(),
|
|
55
|
+
effort: z.string().min(1).optional(),
|
|
56
|
+
sessionId: z.string().uuid().optional(),
|
|
57
|
+
keepOpen: z.boolean().default(false),
|
|
58
|
+
})
|
|
59
|
+
.strict(),
|
|
60
|
+
annotations: {
|
|
61
|
+
readOnlyHint: false,
|
|
62
|
+
destructiveHint: false,
|
|
63
|
+
idempotentHint: false,
|
|
64
|
+
},
|
|
65
|
+
}, async (input) => toolResult(async () => (await host.get()).chat(input)));
|
|
66
|
+
server.registerTool("chatgpt_close", {
|
|
67
|
+
title: "通常Chat sessionを閉じる",
|
|
68
|
+
description: "process内sessionをserver archiveし、opaque handleを破棄する。deleteは行わない。",
|
|
69
|
+
inputSchema: z.object({ sessionId: z.string().uuid() }).strict(),
|
|
70
|
+
annotations: {
|
|
71
|
+
readOnlyHint: false,
|
|
72
|
+
destructiveHint: false,
|
|
73
|
+
idempotentHint: false,
|
|
74
|
+
},
|
|
75
|
+
}, async (input) => toolResult(async () => (await host.get()).closeSession(input)));
|
|
76
|
+
return server;
|
|
77
|
+
}
|
|
78
|
+
async function toolResult(action) {
|
|
79
|
+
try {
|
|
80
|
+
const result = await action();
|
|
81
|
+
return {
|
|
82
|
+
content: [{ type: "text", text: JSON.stringify(result) }],
|
|
83
|
+
structuredContent: typeof result === "object" && result !== null ? { ...result } : { value: result },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const body = error instanceof ConnectorError
|
|
88
|
+
? { code: error.code, message: error.message }
|
|
89
|
+
: { code: "CHAT_FAILED", message: "connector operationが失敗しました。" };
|
|
90
|
+
return {
|
|
91
|
+
content: [{ type: "text", text: JSON.stringify(body) }],
|
|
92
|
+
isError: true,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=mcp-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../../src/mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC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AAE,CAAC;YAChE,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/src/mcp.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createGptConnectorMcpServer, LazyConnectorHost } from "./mcp-server.js";
|
|
4
|
+
const host = new LazyConnectorHost(process.env.GPT_CONNECTOR_CDP_ENDPOINT ?? "http://127.0.0.1:9223");
|
|
5
|
+
const server = createGptConnectorMcpServer(host);
|
|
6
|
+
async function shutdown() {
|
|
7
|
+
await host.shutdown();
|
|
8
|
+
}
|
|
9
|
+
process.once("SIGINT", () => {
|
|
10
|
+
void shutdown().finally(() => process.exit(0));
|
|
11
|
+
});
|
|
12
|
+
process.once("SIGTERM", () => {
|
|
13
|
+
void shutdown().finally(() => process.exit(0));
|
|
14
|
+
});
|
|
15
|
+
const transport = new StdioServerTransport();
|
|
16
|
+
await server.connect(transport);
|
|
17
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/mcp.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,MAAM,IAAI,GAAG,IAAI,iBAAiB,CAChC,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,uBAAuB,CAClE,CAAC;AACF,MAAM,MAAM,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;AAEjD,KAAK,UAAU,QAAQ;IACrB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;IAC1B,KAAK,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;IAC3B,KAAK,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ModelCatalog } from "./contract.js";
|
|
2
|
+
export interface RawThinkingEffort {
|
|
3
|
+
readonly thinking_effort?: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface RawModel {
|
|
6
|
+
readonly slug?: unknown;
|
|
7
|
+
readonly title?: unknown;
|
|
8
|
+
readonly reasoning_type?: unknown;
|
|
9
|
+
readonly thinking_efforts?: unknown;
|
|
10
|
+
readonly configurable_thinking_effort?: unknown;
|
|
11
|
+
readonly is_work_mode_model?: unknown;
|
|
12
|
+
readonly max_tokens?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface RawModelCatalog {
|
|
15
|
+
readonly default_model_slug?: unknown;
|
|
16
|
+
readonly models?: unknown;
|
|
17
|
+
}
|
|
18
|
+
export declare function normalizeModelCatalog(raw: RawModelCatalog): ModelCatalog;
|
|
19
|
+
export interface ValidatedModelSelection {
|
|
20
|
+
readonly requestedModel?: string;
|
|
21
|
+
readonly requestedEffort?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function validateModelSelection(catalog: ModelCatalog, model: string | undefined, effort: string | undefined): ValidatedModelSelection;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ConnectorError } from "./errors.js";
|
|
2
|
+
function toEfforts(value) {
|
|
3
|
+
if (!Array.isArray(value))
|
|
4
|
+
return [];
|
|
5
|
+
return value.flatMap((item) => {
|
|
6
|
+
if (typeof item !== "object" || item === null)
|
|
7
|
+
return [];
|
|
8
|
+
const effort = item.thinking_effort;
|
|
9
|
+
return typeof effort === "string" && effort.length > 0 ? [effort] : [];
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function toModel(value) {
|
|
13
|
+
if (typeof value !== "object" || value === null)
|
|
14
|
+
return null;
|
|
15
|
+
const raw = value;
|
|
16
|
+
if (raw.is_work_mode_model === true || typeof raw.slug !== "string")
|
|
17
|
+
return null;
|
|
18
|
+
return {
|
|
19
|
+
id: raw.slug,
|
|
20
|
+
title: typeof raw.title === "string" ? raw.title : raw.slug,
|
|
21
|
+
reasoningType: typeof raw.reasoning_type === "string" ? raw.reasoning_type : null,
|
|
22
|
+
efforts: toEfforts(raw.thinking_efforts),
|
|
23
|
+
configurableEffort: raw.configurable_thinking_effort === true,
|
|
24
|
+
maxTokens: typeof raw.max_tokens === "number" && Number.isFinite(raw.max_tokens)
|
|
25
|
+
? raw.max_tokens
|
|
26
|
+
: null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function normalizeModelCatalog(raw) {
|
|
30
|
+
const models = Array.isArray(raw.models)
|
|
31
|
+
? raw.models.flatMap((model) => {
|
|
32
|
+
const normalized = toModel(model);
|
|
33
|
+
return normalized === null ? [] : [normalized];
|
|
34
|
+
})
|
|
35
|
+
: [];
|
|
36
|
+
const defaultModel = typeof raw.default_model_slug === "string" &&
|
|
37
|
+
models.some((model) => model.id === raw.default_model_slug)
|
|
38
|
+
? raw.default_model_slug
|
|
39
|
+
: null;
|
|
40
|
+
return { defaultModel, models };
|
|
41
|
+
}
|
|
42
|
+
export function validateModelSelection(catalog, model, effort) {
|
|
43
|
+
if (model === undefined) {
|
|
44
|
+
if (effort !== undefined) {
|
|
45
|
+
throw new ConnectorError("EFFORT_NOT_SUPPORTED", "effortを指定する場合はmodelも指定してください。");
|
|
46
|
+
}
|
|
47
|
+
return {};
|
|
48
|
+
}
|
|
49
|
+
const selected = catalog.models.find((candidate) => candidate.id === model);
|
|
50
|
+
if (selected === undefined) {
|
|
51
|
+
throw new ConnectorError("MODEL_NOT_AVAILABLE", "指定modelは現在の通常Chat catalogで利用できません。", { model });
|
|
52
|
+
}
|
|
53
|
+
if (effort !== undefined && !selected.efforts.includes(effort)) {
|
|
54
|
+
throw new ConnectorError("EFFORT_NOT_SUPPORTED", "指定effortは選択modelで利用できません。", { model, effort });
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
requestedModel: model,
|
|
58
|
+
...(effort === undefined ? {} : { requestedEffort: effort }),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=model-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-catalog.js","sourceRoot":"","sources":["../../src/model-catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAsB7C,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAErC,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,EAAE,CAAC;QACzD,MAAM,MAAM,GAAI,IAA0B,CAAC,eAAe,CAAC;QAC3D,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC7D,MAA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ildId: string;
|
|
3
|
+
export declare function createBridgeBootstrapExpression(coreUrl: string, conversationUrl: string): string;
|
|
4
|
+
export declare function createBridgeCallExpression(method: "startModels" | "startChat" | "startClose" | "poll", args: readonly unknown[]): string;
|