@canonmsg/claude-code-plugin 0.21.1 → 0.21.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/host.js CHANGED
@@ -36,7 +36,7 @@ import { ApprovalManager, readHostSessionConfig, resolveHostWorkspaceCwd, } from
36
36
  import { runCli } from './cli-entry.js';
37
37
  import { synthesizeClaudeApprovalDiff } from './approval-diff.js';
38
38
  import { decideClaudeToolPermissionForMode, parseAllowedNonOwnerClaudeTools, } from './tool-policy.js';
39
- import { applyClaudeSessionControl, buildClaudeFinalMessageId, buildClaudeInitialSessionState, createClaudeInputEnvelope, formatClaudeControlError, normalizeClaudeEffortLevel, parseClaudePermissionMode, resolveClaudeModelOptions, resetClaudeCompletedTurnState, shouldDeliverClaudeFinal, } from './session-state.js';
39
+ import { applyClaudeSessionControl, buildClaudeFinalMessageId, buildClaudeInitialSessionState, claudeModelInfoToOption, createClaudeInputEnvelope, formatClaudeControlError, isClaudeCustomModelOption, normalizeClaudeEffortLevel, parseClaudePermissionMode, resolveClaudeModelOptions, resetClaudeCompletedTurnState, shouldDeliverClaudeFinal, } from './session-state.js';
40
40
  import { claudeThinkingToConfig, parseClaudeSessionDefaults, resolveEffectiveSessionSettings, } from './session-defaults.js';
41
41
  import { mapClaudeSubagentActivity } from './subagent-activity.js';
42
42
  function parseRuntimeVisibilityPreset(value) {
@@ -331,11 +331,20 @@ function resolveClaudeCliPath() {
331
331
  console.error('[canon-host] claude CLI not on PATH; using SDK-bundled binary');
332
332
  return undefined;
333
333
  }
334
+ const CLAUDE_SUPPLEMENTAL_MODEL_PROBES = ['opus'];
335
+ function mergeModelOptions(...groups) {
336
+ const byValue = new Map();
337
+ for (const group of groups) {
338
+ for (const option of group) {
339
+ if (!byValue.has(option.value)) {
340
+ byValue.set(option.value, option);
341
+ }
342
+ }
343
+ }
344
+ return [...byValue.values()];
345
+ }
334
346
  function toModelOptions(models) {
335
- return models.map((model) => ({
336
- value: model.value,
337
- label: model.displayName,
338
- }));
347
+ return models.map(claudeModelInfoToOption);
339
348
  }
340
349
  async function publishAgentRuntime(port, runtime) {
341
350
  await port.publishHostAgentRuntime({
@@ -375,6 +384,21 @@ function resolveExecutionFallbackReason(environment) {
375
384
  : environment.reason;
376
385
  }
377
386
  async function detectRuntimeModels(cwd) {
387
+ const discovered = await detectRuntimeModelsForSelection(cwd, 'default');
388
+ const supplemental = await Promise.all(CLAUDE_SUPPLEMENTAL_MODEL_PROBES.map(async (model) => {
389
+ try {
390
+ const options = await detectRuntimeModelsForSelection(cwd, model);
391
+ const option = options.find((entry) => entry.value === model);
392
+ return option && !isClaudeCustomModelOption(option) ? [option] : [];
393
+ }
394
+ catch (error) {
395
+ console.error(`[canon-host] Supplemental Claude model probe failed for ${model}:`, error);
396
+ return [];
397
+ }
398
+ }));
399
+ return mergeModelOptions(discovered, ...supplemental);
400
+ }
401
+ async function detectRuntimeModelsForSelection(cwd, model) {
378
402
  const emptyPrompt = {
379
403
  async *[Symbol.asyncIterator]() { },
380
404
  };
@@ -384,7 +408,7 @@ async function detectRuntimeModels(cwd) {
384
408
  options: {
385
409
  systemPrompt: { type: 'preset', preset: 'claude_code' },
386
410
  tools: { type: 'preset', preset: 'claude_code' },
387
- model: 'default',
411
+ model,
388
412
  permissionMode: 'default',
389
413
  cwd,
390
414
  settings: { forceLoginMethod: 'claudeai' },
@@ -103,6 +103,13 @@ export declare function shouldDeliverClaudeFinal(input: {
103
103
  interruptedTurnKeys: ReadonlySet<string>;
104
104
  }): boolean;
105
105
  export declare function resetClaudeCompletedTurnState(session: ClaudeCompletedTurnState): void;
106
+ export interface ClaudeModelInfoLike {
107
+ value: string;
108
+ displayName: string;
109
+ description?: string;
110
+ }
111
+ export declare function claudeModelInfoToOption(model: ClaudeModelInfoLike): ModelOption;
112
+ export declare function isClaudeCustomModelOption(option: ModelOption | null | undefined): boolean;
106
113
  export declare function resolveClaudeModelOptions(input: {
107
114
  discovered: ReadonlyArray<ModelOption>;
108
115
  selectedModel?: string | null;
@@ -215,6 +215,32 @@ export function resetClaudeCompletedTurnState(session) {
215
215
  session.toolInProgress = false;
216
216
  session.turnState = 'idle';
217
217
  }
218
+ function normalizeModelDescription(value) {
219
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
220
+ }
221
+ function displayLabelWithClaudeVersion(input) {
222
+ const label = input.displayName.trim() || input.value;
223
+ const description = normalizeModelDescription(input.description);
224
+ if (!description || label.includes('(') || /\d/.test(label))
225
+ return label;
226
+ const [summary] = description.split('·');
227
+ const versionedLabel = summary?.trim();
228
+ return versionedLabel
229
+ && versionedLabel.toLowerCase().startsWith(label.toLowerCase())
230
+ && /\d/.test(versionedLabel)
231
+ ? versionedLabel
232
+ : label;
233
+ }
234
+ export function claudeModelInfoToOption(model) {
235
+ return {
236
+ value: model.value,
237
+ label: displayLabelWithClaudeVersion(model),
238
+ ...(normalizeModelDescription(model.description) ? { description: normalizeModelDescription(model.description) } : {}),
239
+ };
240
+ }
241
+ export function isClaudeCustomModelOption(option) {
242
+ return option?.description?.trim().toLowerCase() === 'custom model';
243
+ }
218
244
  export function resolveClaudeModelOptions(input) {
219
245
  const byValue = new Map();
220
246
  for (const option of input.discovered) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonmsg/claude-code-plugin",
3
- "version": "0.21.1",
3
+ "version": "0.21.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",
@@ -33,8 +33,8 @@
33
33
  "@anthropic-ai/claude-agent-sdk": "^0.3.200",
34
34
  "@canonmsg/agent-host": "^0.4.0",
35
35
  "@canonmsg/agent-sdk": "^3.4.4",
36
- "@canonmsg/bridge": "^0.2.0",
37
- "@canonmsg/core": "^3.2.0",
36
+ "@canonmsg/bridge": "^0.2.3",
37
+ "@canonmsg/core": "^3.2.1",
38
38
  "@canonmsg/framework": "^0.2.0",
39
39
  "@modelcontextprotocol/sdk": "^1.29.0"
40
40
  },