@canonmsg/claude-code-plugin 0.15.1 → 0.15.2
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/mcp-args.d.ts +2 -1
- package/dist/mcp-args.js +26 -0
- package/dist/server.js +7 -1
- package/package.json +3 -3
package/dist/mcp-args.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SendContextualMessageOptions } from '@canonmsg/core';
|
|
1
|
+
import type { DirectSessionSelection, SendContextualMessageOptions } from '@canonmsg/core';
|
|
2
2
|
export type McpParseResult<T> = {
|
|
3
3
|
ok: true;
|
|
4
4
|
value: T;
|
|
@@ -32,6 +32,7 @@ export interface SendContextualMessageArgs {
|
|
|
32
32
|
targetUserId?: string;
|
|
33
33
|
text: string;
|
|
34
34
|
selfContext: SendContextualMessageOptions['selfContext'];
|
|
35
|
+
sessionSelection?: DirectSessionSelection;
|
|
35
36
|
messageOptions?: SendContextualMessageOptions['messageOptions'];
|
|
36
37
|
}
|
|
37
38
|
export declare function parseSendContextualMessageArgs(value: unknown): McpParseResult<SendContextualMessageArgs>;
|
package/dist/mcp-args.js
CHANGED
|
@@ -87,6 +87,28 @@ export function parseSendMessageArgs(value) {
|
|
|
87
87
|
},
|
|
88
88
|
};
|
|
89
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
|
+
}
|
|
90
112
|
export function parseSendContextualMessageArgs(value) {
|
|
91
113
|
if (!isRecord(value))
|
|
92
114
|
return { ok: false, error: 'Arguments must be an object' };
|
|
@@ -111,6 +133,9 @@ export function parseSendContextualMessageArgs(value) {
|
|
|
111
133
|
if (type !== 'cross_session') {
|
|
112
134
|
return { ok: false, error: 'self_context.type must be cross_session' };
|
|
113
135
|
}
|
|
136
|
+
const sessionSelection = parseSessionSelection(value.session_selection);
|
|
137
|
+
if (!sessionSelection.ok)
|
|
138
|
+
return sessionSelection;
|
|
114
139
|
const messageOptions = isRecord(value.message_options)
|
|
115
140
|
? value.message_options
|
|
116
141
|
: undefined;
|
|
@@ -125,6 +150,7 @@ export function parseSendContextualMessageArgs(value) {
|
|
|
125
150
|
type: 'cross_session',
|
|
126
151
|
context: context.value,
|
|
127
152
|
},
|
|
153
|
+
...(sessionSelection.value ? { sessionSelection: sessionSelection.value } : {}),
|
|
128
154
|
...(messageOptions ? { messageOptions } : {}),
|
|
129
155
|
},
|
|
130
156
|
};
|
package/dist/server.js
CHANGED
|
@@ -163,6 +163,11 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
|
163
163
|
type: 'object',
|
|
164
164
|
description: 'Required { type: "cross_session", context: "why I am saying this here" }',
|
|
165
165
|
},
|
|
166
|
+
session_selection: {
|
|
167
|
+
type: 'string',
|
|
168
|
+
enum: ['new', 'continue_latest', 'continue_or_create'],
|
|
169
|
+
description: 'Optional direct-agent session behavior when target_user_id is used',
|
|
170
|
+
},
|
|
166
171
|
message_options: {
|
|
167
172
|
type: 'object',
|
|
168
173
|
description: 'Optional Canon send options for the contextual outbound message',
|
|
@@ -321,7 +326,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
321
326
|
const parsed = parseSendContextualMessageArgs(args);
|
|
322
327
|
if (!parsed.ok)
|
|
323
328
|
return toolArgumentError(parsed.error);
|
|
324
|
-
const { sourceConversationId, targetConversationId, targetUserId, text, selfContext, messageOptions, } = parsed.value;
|
|
329
|
+
const { sourceConversationId, targetConversationId, targetUserId, text, selfContext, sessionSelection, messageOptions, } = parsed.value;
|
|
325
330
|
const contextualMessageOptions = messageOptions;
|
|
326
331
|
const result = await client.sendContextualMessage({
|
|
327
332
|
sourceConversationId,
|
|
@@ -329,6 +334,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
329
334
|
...(targetUserId ? { targetUserId } : {}),
|
|
330
335
|
text,
|
|
331
336
|
selfContext,
|
|
337
|
+
...(sessionSelection ? { sessionSelection } : {}),
|
|
332
338
|
...(contextualMessageOptions
|
|
333
339
|
? {
|
|
334
340
|
messageOptions: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/claude-code-plugin",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Canon channel plugin for Claude Code — messaging where AI agents are first-class citizens",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@anthropic-ai/claude-agent-sdk": "^0.2.141",
|
|
34
|
-
"@canonmsg/agent-sdk": "^3.1.
|
|
35
|
-
"@canonmsg/core": "^2.1.
|
|
34
|
+
"@canonmsg/agent-sdk": "^3.1.1",
|
|
35
|
+
"@canonmsg/core": "^2.1.1",
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.29.0"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|