@ct-agents/worker 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/index.ts +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ct-agents/worker",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src"
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"zod": "4.4.3",
|
|
15
|
-
"@ct-agents/memory": "0.0
|
|
16
|
-
"@ct-agents/prompts": "0.0
|
|
17
|
-
"@ct-agents/
|
|
18
|
-
"@ct-agents/
|
|
15
|
+
"@ct-agents/memory": "0.1.0",
|
|
16
|
+
"@ct-agents/prompts": "0.1.0",
|
|
17
|
+
"@ct-agents/protocol": "0.1.0",
|
|
18
|
+
"@ct-agents/tools": "0.1.0"
|
|
19
19
|
},
|
|
20
20
|
"optionalDependencies": {
|
|
21
21
|
"dockerode": "4.0.9"
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
EnvironmentId,
|
|
7
7
|
EnvironmentExecutionMode,
|
|
8
8
|
EnvironmentHostedPolicy,
|
|
9
|
-
EnvironmentResourceSlotRegistrationDto,
|
|
10
9
|
ExecutionScope,
|
|
11
10
|
HarnessId,
|
|
12
11
|
ResourceSlots,
|
|
@@ -541,41 +540,6 @@ export type HttpWorkQueueClientInput = {
|
|
|
541
540
|
signal?: AbortSignal;
|
|
542
541
|
};
|
|
543
542
|
|
|
544
|
-
export type RegisterEnvironmentCatalogInput = {
|
|
545
|
-
baseUrl: string;
|
|
546
|
-
environmentKey: string;
|
|
547
|
-
tools: ToolDescriptor[];
|
|
548
|
-
resourceSlots?: EnvironmentResourceSlotRegistrationDto[];
|
|
549
|
-
fetchImpl?: typeof fetch;
|
|
550
|
-
signal?: AbortSignal;
|
|
551
|
-
};
|
|
552
|
-
|
|
553
|
-
export async function registerEnvironmentCatalog(input: RegisterEnvironmentCatalogInput): Promise<{
|
|
554
|
-
registered: number;
|
|
555
|
-
resourceSlots: number;
|
|
556
|
-
}> {
|
|
557
|
-
const fetchImpl = input.fetchImpl ?? fetch;
|
|
558
|
-
const headers = new Headers();
|
|
559
|
-
headers.set('x-api-key', input.environmentKey);
|
|
560
|
-
headers.set('content-type', 'application/json');
|
|
561
|
-
const body = {
|
|
562
|
-
tools: input.tools,
|
|
563
|
-
...(input.resourceSlots ? { resourceSlots: input.resourceSlots } : {}),
|
|
564
|
-
};
|
|
565
|
-
const response = await fetchImpl(`${trimTrailingSlash(input.baseUrl)}/v1/tools/registrations`, {
|
|
566
|
-
method: 'POST',
|
|
567
|
-
headers,
|
|
568
|
-
body: JSON.stringify(body),
|
|
569
|
-
signal: input.signal,
|
|
570
|
-
});
|
|
571
|
-
const data = await parseApiEnvelope(response, '平台工具目录上报失败');
|
|
572
|
-
const record = expectRecord(data, '工具目录上报响应缺少 data');
|
|
573
|
-
return {
|
|
574
|
-
registered: expectNumber(record.registered, 'registered'),
|
|
575
|
-
resourceSlots: expectNumber(record.resourceSlots, 'resourceSlots'),
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
|
|
579
543
|
export function zodObjectToJsonSchema(schema: z.ZodType<unknown>): Record<string, unknown> {
|
|
580
544
|
const jsonSchema = z.toJSONSchema(schema) as Record<string, unknown>;
|
|
581
545
|
const normalized = normalizeCatalogJsonSchema(jsonSchema, true);
|