@meistrari/tela-sdk-js 2.13.1 → 2.13.2

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 CHANGED
@@ -718,9 +718,9 @@ This is particularly useful when reading task input files: `tela.tasks.getInputF
718
718
 
719
719
  ### Agents API
720
720
 
721
- `tela.agents` is a thin **pass-through wrapper** around [`@meistrari/agent-sdk`](https://www.npmjs.com/package/@meistrari/agent-sdk). Execution, streaming, timeline, cancellation, and model updates are delegated straight to the agent-sdk client; the SDK adds only the Tela-specific bits: addressing agents by **`agentId`** (resolved to the underlying `organizationName`/`repository`), uploading `TelaFile` inputs to the vault, and mapping your Tela credentials onto the agent-sdk auth strategy. Method names and shapes mirror the agent-sdk contract.
721
+ `tela.agents` runs agents through the Tela gateway (`run` → `POST /agent/:id/run`). Streaming, timeline, cancellation, and model updates are delegated to [`@meistrari/agent-sdk`](https://www.npmjs.com/package/@meistrari/agent-sdk). The SDK adds the Tela-specific bits: addressing agents by **`agentId`**, flattening a per-variable `inputs` map into the wire `inputSchema` array, uploading `TelaFile` inputs to the vault, and mapping your Tela credentials onto the agent-sdk auth strategy.
722
722
 
723
- > **Transport:** the wrapper builds an agent-sdk client that calls the `/v4/agents` and `/v4/sessions` endpoints. It defaults to your `baseURL`; set `agentBaseURL` when the v4 agent service lives at a different host:
723
+ > **Transport:** `run` posts to the Tela gateway and is authenticated by your SDK credentials. The delegated streaming/timeline/cancel calls use an agent-sdk client against `/v4/sessions`; it defaults to your `baseURL`, set `agentBaseURL` when the v4 agent service lives at a different host:
724
724
  >
725
725
  > ```typescript
726
726
  > const tela = new TelaSDK({ apiKey: 'your-api-key', agentBaseURL: 'https://agents.example.com' })
@@ -732,8 +732,8 @@ const tela = new TelaSDK({ apiKey: 'your-api-key' })
732
732
  // Discover agents (Tela gateway)
733
733
  const agents = await tela.agents.list()
734
734
 
