toolnexus 0.22.0 → 0.24.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/README.md +73 -4
- package/dist/agents/loop.js +4 -1
- package/dist/agents/runtime.js +4 -1
- package/dist/client.d.ts +26 -1
- package/dist/client.js +56 -16
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/media.d.ts +126 -0
- package/dist/media.js +540 -0
- package/dist/toolconcurrency.d.ts +16 -0
- package/dist/toolconcurrency.js +59 -0
- package/dist/toolkit.d.ts +5 -2
- package/dist/toolkit.js +3 -3
- package/dist/types.d.ts +4 -1
- package/package.json +5 -3
- package/src/agents/loop.ts +4 -1
- package/src/agents/runtime.ts +4 -1
- package/src/client.ts +77 -19
- package/src/index.ts +2 -0
- package/src/media.ts +604 -0
- package/src/toolconcurrency.ts +67 -0
- package/src/toolkit.ts +6 -3
- package/src/types.ts +4 -1
package/src/toolkit.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { startA2AServer, type A2AConfig, type OnTask, type ServeHandle } from ".
|
|
|
11
11
|
import { type MCPServeConfig, type OnCall } from "./mcpserve.js"
|
|
12
12
|
import { toAnthropic, toGemini, toOpenAI } from "./adapters.js"
|
|
13
13
|
import type { Client } from "./client.js"
|
|
14
|
+
import type { Media } from "./media.js"
|
|
14
15
|
|
|
15
16
|
export interface ToolkitOptions {
|
|
16
17
|
mcpConfig?: string | object
|
|
@@ -31,6 +32,8 @@ export interface ToolkitOptions {
|
|
|
31
32
|
/** Sibling-file sample cap: 0 ⇒ default 10, n>0 ⇒ cap, -1 ⇒ omit <skill_files> (§3, S5). */
|
|
32
33
|
skillSampleLimit?: number
|
|
33
34
|
extraTools?: Tool[]
|
|
35
|
+
/** Media generation (§7G): registers `media.tools()` (source "media"). */
|
|
36
|
+
media?: Media
|
|
34
37
|
/** Built-in tools (§4A). On by default. false | { disabled:true } | { enabled:false } ⇒ off. */
|
|
35
38
|
builtins?: BuiltinsConfig
|
|
36
39
|
/** Remote A2A agents — each advertised skill becomes a tool (source:"a2a"). */
|
|
@@ -79,7 +82,7 @@ export class Toolkit {
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
|
|
82
|
-
static async create(opts: ToolkitOptions): Promise<Toolkit> {
|
|
85
|
+
static async create(opts: ToolkitOptions = {}): Promise<Toolkit> {
|
|
83
86
|
const mcp = opts.mcpConfig !== undefined ? await loadMcp(opts.mcpConfig, { waitFor: opts.waitFor, signal: opts.signal }) : undefined
|
|
84
87
|
// Skills come from directories, in-memory data, and/or a lazy provider (§3,
|
|
85
88
|
// S1). The provider is resolved here (create() is async) and merged with the
|
|
@@ -137,7 +140,7 @@ export class Toolkit {
|
|
|
137
140
|
}),
|
|
138
141
|
),
|
|
139
142
|
)
|
|
140
|
-
const agentToolsFlat = agentToolLists.flat()
|
|
143
|
+
const agentToolsFlat = [...agentToolLists.flat(), ...(opts.media ? opts.media.tools() : [])]
|
|
141
144
|
|
|
142
145
|
// A2A inbound profile: a top-level `a2a` block on a parsed config object
|
|
143
146
|
// (mirrors builtins/agents). serve() prefers its inline `a2a` over this.
|
|
@@ -250,6 +253,6 @@ export class Toolkit {
|
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
|
|
253
|
-
export function createToolkit(opts: ToolkitOptions): Promise<Toolkit> {
|
|
256
|
+
export function createToolkit(opts: ToolkitOptions = {}): Promise<Toolkit> {
|
|
254
257
|
return Toolkit.create(opts)
|
|
255
258
|
}
|
package/src/types.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type JSONSchema = {
|
|
|
12
12
|
|
|
13
13
|
import type { ContentPart } from "./content.js"
|
|
14
14
|
|
|
15
|
-
export type ToolSource = "mcp" | "skill" | "builtin" | "native" | "http" | "a2a" | "custom"
|
|
15
|
+
export type ToolSource = "mcp" | "skill" | "builtin" | "native" | "http" | "a2a" | "media" | "custom"
|
|
16
16
|
|
|
17
17
|
export interface ToolResult {
|
|
18
18
|
output: string
|
|
@@ -130,6 +130,9 @@ export interface Tool {
|
|
|
130
130
|
/** What the tool may do (§4C). Builtins always carry hints; MCP tools carry them when the
|
|
131
131
|
* server sends annotations. Advisory: a server can mislabel its tools. */
|
|
132
132
|
hints?: ToolHints
|
|
133
|
+
/** Decides per call whether this tool may run alongside other safe calls of the same model
|
|
134
|
+
* response (SPEC §8 "Tool scheduling"). Absent ⇒ safe only when `hints.readOnly`. */
|
|
135
|
+
concurrencySafe?: (args: Record<string, unknown>) => boolean
|
|
133
136
|
}
|
|
134
137
|
|
|
135
138
|
export type McpStatus = "connected" | "disabled" | "failed"
|