@miphamai/cli 0.24.1 → 0.24.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/package.json +1 -1
- package/src/core/engine.ts +38 -1
- package/src/index.tsx +3 -2
package/package.json
CHANGED
package/src/core/engine.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
ToolResult,
|
|
5
5
|
InferenceHookConfig,
|
|
6
6
|
CrsiConfig,
|
|
7
|
+
CrossSessionConfig,
|
|
7
8
|
} from '../shared/index.ts'
|
|
8
9
|
import { ProviderRegistry } from '../providers/registry'
|
|
9
10
|
import { ContextManager } from './context'
|
|
@@ -69,6 +70,12 @@ export class QueryEngine {
|
|
|
69
70
|
/** Session identifier for cross-session messaging. Set by the app startup via setSessionId(). */
|
|
70
71
|
private sessionId: string = 'session-1'
|
|
71
72
|
|
|
73
|
+
/** Cross-session inbound policy. Default: 'ask' (messages require user review). */
|
|
74
|
+
private crossSessionConfig: CrossSessionConfig = {
|
|
75
|
+
crossSessionInbound: 'ask',
|
|
76
|
+
dialogExpiry: 300,
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
/** Set the session identifier (called from index.tsx at startup with the actual session name). */
|
|
73
80
|
setSessionId(id: string): void {
|
|
74
81
|
this.sessionId = id
|
|
@@ -79,15 +86,45 @@ export class QueryEngine {
|
|
|
79
86
|
return this.sessionId
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
/** Set the cross-session messaging policy (called from index.tsx at startup). */
|
|
90
|
+
setCrossSessionConfig(config: CrossSessionConfig): void {
|
|
91
|
+
this.crossSessionConfig = config
|
|
92
|
+
}
|
|
93
|
+
|
|
82
94
|
/** Poll the cross-session file inbox for messages addressed to this session. */
|
|
83
95
|
async pollCrossSessionInbox(): Promise<void> {
|
|
96
|
+
const policy = this.crossSessionConfig.crossSessionInbound
|
|
97
|
+
|
|
98
|
+
// 'deny' — silently discard all inbound messages
|
|
99
|
+
if (policy === 'deny') {
|
|
100
|
+
try {
|
|
101
|
+
const transport = getFileInboxTransport()
|
|
102
|
+
await transport.poll(this.sessionId) // read + delete, don't forward
|
|
103
|
+
} catch {
|
|
104
|
+
// Best-effort discard
|
|
105
|
+
}
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
84
109
|
try {
|
|
85
110
|
const transport = getFileInboxTransport()
|
|
86
111
|
const messages = await transport.poll(this.sessionId)
|
|
87
112
|
if (messages.length > 0) {
|
|
88
113
|
const bus = getMessageBus()
|
|
89
114
|
for (const msg of messages) {
|
|
90
|
-
|
|
115
|
+
if (policy === 'ask') {
|
|
116
|
+
// Mark as awaiting approval — the model should verify with the user before acting
|
|
117
|
+
bus.post(
|
|
118
|
+
msg.from,
|
|
119
|
+
msg.to,
|
|
120
|
+
`[Awaiting Approval] ${msg.summary}`,
|
|
121
|
+
`[Cross-session message from ${msg.from} — verify with user before acting]\n\n${msg.message}`,
|
|
122
|
+
'warning',
|
|
123
|
+
)
|
|
124
|
+
} else {
|
|
125
|
+
// 'allow' — forward directly
|
|
126
|
+
bus.post(msg.from, msg.to, msg.summary, msg.message, msg.type)
|
|
127
|
+
}
|
|
91
128
|
}
|
|
92
129
|
}
|
|
93
130
|
} catch (err) {
|
package/src/index.tsx
CHANGED
|
@@ -318,8 +318,9 @@ export async function runApp(options: RunOptions): Promise<void> {
|
|
|
318
318
|
heartbeatInterval.unref()
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
// Load cross-session config
|
|
322
|
-
loadCrossSessionConfig()
|
|
321
|
+
// Load cross-session config and wire into the engine's inbound policy
|
|
322
|
+
const crossSessionConfig = loadCrossSessionConfig(process.cwd())
|
|
323
|
+
engine.setCrossSessionConfig(crossSessionConfig)
|
|
323
324
|
|
|
324
325
|
// Auto-save session on exit
|
|
325
326
|
let saved = false
|