mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-18 03:27:08 +00:00
fix: preserve deployed session fixes
Persist paged Codex history checkpoints and bounded, acknowledged delivery. Keep usage sources and accounting across deleted or merged sessions. Include native Goal controls, faster peer/session queries, and release guards. Track the complete deployed source so isolated builds cannot omit local fixes. Validation: all typechecks pass. The full suite reports 7,997 passing tests and 46 existing failures, each reproduced against the prior commit.
This commit is contained in:
@@ -137,6 +137,7 @@ describe('inspectPeer', () => {
|
||||
text: 'status on runner versions?'
|
||||
})
|
||||
expect(result.messages[1]?.text).toContain('Looking into it.')
|
||||
expect(http.get.mock.calls.some(([url]) => String(url).endsWith('/api/sessions'))).toBe(false)
|
||||
|
||||
// Read-only: never resume
|
||||
expect(http.post).toHaveBeenCalledTimes(1)
|
||||
|
||||
@@ -116,7 +116,7 @@ describe('pingPeer', () => {
|
||||
})
|
||||
|
||||
const result = await pingPeer({
|
||||
sessionIdPrefix: '05d9f0f2',
|
||||
sessionIdPrefix: sessionId,
|
||||
message: 'hello peer',
|
||||
accessToken: 'tok',
|
||||
apiUrl: 'http://127.0.0.1:3006',
|
||||
@@ -128,6 +128,7 @@ describe('pingPeer', () => {
|
||||
name: 'Orchestrator',
|
||||
resumed: false
|
||||
})
|
||||
expect(http.get.mock.calls.some(([url]) => String(url).endsWith('/api/sessions'))).toBe(false)
|
||||
expect(http.post).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
|
||||
@@ -80,11 +80,16 @@ export type ListPeerSessionsOptions = {
|
||||
const DEFAULT_WAIT_ACTIVE_SECS = 60
|
||||
const POLL_ACTIVE_MS = 2_000
|
||||
const POLL_PI_READY_MS = 1_000
|
||||
const FULL_SESSION_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
|
||||
function defaultSleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
function isFullSessionId(value: string): boolean {
|
||||
return FULL_SESSION_ID_RE.test(value)
|
||||
}
|
||||
|
||||
const AUTH_RECOVERY_HINT =
|
||||
'On a remote runner, set HAPI_API_URL to the runner hub, and set CLI_API_TOKEN ' +
|
||||
'or run `hapi auth login` to save the token. Inside a HAPI session prefer MCP ' +
|
||||
@@ -484,8 +489,12 @@ export async function pingPeer(options: PingPeerOptions): Promise<PingPeerResult
|
||||
const onProgress = options.onProgress
|
||||
|
||||
const jwt = await exchangeJwt(apiUrl, accessToken, http)
|
||||
const sessions = await listSessions(apiUrl, jwt, http)
|
||||
const matched = resolveSessionByPrefix(sessions, prefix)
|
||||
// Full ids come from Copy-reference citations and are already unambiguous.
|
||||
// Resolve them directly so a peer handoff does not fetch and sort the entire
|
||||
// namespace before it can even inspect one session.
|
||||
const matched = isFullSessionId(prefix)
|
||||
? await getSession(apiUrl, jwt, prefix, http)
|
||||
: resolveSessionByPrefix(await listSessions(apiUrl, jwt, http), prefix)
|
||||
const name = resolvePeerSessionLabel(matched)
|
||||
onProgress?.(`resolved ${matched.id} active=${matched.active} name="${name}"`)
|
||||
|
||||
@@ -679,9 +688,16 @@ export async function inspectPeer(options: InspectPeerOptions): Promise<InspectP
|
||||
const http = options.http ?? axios
|
||||
|
||||
const jwt = await exchangeJwt(apiUrl, accessToken, http)
|
||||
const sessions = await listSessions(apiUrl, jwt, http)
|
||||
const matched = resolveSessionByPrefix(sessions, prefix)
|
||||
const live = await getSession(apiUrl, jwt, matched.id, http)
|
||||
// Copy-reference citations contain the complete UUID. Avoid the expensive
|
||||
// namespace-wide list query in that common path; prefixes still use the
|
||||
// list endpoint to preserve ambiguity detection.
|
||||
const hasFullSessionId = isFullSessionId(prefix)
|
||||
const matched = hasFullSessionId
|
||||
? await getSession(apiUrl, jwt, prefix, http)
|
||||
: resolveSessionByPrefix(await listSessions(apiUrl, jwt, http), prefix)
|
||||
const live = hasFullSessionId
|
||||
? matched
|
||||
: await getSession(apiUrl, jwt, matched.id, http)
|
||||
const meta = live.metadata ?? matched.metadata ?? null
|
||||
const messages = await fetchSessionMessages(apiUrl, jwt, matched.id, messageLimit, http)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user