@promptev/client 1.0.0 → 1.1.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.
@@ -350,6 +350,10 @@ class PromptevClient {
350
350
  obo.groups = options.onBehalfOf.groups;
351
351
  payload.on_behalf_of = obo;
352
352
  }
353
+ if (options?.model != null)
354
+ payload.model = options.model;
355
+ if (options?.toolInputs != null)
356
+ payload.tool_inputs = options.toolInputs;
353
357
  const url = `${this.baseUrl}/api/v1/agents/${encodeURIComponent(slug)}/chat`;
354
358
  // Deliberately NOT fetchWithRetry: a turn is not idempotent — a retried
355
359
  // POST could run the agent, and its tools, a second time.
@@ -72,6 +72,34 @@ export interface OnBehalfOf {
72
72
  /** The end user's groups, as your system knows them. Omit for the key's full grant. */
73
73
  groups?: string[];
74
74
  }
75
+ /** A model of a provider the workspace has connected, by the ids its model list shows. */
76
+ export interface ModelChoice {
77
+ provider: string;
78
+ model: string;
79
+ }
80
+ /**
81
+ * What one call overrides on one of the agent's tools, by where each value
82
+ * goes. Only what the tool already has in that place can be overridden; any
83
+ * other name answers 400, and nothing is stored: the next call runs the agent
84
+ * as it was published.
85
+ *
86
+ * - An HTTP tool has `headers`, `query`, `body` and `path` (a `{{name}}` in
87
+ * its URL). A GET or DELETE has no body: all its parameters are `query`.
88
+ * - An MCP server has `headers` (sent to the server) and `arguments` (of its
89
+ * functions; a value reaches every function that takes that argument).
90
+ *
91
+ * A value the model would have filled is fixed for the call: the model neither
92
+ * sees nor changes it, and it shows wherever tool arguments show (the
93
+ * `tool_call` event, approvals). A header, or a value the tool was saved with,
94
+ * never appears in the stream. Put secrets in `headers`.
95
+ */
96
+ export interface ToolInput {
97
+ headers?: Record<string, string>;
98
+ query?: Record<string, unknown>;
99
+ body?: Record<string, unknown>;
100
+ path?: Record<string, unknown>;
101
+ arguments?: Record<string, unknown>;
102
+ }
75
103
  export interface ChatOptions {
76
104
  /**
77
105
  * Continue an existing thread. Read it off the first `conversation` event
@@ -89,6 +117,16 @@ export interface ChatOptions {
89
117
  conversationId?: string;
90
118
  /** Act for one of your end users — see {@link OnBehalfOf}. */
91
119
  onBehalfOf?: OnBehalfOf;
120
+ /**
121
+ * Run this one call on another model. The workspace's own provider key is
122
+ * used; a model it cannot call answers 400 before the turn starts.
123
+ */
124
+ model?: ModelChoice;
125
+ /**
126
+ * Override what the agent's tools are configured with, for this one call,
127
+ * keyed by tool id (shown on the tool's page) — see {@link ToolInput}.
128
+ */
129
+ toolInputs?: Record<string, ToolInput>;
92
130
  /** Abort the turn from your own signal (in addition to the client timeout). */
93
131
  signal?: AbortSignal;
94
132
  }
package/dist/esm/index.js CHANGED
@@ -339,6 +339,10 @@ export class PromptevClient {
339
339
  obo.groups = options.onBehalfOf.groups;
340
340
  payload.on_behalf_of = obo;
341
341
  }
342
+ if (options?.model != null)
343
+ payload.model = options.model;
344
+ if (options?.toolInputs != null)
345
+ payload.tool_inputs = options.toolInputs;
342
346
  const url = `${this.baseUrl}/api/v1/agents/${encodeURIComponent(slug)}/chat`;
343
347
  // Deliberately NOT fetchWithRetry: a turn is not idempotent — a retried
344
348
  // POST could run the agent, and its tools, a second time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptev/client",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "JavaScript/TypeScript client for Promptev — stream your AI agents and upload documents with a workspace API key",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.cjs",
package/readme.md CHANGED
@@ -76,6 +76,8 @@ client.chat(agentSlug, message, options?): AsyncGenerator<AgentEvent>
76
76
  | `message` | `string` | What to say. Required, non-empty after trimming, at most 20,000 characters. |
77
77
  | `options.conversationId` | `string?` | Continue a thread. Take it from the first `conversation` event. |
