Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(providers): authorize owner Pi native streams
DavidShen5ba17ae03e96
diff --git a/apps/desktop/src/main/remote-agent/__tests__/hostedProviderRouting.test.ts b/apps/desktop/src/main/remote-agent/__tests__/hostedProviderRouting.test.tsindex b4cf9ad864..c8e5455100 100644--- a/apps/desktop/src/main/remote-agent/__tests__/hostedProviderRouting.test.ts+++ b/apps/desktop/src/main/remote-agent/__tests__/hostedProviderRouting.test.ts@@ -20,7 +20,8 @@ vi.mock('../../maker-host/claude-fast-mode-log', () => ({import { setCustomProviders } from '../../maker-host/active-catalog';import { createModelRoutingTransform, setClaudeProxyGatewayKeyReader, setClaudeProxySessionIdResolver } from '../../maker-host/anthropic-compat-proxy-host';import { resolveSessionRouteDecision, setCustomProviderKeyReader } from '../../maker-host/provider-route';-import { bindHostedSessionProvider, clearAllSessionProviders, getSessionProvider, hasSessionProvider } from '../../maker-host/session-provider-store';+import { bindHostedSessionProvider, clearAllSessionProviders, getSessionProvider, hasSessionProvider, hasHostedSessionModelAccess } from '../../maker-host/session-provider-store';+import { hostedProviderOffersModel } from '../../maker-host/guest-provider-route-store';import { LineSplitter } from '../eventLog';import { createRemoteAgentHost, hostSessionIdFor, type HostedStartInput } from '../host/runHost';@@ -55,6 +56,7 @@ beforeEach(() => {id, name: id,runtimes: {codex: { baseUrl: 'https://' + id + '.example.invalid/v1', wireProtocol: 'openai-responses', models: [{ id: MODEL, name: MODEL }] },+ pi: { baseUrl: 'https://' + id + '.example.invalid/v1', wireProtocol: 'openai-responses', models: [MODEL, CLAUDE_MODEL].map(id => ({ id, name: id })) },'claude-code': { baseUrl: 'https://' + id + '.example.invalid/anthropic', wireProtocol: 'anthropic-messages', models: [MODEL, CLAUDE_MODEL].map((model) => ({ id: model, name: model })) },},})));@@ -99,6 +101,8 @@ function setup(hooks: {isAllowed: (providerId, _controller, model) => providerId !== 'forbidden' && (hooks.allowsModel?.(providerId, model ?? '') ?? true),},bindOwnerProviderRoute: bindHostedSessionProvider,+ ownerModelAllowed: (sessionId, providerId, kind, model) => hasHostedSessionModelAccess(sessionId)+ && hostedProviderOffersModel(sessionId, providerId, kind, model),bindGuestProviderRoute: async () => ({ routeToken: 'test-guest-route', modelIds: [MODEL], release() {} }),startHosted: async (input) => {starts.push(input);@@ -170,6 +174,30 @@ async function switchProvider(runId: string, providerId?: string | null) {}describe('same-account hosted provider routing', () => {+ // Review 4333949156 / sharing §12, unit: the old host suite checked only the+ // HTTP proxy. Query the real run tunnel as owner Pi's API-key adapter does;+ // another approved source is allowed, but revocation/stale bindings are denied.+ it('checks owner native requests against the actual provider and current model grant', async () => {+ const allowedProviders = new Set(['fp', 'other']);+ const env = setup({ allowsModel: (providerId, model) => allowedProviders.has(providerId) && model === MODEL });+ const runId = await open('fp', 'owner-native', OWNER, 'pi');+ await waitForEvent(runId, 'started');+ const input = env.starts[0];+ const query = async (providerId?: string, model = MODEL) => {+ const response = await fetch(input.tunnel.url + '/cindy/model-access', { method: 'POST',+ headers: { Authorization: 'Bearer ' + input.tunnel.token }, body: JSON.stringify({ model, providerId }) });+ return (await response.json() as { allowed: boolean }).allowed;+ };+ expect(await query('fp')).toBe(true);+ expect(await query('fp', CLAUDE_MODEL)).toBe(false);+ expect(await query('other')).toBe(true);+ expect(await query('forbidden')).toBe(false);+ expect(await query()).toBe(false);+ allowedProviders.delete('other');+ expect(await query('other')).toBe(false);+ clearAllSessionProviders();+ expect(await query('fp')).toBe(false);+ });// Unit regression for review 4327641928: real host registration must reach the// proxy before the first request and read live grants. Previous tests only checked// provider selection; minimum is a hosted session allowed one of two catalog models.diff --git a/apps/desktop/src/main/remote-agent/host/runHost.ts b/apps/desktop/src/main/remote-agent/host/runHost.tsindex 8b45387d19..e864321c00 100644--- a/apps/desktop/src/main/remote-agent/host/runHost.ts+++ b/apps/desktop/src/main/remote-agent/host/runHost.ts@@ -207,6 +207,8 @@ export interface RemoteAgentHostDeps {};/** 同账号任务在启动前登记来源和逐请求的实时模型授权,子代理同样受此约束。 */bindOwnerProviderRoute?(hostSessionId: string, providerId: string, allowsModel?: (providerId: string, model: string) => boolean): OwnerProviderRouteBinding;+ /** Resolve an owner native request's actual catalog identity before checking its live grant. */+ ownerModelAllowed?(hostSessionId: string, providerId: string, kind: RemoteAgentKind, model: string): boolean;/*** 受邀者任务的出站边界(只对 guest 调用;不提供 = 不接受受邀者)。启动前登记任务用的供应商:本机* proxy 只让这条任务的请求经这个供应商、用它提供的模型。release 在任务结束时调用。@@ -1116,13 +1118,19 @@ export function createRemoteAgentHost(deps: RemoteAgentHostDeps) {// checks this authenticated, run-local endpoint before opening a stream.if (request.path === '/cindy/model-access') {let model: unknown;- try { model = JSON.parse(request.body?.toString('utf8') ?? '{}').model; } catch { /* deny */ }+ let providerId: unknown;+ try { ({ model, providerId } = JSON.parse(request.body?.toString('utf8') ?? '{}')); } catch { /* deny */ }const current = () => !run.closing && !signal.aborted && deps.isOwnerCurrent(run.owner)&& deps.isControllerAuthorized(run.controller);let allowed = false;try {- allowed = run.trust === 'guest' && current() && typeof model === 'string'- && !!model && model.length <= 512 && await run.guestRoute?.allowsModel?.(model) === true && current();+ if (request.method === 'POST' && current() && typeof model === 'string' && model && model.length <= 512) {+ allowed = run.trust === 'guest'+ ? (providerId === undefined || providerId === run.providerId) && await run.guestRoute?.allowsModel?.(model) === true+ : typeof providerId === 'string' && !!providerId && providerId.length <= 512 && !!run.ownerRoute+ && deps.ownerModelAllowed?.(hostSessionId, providerId, run.kind, model) === true;+ allowed = allowed && current();+ }} catch { /* Failed authorization must never open a native stream. */ }return { status: 200, headers: [['content-type', 'application/json']], body: Buffer.from(JSON.stringify({ allowed })) };}diff --git a/apps/desktop/src/main/remote-agent/host/service.ts b/apps/desktop/src/main/remote-agent/host/service.tsindex 73f35a4378..4e45f32fae 100644--- a/apps/desktop/src/main/remote-agent/host/service.ts+++ b/apps/desktop/src/main/remote-agent/host/service.ts@@ -30,7 +30,8 @@ import { currentProviderPartyUsageStore, flushProviderPartyUsage } from '../../uimport { readDeviceLinkSettings } from '../../device-link/settings-store.js';import { readTurnUsageResetAt } from '../../goal-host/usageLimit.js';import { getDesktopProviderService } from '../../maker-host/createDesktopProviderService.js';-import { bindHostedSessionProvider } from '../../maker-host/session-provider-store.js';+import { bindHostedSessionProvider, hasHostedSessionModelAccess } from '../../maker-host/session-provider-store.js';+import { hostedProviderOffersModel } from '../../maker-host/guest-provider-route-store.js';import { isRemoteProviderInvocationAllowed } from '../../maker-host/remote-provider-access-store.js';import { createGuestProviderRouteBinder, guestProviderModelIds, resolveGuestProviderId, resolveSharedProviderId } from './providerAccess';import { createRemoteAgentHost, type HostedStartInput, type RemoteAgentHost, type RunUsageRecord } from './runHost';@@ -141,6 +142,8 @@ export function installRemoteAgentHost(options: { getMaker: () => Maker; userDatstartHosted: (input) => options.getMaker().startHostedAgentSession(input.kind, hostedStartOptions(input)),forkHosted: (kind, opts) => options.getMaker().forkSdkSession(kind, opts),bindOwnerProviderRoute: bindHostedSessionProvider,+ ownerModelAllowed: (hostSessionId, providerId, kind, model) => hasHostedSessionModelAccess(hostSessionId)+ && hostedProviderOffersModel(hostSessionId, providerId, kind, model),isControllerAuthorized,controllerTrust: (controller) => (isProviderSharePeer(controller) ? 'guest' : 'owner'),providerAccess: {diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 769a1d8c74..bf2490b553 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -2817,6 +2817,9 @@ still use the same host-owned mail workflow as the chat card.需更新后才能提供中转成员模型范围保护。旧控制端无需理解 reverse 请求,它在组所在电脑消费;不新增通道或修改移动端原生配置。Pi 的原生供应商适配器只暴露获准模型,在打开流前用既有本机任务隧道的 bearer token 请求 `/cindy/model-access`,模型 ID 来自宿主冻结的授权映射。该路径由执行 Host 消费,复用同一绑定与复核,不转给控制端;凭证与消息内容不进入查询。+同账号 Pi 原生请求也走该本机入口,必须携带实际来源 `providerId`;Host 按该来源把原生模型 ID 解析为目录 ID,+复核当前任务绑定和远程模型范围。访客仍可省略该字段并使用已绑定的唯一来源,提供其他来源时拒绝。+适配器启动与热刷新保留来源标记;本机普通任务不生成标记,不增加远程授权检查。此扩展不改变跨电脑 wire 格式。## 伙伴导入的消息机器人分类diff --git a/docs/product-rules/provider-sharing.md b/docs/product-rules/provider-sharing.mdindex 9d1f9f5812..076b4e4a56 100644--- a/docs/product-rules/provider-sharing.md+++ b/docs/product-rules/provider-sharing.md@@ -585,6 +585,8 @@ Desktop「设置 → 模型供应商」的左栏(2026-10-08 用户裁决):经供应商组转发后,每次实际模型请求仍由组所在电脑按原成员的最新范围复核,并与执行电脑本地权限取交集;撤权、断连或无法完成复核时拒绝该请求。目录过滤不能替代请求校验;已运行任务中的旧目录也不能延续已撤销的权限。Pi 的 API Key 直连保留原生 SDK,由既有原生适配器在打开每条流前经本任务隧道复核,不依赖是否经过 HTTP 代理。+同账号远程任务也启用此检查:按原生运行时对应的实际供应商和模型解析目录 ID,再核对最新远程授权;+初始化、模型热刷新及子代理继承的适配器均保留检查,本机自用不启用远程授权门。受限任务不分给缺少这项复核能力的旧电脑;原本不限模型的旧电脑任务在新增限制时结束,重新分配到支持复核的电脑。## 13. 后续可选diff --git a/packages/maker-core/src/agents/pi/__tests__/nativeProviderAdapterRefresh.test.ts b/packages/maker-core/src/agents/pi/__tests__/nativeProviderAdapterRefresh.test.tsindex dd3851f5b6..877816aac5 100644--- a/packages/maker-core/src/agents/pi/__tests__/nativeProviderAdapterRefresh.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/nativeProviderAdapterRefresh.test.ts@@ -2,14 +2,14 @@ import { runInNewContext } from 'node:vm';import ts from 'typescript';import { describe, expect, it, vi } from 'vitest';import { CINDY_BRIDGE_EXTENSION_SOURCE } from '../cindy-bridge-source.js';-import { PI_NATIVE_PROVIDER_ADAPTER_SOURCE } from '../native-provider-adapter-source.js';+import { nativeProviderAdapterAliases, PI_NATIVE_PROVIDER_ADAPTER_SOURCE } from '../native-provider-adapter-source.js';type RegisteredProvider = { id: string; auth: { apiKey?: unknown; oauth?: unknown }; getModels: () => unknown[];streamSimple(model: unknown, context: unknown, options: unknown): Promise<unknown> };-type Alias = { id: string; name: string; provider: string; keyEnv?: string; models?: Array<{ id: string; grant: string }> };+type Alias = { id: string; name: string; provider: string; keyEnv?: string; remoteProviderId?: string; models?: Array<{ id: string; grant: string }> };-function loadAdapter(initialAliases: Alias[] = [], network?: { fetch: unknown; stream: unknown }) {+function loadAdapter(initialAliases: Alias[] = [], network?: { fetch: unknown; stream: unknown; guest?: boolean }) {const env: Record<string, string> = {CINDY_PI_NATIVE_PROVIDER_ADAPTERS: JSON.stringify(initialAliases),CINDY_PI_KEY_OLD: 'old-secret',@@ -49,7 +49,7 @@ function loadAdapter(initialAliases: Alias[] = [], network?: { fetch: unknown; s}).outputText;const sandbox: Record<string, unknown> = {process: { env },- CINDY_HOSTED: { guest: true, url: 'http://127.0.0.1:9', token: 'run-token' },+ CINDY_HOSTED: { guest: network?.guest ?? true, url: 'http://127.0.0.1:9', token: 'run-token' },fetch: network?.fetch, AbortSignal,__loadPiAi: async (name: string) => name.endsWith('/compat')? { getApiProvider: () => network ? { stream: network.stream, streamSimple: network.stream } : undefined }@@ -69,6 +69,34 @@ function loadAdapter(initialAliases: Alias[] = [], network?: { fetch: unknown; s}describe('Cindy native provider refresh bridge', () => {+ // Review 4333949156 / sharing §12, unit: existing native-stream coverage only+ // used guest=true. An owner-hosted BYOM provider must also query its real source+ // before the SDK, including after refresh; revoked/failed checks cannot stream.+ it.each([undefined, 'native'] as const)('checks owner native streams with adapter=%s at startup and after refresh', async adapterProvider => {+ const aliases = nativeProviderAdapterAliases([{ id: 'runtime', sourceProviderId: 'catalog-provider',+ name: 'BYOM', adapterProvider, models: [{ id: 'old' }],+ }], undefined, true);+ let allowed = true;+ const fetchGrant = vi.fn(async () => ({ ok: true, json: async () => ({ allowed }) }));+ const stream = vi.fn(async function* () {});+ const h = loadAdapter(aliases, { fetch: fetchGrant, stream, guest: false });+ const adapter = await h.adapter.registerCindyNativeProviderAdapters(h.pi);+ h.handlers.get('session_start')!({}, h.ctx);+ expect(h.providers.has('runtime')).toBe(true);+ const request = () => h.providers.get('runtime')!.streamSimple({ provider: 'runtime', id: 'old', api: 'openai-responses' }, { messages: [] }, {});+ await request();+ expect(fetchGrant).toHaveBeenCalledWith('http://127.0.0.1:9/cindy/model-access', expect.objectContaining({+ body: JSON.stringify({ model: 'old', providerId: 'catalog-provider' }),+ }));+ expect(stream).toHaveBeenCalledTimes(1);+ const snapshot = h.adapter.parseCindyProviderRefreshSnapshot(JSON.stringify({ nonce: 'abcdefghijklmnop', env: {}, aliases }), 'abcdefghijklmnop')!;+ await adapter.refresh(snapshot, h.ctx, new Set());+ allowed = false;+ await expect(request()).rejects.toThrow('not authorized');+ fetchGrant.mockRejectedValueOnce(new Error('disconnected'));+ await expect(request()).rejects.toThrow('disconnected');+ expect(stream).toHaveBeenCalledTimes(1);+ });// Unit, sharing §12: Pi API-key transports bypass the HTTP proxy. The existing// refresh tests never opened a native stream. Execute the generated adapter:// only A is listed; revocation/failure must stop before the native SDK opens.diff --git a/packages/maker-core/src/agents/pi/__tests__/pi-device-hosted-guest.test.ts b/packages/maker-core/src/agents/pi/__tests__/pi-device-hosted-guest.test.tsindex ee20aaf3d4..f4ca965a51 100644--- a/packages/maker-core/src/agents/pi/__tests__/pi-device-hosted-guest.test.ts+++ b/packages/maker-core/src/agents/pi/__tests__/pi-device-hosted-guest.test.ts@@ -390,7 +390,7 @@ describe('Pi device-hosted guest sessions', () => {expect(knobs.spawnedArgs).toHaveLength(0);});- it('keeps same-account provider routes unchanged', async () => {+ it('keeps same-account provider routes while attaching native remote model checks', async () => {const { deps, registered } = providerDeps();const { handle, env, configHome } = await start(false, { providerId: 'byom-a', model: 'model-a', deps });try {@@ -403,6 +403,12 @@ describe('Pi device-hosted guest sessions', () => {expect(env.CINDY_PI_VISION_BRIDGE_TEST).toBe('vision-secret');expect(Object.keys(readSubagentRoutes(env)).sort()).toEqual(['denied-model', 'm', 'model-a', 'model-b']);expect(new Set(registered)).toEqual(new Set(['byom-a', 'byom-b', null]));+ // §12 / review 4333949156: startup must guard every owner-native source,+ // including a child's source, instead of enabling the adapter only for guests.+ expect(JSON.parse(env.CINDY_PI_NATIVE_PROVIDER_ADAPTERS!)).toEqual([+ { id: 'byom-a', name: 'byom-a', provider: 'byom-a', keyEnv: 'CINDY_PI_KEY_BYOM_A', remoteProviderId: 'byom-a' },+ { id: 'byom-b', name: 'byom-b', provider: 'byom-b', keyEnv: 'CINDY_PI_KEY_BYOM_B', remoteProviderId: 'byom-b' },+ ]);} finally {await handle.close();}diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.tsindex 28a2a2bbd4..29c68483dd 100644--- a/packages/maker-core/src/agents/pi/index.ts+++ b/packages/maker-core/src/agents/pi/index.ts@@ -5537,7 +5537,7 @@ export class PiAgent extends BaseAgent {...(proxyEnv ?? {}),// BYOM 原生 provider 的 api keys(键名对应 spec.apiKeyEnvVar,models.json 用 $ENV 引用)。...nativeEnv,- CINDY_PI_NATIVE_PROVIDER_ADAPTERS: JSON.stringify(nativeProviderAdapterAliases(nativeProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined)),+ CINDY_PI_NATIVE_PROVIDER_ADAPTERS: JSON.stringify(nativeProviderAdapterAliases(nativeProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined, Boolean(hosted))),// 外部 MCP header 真值只经 env 交给 bridge extension;host 生成独立名字,// 且这些键已进入 piSecretEnvNames,LLM 可调用的 bash 子进程拿不到。...mcpEnv,@@ -6764,8 +6764,8 @@ export class PiAgent extends BaseAgent {const envChanged = Object.keys({ ...nativeEnv, ...latestEnv }).some((key) => nativeEnv[key] !== latestEnv[key],);- const adaptersChanged = JSON.stringify(nativeProviderAdapterAliases(nativeProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined))- !== JSON.stringify(nativeProviderAdapterAliases(latestProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined));+ const adaptersChanged = JSON.stringify(nativeProviderAdapterAliases(nativeProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined, Boolean(hosted)))+ !== JSON.stringify(nativeProviderAdapterAliases(latestProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined, Boolean(hosted)));let gatewayCredentialChanged = false;if (remote && gateway) {try {@@ -6837,7 +6837,7 @@ export class PiAgent extends BaseAgent {const gatewayAuthEnv = remote && nextGateway? await this.deps.auth.getAuthEnv({ credentialMode: 'gateway-key', providerId: requestedProviderId }): authEnv;- const nextAliases = nativeProviderAdapterAliases(nextProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined);+ const nextAliases = nativeProviderAdapterAliases(nextProviders, hostedGuest ? hosted?.guestProvider?.modelIds : undefined, Boolean(hosted));const mutableEnv = (value: Record<string, string>) => Object.fromEntries(Object.entries(value).filter(([key]) => /^CINDY_PI_KEY_[A-Z0-9_]+$/.test(key)|| key === PI_API_KEY_ENV || key === PI_SESSION_TOKEN_ENVdiff --git a/packages/maker-core/src/agents/pi/native-provider-adapter-source.ts b/packages/maker-core/src/agents/pi/native-provider-adapter-source.tsindex d950f72164..5d278bd7ef 100644--- a/packages/maker-core/src/agents/pi/native-provider-adapter-source.ts+++ b/packages/maker-core/src/agents/pi/native-provider-adapter-source.ts@@ -3,9 +3,10 @@ export function nativeProviderAdapterAliases(nativeProviders: Array<{ id: string; name: string; adapterProvider?: string; apiKeyEnvVar?: string;sourceProviderId?: string; models?: Array<{ id: string; wireId?: string }>; modelIdAliases?: Record<string, string> }>,guestModelIds?: readonly string[],-): Array<{ id: string; name: string; provider: string; keyEnv?: string; models?: Array<{ id: string; grant: string }> }> {+ hosted = false,+): Array<{ id: string; name: string; provider: string; keyEnv?: string; remoteProviderId?: string; models?: Array<{ id: string; grant: string }> }> {return nativeProviders.flatMap((provider) => {- const adapter = provider.adapterProvider ?? (guestModelIds ? provider.id : undefined);+ const adapter = provider.adapterProvider ?? (hosted || guestModelIds ? provider.id : undefined);const source = provider.sourceProviderId ?? provider.id;const models = guestModelIds ? (provider.models ?? []).flatMap(model => {const grant = guestModelIds.find(id => id === model.id || provider.modelIdAliases?.[id] === model.id@@ -16,6 +17,7 @@ export function nativeProviderAdapterAliases(id: provider.id,name: provider.name,provider: adapter,+ ...(hosted && !guestModelIds ? { remoteProviderId: source } : {}),...(provider.apiKeyEnvVar ? { keyEnv: provider.apiKeyEnvVar } : {}),...(models ? { models } : {}),}]@@ -24,7 +26,7 @@ export function nativeProviderAdapterAliases(}export const PI_NATIVE_PROVIDER_ADAPTER_SOURCE = String.raw`-type CindyAdapterAlias = { id: string; name: string; provider: string; keyEnv?: string; models?: Array<{ id: string; grant: string }> };+type CindyAdapterAlias = { id: string; name: string; provider: string; keyEnv?: string; remoteProviderId?: string; models?: Array<{ id: string; grant: string }> };type CindyProviderRefreshSnapshot = {nonce: string;env: Record<string, string>;@@ -62,6 +64,7 @@ function parseCindyProviderRefreshSnapshot(raw: unknown, nonce: string): CindyPrif (typeof alias.id !== 'string' || !alias.id || seen.has(alias.id)) return undefined;if (typeof alias.name !== 'string') return undefined;if (typeof alias.provider !== 'string' || !alias.provider) return undefined;+ if (alias.remoteProviderId !== undefined && (typeof alias.remoteProviderId !== 'string' || !alias.remoteProviderId)) return undefined;if (alias.keyEnv !== undefined && (typeof alias.keyEnv !== 'string'|| !cindyRefreshEnvAllowed(alias.keyEnv)@@ -71,6 +74,7 @@ function parseCindyProviderRefreshSnapshot(raw: unknown, nonce: string): CindyPr!model || typeof model.id !== 'string' || !model.id || typeof model.grant !== 'string' || !model.grant))) return undefined;seen.add(alias.id);aliases.push({ id: alias.id, name: alias.name, provider: alias.provider,+ ...(alias.remoteProviderId ? { remoteProviderId: alias.remoteProviderId } : {}),...(alias.keyEnv ? { keyEnv: alias.keyEnv } : {}),...(alias.models ? { models: alias.models.map((model: any) => ({ id: model.id, grant: model.grant })) } : {}) });}@@ -103,15 +107,15 @@ async function registerCindyNativeProviderAdapters(pi: any) {&& (!alias.models || alias.models.some(allowed => allowed.id === model.id)));if (providerModels.length === 0 && !alias.models) continue;const stream = (model: any, context: any, options: any, simple: boolean) => lazyStream(model, async () => {- if (alias.models) {- const grant = alias.models.find(allowed => allowed.id === model.id)?.grant;- if (!grant || !CINDY_HOSTED?.guest) throw new Error('The model is not authorized for this shared task');+ if (alias.models || alias.remoteProviderId) {+ const grant = alias.models ? alias.models.find(allowed => allowed.id === model.id)?.grant : model.id;+ if (!grant || !CINDY_HOSTED || (CINDY_HOSTED.guest && !alias.models)) throw new Error('The model is not authorized for this remote task');const signal = options?.signal ? AbortSignal.any([options.signal, AbortSignal.timeout(10000)]) : AbortSignal.timeout(10000);const response = await fetch(CINDY_HOSTED.url + '/cindy/model-access', {method: 'POST', headers: { Authorization: 'Bearer ' + CINDY_HOSTED.token, 'content-type': 'application/json' },- body: JSON.stringify({ model: grant }), signal,+ body: JSON.stringify({ model: grant, ...(alias.remoteProviderId ? { providerId: alias.remoteProviderId } : {}) }), signal,});- if (!response.ok || (await response.json()).allowed !== true) throw new Error('The model is not authorized for this shared task');+ if (!response.ok || (await response.json()).allowed !== true) throw new Error('The model is not authorized for this remote task');}const api = getApiProvider(model.api);if (!api) throw new Error('The selected native provider API is unavailable');