@namzu/sdk 1.1.0 → 1.2.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 +86 -0
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +2 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +4 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/{runtime/query → constants}/continuation.d.ts +5 -0
- package/dist/constants/continuation.d.ts.map +1 -0
- package/dist/{runtime/query → constants}/continuation.js +5 -0
- package/dist/constants/continuation.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +11 -0
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +30 -1
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/provider/capabilities.d.ts +27 -0
- package/dist/provider/capabilities.d.ts.map +1 -0
- package/dist/provider/capabilities.js +29 -0
- package/dist/provider/capabilities.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 +3 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +2 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +8 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/runtime/query/__tests__/capability-negotiation.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/capability-negotiation.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/capability-negotiation.test.js +184 -0
- package/dist/runtime/query/__tests__/capability-negotiation.test.js.map +1 -0
- package/dist/runtime/query/__tests__/checkpoint-store.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/checkpoint-store.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/checkpoint-store.test.js +259 -0
- package/dist/runtime/query/__tests__/checkpoint-store.test.js.map +1 -0
- package/dist/runtime/query/__tests__/checkpoint.test.js +9 -3
- package/dist/runtime/query/__tests__/checkpoint.test.js.map +1 -1
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.d.ts +2 -0
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.d.ts.map +1 -0
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js +110 -0
- package/dist/runtime/query/__tests__/orphan-task-turn-end.test.js.map +1 -0
- package/dist/runtime/query/checkpoint.d.ts +16 -2
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +21 -7
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/context.d.ts +7 -0
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +1 -0
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/index.d.ts +20 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +75 -6
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +3 -57
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +246 -735
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/checkpoint.js +22 -0
- package/dist/runtime/query/iteration/phases/checkpoint.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +1 -2
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts +35 -0
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -0
- package/dist/runtime/query/iteration/stream-turn.js +341 -0
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -0
- package/dist/runtime/query/replay/list.d.ts +17 -1
- package/dist/runtime/query/replay/list.d.ts.map +1 -1
- package/dist/runtime/query/replay/list.js +21 -4
- package/dist/runtime/query/replay/list.js.map +1 -1
- package/dist/runtime/query/replay/prepare.d.ts +10 -0
- package/dist/runtime/query/replay/prepare.d.ts.map +1 -1
- package/dist/runtime/query/replay/prepare.js +20 -4
- package/dist/runtime/query/replay/prepare.js.map +1 -1
- package/dist/store/index.d.ts +1 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/run/checkpoint-disk.d.ts +28 -0
- package/dist/store/run/checkpoint-disk.d.ts.map +1 -0
- package/dist/store/run/checkpoint-disk.js +55 -0
- package/dist/store/run/checkpoint-disk.js.map +1 -0
- package/dist/types/provider/config.d.ts +18 -0
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +10 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/run/checkpoint-store.d.ts +64 -0
- package/dist/types/run/checkpoint-store.d.ts.map +1 -0
- package/dist/types/run/checkpoint-store.js +12 -0
- package/dist/types/run/checkpoint-store.js.map +1 -0
- package/dist/types/run/config.d.ts +27 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +6 -0
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/index.d.ts +1 -0
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +1 -0
- package/dist/types/run/index.js.map +1 -1
- package/package.json +1 -1
- package/src/bridge/a2a/mapper.ts +3 -0
- package/src/bridge/sse/mapper.ts +5 -0
- package/src/{runtime/query → constants}/continuation.ts +5 -0
- package/src/constants/index.ts +1 -0
- package/src/manager/run/persistence.ts +34 -1
- package/src/provider/capabilities.ts +47 -0
- package/src/provider/index.ts +5 -0
- package/src/public-runtime.ts +4 -0
- package/src/run/reporter.ts +9 -0
- package/src/runtime/query/__tests__/capability-negotiation.test.ts +248 -0
- package/src/runtime/query/__tests__/checkpoint-store.test.ts +322 -0
- package/src/runtime/query/__tests__/checkpoint.test.ts +15 -6
- package/src/runtime/query/__tests__/orphan-task-turn-end.test.ts +127 -0
- package/src/runtime/query/checkpoint.ts +23 -9
- package/src/runtime/query/context.ts +9 -0
- package/src/runtime/query/index.ts +115 -28
- package/src/runtime/query/iteration/index.ts +298 -905
- package/src/runtime/query/iteration/phases/checkpoint.ts +25 -0
- package/src/runtime/query/iteration/phases/context.ts +1 -3
- package/src/runtime/query/iteration/stream-turn.ts +396 -0
- package/src/runtime/query/replay/list.ts +38 -4
- package/src/runtime/query/replay/prepare.ts +37 -4
- package/src/store/index.ts +1 -0
- package/src/store/run/checkpoint-disk.ts +67 -0
- package/src/types/provider/config.ts +18 -0
- package/src/types/provider/interface.ts +11 -0
- package/src/types/run/checkpoint-store.ts +72 -0
- package/src/types/run/config.ts +30 -0
- package/src/types/run/events.ts +13 -0
- package/src/types/run/index.ts +1 -0
- package/dist/runtime/query/continuation.d.ts.map +0 -1
- package/dist/runtime/query/continuation.js.map +0 -1
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { extractFromUserMessage } from '../../compaction/extractor.js'
|
|
8
8
|
import { WorkingStateManager } from '../../compaction/manager.js'
|
|
9
9
|
import type { CompactionConfig } from '../../config/runtime.js'
|
|
10
|
+
import { resolveProviderCapabilities } from '../../provider/capabilities.js'
|
|
10
11
|
import type { PathBuilder } from '../../session/workspace/path-builder.js'
|
|
11
12
|
import { GENAI, NAMZU, agentRunSpanName } from '../../telemetry/attributes.js'
|
|
12
13
|
import { getTracer } from '../../telemetry/runtime-accessors.js'
|
|
@@ -28,6 +29,7 @@ import { type Message, createSystemMessage } from '../../types/message/index.js'
|
|
|
28
29
|
import type { AgentPersona } from '../../types/persona/index.js'
|
|
29
30
|
import type { LLMProvider } from '../../types/provider/index.js'
|
|
30
31
|
import type { TaskRouterConfig } from '../../types/router/index.js'
|
|
32
|
+
import type { CheckpointStore } from '../../types/run/checkpoint-store.js'
|
|
31
33
|
import type { AgentRunConfig, Run, RunEvent, RunEventListener } from '../../types/run/index.js'
|
|
32
34
|
import type { Sandbox, SandboxProvider } from '../../types/sandbox/index.js'
|
|
33
35
|
import type { ProjectId, ThreadId } from '../../types/session/ids.js'
|
|
@@ -95,6 +97,15 @@ export interface QueryParams {
|
|
|
95
97
|
*/
|
|
96
98
|
pathBuilder?: PathBuilder
|
|
97
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Optional checkpoint persistence override. Absent ⇒ iteration
|
|
102
|
+
* checkpoints go to the disk layout under the run's output directory
|
|
103
|
+
* (today's behavior). A host injects a scope-keyed
|
|
104
|
+
* {@link CheckpointStore} (e.g. Postgres-backed) so mid-turn resume
|
|
105
|
+
* survives machines that lose their local disk.
|
|
106
|
+
*/
|
|
107
|
+
checkpointStore?: CheckpointStore
|
|
108
|
+
|
|
98
109
|
runId?: RunId
|
|
99
110
|
|
|
100
111
|
parentRunId?: RunId
|
|
@@ -148,6 +159,18 @@ export interface QueryParams {
|
|
|
148
159
|
sandboxProvider?: SandboxProvider
|
|
149
160
|
|
|
150
161
|
invocationState?: InvocationState
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Capability-mismatch handling. Default `false`: when the request asks
|
|
165
|
+
* for something the provider driver declared it cannot do (tools
|
|
166
|
+
* registered against a `supportsTools: false` driver, image
|
|
167
|
+
* attachments against a `supportsVision: false` driver), the runtime
|
|
168
|
+
* warns loudly, emits a `capability_warning` run event, and degrades
|
|
169
|
+
* explicitly (tool surfaces stripped from prompt + request;
|
|
170
|
+
* attachments left unmapped by the driver). `true`: throw instead of
|
|
171
|
+
* degrading.
|
|
172
|
+
*/
|
|
173
|
+
strictCapabilities?: boolean
|
|
151
174
|
}
|
|
152
175
|
|
|
153
176
|
export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run> {
|
|
@@ -174,6 +197,7 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
174
197
|
projectId: params.projectId,
|
|
175
198
|
tenantId: params.tenantId,
|
|
176
199
|
pathBuilder: params.pathBuilder,
|
|
200
|
+
checkpointStore: params.checkpointStore,
|
|
177
201
|
runId: params.runId,
|
|
178
202
|
parentRunId: params.parentRunId,
|
|
179
203
|
depth: params.depth,
|
|
@@ -244,7 +268,45 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
244
268
|
}
|
|
245
269
|
}
|
|
246
270
|
|
|
247
|
-
|
|
271
|
+
// ─── Provider capability negotiation (before tooling bootstrap) ────────
|
|
272
|
+
// Compare what the request asks for with what the DRIVER declared it
|
|
273
|
+
// does. Undeclared capabilities resolve permissively (today's behavior
|
|
274
|
+
// for third-party providers); declared gaps degrade loudly instead of
|
|
275
|
+
// silently.
|
|
276
|
+
const capabilities = resolveProviderCapabilities(params.provider)
|
|
277
|
+
const registeredToolCount = params.tools.listNames().length
|
|
278
|
+
const stripToolSurfaces = !capabilities.supportsTools && registeredToolCount > 0
|
|
279
|
+
const attachmentMessageCount = capabilities.supportsVision
|
|
280
|
+
? 0
|
|
281
|
+
: params.messages.filter(
|
|
282
|
+
(m) => m.role === 'user' && m.attachments !== undefined && m.attachments.length > 0,
|
|
283
|
+
).length
|
|
284
|
+
|
|
285
|
+
if (stripToolSurfaces) {
|
|
286
|
+
const message = `Provider '${params.provider.id}' declares supportsTools: false but ${registeredToolCount} tool(s) are registered — stripping all tool surfaces from the prompt and request so the model is never told about tools it cannot call. Pass strictCapabilities: true to fail instead, or use a tools-capable provider.`
|
|
287
|
+
if (params.strictCapabilities) {
|
|
288
|
+
throw new Error(message)
|
|
289
|
+
}
|
|
290
|
+
ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
|
|
291
|
+
providerId: params.provider.id,
|
|
292
|
+
registeredToolCount,
|
|
293
|
+
})
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (attachmentMessageCount > 0) {
|
|
297
|
+
const message = `Provider '${params.provider.id}' declares supportsVision: false but ${attachmentMessageCount} user message(s) carry image attachments — the driver will not map them, so the model never sees the images. Pass strictCapabilities: true to fail instead, or use a vision-capable provider.`
|
|
298
|
+
if (params.strictCapabilities) {
|
|
299
|
+
throw new Error(message)
|
|
300
|
+
}
|
|
301
|
+
ctx.log.warn(`CAPABILITY MISMATCH: ${message}`, {
|
|
302
|
+
providerId: params.provider.id,
|
|
303
|
+
attachmentMessageCount,
|
|
304
|
+
})
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const effectiveAllowedTools = stripToolSurfaces
|
|
308
|
+
? []
|
|
309
|
+
: withDeferredDiscoveryTool(params.tools, params.allowedTools)
|
|
248
310
|
|
|
249
311
|
const toolExecutor = ToolingBootstrap.init(
|
|
250
312
|
{
|
|
@@ -286,7 +348,10 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
286
348
|
maxIterations: params.runConfig.maxIterations,
|
|
287
349
|
})
|
|
288
350
|
|
|
289
|
-
const checkpointMgr = new CheckpointManager(
|
|
351
|
+
const checkpointMgr = new CheckpointManager(
|
|
352
|
+
ctx.runMgr.getCheckpointStore(),
|
|
353
|
+
ctx.runMgr.getRunScope(),
|
|
354
|
+
)
|
|
290
355
|
|
|
291
356
|
const resultAssembler = new ResultAssembler({
|
|
292
357
|
runMgr: ctx.runMgr,
|
|
@@ -330,35 +395,33 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
330
395
|
? new VerificationGate(params.verificationGate, ctx.log)
|
|
331
396
|
: undefined
|
|
332
397
|
|
|
333
|
-
const iterationOrchestrator = new IterationOrchestrator(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
taskGateway: params.taskGateway,
|
|
340
|
-
taskStore: params.taskStore,
|
|
341
|
-
launchedTasks: params.launchedTasks,
|
|
342
|
-
advisoryCtx,
|
|
343
|
-
compactionConfig: params.compactionConfig,
|
|
344
|
-
workingStateManager,
|
|
345
|
-
workingMemoryProvider: params.workingMemoryProvider,
|
|
346
|
-
agentBus: params.agentBus,
|
|
347
|
-
verificationGate: verificationGate,
|
|
348
|
-
pluginManager: params.pluginManager,
|
|
349
|
-
},
|
|
350
|
-
ctx.runMgr,
|
|
398
|
+
const iterationOrchestrator = new IterationOrchestrator({
|
|
399
|
+
provider: params.provider,
|
|
400
|
+
runConfig: params.runConfig,
|
|
401
|
+
tools: params.tools,
|
|
402
|
+
allowedTools: effectiveAllowedTools,
|
|
403
|
+
runMgr: ctx.runMgr,
|
|
351
404
|
toolExecutor,
|
|
352
405
|
guard,
|
|
353
|
-
ctx.activityStore,
|
|
354
|
-
eventTranslator.emitEvent,
|
|
355
|
-
() => eventTranslator.drainPending(),
|
|
356
|
-
ctx.abortController,
|
|
357
|
-
ctx.log,
|
|
358
|
-
params.resumeHandler,
|
|
406
|
+
activityStore: ctx.activityStore,
|
|
407
|
+
emitEvent: eventTranslator.emitEvent,
|
|
408
|
+
drainPending: () => eventTranslator.drainPending(),
|
|
409
|
+
abortController: ctx.abortController,
|
|
410
|
+
log: ctx.log,
|
|
411
|
+
resumeHandler: params.resumeHandler,
|
|
359
412
|
checkpointMgr,
|
|
360
|
-
ctx.planManager,
|
|
361
|
-
|
|
413
|
+
planManager: ctx.planManager,
|
|
414
|
+
taskGateway: params.taskGateway,
|
|
415
|
+
taskStore: params.taskStore,
|
|
416
|
+
launchedTasks: params.launchedTasks ?? new Map(),
|
|
417
|
+
compactionConfig: params.compactionConfig,
|
|
418
|
+
workingStateManager,
|
|
419
|
+
workingMemoryProvider: params.workingMemoryProvider,
|
|
420
|
+
advisoryCtx,
|
|
421
|
+
agentBus: params.agentBus,
|
|
422
|
+
verificationGate,
|
|
423
|
+
pluginManager: params.pluginManager,
|
|
424
|
+
})
|
|
362
425
|
|
|
363
426
|
const tracer = getTracer()
|
|
364
427
|
|
|
@@ -474,6 +537,30 @@ export async function* query(params: QueryParams): AsyncGenerator<RunEvent, Run>
|
|
|
474
537
|
})
|
|
475
538
|
yield* eventTranslator.drainPending()
|
|
476
539
|
|
|
540
|
+
// Surface capability degradation to the host as run events —
|
|
541
|
+
// explicit, not silent (the log.warn above fires at setup time;
|
|
542
|
+
// this is the machine-readable channel).
|
|
543
|
+
if (stripToolSurfaces) {
|
|
544
|
+
await eventTranslator.emitEvent({
|
|
545
|
+
type: 'capability_warning',
|
|
546
|
+
runId: ctx.runMgr.id,
|
|
547
|
+
capability: 'tools',
|
|
548
|
+
providerId: params.provider.id,
|
|
549
|
+
message: `Provider '${params.provider.id}' does not support tools — ${registeredToolCount} registered tool(s) were stripped from the prompt and request.`,
|
|
550
|
+
})
|
|
551
|
+
yield* eventTranslator.drainPending()
|
|
552
|
+
}
|
|
553
|
+
if (attachmentMessageCount > 0) {
|
|
554
|
+
await eventTranslator.emitEvent({
|
|
555
|
+
type: 'capability_warning',
|
|
556
|
+
runId: ctx.runMgr.id,
|
|
557
|
+
capability: 'vision',
|
|
558
|
+
providerId: params.provider.id,
|
|
559
|
+
message: `Provider '${params.provider.id}' does not support vision — image attachments on ${attachmentMessageCount} user message(s) will not reach the model.`,
|
|
560
|
+
})
|
|
561
|
+
yield* eventTranslator.drainPending()
|
|
562
|
+
}
|
|
563
|
+
|
|
477
564
|
if (params.pluginManager) {
|
|
478
565
|
const hookResults = await params.pluginManager.executeHooks(
|
|
479
566
|
'run_start',
|