78
78
  | `options.onBehalfOf` | `object?` | Act for one of your end users — see [On behalf of your users](#on-behalf-of-your-users). |
79
+ | `options.model` | `{ provider, model }?` | Run this one call on another model. See [Changing the model or a tool's values for one call](#changing-the-model-or-a-tools-values-for-one-call). |
80
+ | `options.toolInputs` | `Record<toolId, ToolInput>?` | Override what the agent's tools are set up with, for this one call. Same section. |
79
81
  | `options.signal` | `AbortSignal?` | Cancel the turn. |
80
82
 
81
83
  Returns an async generator of [events](#events). It ends after `done`, or after `error`.
@@ -103,6 +105,60 @@ Passing `conversationId` is worth doing for a second reason: a tool set to **Ask
103
105
 
104
106
  A thread belongs to the agent, to this API, **and** to the `onBehalfOf.subject` it was opened under. Keep the subject the same across a conversation's turns, and never reuse an id from the app, the portal or an embed — any mismatch answers `404`, not a fresh thread.
105
107
 
108
+ ## Changing the model or a tool's values for one call
109
+
110
+ Both options are optional. Leave them out and the agent runs exactly as it was published. Nothing a call sends is stored: the next call runs the published agent again.
111
+
112
+ ### `model`
113
+
114
+ ```ts
115
+ for await (const ev of client.chat("support-agent", question, {
116
+ model: { provider: "openai", model: "gpt-5-mini" },
117
+ })) { /* … */ }
118
+ ```
119
+
120
+ `provider` and `model` are the ids shown in your workspace's model list. The workspace's own provider key is used; a call never carries a key. The model runs on its default settings, because the agent's saved settings (temperature and the like) were tuned for its own model.
121
+
122
+ The call answers `400` (a `ValidationError`, with `field` set) before the model is called when the workspace has no such provider, the provider has no key, the model is not in its list or has been retired, or the model cannot call tools and the agent has tools.
123
+
124
+ ### `toolInputs`
125
+
126
+ Override what a tool is set up with, keyed by the tool's **id** (shown on the tool's page in promptev, with a copy button). Each value goes under the place it belongs to:
127
+
128
+ ```ts
129
+ for await (const ev of client.chat("support-agent", "How many open orders does ACME have?", {
130
+ toolInputs: {
131
+ "0b6f2c1e-…": { // an HTTP tool
132
+ headers: { Authorization: `Bearer ${endUserToken}` },
133
+ query: { region: "us" },
134
+ body: { account_id: "acme" },
135
+ path: { customer: "acme" }, // a {{customer}} in the tool's URL
136
+ },
137
+ "7d41a9c3-…": { // an MCP server
138
+ headers: { Authorization: `Bearer ${endUserToken}` },
139
+ arguments: { project_id: "p_123" },
140
+ },
141
+ },
142
+ })) { /* … */ }
143
+ ```
144
+
145
+ | Tool | Place | What it is |
146
+ |---|---|---|
147
+ | HTTP | `headers` | A header the tool was saved with. Names match in any letter case. |
148
+ | HTTP | `query` | A query parameter: one the tool was saved with, or one the model fills. A `GET` or `DELETE` tool has no body, so all of its parameters are `query`. |
149
+ | HTTP | `body` | A body value (`POST`, `PUT`, `PATCH`): a key of the saved body, or a parameter the model fills. |
150
+ | HTTP | `path` | A `{{name}}` in the tool's URL. |
151
+ | MCP server | `headers` | A header the server was saved with (`Authorization` when it was saved with a token). |
152
+ | MCP server | `arguments` | An argument of the server's functions. The value reaches every function that takes an argument of that name. |
153
+
154
+ The rules:
155
+
156
+ - **Override only.** A name the tool does not have in that place answers `400`, and the message lists what the tool does have there. Nothing extra is ever passed through.
157
+ - **A value the model would have filled is fixed for the call.** The model neither sees that parameter nor can change it, so the answer's wording follows the question while the tool gets your value.
158
+ - **What is visible.** A value the model would have filled shows wherever tool arguments show: the `tool_call` event and approval requests. A header, and any value the tool was saved with, never appears in the stream. **Put secrets in `headers`.**
159
+ - **Limits.** 20 tools per call, 20 names per place, 16 KB per tool.
160
+ - Overriding a value the tool was **saved with** (a header, a fixed query parameter, a key of the saved body) needs a server that supports it. One that does not answers `400` saying so; it never runs the call without your value.
161
+
106
162
  ## Events
107
163
 
108
164
  Every frame the server can send, typed. Narrow on `event.type`.