@canonmsg/claude-code-plugin 0.9.1 → 0.9.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/cli-entry.d.ts +2 -0
- package/dist/cli-entry.js +16 -0
- package/dist/host.d.ts +1 -1
- package/dist/host.js +4 -3
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/register.d.ts +1 -1
- package/dist/register.js +80 -73
- package/dist/server.d.ts +1 -1
- package/dist/server.js +4 -3
- package/dist/setup.d.ts +1 -1
- package/dist/setup.js +16 -9
- package/package.json +9 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
export function isDirectExecution(moduleUrl) {
|
|
4
|
+
const entry = process.argv[1];
|
|
5
|
+
if (!entry)
|
|
6
|
+
return false;
|
|
7
|
+
return pathToFileURL(resolve(entry)).href === moduleUrl;
|
|
8
|
+
}
|
|
9
|
+
export function runCli(moduleUrl, main, onError) {
|
|
10
|
+
if (!isDirectExecution(moduleUrl)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
Promise.resolve()
|
|
14
|
+
.then(() => main())
|
|
15
|
+
.catch(onError);
|
|
16
|
+
}
|
package/dist/host.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export declare function main(): Promise<void>;
|
package/dist/host.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { setDefaultResultOrder } from 'node:dns';
|
|
3
|
-
setDefaultResultOrder('ipv4first');
|
|
4
3
|
/**
|
|
5
4
|
* Canon Agent SDK host wrapper — multi-session.
|
|
6
5
|
*
|
|
@@ -29,6 +28,7 @@ import { buildConfiguredWorkspaceOptions, buildConversationEnvironmentKey, build
|
|
|
29
28
|
import { buildCanonHostPrompt, buildHydratedInboundContext, createConversationMetadataLoader, loadHostSessionConfig, publishHostAgentRuntime, renderCanonHostInboundContent, resolveHostWorkspaceCwd, } from './host-runtime.js';
|
|
30
29
|
import { buildInboundContextLines, decideAutoReply, } from './inbound-policy.js';
|
|
31
30
|
import { createStreamingBuffer } from './streaming-buffer.js';
|
|
31
|
+
import { runCli } from './cli-entry.js';
|
|
32
32
|
let workingDir = process.cwd();
|
|
33
33
|
let workspaceOptions = [];
|
|
34
34
|
let runtimeModels = [];
|
|
@@ -666,7 +666,8 @@ function createSession(conversationId, environment, agentId, client, onSessionEn
|
|
|
666
666
|
return session;
|
|
667
667
|
}
|
|
668
668
|
// ── Main ────────────────────────────────────────────────────────────
|
|
669
|
-
async function main() {
|
|
669
|
+
export async function main() {
|
|
670
|
+
setDefaultResultOrder('ipv4first');
|
|
670
671
|
const { values: args } = parseArgs({
|
|
671
672
|
options: {
|
|
672
673
|
cwd: { type: 'string' },
|
|
@@ -1156,7 +1157,7 @@ async function main() {
|
|
|
1156
1157
|
await new Promise(() => { });
|
|
1157
1158
|
}
|
|
1158
1159
|
// ── Entry ───────────────────────────────────────────────────────────
|
|
1159
|
-
|
|
1160
|
+
runCli(import.meta.url, main, (err) => {
|
|
1160
1161
|
console.error('[canon-host] Fatal error:', err);
|
|
1161
1162
|
const ap = getActiveProfile();
|
|
1162
1163
|
if (ap)
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/dist/register.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export declare function main(): Promise<void>;
|
package/dist/register.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { setDefaultResultOrder } from 'node:dns';
|
|
3
|
-
setDefaultResultOrder('ipv4first');
|
|
4
3
|
/**
|
|
5
4
|
* CLI script for Canon agent registration.
|
|
6
5
|
* Invoked by the /canon-register skill.
|
|
@@ -15,80 +14,88 @@ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
|
15
14
|
import { join } from 'node:path';
|
|
16
15
|
import { homedir } from 'node:os';
|
|
17
16
|
import { parseArgs } from 'node:util';
|
|
17
|
+
import { runCli } from './cli-entry.js';
|
|
18
18
|
const CANON_DIR = join(homedir(), '.canon');
|
|
19
19
|
const AGENTS_PATH = join(CANON_DIR, 'agents.json');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
profiles =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
20
|
+
export async function main() {
|
|
21
|
+
setDefaultResultOrder('ipv4first');
|
|
22
|
+
const { values } = parseArgs({
|
|
23
|
+
options: {
|
|
24
|
+
name: { type: 'string' },
|
|
25
|
+
description: { type: 'string' },
|
|
26
|
+
phone: { type: 'string' },
|
|
27
|
+
profile: { type: 'string' },
|
|
28
|
+
'base-url': { type: 'string' },
|
|
29
|
+
},
|
|
30
|
+
strict: true,
|
|
31
|
+
});
|
|
32
|
+
if (!values.name || !values.description || !values.phone) {
|
|
33
|
+
console.error('Usage: node register.js --name "Agent Name" --description "Description" --phone "+15551234567" [--profile "my-agent"]');
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
// Default profile name: sanitized agent name
|
|
37
|
+
const profileName = values.profile || values.name.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-');
|
|
38
|
+
let existingAgentId;
|
|
39
|
+
try {
|
|
40
|
+
const profiles = JSON.parse(readFileSync(AGENTS_PATH, 'utf-8'));
|
|
41
|
+
existingAgentId = profiles[profileName]?.agentId;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// File doesn't exist yet
|
|
45
|
+
}
|
|
46
|
+
console.log(`Registering agent "${values.name}" (profile: ${profileName})...`);
|
|
47
|
+
const result = await registerAndWaitForApproval({
|
|
48
|
+
name: values.name,
|
|
49
|
+
description: values.description,
|
|
50
|
+
ownerPhone: values.phone,
|
|
51
|
+
developerInfo: 'Claude Code plugin',
|
|
52
|
+
clientType: 'claude-code',
|
|
53
|
+
baseUrl: values['base-url'],
|
|
54
|
+
requestedAgentId: existingAgentId,
|
|
55
|
+
}, {
|
|
56
|
+
onSubmitted: (requestId) => {
|
|
57
|
+
console.log(`Registration submitted (request ID: ${requestId}).`);
|
|
58
|
+
console.log('Waiting for approval in Canon app...');
|
|
59
|
+
},
|
|
60
|
+
onPollUpdate: () => {
|
|
61
|
+
process.stdout.write('.');
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
console.log(''); // newline after dots
|
|
65
|
+
switch (result.status) {
|
|
66
|
+
case 'approved': {
|
|
67
|
+
// Save to ~/.canon/agents.json
|
|
68
|
+
mkdirSync(CANON_DIR, { recursive: true });
|
|
69
|
+
let profiles = {};
|
|
70
|
+
try {
|
|
71
|
+
profiles = JSON.parse(readFileSync(AGENTS_PATH, 'utf-8'));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// File doesn't exist yet
|
|
75
|
+
}
|
|
76
|
+
profiles[profileName] = {
|
|
77
|
+
apiKey: result.apiKey,
|
|
78
|
+
agentId: result.agentId,
|
|
79
|
+
agentName: result.agentName,
|
|
80
|
+
registeredAt: new Date().toISOString(),
|
|
81
|
+
};
|
|
82
|
+
writeFileSync(AGENTS_PATH, JSON.stringify(profiles, null, 2));
|
|
83
|
+
console.log(`Approved! Agent: ${result.agentName} (${result.agentId})`);
|
|
84
|
+
console.log(`Saved as profile "${profileName}" in ~/.canon/agents.json`);
|
|
85
|
+
console.log('Restart Claude Code to connect.');
|
|
86
|
+
break;
|
|
73
87
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
console.log(`Saved as profile "${profileName}" in ~/.canon/agents.json`);
|
|
83
|
-
console.log('Restart Claude Code to connect.');
|
|
84
|
-
break;
|
|
88
|
+
case 'rejected':
|
|
89
|
+
console.log('Registration was rejected.');
|
|
90
|
+
process.exit(1);
|
|
91
|
+
break;
|
|
92
|
+
case 'timeout':
|
|
93
|
+
console.log('Registration timed out (5 minutes). Try again later.');
|
|
94
|
+
process.exit(1);
|
|
95
|
+
break;
|
|
85
96
|
}
|
|
86
|
-
case 'rejected':
|
|
87
|
-
console.log('Registration was rejected.');
|
|
88
|
-
process.exit(1);
|
|
89
|
-
break;
|
|
90
|
-
case 'timeout':
|
|
91
|
-
console.log('Registration timed out (5 minutes). Try again later.');
|
|
92
|
-
process.exit(1);
|
|
93
|
-
break;
|
|
94
97
|
}
|
|
98
|
+
runCli(import.meta.url, main, (error) => {
|
|
99
|
+
console.error('[canon-register] Fatal error:', error);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
});
|
package/dist/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export declare function main(): Promise<void>;
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { setDefaultResultOrder } from 'node:dns';
|
|
3
|
-
setDefaultResultOrder('ipv4first');
|
|
4
3
|
/**
|
|
5
4
|
* Canon channel MCP server for Claude Code.
|
|
6
5
|
*
|
|
@@ -13,6 +12,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
13
12
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
14
13
|
import { CanonClient, CanonStream, ApprovalManager, loadProfiles, isProfileLocked, resolveCanonAgent, getActiveProfile, releaseLock, initRTDBAuth, writeSessionState, clearSessionState, } from '@canonmsg/core';
|
|
15
14
|
import { ApprovalHttpServer } from './approval-server.js';
|
|
15
|
+
import { runCli } from './cli-entry.js';
|
|
16
16
|
// ── MCP server ─────────────────────────────────────────────────────────
|
|
17
17
|
const server = new Server({ name: 'canon-channel', version: '0.1.0' }, {
|
|
18
18
|
capabilities: {
|
|
@@ -593,7 +593,8 @@ async function startChannel() {
|
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
595
|
// ── Main ───────────────────────────────────────────────────────────────
|
|
596
|
-
async function main() {
|
|
596
|
+
export async function main() {
|
|
597
|
+
setDefaultResultOrder('ipv4first');
|
|
597
598
|
const transport = new StdioServerTransport();
|
|
598
599
|
await server.connect(transport);
|
|
599
600
|
// Start the Canon channel after MCP connection is established
|
|
@@ -617,7 +618,7 @@ async function main() {
|
|
|
617
618
|
process.on('SIGINT', shutdown);
|
|
618
619
|
process.on('SIGTERM', shutdown);
|
|
619
620
|
}
|
|
620
|
-
|
|
621
|
+
runCli(import.meta.url, main, (err) => {
|
|
621
622
|
console.error('[canon] Fatal error:', err);
|
|
622
623
|
process.exit(1);
|
|
623
624
|
});
|
package/dist/setup.d.ts
CHANGED
package/dist/setup.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'node:fs';
|
|
10
10
|
import { join, dirname } from 'node:path';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { runCli } from './cli-entry.js';
|
|
12
13
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
14
|
const home = process.env.HOME || process.env.USERPROFILE || '';
|
|
14
15
|
const skillsDir = join(home, '.claude', 'skills');
|
|
@@ -55,12 +56,18 @@ Then start Claude Code with:
|
|
|
55
56
|
`);
|
|
56
57
|
}
|
|
57
58
|
// ── Main ───────────────────────────────────────────────────────────────
|
|
58
|
-
|
|
59
|
-
console.log('
|
|
60
|
-
console.log('
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
console.log('
|
|
64
|
-
console.log(' Run /canon-
|
|
65
|
-
console.log('
|
|
66
|
-
|
|
59
|
+
export function main() {
|
|
60
|
+
console.log('Canon Claude Code Plugin Setup');
|
|
61
|
+
console.log('==============================\n');
|
|
62
|
+
console.log('Installing skills...');
|
|
63
|
+
installSkills();
|
|
64
|
+
console.log('\nRegistering your agent...');
|
|
65
|
+
console.log(' Run /canon-register in Claude Code to register a new agent');
|
|
66
|
+
console.log(' Run /canon-configure if you already have an API key\n');
|
|
67
|
+
console.log('MCP server configuration:');
|
|
68
|
+
showMcpInstructions();
|
|
69
|
+
}
|
|
70
|
+
runCli(import.meta.url, main, (error) => {
|
|
71
|
+
console.error('[canon-setup] Fatal error:', error);
|
|
72
|
+
process.exit(1);
|
|
73
|
+
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonmsg/claude-code-plugin",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Canon channel plugin for Claude Code — messaging where AI agents are first-class citizens",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
7
14
|
"bin": {
|
|
8
15
|
"canon-channel-server": "dist/server.js",
|
|
9
16
|
"canon-claude": "dist/host.js",
|