Skip to content

armgit / Orkas

Public Imported from GitHub
0

Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.

Keep connector list usable after secret decode failure

wytb8e7ffd59f82
diff --git a/src/main/features/connectors/registry.ts b/src/main/features/connectors/registry.ts
index 3d02764f..1a512f9d 100644
--- a/src/main/features/connectors/registry.ts
+++ b/src/main/features/connectors/registry.ts
@@ -43,6 +43,7 @@ const _writeMutex = new Mutex();
const EMPTY: ConnectorsFile = { version: 2, connections: {}, oauth_hints: {}, _deleted_at: {} };
const CONNECTOR_SECRET_NAMESPACE = 'connectors.instance';
+const SECRETS_UNAVAILABLE_MESSAGE = 'connector_reconnect_required';
// On-disk shape: ConnectorInstance with all token-bearing fields collapsed into one
// locally encrypted `secrets_enc` string. **`transport` is in the blob too** — even though it's
@@ -126,6 +127,7 @@ function _hydrateSecrets(uid: string, disk: InstanceOnDisk): { instance: Connect
const dec = _tryDecrypt(uid, disk.id, secrets_enc);
if (dec === null) {
log.warn('decrypt secrets_enc failed (known formats) — instance left without transport/grant', { id: disk.id });
+ out.status = { kind: 'error', message: SECRETS_UNAVAILABLE_MESSAGE, at: Date.now() };
(out as ConnectorInstanceWithPreservedSecrets)[PRESERVED_SECRETS] = { ciphertext: secrets_enc };
return { instance: out, migrated: false };
}
@@ -145,6 +147,7 @@ function _hydrateSecrets(uid: string, disk: InstanceOnDisk): { instance: Connect
}
} catch (err) {
log.warn('parse secrets_enc payload failed', { id: disk.id, error: (err as Error).message });
+ out.status = { kind: 'error', message: SECRETS_UNAVAILABLE_MESSAGE, at: Date.now() };
(out as ConnectorInstanceWithPreservedSecrets)[PRESERVED_SECRETS] = { ciphertext: secrets_enc };
return { instance: out, migrated: false };
}
diff --git a/src/main/ipc/connectors.ts b/src/main/ipc/connectors.ts
index 9bfcc236..a7b95d2a 100644
--- a/src/main/ipc/connectors.ts
+++ b/src/main/ipc/connectors.ts
@@ -38,7 +38,7 @@ interface ClientConnectorInstance {
id: string;
display_name: string;
origin?: 'catalog' | 'custom';
- transport:
+ transport?:
| { kind: 'stdio'; summary: string }
| { kind: 'streamable-http'; summary: string };
enabled_subtools: string[] | null;
@@ -51,15 +51,17 @@ interface ClientConnectorInstance {
enabled?: boolean;
}
-function _safeTransportSummary(inst: ConnectorInstance): ClientConnectorInstance['transport'] {
- if (inst.transport.kind === 'stdio') {
- const command = path.basename(inst.transport.command || '');
- const argCount = inst.transport.args?.length ?? 0;
+function _safeTransportSummary(inst: ConnectorInstance): ClientConnectorInstance['transport'] | undefined {
+ const transport = inst.transport;
+ if (!transport) return undefined;
+ if (transport.kind === 'stdio') {
+ const command = path.basename(transport.command || '');
+ const argCount = transport.args?.length ?? 0;
const suffix = argCount === 1 ? '1 arg' : `${argCount} args`;
return { kind: 'stdio', summary: argCount > 0 ? `${command} (${suffix})` : command };
}
try {
- const url = new URL(inst.transport.url);
+ const url = new URL(transport.url);
url.username = '';
url.password = '';
url.search = '';
@@ -77,7 +79,7 @@ function toClientInstance(inst: ConnectorInstance, enabled?: boolean): ClientCon
id: inst.id,
display_name: inst.display_name,
...(inst.origin ? { origin: inst.origin } : {}),
- transport,
+ ...(transport ? { transport } : {}),
enabled_subtools: inst.enabled_subtools,
tools_cache: inst.tools_cache,
tools_cached_at: inst.tools_cached_at,
diff --git a/test/main/features/connectors/registry.test.ts b/test/main/features/connectors/registry.test.ts
index 8ea759d2..ef60d5a3 100644
--- a/test/main/features/connectors/registry.test.ts
+++ b/test/main/features/connectors/registry.test.ts
@@ -106,6 +106,13 @@ describe('features/connectors/registry', () => {
const loaded = registry.load(uid);
expect(loaded.connections.gmail.oauth_grant).toBeUndefined();
+ expect(loaded.connections.gmail.status).toMatchObject({
+ kind: 'error',
+ message: 'connector_reconnect_required',
+ });
+ const beforePatch = JSON.parse(fs.readFileSync(file, 'utf8'));
+ expect(beforePatch.connections.gmail.status.kind).toBe('connected');
+ expect(beforePatch.connections.gmail.secrets_enc).toBe(originalSecrets);
await registry.update(uid, 'gmail', (cur) => ({
...cur,
diff --git a/test/main/ipc/connectors.test.ts b/test/main/ipc/connectors.test.ts
index dae8ed36..5320e180 100644
--- a/test/main/ipc/connectors.test.ts
+++ b/test/main/ipc/connectors.test.ts
@@ -103,6 +103,17 @@ describe('ipc/connectors renderer DTO', () => {
expect(json).not.toContain('header-secret');
});
+ it('keeps an undecryptable connector row listable without a transport', async () => {
+ const { _toClientInstanceForTest } = await import('../../../src/main/ipc/connectors');
+ const inst = baseInstance(undefined);
+ inst.status = { kind: 'error', message: 'connector_reconnect_required', at: 1 };
+
+ const dto = _toClientInstanceForTest(inst);
+
+ expect(dto.transport).toBeUndefined();
+ expect(dto.status).toEqual(inst.status);
+ });
+
it('returns the latest connector status after refresh', async () => {
const degraded = {
...baseInstance({