@cocorograph/hub-agent 0.8.117 → 0.8.118
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 +1 -1
- package/src/grok-stream-bridge.mjs +4 -0
- package/src/main.mjs +8 -2
- package/src/session-restore.mjs +9 -7
package/package.json
CHANGED
|
@@ -479,6 +479,10 @@ export class GrokStreamBridge extends EventEmitter {
|
|
|
479
479
|
session.cancelledTurn = session.turnSeq
|
|
480
480
|
this._clearTurnPermissions(session, session.turnSeq, true)
|
|
481
481
|
session.client.notify('session/cancel', { sessionId: session.sessionId })
|
|
482
|
+
if (!session.promptInFlight && !session.dispatchingInput) {
|
|
483
|
+
this.emit('grok_turn_complete', { stream_id: session.stream_id, session_id: session.sessionId,
|
|
484
|
+
stopReason: 'cancelled', lastSeq: session.updateSeq })
|
|
485
|
+
}
|
|
482
486
|
}
|
|
483
487
|
|
|
484
488
|
permissionReply({ stream_id, request_id, result }) {
|
package/src/main.mjs
CHANGED
|
@@ -3794,10 +3794,11 @@ export async function dispatch(msg, ctx) {
|
|
|
3794
3794
|
runInLane: scheduler && ((lane, fn) => scheduler.runInLane(lane, fn)),
|
|
3795
3795
|
claudeBridge: ctx.claudeBridge,
|
|
3796
3796
|
codexBridge: ctx.codexBridge,
|
|
3797
|
+
grokBridge: ctx.grokBridge,
|
|
3797
3798
|
claudeAttachOptions: () => resolveClaudeAttachOptions(ctx.config),
|
|
3798
3799
|
available: (kind) => kind === "codex"
|
|
3799
3800
|
? codexAvailableForDispatch(ctx)
|
|
3800
|
-
: ctx.availableClis?.includes(
|
|
3801
|
+
: ctx.availableClis?.includes(kind) === true,
|
|
3801
3802
|
logger: ctx.logger,
|
|
3802
3803
|
})
|
|
3803
3804
|
return
|
|
@@ -4990,6 +4991,7 @@ export async function dispatch(msg, ctx) {
|
|
|
4990
4991
|
noteRestoreStop(ctx.sessionRestoreState, "claude", cwd)
|
|
4991
4992
|
result.stopped = await ctx.claudeBridge.stopSessionsFor({ cwd, reason: "chat-stop" })
|
|
4992
4993
|
} else if (msg.cli_kind === "grok") {
|
|
4994
|
+
noteRestoreStop(ctx.sessionRestoreState, "grok", cwd)
|
|
4993
4995
|
result.stopped = await ctx.grokBridge?.stopSessionsForCwd({ cwd, reason: "chat-stop" }) ?? 0
|
|
4994
4996
|
} else {
|
|
4995
4997
|
noteRestoreStop(ctx.sessionRestoreState, "codex", cwd)
|
|
@@ -5010,7 +5012,11 @@ export async function dispatch(msg, ctx) {
|
|
|
5010
5012
|
}
|
|
5011
5013
|
} else if (msg.cli_kind === "grok") {
|
|
5012
5014
|
if (typeof msg.stream_id !== "string" || !msg.stream_id) result.error = "stream_id required"
|
|
5013
|
-
else
|
|
5015
|
+
else {
|
|
5016
|
+
const streamCwd = ctx.grokBridge?.sessions?.get?.(msg.stream_id)?.cwd
|
|
5017
|
+
if (streamCwd) noteRestoreStop(ctx.sessionRestoreState, "grok", streamCwd)
|
|
5018
|
+
result.stopped = await ctx.grokBridge?.stopSessionForStream({ stream_id: msg.stream_id, reason: "chat-stop" }) ?? 0
|
|
5019
|
+
}
|
|
5014
5020
|
} else if (msg.cli_kind === "codex") {
|
|
5015
5021
|
if (typeof msg.stream_id !== "string" || !msg.stream_id) result.error = "stream_id required"
|
|
5016
5022
|
else {
|
package/src/session-restore.mjs
CHANGED
|
@@ -31,7 +31,7 @@ export function noteRestoreStop(state, cliKind, cwd) {
|
|
|
31
31
|
* 受付状態と Hub の「接続ごとに 1 回」の送信がかみ合わず、復元が途中で止まる (2 巡目 blocker)。
|
|
32
32
|
*/
|
|
33
33
|
export async function restoreSessions(message, {
|
|
34
|
-
state, claudeBridge, codexBridge, available, logger,
|
|
34
|
+
state, claudeBridge, codexBridge, grokBridge, available, logger,
|
|
35
35
|
runInLane = (_lane, fn) => fn(), statCwd = stat,
|
|
36
36
|
claudeAttachOptions = () => ({}),
|
|
37
37
|
}) {
|
|
@@ -40,7 +40,7 @@ export async function restoreSessions(message, {
|
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
42
|
state.accepted = true
|
|
43
|
-
const bridges = { claude: claudeBridge, codex: codexBridge }
|
|
43
|
+
const bridges = { claude: claudeBridge, codex: codexBridge, grok: grokBridge }
|
|
44
44
|
const logSkip = (row, reason) => logger?.info?.({
|
|
45
45
|
cli_kind: row?.cli_kind, cwd: row?.cwd, session_id: row?.session_id, reason,
|
|
46
46
|
}, "agent.sessions.restore skipped")
|
|
@@ -48,7 +48,7 @@ export async function restoreSessions(message, {
|
|
|
48
48
|
logSkip(null, "sessions must be an array")
|
|
49
49
|
return
|
|
50
50
|
}
|
|
51
|
-
const snapshot = () => describeLiveSessionsUnion({ claudeBridge, codexBridge }).map((s) => ({
|
|
51
|
+
const snapshot = () => describeLiveSessionsUnion({ claudeBridge, codexBridge, grokBridge }).map((s) => ({
|
|
52
52
|
cli_kind: s.kind, cwd: s.cwd, session_id: s.session_id || s.thread_id,
|
|
53
53
|
}))
|
|
54
54
|
const same = (a, b) => a.cli_kind === b.cli_kind && a.cwd === b.cwd && a.session_id === b.session_id
|
|
@@ -73,7 +73,7 @@ export async function restoreSessions(message, {
|
|
|
73
73
|
const live = [...current, ...selected.filter((r) => !current.some((s) => same(s, r)))]
|
|
74
74
|
if (live.length >= WARM_TOTAL_MAX) break
|
|
75
75
|
try {
|
|
76
|
-
if (!row || !["claude", "codex"].includes(row.cli_kind)) throw new Error("unknown CLI")
|
|
76
|
+
if (!row || !["claude", "codex", "grok"].includes(row.cli_kind)) throw new Error("unknown CLI")
|
|
77
77
|
if (!bridges[row.cli_kind] || !available(row.cli_kind)) throw new Error("CLI unavailable")
|
|
78
78
|
if (typeof row.session_id !== "string" || !row.session_id.trim()) throw new Error("empty session_id")
|
|
79
79
|
if (typeof row.cwd !== "string" || !path.isAbsolute(row.cwd)) throw new Error("cwd must be absolute")
|
|
@@ -115,9 +115,11 @@ export async function restoreSessions(message, {
|
|
|
115
115
|
// ここで欠けると復元した会話だけ権限モードが既定に落ちる (0.8.91 の実測)。
|
|
116
116
|
...(row.cli_kind === "claude"
|
|
117
117
|
? { ...claudeAttachOptions(), resumeSessionId: row.session_id }
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
: row.cli_kind === "grok"
|
|
119
|
+
? { resumeSessionId: row.session_id }
|
|
120
|
+
// Codex は承認ポリシー / サンドボックスを thread 開始時にしか受け取らない。Hub が
|
|
121
|
+
// Cockpit の既定を行に載せる (空なら載せない = config.toml 既定。通常 attach と同じ)。
|
|
122
|
+
: {
|
|
121
123
|
resumeThreadId: row.session_id,
|
|
122
124
|
approvalPolicy: nonEmpty(row.approval_policy),
|
|
123
125
|
sandbox: nonEmpty(row.sandbox),
|