@namzu/sdk 1.3.0 → 1.4.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 +87 -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 +5 -2
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/execute.test.js +11 -0
- package/dist/registry/tool/execute.test.js.map +1 -1
- package/dist/runtime/query/__tests__/stream-recovery.test.js +54 -1
- package/dist/runtime/query/__tests__/stream-recovery.test.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 +54 -0
- package/dist/tools/builtins/__tests__/edit.test.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +11 -13
- package/dist/tools/builtins/edit.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 +1 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +1 -0
- package/dist/tools/defineTool.js.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/tool/index.d.ts +6 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/package.json +1 -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 +14 -0
- package/src/registry/tool/execute.ts +5 -2
- package/src/runtime/query/__tests__/stream-recovery.test.ts +64 -1
- 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 +76 -0
- package/src/tools/builtins/edit.ts +12 -12
- 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 +2 -0
- 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/tool/index.ts +6 -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,7 @@ export interface DefineToolOptions<S extends z.ZodType> {
|
|
|
11
11
|
name: string
|
|
12
12
|
description: string
|
|
13
13
|
inputSchema: S
|
|
14
|
+
validationErrorHint?: string
|
|
14
15
|
category: ToolDefinition['category']
|
|
15
16
|
permissions: ToolPermission[]
|
|
16
17
|
readOnly: boolean
|
|
@@ -29,6 +30,7 @@ export function defineTool<S extends z.ZodType>(
|
|
|
29
30
|
name: options.name,
|
|
30
31
|
description: options.description,
|
|
31
32
|
inputSchema: options.inputSchema,
|
|
33
|
+
validationErrorHint: options.validationErrorHint,
|
|
32
34
|
tier: options.tier,
|
|
33
35
|
category: options.category,
|
|
34
36
|
permissions: options.permissions,
|
|
@@ -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
|
package/src/types/tool/index.ts
CHANGED
|
@@ -64,6 +64,12 @@ export interface ToolDefinition<TInput = unknown> {
|
|
|
64
64
|
name: string
|
|
65
65
|
description: string
|
|
66
66
|
inputSchema: z.ZodType<TInput, z.ZodTypeDef, unknown>
|
|
67
|
+
/**
|
|
68
|
+
* Concise, model-readable recovery guidance appended when inputSchema
|
|
69
|
+
* rejects a call. Use for conditional schemas whose required shapes
|
|
70
|
+
* cannot be reconstructed from JSON Schema's top-level `required` list.
|
|
71
|
+
*/
|
|
72
|
+
validationErrorHint?: string
|
|
67
73
|
execute(input: TInput, context: ToolContext): Promise<ToolResult>
|
|
68
74
|
tier?: string
|
|
69
75
|
permissions?: ToolPermission[]
|