@namzu/sdk 1.3.0 → 2.0.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/CHANGELOG.md +106 -0
- package/dist/compaction/__tests__/verifier-empty-reply.test.d.ts +12 -0
- package/dist/compaction/__tests__/verifier-empty-reply.test.d.ts.map +1 -0
- package/dist/compaction/__tests__/verifier-empty-reply.test.js +73 -0
- package/dist/compaction/__tests__/verifier-empty-reply.test.js.map +1 -0
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +10 -1
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/config/__tests__/compaction-budget-schema.test.d.ts +18 -0
- package/dist/config/__tests__/compaction-budget-schema.test.d.ts.map +1 -0
- package/dist/config/__tests__/compaction-budget-schema.test.js +96 -0
- package/dist/config/__tests__/compaction-budget-schema.test.js.map +1 -0
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +20 -11
- package/dist/config/runtime.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +2 -1
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +3 -1
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/provider/__tests__/errors.test.d.ts +2 -0
- package/dist/provider/__tests__/errors.test.d.ts.map +1 -0
- package/dist/provider/__tests__/errors.test.js +61 -0
- package/dist/provider/__tests__/errors.test.js.map +1 -0
- package/dist/provider/errors.d.ts +108 -0
- package/dist/provider/errors.d.ts.map +1 -0
- package/dist/provider/errors.js +311 -0
- package/dist/provider/errors.js.map +1 -0
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +1 -0
- package/dist/provider/index.js.map +1 -1
- package/dist/public-runtime.d.ts +11 -11
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +11 -11
- package/dist/public-runtime.js.map +1 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +45 -12
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/execute.test.js +104 -7
- package/dist/registry/tool/execute.test.js.map +1 -1
- package/dist/registry/toolset/catalog.d.ts.map +1 -1
- package/dist/registry/toolset/catalog.js +17 -4
- package/dist/registry/toolset/catalog.js.map +1 -1
- package/dist/registry/toolset/catalog.test.js +101 -0
- package/dist/registry/toolset/catalog.test.js.map +1 -1
- package/dist/runtime/query/__tests__/capability-negotiation.test.js +79 -0
- package/dist/runtime/query/__tests__/capability-negotiation.test.js.map +1 -1
- package/dist/runtime/query/__tests__/deferred-tools.test.js +100 -0
- package/dist/runtime/query/__tests__/deferred-tools.test.js.map +1 -1
- package/dist/runtime/query/__tests__/long-document-flow.test.js +12 -12
- package/dist/runtime/query/__tests__/long-document-flow.test.js.map +1 -1
- package/dist/runtime/query/__tests__/stream-recovery.test.js +55 -2
- package/dist/runtime/query/__tests__/stream-recovery.test.js.map +1 -1
- package/dist/runtime/query/executor.js +2 -2
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +10 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.d.ts +32 -0
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js +152 -0
- package/dist/runtime/query/iteration/phases/compaction-safe-cut.test.js.map +1 -0
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +52 -12
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +11 -5
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +11 -1
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/tools/builtins/__tests__/edit.test.js +216 -10
- package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/payload-budget.test.js +30 -16
- package/dist/tools/builtins/__tests__/payload-budget.test.js.map +1 -1
- package/dist/tools/builtins/__tests__/write-file.test.js +37 -13
- package/dist/tools/builtins/__tests__/write-file.test.js.map +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts +13 -0
- package/dist/tools/builtins/atomic-write-file.d.ts.map +1 -0
- package/dist/tools/builtins/atomic-write-file.js +46 -0
- package/dist/tools/builtins/atomic-write-file.js.map +1 -0
- package/dist/tools/builtins/bash.js +2 -2
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts +2 -5
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +105 -125
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-mutation-lock.d.ts +7 -0
- package/dist/tools/builtins/file-mutation-lock.d.ts.map +1 -0
- package/dist/tools/builtins/file-mutation-lock.js +25 -0
- package/dist/tools/builtins/file-mutation-lock.js.map +1 -0
- package/dist/tools/builtins/index.js +2 -2
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts +1 -2
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +66 -40
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/__tests__/task-list.test.js +14 -0
- package/dist/tools/coordinator/__tests__/task-list.test.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts +6 -8
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +11 -32
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/defineTool.d.ts +3 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +3 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/types/provider/chat.d.ts +9 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/error.d.ts +22 -0
- package/dist/types/provider/error.d.ts.map +1 -0
- package/dist/types/provider/error.js +2 -0
- package/dist/types/provider/error.js.map +1 -0
- package/dist/types/provider/index.d.ts +1 -0
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/run/entity.d.ts +2 -0
- package/dist/types/run/entity.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +2 -0
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +4 -0
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +20 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/compaction/__tests__/verifier-empty-reply.test.ts +96 -0
- package/src/compaction/verifier.ts +10 -1
- package/src/config/__tests__/compaction-budget-schema.test.ts +114 -0
- package/src/config/runtime.ts +20 -11
- package/src/manager/run/persistence.ts +3 -1
- package/src/provider/__tests__/errors.test.ts +85 -0
- package/src/provider/errors.ts +344 -0
- package/src/provider/index.ts +15 -0
- package/src/public-runtime.ts +53 -10
- package/src/registry/tool/execute.test.ts +121 -7
- package/src/registry/tool/execute.ts +50 -12
- package/src/registry/toolset/catalog.test.ts +118 -0
- package/src/registry/toolset/catalog.ts +26 -4
- package/src/runtime/query/__tests__/capability-negotiation.test.ts +88 -0
- package/src/runtime/query/__tests__/deferred-tools.test.ts +111 -0
- package/src/runtime/query/__tests__/long-document-flow.test.ts +12 -12
- package/src/runtime/query/__tests__/stream-recovery.test.ts +65 -2
- package/src/runtime/query/executor.ts +2 -2
- package/src/runtime/query/iteration/index.ts +15 -0
- package/src/runtime/query/iteration/phases/compaction-safe-cut.test.ts +186 -0
- package/src/runtime/query/iteration/phases/compaction.ts +54 -12
- package/src/runtime/query/iteration/stream-turn.ts +11 -6
- package/src/runtime/query/result.ts +11 -1
- package/src/tools/builtins/__tests__/edit.test.ts +270 -10
- package/src/tools/builtins/__tests__/payload-budget.test.ts +40 -20
- package/src/tools/builtins/__tests__/write-file.test.ts +52 -13
- package/src/tools/builtins/atomic-write-file.ts +58 -0
- package/src/tools/builtins/bash.ts +2 -2
- package/src/tools/builtins/edit.ts +116 -162
- package/src/tools/builtins/file-mutation-lock.ts +27 -0
- package/src/tools/builtins/index.ts +2 -2
- package/src/tools/builtins/write-file.ts +68 -44
- package/src/tools/coordinator/__tests__/task-list.test.ts +16 -0
- package/src/tools/coordinator/agent.ts +6 -8
- package/src/tools/coordinator/index.ts +11 -34
- package/src/tools/defineTool.ts +6 -0
- package/src/types/provider/chat.ts +14 -1
- package/src/types/provider/error.ts +29 -0
- package/src/types/provider/index.ts +5 -0
- package/src/types/run/entity.ts +2 -0
- package/src/types/run/events.ts +7 -1
- package/src/types/sandbox/index.ts +4 -0
- package/src/types/tool/index.ts +20 -0
|
@@ -227,28 +227,6 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
227
227
|
},
|
|
228
228
|
})
|
|
229
229
|
|
|
230
|
-
const cancelTask = defineTool({
|
|
231
|
-
name: 'cancel_task',
|
|
232
|
-
description:
|
|
233
|
-
'Cancel a running agent task. Only use this with a task_id from a previous create_task.',
|
|
234
|
-
inputSchema: z.object({
|
|
235
|
-
task_id: z.string().describe('Agent task ID from a previous create_task'),
|
|
236
|
-
}),
|
|
237
|
-
category: 'custom',
|
|
238
|
-
permissions: [],
|
|
239
|
-
readOnly: false,
|
|
240
|
-
destructive: false,
|
|
241
|
-
concurrencySafe: true,
|
|
242
|
-
async execute({ task_id }) {
|
|
243
|
-
gateway.cancelTask(task_id as TaskId)
|
|
244
|
-
return {
|
|
245
|
-
success: true,
|
|
246
|
-
output: `Task ${task_id} cancelled`,
|
|
247
|
-
data: { task_id },
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
})
|
|
251
|
-
|
|
252
230
|
const agentTaskList = defineTool({
|
|
253
231
|
name: 'agent_task_list',
|
|
254
232
|
description:
|
|
@@ -305,19 +283,18 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
305
283
|
},
|
|
306
284
|
})
|
|
307
285
|
|
|
308
|
-
// `continue_task`
|
|
309
|
-
//
|
|
310
|
-
//
|
|
311
|
-
//
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
//
|
|
318
|
-
// for follow-ups) wants to re-register it.
|
|
286
|
+
// `continue_task` and model-facing per-task cancellation both
|
|
287
|
+
// belonged to the old non-blocking worker protocol. With
|
|
288
|
+
// `create_task` now blocking + tool_result returning the worker's
|
|
289
|
+
// final output, every worker is terminal by the time a later model
|
|
290
|
+
// turn learns its task id. The old cancel tool additionally called
|
|
291
|
+
// a void/no-op gateway method and manufactured "cancelled" even for
|
|
292
|
+
// a missing id. Host-owned run interruption still uses the gateway
|
|
293
|
+
// cancellation contract directly; it does not need a model tool.
|
|
294
|
+
// Keep only the follow-up definition for a future non-default
|
|
295
|
+
// gateway that deliberately preserves live workers between turns.
|
|
319
296
|
void continueTask
|
|
320
|
-
const tools: ToolDefinition[] = [createTask,
|
|
297
|
+
const tools: ToolDefinition[] = [createTask, agentTaskList]
|
|
321
298
|
|
|
322
299
|
if (getPlanManager) {
|
|
323
300
|
const approvePlan = defineTool({
|
package/src/tools/defineTool.ts
CHANGED
|
@@ -11,6 +11,9 @@ export interface DefineToolOptions<S extends z.ZodType> {
|
|
|
11
11
|
name: string
|
|
12
12
|
description: string
|
|
13
13
|
inputSchema: S
|
|
14
|
+
modelInputSchema?: Record<string, unknown>
|
|
15
|
+
enforceModelInput?: boolean
|
|
16
|
+
validationErrorHint?: string
|
|
14
17
|
category: ToolDefinition['category']
|
|
15
18
|
permissions: ToolPermission[]
|
|
16
19
|
readOnly: boolean
|
|
@@ -29,6 +32,9 @@ export function defineTool<S extends z.ZodType>(
|
|
|
29
32
|
name: options.name,
|
|
30
33
|
description: options.description,
|
|
31
34
|
inputSchema: options.inputSchema,
|
|
35
|
+
modelInputSchema: options.modelInputSchema,
|
|
36
|
+
enforceModelInput: options.enforceModelInput,
|
|
37
|
+
validationErrorHint: options.validationErrorHint,
|
|
32
38
|
tier: options.tier,
|
|
33
39
|
category: options.category,
|
|
34
40
|
permissions: options.permissions,
|
|
@@ -12,7 +12,11 @@ export type ResponseFormat =
|
|
|
12
12
|
| { type: 'json_object' }
|
|
13
13
|
| {
|
|
14
14
|
type: 'json_schema'
|
|
15
|
-
json_schema: {
|
|
15
|
+
json_schema: {
|
|
16
|
+
name: string
|
|
17
|
+
schema: Record<string, unknown>
|
|
18
|
+
strict?: boolean
|
|
19
|
+
}
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
export interface CacheControl {
|
|
@@ -23,6 +27,15 @@ export interface ChatCompletionParams {
|
|
|
23
27
|
model: string
|
|
24
28
|
messages: Message[]
|
|
25
29
|
tools?: LLMToolSchema[]
|
|
30
|
+
/**
|
|
31
|
+
* Provider hint naming tools whose model-facing JSON Schema should be
|
|
32
|
+
* enforced through constrained generation when the selected transport and
|
|
33
|
+
* model support it.
|
|
34
|
+
*
|
|
35
|
+
* This is not a wire field. Provider implementations must consume or omit
|
|
36
|
+
* it instead of serializing ChatCompletionParams wholesale.
|
|
37
|
+
*/
|
|
38
|
+
enforceToolInputSchema?: readonly string[]
|
|
26
39
|
temperature?: number
|
|
27
40
|
maxTokens?: number
|
|
28
41
|
stream?: boolean
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** What went wrong, at the coarsest granularity a caller can act on. */
|
|
2
|
+
export type ProviderErrorKind =
|
|
3
|
+
| 'throttle'
|
|
4
|
+
| 'network'
|
|
5
|
+
| 'auth'
|
|
6
|
+
| 'context_overflow'
|
|
7
|
+
| 'bad_request'
|
|
8
|
+
| 'server'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Serializable provider-failure metadata carried by failed runs and events.
|
|
12
|
+
*
|
|
13
|
+
* No response body, vendor message, URL, or `cause` belongs here.
|
|
14
|
+
*/
|
|
15
|
+
export interface ProviderErrorInfo {
|
|
16
|
+
readonly kind: ProviderErrorKind
|
|
17
|
+
readonly providerId: string
|
|
18
|
+
readonly status?: number
|
|
19
|
+
readonly retryAfterMs?: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ProviderRequestErrorInit extends ProviderErrorInfo {
|
|
23
|
+
/**
|
|
24
|
+
* Optional extra clause for the message. MUST be text this codebase
|
|
25
|
+
* authored — never a fragment of a response body, a header, or a vendor
|
|
26
|
+
* error.
|
|
27
|
+
*/
|
|
28
|
+
readonly detail?: string
|
|
29
|
+
}
|
|
@@ -8,6 +8,11 @@ export type {
|
|
|
8
8
|
export type { StreamChunk } from './stream.js'
|
|
9
9
|
export type { ModelInfo } from './model.js'
|
|
10
10
|
export type { LLMProvider } from './interface.js'
|
|
11
|
+
export type {
|
|
12
|
+
ProviderErrorInfo,
|
|
13
|
+
ProviderErrorKind,
|
|
14
|
+
ProviderRequestErrorInit,
|
|
15
|
+
} from './error.js'
|
|
11
16
|
export type {
|
|
12
17
|
ProviderConfigRegistry,
|
|
13
18
|
ProviderType,
|
package/src/types/run/entity.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentStatus, CostInfo, TokenUsage } from '../common/index.js'
|
|
2
2
|
import type { RunId } from '../ids/index.js'
|
|
3
3
|
import type { Message } from '../message/index.js'
|
|
4
|
+
import type { ProviderErrorInfo } from '../provider/index.js'
|
|
4
5
|
import type { AgentRunConfig } from './config.js'
|
|
5
6
|
import type { ReplayAttribution } from './replay.js'
|
|
6
7
|
import type { StopReason } from './stop-reason.js'
|
|
@@ -37,6 +38,7 @@ export interface Run {
|
|
|
37
38
|
endedAt?: number
|
|
38
39
|
stopReason?: StopReason
|
|
39
40
|
lastError?: string
|
|
41
|
+
lastProviderError?: ProviderErrorInfo
|
|
40
42
|
result?: string
|
|
41
43
|
|
|
42
44
|
parentRunId?: RunId
|
package/src/types/run/events.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
} from '../ids/index.js'
|
|
15
15
|
import type { PlanStep } from '../plan/index.js'
|
|
16
16
|
import type { PluginHookEvent, PluginHookResult } from '../plugin/index.js'
|
|
17
|
+
import type { ProviderErrorInfo } from '../provider/index.js'
|
|
17
18
|
import type { TaskStatus } from '../task/index.js'
|
|
18
19
|
import type { Lineage } from './lineage.js'
|
|
19
20
|
import type { MessageStopReason } from './stop-reason.js'
|
|
@@ -98,7 +99,12 @@ type CoreRunEvent =
|
|
|
98
99
|
fromCheckpointId: CheckpointId
|
|
99
100
|
}
|
|
100
101
|
| { type: 'run_completed'; runId: RunId; result: string }
|
|
101
|
-
| {
|
|
102
|
+
| {
|
|
103
|
+
type: 'run_failed'
|
|
104
|
+
runId: RunId
|
|
105
|
+
error: string
|
|
106
|
+
providerError?: ProviderErrorInfo
|
|
107
|
+
}
|
|
102
108
|
// Additive 2026-07 (provider capability negotiation): emitted once per
|
|
103
109
|
// run when the request asks for something the provider DRIVER declared
|
|
104
110
|
// it cannot do — tools registered against a no-tools driver (tool
|
|
@@ -93,6 +93,10 @@ export interface Sandbox {
|
|
|
93
93
|
readonly rootDir: string
|
|
94
94
|
readonly environment: SandboxEnvironment
|
|
95
95
|
exec(command: string, args?: string[], opts?: SandboxExecOptions): Promise<SandboxExecResult>
|
|
96
|
+
/**
|
|
97
|
+
* Atomically replace the destination body: readers must observe either the
|
|
98
|
+
* previous complete body or the new complete body, never a truncated file.
|
|
99
|
+
*/
|
|
96
100
|
writeFile(path: string, content: string | Buffer): Promise<void>
|
|
97
101
|
readFile(path: string): Promise<Buffer>
|
|
98
102
|
/**
|
package/src/types/tool/index.ts
CHANGED
|
@@ -64,6 +64,26 @@ export interface ToolDefinition<TInput = unknown> {
|
|
|
64
64
|
name: string
|
|
65
65
|
description: string
|
|
66
66
|
inputSchema: z.ZodType<TInput, z.ZodTypeDef, unknown>
|
|
67
|
+
/**
|
|
68
|
+
* Optional canonical JSON Schema shown to models instead of the runtime
|
|
69
|
+
* Zod schema. Use this when runtime compatibility accepts aliases or
|
|
70
|
+
* constraints that should not be advertised to a model.
|
|
71
|
+
*
|
|
72
|
+
* This is intentionally independent of TInput: the model-facing contract
|
|
73
|
+
* may be narrower than the execution decoder.
|
|
74
|
+
*/
|
|
75
|
+
modelInputSchema?: Record<string, unknown>
|
|
76
|
+
/**
|
|
77
|
+
* Ask capable providers to constrain generated input to modelInputSchema.
|
|
78
|
+
* ToolRegistry rejects this flag unless modelInputSchema is also present.
|
|
79
|
+
*/
|
|
80
|
+
enforceModelInput?: boolean
|
|
81
|
+
/**
|
|
82
|
+
* Concise, model-readable recovery guidance appended when inputSchema
|
|
83
|
+
* rejects a call. Use for conditional schemas whose required shapes
|
|
84
|
+
* cannot be reconstructed from JSON Schema's top-level `required` list.
|
|
85
|
+
*/
|
|
86
|
+
validationErrorHint?: string
|
|
67
87
|
execute(input: TInput, context: ToolContext): Promise<ToolResult>
|
|
68
88
|
tier?: string
|
|
69
89
|
permissions?: ToolPermission[]
|