@canonmsg/claude-code-plugin 0.32.0 → 0.34.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/.claude-plugin/plugin.json +1 -1
- package/dist/agent-context-state.d.ts +15 -0
- package/dist/agent-context-state.js +35 -0
- package/dist/canon-user-content.d.ts +3 -3
- package/dist/canon-user-content.js +4 -4
- package/dist/communication-policy.d.ts +2 -0
- package/dist/communication-policy.js +4 -0
- package/dist/host.d.ts +2 -2
- package/dist/host.js +128 -259
- package/dist/inbound-reply-authority.d.ts +42 -0
- package/dist/inbound-reply-authority.js +107 -0
- package/dist/mcp-args.d.ts +3 -0
- package/dist/mcp-args.js +12 -0
- package/dist/register.js +2 -1
- package/dist/server.js +253 -144
- package/dist/session-state.d.ts +6 -46
- package/dist/session-state.js +1 -74
- package/dist/tool-policy.js +2 -7
- package/package.json +6 -6
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AgentContext } from '@canonmsg/core';
|
|
2
|
+
/** Coordinates first identity discovery with the MCP client's cached tool list. */
|
|
3
|
+
export declare class AgentContextState {
|
|
4
|
+
private readonly onCommunicationAvailabilityChanged;
|
|
5
|
+
private resolveReady;
|
|
6
|
+
private settled;
|
|
7
|
+
private contextValue;
|
|
8
|
+
readonly ready: Promise<void>;
|
|
9
|
+
constructor(onCommunicationAvailabilityChanged: () => void);
|
|
10
|
+
get current(): AgentContext | null;
|
|
11
|
+
set(context: AgentContext): void;
|
|
12
|
+
/** Resolve tools/list even when startup cannot obtain a trusted identity. */
|
|
13
|
+
settleUnavailable(): void;
|
|
14
|
+
private settle;
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isProactiveCommunicationEnabled } from './communication-policy.js';
|
|
2
|
+
/** Coordinates first identity discovery with the MCP client's cached tool list. */
|
|
3
|
+
export class AgentContextState {
|
|
4
|
+
onCommunicationAvailabilityChanged;
|
|
5
|
+
resolveReady;
|
|
6
|
+
settled = false;
|
|
7
|
+
contextValue = null;
|
|
8
|
+
ready = new Promise((resolve) => {
|
|
9
|
+
this.resolveReady = resolve;
|
|
10
|
+
});
|
|
11
|
+
constructor(onCommunicationAvailabilityChanged) {
|
|
12
|
+
this.onCommunicationAvailabilityChanged = onCommunicationAvailabilityChanged;
|
|
13
|
+
}
|
|
14
|
+
get current() {
|
|
15
|
+
return this.contextValue;
|
|
16
|
+
}
|
|
17
|
+
set(context) {
|
|
18
|
+
const wasEnabled = isProactiveCommunicationEnabled(this.contextValue?.outboundPolicy);
|
|
19
|
+
this.contextValue = context;
|
|
20
|
+
this.settle();
|
|
21
|
+
const isEnabled = isProactiveCommunicationEnabled(context.outboundPolicy);
|
|
22
|
+
if (wasEnabled !== isEnabled)
|
|
23
|
+
this.onCommunicationAvailabilityChanged();
|
|
24
|
+
}
|
|
25
|
+
/** Resolve tools/list even when startup cannot obtain a trusted identity. */
|
|
26
|
+
settleUnavailable() {
|
|
27
|
+
this.settle();
|
|
28
|
+
}
|
|
29
|
+
settle() {
|
|
30
|
+
if (this.settled)
|
|
31
|
+
return;
|
|
32
|
+
this.settled = true;
|
|
33
|
+
this.resolveReady();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SDKUserMessage } from '@anthropic-ai/claude-agent-sdk';
|
|
2
2
|
import { type AnthropicImageBudgetOptions, type MaterializedCanonAttachment } from '@canonmsg/agent-sdk';
|
|
3
|
-
import { renderCanonHostInboundContent, type CanonReplyContext
|
|
3
|
+
import { renderCanonHostInboundContent, type CanonReplyContext } from '@canonmsg/core';
|
|
4
4
|
type ClaudeRenderableInboundMessage = Parameters<typeof renderCanonHostInboundContent>[0];
|
|
5
5
|
/**
|
|
6
6
|
* Claude-only rendering policy for Canon media. Core deliberately omits all
|
|
@@ -8,8 +8,8 @@ type ClaudeRenderableInboundMessage = Parameters<typeof renderCanonHostInboundCo
|
|
|
8
8
|
* that the bounded runtime did not materialize, while materialized images keep
|
|
9
9
|
* their local-path placeholder without a duplicate link.
|
|
10
10
|
*/
|
|
11
|
-
export declare function renderClaudeInboundContent(message: ClaudeRenderableInboundMessage, materialized?: ReadonlyArray<MaterializedCanonAttachment
|
|
12
|
-
export declare function withClaudeReplyContextMediaReferences(replyContext: CanonReplyContext | null, materialized: ReadonlyArray<MaterializedCanonAttachment
|
|
11
|
+
export declare function renderClaudeInboundContent(message: ClaudeRenderableInboundMessage, materialized?: ReadonlyArray<MaterializedCanonAttachment>): string;
|
|
12
|
+
export declare function withClaudeReplyContextMediaReferences(replyContext: CanonReplyContext | null, materialized: ReadonlyArray<MaterializedCanonAttachment>): CanonReplyContext | null;
|
|
13
13
|
/**
|
|
14
14
|
* Build the Claude Code SDK's multimodal user content without allowing native
|
|
15
15
|
* image blocks to consume the whole request. The prompt text is preserved
|
|
@@ -28,8 +28,8 @@ function validatedPromptAttachmentUrl(value) {
|
|
|
28
28
|
* that the bounded runtime did not materialize, while materialized images keep
|
|
29
29
|
* their local-path placeholder without a duplicate link.
|
|
30
30
|
*/
|
|
31
|
-
export function renderClaudeInboundContent(message, materialized = []
|
|
32
|
-
const rendered = renderCanonHostInboundContent(message, materialized
|
|
31
|
+
export function renderClaudeInboundContent(message, materialized = []) {
|
|
32
|
+
const rendered = renderCanonHostInboundContent(message, materialized);
|
|
33
33
|
const materializedIndexes = new Set(materialized.map((attachment) => attachment.index));
|
|
34
34
|
const imageLinks = (message.attachments ?? []).flatMap((attachment, index) => {
|
|
35
35
|
if (attachment.kind !== 'image' || materializedIndexes.has(index))
|
|
@@ -39,7 +39,7 @@ export function renderClaudeInboundContent(message, materialized = [], renderOpt
|
|
|
39
39
|
});
|
|
40
40
|
return imageLinks.length > 0 ? `${rendered}\n${imageLinks.join('\n')}` : rendered;
|
|
41
41
|
}
|
|
42
|
-
export function withClaudeReplyContextMediaReferences(replyContext, materialized
|
|
42
|
+
export function withClaudeReplyContextMediaReferences(replyContext, materialized) {
|
|
43
43
|
if (!replyContext?.found)
|
|
44
44
|
return replyContext;
|
|
45
45
|
return {
|
|
@@ -50,7 +50,7 @@ export function withClaudeReplyContextMediaReferences(replyContext, materialized
|
|
|
50
50
|
attachments: replyContext.attachments,
|
|
51
51
|
contactCard: replyContext.contactCard,
|
|
52
52
|
senderType: replyContext.senderType ?? undefined,
|
|
53
|
-
}, materialized
|
|
53
|
+
}, materialized),
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
/**
|
package/dist/host.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { type PermissionResult, type SDKControlReloadPluginsResponse } from '@anthropic-ai/claude-agent-sdk';
|
|
3
3
|
import { type RecoveryCheckpointTracker } from '@canonmsg/coding-agent-host';
|
|
4
|
-
import { type CanonRuntimeCommandDescriptor, type HostInboundParticipantContext as InboundParticipantContext, type CanonReplyContext, type MessageCreatedPayload, type ResolvedAgentBehaviorPolicy, type TurnVerbosityConfig } from '@canonmsg/core';
|
|
4
|
+
import { type CanonRuntimeCommandDescriptor, type ExecutionEnvironmentMode, type HostInboundParticipantContext as InboundParticipantContext, type CanonReplyContext, type MessageCreatedPayload, type ResolvedAgentBehaviorPolicy, type TurnVerbosityConfig } from '@canonmsg/core';
|
|
5
5
|
/**
|
|
6
6
|
* `--turn-verbosity` beats `CANON_TURN_VERBOSITY`; `null` means "unset, use the
|
|
7
7
|
* per-conversation-type default".
|
|
@@ -25,9 +25,9 @@ export declare function buildClaudePlanAllowResult(input: Record<string, unknown
|
|
|
25
25
|
* through. Canon-injected aliases keep precedence over native names.
|
|
26
26
|
*/
|
|
27
27
|
export declare function buildNativeSlashCommandDescriptors(native: SDKControlReloadPluginsResponse['commands'], reservedAliases: ReadonlySet<string>): CanonRuntimeCommandDescriptor[];
|
|
28
|
+
export declare function resolveSessionExecutionMode(defaultExecutionMode?: ExecutionEnvironmentMode): ExecutionEnvironmentMode;
|
|
28
29
|
export declare function createClaudeRecoveryCheckpointTracker(persist: (messageId: string) => boolean): RecoveryCheckpointTracker;
|
|
29
30
|
export declare const NO_REPLY_TOOL_NAME: string;
|
|
30
|
-
export declare const REACH_OUT_TOOL_NAME = "mcp__canon__send_to";
|
|
31
31
|
export declare function buildCanonPrompt(input: {
|
|
32
32
|
content: string;
|
|
33
33
|
conversationId: string;
|