mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Merge branch 'cloud/integration' of https://github.com/nwparker/orca-private into cloud/agents-a5
This commit is contained in:
@@ -32,9 +32,10 @@ export type AccountProvider = {
|
||||
credential(db: D1Database, keyring: Keyring, userId: string, now: number): Promise<string | null>
|
||||
}
|
||||
|
||||
/** D13: a workspace shared with teammates never uses a personal account. */
|
||||
/** D13: a workspace shared with teammates never uses a personal account. Fails closed: only a row
|
||||
* known to be private counts as unshared. */
|
||||
export function isSharedWorkspace(row: Pick<SandboxRow, 'visibility'>): boolean {
|
||||
return row.visibility === 'team'
|
||||
return row.visibility !== 'private'
|
||||
}
|
||||
|
||||
export const claudeAccount: AccountProvider = {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { SignJWT, createLocalJWKSet, exportJWK, generateKeyPair } from 'jose'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { isSharedWorkspace } from '../src/account-providers'
|
||||
import { ENV_COMMAND, START_COMMAND } from '../src/sandbox-vm-commands'
|
||||
import { createHarness } from './harness'
|
||||
|
||||
@@ -199,3 +200,13 @@ describe('egress-time Source (D10) and shared workspaces (D13)', () => {
|
||||
expect((await h.call('GET', '/v1/agent-credentials', { bearer: mia })).body.providerEnabled.claude).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('D13 fails closed', () => {
|
||||
it('treats any visibility other than private as shared', () => {
|
||||
expect(isSharedWorkspace({ visibility: 'private' })).toBe(false)
|
||||
expect(isSharedWorkspace({ visibility: 'team' })).toBe(true)
|
||||
for (const visibility of ['', 'org', null, undefined] as unknown as string[]) {
|
||||
expect(isSharedWorkspace({ visibility } as never)).toBe(true)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
+3
-7
@@ -20,11 +20,7 @@ import type {
|
||||
CloudSecretsErrorCode
|
||||
} from '../../../../../shared/cloud-secrets/cloud-secrets-wire'
|
||||
import { parseScope, writableScopes } from '../../cloud-secrets-ask/cloud-secrets-ask-model'
|
||||
import {
|
||||
isGuestInSharedWorkspace,
|
||||
type CloudPanelAddSecret,
|
||||
type CloudPanelSectionsData
|
||||
} from './use-cloud-panel-sections'
|
||||
import type { CloudPanelAddSecret, CloudPanelSectionsData } from './use-cloud-panel-sections'
|
||||
|
||||
/** A declared name nobody provides: Missing chip, then Add (members: Add mine) opens an inline field. */
|
||||
export function CloudMissingSecretRow({
|
||||
@@ -47,8 +43,8 @@ export function CloudMissingSecretRow({
|
||||
const t = useTranslate()
|
||||
const id = React.useId()
|
||||
const admin = data.effective.caller.canWrite.org
|
||||
// A teammate's Personal values don't reach someone else's shared workspace.
|
||||
const guest = isGuestInSharedWorkspace(data)
|
||||
// A teammate's Personal values don't reach someone else's shared workspace (or one we can't tell).
|
||||
const guest = data.withoutPersonal
|
||||
const scopes = writableScopes(data.effective.caller, {
|
||||
repo: data.repoKey !== null,
|
||||
shared: true
|
||||
|
||||
+2
-1
@@ -183,7 +183,8 @@ export const empty = defineFixture({
|
||||
missing: [],
|
||||
repoKey: 'github.com/acme/web',
|
||||
asleep: false,
|
||||
sharing: null
|
||||
sharing: null,
|
||||
withoutPersonal: false
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
+23
@@ -111,4 +111,27 @@ describe('shared workspaces (D13)', () => {
|
||||
.missing
|
||||
).toEqual([])
|
||||
})
|
||||
|
||||
it('fails closed when the workspace sharing could not be read (D13)', () => {
|
||||
const declared = ['NPM_TOKEN', 'SENTRY_DSN', 'DATABASE_URL']
|
||||
const data = cloudPanelSectionsData({
|
||||
effective: values,
|
||||
envVarNames: declared,
|
||||
repoKey: null,
|
||||
asleep: false,
|
||||
sharing: null,
|
||||
sharingUnknown: true
|
||||
})
|
||||
expect(data.withoutPersonal).toBe(true)
|
||||
expect(data.missing).toEqual(['NPM_TOKEN'])
|
||||
expect(
|
||||
cloudPanelSectionsData({
|
||||
effective: values,
|
||||
envVarNames: declared,
|
||||
repoKey: null,
|
||||
asleep: false,
|
||||
sharing: null
|
||||
}).withoutPersonal
|
||||
).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
+13
-3
@@ -23,6 +23,11 @@ export type CloudPanelSectionsData = {
|
||||
asleep: boolean
|
||||
/** Shared with teammates (D13), and whose workspace it is; null when unknown. */
|
||||
sharing: CloudWorkspaceSharing | null
|
||||
/**
|
||||
* The caller's Personal values are left out: a teammate in a shared workspace, or a workspace whose
|
||||
* sharing couldn't be read (D13 fails closed: it may be someone else's shared workspace).
|
||||
*/
|
||||
withoutPersonal: boolean
|
||||
}
|
||||
|
||||
/** A teammate's view of someone else's shared workspace: only their non-Personal values apply. */
|
||||
@@ -36,10 +41,13 @@ export function cloudPanelSectionsData(args: {
|
||||
repoKey: string | null
|
||||
asleep: boolean
|
||||
sharing: CloudWorkspaceSharing | null
|
||||
/** The workspace's sharing read failed; treat it as possibly someone else's shared workspace. */
|
||||
sharingUnknown?: boolean
|
||||
}): CloudPanelSectionsData {
|
||||
const guest = isGuestInSharedWorkspace(args)
|
||||
const effective = guest ? withoutCallerPersonal(args.effective) : args.effective
|
||||
const withoutPersonal = args.sharingUnknown === true || isGuestInSharedWorkspace(args)
|
||||
const effective = withoutPersonal ? withoutCallerPersonal(args.effective) : args.effective
|
||||
return {
|
||||
withoutPersonal,
|
||||
effective,
|
||||
missing: args.envVarNames ? missingSecretNames(args.envVarNames, effective) : [],
|
||||
repoKey: args.repoKey,
|
||||
@@ -103,7 +111,9 @@ export function useCloudPanelSections(args: {
|
||||
envVarNames: environment?.envVarNames ?? null,
|
||||
repoKey,
|
||||
asleep,
|
||||
sharing: sharing?.ok ? sharing.value : null
|
||||
sharing: sharing?.ok ? sharing.value : null,
|
||||
// A sandbox whose sharing couldn't be read fails closed (D13).
|
||||
sharingUnknown: runtimeEnvironmentId !== null && !sharing?.ok
|
||||
})
|
||||
})
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user