@ct-agents/worker 0.2.0 → 0.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ct-agents/worker",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -12,12 +12,12 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "zod": "4.4.3",
15
- "@ct-agents/harness": "0.2.0",
16
- "@ct-agents/memory": "0.2.0",
17
- "@ct-agents/environment": "0.2.0",
18
- "@ct-agents/prompts": "0.2.0",
19
- "@ct-agents/protocol": "0.2.0",
20
- "@ct-agents/tools": "0.2.0"
15
+ "@ct-agents/harness": "0.2.2",
16
+ "@ct-agents/environment": "0.2.2",
17
+ "@ct-agents/prompts": "0.2.2",
18
+ "@ct-agents/memory": "0.2.2",
19
+ "@ct-agents/protocol": "0.2.2",
20
+ "@ct-agents/tools": "0.2.2"
21
21
  },
22
22
  "optionalDependencies": {
23
23
  "dockerode": "4.0.9"
package/src/index.ts CHANGED
@@ -150,7 +150,13 @@ export type RunContextResolverWorkerLoopInput = ContextResolverWorkerInput & {
150
150
  };
151
151
 
152
152
  export const DEFAULT_CLAIM_BLOCK_MS = 15_000;
153
- const PLATFORM_PROXY_RESOURCE_SLOTS = new Set(['skills', 'memory']);
153
+ const PLATFORM_PROXY_RESOURCE_CAPABILITIES = [
154
+ { slot: 'skills', implementationId: 'platform-skills-store' },
155
+ { slot: 'memory', implementationId: 'platform-memory-store' },
156
+ ] as const;
157
+ const PLATFORM_PROXY_RESOURCE_SLOTS = new Set<string>(
158
+ PLATFORM_PROXY_RESOURCE_CAPABILITIES.map((capability) => capability.slot),
159
+ );
154
160
 
155
161
  export function createPlatformBuiltinToolHandlers(): ToolHandler[] {
156
162
  return [
@@ -173,6 +179,7 @@ export function createWorkerCapabilityRegistration(input: {
173
179
  implementationReleaseId: string;
174
180
  toolRegistry: ToolRegistry;
175
181
  resourceImpls: EnvironmentWorkerResourceImplementations;
182
+ platformResourceProxy?: boolean;
176
183
  }): WorkerCapabilityRegistration {
177
184
  const toolRegistry = withPlatformBuiltinTools(input.toolRegistry);
178
185
  const toolCapabilities = toolRegistry.listTools().map((descriptor) => {
@@ -194,6 +201,15 @@ export function createWorkerCapabilityRegistration(input: {
194
201
  const resourceCapabilities = Object.entries(input.resourceImpls).flatMap(([slot, implementations]) => (
195
202
  Object.keys(implementations).map((implementationId) => ({ slot, implementationId }))
196
203
  ));
204
+ if (input.platformResourceProxy) {
205
+ for (const capability of PLATFORM_PROXY_RESOURCE_CAPABILITIES) {
206
+ if (!resourceCapabilities.some((candidate) => (
207
+ candidate.slot === capability.slot && candidate.implementationId === capability.implementationId
208
+ ))) {
209
+ resourceCapabilities.push(capability);
210
+ }
211
+ }
212
+ }
197
213
  return {
198
214
  workerInstanceId: input.workerInstanceId,
199
215
  implementationReleaseId: input.implementationReleaseId,
@@ -19,6 +19,8 @@ import type { EnvironmentWorkerResourceImplementation } from '../../index.js';
19
19
 
20
20
  const DEFAULT_MAX_OUTPUT_TOKENS = 4_096;
21
21
  const DEFAULT_TIMEOUT_MS = 60_000;
22
+ const DEFAULT_PROVIDER = 'anthropic' as const;
23
+ const DEFAULT_MODEL = 'deepseek-v4-flash';
22
24
  const MAX_PROMPT_BYTES = 512 * 1_024;
23
25
  const MAX_SYSTEM_PROMPT_BYTES = 32 * 1_024;
24
26
  const MAX_RESPONSE_BYTES = 1_024 * 1_024;
@@ -383,6 +385,12 @@ export function createTextGenerationResourceDefinition(
383
385
  title: '模型 Provider API',
384
386
  description: '通过 OpenAI 或 Anthropic 兼容 API 生成文本。',
385
387
  supportedExecutionModes: ['hosted', 'self_hosted'],
388
+ defaultOptions: {
389
+ provider: DEFAULT_PROVIDER,
390
+ defaultModel: DEFAULT_MODEL,
391
+ maxOutputTokens: DEFAULT_MAX_OUTPUT_TOKENS,
392
+ timeoutMs: DEFAULT_TIMEOUT_MS,
393
+ },
386
394
  optionsSchema: textGenerationOptionsSchema,
387
395
  optionsJsonSchema: z.toJSONSchema(textGenerationOptionsSchema),
388
396
  factory: (options) => createTextGenerationResource(
@@ -401,6 +401,7 @@ export function createTavilyWebSearchResourceDefinition(
401
401
  title: 'Tavily',
402
402
  description: '通过 Tavily 官方 Search API 搜索公开互联网内容。',
403
403
  supportedExecutionModes: ['hosted', 'self_hosted'],
404
+ defaultOptions: { timeoutMs: 30_000 },
404
405
  optionsSchema: tavilyWebSearchOptionsSchema,
405
406
  optionsJsonSchema: z.toJSONSchema(tavilyWebSearchOptionsSchema),
406
407
  factory: (options) => createTavilyWebSearchResource(tavilyWebSearchOptionsSchema.parse(options), dependencies),
@@ -29,6 +29,7 @@ export function createSandboxResourceDefinition(): ResourceDefinition<Sandbox> {
29
29
  id: 'local-process',
30
30
  title: 'Local process',
31
31
  description: '本地开发用 sandbox 声明;生产应替换为隔离实现。',
32
+ defaultOptions: {},
32
33
  optionsSchema: sandboxResourceOptionsSchema,
33
34
  optionsJsonSchema: z.toJSONSchema(sandboxResourceOptionsSchema),
34
35
  factory: () => {