@cocorograph/hub-agent 0.6.26 → 0.6.27
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/package.json +2 -2
- package/src/claude-stream-bridge.mjs +43 -4
- package/src/main.mjs +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocorograph/hub-agent",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.27",
|
|
4
4
|
"description": "Hub Hosted Cockpit のローカル常駐 agent。Hub と outbound WSS で接続し、ローカルの tmux/pty を中継する。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"LICENSE"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.
|
|
35
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.158",
|
|
36
36
|
"commander": "^12.1.0",
|
|
37
37
|
"node-pty": "^1.0.0",
|
|
38
38
|
"pino": "^9.0.0",
|
|
@@ -137,6 +137,7 @@ class ClaudeStreamSession {
|
|
|
137
137
|
permissionMode,
|
|
138
138
|
maxTurns,
|
|
139
139
|
maxThinkingTokens,
|
|
140
|
+
effort,
|
|
140
141
|
resumeSessionId,
|
|
141
142
|
resident,
|
|
142
143
|
sdk,
|
|
@@ -158,6 +159,10 @@ class ClaudeStreamSession {
|
|
|
158
159
|
this.maxTurns = typeof maxTurns === "number" ? maxTurns : null
|
|
159
160
|
this.maxThinkingTokens =
|
|
160
161
|
typeof maxThinkingTokens === "number" ? maxThinkingTokens : null
|
|
162
|
+
// Opus 4.6+ の effort パラメータ (low/medium/high/xhigh/max)。adaptive thinking と
|
|
163
|
+
// 併用して思考の深さを制御する。Opus では budget 方式 (maxThinkingTokens) は廃止
|
|
164
|
+
// 扱いのため、effort モデルでは effort + thinking:{type:'adaptive'} を使う。
|
|
165
|
+
this.effort = effort || null
|
|
161
166
|
this.sdk = sdk
|
|
162
167
|
this.logger = logger
|
|
163
168
|
this.onEvent = onEvent
|
|
@@ -326,7 +331,7 @@ class ClaudeStreamSession {
|
|
|
326
331
|
* 値が undefined のキーは「変更なし」として無視する (バッジ未送出時に既存値を消さない)。
|
|
327
332
|
* model に空文字/null が来たら setModel(undefined) でデフォルトへ戻す。
|
|
328
333
|
* maxThinkingTokens に 0/null が来たら setMaxThinkingTokens(null) でオフにする。 */
|
|
329
|
-
applyRuntimeOptions({ model, permissionMode, maxThinkingTokens } = {}) {
|
|
334
|
+
applyRuntimeOptions({ model, permissionMode, maxThinkingTokens, effort } = {}) {
|
|
330
335
|
const q = this._residentQuery
|
|
331
336
|
// モデル
|
|
332
337
|
if (model !== undefined) {
|
|
@@ -378,6 +383,34 @@ class ClaudeStreamSession {
|
|
|
378
383
|
}
|
|
379
384
|
}
|
|
380
385
|
}
|
|
386
|
+
// effort (Opus 4.6+)。SDK には setEffort 相当のランタイム制御メソッドが無いため、
|
|
387
|
+
// 保持値の更新のみ行う。per-message セッションは次ターンの options 構築時に
|
|
388
|
+
// this.effort を読むため即反映される。常駐 query は次 spawn (resume 再起動) 時に
|
|
389
|
+
// 反映される (= 次回セッションから切替。ユーザー要件と一致)。
|
|
390
|
+
if (effort !== undefined) {
|
|
391
|
+
this.effort = effort || null
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/** モデルが Opus 4.6+ (effort / adaptive thinking 対応) かどうか。
|
|
396
|
+
* budget 方式 (maxThinkingTokens) は Opus 4.7+ で廃止扱いのため、effort モデルでは
|
|
397
|
+
* effort + thinking:{type:'adaptive'} に切り替える。 */
|
|
398
|
+
_isEffortModel() {
|
|
399
|
+
return typeof this.model === "string" && /claude-opus-4-[678]/.test(this.model)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** 思考関連オプション (effort / adaptive thinking / 旧 budget) を options へ適用する。
|
|
403
|
+
* per-message / 常駐 query の両方から呼ぶ共通ロジック (分岐の二重定義を避ける)。 */
|
|
404
|
+
_applyThinkingOptions(options) {
|
|
405
|
+
if (this._isEffortModel()) {
|
|
406
|
+
// Opus: adaptive thinking を明示 ON にし、effort で深さを指定する。
|
|
407
|
+
// budget 方式 (maxThinkingTokens) は使わない (Opus 4.7+ で非対応)。
|
|
408
|
+
options.thinking = { type: "adaptive" }
|
|
409
|
+
if (this.effort) options.effort = this.effort
|
|
410
|
+
} else if (this.maxThinkingTokens != null) {
|
|
411
|
+
// 非 effort モデル (Sonnet / Haiku 等) は従来の budget 方式を維持。
|
|
412
|
+
options.maxThinkingTokens = this.maxThinkingTokens
|
|
413
|
+
}
|
|
381
414
|
}
|
|
382
415
|
|
|
383
416
|
/** soft detach: browser 切断時にターンを中断せずセッションを生かしたまま detached に
|
|
@@ -475,9 +508,10 @@ class ClaudeStreamSession {
|
|
|
475
508
|
}
|
|
476
509
|
if (this.model) options.model = this.model
|
|
477
510
|
if (this.permissionMode) options.permissionMode = this.permissionMode
|
|
478
|
-
// Phase B: チャット SDK に効くオプション (
|
|
511
|
+
// Phase B: チャット SDK に効くオプション (ツール往復上限)。
|
|
479
512
|
if (this.maxTurns != null) options.maxTurns = this.maxTurns
|
|
480
|
-
|
|
513
|
+
// 思考オプション (effort / adaptive thinking / 旧 budget) はモデルに応じて切替。
|
|
514
|
+
this._applyThinkingOptions(options)
|
|
481
515
|
// 直前ターンまでの session_id があれば resume チェーン
|
|
482
516
|
if (this.sessionId) options.resume = this.sessionId
|
|
483
517
|
|
|
@@ -683,7 +717,7 @@ class ClaudeStreamSession {
|
|
|
683
717
|
if (this.model) options.model = this.model
|
|
684
718
|
if (this.permissionMode) options.permissionMode = this.permissionMode
|
|
685
719
|
if (this.maxTurns != null) options.maxTurns = this.maxTurns
|
|
686
|
-
|
|
720
|
+
this._applyThinkingOptions(options)
|
|
687
721
|
// 改修4: 起動時に sessionId (= resumeSessionId) があれば resume チェーンで文脈を引き継ぐ。
|
|
688
722
|
// query 起動時点の値のみ有効 (起動後に確定/変化する session_id は同一 query 内で継続される)。
|
|
689
723
|
if (this.sessionId) options.resume = this.sessionId
|
|
@@ -871,6 +905,7 @@ export class ClaudeStreamBridge extends EventEmitter {
|
|
|
871
905
|
* permissionMode?: string|null,
|
|
872
906
|
* maxTurns?: number|null,
|
|
873
907
|
* maxThinkingTokens?: number|null,
|
|
908
|
+
* effort?: string|null,
|
|
874
909
|
* resumeSessionId?: string|null,
|
|
875
910
|
* }} args
|
|
876
911
|
* @returns {{ stream_id: string, resuming: boolean }}
|
|
@@ -882,6 +917,7 @@ export class ClaudeStreamBridge extends EventEmitter {
|
|
|
882
917
|
permissionMode,
|
|
883
918
|
maxTurns,
|
|
884
919
|
maxThinkingTokens,
|
|
920
|
+
effort,
|
|
885
921
|
resumeSessionId,
|
|
886
922
|
resident,
|
|
887
923
|
}) {
|
|
@@ -910,6 +946,7 @@ export class ClaudeStreamBridge extends EventEmitter {
|
|
|
910
946
|
permissionMode,
|
|
911
947
|
maxThinkingTokens:
|
|
912
948
|
typeof maxThinkingTokens === "number" ? maxThinkingTokens : null,
|
|
949
|
+
effort,
|
|
913
950
|
})
|
|
914
951
|
this.sessions.set(stream_id, live)
|
|
915
952
|
this.logger?.info(
|
|
@@ -920,6 +957,7 @@ export class ClaudeStreamBridge extends EventEmitter {
|
|
|
920
957
|
model: live.model,
|
|
921
958
|
permissionMode: live.permissionMode,
|
|
922
959
|
maxThinkingTokens: live.maxThinkingTokens,
|
|
960
|
+
effort: live.effort,
|
|
923
961
|
},
|
|
924
962
|
"claude stream reattached to live session",
|
|
925
963
|
)
|
|
@@ -934,6 +972,7 @@ export class ClaudeStreamBridge extends EventEmitter {
|
|
|
934
972
|
maxTurns: typeof maxTurns === "number" ? maxTurns : null,
|
|
935
973
|
maxThinkingTokens:
|
|
936
974
|
typeof maxThinkingTokens === "number" ? maxThinkingTokens : null,
|
|
975
|
+
effort: effort || null,
|
|
937
976
|
resumeSessionId: resumeSessionId || null,
|
|
938
977
|
resident,
|
|
939
978
|
sdk: this.sdk,
|
package/src/main.mjs
CHANGED
|
@@ -756,6 +756,9 @@ async function dispatch(msg, ctx) {
|
|
|
756
756
|
typeof msg.max_thinking_tokens === "number"
|
|
757
757
|
? msg.max_thinking_tokens
|
|
758
758
|
: null,
|
|
759
|
+
// effort (Opus 4.6+): browser がチャット既定 (agent 設定由来) を送る。
|
|
760
|
+
// 空文字/未指定なら null (SDK / Claude Code 既定 = Opus は high)。
|
|
761
|
+
effort: msg.effort || ctx.config?.claude_effort || null,
|
|
759
762
|
resumeSessionId: msg.resume_session_id || null,
|
|
760
763
|
})
|
|
761
764
|
ctx.client.send({
|