735
- // Start a session by agentId — resolved to org/repo under the hood.
736
- const started = await tela.agents.executeAgent({
735
+ // Start a session by agentId.
736
+ const started = await tela.agents.run({
737
737
  agentId: agents[0].id,
738
738
  message: 'Summarize the latest tickets',
739
739
  })
@@ -743,7 +743,7 @@ if (!started.success)
743
743
  const { sessionId } = started
744
744
  ```
745
745
 
746
- `executeAgent` returns the agent-sdk `ExecuteAgentResponse` (`{ success: true, sessionId } | { success: false, error }`). Stream the session's events by id:
746
+ `run` returns `{ success, sessionId }` execution is async, so stream the session's events by id:
747
747
 
748
748
  ```typescript
749
749
  for await (const event of await tela.agents.streamSession(sessionId)) {
@@ -767,60 +767,68 @@ const timeline = await tela.agents.fetchTimeline(sessionId)
767
767
  await tela.agents.cancelSession(sessionId)
768
768
  ```
769
769
 
770
- **Inputs** — pass file inputs as `TelaFile`s (uploaded to the vault automatically) or ready `vault://` references:
770
+ **Inputs** — `inputs` is a map keyed by variable name. Each value is a single entry or an array of entries; an entry can be a `TelaFile` (uploaded to the vault automatically), a ready `vault://` reference, or a text entry — each optionally carrying `metadata`. The SDK flattens this into the wire `inputSchema` array, tagging every entry with its variable name.
771
771
 
772
772
  ```typescript
773
- await tela.agents.executeAgent({
773
+ await tela.agents.run({
774
774
  agentId,
775
- message: 'Review this contract',
776
- inputs: [
777
- tela.createFile(buffer, { name: 'contract.pdf', mimeType: 'application/pdf' }),
778
- { vaultRef: 'vault://...', filename: 'reference.txt' },
779
- ],
775
+ message: 'Review this contract against the references',
776
+ inputs: {
777
+ // a TelaFile uploaded to the vault for you
778
+ contract: tela.createFile(buffer, { name: 'contract.pdf', mimeType: 'application/pdf' }),
779
+ // multiple entries for one variable; ready vault refs with metadata
780
+ references: [
781
+ { vaultRef: 'vault://...', filename: 'reference.txt', metadata: 'prior version' },
782
+ ],
783
+ // a text input
784
+ notes: { type: 'text', content: 'Focus on the indemnity clauses.' },
785
+ },
786
+ environmentVariables: { LOCALE: 'en-US' },
780
787
  })
781
788
  ```
782
789
 
783
- **Multi-turn / recover** — continue or recover an existing session by `sessionId` (omit `agentId`):
790
+ **Multi-turn** — continue an existing session by passing its `sessionId` alongside the `agentId`:
784
791
 
785
792
  ```typescript
786
- await tela.agents.executeAgent({ sessionId, message: 'Now implement step 1' }) // continue
787
- await tela.agents.executeAgent({ sessionId, recover: true }) // recover a failed/terminal session
793
+ await tela.agents.run({ agentId, sessionId, message: 'Now implement step 1' })
788
794
  ```
789
795
 
790
- **Webhooks** — register up to 5 HTTPS endpoints to receive session lifecycle callbacks instead of (or alongside) streaming. Passing `webhooks` on a continuation **replaces** the set.
796
+ **Webhooks** — register session lifecycle callbacks by passing `webhooks` to `run`. The gateway forwards the webhook config to the agent execution service unchanged. Passing `webhooks` on a continuation replaces the session's registration; omitting it keeps the existing registration.
791
797
 
792
798
  ```typescript
793
- import { verifyWebhookSignature } from '@meistrari/tela-sdk-js'
794
- import type { SessionWebhookEventPayload } from '@meistrari/tela-sdk-js'
795
-
796
- await tela.agents.executeAgent({
799
+ await tela.agents.run({
797
800
  agentId,
798
- message: 'Audit the README for typos',
801
+ message: 'Summarize the latest tickets',
799
802
  webhooks: [{
800
- url: 'https://example.com/hooks/agent',
801
- events: ['session.completed', 'session.failed'], // defaults to all session.* events
802
- secret: 'whsec_…', // optional HMAC-SHA256 signing secret
803
+ url: 'https://example.com/hooks/agent-session',
804
+ events: ['session.completed', 'session.failed', 'session.cancelled'],
805
+ secret: 'whsec_a-long-random-string',
803
806
  }],
804
807
  })
805
-
806
- // On your endpoint, verify the signature before trusting the payload:
807
- const valid = await verifyWebhookSignature(
808
- rawBody,
809
- req.headers.get('x-tela-agent-webhook-signature'),
810
- process.env.WEBHOOK_SECRET!,
811
- )
812
- if (!valid)
813
- return res.status(401).end()
814
- const event = JSON.parse(rawBody) as SessionWebhookEventPayload
815
808
  ```
816
809
 
810
+ Webhook URLs must be HTTPS and publicly reachable. Up to five webhooks can be registered per session. Use `verifyWebhookSignature` to verify signed deliveries.
811
+
817
812
  **Model updates** — set an agent's model by id:
818
813
 
819
814
  ```typescript
820
815
  await tela.agents.updateAgentModel({ agentId, model: 'claude-opus-4-8', commitMessage: 'bump model' })
821
816
  ```
822
817
 
823
- The contract types (`SessionStreamEvent`, `SessionTimelineResponse`, `SessionWebhookConfig`, …), `verifyWebhookSignature`, and `parseSessionStream` are re-exported from `@meistrari/tela-sdk-js` — the agent-sdk is the single source of truth.
818
+ The contract types (`SessionStreamEvent`, `SessionTimelineResponse`, `AgentRunWebhooks`, `SessionWebhookConfig`, …), `verifyWebhookSignature`, and `parseSessionStream` are re-exported from `@meistrari/tela-sdk-js` — the agent-sdk is the single source of truth for the session/streaming/webhook contract.
819
+
820
+ **Migration note** — replace `tela.agents.executeAgent(...)` with `tela.agents.run(...)`. `agentId` is now required, `inputs` is keyed by variable name instead of a flat array, and `webhooks` moves unchanged onto `run`. The Tela gateway run path does not support agent-sdk `recover` requests; start or continue a session with `message` instead.
821
+
822
+ ```typescript
823
+ await tela.agents.run({
824
+ agentId,
825
+ message,
826
+ inputs: {
827
+ document: tela.createFile(file, { name: 'document.pdf' }),
828
+ },
829
+ webhooks,
830
+ })
831
+ ```
824
832
 
825
833
  ## Migration Guide from v1.x to v2
826
834
 
package/dist/index.cjs CHANGED
@@ -24,7 +24,7 @@ const changeCase__namespace = /*#__PURE__*/_interopNamespaceCompat(changeCase);
24
24
  const z__default = /*#__PURE__*/_interopDefaultCompat(z);
25
25
  const Emittery__default = /*#__PURE__*/_interopDefaultCompat(Emittery);
26
26
 
27
- const version = "2.13.1";
27
+ const version = "2.13.2";
28
28
 
29
29
  var __defProp$b = Object.defineProperty;
30
30
  var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -4788,34 +4788,27 @@ class Agents {
4788
4788
  return response.data;
4789
4789
  }
4790
4790
  /**
4791
- * Starts (or continues/recovers) an agent session, delegating to the
4792
- * agent-sdk client (`POST /v4/agents/execute`).
4791
+ * Starts (or continues) an agent session via the Tela gateway
4792
+ * (`POST /agent/:id/run`).
4793
4793
  *
4794
- * - **New session**: pass `agentId` (+ `message`). It is resolved to the
4795
- * underlying `organizationName`/`repository`.
4796
- * - **Continue / recover**: pass `sessionId` (omit `agentId`); `recover: true`
4797
- * resumes without a new message.
4794
+ * - **New session**: pass `agentId` (+ `message`).
4795
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4798
4796
  *
4799
- * After the request shape is validated, `TelaFile` inputs are uploaded to
4800
- * the vault; `webhooks` pass through to register lifecycle callbacks.
4801
- *
4802
- * @throws {Error} If neither `agentId` nor `sessionId` is provided, or if
4803
- * both are provided.
4797
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4798
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4799
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4804
4800
  */
4805
- async executeAgent(params) {
4806
- const { agentId, inputs, ...rest } = params;
4807
- const hasSessionId = rest.sessionId !== void 0;
4808
- if (hasSessionId) {
4809
- if (agentId)
4810
- throw new Error("agents.executeAgent: pass either `agentId` to start a new session or `sessionId` to continue/recover an existing session, not both.");
4811
- const resolvedInputs2 = inputs ? await this.uploadInputs(inputs) : void 0;
4812
- return this.client.executeAgent({ ...rest, inputs: resolvedInputs2 });
4813
- }
4814
- if (!agentId)
4815
- throw new Error("agents.executeAgent: `agentId` is required to start a new session (omit it only when continuing an existing `sessionId`).");
4816
- const resolvedInputs = inputs ? await this.uploadInputs(inputs) : void 0;
4817
- const { organizationName, repository } = await this.resolveAgent(agentId);
4818
- return this.client.executeAgent({ ...rest, inputs: resolvedInputs, organizationName, repository });
4801
+ async run(params) {
4802
+ const { agentId, message, sessionId, environmentVariables, inputs, webhooks } = params;
4803
+ const inputSchema = inputs ? await this.buildInputSchema(inputs) : void 0;
4804
+ const response = await this.gateway.post(
4805
+ `/agent/${agentId}/run`,
4806
+ {
4807
+ ...AGENT_NO_TRANSFORM,
4808
+ body: { message, sessionId, inputSchema, environmentVariables, webhooks }
4809
+ }
4810
+ );
4811
+ return response.data;
4819
4812
  }
4820
4813
  /**
4821
4814
  * Updates an agent's model, delegating to the agent-sdk client
@@ -4844,19 +4837,45 @@ class Agents {
4844
4837
  return resolution;
4845
4838
  }
4846
4839
  /**
4847
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4848
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4840
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4841
+ * `inputSchema` array, tagging each entry with its variable name and
4842
+ * uploading any {@link TelaFile} entries to the vault.
4849
4843
  */
4850
- async uploadInputs(inputs) {
4851
- return Promise.all(
4852
- inputs.map(async (input) => {
4853
- if (isTelaFile(input)) {
4854
- const { fileUrl } = await uploadFile(input, this.gateway);
4855
- return { vaultRef: fileUrl, filename: input.name ?? "file" };
4856
- }
4857
- return input;
4858
- })
4859
- );
4844
+ async buildInputSchema(inputs) {
4845
+ const pairs = Object.entries(inputs).flatMap(([name, value]) => {
4846
+ const entries = Array.isArray(value) ? value : [value];
4847
+ return entries.map((entry) => ({ name, entry }));
4848
+ });
4849
+ return Promise.all(pairs.map(({ name, entry }) => this.resolveEntry(name, entry)));
4850
+ }
4851
+ /**
4852
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4853
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4854
+ */
4855
+ async resolveEntry(name, entry) {
4856
+ if (isTelaFile(entry)) {
4857
+ const { fileUrl } = await uploadFile(entry, this.gateway);
4858
+ return { type: "file", name, vaultRef: fileUrl, filename: entry.name ?? "file" };
4859
+ }
4860
+ if ("type" in entry && entry.type === "text")
4861
+ return { type: "text", name, content: entry.content };
4862
+ if ("file" in entry) {
4863
+ const { fileUrl } = await uploadFile(entry.file, this.gateway);
4864
+ return {
4865
+ type: "file",
4866
+ name,
4867
+ vaultRef: fileUrl,
4868
+ filename: entry.filename ?? entry.file.name ?? "file",
4869
+ ...entry.metadata ? { metadata: entry.metadata } : {}
4870
+ };
4871
+ }
4872
+ return {
4873
+ type: "file",
4874
+ name,
4875
+ vaultRef: entry.vaultRef,
4876
+ filename: entry.filename,
4877
+ ...entry.metadata ? { metadata: entry.metadata } : {}
4878
+ };
4860
4879
  }
4861
4880
  }
4862
4881
 
@@ -4956,13 +4975,13 @@ const _TelaSDK = class _TelaSDK extends BaseClient {
4956
4975
  */
4957
4976
  __publicField(this, "vault", new Vault(this));
4958
4977
  /**
4959
- * Agents API resource a thin pass-through wrapper around
4960
- * `@meistrari/agent-sdk`. Execute by `agentId`, then stream events, fetch the
4961
- * timeline, or cancel by `sessionId`.
4978
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4979
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4980
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4962
4981
  *
4963
4982
  * @example
4964
4983
  * ```typescript
4965
- * const { sessionId } = await tela.agents.executeAgent({
4984
+ * const { sessionId } = await tela.agents.run({
4966
4985
  * agentId: 'agent-id',
4967
4986
  * message: 'Hello',
4968
4987
  * })
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import z, { z as z$1 } from 'zod';
2
2
  import Emittery from 'emittery';
3
3
  import { JSONSchema } from 'zod/v4/core';
4
- import { SessionStreamEvent, AgentInput, ExecuteAgentRequest, UpdateAgentModelRequest, AgentClient, AuthStrategy, ExecuteAgentResponse, UpdateAgentModelResponse } from '@meistrari/agent-sdk';
5
- export { AgentInput, CancelSessionResponse, ExecuteAgentResponse, FetchTimelineOptions, ResolveReferenceOptions, SessionStatus, SessionStreamEvent, SessionTimelineResponse, SessionWebhookConfig, SessionWebhookEventPayload, SessionWebhookEventType, SessionWebhookSubagent, SessionWebhookUsage, StreamSessionOptions, UpdateAgentModelResponse, parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
4
+ import { SessionStreamEvent, ExecuteAgentRequest, ExecuteAgentResponse, UpdateAgentModelRequest, AgentClient, AuthStrategy, UpdateAgentModelResponse } from '@meistrari/agent-sdk';
5
+ export { CancelSessionResponse, FetchTimelineOptions, ResolveReferenceOptions, SessionStatus, SessionStreamEvent, SessionTimelineResponse, SessionWebhookConfig, SessionWebhookEventPayload, SessionWebhookEventType, SessionWebhookSubagent, SessionWebhookUsage, StreamSessionOptions, UpdateAgentModelResponse, parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
6
6
 
7
7
  /**
8
8
  * Base HTTP client with retry logic, request/response transformation, and streaming support.
@@ -4166,18 +4166,16 @@ declare class Vault {
4166
4166
  /**
4167
4167
  * Types for the Agents API.
4168
4168
  *
4169
- * `tela.agents` is a thin wrapper around `@meistrari/agent-sdk` it delegates
4170
- * execution, streaming, timeline, cancellation, and model updates straight to
4171
- * the agent-sdk client. The session/agent **contract is the agent-sdk's**, so
4172
- * those types are re-exported here (single source of truth) rather than
4173
- * redefined.
4169
+ * Execution runs through the Tela gateway (`POST /agent/:id/run`): {@link RunAgentParams}
4170
+ * carries a per-variable {@link AgentRunInputs} map that the wrapper flattens into the
4171
+ * wire `inputSchema` array (each entry tagged with its variable `name`), uploading any
4172
+ * {@link TelaFile} inputs to the vault along the way.
4174
4173
  *
4175
- * The only Tela-specific additions are:
4176
- * - the **`agentId` contract**: a Tela agent is addressed by id and resolved to
4177
- * the underlying `organizationName`/`repository` (via the gateway `/agent`
4178
- * routes); and
4179
- * - the **vault integration**: `inputs` may carry {@link TelaFile}s, which are
4180
- * uploaded to the vault and passed to the agent as `vault://` references.
4174
+ * Streaming, timeline, cancellation, and model updates are still delegated to
4175
+ * `@meistrari/agent-sdk`, so those session/agent contract types are re-exported here
4176
+ * (single source of truth) rather than redefined. A Tela agent is addressed by id and
4177
+ * resolved to the underlying `organizationName`/`repository` (via the gateway `/agent`
4178
+ * routes) for those delegated calls.
4181
4179
  *
4182
4180
  * @module Resources
4183
4181
  */
@@ -4241,34 +4239,86 @@ interface ListAgentsQuery {
4241
4239
  projectId?: string;
4242
4240
  includeProjects?: boolean;
4243
4241
  }
4242
+ /** A file input whose vault reference is already known. */
4243
+ interface AgentFileEntry {
4244
+ type?: 'file';
4245
+ /** A `vault://` reference. */
4246
+ vaultRef: string;
4247
+ /** The user-facing filename. */
4248
+ filename: string;
4249
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4250
+ metadata?: string;
4251
+ }
4252
+ /** A {@link TelaFile} to upload to the vault before the run, with optional metadata. */
4253
+ interface AgentUploadEntry {
4254
+ type?: 'file';
4255
+ /** The file to upload; its vault reference is derived automatically. */
4256
+ file: TelaFile;
4257
+ /** Overrides the uploaded filename; defaults to the {@link TelaFile}'s name. */
4258
+ filename?: string;
4259
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4260
+ metadata?: string;
4261
+ }
4262
+ /** A text input. */
4263
+ interface AgentTextEntry {
4264
+ type: 'text';
4265
+ /** The text content (≤10MB). */
4266
+ content: string;
4267
+ }
4244
4268
  /**
4245
- * A single execution input: either a ready agent-sdk {@link AgentInput} (a
4246
- * `vault://` reference) or a {@link TelaFile} that the wrapper uploads to the
4247
- * vault automatically before delegating.
4269
+ * One input value for a variable. A bare {@link TelaFile} is sugar for
4270
+ * `{ file }` it is uploaded to the vault automatically.
4248
4271
  */
4249
- type AgentExecuteInput = AgentInput | TelaFile;
4272
+ type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
4250
4273
  /**
4251
- * Parameters for executing (or continuing) an agent session.
4252
- *
4253
- * Mirrors the agent-sdk `ExecuteAgentRequest` verbatim, except:
4254
- * - `organizationName`/`repository` are replaced by **`agentId`** (resolved by
4255
- * the wrapper); and
4256
- * - `inputs` may include {@link TelaFile}s (uploaded to the vault for you).
4274
+ * Per-variable inputs: the key is the variable `name`, the value is one entry or
4275
+ * an array of entries. The wrapper flattens this into the wire `inputSchema`
4276
+ * array, tagging every entry with its variable name.
4277
+ */
4278
+ type AgentRunInputs = Record<string, AgentRunInputEntry | AgentRunInputEntry[]>;
4279
+ /** Webhook registrations accepted by {@link Agents.run}; forwarded to `/agent/:id/run` unchanged. */
4280
+ type AgentRunWebhooks = ExecuteAgentRequest['webhooks'];
4281
+ /**
4282
+ * A single wire `inputSchema` entry as sent to `POST /agent/:id/run`. Produced by
4283
+ * flattening {@link AgentRunInputs}.
4284
+ */
4285
+ type AgentRunInputItem = {
4286
+ type: 'file';
4287
+ name: string;
4288
+ vaultRef: string;
4289
+ filename: string;
4290
+ metadata?: string;
4291
+ } | {
4292
+ type: 'text';
4293
+ name: string;
4294
+ content: string;
4295
+ };
4296
+ /**
4297
+ * Parameters for {@link Agents.run} — starting or continuing an agent session via
4298
+ * the Tela gateway (`POST /agent/:id/run`).
4257
4299
  *
4258
- * Start a new session with `agentId`; continue or recover an existing one with
4259
- * `sessionId` (omit `agentId`). Passing both is rejected to avoid ambiguous
4260
- * agent-sdk delegation semantics.
4300
+ * Start a new session with just `agentId` (+ `message`); continue an existing one
4301
+ * by also passing its `sessionId`.
4261
4302
  */
4262
- interface ExecuteAgentParams extends Omit<ExecuteAgentRequest, 'organizationName' | 'repository' | 'inputs'> {
4263
- /**
4264
- * The Tela agent id. Required to start a new session — it is resolved to the
4265
- * underlying `organizationName`/`repository`. Omit it when continuing or
4266
- * recovering an existing `sessionId`; do not pass both.
4267
- */
4268
- agentId?: string;
4269
- /** File inputs. `TelaFile`s are uploaded to the vault; `AgentInput`s pass through. */
4270
- inputs?: AgentExecuteInput[];
4303
+ interface RunAgentParams {
4304
+ /** The Tela agent id (path param). Always required — `/agent/:id/run`. */
4305
+ agentId: string;
4306
+ /** The turn message (required by the API for both new and continued sessions). */
4307
+ message: string;
4308
+ /** Continue an existing session by id; omit to start a new one. */
4309
+ sessionId?: string;
4310
+ /** Key/value environment variables for the run. */
4311
+ environmentVariables?: Record<string, string>;
4312
+ /** Per-variable inputs, flattened into the wire `inputSchema` array. */
4313
+ inputs?: AgentRunInputs;
4314
+ /**
4315
+ * Optional session webhook registrations. On continuation, passing this
4316
+ * replaces the existing set; omitting it keeps the current registration.
4317
+ */
4318
+ webhooks?: AgentRunWebhooks;
4271
4319
  }
4320
+ /** Response of `POST /agent/:id/run`, matching the agent-sdk execute response union. */
4321
+ type RunAgentResponse = ExecuteAgentResponse;
4272
4322
  /**
4273
4323
  * Parameters for updating an agent's model — mirrors the agent-sdk
4274
4324
  * `UpdateAgentModelRequest`, with `agentId` in place of `repository`.
@@ -4285,21 +4335,19 @@ interface UpdateAgentModelParams {
4285
4335
  /**
4286
4336
  * Agents API resource (`tela.agents`).
4287
4337
  *
4288
- * A thin **pass-through wrapper** around `@meistrari/agent-sdk`. Execution,
4289
- * streaming, timeline, cancellation, and model updates are delegated straight to
4290
- * the agent-sdk client (which talks to the `/v4/*` endpoints). The wrapper adds
4291
- * only the Tela-specific bits:
4338
+ * Execution runs through the Tela gateway (`run` → `POST /agent/:id/run`): the
4339
+ * wrapper flattens the per-variable `inputs` map into the wire `inputSchema`
4340
+ * array and uploads any `TelaFile` inputs to the vault first. Streaming,
4341
+ * timeline, cancellation, and model updates are delegated to `@meistrari/agent-sdk`
4342
+ * (which talks to the `/v4/*` endpoints). The wrapper adds the Tela-specific bits:
4292
4343
  *
4293
4344
  * - **`agentId` resolution** — a Tela agent is addressed by id; the wrapper
4294
4345
  * resolves it to the underlying `organizationName`/`repository` via the Tela
4295
- * gateway `/agent` routes before delegating an execution.
4346
+ * gateway `/agent` routes for the delegated agent-sdk calls.
4296
4347
  * - **vault integration** — `TelaFile` inputs are uploaded to the vault and
4297
4348
  * passed to the agent as `vault://` references.
4298
4349
  * - **auth** — Tela credentials are mapped onto an agent-sdk `AuthStrategy`.
4299
4350
  *
4300
- * Webhook registration comes for free: `webhooks` is part of the agent-sdk
4301
- * execute contract and passes straight through.
4302
- *
4303
4351
  * @module Resources
4304
4352
  */
4305
4353
 
@@ -4326,14 +4374,17 @@ type AgentsConfig = {
4326
4374
  * ```typescript
4327
4375
  * const tela = new TelaSDK({ apiKey: '...' })
4328
4376
  *
4329
- * // Start a session by agent id (resolved to org/repo under the hood).
4330
- * const { sessionId } = await tela.agents.executeAgent({
4377
+ * // Start a session by agent id (`POST /agent/:id/run`).
4378
+ * const { sessionId } = await tela.agents.run({
4331
4379
  * agentId: 'agent-123',
4332
4380
  * message: 'Summarize the latest tickets',
4333
- * webhooks: [{ url: 'https://example.com/hook', events: ['session.completed'] }],
4381
+ * inputs: {
4382
+ * report: tela.createFile('https://example.com/q3.pdf'),
4383
+ * notes: { type: 'text', content: 'Focus on churn.' },
4384
+ * },
4334
4385
  * })
4335
4386
  *
4336
- * // Stream / inspect / cancel by session id (straight pass-through).
4387
+ * // Stream / inspect / cancel by session id (agent-sdk pass-through).
4337
4388
  * for await (const event of await tela.agents.streamSession(sessionId))
4338
4389
  * console.log(event.kind)
4339
4390
  * const timeline = await tela.agents.fetchTimeline(sessionId)
@@ -4377,21 +4428,17 @@ declare class Agents {
4377
4428
  */
4378
4429
  get(agentId: string): Promise<AgentRecord>;
4379
4430
  /**
4380
- * Starts (or continues/recovers) an agent session, delegating to the
4381
- * agent-sdk client (`POST /v4/agents/execute`).
4382
- *
4383
- * - **New session**: pass `agentId` (+ `message`). It is resolved to the
4384
- * underlying `organizationName`/`repository`.
4385
- * - **Continue / recover**: pass `sessionId` (omit `agentId`); `recover: true`
4386
- * resumes without a new message.
4431
+ * Starts (or continues) an agent session via the Tela gateway
4432
+ * (`POST /agent/:id/run`).
4387
4433
  *
4388
- * After the request shape is validated, `TelaFile` inputs are uploaded to
4389
- * the vault; `webhooks` pass through to register lifecycle callbacks.
4434
+ * - **New session**: pass `agentId` (+ `message`).
4435
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4390
4436
  *
4391
- * @throws {Error} If neither `agentId` nor `sessionId` is provided, or if
4392
- * both are provided.
4437
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4438
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4439
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4393
4440
  */
4394
- executeAgent(params: ExecuteAgentParams): Promise<ExecuteAgentResponse>;
4441
+ run(params: RunAgentParams): Promise<RunAgentResponse>;
4395
4442
  /**
4396
4443
  * Updates an agent's model, delegating to the agent-sdk client
4397
4444
  * (`PUT /v4/agents/:repository/model`). The `agentId` is resolved to the
@@ -4404,10 +4451,16 @@ declare class Agents {
4404
4451
  */
4405
4452
  private resolveAgent;
4406
4453
  /**
4407
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4408
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4454
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4455
+ * `inputSchema` array, tagging each entry with its variable name and
4456
+ * uploading any {@link TelaFile} entries to the vault.
4457
+ */
4458
+ private buildInputSchema;
4459
+ /**
4460
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4461
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4409
4462
  */
4410
- private uploadInputs;
4463
+ private resolveEntry;
4411
4464
  }
4412
4465
 
4413
4466
  /**
@@ -4554,13 +4607,13 @@ declare class TelaSDK extends BaseClient {
4554
4607
  */
4555
4608
  vault: Vault;
4556
4609
  /**
4557
- * Agents API resource a thin pass-through wrapper around
4558
- * `@meistrari/agent-sdk`. Execute by `agentId`, then stream events, fetch the
4559
- * timeline, or cancel by `sessionId`.
4610
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4611
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4612
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4560
4613
  *
4561
4614
  * @example
4562
4615
  * ```typescript
4563
- * const { sessionId } = await tela.agents.executeAgent({
4616
+ * const { sessionId } = await tela.agents.run({
4564
4617
  * agentId: 'agent-id',
4565
4618
  * message: 'Hello',
4566
4619
  * })
@@ -4627,4 +4680,4 @@ declare class TelaSDK extends BaseClient {
4627
4680
  */
4628
4681
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4629
4682
 
4630
- export { APIError, type AgentExecuteInput, AgentExecutionFailedError, type AgentInputVariable, type AgentRecord, Agents, type AgentsConfig, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, type ExecuteAgentParams, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, type ListAgentsQuery, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type SessionErrorEvent, type SessionResultEvent, type SessionStatusEvent, type SessionStepsEvent, type SessionTimelineFinalizeEvent, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, type UpdateAgentModelParams, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
4683
+ export { APIError, AgentExecutionFailedError, type AgentFileEntry, type AgentInputVariable, type AgentRecord, type AgentRunInputEntry, type AgentRunInputItem, type AgentRunInputs, type AgentRunWebhooks, type AgentTextEntry, type AgentUploadEntry, Agents, type AgentsConfig, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, type ListAgentsQuery, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type RunAgentParams, type RunAgentResponse, type SchemaBuilder, type SessionErrorEvent, type SessionResultEvent, type SessionStatusEvent, type SessionStepsEvent, type SessionTimelineFinalizeEvent, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, type UpdateAgentModelParams, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import z, { z as z$1 } from 'zod';
2
2
  import Emittery from 'emittery';
3
3
  import { JSONSchema } from 'zod/v4/core';
4
- import { SessionStreamEvent, AgentInput, ExecuteAgentRequest, UpdateAgentModelRequest, AgentClient, AuthStrategy, ExecuteAgentResponse, UpdateAgentModelResponse } from '@meistrari/agent-sdk';
5
- export { AgentInput, CancelSessionResponse, ExecuteAgentResponse, FetchTimelineOptions, ResolveReferenceOptions, SessionStatus, SessionStreamEvent, SessionTimelineResponse, SessionWebhookConfig, SessionWebhookEventPayload, SessionWebhookEventType, SessionWebhookSubagent, SessionWebhookUsage, StreamSessionOptions, UpdateAgentModelResponse, parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
4
+ import { SessionStreamEvent, ExecuteAgentRequest, ExecuteAgentResponse, UpdateAgentModelRequest, AgentClient, AuthStrategy, UpdateAgentModelResponse } from '@meistrari/agent-sdk';
5
+ export { CancelSessionResponse, FetchTimelineOptions, ResolveReferenceOptions, SessionStatus, SessionStreamEvent, SessionTimelineResponse, SessionWebhookConfig, SessionWebhookEventPayload, SessionWebhookEventType, SessionWebhookSubagent, SessionWebhookUsage, StreamSessionOptions, UpdateAgentModelResponse, parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
6
6
 
7
7
  /**
8
8
  * Base HTTP client with retry logic, request/response transformation, and streaming support.
@@ -4166,18 +4166,16 @@ declare class Vault {
4166
4166
  /**
4167
4167
  * Types for the Agents API.
4168
4168
  *
4169
- * `tela.agents` is a thin wrapper around `@meistrari/agent-sdk` it delegates
4170
- * execution, streaming, timeline, cancellation, and model updates straight to
4171
- * the agent-sdk client. The session/agent **contract is the agent-sdk's**, so
4172
- * those types are re-exported here (single source of truth) rather than
4173
- * redefined.
4169
+ * Execution runs through the Tela gateway (`POST /agent/:id/run`): {@link RunAgentParams}
4170
+ * carries a per-variable {@link AgentRunInputs} map that the wrapper flattens into the
4171
+ * wire `inputSchema` array (each entry tagged with its variable `name`), uploading any
4172
+ * {@link TelaFile} inputs to the vault along the way.
4174
4173
  *
4175
- * The only Tela-specific additions are:
4176
- * - the **`agentId` contract**: a Tela agent is addressed by id and resolved to
4177
- * the underlying `organizationName`/`repository` (via the gateway `/agent`
4178
- * routes); and
4179
- * - the **vault integration**: `inputs` may carry {@link TelaFile}s, which are
4180
- * uploaded to the vault and passed to the agent as `vault://` references.
4174
+ * Streaming, timeline, cancellation, and model updates are still delegated to
4175
+ * `@meistrari/agent-sdk`, so those session/agent contract types are re-exported here
4176
+ * (single source of truth) rather than redefined. A Tela agent is addressed by id and
4177
+ * resolved to the underlying `organizationName`/`repository` (via the gateway `/agent`
4178
+ * routes) for those delegated calls.
4181
4179
  *
4182
4180
  * @module Resources
4183
4181
  */
@@ -4241,34 +4239,86 @@ interface ListAgentsQuery {
4241
4239
  projectId?: string;
4242
4240
  includeProjects?: boolean;
4243
4241
  }
4242
+ /** A file input whose vault reference is already known. */
4243
+ interface AgentFileEntry {
4244
+ type?: 'file';
4245
+ /** A `vault://` reference. */
4246
+ vaultRef: string;
4247
+ /** The user-facing filename. */
4248
+ filename: string;
4249
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4250
+ metadata?: string;
4251
+ }
4252
+ /** A {@link TelaFile} to upload to the vault before the run, with optional metadata. */
4253
+ interface AgentUploadEntry {
4254
+ type?: 'file';
4255
+ /** The file to upload; its vault reference is derived automatically. */
4256
+ file: TelaFile;
4257
+ /** Overrides the uploaded filename; defaults to the {@link TelaFile}'s name. */
4258
+ filename?: string;
4259
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4260
+ metadata?: string;
4261
+ }
4262
+ /** A text input. */
4263
+ interface AgentTextEntry {
4264
+ type: 'text';
4265
+ /** The text content (≤10MB). */
4266
+ content: string;
4267
+ }
4244
4268
  /**
4245
- * A single execution input: either a ready agent-sdk {@link AgentInput} (a
4246
- * `vault://` reference) or a {@link TelaFile} that the wrapper uploads to the
4247
- * vault automatically before delegating.
4269
+ * One input value for a variable. A bare {@link TelaFile} is sugar for
4270
+ * `{ file }` it is uploaded to the vault automatically.
4248
4271
  */
4249
- type AgentExecuteInput = AgentInput | TelaFile;
4272
+ type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
4250
4273
  /**
4251
- * Parameters for executing (or continuing) an agent session.
4252
- *
4253
- * Mirrors the agent-sdk `ExecuteAgentRequest` verbatim, except:
4254
- * - `organizationName`/`repository` are replaced by **`agentId`** (resolved by
4255
- * the wrapper); and
4256
- * - `inputs` may include {@link TelaFile}s (uploaded to the vault for you).
4274
+ * Per-variable inputs: the key is the variable `name`, the value is one entry or
4275
+ * an array of entries. The wrapper flattens this into the wire `inputSchema`
4276
+ * array, tagging every entry with its variable name.
4277
+ */
4278
+ type AgentRunInputs = Record<string, AgentRunInputEntry | AgentRunInputEntry[]>;
4279
+ /** Webhook registrations accepted by {@link Agents.run}; forwarded to `/agent/:id/run` unchanged. */
4280
+ type AgentRunWebhooks = ExecuteAgentRequest['webhooks'];
4281
+ /**
4282
+ * A single wire `inputSchema` entry as sent to `POST /agent/:id/run`. Produced by
4283
+ * flattening {@link AgentRunInputs}.
4284
+ */
4285
+ type AgentRunInputItem = {
4286
+ type: 'file';
4287
+ name: string;
4288
+ vaultRef: string;
4289
+ filename: string;
4290
+ metadata?: string;
4291
+ } | {
4292
+ type: 'text';
4293
+ name: string;
4294
+ content: string;
4295
+ };
4296
+ /**
4297
+ * Parameters for {@link Agents.run} — starting or continuing an agent session via
4298
+ * the Tela gateway (`POST /agent/:id/run`).
4257
4299
  *
4258
- * Start a new session with `agentId`; continue or recover an existing one with
4259
- * `sessionId` (omit `agentId`). Passing both is rejected to avoid ambiguous
4260
- * agent-sdk delegation semantics.
4300
+ * Start a new session with just `agentId` (+ `message`); continue an existing one
4301
+ * by also passing its `sessionId`.
4261
4302
  */
4262
- interface ExecuteAgentParams extends Omit<ExecuteAgentRequest, 'organizationName' | 'repository' | 'inputs'> {
4263
- /**
4264
- * The Tela agent id. Required to start a new session — it is resolved to the
4265
- * underlying `organizationName`/`repository`. Omit it when continuing or
4266
- * recovering an existing `sessionId`; do not pass both.
4267
- */
4268
- agentId?: string;
4269
- /** File inputs. `TelaFile`s are uploaded to the vault; `AgentInput`s pass through. */
4270
- inputs?: AgentExecuteInput[];
4303
+ interface RunAgentParams {
4304
+ /** The Tela agent id (path param). Always required — `/agent/:id/run`. */
4305
+ agentId: string;
4306
+ /** The turn message (required by the API for both new and continued sessions). */
4307
+ message: string;
4308
+ /** Continue an existing session by id; omit to start a new one. */
4309
+ sessionId?: string;
4310
+ /** Key/value environment variables for the run. */
4311
+ environmentVariables?: Record<string, string>;
4312
+ /** Per-variable inputs, flattened into the wire `inputSchema` array. */
4313
+ inputs?: AgentRunInputs;
4314
+ /**
4315
+ * Optional session webhook registrations. On continuation, passing this
4316
+ * replaces the existing set; omitting it keeps the current registration.
4317
+ */
4318
+ webhooks?: AgentRunWebhooks;
4271
4319
  }
4320
+ /** Response of `POST /agent/:id/run`, matching the agent-sdk execute response union. */
4321
+ type RunAgentResponse = ExecuteAgentResponse;
4272
4322
  /**
4273
4323
  * Parameters for updating an agent's model — mirrors the agent-sdk
4274
4324
  * `UpdateAgentModelRequest`, with `agentId` in place of `repository`.
@@ -4285,21 +4335,19 @@ interface UpdateAgentModelParams {
4285
4335
  /**
4286
4336
  * Agents API resource (`tela.agents`).
4287
4337
  *
4288
- * A thin **pass-through wrapper** around `@meistrari/agent-sdk`. Execution,
4289
- * streaming, timeline, cancellation, and model updates are delegated straight to
4290
- * the agent-sdk client (which talks to the `/v4/*` endpoints). The wrapper adds
4291
- * only the Tela-specific bits:
4338
+ * Execution runs through the Tela gateway (`run` → `POST /agent/:id/run`): the
4339
+ * wrapper flattens the per-variable `inputs` map into the wire `inputSchema`
4340
+ * array and uploads any `TelaFile` inputs to the vault first. Streaming,
4341
+ * timeline, cancellation, and model updates are delegated to `@meistrari/agent-sdk`
4342
+ * (which talks to the `/v4/*` endpoints). The wrapper adds the Tela-specific bits:
4292
4343
  *
4293
4344
  * - **`agentId` resolution** — a Tela agent is addressed by id; the wrapper
4294
4345
  * resolves it to the underlying `organizationName`/`repository` via the Tela
4295
- * gateway `/agent` routes before delegating an execution.
4346
+ * gateway `/agent` routes for the delegated agent-sdk calls.
4296
4347
  * - **vault integration** — `TelaFile` inputs are uploaded to the vault and
4297
4348
  * passed to the agent as `vault://` references.
4298
4349
  * - **auth** — Tela credentials are mapped onto an agent-sdk `AuthStrategy`.
4299
4350
  *
4300
- * Webhook registration comes for free: `webhooks` is part of the agent-sdk
4301
- * execute contract and passes straight through.
4302
- *
4303
4351
  * @module Resources
4304
4352
  */
4305
4353
 
@@ -4326,14 +4374,17 @@ type AgentsConfig = {
4326
4374
  * ```typescript
4327
4375
  * const tela = new TelaSDK({ apiKey: '...' })
4328
4376
  *
4329
- * // Start a session by agent id (resolved to org/repo under the hood).
4330
- * const { sessionId } = await tela.agents.executeAgent({
4377
+ * // Start a session by agent id (`POST /agent/:id/run`).
4378
+ * const { sessionId } = await tela.agents.run({
4331
4379
  * agentId: 'agent-123',
4332
4380
  * message: 'Summarize the latest tickets',
4333
- * webhooks: [{ url: 'https://example.com/hook', events: ['session.completed'] }],
4381
+ * inputs: {
4382
+ * report: tela.createFile('https://example.com/q3.pdf'),
4383
+ * notes: { type: 'text', content: 'Focus on churn.' },
4384
+ * },
4334
4385
  * })
4335
4386
  *
4336
- * // Stream / inspect / cancel by session id (straight pass-through).
4387
+ * // Stream / inspect / cancel by session id (agent-sdk pass-through).
4337
4388
  * for await (const event of await tela.agents.streamSession(sessionId))
4338
4389
  * console.log(event.kind)
4339
4390
  * const timeline = await tela.agents.fetchTimeline(sessionId)
@@ -4377,21 +4428,17 @@ declare class Agents {
4377
4428
  */
4378
4429
  get(agentId: string): Promise<AgentRecord>;
4379
4430
  /**
4380
- * Starts (or continues/recovers) an agent session, delegating to the
4381
- * agent-sdk client (`POST /v4/agents/execute`).
4382
- *
4383
- * - **New session**: pass `agentId` (+ `message`). It is resolved to the
4384
- * underlying `organizationName`/`repository`.
4385
- * - **Continue / recover**: pass `sessionId` (omit `agentId`); `recover: true`
4386
- * resumes without a new message.
4431
+ * Starts (or continues) an agent session via the Tela gateway
4432
+ * (`POST /agent/:id/run`).
4387
4433
  *
4388
- * After the request shape is validated, `TelaFile` inputs are uploaded to
4389
- * the vault; `webhooks` pass through to register lifecycle callbacks.
4434
+ * - **New session**: pass `agentId` (+ `message`).
4435
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4390
4436
  *
4391
- * @throws {Error} If neither `agentId` nor `sessionId` is provided, or if
4392
- * both are provided.
4437
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4438
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4439
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4393
4440
  */
4394
- executeAgent(params: ExecuteAgentParams): Promise<ExecuteAgentResponse>;
4441
+ run(params: RunAgentParams): Promise<RunAgentResponse>;
4395
4442
  /**
4396
4443
  * Updates an agent's model, delegating to the agent-sdk client
4397
4444
  * (`PUT /v4/agents/:repository/model`). The `agentId` is resolved to the
@@ -4404,10 +4451,16 @@ declare class Agents {
4404
4451
  */
4405
4452
  private resolveAgent;
4406
4453
  /**
4407
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4408
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4454
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4455
+ * `inputSchema` array, tagging each entry with its variable name and
4456
+ * uploading any {@link TelaFile} entries to the vault.
4457
+ */
4458
+ private buildInputSchema;
4459
+ /**
4460
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4461
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4409
4462
  */
4410
- private uploadInputs;
4463
+ private resolveEntry;
4411
4464
  }
4412
4465
 
4413
4466
  /**
@@ -4554,13 +4607,13 @@ declare class TelaSDK extends BaseClient {
4554
4607
  */
4555
4608
  vault: Vault;
4556
4609
  /**
4557
- * Agents API resource a thin pass-through wrapper around
4558
- * `@meistrari/agent-sdk`. Execute by `agentId`, then stream events, fetch the
4559
- * timeline, or cancel by `sessionId`.
4610
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4611
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4612
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4560
4613
  *
4561
4614
  * @example
4562
4615
  * ```typescript
4563
- * const { sessionId } = await tela.agents.executeAgent({
4616
+ * const { sessionId } = await tela.agents.run({
4564
4617
  * agentId: 'agent-id',
4565
4618
  * message: 'Hello',
4566
4619
  * })
@@ -4627,4 +4680,4 @@ declare class TelaSDK extends BaseClient {
4627
4680
  */
4628
4681
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4629
4682
 
4630
- export { APIError, type AgentExecuteInput, AgentExecutionFailedError, type AgentInputVariable, type AgentRecord, Agents, type AgentsConfig, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, type ExecuteAgentParams, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, type ListAgentsQuery, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type SessionErrorEvent, type SessionResultEvent, type SessionStatusEvent, type SessionStepsEvent, type SessionTimelineFinalizeEvent, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, type UpdateAgentModelParams, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
4683
+ export { APIError, AgentExecutionFailedError, type AgentFileEntry, type AgentInputVariable, type AgentRecord, type AgentRunInputEntry, type AgentRunInputItem, type AgentRunInputs, type AgentRunWebhooks, type AgentTextEntry, type AgentUploadEntry, Agents, type AgentsConfig, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, type ListAgentsQuery, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type RunAgentParams, type RunAgentResponse, type SchemaBuilder, type SessionErrorEvent, type SessionResultEvent, type SessionStatusEvent, type SessionStepsEvent, type SessionTimelineFinalizeEvent, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, type UpdateAgentModelParams, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import z, { z as z$1 } from 'zod';
2
2
  import Emittery from 'emittery';
3
3
  import { JSONSchema } from 'zod/v4/core';
4
- import { SessionStreamEvent, AgentInput, ExecuteAgentRequest, UpdateAgentModelRequest, AgentClient, AuthStrategy, ExecuteAgentResponse, UpdateAgentModelResponse } from '@meistrari/agent-sdk';
5
- export { AgentInput, CancelSessionResponse, ExecuteAgentResponse, FetchTimelineOptions, ResolveReferenceOptions, SessionStatus, SessionStreamEvent, SessionTimelineResponse, SessionWebhookConfig, SessionWebhookEventPayload, SessionWebhookEventType, SessionWebhookSubagent, SessionWebhookUsage, StreamSessionOptions, UpdateAgentModelResponse, parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
4
+ import { SessionStreamEvent, ExecuteAgentRequest, ExecuteAgentResponse, UpdateAgentModelRequest, AgentClient, AuthStrategy, UpdateAgentModelResponse } from '@meistrari/agent-sdk';
5
+ export { CancelSessionResponse, FetchTimelineOptions, ResolveReferenceOptions, SessionStatus, SessionStreamEvent, SessionTimelineResponse, SessionWebhookConfig, SessionWebhookEventPayload, SessionWebhookEventType, SessionWebhookSubagent, SessionWebhookUsage, StreamSessionOptions, UpdateAgentModelResponse, parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
6
6
 
7
7
  /**
8
8
  * Base HTTP client with retry logic, request/response transformation, and streaming support.
@@ -4166,18 +4166,16 @@ declare class Vault {
4166
4166
  /**
4167
4167
  * Types for the Agents API.
4168
4168
  *
4169
- * `tela.agents` is a thin wrapper around `@meistrari/agent-sdk` it delegates
4170
- * execution, streaming, timeline, cancellation, and model updates straight to
4171
- * the agent-sdk client. The session/agent **contract is the agent-sdk's**, so
4172
- * those types are re-exported here (single source of truth) rather than
4173
- * redefined.
4169
+ * Execution runs through the Tela gateway (`POST /agent/:id/run`): {@link RunAgentParams}
4170
+ * carries a per-variable {@link AgentRunInputs} map that the wrapper flattens into the
4171
+ * wire `inputSchema` array (each entry tagged with its variable `name`), uploading any
4172
+ * {@link TelaFile} inputs to the vault along the way.
4174
4173
  *
4175
- * The only Tela-specific additions are:
4176
- * - the **`agentId` contract**: a Tela agent is addressed by id and resolved to
4177
- * the underlying `organizationName`/`repository` (via the gateway `/agent`
4178
- * routes); and
4179
- * - the **vault integration**: `inputs` may carry {@link TelaFile}s, which are
4180
- * uploaded to the vault and passed to the agent as `vault://` references.
4174
+ * Streaming, timeline, cancellation, and model updates are still delegated to
4175
+ * `@meistrari/agent-sdk`, so those session/agent contract types are re-exported here
4176
+ * (single source of truth) rather than redefined. A Tela agent is addressed by id and
4177
+ * resolved to the underlying `organizationName`/`repository` (via the gateway `/agent`
4178
+ * routes) for those delegated calls.
4181
4179
  *
4182
4180
  * @module Resources
4183
4181
  */
@@ -4241,34 +4239,86 @@ interface ListAgentsQuery {
4241
4239
  projectId?: string;
4242
4240
  includeProjects?: boolean;
4243
4241
  }
4242
+ /** A file input whose vault reference is already known. */
4243
+ interface AgentFileEntry {
4244
+ type?: 'file';
4245
+ /** A `vault://` reference. */
4246
+ vaultRef: string;
4247
+ /** The user-facing filename. */
4248
+ filename: string;
4249
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4250
+ metadata?: string;
4251
+ }
4252
+ /** A {@link TelaFile} to upload to the vault before the run, with optional metadata. */
4253
+ interface AgentUploadEntry {
4254
+ type?: 'file';
4255
+ /** The file to upload; its vault reference is derived automatically. */
4256
+ file: TelaFile;
4257
+ /** Overrides the uploaded filename; defaults to the {@link TelaFile}'s name. */
4258
+ filename?: string;
4259
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4260
+ metadata?: string;
4261
+ }
4262
+ /** A text input. */
4263
+ interface AgentTextEntry {
4264
+ type: 'text';
4265
+ /** The text content (≤10MB). */
4266
+ content: string;
4267
+ }
4244
4268
  /**
4245
- * A single execution input: either a ready agent-sdk {@link AgentInput} (a
4246
- * `vault://` reference) or a {@link TelaFile} that the wrapper uploads to the
4247
- * vault automatically before delegating.
4269
+ * One input value for a variable. A bare {@link TelaFile} is sugar for
4270
+ * `{ file }` it is uploaded to the vault automatically.
4248
4271
  */
4249
- type AgentExecuteInput = AgentInput | TelaFile;
4272
+ type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
4250
4273
  /**
4251
- * Parameters for executing (or continuing) an agent session.
4252
- *
4253
- * Mirrors the agent-sdk `ExecuteAgentRequest` verbatim, except:
4254
- * - `organizationName`/`repository` are replaced by **`agentId`** (resolved by
4255
- * the wrapper); and
4256
- * - `inputs` may include {@link TelaFile}s (uploaded to the vault for you).
4274
+ * Per-variable inputs: the key is the variable `name`, the value is one entry or
4275
+ * an array of entries. The wrapper flattens this into the wire `inputSchema`
4276
+ * array, tagging every entry with its variable name.
4277
+ */
4278
+ type AgentRunInputs = Record<string, AgentRunInputEntry | AgentRunInputEntry[]>;
4279
+ /** Webhook registrations accepted by {@link Agents.run}; forwarded to `/agent/:id/run` unchanged. */
4280
+ type AgentRunWebhooks = ExecuteAgentRequest['webhooks'];
4281
+ /**
4282
+ * A single wire `inputSchema` entry as sent to `POST /agent/:id/run`. Produced by
4283
+ * flattening {@link AgentRunInputs}.
4284
+ */
4285
+ type AgentRunInputItem = {
4286
+ type: 'file';
4287
+ name: string;
4288
+ vaultRef: string;
4289
+ filename: string;
4290
+ metadata?: string;
4291
+ } | {
4292
+ type: 'text';
4293
+ name: string;
4294
+ content: string;
4295
+ };
4296
+ /**
4297
+ * Parameters for {@link Agents.run} — starting or continuing an agent session via
4298
+ * the Tela gateway (`POST /agent/:id/run`).
4257
4299
  *
4258
- * Start a new session with `agentId`; continue or recover an existing one with
4259
- * `sessionId` (omit `agentId`). Passing both is rejected to avoid ambiguous
4260
- * agent-sdk delegation semantics.
4300
+ * Start a new session with just `agentId` (+ `message`); continue an existing one
4301
+ * by also passing its `sessionId`.
4261
4302
  */
4262
- interface ExecuteAgentParams extends Omit<ExecuteAgentRequest, 'organizationName' | 'repository' | 'inputs'> {
4263
- /**
4264
- * The Tela agent id. Required to start a new session — it is resolved to the
4265
- * underlying `organizationName`/`repository`. Omit it when continuing or
4266
- * recovering an existing `sessionId`; do not pass both.
4267
- */
4268
- agentId?: string;
4269
- /** File inputs. `TelaFile`s are uploaded to the vault; `AgentInput`s pass through. */
4270
- inputs?: AgentExecuteInput[];
4303
+ interface RunAgentParams {
4304
+ /** The Tela agent id (path param). Always required — `/agent/:id/run`. */
4305
+ agentId: string;
4306
+ /** The turn message (required by the API for both new and continued sessions). */
4307
+ message: string;
4308
+ /** Continue an existing session by id; omit to start a new one. */
4309
+ sessionId?: string;
4310
+ /** Key/value environment variables for the run. */
4311
+ environmentVariables?: Record<string, string>;
4312
+ /** Per-variable inputs, flattened into the wire `inputSchema` array. */
4313
+ inputs?: AgentRunInputs;
4314
+ /**
4315
+ * Optional session webhook registrations. On continuation, passing this
4316
+ * replaces the existing set; omitting it keeps the current registration.
4317
+ */
4318
+ webhooks?: AgentRunWebhooks;
4271
4319
  }
4320
+ /** Response of `POST /agent/:id/run`, matching the agent-sdk execute response union. */
4321
+ type RunAgentResponse = ExecuteAgentResponse;
4272
4322
  /**
4273
4323
  * Parameters for updating an agent's model — mirrors the agent-sdk
4274
4324
  * `UpdateAgentModelRequest`, with `agentId` in place of `repository`.
@@ -4285,21 +4335,19 @@ interface UpdateAgentModelParams {
4285
4335
  /**
4286
4336
  * Agents API resource (`tela.agents`).
4287
4337
  *
4288
- * A thin **pass-through wrapper** around `@meistrari/agent-sdk`. Execution,
4289
- * streaming, timeline, cancellation, and model updates are delegated straight to
4290
- * the agent-sdk client (which talks to the `/v4/*` endpoints). The wrapper adds
4291
- * only the Tela-specific bits:
4338
+ * Execution runs through the Tela gateway (`run` → `POST /agent/:id/run`): the
4339
+ * wrapper flattens the per-variable `inputs` map into the wire `inputSchema`
4340
+ * array and uploads any `TelaFile` inputs to the vault first. Streaming,
4341
+ * timeline, cancellation, and model updates are delegated to `@meistrari/agent-sdk`
4342
+ * (which talks to the `/v4/*` endpoints). The wrapper adds the Tela-specific bits:
4292
4343
  *
4293
4344
  * - **`agentId` resolution** — a Tela agent is addressed by id; the wrapper
4294
4345
  * resolves it to the underlying `organizationName`/`repository` via the Tela
4295
- * gateway `/agent` routes before delegating an execution.
4346
+ * gateway `/agent` routes for the delegated agent-sdk calls.
4296
4347
  * - **vault integration** — `TelaFile` inputs are uploaded to the vault and
4297
4348
  * passed to the agent as `vault://` references.
4298
4349
  * - **auth** — Tela credentials are mapped onto an agent-sdk `AuthStrategy`.
4299
4350
  *
4300
- * Webhook registration comes for free: `webhooks` is part of the agent-sdk
4301
- * execute contract and passes straight through.
4302
- *
4303
4351
  * @module Resources
4304
4352
  */
4305
4353
 
@@ -4326,14 +4374,17 @@ type AgentsConfig = {
4326
4374
  * ```typescript
4327
4375
  * const tela = new TelaSDK({ apiKey: '...' })
4328
4376
  *
4329
- * // Start a session by agent id (resolved to org/repo under the hood).
4330
- * const { sessionId } = await tela.agents.executeAgent({
4377
+ * // Start a session by agent id (`POST /agent/:id/run`).
4378
+ * const { sessionId } = await tela.agents.run({
4331
4379
  * agentId: 'agent-123',
4332
4380
  * message: 'Summarize the latest tickets',
4333
- * webhooks: [{ url: 'https://example.com/hook', events: ['session.completed'] }],
4381
+ * inputs: {
4382
+ * report: tela.createFile('https://example.com/q3.pdf'),
4383
+ * notes: { type: 'text', content: 'Focus on churn.' },
4384
+ * },
4334
4385
  * })
4335
4386
  *
4336
- * // Stream / inspect / cancel by session id (straight pass-through).
4387
+ * // Stream / inspect / cancel by session id (agent-sdk pass-through).
4337
4388
  * for await (const event of await tela.agents.streamSession(sessionId))
4338
4389
  * console.log(event.kind)
4339
4390
  * const timeline = await tela.agents.fetchTimeline(sessionId)
@@ -4377,21 +4428,17 @@ declare class Agents {
4377
4428
  */
4378
4429
  get(agentId: string): Promise<AgentRecord>;
4379
4430
  /**
4380
- * Starts (or continues/recovers) an agent session, delegating to the
4381
- * agent-sdk client (`POST /v4/agents/execute`).
4382
- *
4383
- * - **New session**: pass `agentId` (+ `message`). It is resolved to the
4384
- * underlying `organizationName`/`repository`.
4385
- * - **Continue / recover**: pass `sessionId` (omit `agentId`); `recover: true`
4386
- * resumes without a new message.
4431
+ * Starts (or continues) an agent session via the Tela gateway
4432
+ * (`POST /agent/:id/run`).
4387
4433
  *
4388
- * After the request shape is validated, `TelaFile` inputs are uploaded to
4389
- * the vault; `webhooks` pass through to register lifecycle callbacks.
4434
+ * - **New session**: pass `agentId` (+ `message`).
4435
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4390
4436
  *
4391
- * @throws {Error} If neither `agentId` nor `sessionId` is provided, or if
4392
- * both are provided.
4437
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4438
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4439
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4393
4440
  */
4394
- executeAgent(params: ExecuteAgentParams): Promise<ExecuteAgentResponse>;
4441
+ run(params: RunAgentParams): Promise<RunAgentResponse>;
4395
4442
  /**
4396
4443
  * Updates an agent's model, delegating to the agent-sdk client
4397
4444
  * (`PUT /v4/agents/:repository/model`). The `agentId` is resolved to the
@@ -4404,10 +4451,16 @@ declare class Agents {
4404
4451
  */
4405
4452
  private resolveAgent;
4406
4453
  /**
4407
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4408
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4454
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4455
+ * `inputSchema` array, tagging each entry with its variable name and
4456
+ * uploading any {@link TelaFile} entries to the vault.
4457
+ */
4458
+ private buildInputSchema;
4459
+ /**
4460
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4461
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4409
4462
  */
4410
- private uploadInputs;
4463
+ private resolveEntry;
4411
4464
  }
4412
4465
 
4413
4466
  /**
@@ -4554,13 +4607,13 @@ declare class TelaSDK extends BaseClient {
4554
4607
  */
4555
4608
  vault: Vault;
4556
4609
  /**
4557
- * Agents API resource a thin pass-through wrapper around
4558
- * `@meistrari/agent-sdk`. Execute by `agentId`, then stream events, fetch the
4559
- * timeline, or cancel by `sessionId`.
4610
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4611
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4612
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4560
4613
  *
4561
4614
  * @example
4562
4615
  * ```typescript
4563
- * const { sessionId } = await tela.agents.executeAgent({
4616
+ * const { sessionId } = await tela.agents.run({
4564
4617
  * agentId: 'agent-id',
4565
4618
  * message: 'Hello',
4566
4619
  * })
@@ -4627,4 +4680,4 @@ declare class TelaSDK extends BaseClient {
4627
4680
  */
4628
4681
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4629
4682
 
4630
- export { APIError, type AgentExecuteInput, AgentExecutionFailedError, type AgentInputVariable, type AgentRecord, Agents, type AgentsConfig, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, type ExecuteAgentParams, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, type ListAgentsQuery, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type SchemaBuilder, type SessionErrorEvent, type SessionResultEvent, type SessionStatusEvent, type SessionStepsEvent, type SessionTimelineFinalizeEvent, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, type UpdateAgentModelParams, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
4683
+ export { APIError, AgentExecutionFailedError, type AgentFileEntry, type AgentInputVariable, type AgentRecord, type AgentRunInputEntry, type AgentRunInputItem, type AgentRunInputs, type AgentRunWebhooks, type AgentTextEntry, type AgentUploadEntry, Agents, type AgentsConfig, AuthenticationError, AuthorizationError, BadRequestError, BaseClient, type BaseClientOptions, type BaseTelaFileOptions, BatchExecutionFailedError, type BatchParams, type BatchQueueConfig, type BatchQueueType, type BatchWebhookConfig, ConflictApiKeyAndJWTError, ConflictAuthMethodsError, ConflictError, ConnectionError, ConnectionTimeout, EmptyFileError, ExecutionFailedError, ExecutionNotStartedError, FileUploadError, type HTTPMethods, InternalServerError, InvalidExecutionModeError, InvalidFileURL, type ListAgentsQuery, MissingApiKeyOrJWTError, MissingAuthError, type NormalizedTaskStatus, NotFoundError, RateLimitError, type RequestOptions, type RunAgentParams, type RunAgentResponse, type SchemaBuilder, type SessionErrorEvent, type SessionResultEvent, type SessionStatusEvent, type SessionStepsEvent, type SessionTimelineFinalizeEvent, type Task, type TaskDeleteBulkResult, type TaskDeleteResult, TaskFailedError, type TaskInputContent, type TaskInputFile, type TaskListItem, type TaskListQuery, type TaskListResult, type TaskOrderBy, type TaskOutputContent, type TaskRerunResult, type TaskStatus, type TaskUndoApprovalBulkResult, type TaskUpdatePayload, Tasks, TelaError, TelaFile, type TelaFileInput, type TelaFileOptions, type TelaFileOptionsWithMimeType, TelaFileSchema, TelaSDK, type TelaSDKOptions, UnprocessableEntityError, type UpdateAgentModelParams, UserAbortError, Vault, createTelaClient, extractTaskOutput, isTelaFile, isTelaFileArray, normalizeTaskStatus, toError };
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import Emittery from 'emittery';
5
5
  import { agentClient, DataTokenAuthStrategy, APIKeyAuthStrategy } from '@meistrari/agent-sdk';
6
6
  export { parseSessionStream, verifyWebhookSignature } from '@meistrari/agent-sdk';
7
7
 
8
- const version = "2.13.1";
8
+ const version = "2.13.2";
9
9
 
10
10
  var __defProp$b = Object.defineProperty;
11
11
  var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -4769,34 +4769,27 @@ class Agents {
4769
4769
  return response.data;
4770
4770
  }
4771
4771
  /**
4772
- * Starts (or continues/recovers) an agent session, delegating to the
4773
- * agent-sdk client (`POST /v4/agents/execute`).
4772
+ * Starts (or continues) an agent session via the Tela gateway
4773
+ * (`POST /agent/:id/run`).
4774
4774
  *
4775
- * - **New session**: pass `agentId` (+ `message`). It is resolved to the
4776
- * underlying `organizationName`/`repository`.
4777
- * - **Continue / recover**: pass `sessionId` (omit `agentId`); `recover: true`
4778
- * resumes without a new message.
4775
+ * - **New session**: pass `agentId` (+ `message`).
4776
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4779
4777
  *
4780
- * After the request shape is validated, `TelaFile` inputs are uploaded to
4781
- * the vault; `webhooks` pass through to register lifecycle callbacks.
4782
- *
4783
- * @throws {Error} If neither `agentId` nor `sessionId` is provided, or if
4784
- * both are provided.
4778
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4779
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4780
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4785
4781
  */
4786
- async executeAgent(params) {
4787
- const { agentId, inputs, ...rest } = params;
4788
- const hasSessionId = rest.sessionId !== void 0;
4789
- if (hasSessionId) {
4790
- if (agentId)
4791
- throw new Error("agents.executeAgent: pass either `agentId` to start a new session or `sessionId` to continue/recover an existing session, not both.");
4792
- const resolvedInputs2 = inputs ? await this.uploadInputs(inputs) : void 0;
4793
- return this.client.executeAgent({ ...rest, inputs: resolvedInputs2 });
4794
- }
4795
- if (!agentId)
4796
- throw new Error("agents.executeAgent: `agentId` is required to start a new session (omit it only when continuing an existing `sessionId`).");
4797
- const resolvedInputs = inputs ? await this.uploadInputs(inputs) : void 0;
4798
- const { organizationName, repository } = await this.resolveAgent(agentId);
4799
- return this.client.executeAgent({ ...rest, inputs: resolvedInputs, organizationName, repository });
4782
+ async run(params) {
4783
+ const { agentId, message, sessionId, environmentVariables, inputs, webhooks } = params;
4784
+ const inputSchema = inputs ? await this.buildInputSchema(inputs) : void 0;
4785
+ const response = await this.gateway.post(
4786
+ `/agent/${agentId}/run`,
4787
+ {
4788
+ ...AGENT_NO_TRANSFORM,
4789
+ body: { message, sessionId, inputSchema, environmentVariables, webhooks }
4790
+ }
4791
+ );
4792
+ return response.data;
4800
4793
  }
4801
4794
  /**
4802
4795
  * Updates an agent's model, delegating to the agent-sdk client
@@ -4825,19 +4818,45 @@ class Agents {
4825
4818
  return resolution;
4826
4819
  }
4827
4820
  /**
4828
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4829
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4821
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4822
+ * `inputSchema` array, tagging each entry with its variable name and
4823
+ * uploading any {@link TelaFile} entries to the vault.
4830
4824
  */
4831
- async uploadInputs(inputs) {
4832
- return Promise.all(
4833
- inputs.map(async (input) => {
4834
- if (isTelaFile(input)) {
4835
- const { fileUrl } = await uploadFile(input, this.gateway);
4836
- return { vaultRef: fileUrl, filename: input.name ?? "file" };
4837
- }
4838
- return input;
4839
- })
4840
- );
4825
+ async buildInputSchema(inputs) {
4826
+ const pairs = Object.entries(inputs).flatMap(([name, value]) => {
4827
+ const entries = Array.isArray(value) ? value : [value];
4828
+ return entries.map((entry) => ({ name, entry }));
4829
+ });
4830
+ return Promise.all(pairs.map(({ name, entry }) => this.resolveEntry(name, entry)));
4831
+ }
4832
+ /**
4833
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4834
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4835
+ */
4836
+ async resolveEntry(name, entry) {
4837
+ if (isTelaFile(entry)) {
4838
+ const { fileUrl } = await uploadFile(entry, this.gateway);
4839
+ return { type: "file", name, vaultRef: fileUrl, filename: entry.name ?? "file" };
4840
+ }
4841
+ if ("type" in entry && entry.type === "text")
4842
+ return { type: "text", name, content: entry.content };
4843
+ if ("file" in entry) {
4844
+ const { fileUrl } = await uploadFile(entry.file, this.gateway);
4845
+ return {
4846
+ type: "file",
4847
+ name,
4848
+ vaultRef: fileUrl,
4849
+ filename: entry.filename ?? entry.file.name ?? "file",
4850
+ ...entry.metadata ? { metadata: entry.metadata } : {}
4851
+ };
4852
+ }
4853
+ return {
4854
+ type: "file",
4855
+ name,
4856
+ vaultRef: entry.vaultRef,
4857
+ filename: entry.filename,
4858
+ ...entry.metadata ? { metadata: entry.metadata } : {}
4859
+ };
4841
4860
  }
4842
4861
  }
4843
4862
 
@@ -4937,13 +4956,13 @@ const _TelaSDK = class _TelaSDK extends BaseClient {
4937
4956
  */
4938
4957
  __publicField(this, "vault", new Vault(this));
4939
4958
  /**
4940
- * Agents API resource a thin pass-through wrapper around
4941
- * `@meistrari/agent-sdk`. Execute by `agentId`, then stream events, fetch the
4942
- * timeline, or cancel by `sessionId`.
4959
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4960
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4961
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4943
4962
  *
4944
4963
  * @example
4945
4964
  * ```typescript
4946
- * const { sessionId } = await tela.agents.executeAgent({
4965
+ * const { sessionId } = await tela.agents.run({
4947
4966
  * agentId: 'agent-id',
4948
4967
  * message: 'Hello',
4949
4968
  * })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-sdk-js",
3
- "version": "2.13.1",
3
+ "version": "2.13.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/meistrari/tela-sdk-js.git"