mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-23 16:34:27 +00:00
🌳 feat: Isolate Attached Workspaces by Conversation (#16107)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Waiting to run
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Blocked by required conditions
* feat: bind attached workspaces to conversations
* ⬆️ chore: bump agents to 3.8.8
This commit is contained in:
parent
36efc7b4e2
commit
2df937dd06
21 changed files with 339 additions and 32 deletions
|
|
@ -93,7 +93,11 @@ describe('getCodeBridgeWorkerStatus', () => {
|
|||
protocolVersion: 1,
|
||||
operations: ['read_file', 'execute_command'],
|
||||
workspaces: [
|
||||
{ id: 'project-a', name: 'Project A' },
|
||||
{
|
||||
id: 'project-a',
|
||||
name: 'Project A',
|
||||
workspaceInstances: ['git_worktree'],
|
||||
},
|
||||
{ id: 'docs', operations: ['read_file'] },
|
||||
],
|
||||
},
|
||||
|
|
@ -120,7 +124,11 @@ describe('getCodeBridgeWorkerStatus', () => {
|
|||
runtimes: ['bash'],
|
||||
operations: ['read_file', 'execute_command'],
|
||||
workspaces: [
|
||||
{ id: 'project-a', name: 'Project A' },
|
||||
{
|
||||
id: 'project-a',
|
||||
name: 'Project A',
|
||||
workspaceInstances: ['git_worktree'],
|
||||
},
|
||||
{ id: 'docs', operations: ['read_file'] },
|
||||
],
|
||||
});
|
||||
|
|
@ -196,6 +204,21 @@ describe('getCodeBridgeWorkerStatus', () => {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
online: true,
|
||||
ready: true,
|
||||
leaseExpiresInMs: 5_000,
|
||||
capabilities: {
|
||||
statefulWorkspace: true,
|
||||
sandboxProfile: 'native-srt',
|
||||
runtimes: ['bash'],
|
||||
workspaceTools: {
|
||||
protocolVersion: 1,
|
||||
operations: ['read_file'],
|
||||
workspaces: [{ id: 'project-a', workspaceInstances: ['container'] }],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
online: true,
|
||||
ready: true,
|
||||
|
|
|
|||
|
|
@ -194,6 +194,7 @@ function validWorkspaceCapabilities(value: unknown): value is {
|
|||
key !== 'id' &&
|
||||
key !== 'name' &&
|
||||
key !== 'operations' &&
|
||||
key !== 'workspaceInstances' &&
|
||||
key !== 'environment' &&
|
||||
key !== 'instructions',
|
||||
) ||
|
||||
|
|
@ -205,6 +206,10 @@ function validWorkspaceCapabilities(value: unknown): value is {
|
|||
workspace.instructions.length > 1 ||
|
||||
!workspace.instructions.every(isRepositoryInstructionDescriptor))) ||
|
||||
(workspace.environment !== undefined && !isCodeWorkspaceEnvironment(workspace.environment)) ||
|
||||
(workspace.workspaceInstances !== undefined &&
|
||||
(!Array.isArray(workspace.workspaceInstances) ||
|
||||
workspace.workspaceInstances.length !== 1 ||
|
||||
workspace.workspaceInstances[0] !== 'git_worktree')) ||
|
||||
(workspace.name !== undefined &&
|
||||
(typeof workspace.name !== 'string' ||
|
||||
workspace.name.trim().length === 0 ||
|
||||
|
|
|
|||
|
|
@ -433,6 +433,34 @@ describe('resolveCodeExecutionWorkspaceContext', () => {
|
|||
expect(resolved.codeWorkspace?.environment).toEqual(environment);
|
||||
});
|
||||
|
||||
it('activates a server-derived instance only when the worker advertises worktree support', async () => {
|
||||
const workspaceInstanceId = 'c'.repeat(64);
|
||||
jest
|
||||
.spyOn(globalThis, 'fetch')
|
||||
.mockResolvedValue(
|
||||
workspaceStatus([
|
||||
{ id: 'worktree', workspaceInstances: ['git_worktree'] },
|
||||
{ id: 'legacy' },
|
||||
]),
|
||||
);
|
||||
|
||||
const supported = await resolveCodeExecutionWorkspaceContext({
|
||||
context: { ...context, conversationWorkspaceInstanceId: workspaceInstanceId },
|
||||
requestedSelections: [{ environmentId: 'personal', workspaceId: 'worktree' }],
|
||||
environments,
|
||||
getAppConfig,
|
||||
});
|
||||
const legacy = await resolveCodeExecutionWorkspaceContext({
|
||||
context: { ...context, conversationWorkspaceInstanceId: workspaceInstanceId },
|
||||
requestedSelections: [{ environmentId: 'personal', workspaceId: 'legacy' }],
|
||||
environments,
|
||||
getAppConfig,
|
||||
});
|
||||
|
||||
expect(supported.codeWorkspace?.workspaceInstanceId).toBe(workspaceInstanceId);
|
||||
expect(legacy.codeWorkspace).not.toHaveProperty('workspaceInstanceId');
|
||||
});
|
||||
|
||||
it('admits native workspace tools without enabling programmatic runtime execution', async () => {
|
||||
jest
|
||||
.spyOn(globalThis, 'fetch')
|
||||
|
|
|
|||
|
|
@ -178,6 +178,10 @@ export async function resolveCodeExecutionWorkspaceContext({
|
|||
codeWorkspace: {
|
||||
...selection,
|
||||
operations: [...(workspace.operations ?? status.operations)],
|
||||
...(context.conversationWorkspaceInstanceId &&
|
||||
workspace.workspaceInstances?.includes('git_worktree')
|
||||
? { workspaceInstanceId: context.conversationWorkspaceInstanceId }
|
||||
: {}),
|
||||
...(status.maxCommandTimeoutMs == null
|
||||
? {}
|
||||
: { maxCommandTimeoutMs: status.maxCommandTimeoutMs }),
|
||||
|
|
|
|||
|
|
@ -76,15 +76,20 @@ describe('programmatic Bash Git identity', () => {
|
|||
}
|
||||
});
|
||||
|
||||
test('pins a selected project on the real SDK no-tools route', async () => {
|
||||
const received: { url?: string; workspace?: string | string[]; code: string }[] = [];
|
||||
test('pins the selected project and conversation instance on the real SDK no-tools route', async () => {
|
||||
const received: {
|
||||
url?: string;
|
||||
workspace?: string | string[];
|
||||
code: string;
|
||||
workspace_instance_id?: string;
|
||||
}[] = [];
|
||||
const server = createServer(async (req, res) => {
|
||||
let body = '';
|
||||
for await (const chunk of req) body += chunk;
|
||||
received.push({
|
||||
url: req.url,
|
||||
workspace: req.headers['x-librechat-code-workspace-id'],
|
||||
code: JSON.parse(body).code,
|
||||
...JSON.parse(body),
|
||||
});
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
res.end(JSON.stringify({ status: 'completed', stdout: 'done', stderr: '', files: [] }));
|
||||
|
|
@ -92,11 +97,13 @@ describe('programmatic Bash Git identity', () => {
|
|||
server.listen(0, '127.0.0.1');
|
||||
await once(server, 'listening');
|
||||
const { port } = server.address() as AddressInfo;
|
||||
const workspaceInstanceId = 'a'.repeat(64);
|
||||
try {
|
||||
const bashTool = createGitIdentityProgrammaticBashTool(
|
||||
{
|
||||
baseUrl: `http://127.0.0.1:${port}/v1`,
|
||||
workspaceId: 'project-a',
|
||||
workspaceInstanceId,
|
||||
authHeaders: () => ({}),
|
||||
},
|
||||
{ name: 'Lia', email: 'lia@example.com' },
|
||||
|
|
@ -108,7 +115,11 @@ describe('programmatic Bash Git identity', () => {
|
|||
invocationConfig,
|
||||
);
|
||||
expect(received).toHaveLength(1);
|
||||
expect(received[0]).toMatchObject({ url: '/v1/exec/programmatic', workspace: 'project-a' });
|
||||
expect(received[0]).toMatchObject({
|
||||
url: '/v1/exec/programmatic',
|
||||
workspace: 'project-a',
|
||||
workspace_instance_id: workspaceInstanceId,
|
||||
});
|
||||
expect(received[0].code).toContain("GIT_AUTHOR_NAME='Lia'");
|
||||
expect(bashTool.description).toContain('selected persistent workspace');
|
||||
} finally {
|
||||
|
|
@ -152,6 +163,26 @@ function commandResponse(overrides: Record<string, unknown> = {}): Response {
|
|||
}
|
||||
|
||||
describe('createAttachedWorkspaceBashTool', () => {
|
||||
test('dispatches commands to the resolved conversation workspace instance', async () => {
|
||||
const fetchImpl: CodeBridgeFetch = jest.fn(async () => commandResponse());
|
||||
const workspaceInstanceId = 'e'.repeat(64);
|
||||
const bashTool = createAttachedWorkspaceBashTool({
|
||||
baseUrl: 'https://code.example.com/v1/',
|
||||
authHeaders: () => ({}),
|
||||
workspaceId: 'project-a',
|
||||
workspaceInstanceId,
|
||||
fetchImpl,
|
||||
});
|
||||
|
||||
await bashTool.invoke({ command: 'pwd' });
|
||||
|
||||
const [, options] = (fetchImpl as jest.Mock).mock.calls[0];
|
||||
expect(JSON.parse(options.body)).toMatchObject({
|
||||
workspaceId: 'project-a',
|
||||
workspaceInstanceId,
|
||||
});
|
||||
});
|
||||
|
||||
test('dispatches only advertised named actions with the resolved definition fingerprint', async () => {
|
||||
const fetchImpl: CodeBridgeFetch = jest.fn(async () => commandResponse());
|
||||
const bashTool = createAttachedWorkspaceBashTool({
|
||||
|
|
|
|||
|
|
@ -229,24 +229,25 @@ export function createContextProgrammaticBashTool(
|
|||
identity?: AgentGitIdentity | null,
|
||||
): DynamicStructuredTool {
|
||||
const attached = context?.environmentType === 'attached';
|
||||
return createGitIdentityProgrammaticBashTool(
|
||||
{
|
||||
authHeaders,
|
||||
baseUrl: context?.baseUrl,
|
||||
executionProfile: context?.executionProfile,
|
||||
runtimeSessionHint: context?.runtimeSessionHint,
|
||||
...(attached
|
||||
? {
|
||||
workspaceId: context.codeWorkspace?.workspaceId,
|
||||
runTimeoutMs: resolveAttachedWorkspaceProgrammaticTimeout(
|
||||
context.codeEnvironmentConfigSchema,
|
||||
context.codeWorkspace?.maxCommandTimeoutMs,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
attached ? identity : undefined,
|
||||
);
|
||||
const options: Parameters<typeof createBashProgrammaticToolCallingTool>[0] & {
|
||||
workspaceInstanceId?: string;
|
||||
} = {
|
||||
authHeaders,
|
||||
baseUrl: context?.baseUrl,
|
||||
executionProfile: context?.executionProfile,
|
||||
runtimeSessionHint: context?.runtimeSessionHint,
|
||||
...(attached
|
||||
? {
|
||||
workspaceId: context.codeWorkspace?.workspaceId,
|
||||
workspaceInstanceId: context.codeWorkspace?.workspaceInstanceId,
|
||||
runTimeoutMs: resolveAttachedWorkspaceProgrammaticTimeout(
|
||||
context.codeEnvironmentConfigSchema,
|
||||
context.codeWorkspace?.maxCommandTimeoutMs,
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
return createGitIdentityProgrammaticBashTool(options, attached ? identity : undefined);
|
||||
}
|
||||
|
||||
/** Apply authorship before the SDK prepares the script and its replay requests. */
|
||||
|
|
@ -280,6 +281,7 @@ export function createAttachedWorkspaceBashTool({
|
|||
baseUrl,
|
||||
authHeaders,
|
||||
workspaceId,
|
||||
workspaceInstanceId,
|
||||
environment,
|
||||
gitIdentity,
|
||||
maxTimeoutMs = WORKSPACE_COMMAND_DEFAULT_TIMEOUT_MS,
|
||||
|
|
@ -289,6 +291,7 @@ export function createAttachedWorkspaceBashTool({
|
|||
baseUrl: string;
|
||||
authHeaders: () => Promise<Record<string, string>> | Record<string, string>;
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
environment?: CodeWorkspaceDescriptor['environment'];
|
||||
gitIdentity?: AgentGitIdentity | null;
|
||||
/** Effective admin/upstream ceiling already intersected with the protocol hard cap. */
|
||||
|
|
@ -361,6 +364,7 @@ export function createAttachedWorkspaceBashTool({
|
|||
protocolVersion: 1,
|
||||
operation: 'execute_command',
|
||||
workspaceId,
|
||||
...(workspaceInstanceId ? { workspaceInstanceId } : {}),
|
||||
command,
|
||||
...(action && environment
|
||||
? { environmentAction: { name: action, fingerprint: environment.fingerprint } }
|
||||
|
|
|
|||
|
|
@ -103,6 +103,38 @@ describe('repository instruction loading', () => {
|
|||
expect(await load({ ...input, mode: 'defer' })).toContain('unless they conflict');
|
||||
});
|
||||
|
||||
it('reads and caches instructions within the resolved conversation worktree', async () => {
|
||||
const load = createRepositoryInstructionLoader();
|
||||
let requestBody: string | undefined;
|
||||
const fetchImpl = jest.fn(
|
||||
async (_input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => {
|
||||
requestBody = init?.body as string | undefined;
|
||||
return response();
|
||||
},
|
||||
);
|
||||
const workspaceInstanceId = 'f'.repeat(64);
|
||||
const scopedContext = {
|
||||
...context,
|
||||
codeWorkspace: { ...context.codeWorkspace!, workspaceInstanceId },
|
||||
};
|
||||
const input = {
|
||||
enabled: true,
|
||||
context: scopedContext,
|
||||
principalId: 'alice',
|
||||
fetchImpl,
|
||||
authHeaders: async () => ({}),
|
||||
assertContent: jest.fn(),
|
||||
};
|
||||
|
||||
await load(input);
|
||||
await load(input);
|
||||
|
||||
expect(fetchImpl).toHaveBeenCalledTimes(1);
|
||||
expect(JSON.parse(requestBody!)).toMatchObject({
|
||||
workspaceInstanceId,
|
||||
});
|
||||
});
|
||||
|
||||
it('omits changed, missing and unauthorized instruction snapshots', async () => {
|
||||
const load = createRepositoryInstructionLoader();
|
||||
const input = {
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ export function createRepositoryInstructionLoader() {
|
|||
context.baseUrl,
|
||||
context.bridgeWorkerId,
|
||||
workspace.workspaceId,
|
||||
workspace.workspaceInstanceId ?? null,
|
||||
descriptor.path,
|
||||
descriptor.sha256,
|
||||
]);
|
||||
|
|
@ -103,6 +104,9 @@ export function createRepositoryInstructionLoader() {
|
|||
protocolVersion: 1,
|
||||
operation: 'read_file',
|
||||
workspaceId: workspace.workspaceId,
|
||||
...(workspace.workspaceInstanceId
|
||||
? { workspaceInstanceId: workspace.workspaceInstanceId }
|
||||
: {}),
|
||||
path: descriptor.path,
|
||||
instructionSha256: descriptor.sha256,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,6 +3,57 @@ import type { CodeBridgeFetch } from './bridge';
|
|||
import { executeWorkspaceTool, WorkspaceToolHttpError } from './workspace';
|
||||
|
||||
describe('workspace admission feedback', () => {
|
||||
test('forwards a valid conversation workspace instance unchanged', async () => {
|
||||
const workspaceInstanceId = 'd'.repeat(64);
|
||||
const fetchImpl = jest.fn().mockResolvedValue(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
protocolVersion: 1,
|
||||
operation: 'write_file',
|
||||
workspaceId: 'primary',
|
||||
path: 'notes.txt',
|
||||
created: true,
|
||||
bytesWritten: 5,
|
||||
}),
|
||||
{ status: 200, headers: { 'Content-Type': 'application/json' } },
|
||||
),
|
||||
);
|
||||
|
||||
await executeWorkspaceTool({
|
||||
baseURL: 'https://code.example/v1',
|
||||
authHeaders: {},
|
||||
fetchImpl,
|
||||
request: {
|
||||
protocolVersion: 1,
|
||||
operation: 'write_file',
|
||||
workspaceId: 'primary',
|
||||
workspaceInstanceId,
|
||||
path: 'notes.txt',
|
||||
content: 'ready',
|
||||
},
|
||||
});
|
||||
|
||||
expect(JSON.parse(fetchImpl.mock.calls[0][1].body)).toMatchObject({ workspaceInstanceId });
|
||||
});
|
||||
|
||||
test('rejects malformed workspace instance identifiers before transport', async () => {
|
||||
const fetchImpl = jest.fn();
|
||||
await expect(
|
||||
executeWorkspaceTool({
|
||||
baseURL: 'https://code.example/v1',
|
||||
authHeaders: {},
|
||||
fetchImpl,
|
||||
request: {
|
||||
protocolVersion: 1,
|
||||
operation: 'list_files',
|
||||
workspaceId: 'primary',
|
||||
workspaceInstanceId: 'conversation-1',
|
||||
},
|
||||
}),
|
||||
).rejects.toBeInstanceOf(WorkspaceToolHttpError);
|
||||
expect(fetchImpl).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('identifies definite pre-execution expiry without retrying the operation', async () => {
|
||||
const fetchImpl = jest.fn().mockResolvedValue(
|
||||
new Response(JSON.stringify({ code: 'WORKSPACE_QUEUE_TIMEOUT' }), {
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ export interface WorkspaceReadRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'read_file';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
path: string;
|
||||
startLine?: number;
|
||||
maxLines?: number;
|
||||
|
|
@ -109,6 +110,7 @@ export interface WorkspaceSearchRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'search_text';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
query: string;
|
||||
path?: string;
|
||||
maxResults?: number;
|
||||
|
|
@ -118,6 +120,7 @@ export interface WorkspaceListRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'list_files';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
path?: string;
|
||||
maxResults?: number;
|
||||
afterPath?: string;
|
||||
|
|
@ -127,6 +130,7 @@ export interface WorkspaceExecuteCommandRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'execute_command';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
command: string;
|
||||
cwd?: string;
|
||||
timeoutMs?: number;
|
||||
|
|
@ -138,6 +142,7 @@ export interface WorkspaceWriteRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'write_file';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
path: string;
|
||||
content: string;
|
||||
overwrite?: boolean;
|
||||
|
|
@ -152,6 +157,7 @@ export interface WorkspaceEditRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'edit_file';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
path: string;
|
||||
edits: WorkspaceTextEdit[];
|
||||
expectedBaseSha256?: string;
|
||||
|
|
@ -161,6 +167,7 @@ export interface WorkspacePreviewEditRequest {
|
|||
protocolVersion: 1;
|
||||
operation: 'preview_edit';
|
||||
workspaceId: string;
|
||||
workspaceInstanceId?: string;
|
||||
path: string;
|
||||
edits: WorkspaceTextEdit[];
|
||||
}
|
||||
|
|
@ -486,7 +493,9 @@ async function readBoundedJson(response: Response, signal?: AbortSignal): Promis
|
|||
function isValidRequest(request: WorkspaceToolRequest): boolean {
|
||||
if (
|
||||
request.protocolVersion !== 1 ||
|
||||
!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(request.workspaceId)
|
||||
!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(request.workspaceId) ||
|
||||
(request.workspaceInstanceId !== undefined &&
|
||||
!/^[a-f0-9]{64}$/.test(request.workspaceInstanceId))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue