@canonmsg/claude-code-plugin 0.21.2 → 0.22.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 +1 -17
- package/dist/host.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/session-state.d.ts +0 -1
- package/dist/session-state.js +23 -56
- package/dist/setup.d.ts +2 -3
- package/dist/setup.js +5 -29
- package/package.json +8 -10
- package/skills/configure/SKILL.md +4 -10
- package/.claude-plugin/plugin.json +0 -25
- package/dist/approval-server.d.ts +0 -33
- package/dist/approval-server.js +0 -200
- package/dist/mcp-args.d.ts +0 -45
- package/dist/mcp-args.js +0 -179
- package/dist/server.d.ts +0 -2
- package/dist/server.js +0 -711
package/dist/mcp-args.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
function isRecord(value) {
|
|
2
|
-
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
3
|
-
}
|
|
4
|
-
function requiredString(record, key, maxLength = 4096) {
|
|
5
|
-
const value = record[key];
|
|
6
|
-
if (typeof value !== 'string') {
|
|
7
|
-
return { ok: false, error: `Missing ${key}` };
|
|
8
|
-
}
|
|
9
|
-
const trimmed = value.trim();
|
|
10
|
-
if (!trimmed) {
|
|
11
|
-
return { ok: false, error: `Missing ${key}` };
|
|
12
|
-
}
|
|
13
|
-
if (trimmed.length > maxLength) {
|
|
14
|
-
return { ok: false, error: `${key} is too long` };
|
|
15
|
-
}
|
|
16
|
-
return { ok: true, value: trimmed };
|
|
17
|
-
}
|
|
18
|
-
function optionalString(record, key, maxLength = 4096) {
|
|
19
|
-
const value = record[key];
|
|
20
|
-
if (typeof value !== 'string')
|
|
21
|
-
return undefined;
|
|
22
|
-
const trimmed = value.trim();
|
|
23
|
-
return trimmed && trimmed.length <= maxLength ? trimmed : undefined;
|
|
24
|
-
}
|
|
25
|
-
function optionalNumber(record, key) {
|
|
26
|
-
const value = record[key];
|
|
27
|
-
return typeof value === 'number' && Number.isFinite(value) && value >= 0
|
|
28
|
-
? value
|
|
29
|
-
: undefined;
|
|
30
|
-
}
|
|
31
|
-
function parseContentType(value) {
|
|
32
|
-
if (value == null)
|
|
33
|
-
return { ok: true, value: 'text' };
|
|
34
|
-
if (value === 'text' || value === 'image' || value === 'audio' || value === 'video' || value === 'file') {
|
|
35
|
-
return { ok: true, value };
|
|
36
|
-
}
|
|
37
|
-
return { ok: false, error: 'Invalid content_type' };
|
|
38
|
-
}
|
|
39
|
-
export function parseReplyArgs(value) {
|
|
40
|
-
if (!isRecord(value))
|
|
41
|
-
return { ok: false, error: 'Arguments must be an object' };
|
|
42
|
-
const conversationId = requiredString(value, 'conversation_id', 256);
|
|
43
|
-
if (!conversationId.ok)
|
|
44
|
-
return conversationId;
|
|
45
|
-
const text = requiredString(value, 'text');
|
|
46
|
-
if (!text.ok)
|
|
47
|
-
return text;
|
|
48
|
-
return {
|
|
49
|
-
ok: true,
|
|
50
|
-
value: {
|
|
51
|
-
conversationId: conversationId.value,
|
|
52
|
-
text: text.value,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export function parseSendMessageArgs(value) {
|
|
57
|
-
if (!isRecord(value))
|
|
58
|
-
return { ok: false, error: 'Arguments must be an object' };
|
|
59
|
-
const conversationId = requiredString(value, 'conversation_id', 256);
|
|
60
|
-
if (!conversationId.ok)
|
|
61
|
-
return conversationId;
|
|
62
|
-
const contentType = parseContentType(value.content_type);
|
|
63
|
-
if (!contentType.ok)
|
|
64
|
-
return contentType;
|
|
65
|
-
const imageUrl = optionalString(value, 'image_url', 4096);
|
|
66
|
-
const audioUrl = optionalString(value, 'audio_url', 4096);
|
|
67
|
-
const videoUrl = optionalString(value, 'video_url', 4096);
|
|
68
|
-
const fileUrl = optionalString(value, 'file_url', 4096);
|
|
69
|
-
const mediaPath = optionalString(value, 'media_path', 4096);
|
|
70
|
-
const fileName = optionalString(value, 'file_name', 512);
|
|
71
|
-
const mimeType = optionalString(value, 'mime_type', 256);
|
|
72
|
-
const durationMs = optionalNumber(value, 'duration_ms');
|
|
73
|
-
return {
|
|
74
|
-
ok: true,
|
|
75
|
-
value: {
|
|
76
|
-
conversationId: conversationId.value,
|
|
77
|
-
text: optionalString(value, 'text') ?? '',
|
|
78
|
-
contentType: contentType.value,
|
|
79
|
-
...(imageUrl ? { imageUrl } : {}),
|
|
80
|
-
...(audioUrl ? { audioUrl } : {}),
|
|
81
|
-
...(videoUrl ? { videoUrl } : {}),
|
|
82
|
-
...(fileUrl ? { fileUrl } : {}),
|
|
83
|
-
...(mediaPath ? { mediaPath } : {}),
|
|
84
|
-
...(fileName ? { fileName } : {}),
|
|
85
|
-
...(mimeType ? { mimeType } : {}),
|
|
86
|
-
...(durationMs != null ? { durationMs } : {}),
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function parseSessionSelection(value) {
|
|
91
|
-
if (value == null)
|
|
92
|
-
return { ok: true, value: undefined };
|
|
93
|
-
const raw = typeof value === 'string'
|
|
94
|
-
? value
|
|
95
|
-
: isRecord(value) && typeof value.mode === 'string'
|
|
96
|
-
? value.mode
|
|
97
|
-
: null;
|
|
98
|
-
const mode = raw?.trim().toLowerCase().replace(/-/g, '_');
|
|
99
|
-
if (!mode)
|
|
100
|
-
return { ok: false, error: 'Invalid session_selection' };
|
|
101
|
-
if (mode === 'new' || mode === 'fresh' || mode === 'start_new') {
|
|
102
|
-
return { ok: true, value: { mode: 'new' } };
|
|
103
|
-
}
|
|
104
|
-
if (mode === 'continue_latest' || mode === 'latest' || mode === 'continue') {
|
|
105
|
-
return { ok: true, value: { mode: 'continue_latest' } };
|
|
106
|
-
}
|
|
107
|
-
if (mode === 'continue_or_create' || mode === 'auto' || mode === 'reuse_or_create') {
|
|
108
|
-
return { ok: true, value: { mode: 'continue_or_create' } };
|
|
109
|
-
}
|
|
110
|
-
return { ok: false, error: 'session_selection must be new, continue_latest, or continue_or_create' };
|
|
111
|
-
}
|
|
112
|
-
export function parseSendContextualMessageArgs(value) {
|
|
113
|
-
if (!isRecord(value))
|
|
114
|
-
return { ok: false, error: 'Arguments must be an object' };
|
|
115
|
-
const sourceConversationId = requiredString(value, 'source_conversation_id', 256);
|
|
116
|
-
if (!sourceConversationId.ok)
|
|
117
|
-
return sourceConversationId;
|
|
118
|
-
const text = requiredString(value, 'text');
|
|
119
|
-
if (!text.ok)
|
|
120
|
-
return text;
|
|
121
|
-
const targetConversationId = optionalString(value, 'target_conversation_id', 256);
|
|
122
|
-
const targetUserId = optionalString(value, 'target_user_id', 256);
|
|
123
|
-
if (Boolean(targetConversationId) === Boolean(targetUserId)) {
|
|
124
|
-
return { ok: false, error: 'Provide exactly one target_conversation_id or target_user_id' };
|
|
125
|
-
}
|
|
126
|
-
if (!isRecord(value.self_context)) {
|
|
127
|
-
return { ok: false, error: 'Missing self_context' };
|
|
128
|
-
}
|
|
129
|
-
const type = value.self_context.type;
|
|
130
|
-
const context = requiredString(value.self_context, 'context');
|
|
131
|
-
if (!context.ok)
|
|
132
|
-
return context;
|
|
133
|
-
if (type !== 'cross_session') {
|
|
134
|
-
return { ok: false, error: 'self_context.type must be cross_session' };
|
|
135
|
-
}
|
|
136
|
-
const sessionSelection = parseSessionSelection(value.session_selection);
|
|
137
|
-
if (!sessionSelection.ok)
|
|
138
|
-
return sessionSelection;
|
|
139
|
-
const messageOptions = isRecord(value.message_options)
|
|
140
|
-
? value.message_options
|
|
141
|
-
: undefined;
|
|
142
|
-
return {
|
|
143
|
-
ok: true,
|
|
144
|
-
value: {
|
|
145
|
-
sourceConversationId: sourceConversationId.value,
|
|
146
|
-
...(targetConversationId ? { targetConversationId } : {}),
|
|
147
|
-
...(targetUserId ? { targetUserId } : {}),
|
|
148
|
-
text: text.value,
|
|
149
|
-
selfContext: {
|
|
150
|
-
type: 'cross_session',
|
|
151
|
-
context: context.value,
|
|
152
|
-
},
|
|
153
|
-
...(sessionSelection.value ? { sessionSelection: sessionSelection.value } : {}),
|
|
154
|
-
...(messageOptions ? { messageOptions } : {}),
|
|
155
|
-
},
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
export function parseSetTypingArgs(value) {
|
|
159
|
-
if (!isRecord(value))
|
|
160
|
-
return { ok: false, error: 'Arguments must be an object' };
|
|
161
|
-
const conversationId = requiredString(value, 'conversation_id', 256);
|
|
162
|
-
if (!conversationId.ok)
|
|
163
|
-
return conversationId;
|
|
164
|
-
if (typeof value.typing !== 'boolean') {
|
|
165
|
-
return { ok: false, error: 'typing must be a boolean' };
|
|
166
|
-
}
|
|
167
|
-
const status = value.status;
|
|
168
|
-
if (status !== undefined && status !== 'typing' && status !== 'thinking') {
|
|
169
|
-
return { ok: false, error: 'Invalid status' };
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
ok: true,
|
|
173
|
-
value: {
|
|
174
|
-
conversationId: conversationId.value,
|
|
175
|
-
typing: value.typing,
|
|
176
|
-
...(status ? { status } : {}),
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
}
|
package/dist/server.d.ts
DELETED