mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
Merge remote-tracking branch 'origin/main' into brennanb2025/claude-alias-rows
# Conflicts: # src/renderer/src/components/agent/agent-launch-setup-option-rows.test.ts # src/shared/legacy-agent-models.test.ts
This commit is contained in:
@@ -44,8 +44,8 @@ on:
|
||||
- 'src/main/native-chat/subagent-entry-id-bounds.ts'
|
||||
- 'src/main/native-chat/agent-session-journal/item-lifecycle/journal-payload-bounds.ts'
|
||||
- 'src/main/native-chat/agent-session-journal/item-lifecycle/journal-reasoning-row.ts'
|
||||
- 'src/main/claude/claude-internal-message-content.ts'
|
||||
- 'src/main/claude/claude-stop-hook-feedback.ts'
|
||||
- 'src/main/claude/structured/journal/claude-internal-message-content.ts'
|
||||
- 'src/main/claude/structured/journal/claude-stop-hook-feedback.ts'
|
||||
- 'src/main/claude/structured/journal/**'
|
||||
- 'src/main/claude/__fixtures__/claude-adapter-capture-fold.jsonl'
|
||||
- 'src/main/codex/app-server/codex-item-field-readers.ts'
|
||||
@@ -132,8 +132,8 @@ on:
|
||||
- 'src/main/native-chat/subagent-entry-id-bounds.ts'
|
||||
- 'src/main/native-chat/agent-session-journal/item-lifecycle/journal-payload-bounds.ts'
|
||||
- 'src/main/native-chat/agent-session-journal/item-lifecycle/journal-reasoning-row.ts'
|
||||
- 'src/main/claude/claude-internal-message-content.ts'
|
||||
- 'src/main/claude/claude-stop-hook-feedback.ts'
|
||||
- 'src/main/claude/structured/journal/claude-internal-message-content.ts'
|
||||
- 'src/main/claude/structured/journal/claude-stop-hook-feedback.ts'
|
||||
- 'src/main/claude/structured/journal/**'
|
||||
- 'src/main/claude/__fixtures__/claude-adapter-capture-fold.jsonl'
|
||||
- 'src/main/codex/app-server/codex-item-field-readers.ts'
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { PushDeviceRegistryStore, type PushDeviceUpsert } from './device-registry-store.js'
|
||||
import { openInMemoryPushDatabase } from '../database/push-database.js'
|
||||
import type { CloudDatabase as PushDatabase } from '@orca-cloud/cloud-database/cloud-database'
|
||||
|
||||
const OWNER = 'abcdefghijklmnop'
|
||||
const OTHER = 'ponmlkjihgfedcba'
|
||||
|
||||
describe('push device registry store', () => {
|
||||
let database: PushDatabase
|
||||
let clock = 1_700_000_000_000
|
||||
let devices: PushDeviceRegistryStore
|
||||
|
||||
beforeEach(async () => {
|
||||
database = await openInMemoryPushDatabase()
|
||||
clock = 1_700_000_000_000
|
||||
devices = new PushDeviceRegistryStore(database, () => clock)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await database.close()
|
||||
})
|
||||
|
||||
async function upsertOk(input: PushDeviceUpsert): Promise<string> {
|
||||
const result = await devices.upsert(input)
|
||||
if (!result.ok) throw new Error(`unexpected upsert refusal: ${result.reason}`)
|
||||
return result.registrationId
|
||||
}
|
||||
|
||||
function androidDevice(deviceId: string): PushDeviceUpsert {
|
||||
return {
|
||||
hostFingerprint: OWNER,
|
||||
deviceId,
|
||||
platform: 'android',
|
||||
token: `token-${deviceId}`
|
||||
}
|
||||
}
|
||||
|
||||
it('keeps one registration per host and device while replacing the token', async () => {
|
||||
const first = await upsertOk({
|
||||
hostFingerprint: OWNER,
|
||||
deviceId: 'device-1',
|
||||
platform: 'ios',
|
||||
token: 'a'.repeat(64),
|
||||
apnsEnvironment: 'sandbox'
|
||||
})
|
||||
clock += 1_000
|
||||
const second = await upsertOk({
|
||||
hostFingerprint: OWNER,
|
||||
deviceId: 'device-1',
|
||||
platform: 'ios',
|
||||
token: 'b'.repeat(64),
|
||||
apnsEnvironment: 'production'
|
||||
})
|
||||
expect(second).toBe(first)
|
||||
const registration = await devices.findById(first)
|
||||
expect(registration).toMatchObject({
|
||||
token: 'b'.repeat(64),
|
||||
apnsEnvironment: 'production',
|
||||
dead: false
|
||||
})
|
||||
expect(await devices.list(OWNER)).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('revives a registration that a re-registered token replaces', async () => {
|
||||
const registrationId = await upsertOk({
|
||||
hostFingerprint: OWNER,
|
||||
deviceId: 'device-1',
|
||||
platform: 'android',
|
||||
token: 'token-one'
|
||||
})
|
||||
await devices.markDead((await devices.findById(registrationId))!)
|
||||
expect((await devices.findById(registrationId))?.dead).toBe(true)
|
||||
await upsertOk({
|
||||
hostFingerprint: OWNER,
|
||||
deviceId: 'device-1',
|
||||
platform: 'android',
|
||||
token: 'token-two'
|
||||
})
|
||||
expect(await devices.findById(registrationId)).toMatchObject({
|
||||
token: 'token-two',
|
||||
dead: false
|
||||
})
|
||||
})
|
||||
|
||||
it('lets only the owning host delete a registration', async () => {
|
||||
const registrationId = await upsertOk({
|
||||
hostFingerprint: OWNER,
|
||||
deviceId: 'device-1',
|
||||
platform: 'android',
|
||||
token: 'token-one'
|
||||
})
|
||||
expect(await devices.deleteOwned(OTHER, registrationId)).toBe(false)
|
||||
expect(await devices.findById(registrationId)).not.toBeNull()
|
||||
expect(await devices.deleteOwned(OWNER, registrationId)).toBe(true)
|
||||
expect(await devices.findById(registrationId)).toBeNull()
|
||||
})
|
||||
|
||||
it('scopes lookups and listings to the owning host', async () => {
|
||||
const owned = await upsertOk({
|
||||
hostFingerprint: OWNER,
|
||||
deviceId: 'device-1',
|
||||
platform: 'android',
|
||||
token: 'token-one'
|
||||
})
|
||||
const foreign = await upsertOk({
|
||||
hostFingerprint: OTHER,
|
||||
deviceId: 'device-2',
|
||||
platform: 'android',
|
||||
token: 'token-two'
|
||||
})
|
||||
const found = await devices.findOwned(OWNER, [owned, foreign])
|
||||
expect([...found.keys()]).toEqual([owned])
|
||||
expect(await devices.list(OTHER)).toEqual([
|
||||
{ registrationId: foreign, deviceId: 'device-2', platform: 'android', dead: false }
|
||||
])
|
||||
expect(await devices.findOwned(OWNER, [])).toEqual(new Map())
|
||||
})
|
||||
|
||||
it('counts the cap per host, not across the whole table', async () => {
|
||||
for (let index = 0; index < PUSH_LIMITS.maxDevicesPerHost; index++) {
|
||||
await upsertOk(androidDevice(`device-${index}`))
|
||||
}
|
||||
expect((await devices.upsert(androidDevice('extra'))).ok).toBe(false)
|
||||
expect(
|
||||
(await devices.upsert({ ...androidDevice('device-0'), hostFingerprint: OTHER })).ok
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,3 @@
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import {
|
||||
answerPushHostChallenge,
|
||||
@@ -27,21 +26,6 @@ describe('push host challenge store', () => {
|
||||
await database.close()
|
||||
})
|
||||
|
||||
it('rejects a challenge the moment its own ttl elapses', async () => {
|
||||
const host = createPushHostKeypair(4)
|
||||
const challenge = await store.issue(hostPublicKeyB64(host))
|
||||
const proof = answerPushHostChallenge(challenge!, {
|
||||
gatewayOrigin: GATEWAY_ORIGIN,
|
||||
keypair: host,
|
||||
now: () => clock
|
||||
})!
|
||||
clock += PUSH_LIMITS.challengeTtlMs + 1
|
||||
await expect(store.verify(challenge!.challengeId, proof)).resolves.toEqual({
|
||||
ok: false,
|
||||
reason: 'expired'
|
||||
})
|
||||
})
|
||||
|
||||
it('refuses a wrong host: the box will not open and a foreign proof will not match', async () => {
|
||||
const owner = createPushHostKeypair(6)
|
||||
const intruder = createPushHostKeypair(7)
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { PushHostSessionStore } from './host-session-store.js'
|
||||
import { openInMemoryPushDatabase } from '../database/push-database.js'
|
||||
import type { CloudDatabase as PushDatabase } from '@orca-cloud/cloud-database/cloud-database'
|
||||
|
||||
const HOST = 'abcdefghijklmnop'
|
||||
|
||||
describe('push host session store', () => {
|
||||
let database: PushDatabase
|
||||
let clock = 1_700_000_000_000
|
||||
let sessions: PushHostSessionStore
|
||||
|
||||
beforeEach(async () => {
|
||||
database = await openInMemoryPushDatabase()
|
||||
clock = 1_700_000_000_000
|
||||
sessions = new PushHostSessionStore(database, () => clock)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await database.close()
|
||||
})
|
||||
|
||||
it('reports expiry separately from an unknown token', async () => {
|
||||
const session = await sessions.create(HOST)
|
||||
clock += PUSH_LIMITS.sessionTtlMs + 1
|
||||
await expect(sessions.resolve(session.sessionToken)).resolves.toEqual({
|
||||
ok: false,
|
||||
reason: 'session_expired'
|
||||
})
|
||||
await expect(sessions.resolve('not-a-session')).resolves.toEqual({
|
||||
ok: false,
|
||||
reason: 'unknown_session'
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps one live session per host and prunes it once expired', async () => {
|
||||
const first = await sessions.create(HOST)
|
||||
const second = await sessions.create(HOST)
|
||||
// The earlier session is gone the moment its host proves again, so a flood
|
||||
// of proofs leaves one row per host rather than one per proof.
|
||||
await expect(sessions.resolve(first.sessionToken)).resolves.toEqual({
|
||||
ok: false,
|
||||
reason: 'unknown_session'
|
||||
})
|
||||
await expect(sessions.resolve(second.sessionToken)).resolves.toMatchObject({ ok: true })
|
||||
const other = await sessions.create('ponmlkjihgfedcba')
|
||||
await expect(sessions.resolve(second.sessionToken)).resolves.toMatchObject({ ok: true })
|
||||
clock += PUSH_LIMITS.sessionTtlMs + 1
|
||||
expect(await sessions.pruneExpired()).toBe(2)
|
||||
await expect(sessions.resolve(other.sessionToken)).resolves.toMatchObject({ ok: false })
|
||||
})
|
||||
})
|
||||
@@ -1,81 +0,0 @@
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { Hono } from 'hono'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { ClientIpRateLimiter, clientIpRateLimit } from './client-ip-rate-limit.js'
|
||||
|
||||
const CAPACITY = PUSH_LIMITS.unauthenticatedRequestsPerMinutePerIp
|
||||
|
||||
function limiterApp(limiter: ClientIpRateLimiter, trustedProxyHops = 0): Hono {
|
||||
const app = new Hono()
|
||||
app.post('/probe', clientIpRateLimit(limiter, { trustedProxyHops }), (context) =>
|
||||
context.json({ ok: true })
|
||||
)
|
||||
return app
|
||||
}
|
||||
|
||||
describe('client ip rate limiter', () => {
|
||||
it('buckets on the last forwarded hop, the only one the platform appended', async () => {
|
||||
const app = limiterApp(new ClientIpRateLimiter({ now: () => 1_000 }))
|
||||
for (let index = 0; index < CAPACITY; index++) {
|
||||
await app.request('/probe', {
|
||||
method: 'POST',
|
||||
headers: { 'x-forwarded-for': `10.0.0.${index}, 203.0.113.7` }
|
||||
})
|
||||
}
|
||||
const sameClient = await app.request('/probe', {
|
||||
method: 'POST',
|
||||
headers: { 'x-forwarded-for': '10.9.9.9, 203.0.113.7' }
|
||||
})
|
||||
expect(sameClient.status).toBe(429)
|
||||
const otherClient = await app.request('/probe', {
|
||||
method: 'POST',
|
||||
headers: { 'x-forwarded-for': '10.0.0.1, 198.51.100.9' }
|
||||
})
|
||||
expect(otherClient.status).toBe(200)
|
||||
})
|
||||
|
||||
it('skips the configured trusted proxies when counting from the right', async () => {
|
||||
const app = limiterApp(new ClientIpRateLimiter({ now: () => 1_000, capacity: 1 }), 1)
|
||||
// <client>, <cloud run>, <load balancer>: one trusted hop after the client.
|
||||
const headers = { 'x-forwarded-for': '203.0.113.7, 10.0.0.1' }
|
||||
expect((await app.request('/probe', { method: 'POST', headers })).status).toBe(200)
|
||||
expect((await app.request('/probe', { method: 'POST', headers })).status).toBe(429)
|
||||
expect(
|
||||
(
|
||||
await app.request('/probe', {
|
||||
method: 'POST',
|
||||
headers: { 'x-forwarded-for': '198.51.100.9, 10.0.0.1' }
|
||||
})
|
||||
).status
|
||||
).toBe(200)
|
||||
})
|
||||
|
||||
it('trusts nothing when the header is shorter than the configured depth', async () => {
|
||||
const app = limiterApp(new ClientIpRateLimiter({ now: () => 1_000, capacity: 1 }), 1)
|
||||
// Only one hop, so the client value the depth points at does not exist.
|
||||
const headers = { 'x-forwarded-for': '203.0.113.7' }
|
||||
expect((await app.request('/probe', { method: 'POST', headers })).status).toBe(200)
|
||||
expect(
|
||||
(
|
||||
await app.request('/probe', {
|
||||
method: 'POST',
|
||||
headers: { 'x-forwarded-for': '198.51.100.9' }
|
||||
})
|
||||
).status
|
||||
).toBe(429)
|
||||
})
|
||||
|
||||
it('ignores spoofable x-real-ip and uses a single shared bucket', async () => {
|
||||
const app = limiterApp(new ClientIpRateLimiter({ now: () => 1_000, capacity: 1 }))
|
||||
expect(
|
||||
(await app.request('/probe', { method: 'POST', headers: { 'x-real-ip': '198.51.100.9' } }))
|
||||
.status
|
||||
).toBe(200)
|
||||
expect(
|
||||
(await app.request('/probe', { method: 'POST', headers: { 'x-real-ip': '203.0.113.7' } }))
|
||||
.status
|
||||
).toBe(429)
|
||||
expect((await app.request('/probe', { method: 'POST' })).status).toBe(429)
|
||||
expect((await app.request('/probe', { method: 'POST' })).status).toBe(429)
|
||||
})
|
||||
})
|
||||
@@ -1,9 +1,6 @@
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { createPushHostKeypair } from '../host-auth/host-challenge-answering.test-fixture.js'
|
||||
import type { CloudDatabase as PushDatabase } from '@orca-cloud/cloud-database/cloud-database'
|
||||
import { createPushServer } from '../push-server.js'
|
||||
import { createPushServerHarness, testPushConfig } from './push-server-harness.test-fixture.js'
|
||||
import { createPushServerHarness } from './push-server-harness.test-fixture.js'
|
||||
|
||||
describe('push gateway authentication and device routes', () => {
|
||||
let harness: Awaited<ReturnType<typeof createPushServerHarness>>
|
||||
@@ -16,63 +13,6 @@ describe('push gateway authentication and device routes', () => {
|
||||
await harness.close()
|
||||
})
|
||||
|
||||
it('reports not ready when the database is unreachable', async () => {
|
||||
const unreachable: PushDatabase = {
|
||||
dialect: 'sqlite',
|
||||
query: async () => {
|
||||
throw new Error('no connection')
|
||||
},
|
||||
transaction: async (operation) => await operation(unreachable),
|
||||
lockQuotaScope: async () => undefined,
|
||||
tryLockScope: async () => true,
|
||||
tryLockSharedScope: async () => true,
|
||||
close: async () => undefined
|
||||
}
|
||||
const broken = createPushServer(testPushConfig(), unreachable, {
|
||||
fcmAccessToken: async () => 'token',
|
||||
fcmTransport: async () => ({ status: 200, body: '{}' })
|
||||
})
|
||||
expect((await broken.app.request('/health')).status).toBe(200)
|
||||
expect((await broken.app.request('/ready')).status).toBe(503)
|
||||
await broken.worker.stop()
|
||||
})
|
||||
|
||||
it('completes challenge, session, register, list, delete', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(11))
|
||||
const registrationId = await harness.registerAndroid(sessionToken)
|
||||
|
||||
const list = await harness.authorized('/v1/devices', {}, sessionToken)
|
||||
expect(await list.json()).toEqual({
|
||||
devices: [{ registrationId, deviceId: 'device-1', platform: 'android', dead: false }]
|
||||
})
|
||||
|
||||
const deleted = await harness.authorized(
|
||||
`/v1/devices/${registrationId}`,
|
||||
{ method: 'DELETE' },
|
||||
sessionToken
|
||||
)
|
||||
expect(deleted.status).toBe(204)
|
||||
expect(await harness.server.devices.findById(registrationId)).toBeNull()
|
||||
})
|
||||
|
||||
it('refuses a request with no bearer, a bogus bearer, and an expired session', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(12))
|
||||
expect((await harness.server.app.request('/v1/devices')).status).toBe(401)
|
||||
const bogus = await harness.authorized('/v1/devices', {}, 'nonsense')
|
||||
expect(bogus.status).toBe(401)
|
||||
expect(await bogus.json()).toEqual({ error: 'invalid_token' })
|
||||
|
||||
harness.advanceClock(PUSH_LIMITS.sessionTtlMs + 1)
|
||||
const expired = await harness.authorized('/v1/devices', {}, sessionToken)
|
||||
expect(expired.status).toBe(401)
|
||||
expect(await expired.json()).toEqual({ error: 'session_expired' })
|
||||
})
|
||||
|
||||
it('never returns the host fingerprint on the challenge itself', async () => {
|
||||
const challenge = await harness.issueChallenge(createPushHostKeypair(22))
|
||||
expect(challenge).not.toHaveProperty('hostFingerprint')
|
||||
})
|
||||
|
||||
it('lets only the owning host delete a registration', async () => {
|
||||
const ownerToken = await harness.signIn(createPushHostKeypair(14))
|
||||
const intruderToken = await harness.signIn(createPushHostKeypair(15))
|
||||
@@ -87,34 +27,4 @@ describe('push gateway authentication and device routes', () => {
|
||||
expect(await forbidden.json()).toEqual({ error: 'not_found' })
|
||||
expect(await harness.server.devices.findById(registrationId)).not.toBeNull()
|
||||
})
|
||||
|
||||
it('replaces the token on a re-registration and keeps one registration id', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(23))
|
||||
const first = await harness.registerAndroid(sessionToken)
|
||||
const again = await harness.post(
|
||||
'/v1/devices',
|
||||
{
|
||||
v: 1,
|
||||
deviceId: 'device-1',
|
||||
platform: 'android',
|
||||
token: 'rotated_token:APA91b-newnewnewnewnewnewnewnewnewnew'
|
||||
},
|
||||
sessionToken
|
||||
)
|
||||
expect(await again.json()).toEqual({ registrationId: first })
|
||||
expect(await harness.server.devices.findById(first)).toMatchObject({
|
||||
token: 'rotated_token:APA91b-newnewnewnewnewnewnewnewnewnew'
|
||||
})
|
||||
})
|
||||
|
||||
it('rejects a malformed registration body', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(16))
|
||||
const bad = await harness.post(
|
||||
'/v1/devices',
|
||||
{ v: 1, deviceId: 'device-1', platform: 'ios', token: 'not-hex' },
|
||||
sessionToken
|
||||
)
|
||||
expect(bad.status).toBe(400)
|
||||
expect(await bad.json()).toEqual({ error: 'invalid_request' })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import {
|
||||
createPushHostKeypair,
|
||||
hostPublicKeyB64
|
||||
} from '../host-auth/host-challenge-answering.test-fixture.js'
|
||||
import { createPushServerHarness, notification } from './push-server-harness.test-fixture.js'
|
||||
import { createPushServerHarness } from './push-server-harness.test-fixture.js'
|
||||
|
||||
const CLIENT_IP = '203.0.113.7'
|
||||
const OTHER_CLIENT_IP = '198.51.100.9'
|
||||
@@ -48,42 +48,6 @@ describe('push gateway request limits', () => {
|
||||
expect(await response.json()).toEqual({ error: 'request_too_large' })
|
||||
})
|
||||
|
||||
it('still refuses an oversized body that declares a content length', async () => {
|
||||
const body = oversizedChallengeBody()
|
||||
const response = await harness.server.app.request('/v1/host/challenge', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
'content-length': String(Buffer.byteLength(body))
|
||||
},
|
||||
body
|
||||
})
|
||||
expect(response.status).toBe(413)
|
||||
expect(await response.json()).toEqual({ error: 'request_too_large' })
|
||||
})
|
||||
|
||||
it('caps an authenticated oversized send as well', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(61))
|
||||
const response = await harness.server.app.request(
|
||||
new Request('http://push.test/v1/send', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
authorization: `Bearer ${sessionToken}`
|
||||
},
|
||||
body: new ReadableStream<Uint8Array>({
|
||||
start(controller) {
|
||||
controller.enqueue(new TextEncoder().encode(oversizedChallengeBody()))
|
||||
controller.close()
|
||||
}
|
||||
}),
|
||||
duplex: 'half'
|
||||
} as RequestInit)
|
||||
)
|
||||
expect(response.status).toBe(413)
|
||||
expect(await response.json()).toEqual({ error: 'request_too_large' })
|
||||
})
|
||||
|
||||
it('rate limits one client ip across both unauthenticated routes', async () => {
|
||||
const body = JSON.stringify({
|
||||
v: 1,
|
||||
@@ -135,27 +99,6 @@ describe('push gateway request limits', () => {
|
||||
expect(spoofed.status).toBe(429)
|
||||
})
|
||||
|
||||
it('lets a throttled client back in once the window refills', async () => {
|
||||
const body = JSON.stringify({
|
||||
v: 1,
|
||||
hostPublicKeyB64: hostPublicKeyB64(createPushHostKeypair(63))
|
||||
})
|
||||
const headers = { 'content-type': 'application/json', 'x-forwarded-for': CLIENT_IP }
|
||||
for (let index = 0; index < PUSH_LIMITS.unauthenticatedRequestsPerMinutePerIp; index++) {
|
||||
await harness.server.app.request('/v1/host/challenge', { method: 'POST', headers, body })
|
||||
}
|
||||
expect(
|
||||
(await harness.server.app.request('/v1/host/challenge', { method: 'POST', headers, body }))
|
||||
.status
|
||||
).toBe(429)
|
||||
|
||||
harness.advanceClock(60_000)
|
||||
expect(
|
||||
(await harness.server.app.request('/v1/host/challenge', { method: 'POST', headers, body }))
|
||||
.status
|
||||
).toBe(200)
|
||||
})
|
||||
|
||||
it('limits authenticated hosts independently behind the same IP', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(64))
|
||||
const headers = { 'x-forwarded-for': CLIENT_IP }
|
||||
@@ -175,43 +118,4 @@ describe('push gateway request limits', () => {
|
||||
})
|
||||
expect(challenge.status).toBe(200)
|
||||
})
|
||||
|
||||
// Why: a database error carries the failing row in its message. The response
|
||||
// and the log must both stop at the error's name.
|
||||
it('answers an unexpected route failure with a bare 500 and logs only the name', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(66))
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
|
||||
try {
|
||||
await harness.database.close()
|
||||
const response = await harness.authorized('/v1/devices', {}, sessionToken)
|
||||
expect(response.status).toBe(500)
|
||||
expect(await response.json()).toEqual({ error: 'internal' })
|
||||
const logged = warn.mock.calls.map((call) => String(call[0])).join('\n')
|
||||
expect(logged).toContain('"event":"orca_push_request_failed"')
|
||||
expect(logged).not.toContain('SELECT')
|
||||
expect(logged).not.toContain('push_devices')
|
||||
expect(harness.server.observability.consume().request_error).toBe(1)
|
||||
} finally {
|
||||
warn.mockRestore()
|
||||
}
|
||||
})
|
||||
|
||||
it('charges a repeated registration id once and returns one result', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(65))
|
||||
const registrationId = await harness.registerAndroid(sessionToken)
|
||||
|
||||
const response = await harness.post(
|
||||
'/v1/send',
|
||||
{
|
||||
v: 1,
|
||||
registrationIds: [registrationId, registrationId, registrationId],
|
||||
notification: notification()
|
||||
},
|
||||
sessionToken
|
||||
)
|
||||
expect(await response.json()).toEqual({ results: [{ registrationId, status: 'queued' }] })
|
||||
expect(await harness.server.deliveryStore.pendingCount(registrationId)).toBe(1)
|
||||
const [row] = await harness.database.query('SELECT COUNT(*) AS sends FROM push_events')
|
||||
expect(Number(row?.sends)).toBe(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { PushNotificationSchema } from '@orca-cloud/push-contract/send-messages'
|
||||
import { PUSH_LIMITS } from '@orca-cloud/push-contract/push-limits'
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { createPushHostKeypair } from '../host-auth/host-challenge-answering.test-fixture.js'
|
||||
import {
|
||||
APNS_TOKEN,
|
||||
createPushServerHarness,
|
||||
FCM_TOKEN,
|
||||
notification
|
||||
@@ -20,24 +17,6 @@ describe('push gateway send route', () => {
|
||||
await harness.close()
|
||||
})
|
||||
|
||||
it('rejects a batch over the registration cap', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(16))
|
||||
const oversized = await harness.post(
|
||||
'/v1/send',
|
||||
{
|
||||
v: 1,
|
||||
registrationIds: Array.from(
|
||||
{ length: PUSH_LIMITS.maxRegistrationIdsPerSend + 1 },
|
||||
(_, index) => `reg-${index}`
|
||||
),
|
||||
notification: notification()
|
||||
},
|
||||
sessionToken
|
||||
)
|
||||
expect(oversized.status).toBe(400)
|
||||
expect(await oversized.json()).toEqual({ error: 'invalid_request' })
|
||||
})
|
||||
|
||||
it('queues a send, delivers it to fcm, and reports a dead token on the next send', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(17))
|
||||
const registrationId = await harness.registerAndroid(sessionToken)
|
||||
@@ -75,101 +54,6 @@ describe('push gateway send route', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('leaves a live registration alone when the provider reports a transient failure', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(24))
|
||||
const registrationId = await harness.registerAndroid(sessionToken)
|
||||
await harness.post(
|
||||
'/v1/send',
|
||||
{ v: 1, registrationIds: [registrationId], notification: notification() },
|
||||
sessionToken
|
||||
)
|
||||
harness.setFcmResponse({
|
||||
status: 503,
|
||||
body: JSON.stringify({ error: { status: 'UNAVAILABLE', message: 'backend busy' } })
|
||||
})
|
||||
await harness.flushDeliveries()
|
||||
expect(await harness.server.devices.findById(registrationId)).toMatchObject({ dead: false })
|
||||
})
|
||||
|
||||
it('reports retries from the durable worker after the provider delay', async () => {
|
||||
const token = await harness.signIn(createPushHostKeypair(26))
|
||||
const registrationId = await harness.registerAndroid(token)
|
||||
await harness.post(
|
||||
'/v1/send',
|
||||
{
|
||||
v: 1,
|
||||
registrationIds: [registrationId],
|
||||
notification: notification()
|
||||
},
|
||||
token
|
||||
)
|
||||
harness.setFcmResponse({ status: 503, body: '{}' })
|
||||
await harness.flushDeliveries()
|
||||
expect(harness.server.observability.consume()).toMatchObject({
|
||||
delivery_error: 1,
|
||||
delivery_retry: 0
|
||||
})
|
||||
harness.advanceClock(10_000)
|
||||
harness.setFcmResponse({ status: 200, body: '{}' })
|
||||
await harness.server.worker.runDue()
|
||||
expect(harness.server.observability.consume()).toMatchObject({
|
||||
delivery_sent: 1,
|
||||
delivery_retry: 1
|
||||
})
|
||||
})
|
||||
|
||||
it('sends a burst as individual APNs alerts grouped by the host thread', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(18))
|
||||
const registration = await harness.post(
|
||||
'/v1/devices',
|
||||
{
|
||||
v: 1,
|
||||
deviceId: 'iphone-1',
|
||||
platform: 'ios',
|
||||
token: APNS_TOKEN,
|
||||
apnsEnvironment: 'sandbox'
|
||||
},
|
||||
sessionToken
|
||||
)
|
||||
const { registrationId } = (await registration.json()) as { registrationId: string }
|
||||
for (const seq of [1, 2, 3]) {
|
||||
await harness.post(
|
||||
'/v1/send',
|
||||
{
|
||||
v: 1,
|
||||
registrationIds: [registrationId],
|
||||
notification: notification({ notificationId: `note-${seq}`, notificationSeq: seq })
|
||||
},
|
||||
sessionToken
|
||||
)
|
||||
}
|
||||
await harness.flushDeliveries()
|
||||
expect(harness.apnsRequests).toHaveLength(3)
|
||||
const bodies = harness.apnsRequests.map(
|
||||
(request) =>
|
||||
JSON.parse(request.body) as {
|
||||
aps: { alert: { title: string; body: string }; 'thread-id': string }
|
||||
orca: Record<string, unknown> & { notificationSeq: number }
|
||||
}
|
||||
)
|
||||
expect(
|
||||
harness.apnsRequests.every((request) => request.host === 'api.sandbox.push.apple.com')
|
||||
).toBe(true)
|
||||
expect(bodies.map((body) => body.aps.alert)).toEqual(
|
||||
Array.from({ length: 3 }, () => ({
|
||||
title: 'Agent needs input',
|
||||
body: 'Waiting on your answer'
|
||||
}))
|
||||
)
|
||||
expect(new Set(bodies.map((body) => body.aps['thread-id'])).size).toBe(1)
|
||||
expect(bodies.map((body) => body.orca.notificationSeq).sort((a, b) => a - b)).toEqual([1, 2, 3])
|
||||
expect(bodies.every((body) => !('coalescedCount' in body.orca))).toBe(true)
|
||||
expect(bodies.every((body) => !('summaryMembers' in body.orca))).toBe(true)
|
||||
expect(
|
||||
new Set(harness.apnsRequests.map((request) => request.headers['apns-collapse-id'])).size
|
||||
).toBe(3)
|
||||
})
|
||||
|
||||
it('reports an error for a registration the host does not own', async () => {
|
||||
const ownerToken = await harness.signIn(createPushHostKeypair(19))
|
||||
const intruderToken = await harness.signIn(createPushHostKeypair(20))
|
||||
@@ -188,29 +72,4 @@ describe('push gateway send route', () => {
|
||||
})
|
||||
expect(await harness.server.deliveryStore.pendingCount(registrationId)).toBe(0)
|
||||
})
|
||||
|
||||
it('rate limits a host that exhausted its 15-minute allowance', async () => {
|
||||
const sessionToken = await harness.signIn(createPushHostKeypair(21))
|
||||
const registrationId = await harness.registerAndroid(sessionToken)
|
||||
const hostFingerprint = (await harness.server.devices.findById(registrationId))!.hostFingerprint
|
||||
for (let index = 0; index < PUSH_LIMITS.hostEventsPerWindow; index++) {
|
||||
expect(
|
||||
await harness.server.deliveryStore.accept(
|
||||
hostFingerprint,
|
||||
registrationId,
|
||||
PushNotificationSchema.parse(
|
||||
notification({ notificationId: `note-${index + 1000}`, notificationSeq: index + 1000 })
|
||||
)
|
||||
)
|
||||
).toBe('queued')
|
||||
}
|
||||
const limited = await harness.post(
|
||||
'/v1/send',
|
||||
{ v: 1, registrationIds: [registrationId], notification: notification() },
|
||||
sessionToken
|
||||
)
|
||||
expect(limited.status).toBe(200)
|
||||
expect(await limited.json()).toEqual({ results: [{ registrationId, status: 'rate_limited' }] })
|
||||
expect(await harness.server.deliveryStore.pendingCount(registrationId)).toBe(300)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
import { startPushBackground } from '../push-background.js'
|
||||
import { createPushHostKeypair } from '../host-auth/host-challenge-answering.test-fixture.js'
|
||||
import { createPushServerHarness, notification } from './push-server-harness.test-fixture.js'
|
||||
|
||||
const cleanups: (() => Promise<void>)[] = []
|
||||
afterEach(async () => {
|
||||
for (const cleanup of cleanups.splice(0)) {
|
||||
await cleanup()
|
||||
}
|
||||
vi.useRealTimers()
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
async function fixture() {
|
||||
const h = await createPushServerHarness()
|
||||
const token = await h.signIn(createPushHostKeypair(31))
|
||||
const registrationId = await h.registerAndroid(token)
|
||||
let stop = async () => {}
|
||||
cleanups.push(async () => {
|
||||
await stop()
|
||||
await h.close()
|
||||
})
|
||||
vi.useFakeTimers()
|
||||
return {
|
||||
...h,
|
||||
registrationId,
|
||||
start: () => {
|
||||
stop = startPushBackground({ mode: 'active' }, h.server)
|
||||
},
|
||||
send: (event = notification(), ids = [registrationId]) =>
|
||||
h.post('/v1/send', { v: 1, registrationIds: ids, notification: event }, token),
|
||||
invalid: () => h.post('/v1/send', { v: 1 }, token)
|
||||
}
|
||||
}
|
||||
|
||||
it('keeps concurrent accepted retries idempotent while automatic delivery runs', async () => {
|
||||
const h = await fixture()
|
||||
h.start()
|
||||
await Promise.all(Array.from({ length: 10 }, () => h.send()))
|
||||
await vi.waitFor(() => expect(h.fcmRequests).toHaveLength(1))
|
||||
await h.send()
|
||||
await h.server.worker.runDue()
|
||||
expect(h.fcmRequests).toHaveLength(1)
|
||||
expect(await h.server.deliveryStore.pendingCount(h.registrationId)).toBe(0)
|
||||
})
|
||||
@@ -1,6 +1,4 @@
|
||||
import pg from 'pg'
|
||||
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
|
||||
import { ASSIGNMENT_CONNECTION_HEADROOM_QUERY } from './assignment-connection-headroom-query.js'
|
||||
import { RelayAssignmentStore } from './assignment-store.js'
|
||||
import {
|
||||
openRelayDatabase,
|
||||
@@ -9,7 +7,6 @@ import {
|
||||
|
||||
const databaseUrl = process.env.ORCA_RELAY_TEST_POSTGRES_URL
|
||||
const describePostgres = databaseUrl ? describe : describe.skip
|
||||
const headroomIndexName = 'relay_control_connection_reservation_headroom'
|
||||
const cell = {
|
||||
id: 'connection-headroom-postgres',
|
||||
url: 'https://connection-headroom-postgres.example.com',
|
||||
@@ -160,39 +157,6 @@ describePostgres('PostgreSQL assignment connection headroom', () => {
|
||||
expect(Number(reservations[0]!.count)).toBe(1)
|
||||
}, 15_000)
|
||||
|
||||
it('uses the composite headroom index when released history dominates', async () => {
|
||||
await databases[0]!.query(
|
||||
`INSERT INTO relay_control_connection_reservations
|
||||
(reservation_id, idempotency_key, user_id, relay_host_id,
|
||||
assignment_epoch, cell_id, state, created_at, timeout_at, updated_at)
|
||||
SELECT 'headroom-plan-' || value, 'headroom-plan-' || value,
|
||||
'connection-headroom-postgres-plan', 'plan-host-' || value,
|
||||
1, ?, 'released', 1, 2, 1
|
||||
FROM generate_series(1, 50000) AS value`,
|
||||
[cell.id]
|
||||
)
|
||||
await databases[0]!.query(`ANALYZE relay_control_connection_reservations`)
|
||||
|
||||
const client = new pg.Client({ connectionString: databaseUrl })
|
||||
await client.connect()
|
||||
let reservationIndexPlan: Record<string, unknown> | undefined
|
||||
try {
|
||||
const plan = await client.query(
|
||||
`EXPLAIN (FORMAT JSON) ${ASSIGNMENT_CONNECTION_HEADROOM_QUERY}`
|
||||
)
|
||||
reservationIndexPlan = findReservationHeadroomIndexPlan(
|
||||
plan.rows[0]?.['QUERY PLAN']
|
||||
)
|
||||
} finally {
|
||||
await client.end()
|
||||
}
|
||||
|
||||
expect(reservationIndexPlan).toBeDefined()
|
||||
expect(String(reservationIndexPlan?.['Index Cond'])).toContain('cell_id')
|
||||
expect(String(reservationIndexPlan?.['Index Cond'])).toContain('state = ANY')
|
||||
expect(reservationIndexPlan?.['Filter']).toBeUndefined()
|
||||
})
|
||||
|
||||
it('deduplicates expired debt after a fresh PostgreSQL snapshot', async () => {
|
||||
const now = 200
|
||||
const store = new RelayAssignmentStore(databases[0]!, () => now, {
|
||||
@@ -337,16 +301,3 @@ describePostgres('PostgreSQL assignment connection headroom', () => {
|
||||
).toEqual([{ state: 'released' }])
|
||||
})
|
||||
})
|
||||
|
||||
function findReservationHeadroomIndexPlan(
|
||||
value: unknown
|
||||
): Record<string, unknown> | undefined {
|
||||
if (value === null || typeof value !== 'object') return undefined
|
||||
const record = value as Record<string, unknown>
|
||||
if (!Array.isArray(value) && record['Index Name'] === headroomIndexName) return record
|
||||
for (const child of Object.values(value)) {
|
||||
const match = findReservationHeadroomIndexPlan(child)
|
||||
if (match) return match
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
@@ -157,14 +157,6 @@ describePostgres('a host leaving a dead reserve cell, on PostgreSQL', () => {
|
||||
expect(await reservedOn(dead)).toEqual(reservedBefore)
|
||||
})
|
||||
|
||||
it('hard crash with no dead-man trip: a ledger-only row moves too', async () => {
|
||||
const host = nextHost()
|
||||
await ledgerRow(host, 7)
|
||||
await store.setCellAdmitMode(dead.id, 'reserve')
|
||||
await killDeadCell()
|
||||
expect(await hostAssign(host)).toMatchObject({ cellId: live.id, assignmentEpoch: 8 })
|
||||
})
|
||||
|
||||
it('a seat ahead of the row: the move mints above it, and the revived cell\'s seat never wins the row back', async () => {
|
||||
const host = nextHost()
|
||||
await ledgerRow(host, 4)
|
||||
|
||||
@@ -45,9 +45,9 @@ ignores:
|
||||
- '**/__fixtures__/**'
|
||||
- 'src/shared/agent-launch/startup/claude-chat-entrypoint.ts'
|
||||
- 'src/main/claude/claude-stream-json-connection.ts'
|
||||
- 'src/main/claude/claude-agent-sdk-process-spawn.ts'
|
||||
- 'src/main/claude/child-process/claude-agent-sdk-process-spawn.ts'
|
||||
- 'src/main/claude/structured/launch/claude-structured-child-env.ts'
|
||||
- 'src/main/claude/claude-model-catalog-probe.ts'
|
||||
- 'src/main/claude/model-catalog/claude-model-catalog-probe.ts'
|
||||
rule:
|
||||
all:
|
||||
- any:
|
||||
@@ -67,9 +67,9 @@ ignores:
|
||||
- '**/__fixtures__/**'
|
||||
- 'src/shared/agent-launch/startup/claude-chat-entrypoint.ts'
|
||||
- 'src/main/claude/claude-stream-json-connection.ts'
|
||||
- 'src/main/claude/claude-agent-sdk-process-spawn.ts'
|
||||
- 'src/main/claude/child-process/claude-agent-sdk-process-spawn.ts'
|
||||
- 'src/main/claude/structured/launch/claude-structured-child-env.ts'
|
||||
- 'src/main/claude/claude-model-catalog-probe.ts'
|
||||
- 'src/main/claude/model-catalog/claude-model-catalog-probe.ts'
|
||||
rule:
|
||||
all:
|
||||
- any:
|
||||
|
||||
@@ -16,7 +16,7 @@ export const MAIN_BUILD_ENTRY_POINTS: Record<string, string> = {
|
||||
),
|
||||
'computer-sidecar': resolve('src/main/computer/computer-sidecar.ts'),
|
||||
'claude-conversation-fork-worker-entry': resolve(
|
||||
'src/main/claude/claude-conversation-fork-worker-entry.ts'
|
||||
'src/main/claude/transcripts/claude-conversation-fork-worker-entry.ts'
|
||||
),
|
||||
'stt-worker': resolve('src/main/speech/stt-worker.ts'),
|
||||
'warp-theme-parser-worker': resolve('src/main/warp-themes/warp-theme-parser-worker.ts'),
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
4 test-no-in-test-import-actual:src/main/bitbucket/credential-store.test.ts
|
||||
1 test-no-in-test-import-actual:src/main/bitbucket/status-no-decrypt.test.ts
|
||||
3 test-no-in-test-import-actual:src/main/claude-usage/scanner-scan.test.ts
|
||||
1 test-no-in-test-import-actual:src/main/claude/claude-agent-sdk-process-spawn.test.ts
|
||||
5 test-no-in-test-import-actual:src/main/daemon/endpoint/publication/testing/daemon-endpoint-publish.test.ts
|
||||
1 test-no-in-test-import-actual:src/main/daemon/history/storage/testing/terminal-history-permissions.test.ts
|
||||
1 test-no-in-test-import-actual:src/main/git/command-runner/process-capture/spawned-command-tree-kill.test.ts
|
||||
@@ -28,14 +27,6 @@
|
||||
3 test-no-in-test-import-actual:src/renderer/src/components/terminal-pane/snapshots/remote-snapshot-alt-screen-host-chain.test.ts
|
||||
1 test-no-in-test-import-actual:src/renderer/src/hooks/useIpcEvents-agent-status-pane-teardown.test.ts
|
||||
1 test-no-polling-loop:src/main/browser/cookies/browser-cookie-import-concurrency.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/claude-stop-ack-race.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/claude-stream-json-connection.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/claude-supervised-stop-real-cli.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/claude-supervised-stop.integration.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/structured/claude-structured-real-cli-fold.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/structured/claude-structured-real-cli-stop-task.test.ts
|
||||
5 test-no-polling-loop:src/main/claude/structured/claude-structured-real-cli.test.ts
|
||||
1 test-no-polling-loop:src/main/claude/structured/launch/claude-structured-real-cli-options.test.ts
|
||||
1 test-no-polling-loop:src/main/codex/hooks/reconciliation/codex-hook-toggle-off-wins.test.ts
|
||||
1 test-no-polling-loop:src/main/codex/structured/launch/codex-structured-real-cli-command-env.test.ts
|
||||
1 test-no-polling-loop:src/main/daemon/providers/adapter/testing/daemon-self-retirement-respawn.test.ts
|
||||
@@ -151,16 +142,6 @@
|
||||
1 test-no-real-time-wait:src/main/browser/identity/wire-probes/browser-session-ua-wire-identity.electron.test.ts
|
||||
1 test-no-real-time-wait:src/main/browser/network/tunnels/execution-route-socket-duplex.test.ts
|
||||
1 test-no-real-time-wait:src/main/browser/network/tunnels/remote-browser-socks-server.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/claude-agent-sdk-exit-proof.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/claude-agent-sdk-user-message-queue.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/claude-stop-ack-race.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/claude-stream-json-connection.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/claude-supervised-stop-real-cli.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/claude-supervised-stop.integration.test.ts
|
||||
2 test-no-real-time-wait:src/main/claude/structured/claude-structured-real-cli-fold.test.ts
|
||||
2 test-no-real-time-wait:src/main/claude/structured/claude-structured-real-cli-stop-task.test.ts
|
||||
5 test-no-real-time-wait:src/main/claude/structured/claude-structured-real-cli.test.ts
|
||||
1 test-no-real-time-wait:src/main/claude/structured/launch/claude-structured-real-cli-options.test.ts
|
||||
1 test-no-real-time-wait:src/main/codex/hooks/reconciliation/codex-hook-reconcile.test.ts
|
||||
1 test-no-real-time-wait:src/main/codex/hooks/reconciliation/codex-hook-toggle-off-wins.test.ts
|
||||
1 test-no-real-time-wait:src/main/codex/structured/launch/codex-structured-real-cli-command-env.test.ts
|
||||
@@ -271,7 +252,6 @@
|
||||
1 test-no-real-time-wait:tests/e2e/codex-ctrl-c-status.spec.ts
|
||||
4 test-no-real-time-wait:tests/e2e/combined-diff-scroll-restore.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/computer-windows.e2e.ts
|
||||
3 test-no-real-time-wait:tests/e2e/cross-version-wire/host-model-catalog-released-phone.unit.test.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/released-relay-daemon.ts
|
||||
2 test-no-real-time-wait:tests/e2e/cross-version-wire/released-relay-transport.ts
|
||||
@@ -427,7 +407,7 @@
|
||||
2 test-no-wall-clock:src/main/agent-hooks/installation/scripts/managed-hook-timeout.test.ts
|
||||
1 test-no-wall-clock:src/main/agent-hooks/server/testing/http/server-endpoint-file-lifecycle.test.ts
|
||||
4 test-no-wall-clock:src/main/agent-hooks/server/testing/identity/server-launch-resume-identity.test.ts
|
||||
5 test-no-wall-clock:src/main/agent-hooks/server/testing/replay/spool.test.ts
|
||||
3 test-no-wall-clock:src/main/agent-hooks/server/testing/replay/spool.test.ts
|
||||
3 test-no-wall-clock:src/main/agent-hooks/server/testing/structured-ingress/server-ingest-structured-status.test.ts
|
||||
1 test-no-wall-clock:src/main/ai-vault/parse-cache/session-parse-cache-preview-upgrade.test.ts
|
||||
2 test-no-wall-clock:src/main/ai-vault/scanners/copilot/session-scanner-copilot-parser.test.ts
|
||||
@@ -440,16 +420,6 @@
|
||||
2 test-no-wall-clock:src/main/antigravity/posix-hook-invocation.test.ts
|
||||
2 test-no-wall-clock:src/main/browser/cookies/browser-cookie-import-partition-reland.electron.test.ts
|
||||
2 test-no-wall-clock:src/main/browser/network/execution-routes/wsl-browser-network-execution-route.test.ts
|
||||
1 test-no-wall-clock:src/main/claude/claude-background-wake-retention.test.ts
|
||||
1 test-no-wall-clock:src/main/claude/claude-descendant-escalation-boundary.test.ts
|
||||
1 test-no-wall-clock:src/main/claude/claude-folder-trust-file.test.ts
|
||||
5 test-no-wall-clock:src/main/claude/claude-supervised-stop-real-cli.test.ts
|
||||
6 test-no-wall-clock:src/main/claude/claude-supervised-stop.integration.test.ts
|
||||
4 test-no-wall-clock:src/main/claude/structured/claude-structured-real-cli-fold.test.ts
|
||||
1 test-no-wall-clock:src/main/claude/structured/claude-structured-real-cli-rewind.test.ts
|
||||
3 test-no-wall-clock:src/main/claude/structured/claude-structured-real-cli-stop-task.test.ts
|
||||
10 test-no-wall-clock:src/main/claude/structured/claude-structured-real-cli.test.ts
|
||||
3 test-no-wall-clock:src/main/claude/structured/launch/claude-structured-real-cli-options.test.ts
|
||||
1 test-no-wall-clock:src/main/codex-accounts/legacy-wsl-auth-drain/legacy-wsl-runtime-auth-drain-rollback-script.test.ts
|
||||
6 test-no-wall-clock:src/main/codex/app-server/codex-app-server-client.test.ts
|
||||
2 test-no-wall-clock:src/main/codex/structured/launch/codex-structured-real-cli-command-env.test.ts
|
||||
@@ -628,12 +598,7 @@
|
||||
1 test-timeout-needs-reason:src/main/browser/guest-lifecycle/find/browser-find-frame-traversal.electron.test.ts
|
||||
1 test-timeout-needs-reason:src/main/browser/identity/wire-probes/browser-session-ua-wire-identity-cross-context.electron.test.ts
|
||||
1 test-timeout-needs-reason:src/main/browser/identity/wire-probes/browser-session-ua-wire-identity.electron.test.ts
|
||||
1 test-timeout-needs-reason:src/main/claude/claude-agent-sdk-exit-proof.test.ts
|
||||
1 test-timeout-needs-reason:src/main/claude/claude-background-run-isolation-real-cli.test.ts
|
||||
2 test-timeout-needs-reason:src/main/claude/claude-status-line-windows.test.ts
|
||||
1 test-timeout-needs-reason:src/main/claude/claude-stop-ack-race.test.ts
|
||||
1 test-timeout-needs-reason:src/main/claude/structured/claude-structured-real-cli.test.ts
|
||||
1 test-timeout-needs-reason:src/main/claude/windows-native-hook-registration.test.ts
|
||||
1 test-timeout-needs-reason:src/main/claude/child-process/claude-agent-sdk-exit-proof.test.ts
|
||||
2 test-timeout-needs-reason:src/main/codex/app-server/codex-app-server-teardown.integration.test.ts
|
||||
1 test-timeout-needs-reason:src/main/codex/hooks/installation/hook-service-legacy-cleanup.test.ts
|
||||
1 test-timeout-needs-reason:src/main/codex/structured/catalog/codex-model-catalog-probe.test.ts
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"src/main/plugins/panels/plugin-source-transpile-worker-entry.ts": "Dedicated worker-thread entry; blocking work stays off Electron main.",
|
||||
"src/main/claude/claude-conversation-fork-worker-entry.ts": "Dedicated worker-thread entry; blocking work stays off Electron main.",
|
||||
"src/main/claude/transcripts/claude-conversation-fork-worker-entry.ts": "Dedicated worker-thread entry; blocking work stays off Electron main.",
|
||||
"src/main/speech/stt-worker.ts": "Dedicated utility/forked-process entry; speech work stays off Electron main.",
|
||||
"src/main/warp-themes/warp-theme-parser-worker.ts": "Dedicated worker-thread entry; blocking work stays off Electron main.",
|
||||
"src/main/ai-vault-search/worker/session-search-worker-entry.ts": "Dedicated worker-thread entry; blocking work stays off Electron main.",
|
||||
|
||||
@@ -89,14 +89,14 @@
|
||||
1 src/main/claude-accounts/runtime-auth/runtime-paths.ts
|
||||
7 src/main/claude-accounts/sign-in/claude-account-folder.ts
|
||||
3 src/main/claude/agent-view/agent-view-install.ts
|
||||
1 src/main/claude/claude-diff-panel-auto-open.ts
|
||||
14 src/main/claude/claude-folder-trust-file.ts
|
||||
2 src/main/claude/claude-profile-hook-target.ts
|
||||
1 src/main/claude/claude-rejected-api-key.ts
|
||||
1 src/main/claude/claude-rewind-transcript.ts
|
||||
1 src/main/claude/configuration/claude-diff-panel-auto-open.ts
|
||||
14 src/main/claude/configuration/claude-folder-trust-file.ts
|
||||
2 src/main/claude/hooks/claude-profile-hook-target.ts
|
||||
1 src/main/claude/configuration/claude-rejected-api-key.ts
|
||||
1 src/main/claude/transcripts/claude-rewind-transcript.ts
|
||||
1 src/main/claude/hook-service.ts
|
||||
3 src/main/claude/statusline-install.ts
|
||||
6 src/main/claude/windows-hook-files.ts
|
||||
3 src/main/claude/hooks/statusline-install.ts
|
||||
6 src/main/claude/hooks/windows-hook-files.ts
|
||||
1 src/main/cli/appimage/appimage-copy-pre-extraction.ts
|
||||
3 src/main/cli/appimage/appimage-extracted-root.ts
|
||||
1 src/main/cli/appimage/appimage-extraction-pruning.ts
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -13,7 +13,6 @@
|
||||
1 src/main/ipc/source-control/github-work-item-args.ts
|
||||
1 src/main/ipc/source-control/gitlab-repo-access.ts
|
||||
2 src/main/ipc/workspace-cleanup/workspace-cleanup-candidate.ts
|
||||
1 src/main/ipc/workspace-cleanup/workspace-cleanup-disconnected-ssh.ts
|
||||
1 src/main/ipc/worktrees-test-metadata-pruning-store.ts
|
||||
1 src/main/ipc/worktrees/listing/authoritative-local-worktree-metadata-pruning.ts
|
||||
1 src/main/ipc/worktrees/listing/register-host-catalog-handlers.ts
|
||||
|
||||
@@ -306,7 +306,6 @@
|
||||
"src/cli/command-suggestion-destructive-families.test.ts": 226,
|
||||
"src/cli/command-suggestion.test.ts": 68,
|
||||
"src/cli/computer-tree-query.test.ts": 79,
|
||||
"src/cli/format-recovery.test.ts": 413,
|
||||
"src/cli/format.test.ts": 446,
|
||||
"src/cli/handlers/account.test.ts": 849,
|
||||
"src/cli/handlers/agent-hooks.test.ts": 1702,
|
||||
@@ -1024,7 +1023,6 @@
|
||||
"src/main/browser/routing/local-host-partitions/wsl-host-browser-route-partition.test.ts": 753,
|
||||
"src/main/claude-accounts/sign-in/claude-account-folder.test.ts": 153,
|
||||
"src/main/claude-accounts/claude-account-service.test.ts": 1207,
|
||||
"src/main/claude-accounts/sign-in/claude-command-process-windows-only.test.ts": 90,
|
||||
"src/main/claude-accounts/sign-in/claude-login-session.test.ts": 1048,
|
||||
"src/main/claude-accounts/sign-in/claude-pasted-code-login.test.ts": 238,
|
||||
"src/main/claude-accounts/profiles/setup/claude-profile-history-windows.test.ts": 121,
|
||||
@@ -1036,7 +1034,6 @@
|
||||
"src/main/claude-accounts/profiles/setup/claude-profile-setup.test.ts": 405,
|
||||
"src/main/claude-accounts/profiles/wsl/claude-profile-wsl-router.test.ts": 919,
|
||||
"src/main/claude-accounts/sign-in/claude-sign-in-browser.test.ts": 314,
|
||||
"src/main/claude-accounts/runtime-auth/claude-structured-auth-policy.test.ts": 52,
|
||||
"src/main/claude-accounts/runtime-auth/keychain-config-directory-aliases.test.ts": 51,
|
||||
"src/main/claude-accounts/selection/runtime-selection.test.ts": 41,
|
||||
"src/main/claude-accounts/sign-in/windows-command-invocation.test.ts": 48,
|
||||
@@ -1056,62 +1053,62 @@
|
||||
"src/main/claude/agent-view/agent-view-service.test.ts": 403,
|
||||
"src/main/claude/claude-agent-sdk-contract-pins.test.ts": 3506,
|
||||
"src/main/claude/claude-agent-sdk-exit-proof-identity.test.ts": 134,
|
||||
"src/main/claude/claude-agent-sdk-exit-proof.test.ts": 8832,
|
||||
"src/main/claude/claude-agent-sdk-import-boundary.test.ts": 546,
|
||||
"src/main/claude/claude-agent-sdk-process-spawn.test.ts": 182,
|
||||
"src/main/claude/claude-agent-sdk-user-message-queue.test.ts": 143,
|
||||
"src/main/claude/child-process/claude-agent-sdk-exit-proof.test.ts": 8832,
|
||||
"src/main/claude/sdk-transport/claude-agent-sdk-import-boundary.test.ts": 546,
|
||||
"src/main/claude/child-process/claude-agent-sdk-process-spawn.test.ts": 182,
|
||||
"src/main/claude/sdk-transport/claude-agent-sdk-user-message-queue.test.ts": 143,
|
||||
"src/main/claude/claude-api-retry-row.test.ts": 901,
|
||||
"src/main/claude/claude-background-run-isolation-real-cli.test.ts": 147,
|
||||
"src/main/claude/claude-background-stop-records.test.ts": 1249,
|
||||
"src/main/claude/claude-background-task-resume.test.ts": 54,
|
||||
"src/main/claude/claude-background-task-terminal-frames.test.ts": 103,
|
||||
"src/main/claude/background-tasks/claude-background-task-resume.test.ts": 54,
|
||||
"src/main/claude/background-tasks/claude-background-task-terminal-frames.test.ts": 103,
|
||||
"src/main/claude/claude-background-task-turn-resumption.test.ts": 325,
|
||||
"src/main/claude/claude-background-wake-retention.test.ts": 1652,
|
||||
"src/main/claude/claude-child-process-environment.test.ts": 52,
|
||||
"src/main/claude/claude-child-work-decoder.test.ts": 110,
|
||||
"src/main/claude/child-process/claude-child-process-environment.test.ts": 52,
|
||||
"src/main/claude/child-work/claude-child-work-decoder.test.ts": 110,
|
||||
"src/main/claude/claude-close-turn-end.test.ts": 970,
|
||||
"src/main/claude/claude-command-lifecycle-frames.test.ts": 268,
|
||||
"src/main/claude/claude-command-lifecycle.test.ts": 1107,
|
||||
"src/main/claude/claude-command-turn.test.ts": 292,
|
||||
"src/main/claude/claude-config-dir-pin.test.ts": 47,
|
||||
"src/main/claude/structured/turns/claude-command-lifecycle-frames.test.ts": 268,
|
||||
"src/main/claude/structured/turns/claude-command-lifecycle.test.ts": 1107,
|
||||
"src/main/claude/structured/turns/claude-command-turn.test.ts": 292,
|
||||
"src/main/claude/structured/launch/claude-config-dir-pin.test.ts": 47,
|
||||
"src/main/claude/claude-context-model-switch.test.ts": 422,
|
||||
"src/main/claude/claude-context-usage-restart.test.ts": 925,
|
||||
"src/main/claude/claude-context-usage-unloaded-turn.test.ts": 4910,
|
||||
"src/main/claude/claude-descendant-escalation-boundary.test.ts": 593,
|
||||
"src/main/claude/claude-diff-panel-auto-open.test.ts": 117,
|
||||
"src/main/claude/configuration/claude-diff-panel-auto-open.test.ts": 117,
|
||||
"src/main/claude/claude-fold-steer-receipt.test.ts": 1019,
|
||||
"src/main/claude/claude-folder-trust-file.test.ts": 762,
|
||||
"src/main/claude/claude-hook-event-versions.test.ts": 137,
|
||||
"src/main/claude/configuration/claude-folder-trust-file.test.ts": 762,
|
||||
"src/main/claude/cli-capabilities/claude-hook-event-versions.test.ts": 137,
|
||||
"src/main/claude/claude-informational-row.test.ts": 811,
|
||||
"src/main/claude/claude-journal-turn-scope.test.ts": 254,
|
||||
"src/main/claude/claude-model-catalog-probe.test.ts": 2098,
|
||||
"src/main/claude/structured/journal/claude-journal-turn-scope.test.ts": 254,
|
||||
"src/main/claude/model-catalog/claude-model-catalog-probe.test.ts": 2098,
|
||||
"src/main/claude/claude-naming-invocation.test.ts": 334,
|
||||
"src/main/claude/claude-plan-approval-mode.test.ts": 905,
|
||||
"src/main/claude/claude-profile-hooks.test.ts": 371,
|
||||
"src/main/claude/claude-provider-session-rename.test.ts": 597,
|
||||
"src/main/claude/claude-provisional-row-corrections.test.ts": 67,
|
||||
"src/main/claude/claude-request-end-wait.test.ts": 53,
|
||||
"src/main/claude/claude-rewind-transcript.test.ts": 762,
|
||||
"src/main/claude/hooks/claude-profile-hooks.test.ts": 371,
|
||||
"src/main/claude/transcripts/claude-provider-session-rename.test.ts": 597,
|
||||
"src/main/claude/subagents/claude-provisional-row-corrections.test.ts": 67,
|
||||
"src/main/claude/structured/turns/claude-request-end-wait.test.ts": 53,
|
||||
"src/main/claude/transcripts/claude-rewind-transcript.test.ts": 762,
|
||||
"src/main/claude/claude-settings-schema-install.test.ts": 410,
|
||||
"src/main/claude/claude-status-line-install.test.ts": 342,
|
||||
"src/main/claude/hooks/claude-status-line-install.test.ts": 342,
|
||||
"src/main/claude/claude-status-line-windows.test.ts": 273,
|
||||
"src/main/claude/claude-stop-ack-race.test.ts": 1301,
|
||||
"src/main/claude/claude-stream-json-connection-close.test.ts": 621,
|
||||
"src/main/claude/claude-stream-json-connection.test.ts": 8687,
|
||||
"src/main/claude/claude-streamed-text-checkpoints.test.ts": 59,
|
||||
"src/main/claude/sdk-transport/claude-stream-json-connection.test.ts": 8687,
|
||||
"src/main/claude/structured/journal/claude-streamed-text-checkpoints.test.ts": 59,
|
||||
"src/main/claude/claude-structured-launch-home-perf.test.ts": 401,
|
||||
"src/main/claude/claude-structured-result-control-overlap.test.ts": 1136,
|
||||
"src/main/claude/claude-subagent-id-aliases.test.ts": 46,
|
||||
"src/main/claude/subagents/claude-subagent-id-aliases.test.ts": 46,
|
||||
"src/main/claude/claude-subagent-permission-request.test.ts": 3776,
|
||||
"src/main/claude/claude-subagent-resume-after-restart.test.ts": 825,
|
||||
"src/main/claude/subagents/claude-subagent-resume-after-restart.test.ts": 825,
|
||||
"src/main/claude/claude-supervised-stop-real-cli.test.ts": 382,
|
||||
"src/main/claude/claude-supervised-stop.integration.test.ts": 3821,
|
||||
"src/main/claude/claude-transcript-catch-up.test.ts": 4017,
|
||||
"src/main/claude/transcripts/claude-transcript-catch-up.test.ts": 4017,
|
||||
"src/main/claude/claude-transcript-duration.test.ts": 1411,
|
||||
"src/main/claude/claude-transcript-entry-uuid.test.ts": 38,
|
||||
"src/main/claude/hook-service.test.ts": 329,
|
||||
"src/main/claude/post-compact-hook-command.test.ts": 314,
|
||||
"src/main/claude/statusline-script.test.ts": 257,
|
||||
"src/main/claude/transcripts/claude-transcript-entry-uuid.test.ts": 38,
|
||||
"src/main/claude/hooks/hook-service.test.ts": 329,
|
||||
"src/main/claude/hooks/post-compact-hook-command.test.ts": 314,
|
||||
"src/main/claude/hooks/statusline-script.test.ts": 257,
|
||||
"src/main/claude/structured/claude-structured-content-parts.test.ts": 277,
|
||||
"src/main/claude/structured/claude-structured-conversation-stop.test.ts": 884,
|
||||
"src/main/claude/structured/claude-structured-dispatch-admission.test.ts": 426,
|
||||
@@ -1153,7 +1150,7 @@
|
||||
"src/main/claude/structured/launch/claude-structured-options.test.ts": 420,
|
||||
"src/main/claude/structured/launch/claude-structured-provider-fallback.test.ts": 670,
|
||||
"src/main/claude/structured/launch/claude-structured-real-cli-options.test.ts": 902,
|
||||
"src/main/claude/windows-hook-files.test.ts": 356,
|
||||
"src/main/claude/hooks/windows-hook-files.test.ts": 356,
|
||||
"src/main/claude/windows-native-hook-registration.test.ts": 246,
|
||||
"src/main/cli/appimage/appimage-copy-pre-extraction.test.ts": 328,
|
||||
"src/main/cli/appimage/appimage-extraction-pruning-namespace.test.ts": 106,
|
||||
@@ -1193,7 +1190,6 @@
|
||||
"src/main/codex-accounts/legacy-wsl-auth-drain/legacy-wsl-runtime-auth-drain-apply-script.test.ts": 5936,
|
||||
"src/main/codex-accounts/legacy-wsl-auth-drain/legacy-wsl-runtime-auth-drain-rollback-script.test.ts": 558,
|
||||
"src/main/codex-accounts/credentials/managed-codex-auth-readiness.test.ts": 86,
|
||||
"src/main/codex-accounts/runtime-home/routing/runtime-home-catalog-probe-prep.test.ts": 583,
|
||||
"src/main/codex-accounts/runtime-home/legacy-host/runtime-home-legacy-migration.test.ts": 1147,
|
||||
"src/main/codex-accounts/runtime-home/credentials/runtime-home-managed-auth-recovery.test.ts": 658,
|
||||
"src/main/codex-accounts/runtime-home/credentials/runtime-home-mirror-login-copy.test.ts": 1012,
|
||||
@@ -1201,7 +1197,6 @@
|
||||
"src/main/codex-accounts/runtime-home/routing/runtime-home-real-home-lane-routing.test.ts": 879,
|
||||
"src/main/codex-accounts/runtime-home/credentials/runtime-home-retained-auth-provenance.test.ts": 1404,
|
||||
"src/main/codex-accounts/runtime-home/routing/runtime-home-service-per-account-migration.test.ts": 980,
|
||||
"src/main/codex-accounts/runtime-home/routing/runtime-home-session-discovery-read-only.test.ts": 543,
|
||||
"src/main/codex-accounts/runtime-home/routing/runtime-home-session-migration-pass.test.ts": 705,
|
||||
"src/main/codex-accounts/runtime-home/credentials/runtime-home-system-default-mirror-readback.test.ts": 1493,
|
||||
"src/main/codex-accounts/runtime-home/credentials/runtime-home-system-default-snapshot.test.ts": 1255,
|
||||
@@ -2175,7 +2170,6 @@
|
||||
"src/main/ipc/wsl/wsl-host-automation-wake-launch.test.ts": 939,
|
||||
"src/main/ipc/wsl/wsl-host-handlers-user-actions.test.ts": 772,
|
||||
"src/main/ipc/wsl/wsl-host-visible-work-windows.test.ts": 39,
|
||||
"src/main/ipc/wsl/wsl-move-driver-handlers.test.ts": 432,
|
||||
"src/main/ipc/wsl/wsl-move-handlers-setting-off.test.ts": 724,
|
||||
"src/main/ipc/wsl/wsl-move-host-connect.test.ts": 984,
|
||||
"src/main/ipc/wsl/wsl-move-partial-undo.test.ts": 939,
|
||||
@@ -4874,7 +4868,6 @@
|
||||
"src/renderer/src/components/plugins/page/PluginCommandReplacementRow.test.tsx": 1926,
|
||||
"src/renderer/src/components/plugins/page/PluginDetailPage.test.tsx": 3367,
|
||||
"src/renderer/src/components/plugins/page/PluginSettingsSection.test.tsx": 572,
|
||||
"src/renderer/src/components/plugins/presentation/plugin-install-source.test.ts": 214,
|
||||
"src/renderer/src/components/plugins/state/use-plugin-contribution-source.test.tsx": 1935,
|
||||
"src/renderer/src/components/plugins/state/use-plugin-install-link.test.tsx": 518,
|
||||
"src/renderer/src/components/plugins/state/use-plugin-page-navigation.test.tsx": 480,
|
||||
@@ -5159,7 +5152,6 @@
|
||||
"src/renderer/src/components/skills/SkillsPage.test.tsx": 3822,
|
||||
"src/renderer/src/components/sparse/sparse-directory-entry-input.test.ts": 207,
|
||||
"src/renderer/src/components/stats/usage-daily-chart.test.tsx": 333,
|
||||
"src/renderer/src/components/stats/usage-overview-model.test.ts": 364,
|
||||
"src/renderer/src/components/status-bar/ClaudeSwitcherMenu.owner-lifetime.test.tsx": 2317,
|
||||
"src/renderer/src/components/status-bar/StatusBarUsageChangeNotices.test.tsx": 785,
|
||||
"src/renderer/src/components/status-bar/UpdateStatusSegment.test.tsx": 2484,
|
||||
@@ -5173,7 +5165,6 @@
|
||||
"src/renderer/src/components/status-bar/resource-session-kill-confirmation.test.ts": 53,
|
||||
"src/renderer/src/components/status-bar/resource-session-removal-render-budget.test.tsx": 290,
|
||||
"src/renderer/src/components/status-bar/resource-usage-folder-merge.test.ts": 251,
|
||||
"src/renderer/src/components/status-bar/usage-pool-label.test.ts": 170,
|
||||
"src/renderer/src/components/status-bar/use-owner-usage-rate-limits.test.tsx": 462,
|
||||
"src/renderer/src/components/status-bar/use-resource-memory-snapshot.test.tsx": 321,
|
||||
"src/renderer/src/components/status-bar/use-resource-pty-actions.test.tsx": 879,
|
||||
@@ -5238,7 +5229,6 @@
|
||||
"src/renderer/src/components/task-page/task-page-cache-selectors.test.ts": 108,
|
||||
"src/renderer/src/components/task-page/task-page-initial-selection-scaling.test.tsx": 1953,
|
||||
"src/renderer/src/components/task-page/task-page-work-item-pagination.test.ts": 63,
|
||||
"src/renderer/src/components/task-page/use-task-page-source-display.test.tsx": 5228,
|
||||
"src/renderer/src/components/terminal-pane/layout/close/RunningTerminalCloseDialog.test.tsx": 2303,
|
||||
"src/renderer/src/components/terminal-pane/account-restart/detached/account-restart-queue-progress.test.ts": 1988,
|
||||
"src/renderer/src/components/terminal-pane/agent-completion/agent-completion-coordinator-attention-dispatch.test.ts": 301,
|
||||
@@ -6186,7 +6176,6 @@
|
||||
"src/shared/agent-status/process/agent-process-presence-platform.test.ts": 64,
|
||||
"src/shared/agent-launch/startup/agent-prompt-injection.test.ts": 88,
|
||||
"src/shared/agent-scratch-worktrees.test.ts": 61,
|
||||
"src/shared/agent-session/agent-message-display-text.test.ts": 147,
|
||||
"src/shared/agent-session/agent-session-approval-blocked-path.test.ts": 49,
|
||||
"src/shared/agent-session/agent-session-attachments.test.ts": 46,
|
||||
"src/shared/agent-session/agent-session-context-clear.test.ts": 222,
|
||||
@@ -6254,7 +6243,6 @@
|
||||
"src/shared/agent-status/transport/agent-status-osc.test.ts": 104,
|
||||
"src/shared/agent-status/store/agent-status-store-reopen.test.ts": 199,
|
||||
"src/shared/agent-status/title/agent-status-tracker-program-activity.test.ts": 77,
|
||||
"src/shared/agent-launch/startup/agent-tui-input-clear.test.ts": 57,
|
||||
"src/shared/ai-vault/resume/ai-vault-resume-command.test.ts": 70,
|
||||
"src/shared/ai-vault/resume/ai-vault-resume-target.test.ts": 85,
|
||||
"src/shared/ai-vault/scanning/ai-vault-scope-paths.test.ts": 73,
|
||||
@@ -6265,7 +6253,6 @@
|
||||
"src/shared/ai-vault/session-display/ai-vault-session-filters.test.ts": 176,
|
||||
"src/shared/ai-vault/resume/ai-vault-ssh-resume-target.test.ts": 84,
|
||||
"src/shared/ansi-escape-sequences-consumers.test.ts": 140,
|
||||
"src/shared/ansi-escape-sequences.test.ts": 289,
|
||||
"src/shared/antigravity-generation-plan.test.ts": 122,
|
||||
"src/shared/automatic-work-run-marker.test.ts": 93,
|
||||
"src/shared/automation-cron-dialect.test.ts": 65,
|
||||
@@ -6333,7 +6320,6 @@
|
||||
"src/shared/ephemeral-vm-recipe-checkout-mode.test.ts": 106,
|
||||
"src/shared/ephemeral-vm-recipe-output-capture.test.ts": 287,
|
||||
"src/shared/ephemeral-vm-recipe-process.test.ts": 198,
|
||||
"src/shared/ephemeral-vm-recipe-repo-url.test.ts": 56,
|
||||
"src/shared/ephemeral-vm-recipes.test.ts": 160,
|
||||
"src/shared/ephemeral-vm-runtime-store-rollback.test.ts": 321,
|
||||
"src/shared/ephemeral-vm-runtime-store.test.ts": 195,
|
||||
@@ -6439,7 +6425,6 @@
|
||||
"src/shared/keybindings-digit-index.test.ts": 110,
|
||||
"src/shared/keybindings-double-tap.test.ts": 92,
|
||||
"src/shared/keybindings-keyboard-layout.test.ts": 86,
|
||||
"src/shared/keybindings-parse-cache.test.ts": 61,
|
||||
"src/shared/keybindings-parsing.test.ts": 86,
|
||||
"src/shared/keybindings-unassigned-actions.test.ts": 73,
|
||||
"src/shared/kiro-home.test.ts": 39,
|
||||
@@ -6577,7 +6562,6 @@
|
||||
"src/shared/opencode-tui-plugin-install.test.ts": 82,
|
||||
"src/shared/openssh-default-shell.test.ts": 54,
|
||||
"src/shared/orca-browser-cli-commands.test.ts": 59,
|
||||
"src/shared/orca-cli-command-name.test.ts": 41,
|
||||
"src/shared/orca-hook-setup-config.test.ts": 38,
|
||||
"src/shared/orca-session-address.test.ts": 154,
|
||||
"src/shared/orca-yaml-alias-bounds.test.ts": 425,
|
||||
@@ -6746,7 +6730,6 @@
|
||||
"src/shared/remote-runtime/requests/remote-runtime-subscription-frame-router.test.ts": 143,
|
||||
"src/shared/remote-runtime/requests/remote-runtime-subscription-request.test.ts": 646,
|
||||
"src/shared/renderer-restart-preparation.test.ts": 197,
|
||||
"src/shared/repo-display-labels.test.ts": 57,
|
||||
"src/shared/repo-host-identity.test.ts": 45,
|
||||
"src/shared/repo-icon.test.ts": 82,
|
||||
"src/shared/repo-pack-index-scheduling.test.ts": 67,
|
||||
@@ -6850,7 +6833,6 @@
|
||||
"src/shared/terminal/protocol/queries/terminal-color-scheme-protocol.test.ts": 39,
|
||||
"src/shared/terminal/input/terminal-composer-draft.test.ts": 73,
|
||||
"src/shared/terminal/links/terminal-file-uri-link.test.ts": 51,
|
||||
"src/shared/terminal/links/terminal-file-url-target.test.ts": 47,
|
||||
"src/shared/terminal/links/terminal-github-pr-link-detector.test.ts": 61,
|
||||
"src/shared/terminal/links/terminal-http-url-extraction.test.ts": 42,
|
||||
"src/shared/terminal/input/terminal-input.test.ts": 85,
|
||||
@@ -6926,7 +6908,6 @@
|
||||
"src/shared/workspace-attachments/workspace-attachment-origins.test.ts": 42,
|
||||
"src/shared/workspace-attachments/workspace-attachments.test.ts": 204,
|
||||
"src/shared/workspace-cleanup/workspace-cleanup-browse-state-persistence.test.ts": 55,
|
||||
"src/shared/workspace-last-active-switch-on.test.ts": 52,
|
||||
"src/shared/workspace-layout/old-client/old-client-method-translation.test.ts": 352,
|
||||
"src/shared/workspace-layout/old-client/old-client-pane-layout-translation.test.ts": 363,
|
||||
"src/shared/workspace-layout/old-client/old-client-session-tabs-projection-owned-editor.test.ts": 178,
|
||||
|
||||
@@ -29,7 +29,7 @@ export const ORCAD_CHILD_ENTRY_POINTS = {
|
||||
'src/main/worker-thread-child-process/worker-thread-child-process-entry.ts',
|
||||
claudeProfileSetup:
|
||||
'src/main/claude-accounts/profiles/setup/claude-profile-setup-worker-entry.ts',
|
||||
claudeConversationFork: 'src/main/claude/claude-conversation-fork-worker-entry.ts',
|
||||
claudeConversationFork: 'src/main/claude/transcripts/claude-conversation-fork-worker-entry.ts',
|
||||
sttWorker: 'src/main/speech/stt-worker.ts',
|
||||
computerSidecar: 'src/main/computer/computer-sidecar.ts'
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ const NODE_RUNTIME_INCLUDE = [
|
||||
'config/scripts/test-runtime/dom/happy-dom-mutation-observer-retention.test.ts',
|
||||
// These reach Node SQLite through a shared helper or a dynamic import, which the scan skips.
|
||||
'src/main/agent-hooks/server/testing/providers/codex/server-codex-session-start.test.ts',
|
||||
'src/main/claude/claude-transcript-catch-up.test.ts',
|
||||
'src/main/claude/claude-transcript-duration.test.ts',
|
||||
'src/main/claude/transcripts/claude-transcript-catch-up.test.ts',
|
||||
'tests/e2e/native-chat-startup-option-pickers.unit.test.ts',
|
||||
'src/main/ai-vault/transcripts/session-document-consumer-replacement.test.ts',
|
||||
'src/main/ai-vault-search/indexing/session-search-dependent-transcripts.test.ts',
|
||||
@@ -44,7 +43,6 @@ const NODE_RUNTIME_INCLUDE = [
|
||||
'src/main/runtime/orchestration/mailbox/routing/orchestration-mailbox-routing.test.ts',
|
||||
'tests/e2e/cross-version-wire/agent-session-clear-old-client.unit.test.ts',
|
||||
'tests/e2e/cross-version-wire/agent-session-clear-old-tab-mirror.unit.test.ts',
|
||||
'tests/e2e/cross-version-wire/host-model-catalog-released-phone.unit.test.ts',
|
||||
'src/main/pi/rpc/rpc-session-startup.test.ts',
|
||||
'src/main/acp/session/acp-structured-omp-recordings.test.ts',
|
||||
'src/main/native-chat/agent-session-wire/host/testing/structured-agent-session-clear-queued-command.test.ts',
|
||||
@@ -150,11 +148,11 @@ const NODE_RUNTIME_INCLUDE = [
|
||||
'src/main/ipc/filesystem/watchers/filesystem-watcher-ignore-real.test.ts',
|
||||
'src/main/ipc/runtime-environments/runtime-environment-preference.test.ts',
|
||||
'src/renderer/src/components/emulator-pane/emulator-device-frame-visibility.test.tsx',
|
||||
'src/main/claude/claude-agent-sdk-contract-pins.test.ts',
|
||||
'config/scripts/desktop-distribution/runtime-verification/process-host-dev-rebuild.test.ts',
|
||||
'config/scripts/test-runtime/node-worker/vitest-node-runtime-pool.test.ts',
|
||||
// Reopen WAL-backed row caches read-only, which Bun on macOS cannot.
|
||||
'src/main/agent-hooks/server/testing/identity/server-hook-session-binding.test.ts',
|
||||
'src/main/agent-hooks/server/testing/persistence/server-last-status-claude-model.test.ts',
|
||||
'tests/e2e/helpers/persisted-profile-state.unit.test.ts',
|
||||
'src/main/runtime/push/notifications/mobile-notification-dismissal-store.test.ts',
|
||||
'src/main/runtime/push/notifications/mobile-notification-dismissal-read-failure.test.ts',
|
||||
|
||||
@@ -251,7 +251,7 @@ const CROSS_VERSION_WIRE_PREFIXES = [
|
||||
'src/main/native-chat/agent-model-catalog/agent-model-catalog-lister.ts',
|
||||
'src/main/native-chat/agent-model-catalog/agent-model-catalog-listing-waiters.ts',
|
||||
'src/main/native-chat/agent-model-catalog/agent-model-catalog-probe-runner.ts',
|
||||
'src/main/claude/claude-model-catalog-probe.ts',
|
||||
'src/main/claude/model-catalog/claude-model-catalog-probe.ts',
|
||||
'src/main/runtime/agent-session/records/agent-session-record-store',
|
||||
'src/main/runtime/agent-session/records/agent-session-recovery-capsule',
|
||||
'src/shared/agent-session-resume-marker',
|
||||
|
||||
@@ -320,7 +320,7 @@ export const PR_E2E_SOURCE_ROUTES = [
|
||||
MANAGED_SSH_HARNESS.test(file) ||
|
||||
file === 'tests/e2e/fixtures/structured-claude-stub.cjs' ||
|
||||
(isProductSource(file) &&
|
||||
/^src\/(?:main\/(?:claude\/claude-(?:stream-json-connection|stream-json-exit-error|structured-session-exit-lifecycle)|native-chat\/agent-session-wire\/structured-agent-session-failure-text)|renderer\/src\/components\/native-chat\/structured-agent-session-delivery-notices)\.ts$/.test(
|
||||
/^src\/(?:main\/(?:claude\/(?:claude-(?:stream-json-connection|structured-session-exit-lifecycle)|sdk-transport\/claude-stream-json-exit-error)|native-chat\/agent-session-wire\/structured-agent-session-failure-text)|renderer\/src\/components\/native-chat\/structured-agent-session-delivery-notices)\.ts$/.test(
|
||||
file
|
||||
))
|
||||
},
|
||||
|
||||
@@ -170,12 +170,9 @@ export const WINDOWS_BOUNDARY_TESTS = [
|
||||
'src/shared/windows-batch-spawn.win32.test.ts',
|
||||
'src/main/claude/structured/launch/claude-structured-child-env.test.ts',
|
||||
'src/main/agent-hooks/installation/commands/windows-hook-payload-delivery.test.ts',
|
||||
'src/main/agent-hooks/installation/scripts/managed-hook-stdin-lifecycle.test.ts',
|
||||
'src/main/jcode/hook-gate-script.test.ts',
|
||||
'src/main/agent-hooks/installation/commands/windows-native-hook-exe-hosts.test.ts',
|
||||
'src/main/claude/windows-native-hook-registration.test.ts',
|
||||
'src/main/agent-hooks/installation/commands/windows-batch-hook-launcher.test.ts',
|
||||
'src/main/claude/claude-status-line-windows.test.ts',
|
||||
'src/main/codex/hooks/installation/windows-hook-command.test.ts',
|
||||
'src/main/codex/hooks/installation/hook-service-managed-install.test.ts',
|
||||
'src/main/windows/windows-pty-job.win32.test.ts',
|
||||
|
||||
@@ -24,7 +24,8 @@ A plugin adds highlighting for a language through `contributes.syntaxes` in `orc
|
||||
surrounding pairs. Every marker is printable text on one line. Auto-closing and surrounding
|
||||
pairs are at most 8 characters, because the editor types them as you type. Comment markers and
|
||||
brackets can be up to 128. `validate:plugin` refuses an entry that breaks these limits; Orca
|
||||
skips just that entry and loads the rest.
|
||||
skips just that entry and loads the rest. Without `autoClosingPairs`, Orca auto-closes only the
|
||||
brackets that fit in 8 characters.
|
||||
- A plugin can contribute up to 16 syntaxes. Scope names must be unique within the plugin.
|
||||
|
||||
## How Orca uses it
|
||||
|
||||
@@ -5,7 +5,7 @@ description: Pair the Orca mobile app to your desktop to monitor agents and unst
|
||||
|
||||
import { Callout } from '@/components/docs/prose'
|
||||
|
||||
The Orca mobile companion is an iOS/Android app that pairs with your desktop Orca and gives you a read-mostly view of running agents — agent status, recent terminal scrollback, and the controls you actually want from a phone (replying to a prompt, sleeping a worktree, reviewing source control, switching agent accounts). Pairing is one-time and the desktop is always the source of truth.
|
||||
The Orca mobile companion is an iOS/Android app that pairs with your desktop Orca and lets you monitor and control running agents — agent status, recent terminal scrollback, terminal input, source control, and agent accounts. Pairing establishes persistent access to the selected host; the desktop remains the source of truth.
|
||||
|
||||
<Callout title="Beta">
|
||||
The mobile companion is in beta. Install iOS from the [App
|
||||
@@ -36,13 +36,28 @@ The mobile app is intentionally not a full editor — it's a remote control for
|
||||
|
||||
## Pairing
|
||||
|
||||
1. On desktop, open Orca's pairing flow from the account / status menu. Orca shows a one-time pairing code.
|
||||
1. On desktop, open Orca's pairing flow from the account / status menu. Orca shows a pairing code. Treat it as a secret and share it only with the device you want to authorize.
|
||||
1. On mobile, open the Orca companion app and choose **Pair**, then paste the code. (You can also follow a deep link from the desktop directly into the mobile pairing screen.)
|
||||
1. Prefer **Orca Relay** for pairing when it is available — sign-in is required for Relay only. The local network address picker is optional on Relay (expand it when you want a LAN fast path); LAN pairing still needs an address.
|
||||
1. The pairing exchange establishes a device token for that phone; keep desktop reachable on the path you chose.
|
||||
|
||||
Closing the desktop app drops a direct/LAN session until you reopen it. Relay-backed pairing follows the desktop Relay connection — reopen desktop if the host goes offline.
|
||||
|
||||
Current desktop UI pairing offers expire after 10 minutes for mobile and one hour for runtime clients. A paired device's authorization persists beyond the offer's expiry until revoked. Headless offers and older versions can have different lifetimes; do not assume every code is single-use or expires automatically. Regenerate an unused code if it may have been exposed.
|
||||
|
||||
### Access and trust
|
||||
|
||||
A paired phone can read workspace files, send terminal input, and control agents on the paired host and connected remote runtimes made available through it. Pairing is not an enterprise read-only or per-repository sandbox. Use a host account with access appropriate to the phone's user, and protect the phone with its OS lock and your organization's device controls.
|
||||
|
||||
The paired desktop can deliver mobile web UI and JavaScript independently of a mobile store update. These assets travel through the authenticated paired connection and are checked against manifest hashes. The desktop is part of the phone's trust boundary; these checks do not provide a separate publisher signature or store review for every downloaded UI bundle.
|
||||
|
||||
### Revoke a phone or respond to a lost device
|
||||
|
||||
1. On each paired desktop, open the Mobile settings and remove the phone from the paired-device list. Confirm the operation succeeds; removing a saved host on the phone is not a substitute for host-side revocation.
|
||||
1. Host-side revocation removes the device authorization and closes its active connections on that host. Relay credential cleanup is queued durably and requires connectivity to reach the service. Remote runtimes receive updated delegated-device grants when synchronization succeeds. If a host is offline or cleanup has not completed, restrict its network access until revocation is confirmed; there is no guaranteed immediate revocation across offline hosts.
|
||||
1. For a lost phone, use your device-management tools to lock or wipe it and review any separately granted host or provider access. Revoking Orca access does not remotely erase files, screenshots, clipboard contents, or other data already saved on the phone.
|
||||
1. If you suspect a pairing code was shared, regenerate it and review paired devices on the affected host before pairing a replacement phone.
|
||||
|
||||
## Chat UI
|
||||
|
||||
For chat-capable agents (Claude, Codex, and others Orca recognizes), mobile can open the session in **Chat UI** instead of the raw terminal — the same idea as desktop's [Chat UI](/docs/agents/native-chat): a readable transcript, composer, permissions/questions, and image attachments.
|
||||
@@ -122,7 +137,7 @@ For a direct LAN or Tailscale connection, allow the paired desktop's listening p
|
||||
### Common issues
|
||||
|
||||
- **Stuck spinner on a worktree** — the phone tracks a heartbeat from the desktop agent process. If the desktop says idle but the phone shows working, force-refresh the worktree row to sync state.
|
||||
- **Pairing fails** — make sure your desktop and phone are signed into the same Orca account. Pairing codes expire after a few minutes; generate a fresh one if it's been sitting on the screen.
|
||||
- **Pairing fails** — Relay requires desktop sign-in; local-only pairing requires a reachable LAN or Tailscale endpoint. Generate a fresh code if an offer has expired, and check the connection mode and host address.
|
||||
- **Authentication failed / pairing invalid** — the desktop no longer accepts this device token (for example after desktop cleared paired devices). Try **Retry** on the banner first (transient rejections can recover without re-pairing). If it keeps failing, use **Re-pair** from desktop, or **Remove** the host and pair again.
|
||||
- **Update Orca Mobile / Update Orca on your computer** — the phone and desktop speak a versioned mobile protocol. If either side is too old, mobile blocks that host and points you at the App Store (iOS), [GitHub Releases](https://github.com/stablyai/orca/releases) (Android APK or desktop), then back to hosts. After updating, refresh the connection; if the message stays, remove the host and pair again.
|
||||
- **A chat tab says Update mobile** — the session was started in desktop Chat UI, and this phone's app is too old to show it (the tab opens to an empty pane). Update the mobile app, then reconnect to the host so it sees the new app. If the app is already up to date and the tab still says Update mobile after reconnecting, report it with your mobile app version and desktop Orca version.
|
||||
|
||||
@@ -29,3 +29,24 @@ Pick a custom desktop notification sound per category under [Settings → Notifi
|
||||
Supported formats: MP3, WAV, OGG, M4A, AAC, FLAC. One file applies to all delivered desktop notifications.
|
||||
|
||||
When you use a custom sound, set its playback volume from the same settings pane.
|
||||
|
||||
## Disable mobile push from a host
|
||||
|
||||
Set `ORCA_MOBILE_PUSH_MODE` in the environment of each desktop or remote runtime
|
||||
that sends mobile push, then restart that host:
|
||||
|
||||
- `full` (default): existing notification titles, bodies and navigation identifiers.
|
||||
- `disabled`: no alert or test sends and no new push registration from that host.
|
||||
Existing registration deletion and queued cleanup still run. This does not
|
||||
itself erase historical gateway/provider records or disable live in-app events.
|
||||
|
||||
An unrecognized nonempty value disables push delivery. This is a host configuration,
|
||||
not a centrally enforced organization policy. Users who control the host environment
|
||||
can change it. It applies to that host's push gateway traffic, not local desktop
|
||||
notifications or direct/Relay application content. Every sending host needs the
|
||||
setting; older Orca versions do not implement it. OS notification permissions and
|
||||
lock-screen preview settings are separate controls.
|
||||
|
||||
There is no generic-content mode: enabled push may include project/agent text and
|
||||
identifiers. Disabling phone lock-screen previews does not stop that content from
|
||||
reaching the push gateway and APNs/FCM.
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
"usesCleartextTraffic": true,
|
||||
"allowBackup": false,
|
||||
"permissions": ["RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS"],
|
||||
"blockedPermissions": ["android.permission.SYSTEM_ALERT_WINDOW"],
|
||||
"package": "com.stably.orca.mobile",
|
||||
"versionCode": 28,
|
||||
"googleServicesFile": "./google-services.json"
|
||||
|
||||
@@ -7,6 +7,66 @@ function entry(id: number): ConnectionLogEntry {
|
||||
}
|
||||
|
||||
describe('connection log buffer', () => {
|
||||
it('discards history without a pending hydration or late event restoring it', async () => {
|
||||
let resolveLoad: (entries: readonly ConnectionLogEntry[]) => void = () => {}
|
||||
let persisted: readonly ConnectionLogEntry[] = [entry(1)]
|
||||
const store = createConnectionLogStore(3, {
|
||||
load: () =>
|
||||
new Promise((resolve) => {
|
||||
resolveLoad = resolve
|
||||
}),
|
||||
save: async (_hostId, entries) => {
|
||||
persisted = entries
|
||||
}
|
||||
})
|
||||
const hydration = store.hydrate('host-a')
|
||||
store.append('host-a', entry(2))
|
||||
|
||||
await store.discard('host-a')
|
||||
resolveLoad([entry(1)])
|
||||
await hydration
|
||||
store.append('host-a', entry(3))
|
||||
await store.flush()
|
||||
|
||||
expect(store.get('host-a')).toEqual([])
|
||||
expect(persisted).toEqual([])
|
||||
})
|
||||
|
||||
it('discards history after an older in-flight save finishes', async () => {
|
||||
let finishSave: () => void = () => {}
|
||||
let markSaveStarted: () => void = () => {}
|
||||
const saveStarted = new Promise<void>((resolve) => {
|
||||
markSaveStarted = resolve
|
||||
})
|
||||
let persisted: readonly ConnectionLogEntry[] = []
|
||||
let holdNextSave = false
|
||||
const store = createConnectionLogStore(3, {
|
||||
load: async () => [],
|
||||
save: async (_hostId, entries) => {
|
||||
if (holdNextSave) {
|
||||
holdNextSave = false
|
||||
markSaveStarted()
|
||||
await new Promise<void>((resolve) => {
|
||||
finishSave = resolve
|
||||
})
|
||||
}
|
||||
persisted = entries
|
||||
}
|
||||
})
|
||||
await store.hydrate('host-a')
|
||||
await store.flush()
|
||||
holdNextSave = true
|
||||
store.append('host-a', entry(1))
|
||||
await saveStarted
|
||||
|
||||
const cleared = store.discard('host-a')
|
||||
finishSave()
|
||||
await cleared
|
||||
|
||||
expect(store.get('host-a')).toEqual([])
|
||||
expect(persisted).toEqual([])
|
||||
})
|
||||
|
||||
it('redacts credentials before retaining or persisting an event', async () => {
|
||||
const save = vi.fn(async () => {})
|
||||
const store = createConnectionLogStore(3, {
|
||||
|
||||
@@ -8,6 +8,8 @@ const PERSISTENCE_RETRY_DELAY_MS = 200
|
||||
|
||||
export type ConnectionLogStore = {
|
||||
append: (hostId: string, entry: ConnectionLogEntry) => void
|
||||
/** Drops and persists empty history; later appends for the removed host are ignored. */
|
||||
discard: (hostId: string) => Promise<void>
|
||||
flush: () => Promise<void>
|
||||
get: (hostId: string) => readonly ConnectionLogEntry[]
|
||||
hydrate: (hostId: string) => Promise<void>
|
||||
@@ -27,6 +29,8 @@ export function createConnectionLogStore(
|
||||
const listenersByHost = new Map<string, Set<() => void>>()
|
||||
const hydratedHosts = new Set<string>()
|
||||
const hydrationFailedHosts = new Set<string>()
|
||||
// Removed host ids are never reused, so late events from closing clients must not recreate history.
|
||||
const discardedHosts = new Set<string>()
|
||||
const hydrationByHost = new Map<string, Promise<void>>()
|
||||
const activeSaveByHost = new Map<string, Promise<void>>()
|
||||
const dirtyHosts = new Set<string>()
|
||||
@@ -133,6 +137,9 @@ export function createConnectionLogStore(
|
||||
const pending = persistence
|
||||
.load(hostId)
|
||||
.then((stored) => {
|
||||
if (hydratedHosts.has(hostId)) {
|
||||
return
|
||||
}
|
||||
const live = entriesByHost.get(hostId) ?? []
|
||||
const seen = new Set<string>()
|
||||
const merged: ConnectionLogEntry[] = []
|
||||
@@ -163,6 +170,9 @@ export function createConnectionLogStore(
|
||||
|
||||
return {
|
||||
append(hostId, entry) {
|
||||
if (discardedHosts.has(hostId)) {
|
||||
return
|
||||
}
|
||||
let entries = entriesByHost.get(hostId)
|
||||
if (!entries) {
|
||||
entries = []
|
||||
@@ -176,6 +186,15 @@ export function createConnectionLogStore(
|
||||
.catch(() => {})
|
||||
},
|
||||
|
||||
async discard(hostId) {
|
||||
discardedHosts.add(hostId)
|
||||
entriesByHost.delete(hostId)
|
||||
hydratedHosts.add(hostId)
|
||||
hydrationFailedHosts.delete(hostId)
|
||||
notify(hostId)
|
||||
await flushHost(hostId)
|
||||
},
|
||||
|
||||
flush: async () => {
|
||||
await Promise.all([...entriesByHost.keys()].map((hostId) => flushHost(hostId)))
|
||||
},
|
||||
|
||||
@@ -24,6 +24,11 @@ export const connectionLogStore = createConnectionLogStore(200, {
|
||||
}
|
||||
})
|
||||
|
||||
export async function discardConnectionLogs(hostId: string): Promise<void> {
|
||||
sessionStartedHosts.delete(hostId)
|
||||
await connectionLogStore.discard(hostId)
|
||||
}
|
||||
|
||||
export function recordConnectionRevival(
|
||||
hostId: string,
|
||||
reason: 'app-resume' | 'network-change'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { QueryClient } from '@tanstack/react-query'
|
||||
import { discardConnectionLogs } from '../diagnostics/connection/persisted-connection-log-store'
|
||||
import { wipeHostStore } from '../device-store/device-store'
|
||||
import {
|
||||
deleteHostPageCache,
|
||||
@@ -31,4 +32,5 @@ export async function removeHostAndCloseClient(
|
||||
void forgetHostUpdateFailures(hostId).catch(() => undefined)
|
||||
void deleteHostPageCache(hostId).catch(() => undefined)
|
||||
void wipeHostStore(hostId).catch(() => undefined)
|
||||
void discardConnectionLogs(hostId).catch(() => undefined)
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { readPushNotificationsPreference } from '../../storage/preferences'
|
||||
import { shouldPresentNotificationOptIn } from './notification-opt-in-gate'
|
||||
|
||||
vi.mock('../../storage/preferences', () => ({
|
||||
readPushNotificationsPreference: vi.fn()
|
||||
}))
|
||||
|
||||
describe('notification opt-in gate', () => {
|
||||
it('asks for push-service consent when no choice is saved', async () => {
|
||||
vi.mocked(readPushNotificationsPreference).mockResolvedValue({ value: null, loaded: true })
|
||||
await expect(shouldPresentNotificationOptIn()).resolves.toBe(true)
|
||||
})
|
||||
|
||||
it.each([true, false])('does not ask again after choosing %s', async (value) => {
|
||||
vi.mocked(readPushNotificationsPreference).mockResolvedValue({ value, loaded: true })
|
||||
await expect(shouldPresentNotificationOptIn()).resolves.toBe(false)
|
||||
})
|
||||
|
||||
it('does not prompt when the saved choice cannot be read', async () => {
|
||||
vi.mocked(readPushNotificationsPreference).mockResolvedValue({ value: null, loaded: false })
|
||||
await expect(shouldPresentNotificationOptIn()).resolves.toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -1,58 +0,0 @@
|
||||
import { expect, it, vi } from 'vitest'
|
||||
const state = vi.hoisted(
|
||||
(): { taskName: string; task: null | ((input: unknown) => Promise<void>) } => ({
|
||||
taskName: '',
|
||||
task: null
|
||||
})
|
||||
)
|
||||
vi.mock('expo-task-manager', () => ({
|
||||
defineTask: (name: string, task: typeof state.task) => {
|
||||
state.taskName = name
|
||||
state.task = task
|
||||
},
|
||||
isAvailableAsync: async () => true
|
||||
}))
|
||||
vi.mock('expo-notifications', () => ({
|
||||
registerTaskAsync: vi.fn(),
|
||||
getPresentedNotificationsAsync: vi.fn(async () => []),
|
||||
dismissNotificationAsync: vi.fn()
|
||||
}))
|
||||
vi.mock('./push-tray-dismissal', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('./push-tray-dismissal')>()
|
||||
return {
|
||||
...actual,
|
||||
dismissPresentedPushNotification: vi.fn(actual.dismissPresentedPushNotification)
|
||||
}
|
||||
})
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { dismissPresentedPushNotification } from './push-tray-dismissal'
|
||||
import './push-background-dismissal'
|
||||
|
||||
it('does not turn ordinary alerts into dismissals', async () => {
|
||||
vi.mocked(dismissPresentedPushNotification).mockClear()
|
||||
await state.task!({
|
||||
data: { data: { orca: { hostFingerprint: 'host-a', notificationId: 'same-id' } } }
|
||||
})
|
||||
expect(dismissPresentedPushNotification).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('an ID-only background dismissal preserves versioned tray alerts', async () => {
|
||||
const base = { hostFingerprint: 'host-a', notificationId: 'same-id' }
|
||||
vi.mocked(Notifications.getPresentedNotificationsAsync).mockResolvedValue([
|
||||
{ request: { identifier: 'legacy', content: { data: base } } },
|
||||
{
|
||||
request: {
|
||||
identifier: 'versioned',
|
||||
content: {
|
||||
data: {
|
||||
...base,
|
||||
notificationEpoch: 'epoch',
|
||||
notificationSeq: 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
] as never)
|
||||
await state.task!({ data: { data: { ...base, kind: 'dismiss' } } })
|
||||
expect(Notifications.dismissNotificationAsync).toHaveBeenCalledExactlyOnceWith('legacy')
|
||||
})
|
||||
@@ -54,24 +54,3 @@ it('merges batched and concurrent fences without lowering duplicates or acceptin
|
||||
expect(await wasPushDismissed({ ...payload, notificationId: 'other' })).toBe(true)
|
||||
expect(await wasPushDismissed({ ...payload, notificationId: 'invalid' })).toBe(false)
|
||||
})
|
||||
|
||||
it.each([1, 3])('retains live dismissals beyond 512 entries across %i hosts', async (hosts) => {
|
||||
for (let index = 0; index < 520; index++) {
|
||||
await rememberPushDismissal({
|
||||
...payload,
|
||||
hostFingerprint: `host-${index % hosts}`,
|
||||
notificationId: `note-${index}`
|
||||
})
|
||||
}
|
||||
vi.resetModules()
|
||||
const restarted = await import('./push-dismissal-watermarks')
|
||||
for (const index of [0, 1, 519]) {
|
||||
const alert = {
|
||||
...payload,
|
||||
hostFingerprint: `host-${index % hosts}`,
|
||||
notificationId: `note-${index}`
|
||||
}
|
||||
expect(await restarted.wasPushDismissed(alert)).toBe(true)
|
||||
expect(await restarted.wasPushDismissed({ ...alert, notificationSeq: 3 })).toBe(false)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
import { beforeEach, expect, it, vi } from 'vitest'
|
||||
import type {
|
||||
FirebaseRemoteMessageNotification,
|
||||
Notification,
|
||||
NotificationTrigger
|
||||
} from 'expo-notifications'
|
||||
import { startAndroidForegroundPushPresentation } from './android-foreground-push'
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
platform: { OS: 'android' },
|
||||
receive: (_notification: Notification) => {},
|
||||
remove: vi.fn(),
|
||||
eligible: vi.fn().mockResolvedValue(true),
|
||||
schedule: vi.fn().mockResolvedValue('message-1')
|
||||
}))
|
||||
vi.mock('./push-receive', () => ({ canPresentForegroundPush: mocks.eligible }))
|
||||
vi.mock('react-native', () => ({ Platform: mocks.platform }))
|
||||
vi.mock('expo-notifications', () => ({
|
||||
addNotificationReceivedListener: (listener: typeof mocks.receive) => {
|
||||
mocks.receive = listener
|
||||
return { remove: mocks.remove }
|
||||
},
|
||||
scheduleNotificationAsync: mocks.schedule
|
||||
}))
|
||||
|
||||
// Build complete Expo message types once so fixtures need no unchecked assertions.
|
||||
const REMOTE_NOTIFICATION: FirebaseRemoteMessageNotification = {
|
||||
body: null,
|
||||
bodyLocalizationArgs: null,
|
||||
bodyLocalizationKey: null,
|
||||
channelId: null,
|
||||
clickAction: null,
|
||||
color: null,
|
||||
eventTime: null,
|
||||
icon: null,
|
||||
imageUrl: null,
|
||||
lightSettings: null,
|
||||
link: null,
|
||||
localOnly: false,
|
||||
notificationCount: null,
|
||||
notificationPriority: null,
|
||||
sound: null,
|
||||
sticky: false,
|
||||
tag: null,
|
||||
ticker: null,
|
||||
title: null,
|
||||
titleLocalizationArgs: null,
|
||||
titleLocalizationKey: null,
|
||||
usesDefaultLightSettings: false,
|
||||
usesDefaultSound: false,
|
||||
usesDefaultVibrateSettings: false,
|
||||
vibrateTimings: null,
|
||||
visibility: null
|
||||
}
|
||||
|
||||
function pushTrigger(remote: FirebaseRemoteMessageNotification | null): NotificationTrigger {
|
||||
return {
|
||||
type: 'push',
|
||||
remoteMessage: {
|
||||
collapseKey: null,
|
||||
data: {},
|
||||
from: null,
|
||||
messageId: 'message-1',
|
||||
messageType: null,
|
||||
notification: remote,
|
||||
originalPriority: 1,
|
||||
priority: 1,
|
||||
sentTime: 0,
|
||||
to: null,
|
||||
ttl: 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ORCA_PUSH_DATA: Record<string, unknown> = {
|
||||
hostFingerprint: 'host',
|
||||
notificationId: 'event',
|
||||
notificationEpoch: 'epoch',
|
||||
notificationSeq: '3',
|
||||
paneKey: 'pane',
|
||||
channelId: 'orca-desktop'
|
||||
}
|
||||
|
||||
function notification(
|
||||
trigger: NotificationTrigger = pushTrigger(null),
|
||||
data: Record<string, unknown> = ORCA_PUSH_DATA
|
||||
): Notification {
|
||||
return {
|
||||
date: 0,
|
||||
request: {
|
||||
identifier: 'message-1',
|
||||
trigger,
|
||||
content: {
|
||||
title: 'Test notification',
|
||||
subtitle: null,
|
||||
body: '',
|
||||
categoryIdentifier: null,
|
||||
threadIdentifier: null,
|
||||
sound: 'default',
|
||||
data
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mocks.eligible.mockReset().mockResolvedValue(true)
|
||||
mocks.platform.OS = 'android'
|
||||
})
|
||||
|
||||
it('does not reschedule its own local notification or normal provider notifications', () => {
|
||||
startAndroidForegroundPushPresentation()
|
||||
mocks.receive(notification(null))
|
||||
mocks.receive(notification({ channelId: 'orca-desktop' }))
|
||||
mocks.receive(notification(pushTrigger({ ...REMOTE_NOTIFICATION, title: 'Test' })))
|
||||
expect(mocks.schedule).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('leaves silent dismissals and unrelated messages alone', () => {
|
||||
startAndroidForegroundPushPresentation()
|
||||
mocks.receive(notification(undefined, { ...ORCA_PUSH_DATA, kind: 'dismiss' }))
|
||||
mocks.receive(notification(undefined, {}))
|
||||
expect(mocks.schedule).not.toHaveBeenCalled()
|
||||
})
|
||||
@@ -1,36 +0,0 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { Platform } from 'react-native'
|
||||
import { ensureDesktopNotificationChannel } from './desktop-notification-channel'
|
||||
|
||||
vi.mock('expo-notifications', () => ({
|
||||
AndroidImportance: { HIGH: 'high' },
|
||||
setNotificationChannelAsync: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('react-native', () => ({
|
||||
AppState: { currentState: 'background' },
|
||||
Platform: { OS: 'android' }
|
||||
}))
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
Object.assign(Platform, { OS: 'android' })
|
||||
vi.mocked(Notifications.setNotificationChannelAsync).mockResolvedValue(null as never)
|
||||
})
|
||||
|
||||
describe('ensureDesktopNotificationChannel', () => {
|
||||
it('does nothing on iOS, which has no notification channels', () => {
|
||||
Object.assign(Platform, { OS: 'ios' })
|
||||
|
||||
ensureDesktopNotificationChannel()
|
||||
|
||||
expect(Notifications.setNotificationChannelAsync).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('reports channel failure so registration can retry', async () => {
|
||||
vi.mocked(Notifications.setNotificationChannelAsync).mockRejectedValue(new Error('no channels'))
|
||||
|
||||
await expect(ensureDesktopNotificationChannel()).rejects.toThrow('no channels')
|
||||
})
|
||||
})
|
||||
@@ -1,62 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getNotificationNavigationTarget } from './notification-routing'
|
||||
|
||||
describe('notification routing', () => {
|
||||
// Identities stay raw: the target is dispatched as navigator params, not a URL.
|
||||
it('routes notification taps to the worktree terminal screen', () => {
|
||||
expect(
|
||||
getNotificationNavigationTarget({
|
||||
hostId: 'host-1',
|
||||
worktreeId: 'repo::/Users/me/orca/workspaces/feature'
|
||||
})
|
||||
).toEqual({
|
||||
hostId: 'host-1',
|
||||
sessionTarget: {
|
||||
name: '[hostId]/session/[worktreeId]',
|
||||
params: { hostId: 'host-1', worktreeId: 'repo::/Users/me/orca/workspaces/feature' }
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('falls back to the host screen when the payload has no worktree id', () => {
|
||||
expect(getNotificationNavigationTarget({ hostId: 'host-1' })).toEqual({
|
||||
hostId: 'host-1',
|
||||
sessionTarget: null
|
||||
})
|
||||
})
|
||||
|
||||
it('ignores payloads that cannot identify the paired host', () => {
|
||||
expect(getNotificationNavigationTarget({ worktreeId: 'repo::/tmp/worktree' })).toBeNull()
|
||||
})
|
||||
|
||||
it('ignores payloads for hosts that are no longer paired', () => {
|
||||
expect(
|
||||
getNotificationNavigationTarget(
|
||||
{ hostId: 'removed-host', worktreeId: 'repo::/tmp/worktree' },
|
||||
{ knownHostIds: new Set(['host-1']) }
|
||||
)
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
it('preserves the originating pane in the workspace route', () => {
|
||||
const paneKey = 'tab-b:11111111-1111-4111-8111-111111111111'
|
||||
expect(
|
||||
getNotificationNavigationTarget({ hostId: 'host', worktreeId: 'folder:/work', paneKey })
|
||||
?.sessionTarget?.params
|
||||
).toEqual({ hostId: 'host', worktreeId: 'folder:/work', paneKey })
|
||||
})
|
||||
|
||||
it('scopes a tap to a server workspace, and keeps anything else on the desktop', () => {
|
||||
const paramsFor = (executionHost: unknown) =>
|
||||
getNotificationNavigationTarget({ hostId: 'host', worktreeId: 'repo::/srv', executionHost })
|
||||
?.sessionTarget?.params
|
||||
expect(paramsFor('runtime:env-1')).toEqual({
|
||||
hostId: 'host',
|
||||
worktreeId: 'repo::/srv',
|
||||
executionHost: 'runtime:env-1'
|
||||
})
|
||||
for (const notAServer of [undefined, '', 'local', 'ssh:box', 'runtime:', 'env-1', 42]) {
|
||||
expect(paramsFor(notAServer)).toEqual({ hostId: 'host', worktreeId: 'repo::/srv' })
|
||||
}
|
||||
})
|
||||
@@ -1,8 +0,0 @@
|
||||
import { expect, it } from 'vitest'
|
||||
import { readNativeNotificationData } from './native-notification-data'
|
||||
|
||||
it('keeps Android push and local notification data', () => {
|
||||
const data = { hostId: 'host', notificationId: 'done' }
|
||||
expect(readNativeNotificationData({ content: { data }, trigger: { type: 'push' } })).toBe(data)
|
||||
expect(readNativeNotificationData({ content: { data }, trigger: null })).toBe(data)
|
||||
})
|
||||
@@ -1,19 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { deriveHostFingerprint, resolveHostIdForFingerprint } from './push-host-fingerprint'
|
||||
import { resolveHostIdForFingerprint } from './push-host-fingerprint'
|
||||
|
||||
const publicKey = Uint8Array.from({ length: 32 }, (_, index) => index)
|
||||
const publicKeyB64 = Buffer.from(publicKey).toString('base64')
|
||||
|
||||
describe('deriveHostFingerprint', () => {
|
||||
it.each([
|
||||
['a key of the wrong length', Buffer.from(new Uint8Array(16)).toString('base64')],
|
||||
['text that is not base64 at all', '!!!not base64!!!'],
|
||||
['an empty key', '']
|
||||
])('returns null for %s', (_label, value) => {
|
||||
expect(deriveHostFingerprint(value)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveHostIdForFingerprint', () => {
|
||||
const other = Uint8Array.from({ length: 32 }, (_, index) => index + 1)
|
||||
const hosts = [
|
||||
@@ -25,12 +15,4 @@ describe('resolveHostIdForFingerprint', () => {
|
||||
it('maps a push fingerprint back to the paired host id', () => {
|
||||
expect(resolveHostIdForFingerprint('Yw3NKWbEM2aRElRI', hosts)).toBe('host-1')
|
||||
})
|
||||
|
||||
it('returns null for a fingerprint no paired host derives', () => {
|
||||
expect(resolveHostIdForFingerprint('0123456789abcdef', hosts)).toBeNull()
|
||||
})
|
||||
|
||||
it('rejects a fingerprint of the wrong length', () => {
|
||||
expect(resolveHostIdForFingerprint('Yw3NKWbEM2aRElRI'.slice(0, 8), hosts)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import * as Notifications from 'expo-notifications'
|
||||
import { addPushTokenListener, getDevicePushToken } from './push-token'
|
||||
|
||||
vi.mock('expo-notifications', () => ({
|
||||
getDevicePushTokenAsync: vi.fn(),
|
||||
addPushTokenListener: vi.fn()
|
||||
}))
|
||||
|
||||
const dev = globalThis as { __DEV__?: boolean }
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
delete dev.__DEV__
|
||||
})
|
||||
|
||||
describe('getDevicePushToken', () => {
|
||||
it.each([
|
||||
[true, 'sandbox'],
|
||||
[false, 'production']
|
||||
])('reports apnsEnvironment for a __DEV__=%s iOS build as %s', async (isDev, environment) => {
|
||||
dev.__DEV__ = isDev
|
||||
vi.mocked(Notifications.getDevicePushTokenAsync).mockResolvedValue({
|
||||
type: 'ios',
|
||||
data: 'a'.repeat(64)
|
||||
} as never)
|
||||
|
||||
await expect(getDevicePushToken()).resolves.toEqual({
|
||||
platform: 'ios',
|
||||
token: 'a'.repeat(64),
|
||||
apnsEnvironment: environment
|
||||
})
|
||||
})
|
||||
|
||||
it('omits apnsEnvironment for Android, where FCM has no environment split', async () => {
|
||||
vi.mocked(Notifications.getDevicePushTokenAsync).mockResolvedValue({
|
||||
type: 'android',
|
||||
data: 'fcm-registration-token'
|
||||
} as never)
|
||||
|
||||
await expect(getDevicePushToken()).resolves.toEqual({
|
||||
platform: 'android',
|
||||
token: 'fcm-registration-token'
|
||||
})
|
||||
})
|
||||
|
||||
it.each([
|
||||
['a web push subscription', { type: 'web', data: { endpoint: 'https://example.test' } }],
|
||||
['an empty token', { type: 'ios', data: '' }]
|
||||
])('returns null for %s', async (_label, raw) => {
|
||||
vi.mocked(Notifications.getDevicePushTokenAsync).mockResolvedValue(raw as never)
|
||||
|
||||
await expect(getDevicePushToken()).resolves.toBeNull()
|
||||
})
|
||||
|
||||
it('returns null when the shell cannot mint a token at all', async () => {
|
||||
vi.mocked(Notifications.getDevicePushTokenAsync).mockRejectedValue(new Error('no entitlement'))
|
||||
|
||||
await expect(getDevicePushToken()).resolves.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('addPushTokenListener', () => {
|
||||
it('forwards a rolled native token and removes the subscription on teardown', () => {
|
||||
const remove = vi.fn()
|
||||
const native: { emit?: Parameters<typeof Notifications.addPushTokenListener>[0] } = {}
|
||||
vi.mocked(Notifications.addPushTokenListener).mockImplementation((listener) => {
|
||||
native.emit = listener
|
||||
return { remove }
|
||||
})
|
||||
const seen: unknown[] = []
|
||||
|
||||
const stop = addPushTokenListener((token) => seen.push(token))
|
||||
native.emit?.({ type: 'android', data: 'rolled' })
|
||||
native.emit?.({ type: 'web', data: {} })
|
||||
stop()
|
||||
|
||||
expect(seen).toEqual([{ platform: 'android', token: 'rolled' }])
|
||||
expect(remove).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { Translate } from '../i18n/mobile-i18n'
|
||||
import { getPairingScanErrorMessage } from './pairing-scan-error-message'
|
||||
|
||||
const t: Translate = (key) => key
|
||||
|
||||
describe('getPairingScanErrorMessage', () => {
|
||||
it('recognizes the Android download code on the orca.dev and legacy hosts', () => {
|
||||
for (const url of [
|
||||
'https://orca.dev/download/android',
|
||||
'https://www.orca.dev/download/android',
|
||||
'https://onorca.dev/download/android',
|
||||
'https://www.onorca.dev/download/android'
|
||||
]) {
|
||||
expect(getPairingScanErrorMessage(url, t)).toBe('app.pairScan.downloadQrCode')
|
||||
}
|
||||
})
|
||||
|
||||
it('treats other orca.dev pages as an invalid code', () => {
|
||||
expect(getPairingScanErrorMessage('https://orca.dev/download', t)).toBe(
|
||||
'app.pairScan.invalidQrCode'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -69,17 +69,6 @@ function createWriteQueue(): WriteQueueHarness {
|
||||
}
|
||||
}
|
||||
|
||||
function drain(queue: WriteQueueHarness): void {
|
||||
queue.pump()
|
||||
let guard = 0
|
||||
while (queue.pendingWrites.length > 0) {
|
||||
queue.flushWrite()
|
||||
if (++guard > 10_000) {
|
||||
throw new Error('write queue did not drain')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('terminal WebView write queue', () => {
|
||||
// Count queue-reachable string units, not heap bytes; xterm may still retain submitted chunks.
|
||||
|
||||
@@ -127,14 +116,4 @@ describe('terminal WebView write queue', () => {
|
||||
|
||||
expect(queue.writes).toEqual(['first'])
|
||||
})
|
||||
|
||||
it('drains reentrant enqueues in order', () => {
|
||||
const queue = createWriteQueue()
|
||||
queue.enqueue('first')
|
||||
queue.enqueueBoundary(() => queue.enqueue('reentrant'))
|
||||
queue.enqueue('second')
|
||||
drain(queue)
|
||||
|
||||
expect(queue.writes).toEqual(['first', 'secondreentrant'])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -47,14 +47,4 @@ describe('the terminal waits for its bundled glyphs', () => {
|
||||
expect(clearTextureAtlas).not.toHaveBeenCalled()
|
||||
expect(fonts.postToHost).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('withholds readiness until the font can paint the first terminal snapshot', async () => {
|
||||
const fonts = pendingFonts()
|
||||
startMessageBridge(fonts.scope)
|
||||
expect(fonts.postToHost).not.toHaveBeenCalled()
|
||||
fonts.finish()
|
||||
await fonts.loaded
|
||||
expect(fonts.postToHost).toHaveBeenCalledWith({ type: 'web-ready', cellBox: null })
|
||||
stopMessageBridge(fonts.scope)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -9,7 +9,6 @@ const terminals: Terminal[] = []
|
||||
|
||||
afterEach(() => {
|
||||
terminals.splice(0).forEach((term) => term.dispose())
|
||||
vi.unstubAllGlobals()
|
||||
vi.useRealTimers()
|
||||
})
|
||||
|
||||
@@ -30,29 +29,6 @@ async function fixture(text: string) {
|
||||
return { term, scope, select, selected }
|
||||
}
|
||||
|
||||
describe('word selection uses the rendered xterm cell range', () => {
|
||||
it('keeps cell mapping when a legacy WebView has no grapheme segmenter', async () => {
|
||||
const f = await fixture('합성 🙂 cafe\u0301')
|
||||
vi.stubGlobal('Intl', Object.assign(Object.create(Intl), { Segmenter: undefined }))
|
||||
seedWordSelection(f.scope, 3, 0)
|
||||
expect(f.select).toHaveBeenLastCalledWith(0, 0, 4)
|
||||
expect(f.selected()).toBe('합성')
|
||||
seedWordSelection(f.scope, 6, 0)
|
||||
expect(f.select).toHaveBeenLastCalledWith(5, 0, 2)
|
||||
expect(f.selected()).toBe('🙂')
|
||||
})
|
||||
|
||||
it('keeps an absolute scrollback row and tolerates an evicted line', async () => {
|
||||
const f = await fixture('한글\r\nsecond\r\nthird\r\nfourth')
|
||||
expect(f.term.buffer.active.viewportY).toBeGreaterThan(0)
|
||||
seedWordSelection(f.scope, 2, 0)
|
||||
expect(f.select).toHaveBeenLastCalledWith(0, 0, 4)
|
||||
expect(f.selected()).toBe('한글')
|
||||
seedWordSelection(f.scope, 2, 99)
|
||||
expect(f.select).toHaveBeenLastCalledWith(2, 99, 1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Unicode selection boundaries across every rendered column', () => {
|
||||
it.each([
|
||||
['한글', 4],
|
||||
@@ -73,16 +49,4 @@ describe('Unicode selection boundaries across every rendered column', () => {
|
||||
seedWordSelection(f.scope, 3 + width + 1, 0)
|
||||
expect(f.selected()).toBe('next')
|
||||
})
|
||||
|
||||
it('keeps the last wide word on the row and the next wrapped row independent', async () => {
|
||||
const f = await fixture(' '.repeat(56) + '한글next')
|
||||
for (const col of [56, 57, 58, 59]) {
|
||||
seedWordSelection(f.scope, col, 0)
|
||||
expect(f.select).toHaveBeenLastCalledWith(56, 0, 4)
|
||||
expect(f.selected()).toBe('한글')
|
||||
}
|
||||
seedWordSelection(f.scope, 0, 1)
|
||||
expect(f.select).toHaveBeenLastCalledWith(0, 1, 4)
|
||||
expect(f.selected()).toBe('next')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -60,5 +60,5 @@ export function mobileAgentChildRowText(
|
||||
: row.detail?.kind === 'role' && (!row.detail.agentType || row.detail.agentType === 'unknown')
|
||||
? translate('session.agentChildRow.agent', 'Agent')
|
||||
: agentChildRowDetailText(row, now, mobileAgentChildRowCopy())
|
||||
return agentChildRowLeadTrail(row, mobileAgentChildRowName(row), detail)
|
||||
return agentChildRowLeadTrail(mobileAgentChildRowName(row), detail)
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { reportCliError } from './format'
|
||||
import { RuntimeRpcFailureError } from './runtime-client'
|
||||
|
||||
function selectorAmbiguous(): RuntimeRpcFailureError {
|
||||
return new RuntimeRpcFailureError({
|
||||
id: 'req_selector',
|
||||
ok: false,
|
||||
error: { code: 'selector_ambiguous', message: 'selector_ambiguous' },
|
||||
_meta: { runtimeId: 'runtime_local' }
|
||||
})
|
||||
}
|
||||
|
||||
describe('ambiguous selector recovery', () => {
|
||||
it('carries the ambiguous --worktree value into the --json failure envelope', () => {
|
||||
const log = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
reportCliError(selectorAmbiguous(), true, {
|
||||
commandPath: ['terminal', 'create'],
|
||||
worktreeSelector: 'name:feature'
|
||||
})
|
||||
|
||||
expect(JSON.parse(String(log.mock.calls[0]?.[0]))).toMatchObject({
|
||||
error: {
|
||||
code: 'selector_ambiguous',
|
||||
data: {
|
||||
ambiguousSelectors: [{ flag: '--worktree', selector: 'name:feature' }],
|
||||
nextSteps: expect.arrayContaining([expect.stringContaining('identity:<identity.key>')])
|
||||
}
|
||||
}
|
||||
})
|
||||
log.mockRestore()
|
||||
})
|
||||
})
|
||||
|
||||
describe('worktree selector recovery', () => {
|
||||
it('keeps the selector grammar when the error already carries mutation recovery data', () => {
|
||||
const log = vi.spyOn(console, 'log').mockImplementation(() => {})
|
||||
|
||||
reportCliError(
|
||||
new RuntimeRpcFailureError({
|
||||
id: 'req_selector',
|
||||
ok: false,
|
||||
error: {
|
||||
code: 'selector_not_found',
|
||||
message: 'selector_not_found',
|
||||
// Preserve the request ID already attached by mutation recovery.
|
||||
data: { orchestrationRequestId: 'req_abc', nextSteps: ['Run request-show first.'] }
|
||||
},
|
||||
_meta: { runtimeId: 'runtime_local' }
|
||||
}),
|
||||
true,
|
||||
{ commandPath: ['orchestration', 'worker-start'], worktreeSelector: 'bare-repo-id' }
|
||||
)
|
||||
|
||||
expect(JSON.parse(String(log.mock.calls[0]?.[0]))).toMatchObject({
|
||||
error: {
|
||||
data: {
|
||||
orchestrationRequestId: 'req_abc',
|
||||
selector: 'bare-repo-id',
|
||||
validSelectorForms: expect.arrayContaining(['current']),
|
||||
nextSteps: expect.arrayContaining(['Run request-show first.'])
|
||||
}
|
||||
}
|
||||
})
|
||||
log.mockRestore()
|
||||
})
|
||||
})
|
||||
@@ -216,4 +216,53 @@ describe('agent hooks CLI handler', () => {
|
||||
readBack.db.close()
|
||||
}
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ label: 'offline', reachable: false, enabled: true, appliedBy: 'offline' },
|
||||
{ label: 'connected', reachable: true, enabled: false, appliedBy: 'runtime' }
|
||||
] as const)(
|
||||
'reports $label hook status against the SQLite file that holds the setting',
|
||||
async ({ reachable, enabled, appliedBy }) => {
|
||||
const profileId = 'sqlite-status'
|
||||
writeActiveProfileIndex(userDataPath, profileId)
|
||||
const databaseFile = getOrcaProfileStateDatabaseFile(profileId, userDataPath)
|
||||
mkdirSync(join(userDataPath, 'profiles', profileId), { recursive: true })
|
||||
const opened = openProfileStateDatabase(databaseFile, profileId)
|
||||
try {
|
||||
importProfileStateJson(
|
||||
opened.db,
|
||||
JSON.stringify({ settings: { agentStatusHooksEnabled: true } })
|
||||
)
|
||||
} finally {
|
||||
opened.db.close()
|
||||
}
|
||||
getDefaultUserDataPathMock.mockReturnValue(userDataPath)
|
||||
if (reachable) {
|
||||
getCliStatusMock.mockResolvedValueOnce({
|
||||
id: 'test-status',
|
||||
ok: true,
|
||||
result: {
|
||||
app: { running: true, pid: null },
|
||||
runtime: { state: 'ready', reachable: true, runtimeId: null },
|
||||
graph: { state: 'ready' }
|
||||
},
|
||||
_meta: { runtimeId: 'test' }
|
||||
})
|
||||
// The running app has turned hooks off but not yet written it to disk.
|
||||
callMock.mockResolvedValueOnce({
|
||||
id: 'settings',
|
||||
ok: true,
|
||||
result: { settings: { agentStatusHooksEnabled: false } },
|
||||
_meta: { runtimeId: 'runtime-1' }
|
||||
})
|
||||
}
|
||||
|
||||
await main(['agent', 'hooks', 'status', '--json'], userDataPath)
|
||||
|
||||
const payload: unknown = JSON.parse(String(vi.mocked(console.log).mock.calls.at(-1)?.[0]))
|
||||
expect(payload).toMatchObject({
|
||||
result: { enabled, appliedBy, settingsPath: databaseFile }
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
@@ -23,9 +23,11 @@ type AgentHookCommandResult = {
|
||||
// Covers managed-home verification, WSL identity, trust grant, and bounded app-server reap.
|
||||
const WSL_CODEX_PREPARE_TIMEOUT_MS = 50_000
|
||||
|
||||
async function getDataPath(): Promise<string> {
|
||||
return (
|
||||
(await getProfileStateLocation())?.dataFile ?? join(getDefaultUserDataPath(), 'orca-data.json')
|
||||
async function getSettingsPath(): Promise<string> {
|
||||
const { resolveAgentHookSettingsPath } =
|
||||
await import('../../main/persistence/profile-state/offline-access/profile-state-offline-settings.js')
|
||||
return resolveAgentHookSettingsPath(
|
||||
(await getProfileStateLocation()) ?? legacyProfileStateLocation()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -128,6 +130,17 @@ async function updateRunningRuntime(client: RuntimeClient, enabled: boolean): Pr
|
||||
return true
|
||||
}
|
||||
|
||||
/** Null when no runtime answers; a running app owns the live setting. */
|
||||
async function readRunningRuntimeHooksEnabled(client: RuntimeClient): Promise<boolean | null> {
|
||||
if (!(await client.getOfflineRuntimeAdmission()).reachable) {
|
||||
return null
|
||||
}
|
||||
const response = await client.call<{
|
||||
settings: Pick<GlobalSettings, 'agentStatusHooksEnabled'>
|
||||
}>('settings.get')
|
||||
return response.result.settings.agentStatusHooksEnabled !== false
|
||||
}
|
||||
|
||||
function localSuccess<TResult>(result: TResult): RuntimeRpcSuccess<TResult> {
|
||||
return {
|
||||
id: 'local',
|
||||
@@ -166,7 +179,7 @@ async function setAgentHooksEnabled(
|
||||
await import('../../main/agent-hooks/installation/managed-agent-hook-controls.js')
|
||||
const updatedRuntime = await updateRunningRuntime(client, enabled)
|
||||
const offlineUpdate = updatedRuntime ? null : await updateEnabledOnDisk(enabled)
|
||||
const settingsPath = offlineUpdate?.settingsPath ?? (await getDataPath())
|
||||
const settingsPath = offlineUpdate?.settingsPath ?? (await getSettingsPath())
|
||||
const statuses = updatedRuntime
|
||||
? getManagedAgentHookStatuses()
|
||||
: await applyAgentStatusHooksEnabled(enabled, offlineUpdate?.settings)
|
||||
@@ -199,14 +212,15 @@ export const AGENT_HOOK_HANDLERS: Record<string, CommandHandler> = {
|
||||
// Best effort: old or unavailable runtimes must not block Codex launch.
|
||||
}
|
||||
},
|
||||
'agent hooks status': async ({ json, flags }) => {
|
||||
'agent hooks status': async ({ client, json, flags }) => {
|
||||
rejectRemoteHookSelection(flags)
|
||||
const { getManagedAgentHookStatuses } =
|
||||
await import('../../main/agent-hooks/installation/managed-agent-hook-controls.js')
|
||||
const runtimeEnabled = await readRunningRuntimeHooksEnabled(client)
|
||||
const result: AgentHookCommandResult = {
|
||||
enabled: (await readHookSettingsFromDisk()).agentStatusHooksEnabled,
|
||||
settingsPath: await getDataPath(),
|
||||
appliedBy: 'offline',
|
||||
enabled: runtimeEnabled ?? (await readHookSettingsFromDisk()).agentStatusHooksEnabled,
|
||||
settingsPath: await getSettingsPath(),
|
||||
appliedBy: runtimeEnabled === null ? 'offline' : 'runtime',
|
||||
statuses: getManagedAgentHookStatuses()
|
||||
}
|
||||
printResult(localSuccess(result), json, formatAgentHookCommandResult)
|
||||
|
||||
@@ -65,6 +65,10 @@ export async function main(
|
||||
return
|
||||
}
|
||||
if (argv[0] === 'claude-teams') {
|
||||
if (argv.length === 2 && (argv[1] === '--help' || argv[1] === '-h')) {
|
||||
printHelp(COMMAND_SPECS, ['claude-teams'])
|
||||
return
|
||||
}
|
||||
await runClaudeTeams(argv.slice(1), cwd)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ export const ROOT_HELP_TEXT_PRIMARY = [
|
||||
' skills install Install bundled Orca skills globally via the community skills CLI',
|
||||
' skills update Update Orca skills to the version this Orca build ships',
|
||||
'',
|
||||
'Artifacts:',
|
||||
' artifacts Publish, list, update, and manage shared Orca artifacts',
|
||||
'',
|
||||
'Hosts:',
|
||||
' host list List targetable machines and how to name each one',
|
||||
' host rm Remove a saved SSH target',
|
||||
@@ -119,6 +122,8 @@ export const ROOT_HELP_TEXT_PRIMARY = [
|
||||
'',
|
||||
'Agents:',
|
||||
' agent launch Start an agent in a worktree, as a chat or terminal per your settings',
|
||||
' agent hooks Inspect and toggle Orca agent lifecycle hooks',
|
||||
' claude-teams Start Claude Code Agent Teams in the current Orca terminal',
|
||||
'',
|
||||
'Chats:',
|
||||
' chat rename Rename a chat tab',
|
||||
@@ -192,7 +197,10 @@ export const ROOT_HELP_TEXT_PRIMARY = [
|
||||
'Linear:',
|
||||
' linear Read and write Linear issues for agents',
|
||||
'',
|
||||
'Mobile Emulator (iOS Simulator):',
|
||||
'Jira:',
|
||||
' jira Read and write Jira issues for agents',
|
||||
'',
|
||||
'Mobile Emulator (iOS Simulator / Android):',
|
||||
" emulator list List the worktree's attached emulator sessions (iOS and Android)",
|
||||
' emulator attach <device> Attach/start helper and make active for the worktree',
|
||||
' emulator tap <x> <y> Tap at normalized 0..1 coords (preferred for single taps)',
|
||||
|
||||
@@ -5,13 +5,11 @@ import { join } from 'node:path'
|
||||
import { afterAll, describe, expect, it } from 'vitest'
|
||||
import type { AgentJournalMessageItem } from '../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { NativeChatBlock } from '../../../shared/native-chat/native-chat-types'
|
||||
import { AcpPromptContentError, acpDispatchPrompt, acpPromptBlocks } from './acp-prompt-content'
|
||||
import { AcpPromptContentError, acpPromptBlocks } from './acp-prompt-content'
|
||||
|
||||
const PNG = Buffer.from('89504e470d0a1a0a', 'hex')
|
||||
const dir = mkdtempSync(join(tmpdir(), 'acp-prompt-content-'))
|
||||
afterAll(() => rmSync(dir, { recursive: true, force: true }))
|
||||
const pngPath = join(dir, 'shot.png')
|
||||
writeFileSync(pngPath, PNG)
|
||||
|
||||
function message(...blocks: NativeChatBlock[]): AgentJournalMessageItem {
|
||||
return { kind: 'message', role: 'user', blocks }
|
||||
@@ -26,14 +24,6 @@ async function refusal(body: AgentJournalMessageItem, images = true) {
|
||||
}
|
||||
|
||||
describe('ACP prompt content', () => {
|
||||
it('refuses a withheld command typed with arguments', async () => {
|
||||
const result = await acpDispatchPrompt(message({ type: 'text', text: '/allow-all on' }), {
|
||||
spec: { agent: 'copilot', dialect: { withheldCommands: ['allow-all'] } },
|
||||
connection: { initialize: async () => ({ protocolVersion: 1 }) }
|
||||
})
|
||||
expect(Array.isArray(result)).toBe(false)
|
||||
})
|
||||
|
||||
it('sends a host image up to 20 MiB inline and keeps a larger one as a path', async () => {
|
||||
const inlinePath = join(dir, 'photo.png')
|
||||
writeFileSync(inlinePath, Buffer.alloc(20 * 1024 * 1024))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { extname, isAbsolute } from 'node:path'
|
||||
import { isAbsolute } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import {
|
||||
agentSessionFailureFact,
|
||||
@@ -11,7 +11,10 @@ import {
|
||||
} from '../../../shared/agent-session/failures/agent-session-failure-words'
|
||||
import { formatNativeChatFileReference } from '../../../shared/agent-image-paste'
|
||||
import type { AgentJournalMessageItem } from '../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import { IMAGE_FILE_MIME_TYPES } from '../../../shared/file-preview/image-mime-types'
|
||||
import {
|
||||
agentInlineImageMimeType,
|
||||
isAgentInlineImageMimeType
|
||||
} from '../../../shared/agent-inline-image-types'
|
||||
import type { NativeChatImageRefBlock } from '../../../shared/native-chat/native-chat-types'
|
||||
import {
|
||||
NodeFileReadTooLargeError,
|
||||
@@ -24,7 +27,6 @@ import type { AcpStructuredConnection } from '../process/acp-structured-connecti
|
||||
import { acpSessionAcceptsImages } from '../protocol/acp-image-capability'
|
||||
import type { ContentBlock } from '../generated/acp-protocol.generated'
|
||||
|
||||
const ACP_IMAGE_MIME_TYPES = new Set(['image/png', 'image/jpeg', 'image/gif', 'image/webp'])
|
||||
// Reserve space for the JSON-RPC envelope around the prompt blocks.
|
||||
const ACP_PROMPT_LINE_BUDGET = ACP_MAX_LINE_BYTES - 64 * 1024
|
||||
// Budget raw images for base64's 4:3 expansion and leave room for text.
|
||||
@@ -65,7 +67,7 @@ async function imageBlock(
|
||||
): Promise<{ block: ContentBlock; bytes: number }> {
|
||||
if (block.url?.startsWith('data:')) {
|
||||
const match = /^data:(image\/[a-z]+);base64,([A-Za-z0-9+/]*={0,2})$/.exec(block.url)
|
||||
if (!match || !ACP_IMAGE_MIME_TYPES.has(match[1]) || match[2].length % 4 !== 0) {
|
||||
if (!match || !isAgentInlineImageMimeType(match[1]) || match[2].length % 4 !== 0) {
|
||||
throw attachmentProblem({ reason: 'unsupportedType' })
|
||||
}
|
||||
const bytes = Buffer.byteLength(match[2], 'base64')
|
||||
@@ -84,13 +86,13 @@ async function imageBlock(
|
||||
if (!path) {
|
||||
throw attachmentProblem({ reason: 'noSource' })
|
||||
}
|
||||
const mimeType = IMAGE_FILE_MIME_TYPES[extname(path).toLowerCase()]
|
||||
const mimeType = agentInlineImageMimeType(path)
|
||||
const fallback = {
|
||||
block: { type: 'text' as const, text: formatNativeChatFileReference(path) },
|
||||
bytes: 0
|
||||
}
|
||||
const maxBytes = Math.min(remainingBytes, ACP_PROMPT_PER_IMAGE_MAX_BYTES)
|
||||
if (!mimeType || !ACP_IMAGE_MIME_TYPES.has(mimeType) || maxBytes <= 0) {
|
||||
if (!mimeType || maxBytes <= 0) {
|
||||
return fallback
|
||||
}
|
||||
let data: Buffer
|
||||
@@ -155,7 +157,7 @@ export async function acpPromptBlocks(
|
||||
}
|
||||
const previousBytes = blockBytes(blocks[index]!)
|
||||
const path = hostImagePath(block)
|
||||
const mimeType = IMAGE_FILE_MIME_TYPES[extname(path ?? '').toLowerCase()] ?? ''
|
||||
const mimeType = agentInlineImageMimeType(path ?? '') ?? ''
|
||||
const overhead = blockBytes({ type: 'image', mimeType, data: '' })
|
||||
const encodedCapacity =
|
||||
encodedBytes > ACP_PROMPT_LINE_BUDGET
|
||||
|
||||
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { runProcess } from '@orca/process-host'
|
||||
import { removeTree } from '../../../../shared/windows-transient-lock-removal'
|
||||
import '../../../claude/hook-settings'
|
||||
import '../../../claude/hooks/hook-settings'
|
||||
import { wrapWindowsBatchHookCommand } from './windows-direct-cmd-hook-command'
|
||||
import './testing/windows-git-bash-path.test-fixture'
|
||||
import { getWindowsPowerShellExecutablePath } from './windows-powershell-hook-launcher'
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
isAgentStatusHooksEnabled,
|
||||
isAgentStatusHooksEnabledForAgent
|
||||
} from '../../../shared/agent-hook-listener/configuration/agent-status-hooks-setting'
|
||||
import { probeClaudeCliVersion } from '../../claude/claude-hook-event-versions'
|
||||
import { probeClaudeCliVersion } from '../../claude/cli-capabilities/claude-hook-event-versions'
|
||||
import { detectLocalManagedAgentCliPresence } from './local-agent-cli-presence'
|
||||
import {
|
||||
MANAGED_AGENT_HOOK_ASYNC_REMOVERS,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { MANAGED_AGENT_HOOK_TARGETS } from '../../../shared/managed-agent-hook-t
|
||||
import { normalizeDisabledTuiAgents } from '../../../shared/agent-launch/catalog/tui-agent-selection'
|
||||
import type { GlobalSettings } from '../../../shared/global-settings-types'
|
||||
import type { TuiAgentDetectionCommand } from '../../../shared/agent-launch/catalog/tui-agent-detection-commands'
|
||||
import { parseClaudeCliVersionOutput } from '../../claude/claude-hook-event-versions'
|
||||
import { parseClaudeCliVersionOutput } from '../../claude/cli-capabilities/claude-hook-event-versions'
|
||||
|
||||
export type ManagedHookDetectionSettings = Partial<
|
||||
Pick<
|
||||
|
||||
@@ -4,7 +4,7 @@ vi.mock('electron', () => ({ app: { getPath: () => '/tmp/userData' } }))
|
||||
|
||||
import { runVendorHook } from './testing/vendor-hook-delivery.test-fixture'
|
||||
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../claude/hook-service'
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../claude/hooks/hook-script'
|
||||
import { getManagedScript as getCursorManagedScript } from '../../../cursor/hook-script'
|
||||
|
||||
const CLAUDE_SCRIPT_OPTIONS = {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('electron', () => ({ app: { getPath: () => '/tmp/userData' } }))
|
||||
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../claude/hook-service'
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../claude/hooks/hook-script'
|
||||
import { getManagedScript as getCursorManagedScript } from '../../../cursor/hook-script'
|
||||
import { runVendorHook } from './testing/vendor-hook-delivery.test-fixture'
|
||||
|
||||
|
||||
@@ -1,284 +0,0 @@
|
||||
// POSIX hooks drain before exit; Windows missing-context hooks may exit without owning stdin.
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as CodexHookHashLookup from '../../../codex/trust/hooks/codex-hook-hash-lookup'
|
||||
import { spawnProcess } from '@orca/process-host'
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
import type * as osModule from 'node:os'
|
||||
import type * as NativeHookExecutableModule from '../commands/windows-native-hook-executable'
|
||||
|
||||
let isolatedUserDataDir = ''
|
||||
let previousUserDataPath: string | undefined
|
||||
|
||||
beforeEach(() => {
|
||||
vi.stubEnv('GROK_HOME', undefined)
|
||||
vi.stubEnv('KIMI_CODE_HOME', undefined)
|
||||
vi.stubEnv('COPILOT_HOME', undefined)
|
||||
vi.stubEnv('KIRO_HOME', undefined)
|
||||
vi.stubEnv('XDG_CONFIG_HOME', undefined)
|
||||
previousUserDataPath = process.env.ORCA_USER_DATA_PATH
|
||||
isolatedUserDataDir = mkdtempSync(join(tmpdir(), 'orca-hook-stdin-user-data-'))
|
||||
// Isolate managed-script resolution so inherited user-data paths cannot target live hooks.
|
||||
process.env.ORCA_USER_DATA_PATH = isolatedUserDataDir
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
if (previousUserDataPath === undefined) {
|
||||
delete process.env.ORCA_USER_DATA_PATH
|
||||
} else {
|
||||
process.env.ORCA_USER_DATA_PATH = previousUserDataPath
|
||||
}
|
||||
rmSync(isolatedUserDataDir, { recursive: true, force: true })
|
||||
vi.unstubAllEnvs()
|
||||
})
|
||||
|
||||
const { homedirMock, bundledHook } = vi.hoisted(() => {
|
||||
const bundledHook: { path: string | null } = { path: null }
|
||||
return { homedirMock: vi.fn<() => string>(), bundledHook }
|
||||
})
|
||||
|
||||
// Test the real built executable without packaged resource lookup.
|
||||
vi.mock('../commands/windows-native-hook-executable', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof NativeHookExecutableModule>()),
|
||||
resolveBundledWindowsNativeHookExecutable: () => bundledHook.path
|
||||
}))
|
||||
|
||||
vi.mock('../../../codex/trust/hooks/codex-hook-hash-lookup', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof CodexHookHashLookup>()),
|
||||
resolveCodexHookAnswerForLaunch: async () =>
|
||||
(
|
||||
await import('../../../codex/hooks/installation/hook-service-test-harness')
|
||||
).codexHookAnswerForTests()
|
||||
}))
|
||||
|
||||
vi.mock('electron', () => ({
|
||||
app: {
|
||||
getPath: () => '/tmp/orca-user-data'
|
||||
}
|
||||
}))
|
||||
|
||||
vi.mock('os', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof osModule>()
|
||||
return {
|
||||
...actual,
|
||||
homedir: homedirMock.mockImplementation(actual.homedir)
|
||||
}
|
||||
})
|
||||
|
||||
import '../../../antigravity/hook-service'
|
||||
import { ClaudeHookService } from '../../../claude/hook-service'
|
||||
import '../../../claude/hook-settings'
|
||||
import '../../../codex/hooks/installation/hook-service'
|
||||
import '../../../codex/hooks/installation/codex-hook-service-implementation'
|
||||
import '../../../command-code/hook-service'
|
||||
import '../../../copilot/hook-service'
|
||||
import '../../../cursor/hook-service'
|
||||
import '../../../devin/hook-service'
|
||||
import '../../../droid/hook-service'
|
||||
import '../../../gemini/hook-service'
|
||||
import '../../../grok/hook-service'
|
||||
import '../../../kimi/hook-service'
|
||||
|
||||
import '../../../openclaude/hook-service'
|
||||
|
||||
import { POSIX_HOOK_STDIN_READER } from './hook-stdin-contract'
|
||||
import '../commands/runtime-home-hook-command'
|
||||
import '../remote/testing/agent-hook-memory-sftp.test-fixture'
|
||||
import { findGitBash } from '../commands/testing/windows-git-bash-path.test-fixture'
|
||||
import {
|
||||
WINDOWS_POWERSHELL_WARM_UP_TIMEOUT_MS,
|
||||
warmWindowsEncodedPowerShell
|
||||
} from '../commands/testing/windows-powershell-warm-up.test-fixture'
|
||||
import {
|
||||
buildWindowsNativeHookExecutable,
|
||||
WINDOWS_NATIVE_HOOK_BUILD_TIMEOUT_MS
|
||||
} from '../commands/testing/windows-native-hook-exe.test-fixture'
|
||||
|
||||
const REMOTE_HOME = '/home/dev'
|
||||
const LARGE_PAYLOAD = Buffer.alloc(1_000_000, 'x')
|
||||
|
||||
// Seed the user's usual AutoRun target so profile redirection cannot introduce cmd stderr noise.
|
||||
function seedCmdAutoRunTarget(profileDir: string): void {
|
||||
mkdirSync(profileDir, { recursive: true })
|
||||
writeFileSync(join(profileDir, '.cmd_aliases.cmd'), '@echo off\r\n', 'utf8')
|
||||
}
|
||||
|
||||
type HookRun = {
|
||||
exitCode: number | null
|
||||
stdinErrors: NodeJS.ErrnoException[]
|
||||
stderr: string
|
||||
stdout: string
|
||||
}
|
||||
|
||||
function runHookProcess(
|
||||
executable: string,
|
||||
args: string[],
|
||||
env: NodeJS.ProcessEnv,
|
||||
// An open, unwritten pipe exposes read-to-EOF hangs outside an Orca pane.
|
||||
stdin: 'close' | 'abandon' = 'close'
|
||||
): Promise<HookRun> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawnProcess({
|
||||
program: executable,
|
||||
args,
|
||||
env,
|
||||
stdio: 'pipe'
|
||||
})
|
||||
const stdinErrors: NodeJS.ErrnoException[] = []
|
||||
let stderr = ''
|
||||
let stdout = ''
|
||||
const timeout = setTimeout(() => {
|
||||
child.stdin.destroy()
|
||||
child.kill('SIGKILL')
|
||||
reject(
|
||||
new Error(
|
||||
`hook did not finish with stdin ${stdin}d: ${executable} ${args.join(' ').slice(0, 200)}`
|
||||
)
|
||||
)
|
||||
}, 10_000)
|
||||
child.on('error', (error) => {
|
||||
clearTimeout(timeout)
|
||||
reject(error)
|
||||
})
|
||||
child.stdout.on('data', (chunk: Buffer) => {
|
||||
stdout += chunk.toString()
|
||||
})
|
||||
child.stderr.on('data', (chunk: Buffer) => {
|
||||
stderr += chunk.toString()
|
||||
})
|
||||
child.stdin.on('error', (error: NodeJS.ErrnoException) => stdinErrors.push(error))
|
||||
child.on('close', (exitCode) => {
|
||||
clearTimeout(timeout)
|
||||
resolve({ exitCode, stdinErrors, stderr, stdout })
|
||||
})
|
||||
if (stdin === 'close') {
|
||||
child.stdin.end(LARGE_PAYLOAD)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function hookEnvironment(extraEnv: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
|
||||
const env = Object.fromEntries(
|
||||
Object.entries(process.env).filter(([key]) => !key.startsWith('ORCA_'))
|
||||
)
|
||||
return {
|
||||
...env,
|
||||
HOME: REMOTE_HOME,
|
||||
ORCA_AGENT_HOOK_ENDPOINT: '',
|
||||
...extraEnv
|
||||
}
|
||||
}
|
||||
|
||||
describe('Windows managed hook stdin structure', () => {
|
||||
beforeAll(async () => {
|
||||
if (process.platform === 'win32') {
|
||||
await warmWindowsEncodedPowerShell(hookEnvironment())
|
||||
}
|
||||
}, WINDOWS_POWERSHELL_WARM_UP_TIMEOUT_MS)
|
||||
|
||||
// Command-shape assertions missed conhost discarding the consumer's JSON output.
|
||||
it.skipIf(process.platform !== 'win32').each([
|
||||
{ form: 'claude-hook.cmd', bundled: false },
|
||||
{ form: 'orca-agent-hook.exe claude', bundled: true }
|
||||
])(
|
||||
'emits parseable JSON on stdout from the registered Claude hook command ($form), through cmd.exe and Git Bash',
|
||||
async ({ form, bundled }) => {
|
||||
const home = mkdtempSync(join(tmpdir(), 'orca-hook-stdout-json-'))
|
||||
homedirMock.mockReturnValue(home)
|
||||
const absentProfile = join(home, 'absent')
|
||||
seedCmdAutoRunTarget(home)
|
||||
seedCmdAutoRunTarget(absentProfile)
|
||||
try {
|
||||
bundledHook.path = bundled ? buildWindowsNativeHookExecutable() : null
|
||||
expect(new ClaudeHookService().install().state).toBe('installed')
|
||||
const settings = JSON.parse(
|
||||
readFileSync(join(home, '.claude', 'settings.json'), 'utf8')
|
||||
) as { hooks: Record<string, { hooks: { command: string; args?: string[] }[] }[]> }
|
||||
const entry = settings.hooks.PreToolUse[0].hooks[0]
|
||||
expect(entry.args).toBeUndefined()
|
||||
expect(entry.command.endsWith(form)).toBe(true)
|
||||
|
||||
// MSYS rewrites paths and switches, so exercise both shells.
|
||||
const gitBash = findGitBash()
|
||||
const shells = [
|
||||
{ name: 'cmd.exe', executable: 'cmd.exe', args: ['/d', '/c', entry.command] },
|
||||
{ name: 'Git Bash', executable: gitBash, args: ['-c', entry.command] }
|
||||
]
|
||||
const environments = [
|
||||
{ name: 'no Orca env', env: hookEnvironment({ USERPROFILE: home }) },
|
||||
{
|
||||
name: 'Orca env with dead listener',
|
||||
env: hookEnvironment({
|
||||
USERPROFILE: home,
|
||||
ORCA_AGENT_HOOK_PORT: '59999',
|
||||
ORCA_AGENT_HOOK_TOKEN: 'token',
|
||||
ORCA_PANE_KEY: 'tab:leaf'
|
||||
})
|
||||
},
|
||||
{
|
||||
// Profile redirection hides runtime-resolved scripts; direct launchers retain their absolute path.
|
||||
name: 'missing managed script',
|
||||
env: hookEnvironment({ USERPROFILE: absentProfile })
|
||||
}
|
||||
]
|
||||
for (const shell of shells) {
|
||||
for (const environment of environments) {
|
||||
const label = `${shell.name} / ${environment.name}`
|
||||
const result = await runHookProcess(shell.executable, shell.args, environment.env)
|
||||
expect(result.exitCode, `${label} exit code`).toBe(0)
|
||||
expect(result.stderr, `${label} stderr`).toBe('')
|
||||
expect(() => JSON.parse(result.stdout.trim()), `${label} stdout is JSON`).not.toThrow()
|
||||
expect(JSON.parse(result.stdout.trim()), `${label} stdout`).toEqual({})
|
||||
}
|
||||
if (bundled) {
|
||||
const abandoned = await runHookProcess(
|
||||
shell.executable,
|
||||
shell.args,
|
||||
environments[0].env,
|
||||
'abandon'
|
||||
)
|
||||
expect(abandoned.exitCode, `${shell.name} abandoned-stdin exit code`).toBe(0)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
bundledHook.path = null
|
||||
homedirMock.mockImplementation(() => process.env.HOME ?? tmpdir())
|
||||
rmSync(home, { recursive: true, force: true })
|
||||
}
|
||||
},
|
||||
// Allow cold executable builds and six shell launches under load.
|
||||
WINDOWS_NATIVE_HOOK_BUILD_TIMEOUT_MS
|
||||
)
|
||||
})
|
||||
|
||||
describe.skipIf(process.platform === 'win32')('managed hook stdin lifecycle', () => {
|
||||
// Exit zero does not prove stdin was consumed; measure captured bytes.
|
||||
it.each([
|
||||
['empty PATH', ''],
|
||||
// NixOS may lack /bin/cat; exercise the shell's default PATH.
|
||||
['PATH without coreutils', '/nonexistent'],
|
||||
['PATH whose first cat is a decoy', '']
|
||||
])('captures the whole payload with %s', async (label, pathValue) => {
|
||||
const decoyDir = mkdtempSync(join(tmpdir(), 'orca-hook-stdin-decoy-'))
|
||||
try {
|
||||
let effectivePath = pathValue
|
||||
if (label === 'PATH whose first cat is a decoy') {
|
||||
const decoy = join(decoyDir, 'cat')
|
||||
writeFileSync(decoy, '#!/bin/sh\nexit 0\n', { mode: 0o755 })
|
||||
effectivePath = decoyDir
|
||||
}
|
||||
const result = await runHookProcess(
|
||||
'/bin/sh',
|
||||
['-c', `payload=$(${POSIX_HOOK_STDIN_READER}); printf '%s' "${'${#payload}'}"`],
|
||||
{ ...hookEnvironment(), PATH: effectivePath }
|
||||
)
|
||||
expect(result.exitCode, `${label} exit code`).toBe(0)
|
||||
expect(result.stdinErrors, `${label} stdin errors`).toHaveLength(0)
|
||||
expect(result.stdout, `${label} captured bytes`).toBe(String(LARGE_PAYLOAD.length))
|
||||
} finally {
|
||||
rmSync(decoyDir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { AgentHookServer, _internals } from '../../agent-hook-server'
|
||||
import { buildBody, ingestProgramStatusOsc, postHookEvent } from '../server.test-fixtures'
|
||||
|
||||
vi.mock('../../../../telemetry/client', () => ({ track: vi.fn() }))
|
||||
vi.mock('../../../../telemetry/cohort-classifier', () => ({
|
||||
getCohortAtEmit: () => ({ nth_repo_added: 2 })
|
||||
}))
|
||||
|
||||
describe('The Claude model across a restart', () => {
|
||||
let userDataPath: string
|
||||
|
||||
beforeEach(() => {
|
||||
_internals.resetCachesForTests()
|
||||
userDataPath = mkdtempSync(join(tmpdir(), 'orca-claude-model-'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
rmSync(userDataPath, { recursive: true, force: true })
|
||||
})
|
||||
|
||||
it.each([
|
||||
{ saved: 'working', next: 'Stop', osc: false },
|
||||
{ saved: 'done', next: 'UserPromptSubmit', osc: false },
|
||||
// Claude reports OSC 7501 `working` just before UserPromptSubmit.
|
||||
{ saved: 'done', next: 'UserPromptSubmit', osc: true }
|
||||
])(
|
||||
'keeps the SessionStart model after a $saved restart (OSC first: $osc)',
|
||||
async ({ saved, next, osc }) => {
|
||||
const firstServer = new AgentHookServer()
|
||||
await firstServer.start({ env: 'production', userDataPath })
|
||||
await postHookEvent(
|
||||
firstServer,
|
||||
buildBody({ hook_event_name: 'SessionStart', source: 'startup', model: 'claude-opus-5-5' })
|
||||
)
|
||||
await postHookEvent(
|
||||
firstServer,
|
||||
buildBody({ hook_event_name: 'UserPromptSubmit', prompt: 'hi' })
|
||||
)
|
||||
if (saved === 'done') {
|
||||
await postHookEvent(firstServer, buildBody({ hook_event_name: 'Stop' }))
|
||||
}
|
||||
firstServer.flushStatusPersistSync()
|
||||
firstServer.stop()
|
||||
|
||||
const server = new AgentHookServer()
|
||||
await server.start({ env: 'production', userDataPath })
|
||||
try {
|
||||
if (osc) {
|
||||
ingestProgramStatusOsc(server, '\x1b]7501;state=working:app=claude-code\x1b\\')
|
||||
}
|
||||
await postHookEvent(server, buildBody({ hook_event_name: next, prompt: 'next' }))
|
||||
expect(server.getStatusSnapshot()[0]?.model).toBe('claude-opus-5-5')
|
||||
} finally {
|
||||
server.stop()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
@@ -1,8 +1,6 @@
|
||||
import { readSavedStatus } from '../persistence/last-status.test-fixtures'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
appendFileSync,
|
||||
chmodSync,
|
||||
mkdirSync,
|
||||
mkdtempSync,
|
||||
readFileSync,
|
||||
@@ -19,10 +17,9 @@ import {
|
||||
launchTokenHash,
|
||||
type SpoolRecord
|
||||
} from '../../../../../shared/agent-hook-listener/transport/agent-hook-spool'
|
||||
import { AgentHookServer, _internals } from '../../agent-hook-server'
|
||||
import { buildBody } from '../server.test-fixtures'
|
||||
import { _internals as codexInternals } from '../../../../codex/hooks/installation/hook-service'
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../../claude/hook-script'
|
||||
import { AgentHookServer } from '../../agent-hook-server'
|
||||
|
||||
import { getManagedScript as getClaudeManagedScript } from '../../../../claude/hooks/hook-script'
|
||||
import { makePaneKey } from '../../../../../shared/workspace-layout/stable-pane-id'
|
||||
|
||||
describe('agent hook spool', () => {
|
||||
@@ -102,49 +99,6 @@ describe('agent hook spool', () => {
|
||||
expect(statSync(file).ino).toBe(inode)
|
||||
})
|
||||
|
||||
it('replays a spooled Codex SubagentStop through the server after restart', async () => {
|
||||
const userDataPath = mkdtempSync(join(tmpdir(), 'orca-spool-e2e-'))
|
||||
const paneKey = makePaneKey('tab-spool', '00000000-0000-4000-8000-000000000001')
|
||||
const launchToken = 'generation-token'
|
||||
const first = new AgentHookServer()
|
||||
await first.start({ env: 'production', userDataPath })
|
||||
const started = _internals.normalizeHookPayload(
|
||||
'codex',
|
||||
buildBody({ hook_event_name: 'SubagentStart', agent_id: 'child-spooled' }),
|
||||
'production'
|
||||
)!
|
||||
first.ingestRemote(
|
||||
{
|
||||
paneKey,
|
||||
source: 'codex',
|
||||
hookEventName: 'SubagentStart',
|
||||
launchToken,
|
||||
payload: started.payload
|
||||
},
|
||||
'spool-test'
|
||||
)
|
||||
expect(first.getStatusSnapshot()).toHaveLength(1)
|
||||
first.flushStatusPersistSync()
|
||||
first.stop()
|
||||
const spoolDir = join(userDataPath, 'agent-hooks', 'spool')
|
||||
mkdirSync(spoolDir, { recursive: true })
|
||||
writeFileSync(
|
||||
join(spoolDir, 'pane-tab-spooled_0.jsonl'),
|
||||
`\n${JSON.stringify({ paneKey, source: 'codex', hookEventName: 'SubagentStop', launchToken, receivedAt: Date.now(), payload: { hook_event_name: 'SubagentStop', agent_id: 'child-spooled' } })}\n`
|
||||
)
|
||||
const restarted = new AgentHookServer()
|
||||
await restarted.start({ env: 'production', userDataPath })
|
||||
try {
|
||||
const snapshot = restarted.getStatusSnapshot()
|
||||
expect(snapshot).toHaveLength(1)
|
||||
expect(snapshot[0]!.subagents).toBeUndefined()
|
||||
restarted.flushStatusPersistSync()
|
||||
expect(readSavedStatus(restarted.lastStatusPath!)).not.toContain('isReplay')
|
||||
} finally {
|
||||
restarted.stop()
|
||||
}
|
||||
})
|
||||
|
||||
it('rejects a stale remote replay against the hydrated launch-token fence', async () => {
|
||||
const userDataPath = mkdtempSync(join(tmpdir(), 'orca-spool-remote-fence-'))
|
||||
const paneKey = makePaneKey('tab-remote-fence', '00000000-0000-4000-8000-000000000003')
|
||||
@@ -186,37 +140,6 @@ describe('agent hook spool', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('spools when the endpoint is present but the receiver is unavailable', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'orca-spool-failure-'))
|
||||
const endpointDir = join(dir, 'agent-hooks')
|
||||
mkdirSync(endpointDir, { recursive: true })
|
||||
const endpoint = join(endpointDir, 'endpoint.env')
|
||||
writeFileSync(
|
||||
endpoint,
|
||||
'ORCA_AGENT_HOOK_PORT=9\nORCA_AGENT_HOOK_TOKEN=stale\nORCA_AGENT_HOOK_ENV=production\nORCA_AGENT_HOOK_VERSION=1\n'
|
||||
)
|
||||
const script = join(dir, 'codex-hook.sh')
|
||||
writeFileSync(script, codexInternals.getManagedScript('posix'))
|
||||
chmodSync(script, 0o755)
|
||||
execFileSync('/bin/sh', [script], {
|
||||
input: '{"hook_event_name":"SubagentStop","agent_id":"child"}\n',
|
||||
env: {
|
||||
...process.env,
|
||||
ORCA_AGENT_HOOK_ENDPOINT: endpoint,
|
||||
ORCA_PANE_KEY: 'tab-failure:0',
|
||||
ORCA_TAB_ID: 'tab-failure',
|
||||
ORCA_AGENT_LAUNCH_TOKEN: 'generation-token',
|
||||
CLAUDE_JOB_DIR: ''
|
||||
},
|
||||
timeout: 5000
|
||||
})
|
||||
const spoolFiles = readdirSync(join(endpointDir, 'spool'))
|
||||
expect(spoolFiles).toHaveLength(1)
|
||||
expect(readFileSync(join(endpointDir, 'spool', spoolFiles[0]!), 'utf8')).toContain(
|
||||
'SubagentStop'
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps a Claude hook attributed when CLAUDE_CODE_SUBPROCESS_ENV_SCRUB drops the pane key', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'orca-spool-scrubbed-'))
|
||||
const endpointDir = join(dir, 'agent-hooks')
|
||||
@@ -278,42 +201,4 @@ describe('agent hook spool', () => {
|
||||
expect(records).toHaveLength(1)
|
||||
expect(records[0]).toContain('"Stop"')
|
||||
})
|
||||
|
||||
it('does not mark a non-terminal downtime replay as runtime-observed', async () => {
|
||||
const userDataPath = mkdtempSync(join(tmpdir(), 'orca-spool-observed-'))
|
||||
const paneKey = makePaneKey('tab-observed', '00000000-0000-4000-8000-000000000002')
|
||||
const launchToken = 'observed-generation'
|
||||
const first = new AgentHookServer()
|
||||
await first.start({ env: 'production', userDataPath })
|
||||
const started = _internals.normalizeHookPayload(
|
||||
'codex',
|
||||
buildBody({ hook_event_name: 'SubagentStart', agent_id: 'child-observed' }),
|
||||
'production'
|
||||
)!
|
||||
first.ingestRemote(
|
||||
{
|
||||
paneKey,
|
||||
source: 'codex',
|
||||
hookEventName: 'SubagentStart',
|
||||
launchToken,
|
||||
payload: started.payload
|
||||
},
|
||||
null
|
||||
)
|
||||
first.flushStatusPersistSync()
|
||||
first.stop()
|
||||
const spoolDir = join(userDataPath, 'agent-hooks', 'spool')
|
||||
mkdirSync(spoolDir, { recursive: true })
|
||||
writeFileSync(
|
||||
join(spoolDir, 'pane-observed.jsonl'),
|
||||
`\n${JSON.stringify({ paneKey, source: 'codex', hookEventName: 'SubagentStart', launchToken, receivedAt: Date.now(), payload: started.payload })}\n`
|
||||
)
|
||||
const restarted = new AgentHookServer()
|
||||
await restarted.start({ env: 'production', userDataPath })
|
||||
try {
|
||||
expect(restarted.getStatusChangeSnapshot()[0]?.observedInCurrentRuntime).toBe(false)
|
||||
} finally {
|
||||
restarted.stop()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import type * as NodePath from 'node:path'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import type * as ClaudeFolderTrustFile from '../../claude/claude-folder-trust-file'
|
||||
import type * as ClaudeFolderTrustFile from '../../claude/configuration/claude-folder-trust-file'
|
||||
|
||||
const CODEX_CONFIG_FILES = ['/orca/codex-home/config.toml', '/home/u/.codex/config.toml']
|
||||
|
||||
@@ -47,7 +47,7 @@ vi.mock('../../codex/configuration/homes/codex-home-paths', () => ({
|
||||
getLocalCodexTrustConfigFiles: mocks.codexConfigFiles
|
||||
}))
|
||||
vi.mock('../../qoder/workspace-trust', () => ({ markQoderWorkspaceTrusted: mocks.qoder }))
|
||||
vi.mock('../../claude/claude-folder-trust-file', async (importOriginal) => {
|
||||
vi.mock('../../claude/configuration/claude-folder-trust-file', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof ClaudeFolderTrustFile>()
|
||||
mocks.claudeGrant.mockImplementation(actual.grantClaudeWorkspaceTrust)
|
||||
return { ...actual, grantClaudeWorkspaceTrust: mocks.claudeGrant }
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
SHORT_AGENT_TRUST_WRITE_DEADLINE_MS
|
||||
} from './agent-trust-write-deadline'
|
||||
import type { AgentTrustPreset } from './agent-trust-presets'
|
||||
import { resolveLocalClaudeTrustConfig } from '../../claude/claude-folder-trust-file'
|
||||
import { resolveLocalClaudeTrustConfig } from '../../claude/configuration/claude-folder-trust-file'
|
||||
import type { ClaudeRuntimeAuthPreparation } from '../../claude-accounts/runtime-auth/runtime-auth-types'
|
||||
import type { AgentWorkspaceTrustSpawnRequest } from '../../../shared/agent-launch/permissions/agent-workspace-trust-spawn-request'
|
||||
import { parseWslUncPath, toLinuxPath } from '../../../shared/wsl-paths'
|
||||
|
||||
@@ -14,7 +14,7 @@ import { awaitAgentTrustWriteWithinDeadline } from './agent-trust-write-deadline
|
||||
import {
|
||||
type ClaudeTrustConfigTarget,
|
||||
grantClaudeWorkspaceTrust
|
||||
} from '../../claude/claude-folder-trust-file'
|
||||
} from '../../claude/configuration/claude-folder-trust-file'
|
||||
import { isTooBroadToPreTrust } from '../../../shared/agent-launch/permissions/workspace-pretrust-scope'
|
||||
|
||||
/** Resolve trust on the agent’s execution host, including WSL guests and SSH relays. */
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
import { claudeProfileMissing } from './claude-profile-launch-errors'
|
||||
import type { GlobalSettings } from '../../../../shared/global-settings-types'
|
||||
import type { ClaudeManagedAccount } from '../../../../shared/managed-account-types'
|
||||
import { probeRecentClaudeCliVersion } from '../../../claude/claude-hook-event-versions'
|
||||
import { probeRecentClaudeCliVersion } from '../../../claude/cli-capabilities/claude-hook-event-versions'
|
||||
import { writeFileAtomically } from '../../../filesystem/atomic-file-publication'
|
||||
import { resolveClaudeCommand } from '../../../codex-cli/command'
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ClaudeProfileRouter, ClaudeProfileRouterSettings } from './claude-profile-router'
|
||||
import { claudeLaunchDestinationHome } from '../../../claude/claude-launch-destination-home'
|
||||
import { claudeLaunchDestinationHome } from '../../../claude/structured/launch/claude-launch-destination-home'
|
||||
|
||||
/** Every native switcher destination, even an account whose setup has not created its home. */
|
||||
export async function claudeProfileSelectionHomes(
|
||||
|
||||
@@ -5,7 +5,7 @@ import { isDefinitiveAbsence } from '../../../../shared/definitive-filesystem-ab
|
||||
import {
|
||||
resolveClaudeGlobalConfigFile,
|
||||
updateClaudeGlobalConfig
|
||||
} from '../../../claude/claude-folder-trust-file'
|
||||
} from '../../../claude/configuration/claude-folder-trust-file'
|
||||
import { publishFileWithoutOverwrite } from '../../../filesystem/atomic-file-publication'
|
||||
import { CLAUDE_PROFILE_HISTORY_DIRS, mergeClaudeProfileDirectory } from './claude-profile-history'
|
||||
import { readClaudeProfileObject, resolveClaudeDefaultHome } from '../claude-profile-paths'
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
readFileSync,
|
||||
realpathSync,
|
||||
rmSync,
|
||||
symlinkSync,
|
||||
writeFileSync
|
||||
} from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
@@ -115,12 +114,4 @@ describe('Claude account profile setup', () => {
|
||||
runtime: 'host'
|
||||
})
|
||||
})
|
||||
|
||||
itLinks('refuses a data root linked into the default home before writing there', async () => {
|
||||
const f = fixture()
|
||||
mkdirSync(join(f.defaultHome, 'inner'))
|
||||
symlinkSync(join(f.defaultHome, 'inner'), join(f.dataRoot, 'claude-profiles'))
|
||||
expect((await f.setup()).outcome).toBe('refused')
|
||||
expect(existsSync(join(f.defaultHome, 'inner', 'a'))).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { GlobalSettings } from '../../../shared/global-settings-types'
|
||||
import type { ClaudeManagedAccount } from '../../../shared/managed-account-types'
|
||||
import { isHostManagedClaudeAccount } from './environment'
|
||||
|
||||
import { claudeStructuredAuthPolicyForSettings } from './claude-structured-auth-policy'
|
||||
|
||||
const HOST_ACCOUNT = { id: 'host-a', managedAuthRuntime: 'host' } as ClaudeManagedAccount
|
||||
const WSL_ACCOUNT = { id: 'wsl-b', managedAuthRuntime: 'wsl' } as ClaudeManagedAccount
|
||||
const LEGACY_ACCOUNT = { id: 'legacy-c' } as ClaudeManagedAccount
|
||||
|
||||
function settings(
|
||||
overrides: Partial<
|
||||
Pick<
|
||||
GlobalSettings,
|
||||
| 'claudeManagedAccounts'
|
||||
| 'activeClaudeManagedAccountId'
|
||||
| 'activeClaudeManagedAccountIdsByRuntime'
|
||||
>
|
||||
>
|
||||
): Parameters<typeof claudeStructuredAuthPolicyForSettings>[0] {
|
||||
return {
|
||||
claudeManagedAccounts: [HOST_ACCOUNT, WSL_ACCOUNT, LEGACY_ACCOUNT],
|
||||
activeClaudeManagedAccountId: null,
|
||||
...overrides
|
||||
} as Parameters<typeof claudeStructuredAuthPolicyForSettings>[0]
|
||||
}
|
||||
|
||||
describe('isHostManagedClaudeAccount', () => {
|
||||
it('is true for a selected id no account list explains', () => {
|
||||
expect(isHostManagedClaudeAccount([HOST_ACCOUNT], 'deleted-d')).toBe(true)
|
||||
expect(isHostManagedClaudeAccount(undefined, 'deleted-d')).toBe(true)
|
||||
expect(isHostManagedClaudeAccount([], 'deleted-d')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('claudeStructuredAuthPolicyForSettings', () => {
|
||||
it('reads the host runtime selection, not the legacy flat field alone', () => {
|
||||
expect(
|
||||
claudeStructuredAuthPolicyForSettings(
|
||||
settings({
|
||||
activeClaudeManagedAccountId: 'host-a',
|
||||
activeClaudeManagedAccountIdsByRuntime: { host: null, wsl: {} }
|
||||
})
|
||||
)
|
||||
).toEqual({ account: 'managed' })
|
||||
})
|
||||
|
||||
it('ignores a WSL-only selection: the structured child is always a native host process', () => {
|
||||
expect(
|
||||
claudeStructuredAuthPolicyForSettings(
|
||||
settings({
|
||||
activeClaudeManagedAccountIdsByRuntime: { host: null, wsl: { Ubuntu: 'wsl-b' } }
|
||||
})
|
||||
)
|
||||
).toEqual({ account: 'system' })
|
||||
})
|
||||
})
|
||||
@@ -11,7 +11,7 @@ import { readFile, stat } from 'node:fs/promises'
|
||||
import { homedir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { z } from 'zod'
|
||||
import { resolveClaudeGlobalConfigFile } from '../../claude/claude-folder-trust-file'
|
||||
import { resolveClaudeGlobalConfigFile } from '../../claude/configuration/claude-folder-trust-file'
|
||||
import { execSecurityCommand } from '../../macos-keychain/generic-password'
|
||||
import { describeClaudeProfile, readClaudeProfileObject } from '../profiles/claude-profile-paths'
|
||||
import { claudeConfigDirSpellings, claudeKeychainService } from '../runtime-auth/keychain'
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { PassThrough } from 'node:stream'
|
||||
import { afterEach, expect, it, vi } from 'vitest'
|
||||
|
||||
const state = vi.hoisted(() => {
|
||||
const resolved: string[] = []
|
||||
const programs: string[] = []
|
||||
return { resolved, programs }
|
||||
})
|
||||
|
||||
vi.mock('@orca/process-host', () => ({
|
||||
spawnProcess: (spec: { program: string }) => {
|
||||
state.programs.push(spec.program)
|
||||
const child = Object.assign(new EventEmitter(), {
|
||||
stdin: new PassThrough(),
|
||||
stdout: new PassThrough(),
|
||||
stderr: new PassThrough(),
|
||||
pid: undefined,
|
||||
kill: vi.fn()
|
||||
})
|
||||
queueMicrotask(() =>
|
||||
spec.program.startsWith('/proc/')
|
||||
? child.emit(
|
||||
'error',
|
||||
Object.assign(new Error(`spawn ${spec.program} ENOENT`), { code: 'ENOENT' })
|
||||
)
|
||||
: child.emit('close', 0)
|
||||
)
|
||||
return child
|
||||
}
|
||||
}))
|
||||
vi.mock('../../codex-cli/command', () => ({
|
||||
resolveClaudeCommand: () => state.resolved.shift() ?? '/home/me/.local/bin/claude'
|
||||
}))
|
||||
|
||||
import { runClaudeCommandProcess } from './claude-command-process'
|
||||
|
||||
const WINDOWS_ONLY = '/proc/orca-agent-cli-installed-only-on-windows/claude'
|
||||
const config = { windowsPath: '/home/me/.claude', linuxPath: null, wslDistro: null }
|
||||
const originalPlatform = process.platform
|
||||
afterEach(() => {
|
||||
state.resolved.length = 0
|
||||
state.programs.length = 0
|
||||
Object.defineProperty(process, 'platform', { value: originalPlatform })
|
||||
})
|
||||
|
||||
it('never keeps the Windows-only answer, so a Claude installed in WSL since is used', async () => {
|
||||
Object.defineProperty(process, 'platform', { value: 'linux' })
|
||||
// The first lookup sees only the Windows copy; every later one finds the new WSL install.
|
||||
state.resolved.push(WINDOWS_ONLY)
|
||||
await expect(runClaudeCommandProcess(['auth', 'status'], config, 1000)).rejects.toThrow(
|
||||
'installed only on Windows'
|
||||
)
|
||||
await runClaudeCommandProcess(['auth', 'status'], config, 1000)
|
||||
expect(state.programs).toEqual([WINDOWS_ONLY, '/home/me/.local/bin/claude'])
|
||||
})
|
||||
+2
-4
@@ -1,15 +1,13 @@
|
||||
import { classifyClaudeBackgroundTaskKind } from '../../shared/claude-background-task-kind'
|
||||
import type {
|
||||
AgentSessionBackgroundTask,
|
||||
AgentSessionBackgroundTaskRunState
|
||||
} from '../../shared/agent-session/agent-session-background-task-wire'
|
||||
import { ownRetainedString } from '../../shared/own-retained-string'
|
||||
} from '../../../shared/agent-session/agent-session-background-task-wire'
|
||||
import { ownRetainedString } from '../../../shared/own-retained-string'
|
||||
|
||||
const MAX_TASK_ID_LENGTH = 512
|
||||
const MAX_TASK_TEXT_LENGTH = 512
|
||||
|
||||
export type ClaudeBackgroundTaskKind = AgentSessionBackgroundTask['kind']
|
||||
export { classifyClaudeBackgroundTaskKind }
|
||||
|
||||
export function record(value: unknown): Record<string, unknown> | null {
|
||||
return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : null
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
import type { AgentJournalItemIdentity } from '../../shared/agent-session/journal/agent-session-journal-identity'
|
||||
import { parseAgentJournalItemKey } from '../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
import type { AgentJournalProducerLinkage } from '../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import { isBackgroundTaskBlock } from '../../shared/native-chat/native-chat-types'
|
||||
import type { StructuredAgentSessionLifecycleJournal } from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-journal-views'
|
||||
import type { AgentJournalItemIdentity } from '../../../shared/agent-session/journal/agent-session-journal-identity'
|
||||
import { parseAgentJournalItemKey } from '../../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
import type { AgentJournalProducerLinkage } from '../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import { isBackgroundTaskBlock } from '../../../shared/native-chat/native-chat-types'
|
||||
import type { StructuredAgentSessionLifecycleJournal } from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-journal-views'
|
||||
|
||||
export type ClaudeBackgroundTaskDescriptor = {
|
||||
identity: AgentJournalItemIdentity
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { isSettledBackgroundTaskState } from '../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import { isSettledBackgroundTaskState } from '../../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import type { ClaudeBackgroundTaskRow } from './claude-background-task-row-lifecycle'
|
||||
|
||||
const MAX_GENERATION_ENTRIES = 512
|
||||
+3
-8
@@ -1,12 +1,7 @@
|
||||
import type { ClaudeTaskInvocations } from './claude-task-invocations'
|
||||
import { isSettledBackgroundTaskState } from '../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import {
|
||||
classifyClaudeBackgroundTaskKind,
|
||||
record,
|
||||
taskDescription,
|
||||
taskId,
|
||||
taskName
|
||||
} from './claude-background-task-frames'
|
||||
import { isSettledBackgroundTaskState } from '../../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import { classifyClaudeBackgroundTaskKind } from '../../../shared/claude-background-task-kind'
|
||||
import { record, taskDescription, taskId, taskName } from './claude-background-task-frames'
|
||||
import type {
|
||||
ClaudeBackgroundTaskChange,
|
||||
ClaudeBackgroundTaskRow
|
||||
+8
-14
@@ -1,29 +1,23 @@
|
||||
import type { AgentJournalItemIdentity } from '../../shared/agent-session/journal/agent-session-journal-identity'
|
||||
import type { AgentJournalTurnScope } from '../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import { backgroundTaskJournalBody } from '../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import { isBackgroundTaskBlock } from '../../shared/native-chat/native-chat-types'
|
||||
import type { AgentJournalItemIdentity } from '../../../shared/agent-session/journal/agent-session-journal-identity'
|
||||
import type { AgentJournalTurnScope } from '../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import { backgroundTaskJournalBody as claudeBackgroundTaskBody } from '../../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import { isBackgroundTaskBlock } from '../../../shared/native-chat/native-chat-types'
|
||||
import type {
|
||||
StructuredAgentSessionEventSink,
|
||||
StructuredAgentSessionSinkAdmission
|
||||
} from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import type { StructuredAgentSessionLifecycleJournal } from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-journal-views'
|
||||
} from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import type { StructuredAgentSessionLifecycleJournal } from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-journal-views'
|
||||
import type { ClaudeBackgroundTaskRow } from './claude-background-task-row-lifecycle'
|
||||
import { agentJournalItemKey } from '../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
import { estimateStructuredAgentSessionItemBytes } from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink-estimate'
|
||||
import { agentJournalItemKey } from '../../../shared/agent-session/journal/agent-session-journal-item-key'
|
||||
import { estimateStructuredAgentSessionItemBytes } from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink-estimate'
|
||||
import {
|
||||
claudeBackgroundTaskIdentity,
|
||||
resolveClaudeBackgroundTaskIdentity
|
||||
} from './claude-background-task-identity'
|
||||
export {
|
||||
claudeBackgroundTaskIdentity,
|
||||
resolveClaudeBackgroundTaskIdentity
|
||||
} from './claude-background-task-identity'
|
||||
|
||||
const MAX_RESOLVED_TASK_IDENTITIES = 512
|
||||
const ADMITTED: StructuredAgentSessionSinkAdmission = { accepted: true }
|
||||
|
||||
export const claudeBackgroundTaskBody = backgroundTaskJournalBody
|
||||
|
||||
export class ClaudeBackgroundTaskIdentityResolver {
|
||||
private journal: StructuredAgentSessionLifecycleJournal | null = null
|
||||
private epoch: string | null = null
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
import type { ClaudeTaskInvocation } from './claude-task-invocations'
|
||||
import type { AgentJournalProducerLinkage } from '../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalProducerLinkage } from '../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import {
|
||||
canReplaceBackgroundTaskState,
|
||||
isSettledBackgroundTaskState
|
||||
} from '../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import type { NativeChatBackgroundTaskBlock } from '../../shared/native-chat/native-chat-types'
|
||||
import type { ClaudeSubagentIds } from './claude-subagent-id-aliases'
|
||||
} from '../../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import type { NativeChatBackgroundTaskBlock } from '../../../shared/native-chat/native-chat-types'
|
||||
import type { ClaudeSubagentIds } from '../subagents/claude-subagent-id-aliases'
|
||||
import { classifyClaudeBackgroundTaskKind } from '../../../shared/claude-background-task-kind'
|
||||
import {
|
||||
classifyClaudeBackgroundTaskKind,
|
||||
liveClaudeTaskRunState,
|
||||
record,
|
||||
taskAliasId,
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
import { AGENT_JOURNAL_THREAD_SCOPE } from '../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import { AGENT_JOURNAL_THREAD_SCOPE } from '../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
|
||||
import { vi } from 'vitest'
|
||||
import type { AgentJournalItemBody } from '../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalItemIdentity } from '../../shared/agent-session/journal/agent-session-journal-identity'
|
||||
import type { NativeChatBackgroundTaskBlock } from '../../shared/native-chat/native-chat-types'
|
||||
import type { StructuredAgentSessionEventSink } from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import type { AgentJournalItemBody } from '../../../shared/agent-session/journal/agent-session-journal-types'
|
||||
import type { AgentJournalItemIdentity } from '../../../shared/agent-session/journal/agent-session-journal-identity'
|
||||
import type { NativeChatBackgroundTaskBlock } from '../../../shared/native-chat/native-chat-types'
|
||||
import type { StructuredAgentSessionEventSink } from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import { ClaudeBackgroundTaskRows } from './claude-background-task-rows'
|
||||
|
||||
/** Lifecycle frames captured from the reported failure. */
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
import { CLAUDE_BACKGROUND_TASK_SILENT_REFRESH_SUBTYPES } from './claude-background-task-frames'
|
||||
import type { ClaudeTaskInvocations } from './claude-task-invocations'
|
||||
import { claudeBackgroundTaskToolUseId } from './claude-background-task-row-lifecycle'
|
||||
import type { AgentJournalTurnScope } from '../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import type { AgentJournalTurnScope } from '../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import type {
|
||||
StructuredAgentSessionEventSink,
|
||||
StructuredAgentSessionSinkAdmission
|
||||
} from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
} from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import type { ClaudeBackgroundTaskRow } from './claude-background-task-row-lifecycle'
|
||||
import {
|
||||
ClaudeBackgroundTaskIdentityResolver,
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
import { ClaudeTaskInvocations } from './claude-task-invocations'
|
||||
import type { AgentJournalTurnScope } from '../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import { isSettledBackgroundTaskState } from '../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import type { StructuredAgentSessionEventSink } from '../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import { BoundedMap } from '../../shared/bounded-map'
|
||||
import type { AgentJournalTurnScope } from '../../../shared/agent-session/journal/agent-session-journal-turn-scope'
|
||||
import { isSettledBackgroundTaskState } from '../../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import type { StructuredAgentSessionEventSink } from '../../native-chat/agent-session-wire/journal-ingress/structured-agent-session-event-sink'
|
||||
import { BoundedMap } from '../../../shared/bounded-map'
|
||||
import {
|
||||
record,
|
||||
taskAliasId,
|
||||
@@ -31,7 +31,7 @@ import {
|
||||
} from './claude-background-task-row-writer'
|
||||
import { observeClaudeBackgroundTaskStart } from './claude-background-task-start'
|
||||
import { observeOwnedClaudeBackgroundTaskRoster } from './claude-background-task-roster'
|
||||
import { ClaudeSubagentIds } from './claude-subagent-id-aliases'
|
||||
import { ClaudeSubagentIds } from '../subagents/claude-subagent-id-aliases'
|
||||
import { ClaudeOverflowTerminalRows } from './claude-overflow-terminal-rows'
|
||||
|
||||
const MAX_TASK_ROWS = 64
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
import { isSettledBackgroundTaskState } from '../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import { classifyClaudeBackgroundTaskKind } from './claude-background-task-frames'
|
||||
import { isSettledBackgroundTaskState } from '../../../shared/native-chat/input/native-chat-background-task-row'
|
||||
import { classifyClaudeBackgroundTaskKind } from '../../../shared/claude-background-task-kind'
|
||||
import {
|
||||
claudeBackgroundTaskToolUseId,
|
||||
isClaudeBackgroundTranscriptTask,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
ensureClaudeBackgroundTaskRowSlot,
|
||||
type ClaudeBackgroundTaskLedgers
|
||||
} from './claude-background-task-memory'
|
||||
import { isClaudeSubagentTask } from './claude-subagent-task-frames'
|
||||
import { isClaudeSubagentTask } from '../subagents/claude-subagent-task-frames'
|
||||
|
||||
type ClaudeBackgroundTaskStartInput = {
|
||||
id: string
|
||||
-17
@@ -7,23 +7,6 @@ import {
|
||||
} from './claude-background-task-row-test-support'
|
||||
|
||||
describe('claude background task terminal frames', () => {
|
||||
it('reports a failure for a task it never saw admitted', () => {
|
||||
const { rows, items, latest, latestTwin, turnOpens } = harness()
|
||||
expect(rows.observe(ORPHAN_FAILED_NOTIFICATION)).toBe(true)
|
||||
expect(items).toHaveLength(1)
|
||||
expect(turnOpens).toHaveLength(1)
|
||||
expect(latest()).toMatchObject({
|
||||
type: 'background-task',
|
||||
taskId: 'bjzenpq13',
|
||||
kind: 'unknown',
|
||||
state: 'blocked',
|
||||
summary: 'Locate the exact screenshot session',
|
||||
parentToolUseId: 'toolu_01ASNfnDBEzt4w3ejLE12bGu'
|
||||
})
|
||||
expect(latest()?.label).toBe('')
|
||||
expect(latestTwin()).toBe('Locate the exact screenshot session')
|
||||
})
|
||||
|
||||
it('does not resurrect an orphan outcome that named its own parent tool', () => {
|
||||
const { rows, items, latest } = harness([
|
||||
FORWARDED_TOOL,
|
||||
+2
-10
@@ -2,9 +2,9 @@ import type {
|
||||
AgentSessionBackgroundTask,
|
||||
AgentSessionBackgroundTaskRunState,
|
||||
AgentSessionBackgroundTaskState
|
||||
} from '../../shared/agent-session/agent-session-background-task-wire'
|
||||
} from '../../../shared/agent-session/agent-session-background-task-wire'
|
||||
import { classifyClaudeBackgroundTaskKind } from '../../../shared/claude-background-task-kind'
|
||||
import {
|
||||
classifyClaudeBackgroundTaskKind,
|
||||
liveClaudeTaskRunState,
|
||||
record,
|
||||
taskDescription,
|
||||
@@ -21,14 +21,6 @@ import {
|
||||
} from './claude-settled-background-tasks'
|
||||
import { combineClaudeBackgroundTaskRoster } from './claude-background-task-roster-merge'
|
||||
|
||||
export {
|
||||
classifyClaudeBackgroundTaskKind,
|
||||
isBoundedClaudeTaskId,
|
||||
taskDescription as claudeTaskDescription,
|
||||
taskId as claudeTaskId
|
||||
} from './claude-background-task-frames'
|
||||
export type { ClaudeBackgroundTaskKind } from './claude-background-task-frames'
|
||||
|
||||
// Bound terminal IDs without evicting live tasks.
|
||||
const MAX_TERMINAL_TASK_IDS = 256
|
||||
export type ClaudeGoalBackgroundWork = 'live' | 'unverifiable' | 'exited'
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
import type {
|
||||
AgentSessionBackgroundTask,
|
||||
AgentSessionBackgroundTaskRunState
|
||||
} from '../../shared/agent-session/agent-session-background-task-wire'
|
||||
} from '../../../shared/agent-session/agent-session-background-task-wire'
|
||||
|
||||
const MAX_RETAINED_TASKS = 256
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { spawnProcess } from '@orca/process-host'
|
||||
import { proveClaudeChildExit } from './claude-agent-sdk-exit-proof'
|
||||
import { managedChild } from './claude-child-exit-proof-fixture'
|
||||
|
||||
const COOPERATIVE_CHILD = `
|
||||
process.stdin.on('end', () => process.exit(0))
|
||||
process.stdin.resume()
|
||||
process.stdout.write('ready\\n')
|
||||
`
|
||||
|
||||
/** Sample at the close boundary; zombies count as exited even though kill(pid, 0) finds them. */
|
||||
|
||||
// ps start times have second precision; cross that boundary so the snapshot permits forced signals.
|
||||
|
||||
// Model registry retries: slow process-table reads may leave one close attempt unproven.
|
||||
|
||||
function spawnScript(script: string): ChildProcessWithoutNullStreams {
|
||||
const child = spawnProcess({
|
||||
program: process.execPath,
|
||||
args: ['-e', script],
|
||||
stdio: ['pipe', 'pipe', 'pipe']
|
||||
})
|
||||
managedChild(child)
|
||||
return child
|
||||
}
|
||||
|
||||
function firstStdoutLine(child: ChildProcessWithoutNullStreams): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
child.stdout.setEncoding('utf8').once('data', (chunk: string) => resolve(chunk.trim()))
|
||||
})
|
||||
}
|
||||
|
||||
describe('claude child exit proof', () => {
|
||||
it('proves a clean close of a childless root with one snapshot and no signal', async () => {
|
||||
const child = spawnScript(COOPERATIVE_CHILD)
|
||||
expect(await firstStdoutLine(child)).toBe('ready')
|
||||
|
||||
await expect(proveClaudeChildExit({ managed: managedChild(child) })).resolves.toBe(true)
|
||||
}, 20_000)
|
||||
})
|
||||
+4
-4
@@ -2,15 +2,15 @@ import type { ChildProcess } from 'node:child_process'
|
||||
import {
|
||||
terminateDescendantSnapshotWithVerdict,
|
||||
type DescendantTreeVerdict
|
||||
} from '../pty/process-retirement/pty-descendant-exit-verification'
|
||||
} from '../../pty/process-retirement/pty-descendant-exit-verification'
|
||||
import {
|
||||
captureDescendantSnapshot,
|
||||
type DescendantSnapshot
|
||||
} from '../pty/process-retirement/pty-descendant-termination'
|
||||
import { terminateWindowsProcessTree } from '../pty/process-retirement/windows-process-tree-kill'
|
||||
} from '../../pty/process-retirement/pty-descendant-termination'
|
||||
import { terminateWindowsProcessTree } from '../../pty/process-retirement/windows-process-tree-kill'
|
||||
import { mergeClaudeDescendantSnapshots } from './claude-child-tree-snapshot'
|
||||
import { terminateClaudeRoot } from './claude-child-root-termination'
|
||||
import { killProviderWriter } from '../provider-process/provider-process-teardown'
|
||||
import { killProviderWriter } from '../../provider-process/provider-process-teardown'
|
||||
import {
|
||||
proveClaudeChildExitWithReaper,
|
||||
type ClaudeChildExitProofInput
|
||||
@@ -0,0 +1,72 @@
|
||||
import { createFakePipedChild } from '../../../shared/__fixtures__/fake-spawned-child'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import type { SpawnOptions as SdkSpawnOptions } from '@anthropic-ai/claude-agent-sdk'
|
||||
import type { PipedProcessSpawner, ProcessSpec } from '@orca/process-host/process-spec'
|
||||
|
||||
import type * as ProviderSupervisor from '../../provider-process/provider-process-supervisor'
|
||||
|
||||
import { createClaudeCodeProcessSpawn } from './claude-agent-sdk-process-spawn'
|
||||
|
||||
vi.mock('../../provider-process/provider-process-supervisor', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof ProviderSupervisor>()
|
||||
return { ...actual, createProviderSpawnSpec: vi.fn(actual.createProviderSpawnSpec) }
|
||||
})
|
||||
|
||||
function fakeSpawn() {
|
||||
const child = createFakePipedChild()
|
||||
const specs: ProcessSpec[] = []
|
||||
const spawnImpl: PipedProcessSpawner = (spec) => {
|
||||
specs.push(spec)
|
||||
return child
|
||||
}
|
||||
return { child, spawnImpl, specs }
|
||||
}
|
||||
|
||||
function sdkOptions(overrides: Partial<SdkSpawnOptions> = {}): SdkSpawnOptions {
|
||||
return {
|
||||
command: '/usr/local/bin/claude',
|
||||
args: ['--output-format', 'stream-json'],
|
||||
cwd: '/work/repo',
|
||||
env: { PATH: '/usr/bin', CLAUDE_CONFIG_DIR: '/accounts/one', UNSET: undefined },
|
||||
signal: new AbortController().signal,
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
|
||||
describe('claude agent SDK process spawn', () => {
|
||||
it('keeps native chat identity after SDK and configured environment defaults', () => {
|
||||
const process = fakeSpawn()
|
||||
createClaudeCodeProcessSpawn(process.spawnImpl, 'win32').spawn(
|
||||
sdkOptions({
|
||||
env: {
|
||||
CLAUDE_CODE_ENTRYPOINT: 'sdk-ts',
|
||||
claude_code_entrypoint: 'account',
|
||||
PATH: 'C:\\bin'
|
||||
}
|
||||
})
|
||||
)
|
||||
expect(process.specs[0]?.env).toMatchObject({ CLAUDE_CODE_ENTRYPOINT: 'orca', PATH: 'C:\\bin' })
|
||||
expect(
|
||||
Object.keys(process.specs[0]?.env ?? {}).filter(
|
||||
(key) => key.toUpperCase() === 'CLAUDE_CODE_ENTRYPOINT'
|
||||
)
|
||||
).toEqual(['CLAUDE_CODE_ENTRYPOINT'])
|
||||
})
|
||||
|
||||
it('preserves a Windows .cmd shim and its arguments for the host spawner', () => {
|
||||
const process = fakeSpawn()
|
||||
createClaudeCodeProcessSpawn(process.spawnImpl, 'win32').spawn(
|
||||
sdkOptions({
|
||||
command: 'C:\\Users\\dev\\AppData\\npm\\claude.cmd',
|
||||
args: ['--setting-sources=user,project,local', '--session-id', 'a b&c']
|
||||
})
|
||||
)
|
||||
|
||||
expect(process.specs).toEqual([
|
||||
expect.objectContaining({
|
||||
program: 'C:\\Users\\dev\\AppData\\npm\\claude.cmd',
|
||||
args: ['--setting-sources=user,project,local', '--session-id', 'a b&c']
|
||||
})
|
||||
])
|
||||
})
|
||||
})
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { withOrcaClaudeChatEntrypoint } from '../../shared/agent-launch/startup/claude-chat-entrypoint'
|
||||
import { withOrcaClaudeChatEntrypoint } from '../../../shared/agent-launch/startup/claude-chat-entrypoint'
|
||||
import type { ChildProcessWithoutNullStreams } from 'node:child_process'
|
||||
import type { PipedProcessSpawner } from '@orca/process-host/process-spec'
|
||||
import type { SpawnOptions as ClaudeAgentSdkSpawnOptions } from '@anthropic-ai/claude-agent-sdk'
|
||||
@@ -6,7 +6,7 @@ import { spawnProcess } from '@orca/process-host'
|
||||
import {
|
||||
spawnManagedProviderProcess,
|
||||
type ManagedProviderProcess
|
||||
} from '../provider-process/managed-provider-process'
|
||||
} from '../../provider-process/managed-provider-process'
|
||||
import { claudeChildClosePolicy, claudeChildCloseProven } from './claude-child-exit-proof-ladder'
|
||||
|
||||
export type ClaudeCodeProcessSpawn = {
|
||||
+1
-1
@@ -2,7 +2,7 @@ import type { ChildProcessWithoutNullStreams } from 'node:child_process'
|
||||
import {
|
||||
spawnManagedProviderProcess,
|
||||
type ManagedProviderProcess
|
||||
} from '../provider-process/managed-provider-process'
|
||||
} from '../../provider-process/managed-provider-process'
|
||||
import { claudeChildClosePolicy, claudeChildCloseProven } from './claude-child-exit-proof-ladder'
|
||||
|
||||
const managedChildren = new WeakMap<object, ManagedProviderProcess>()
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
import type { ManagedProviderProcess } from '../provider-process/managed-provider-process'
|
||||
import { PROVIDER_SUPERVISOR_MAX_STOP_MS } from '../provider-process/provider-process-supervisor'
|
||||
import type { ManagedProviderProcess } from '../../provider-process/managed-provider-process'
|
||||
import { PROVIDER_SUPERVISOR_MAX_STOP_MS } from '../../provider-process/provider-process-supervisor'
|
||||
import type {
|
||||
ProviderProcessClosePolicy,
|
||||
ProviderProcessCloseResult
|
||||
} from '../provider-process/provider-process-close'
|
||||
} from '../../provider-process/provider-process-close'
|
||||
import type { ClaudeChildTreeReaper } from './claude-agent-sdk-exit-proof'
|
||||
|
||||
export const GRACEFUL_EXIT_MS = 1_500
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
import {
|
||||
CLAUDE_AUTH_ENV_VARS,
|
||||
applyClaudeEnvPatch
|
||||
} from '../claude-accounts/runtime-auth/environment'
|
||||
import { stripInheritedAgentSessionEnv } from '../../shared/agent-launch/startup/parent-agent-session-env'
|
||||
} from '../../claude-accounts/runtime-auth/environment'
|
||||
import { stripInheritedAgentSessionEnv } from '../../../shared/agent-launch/startup/parent-agent-session-env'
|
||||
import {
|
||||
LEGACY_NATIVE_CHAT_VISUALS_DIR_ENV,
|
||||
NATIVE_CHAT_SCRATCH_DIR_ENV
|
||||
} from '../native-chat/native-chat-visuals-delivery'
|
||||
} from '../../native-chat/native-chat-visuals-delivery'
|
||||
|
||||
function cloneProcessEnv(source: NodeJS.ProcessEnv): Record<string, string> {
|
||||
const env: Record<string, string> = {}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import type { DescendantSnapshot } from '../pty/process-retirement/pty-descendant-termination'
|
||||
import type { DescendantSnapshot } from '../../pty/process-retirement/pty-descendant-termination'
|
||||
|
||||
// Non-atomic scans may omit live rows; retain them, but reject any PID whose identity changed.
|
||||
function mergeRowsByPid<Row extends { pid: number }>(
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { StringDecoder } from 'node:string_decoder'
|
||||
import { createIncrementalNdjsonFramer } from '../../shared/main-process-ndjson-framer'
|
||||
import { createIncrementalNdjsonFramer } from '../../../shared/main-process-ndjson-framer'
|
||||
|
||||
// Unescaped quotes occur only as JSON structure, so other records skip this second parse.
|
||||
const FAILED_RESULT_TOKENS = [/"type"\s*:\s*"result"/, /"is_error"\s*:\s*true/]
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
import { BoundedMap } from '../../shared/bounded-map'
|
||||
import { runsOrcaOrchestrationWait } from '../../shared/orca-cli-invocations'
|
||||
import { BoundedMap } from '../../../shared/bounded-map'
|
||||
import { runsOrcaOrchestrationWait } from '../../../shared/orca-cli-invocations'
|
||||
import {
|
||||
claudeRecord,
|
||||
claudeToolUses,
|
||||
readClaudeMessageEnvelope
|
||||
} from './structured/journal/claude-structured-item-translation'
|
||||
} from '../structured/journal/claude-structured-item-translation'
|
||||
|
||||
/** Bash calls that block on `orca orchestration check --wait`, by tool_use_id, until their background task starts. */
|
||||
export class ClaudeAgentWaitCalls {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user