a2a-memory 0.10.11 → 0.10.13
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/dist/a2a/client.d.ts +53 -0
- package/dist/a2a/client.d.ts.map +1 -0
- package/dist/a2a/client.js +252 -0
- package/dist/a2a/client.js.map +1 -0
- package/dist/a2a/discovery.d.ts +45 -0
- package/dist/a2a/discovery.d.ts.map +1 -0
- package/dist/a2a/discovery.js +115 -0
- package/dist/a2a/discovery.js.map +1 -0
- package/dist/a2a/index.d.ts +10 -0
- package/dist/a2a/index.d.ts.map +1 -0
- package/dist/a2a/index.js +8 -0
- package/dist/a2a/index.js.map +1 -0
- package/dist/a2a/types.d.ts +177 -0
- package/dist/a2a/types.d.ts.map +1 -0
- package/dist/a2a/types.js +42 -0
- package/dist/a2a/types.js.map +1 -0
- package/dist/cli/commands/setup-wizard.d.ts +40 -0
- package/dist/cli/commands/setup-wizard.d.ts.map +1 -0
- package/dist/cli/commands/setup-wizard.js +387 -0
- package/dist/cli/commands/setup-wizard.js.map +1 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +14 -0
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/config/manager.js +2 -2
- package/dist/config/manager.js.map +1 -1
- package/dist/db/database.d.ts +48 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/database.js +118 -2
- package/dist/db/database.js.map +1 -1
- package/dist/hooks/post-tool-use.d.ts.map +1 -1
- package/dist/hooks/post-tool-use.js +56 -0
- package/dist/hooks/post-tool-use.js.map +1 -1
- package/dist/hooks/session-end.d.ts.map +1 -1
- package/dist/hooks/session-end.js +17 -0
- package/dist/hooks/session-end.js.map +1 -1
- package/dist/hooks/session-start.d.ts.map +1 -1
- package/dist/hooks/session-start.js +50 -5
- package/dist/hooks/session-start.js.map +1 -1
- package/dist/hooks/user-prompt-submit.d.ts.map +1 -1
- package/dist/hooks/user-prompt-submit.js +16 -0
- package/dist/hooks/user-prompt-submit.js.map +1 -1
- package/dist/lifecycle/cleanup.d.ts.map +1 -1
- package/dist/lifecycle/cleanup.js +14 -3
- package/dist/lifecycle/cleanup.js.map +1 -1
- package/dist/skill/evaluator.d.ts +10 -0
- package/dist/skill/evaluator.d.ts.map +1 -1
- package/dist/skill/evaluator.js +48 -1
- package/dist/skill/evaluator.js.map +1 -1
- package/dist/sync/queue.d.ts +9 -0
- package/dist/sync/queue.d.ts.map +1 -1
- package/dist/sync/queue.js +50 -20
- package/dist/sync/queue.js.map +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Protocol TypeScript Types
|
|
3
|
+
* Google A2A Protocol RC v1.0 준수
|
|
4
|
+
*/
|
|
5
|
+
export interface JSONRPCRequest {
|
|
6
|
+
jsonrpc: '2.0';
|
|
7
|
+
method: string;
|
|
8
|
+
params?: Record<string, unknown>;
|
|
9
|
+
id?: string | number;
|
|
10
|
+
}
|
|
11
|
+
export interface JSONRPCResponse<T = unknown> {
|
|
12
|
+
jsonrpc: '2.0';
|
|
13
|
+
result?: T;
|
|
14
|
+
error?: JSONRPCError;
|
|
15
|
+
id?: string | number;
|
|
16
|
+
}
|
|
17
|
+
export interface JSONRPCError {
|
|
18
|
+
code: number;
|
|
19
|
+
message: string;
|
|
20
|
+
data?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export declare enum JSONRPCErrorCode {
|
|
23
|
+
PARSE_ERROR = -32700,
|
|
24
|
+
INVALID_REQUEST = -32600,
|
|
25
|
+
METHOD_NOT_FOUND = -32601,
|
|
26
|
+
INVALID_PARAMS = -32602,
|
|
27
|
+
INTERNAL_ERROR = -32603,
|
|
28
|
+
TASK_NOT_FOUND = -32001,
|
|
29
|
+
TASK_NOT_CANCELABLE = -32002,
|
|
30
|
+
PUSH_NOTIFICATION_NOT_SUPPORTED = -32003,
|
|
31
|
+
UNSUPPORTED_OPERATION = -32004,
|
|
32
|
+
CONTENT_TYPE_NOT_SUPPORTED = -32005,
|
|
33
|
+
INVALID_AGENT_CARD = -32006
|
|
34
|
+
}
|
|
35
|
+
export interface TextPart {
|
|
36
|
+
type: 'text';
|
|
37
|
+
text: string;
|
|
38
|
+
}
|
|
39
|
+
export interface FilePart {
|
|
40
|
+
type: 'file';
|
|
41
|
+
file: {
|
|
42
|
+
name: string;
|
|
43
|
+
mimeType: string;
|
|
44
|
+
bytes?: string;
|
|
45
|
+
uri?: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface DataPart {
|
|
49
|
+
type: 'data';
|
|
50
|
+
data: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
export type MessagePart = TextPart | FilePart | DataPart;
|
|
53
|
+
export type MessageRole = 'user' | 'agent';
|
|
54
|
+
export interface Message {
|
|
55
|
+
role: MessageRole;
|
|
56
|
+
parts: MessagePart[];
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
}
|
|
59
|
+
export declare enum TaskState {
|
|
60
|
+
SUBMITTED = "submitted",
|
|
61
|
+
WORKING = "working",
|
|
62
|
+
INPUT_REQUIRED = "input-required",
|
|
63
|
+
COMPLETED = "completed",
|
|
64
|
+
FAILED = "failed",
|
|
65
|
+
CANCELED = "canceled"
|
|
66
|
+
}
|
|
67
|
+
export declare const TERMINAL_STATES: ReadonlySet<TaskState>;
|
|
68
|
+
export interface TaskStatus {
|
|
69
|
+
state: TaskState;
|
|
70
|
+
timestamp: string;
|
|
71
|
+
message?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface Artifact {
|
|
74
|
+
name: string;
|
|
75
|
+
parts: MessagePart[];
|
|
76
|
+
}
|
|
77
|
+
export interface TaskData {
|
|
78
|
+
id: string;
|
|
79
|
+
sessionId: string;
|
|
80
|
+
status: TaskStatus;
|
|
81
|
+
messages: Message[];
|
|
82
|
+
artifacts: Artifact[];
|
|
83
|
+
history: TaskStatus[];
|
|
84
|
+
metadata: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export declare enum EventType {
|
|
87
|
+
TASK_STATUS_UPDATE = "TaskStatusUpdateEvent",
|
|
88
|
+
TASK_ARTIFACT_UPDATE = "TaskArtifactUpdateEvent"
|
|
89
|
+
}
|
|
90
|
+
export interface TaskStatusUpdateEvent {
|
|
91
|
+
id: string;
|
|
92
|
+
status: TaskStatus;
|
|
93
|
+
final: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface TaskArtifactUpdateEvent {
|
|
96
|
+
id: string;
|
|
97
|
+
artifact: Artifact;
|
|
98
|
+
}
|
|
99
|
+
export type SSEEvent = TaskStatusUpdateEvent | TaskArtifactUpdateEvent;
|
|
100
|
+
export interface AgentSkill {
|
|
101
|
+
id: string;
|
|
102
|
+
name: string;
|
|
103
|
+
description: string;
|
|
104
|
+
tags?: string[];
|
|
105
|
+
examples?: string[];
|
|
106
|
+
inputModes?: string[];
|
|
107
|
+
outputModes?: string[];
|
|
108
|
+
}
|
|
109
|
+
export interface AgentExtension {
|
|
110
|
+
uri: string;
|
|
111
|
+
description?: string;
|
|
112
|
+
params?: Record<string, unknown>;
|
|
113
|
+
required?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface AgentCapabilities {
|
|
116
|
+
streaming?: boolean;
|
|
117
|
+
pushNotifications?: boolean;
|
|
118
|
+
stateTransitionHistory?: boolean;
|
|
119
|
+
extensions?: AgentExtension[];
|
|
120
|
+
}
|
|
121
|
+
export interface SecurityScheme {
|
|
122
|
+
type: string;
|
|
123
|
+
name?: string;
|
|
124
|
+
in?: string;
|
|
125
|
+
scheme?: string;
|
|
126
|
+
bearerFormat?: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface AgentProvider {
|
|
130
|
+
organization: string;
|
|
131
|
+
url: string;
|
|
132
|
+
}
|
|
133
|
+
export interface AgentCard {
|
|
134
|
+
name: string;
|
|
135
|
+
description: string;
|
|
136
|
+
url: string;
|
|
137
|
+
version: string;
|
|
138
|
+
protocolVersion?: string;
|
|
139
|
+
skills: AgentSkill[];
|
|
140
|
+
capabilities: AgentCapabilities;
|
|
141
|
+
defaultInputModes: string[];
|
|
142
|
+
defaultOutputModes: string[];
|
|
143
|
+
securitySchemes?: Record<string, SecurityScheme>;
|
|
144
|
+
security?: Array<Record<string, string[]>>;
|
|
145
|
+
provider?: AgentProvider;
|
|
146
|
+
documentationUrl?: string;
|
|
147
|
+
iconUrl?: string;
|
|
148
|
+
preferredTransport?: string;
|
|
149
|
+
supportsAuthenticatedExtendedCard?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface MessageSendParams {
|
|
152
|
+
id: string;
|
|
153
|
+
sessionId?: string;
|
|
154
|
+
message: Message;
|
|
155
|
+
metadata?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export interface TaskGetParams {
|
|
158
|
+
id: string;
|
|
159
|
+
historyLength?: number;
|
|
160
|
+
}
|
|
161
|
+
export interface TaskCancelParams {
|
|
162
|
+
id: string;
|
|
163
|
+
}
|
|
164
|
+
export type A2AMethod = 'message/send' | 'message/stream' | 'tasks/get' | 'tasks/cancel' | 'tasks/pushNotification/set' | 'tasks/pushNotification/get';
|
|
165
|
+
export interface A2AProtocolClientConfig {
|
|
166
|
+
baseUrl: string;
|
|
167
|
+
apiKey?: string;
|
|
168
|
+
jwtToken?: string;
|
|
169
|
+
timeout?: number;
|
|
170
|
+
}
|
|
171
|
+
export interface StreamCallbacks {
|
|
172
|
+
onStatusUpdate?: (event: TaskStatusUpdateEvent) => void;
|
|
173
|
+
onArtifactUpdate?: (event: TaskArtifactUpdateEvent) => void;
|
|
174
|
+
onError?: (error: Error) => void;
|
|
175
|
+
onComplete?: () => void;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/a2a/types.ts"],"names":[],"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,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxD,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC5D,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2A Protocol TypeScript Types
|
|
3
|
+
* Google A2A Protocol RC v1.0 준수
|
|
4
|
+
*/
|
|
5
|
+
export var JSONRPCErrorCode;
|
|
6
|
+
(function (JSONRPCErrorCode) {
|
|
7
|
+
// Standard JSON-RPC 2.0
|
|
8
|
+
JSONRPCErrorCode[JSONRPCErrorCode["PARSE_ERROR"] = -32700] = "PARSE_ERROR";
|
|
9
|
+
JSONRPCErrorCode[JSONRPCErrorCode["INVALID_REQUEST"] = -32600] = "INVALID_REQUEST";
|
|
10
|
+
JSONRPCErrorCode[JSONRPCErrorCode["METHOD_NOT_FOUND"] = -32601] = "METHOD_NOT_FOUND";
|
|
11
|
+
JSONRPCErrorCode[JSONRPCErrorCode["INVALID_PARAMS"] = -32602] = "INVALID_PARAMS";
|
|
12
|
+
JSONRPCErrorCode[JSONRPCErrorCode["INTERNAL_ERROR"] = -32603] = "INTERNAL_ERROR";
|
|
13
|
+
// A2A Protocol Custom
|
|
14
|
+
JSONRPCErrorCode[JSONRPCErrorCode["TASK_NOT_FOUND"] = -32001] = "TASK_NOT_FOUND";
|
|
15
|
+
JSONRPCErrorCode[JSONRPCErrorCode["TASK_NOT_CANCELABLE"] = -32002] = "TASK_NOT_CANCELABLE";
|
|
16
|
+
JSONRPCErrorCode[JSONRPCErrorCode["PUSH_NOTIFICATION_NOT_SUPPORTED"] = -32003] = "PUSH_NOTIFICATION_NOT_SUPPORTED";
|
|
17
|
+
JSONRPCErrorCode[JSONRPCErrorCode["UNSUPPORTED_OPERATION"] = -32004] = "UNSUPPORTED_OPERATION";
|
|
18
|
+
JSONRPCErrorCode[JSONRPCErrorCode["CONTENT_TYPE_NOT_SUPPORTED"] = -32005] = "CONTENT_TYPE_NOT_SUPPORTED";
|
|
19
|
+
JSONRPCErrorCode[JSONRPCErrorCode["INVALID_AGENT_CARD"] = -32006] = "INVALID_AGENT_CARD";
|
|
20
|
+
})(JSONRPCErrorCode || (JSONRPCErrorCode = {}));
|
|
21
|
+
// ─── Task ───────────────────────────────────────────────────
|
|
22
|
+
export var TaskState;
|
|
23
|
+
(function (TaskState) {
|
|
24
|
+
TaskState["SUBMITTED"] = "submitted";
|
|
25
|
+
TaskState["WORKING"] = "working";
|
|
26
|
+
TaskState["INPUT_REQUIRED"] = "input-required";
|
|
27
|
+
TaskState["COMPLETED"] = "completed";
|
|
28
|
+
TaskState["FAILED"] = "failed";
|
|
29
|
+
TaskState["CANCELED"] = "canceled";
|
|
30
|
+
})(TaskState || (TaskState = {}));
|
|
31
|
+
export const TERMINAL_STATES = new Set([
|
|
32
|
+
TaskState.COMPLETED,
|
|
33
|
+
TaskState.FAILED,
|
|
34
|
+
TaskState.CANCELED,
|
|
35
|
+
]);
|
|
36
|
+
// ─── SSE Events ─────────────────────────────────────────────
|
|
37
|
+
export var EventType;
|
|
38
|
+
(function (EventType) {
|
|
39
|
+
EventType["TASK_STATUS_UPDATE"] = "TaskStatusUpdateEvent";
|
|
40
|
+
EventType["TASK_ARTIFACT_UPDATE"] = "TaskArtifactUpdateEvent";
|
|
41
|
+
})(EventType || (EventType = {}));
|
|
42
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/a2a/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH,MAAM,CAAN,IAAY,gBAeX;AAfD,WAAY,gBAAgB;IAC1B,wBAAwB;IACxB,0EAAoB,CAAA;IACpB,kFAAwB,CAAA;IACxB,oFAAyB,CAAA;IACzB,gFAAuB,CAAA;IACvB,gFAAuB,CAAA;IAEvB,sBAAsB;IACtB,gFAAuB,CAAA;IACvB,0FAA4B,CAAA;IAC5B,kHAAwC,CAAA;IACxC,8FAA8B,CAAA;IAC9B,wGAAmC,CAAA;IACnC,wFAA2B,CAAA;AAC7B,CAAC,EAfW,gBAAgB,KAAhB,gBAAgB,QAe3B;AAoCD,+DAA+D;AAE/D,MAAM,CAAN,IAAY,SAOX;AAPD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,gCAAmB,CAAA;IACnB,8CAAiC,CAAA;IACjC,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EAPW,SAAS,KAAT,SAAS,QAOpB;AAED,MAAM,CAAC,MAAM,eAAe,GAA2B,IAAI,GAAG,CAAC;IAC7D,SAAS,CAAC,SAAS;IACnB,SAAS,CAAC,MAAM;IAChB,SAAS,CAAC,QAAQ;CACnB,CAAC,CAAC;AAuBH,+DAA+D;AAE/D,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,yDAA4C,CAAA;IAC5C,6DAAgD,CAAA;AAClD,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Setup Wizard
|
|
3
|
+
*
|
|
4
|
+
* One-click interactive setup wizard for A2A Memory Plugin.
|
|
5
|
+
* Automates all 7 manual setup steps into a single guided flow.
|
|
6
|
+
*/
|
|
7
|
+
import { ConfigManager } from '../../config/manager.js';
|
|
8
|
+
interface AgentResult {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
api_key: string;
|
|
12
|
+
}
|
|
13
|
+
export interface WizardOptions {
|
|
14
|
+
serverUrl?: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
password?: string;
|
|
17
|
+
force?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface WizardResult {
|
|
20
|
+
success: boolean;
|
|
21
|
+
serverUrl: string;
|
|
22
|
+
agentId?: string;
|
|
23
|
+
apiKey?: string;
|
|
24
|
+
hooksRegistered: boolean;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function checkServerHealth(serverUrl: string): Promise<boolean>;
|
|
28
|
+
export declare function loginAndGetToken(serverUrl: string, email: string, password: string): Promise<string | null>;
|
|
29
|
+
export declare function findExistingAgent(serverUrl: string, token: string, agentName: string): Promise<AgentResult | null>;
|
|
30
|
+
export declare function createAgent(serverUrl: string, token: string, agentName: string): Promise<AgentResult | null>;
|
|
31
|
+
export declare function saveServerConfig(configManager: ConfigManager, serverUrl: string, apiKey: string): void;
|
|
32
|
+
export declare function getPluginDir(): string;
|
|
33
|
+
export declare function detectGlobalPluginDir(): string;
|
|
34
|
+
export declare function registerHooksToSettings(settingsPath: string, pluginDir: string, force: boolean): {
|
|
35
|
+
registered: boolean;
|
|
36
|
+
alreadyExisted: boolean;
|
|
37
|
+
};
|
|
38
|
+
export declare function runSetupWizard(options?: WizardOptions): Promise<WizardResult>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=setup-wizard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-wizard.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/setup-wizard.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAuBxD,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,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
|
3
|
+
*
|
|
4
|
+
* One-click interactive setup wizard for A2A Memory Plugin.
|
|
5
|
+
* Automates all 7 manual setup steps into a single guided flow.
|
|
6
|
+
*/
|
|
7
|
+
import { createInterface } from 'node:readline';
|
|
8
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { homedir } from 'node:os';
|
|
11
|
+
import { execSync } from 'node:child_process';
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
import { ConfigManager } from '../../config/manager.js';
|
|
14
|
+
const CLAUDE_SETTINGS_PATH = join(homedir(), '.claude', 'settings.json');
|
|
15
|
+
const DEFAULT_SERVER_URL = 'https://a2a-api-production-8d17.up.railway.app';
|
|
16
|
+
const AGENT_NAME = 'claude-code-plugin';
|
|
17
|
+
// ──────────────────────────────────────────────
|
|
18
|
+
// readline helpers
|
|
19
|
+
// ──────────────────────────────────────────────
|
|
20
|
+
function createRl() {
|
|
21
|
+
return createInterface({
|
|
22
|
+
input: process.stdin,
|
|
23
|
+
output: process.stdout,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async function prompt(rl, question) {
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
rl.question(question, (answer) => {
|
|
29
|
+
resolve(answer.trim());
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async function promptWithDefault(rl, question, defaultValue) {
|
|
34
|
+
const answer = await prompt(rl, ` ${question} [${chalk.dim(defaultValue)}]: `);
|
|
35
|
+
return answer === '' ? defaultValue : answer;
|
|
36
|
+
}
|
|
37
|
+
async function promptPassword(rl, question) {
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
// stdin이 TTY일 때만 에코 끄기 시도
|
|
40
|
+
const stdin = process.stdin;
|
|
41
|
+
process.stdout.write(` ${question}: `);
|
|
42
|
+
let password = '';
|
|
43
|
+
if (stdin.setRawMode) {
|
|
44
|
+
stdin.setRawMode(true);
|
|
45
|
+
stdin.resume();
|
|
46
|
+
stdin.setEncoding('utf8');
|
|
47
|
+
const onData = (char) => {
|
|
48
|
+
if (char === '\r' || char === '\n') {
|
|
49
|
+
stdin.setRawMode(false);
|
|
50
|
+
stdin.pause();
|
|
51
|
+
stdin.removeListener('data', onData);
|
|
52
|
+
process.stdout.write('\n');
|
|
53
|
+
resolve(password);
|
|
54
|
+
}
|
|
55
|
+
else if (char === '\u0003') {
|
|
56
|
+
// Ctrl+C
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
else if (char === '\u007F') {
|
|
60
|
+
// Backspace
|
|
61
|
+
if (password.length > 0) {
|
|
62
|
+
password = password.slice(0, -1);
|
|
63
|
+
process.stdout.write('\b \b');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
password += char;
|
|
68
|
+
process.stdout.write('*');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
stdin.on('data', onData);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// TTY가 아닌 경우 (테스트/파이프) 일반 readline 사용
|
|
75
|
+
rl.question('', (answer) => {
|
|
76
|
+
resolve(answer.trim());
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
// ──────────────────────────────────────────────
|
|
82
|
+
// Network helpers (testable, injectable)
|
|
83
|
+
// ──────────────────────────────────────────────
|
|
84
|
+
export async function checkServerHealth(serverUrl) {
|
|
85
|
+
try {
|
|
86
|
+
const res = await fetch(`${serverUrl}/api/v1/health`, {
|
|
87
|
+
signal: AbortSignal.timeout(5000),
|
|
88
|
+
});
|
|
89
|
+
return res.ok;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export async function loginAndGetToken(serverUrl, email, password) {
|
|
96
|
+
try {
|
|
97
|
+
const res = await fetch(`${serverUrl}/api/v1/auth/login`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers: { 'Content-Type': 'application/json' },
|
|
100
|
+
body: JSON.stringify({ email, password }),
|
|
101
|
+
signal: AbortSignal.timeout(10000),
|
|
102
|
+
});
|
|
103
|
+
if (!res.ok) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
const data = (await res.json());
|
|
107
|
+
return data.token ?? null;
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export async function findExistingAgent(serverUrl, token, agentName) {
|
|
114
|
+
try {
|
|
115
|
+
const res = await fetch(`${serverUrl}/api/v1/agents?name=${encodeURIComponent(agentName)}`, {
|
|
116
|
+
headers: {
|
|
117
|
+
Authorization: `Bearer ${token}`,
|
|
118
|
+
'Content-Type': 'application/json',
|
|
119
|
+
},
|
|
120
|
+
signal: AbortSignal.timeout(10000),
|
|
121
|
+
});
|
|
122
|
+
if (!res.ok) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const data = (await res.json());
|
|
126
|
+
const agents = Array.isArray(data) ? data : (data.agents ?? data.items ?? []);
|
|
127
|
+
const match = agents.find((a) => a.name === agentName);
|
|
128
|
+
return match ?? null;
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export async function createAgent(serverUrl, token, agentName) {
|
|
135
|
+
try {
|
|
136
|
+
const res = await fetch(`${serverUrl}/api/v1/agents`, {
|
|
137
|
+
method: 'POST',
|
|
138
|
+
headers: {
|
|
139
|
+
Authorization: `Bearer ${token}`,
|
|
140
|
+
'Content-Type': 'application/json',
|
|
141
|
+
},
|
|
142
|
+
body: JSON.stringify({
|
|
143
|
+
name: agentName,
|
|
144
|
+
description: 'Claude Code Plugin Agent — auto-registered by setup wizard',
|
|
145
|
+
capabilities: ['memory:read', 'memory:create', 'memory:update', 'memory:delete', 'memory:search'],
|
|
146
|
+
}),
|
|
147
|
+
signal: AbortSignal.timeout(10000),
|
|
148
|
+
});
|
|
149
|
+
if (!res.ok) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
return (await res.json());
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// ──────────────────────────────────────────────
|
|
159
|
+
// Config / Hook helpers (testable)
|
|
160
|
+
// ──────────────────────────────────────────────
|
|
161
|
+
export function saveServerConfig(configManager, serverUrl, apiKey) {
|
|
162
|
+
const config = configManager.load();
|
|
163
|
+
config.server.url = serverUrl;
|
|
164
|
+
configManager.save(config);
|
|
165
|
+
configManager.setApiKey(apiKey);
|
|
166
|
+
}
|
|
167
|
+
export function getPluginDir() {
|
|
168
|
+
const url = new URL(import.meta.url);
|
|
169
|
+
const filePath = url.pathname;
|
|
170
|
+
const parts = filePath.split('/');
|
|
171
|
+
// dist/cli/commands/setup-wizard.js → plugin/
|
|
172
|
+
return parts.slice(0, -4).join('/');
|
|
173
|
+
}
|
|
174
|
+
export function detectGlobalPluginDir() {
|
|
175
|
+
try {
|
|
176
|
+
const npmRoot = execSync('npm root -g', { encoding: 'utf8', timeout: 5000 }).trim();
|
|
177
|
+
const candidate = join(npmRoot, 'a2a-memory');
|
|
178
|
+
if (existsSync(candidate)) {
|
|
179
|
+
return candidate;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
// ignore
|
|
184
|
+
}
|
|
185
|
+
// Fallback: import.meta.url 기반
|
|
186
|
+
return getPluginDir();
|
|
187
|
+
}
|
|
188
|
+
export function registerHooksToSettings(settingsPath, pluginDir, force) {
|
|
189
|
+
let settings = {};
|
|
190
|
+
if (existsSync(settingsPath)) {
|
|
191
|
+
try {
|
|
192
|
+
settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// 파싱 실패 시 빈 settings로 시작
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (!settings.hooks) {
|
|
199
|
+
settings.hooks = {};
|
|
200
|
+
}
|
|
201
|
+
const hasExisting = Object.values(settings.hooks).some((configs) => configs.some((c) => c.hooks?.some((h) => h.command?.includes('a2a-memory'))));
|
|
202
|
+
if (hasExisting && !force) {
|
|
203
|
+
return { registered: false, alreadyExisted: true };
|
|
204
|
+
}
|
|
205
|
+
const hooksDir = join(pluginDir, 'dist', 'hooks');
|
|
206
|
+
const hookEntries = [
|
|
207
|
+
['SessionStart', join(hooksDir, 'session-start.js')],
|
|
208
|
+
['PostToolUse', join(hooksDir, 'post-tool-use.js')],
|
|
209
|
+
['SessionEnd', join(hooksDir, 'session-end.js')],
|
|
210
|
+
['UserPromptSubmit', join(hooksDir, 'user-prompt-submit.js')],
|
|
211
|
+
['PreCompact', join(hooksDir, 'pre-compact.js')],
|
|
212
|
+
];
|
|
213
|
+
for (const [hookName, hookPath] of hookEntries) {
|
|
214
|
+
settings.hooks[hookName] = [
|
|
215
|
+
...(settings.hooks[hookName] ?? []).filter((c) => !c.hooks?.some((h) => h.command?.includes('a2a-memory'))),
|
|
216
|
+
{
|
|
217
|
+
matcher: '',
|
|
218
|
+
hooks: [{ type: 'command', command: `node ${hookPath}` }],
|
|
219
|
+
},
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
const settingsDir = join(homedir(), '.claude');
|
|
223
|
+
if (!existsSync(settingsDir)) {
|
|
224
|
+
mkdirSync(settingsDir, { recursive: true });
|
|
225
|
+
}
|
|
226
|
+
writeFileSync(settingsPath, JSON.stringify(settings, null, 2), 'utf-8');
|
|
227
|
+
return { registered: true, alreadyExisted: false };
|
|
228
|
+
}
|
|
229
|
+
// ──────────────────────────────────────────────
|
|
230
|
+
// Main wizard runner
|
|
231
|
+
// ──────────────────────────────────────────────
|
|
232
|
+
export async function runSetupWizard(options = {}) {
|
|
233
|
+
const result = {
|
|
234
|
+
success: false,
|
|
235
|
+
serverUrl: options.serverUrl ?? DEFAULT_SERVER_URL,
|
|
236
|
+
hooksRegistered: false,
|
|
237
|
+
};
|
|
238
|
+
const rl = createRl();
|
|
239
|
+
try {
|
|
240
|
+
// ── Header ──────────────────────────────
|
|
241
|
+
console.log('');
|
|
242
|
+
console.log(chalk.cyan('╔══════════════════════════════════════╗'));
|
|
243
|
+
console.log(chalk.cyan('║') + chalk.bold(' A2A Memory — Quick Setup Wizard ') + chalk.cyan('║'));
|
|
244
|
+
console.log(chalk.cyan('╚══════════════════════════════════════╝'));
|
|
245
|
+
console.log('');
|
|
246
|
+
// ── Step 1: Server URL ───────────────────
|
|
247
|
+
console.log(chalk.bold('Step 1/4: Server Connection'));
|
|
248
|
+
let serverUrl;
|
|
249
|
+
if (options.serverUrl) {
|
|
250
|
+
serverUrl = options.serverUrl;
|
|
251
|
+
console.log(` Server URL: ${chalk.cyan(serverUrl)} ${chalk.dim('(from options)')}`);
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
serverUrl = await promptWithDefault(rl, 'Server URL', DEFAULT_SERVER_URL);
|
|
255
|
+
}
|
|
256
|
+
// URL 유효성 검증
|
|
257
|
+
try {
|
|
258
|
+
new URL(serverUrl);
|
|
259
|
+
}
|
|
260
|
+
catch {
|
|
261
|
+
console.log(chalk.red(` Error: Invalid URL format — ${serverUrl}`));
|
|
262
|
+
result.error = `Invalid URL: ${serverUrl}`;
|
|
263
|
+
return result;
|
|
264
|
+
}
|
|
265
|
+
// Health check
|
|
266
|
+
process.stdout.write(' Checking server connection... ');
|
|
267
|
+
const healthy = await checkServerHealth(serverUrl);
|
|
268
|
+
if (!healthy) {
|
|
269
|
+
console.log(chalk.red('failed'));
|
|
270
|
+
console.log(chalk.red(` Error: Cannot reach server at ${serverUrl}`));
|
|
271
|
+
result.error = `Cannot reach server at ${serverUrl}`;
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
console.log(chalk.green('ok'));
|
|
275
|
+
result.serverUrl = serverUrl;
|
|
276
|
+
console.log('');
|
|
277
|
+
// ── Step 2: Authentication ───────────────
|
|
278
|
+
console.log(chalk.bold('Step 2/4: Authentication'));
|
|
279
|
+
let email;
|
|
280
|
+
let password;
|
|
281
|
+
if (options.email) {
|
|
282
|
+
email = options.email;
|
|
283
|
+
console.log(` Admin Email: ${chalk.cyan(email)} ${chalk.dim('(from options)')}`);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
email = await promptWithDefault(rl, 'Admin Email', 'admin@a2amemory.com');
|
|
287
|
+
}
|
|
288
|
+
if (options.password) {
|
|
289
|
+
password = options.password;
|
|
290
|
+
console.log(` Password: ${chalk.dim('(from options)')}`);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
password = await promptPassword(rl, 'Password');
|
|
294
|
+
}
|
|
295
|
+
process.stdout.write(' Authenticating... ');
|
|
296
|
+
const token = await loginAndGetToken(serverUrl, email, password);
|
|
297
|
+
if (!token) {
|
|
298
|
+
console.log(chalk.red('failed'));
|
|
299
|
+
console.log(chalk.red(' Error: Authentication failed. Check email/password.'));
|
|
300
|
+
result.error = 'Authentication failed';
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
303
|
+
console.log(chalk.green('ok'));
|
|
304
|
+
console.log(` ${chalk.green('Authenticated successfully')}`);
|
|
305
|
+
console.log('');
|
|
306
|
+
// ── Step 3: Agent Registration ───────────
|
|
307
|
+
console.log(chalk.bold('Step 3/4: Agent Registration'));
|
|
308
|
+
let agentId;
|
|
309
|
+
let apiKey;
|
|
310
|
+
// 기존 Agent 확인
|
|
311
|
+
process.stdout.write(` Checking for existing agent '${AGENT_NAME}'... `);
|
|
312
|
+
const existing = await findExistingAgent(serverUrl, token, AGENT_NAME);
|
|
313
|
+
if (existing) {
|
|
314
|
+
console.log(chalk.yellow('found'));
|
|
315
|
+
console.log(` ${chalk.yellow('Agent already exists')} (ID: ${existing.id})`);
|
|
316
|
+
agentId = existing.id;
|
|
317
|
+
// 기존 agent의 api_key가 있으면 사용, 없으면 재생성 불가 → 안내
|
|
318
|
+
if (existing.api_key) {
|
|
319
|
+
apiKey = existing.api_key;
|
|
320
|
+
console.log(` ${chalk.green('API Key retrieved')}`);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
console.log(chalk.yellow(' Warning: Existing agent API Key not returned by server.'));
|
|
324
|
+
console.log(chalk.yellow(' Please retrieve the API Key manually from the dashboard.'));
|
|
325
|
+
apiKey = '';
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
console.log(chalk.dim('not found'));
|
|
330
|
+
process.stdout.write(` Creating agent '${AGENT_NAME}'... `);
|
|
331
|
+
const created = await createAgent(serverUrl, token, AGENT_NAME);
|
|
332
|
+
if (!created) {
|
|
333
|
+
console.log(chalk.red('failed'));
|
|
334
|
+
console.log(chalk.red(' Error: Failed to create agent.'));
|
|
335
|
+
result.error = 'Agent creation failed';
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
console.log(chalk.green('done'));
|
|
339
|
+
console.log(` ${chalk.green('Agent created')} (ID: ${created.id})`);
|
|
340
|
+
agentId = created.id;
|
|
341
|
+
apiKey = created.api_key;
|
|
342
|
+
}
|
|
343
|
+
if (apiKey) {
|
|
344
|
+
const masked = `${apiKey.slice(0, 12)}...`;
|
|
345
|
+
console.log(` ${chalk.green('API Key saved:')} ${chalk.cyan(masked)}`);
|
|
346
|
+
}
|
|
347
|
+
result.agentId = agentId;
|
|
348
|
+
result.apiKey = apiKey;
|
|
349
|
+
// Config 저장
|
|
350
|
+
const configManager = new ConfigManager();
|
|
351
|
+
if (apiKey) {
|
|
352
|
+
saveServerConfig(configManager, serverUrl, apiKey);
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
// API Key 없어도 URL은 저장
|
|
356
|
+
const config = configManager.load();
|
|
357
|
+
config.server.url = serverUrl;
|
|
358
|
+
configManager.save(config);
|
|
359
|
+
}
|
|
360
|
+
console.log('');
|
|
361
|
+
// ── Step 4: Hook Registration ────────────
|
|
362
|
+
console.log(chalk.bold('Step 4/4: Hook Registration'));
|
|
363
|
+
const pluginDir = detectGlobalPluginDir();
|
|
364
|
+
const hookResult = registerHooksToSettings(CLAUDE_SETTINGS_PATH, pluginDir, options.force ?? false);
|
|
365
|
+
if (hookResult.alreadyExisted) {
|
|
366
|
+
console.log(` ${chalk.yellow('Hooks already registered')} (use --force to overwrite)`);
|
|
367
|
+
result.hooksRegistered = false;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
console.log(` ${chalk.green('Claude Code settings.json updated')}`);
|
|
371
|
+
console.log(` ${chalk.green('5 hooks registered')} ${chalk.dim('(SessionStart, PostToolUse, SessionEnd, UserPromptSubmit, PreCompact)')}`);
|
|
372
|
+
result.hooksRegistered = true;
|
|
373
|
+
}
|
|
374
|
+
console.log('');
|
|
375
|
+
// ── Footer ──────────────────────────────
|
|
376
|
+
console.log(chalk.cyan('═══════════════════════════════════════'));
|
|
377
|
+
console.log(chalk.green.bold(' Setup Complete! Restart Claude Code.'));
|
|
378
|
+
console.log(chalk.cyan('═══════════════════════════════════════'));
|
|
379
|
+
console.log('');
|
|
380
|
+
result.success = true;
|
|
381
|
+
return result;
|
|
382
|
+
}
|
|
383
|
+
finally {
|
|
384
|
+
rl.close();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
//# sourceMappingURL=setup-wizard.js.map
|