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.

fix(connectors): restore Gmail parameter compatibility

wytb4a1b3b02c2f
diff --git a/src/main/model/core-agent/connector-meta-tools.ts b/src/main/model/core-agent/connector-meta-tools.ts
index 609a6a48..4e848887 100644
--- a/src/main/model/core-agent/connector-meta-tools.ts
+++ b/src/main/model/core-agent/connector-meta-tools.ts
@@ -465,6 +465,38 @@ export function applyConnectorArgDefaults(
delete out[camel];
}
}
+ if (
+ connectorId === 'gmail'
+ && toolName.startsWith('GMAIL_')
+ && Object.prototype.hasOwnProperty.call(properties, 'user_id')
+ && !Object.prototype.hasOwnProperty.call(out, 'user_id')
+ ) {
+ out.user_id = 'me';
+ }
+ if (connectorId === 'gmail' && toolName === 'GMAIL_FETCH_EMAILS') {
+ if (
+ Object.prototype.hasOwnProperty.call(properties, 'verbose')
+ && !Object.prototype.hasOwnProperty.call(out, 'verbose')
+ ) {
+ out.verbose = false;
+ }
+ if (
+ Object.prototype.hasOwnProperty.call(properties, 'include_payload')
+ && !Object.prototype.hasOwnProperty.call(out, 'include_payload')
+ ) {
+ out.include_payload = false;
+ }
+ }
+ if (connectorId === 'gmail' && toolName.startsWith('GMAIL_')) {
+ const hasBody = Object.prototype.hasOwnProperty.call(out, 'body');
+ const hasMessageBody = Object.prototype.hasOwnProperty.call(out, 'message_body');
+ if (hasBody && !hasMessageBody && Object.prototype.hasOwnProperty.call(properties, 'message_body')) {
+ out.message_body = out.body;
+ }
+ if (hasMessageBody && !hasBody && Object.prototype.hasOwnProperty.call(properties, 'body')) {
+ out.body = out.message_body;
+ }
+ }
return out;
}
diff --git a/test/main/features/local_agents/bridge.test.ts b/test/main/features/local_agents/bridge.test.ts
index 0e4a8737..6bb869bf 100644
--- a/test/main/features/local_agents/bridge.test.ts
+++ b/test/main/features/local_agents/bridge.test.ts
@@ -1128,11 +1128,11 @@ describe('local_agents/bridge › auth + skills', () => {
} finally { await bridge.close(); }
});
- it('connectors.call normalizes schema field names and preserves explicit provider arguments', async () => {
+ it('connectors.call applies the same argument defaults as the in-process connector tool', async () => {
// A Gmail fetch from an external CLI must reach the provider with the same
- // request shape a built-in Agent produces: schema-declared snake_case keys.
- // The public adapter preserves explicit values and leaves omitted provider
- // options to the provider's own defaults.
+ // request shape a built-in Agent produces: snake_case keys plus the Orkas
+ // defaults (user_id=me, verbose/include_payload=false). An explicit value
+ // is preserved (negative control).
bridgeConnectorMock.resolveVisibleConnectors.mockResolvedValue([{
instance: { id: 'gmail', display_name: 'Gmail' },
tools: [{
@@ -1152,7 +1152,7 @@ describe('local_agents/bridge › auth + skills', () => {
});
expect(first.reply).toMatchObject({ ok: true });
expect(bridgeConnectorMock.callTool.mock.calls[0][3]).toEqual({
- max_results: 5,
+ max_results: 5, user_id: 'me', verbose: false, include_payload: false,
});
const second = await rpcOnce(bridge.socketPath, {
id: 62, token: bridge.token, method: 'connectors.call',
@@ -1160,7 +1160,7 @@ describe('local_agents/bridge › auth + skills', () => {
});
expect(second.reply).toMatchObject({ ok: true });
expect(bridgeConnectorMock.callTool.mock.calls[1][3]).toEqual({
- max_results: 2, verbose: true,
+ max_results: 2, verbose: true, user_id: 'me', include_payload: false,
});
} finally {
await bridge.close();
diff --git a/test/main/model/core-agent/connector-meta-tools.test.ts b/test/main/model/core-agent/connector-meta-tools.test.ts
index 97ff5eac..af158dc5 100644
--- a/test/main/model/core-agent/connector-meta-tools.test.ts
+++ b/test/main/model/core-agent/connector-meta-tools.test.ts
@@ -952,6 +952,57 @@ describe('named-Agent Connector fallback model loop', () => {
// ── call_connector_tool ─────────────────────────────────────────────────
describe('call_connector_tool', () => {
+ it('sends bounded schema-declared Gmail fetch defaults through the authorized call', async () => {
+ fixtures.instances = [makeInstance({ id: 'gmail', tools: [{
+ name: 'GMAIL_FETCH_EMAILS', description: 'Read mail.', input_schema: {
+ type: 'object', properties: { user_id: { type: 'string' }, verbose: { type: 'boolean' }, include_payload: { type: 'boolean' } },
+ },
+ }] })];
+ const execute = vi.fn(async () => 'mail results');
+ fixtures.callTool = execute;
+ const { createConnectorMetaTools } = await loadModule();
+ const [, call] = await createConnectorMetaTools({ userId: UID, cid: 'gmail-defaults' });
+ const args = {};
+ expect((await runTool(call, { connector_id: 'gmail', tool_name: 'GMAIL_FETCH_EMAILS', args })).isError).toBeFalsy();
+ expect(execute).toHaveBeenCalledWith(UID, 'gmail', 'GMAIL_FETCH_EMAILS', {
+ user_id: 'me', verbose: false, include_payload: false,
+ }, expect.objectContaining({ conversationId: 'gmail-defaults' }));
+ expect(args).toEqual({});
+ });
+
+ it.each([
+ { provided: 'body', declared: 'message_body' },
+ { provided: 'message_body', declared: 'body' },
+ ])('keeps Gmail send content when the action schema declares $declared', async ({ provided, declared }) => {
+ fixtures.instances = [makeInstance({ id: 'gmail', tools: [{
+ name: 'GMAIL_SEND_EMAIL', description: 'Send mail.',
+ input_schema: { type: 'object', properties: { [declared]: { type: 'string' } } },
+ }] })];
+ const execute = vi.fn(async () => 'sent');
+ fixtures.callTool = execute;
+ const { createConnectorMetaTools } = await loadModule();
+ const [, call] = await createConnectorMetaTools({ userId: UID, cid: 'gmail-body' });
+ const args = { [provided]: 'Requested message' };
+ expect((await runTool(call, { connector_id: 'gmail', tool_name: 'GMAIL_SEND_EMAIL', args })).isError).toBeFalsy();
+ expect(execute).toHaveBeenCalledWith(UID, 'gmail', 'GMAIL_SEND_EMAIL', {
+ [provided]: 'Requested message', [declared]: 'Requested message',
+ }, expect.anything());
+ expect(args).toEqual({ [provided]: 'Requested message' });
+ });
+
+ it('preserves explicit Gmail arguments and keeps defaults within the declared action contract', async () => {
+ const { applyConnectorArgDefaults: normalize } = await loadModule();
+ const schema = { properties: { user_id: {}, verbose: {}, include_payload: {}, body: {}, message_body: {} } };
+ const explicit = { user_id: '', verbose: true, include_payload: true, body: 'one', message_body: 'two' };
+ expect(normalize('gmail', 'GMAIL_FETCH_EMAILS', explicit, schema)).toEqual(explicit);
+ expect(normalize('other', 'GMAIL_FETCH_EMAILS', { body: 'one' }, schema)).toEqual({ body: 'one' });
+ expect(normalize('gmail', 'read_mail', { body: 'one' }, schema)).toEqual({ body: 'one' });
+ expect(normalize('gmail', 'GMAIL_FETCH_EMAILS', {}, { properties: {} })).toEqual({});
+ expect(normalize('gmail', 'GMAIL_SEND_EMAIL', { body: 'one' }, undefined)).toEqual({ body: 'one' });
+ expect(normalize('gmail', 'GMAIL_SEND_EMAIL', { body: '' }, { properties: { message_body: {} } }))
+ .toEqual({ body: '', message_body: '' });
+ });
+
it('requires explicit side-effect confirmation before the model claims completion', async () => {
fixtures.instances = [makeInstance({ id: 'notion', tools: NOTION_TOOLS })];
const { createConnectorMetaTools } = await loadModule();