@meistrari/tela-sdk-js 2.13.1 → 2.14.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 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.14.0";
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;
@@ -2390,6 +2390,7 @@ class CanvasExecution extends Emittery__default {
2390
2390
  versionId: this._params.versionId,
2391
2391
  messages: this._params.messages,
2392
2392
  tags: this._params.tags,
2393
+ environmentName: this._params.environmentName,
2393
2394
  label: this._params.label,
2394
2395
  webhook_url: this._params.webhookUrl
2395
2396
  };
@@ -4788,34 +4789,27 @@ class Agents {
4788
4789
  return response.data;
4789
4790
  }
4790
4791
  /**
4791
- * Starts (or continues/recovers) an agent session, delegating to the
4792
- * agent-sdk client (`POST /v4/agents/execute`).
4792
+ * Starts (or continues) an agent session via the Tela gateway
4793
+ * (`POST /agent/:id/run`).
4793
4794
  *
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.
4795
+ * - **New session**: pass `agentId` (+ `message`).
4796
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4798
4797
  *
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.
4798
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4799
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4800
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4804
4801
  */
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 });
4802
+ async run(params) {
4803
+ const { agentId, message, sessionId, environmentVariables, inputs, webhooks } = params;
4804
+ const inputSchema = inputs ? await this.buildInputSchema(inputs) : void 0;
4805
+ const response = await this.gateway.post(
4806
+ `/agent/${agentId}/run`,
4807
+ {
4808
+ ...AGENT_NO_TRANSFORM,
4809
+ body: { message, sessionId, inputSchema, environmentVariables, webhooks }
4810
+ }
4811
+ );
4812
+ return response.data;
4819
4813
  }
4820
4814
  /**
4821
4815
  * Updates an agent's model, delegating to the agent-sdk client
@@ -4844,19 +4838,45 @@ class Agents {
4844
4838
  return resolution;
4845
4839
  }
4846
4840
  /**
4847
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4848
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4841
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4842
+ * `inputSchema` array, tagging each entry with its variable name and
4843
+ * uploading any {@link TelaFile} entries to the vault.
4849
4844
  */
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
- );
4845
+ async buildInputSchema(inputs) {
4846
+ const pairs = Object.entries(inputs).flatMap(([name, value]) => {
4847
+ const entries = Array.isArray(value) ? value : [value];
4848
+ return entries.map((entry) => ({ name, entry }));
4849
+ });
4850
+ return Promise.all(pairs.map(({ name, entry }) => this.resolveEntry(name, entry)));
4851
+ }
4852
+ /**
4853
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4854
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4855
+ */
4856
+ async resolveEntry(name, entry) {
4857
+ if (isTelaFile(entry)) {
4858
+ const { fileUrl } = await uploadFile(entry, this.gateway);
4859
+ return { type: "file", name, vaultRef: fileUrl, filename: entry.name ?? "file" };
4860
+ }
4861
+ if ("type" in entry && entry.type === "text")
4862
+ return { type: "text", name, content: entry.content };
4863
+ if ("file" in entry) {
4864
+ const { fileUrl } = await uploadFile(entry.file, this.gateway);
4865
+ return {
4866
+ type: "file",
4867
+ name,
4868
+ vaultRef: fileUrl,
4869
+ filename: entry.filename ?? entry.file.name ?? "file",
4870
+ ...entry.metadata ? { metadata: entry.metadata } : {}
4871
+ };
4872
+ }
4873
+ return {
4874
+ type: "file",
4875
+ name,
4876
+ vaultRef: entry.vaultRef,
4877
+ filename: entry.filename,
4878
+ ...entry.metadata ? { metadata: entry.metadata } : {}
4879
+ };
4860
4880
  }
4861
4881
  }
4862
4882
 
@@ -4956,13 +4976,13 @@ const _TelaSDK = class _TelaSDK extends BaseClient {
4956
4976
  */
4957
4977
  __publicField(this, "vault", new Vault(this));
4958
4978
  /**
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`.
4979
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4980
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4981
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4962
4982
  *
4963
4983
  * @example
4964
4984
  * ```typescript
4965
- * const { sessionId } = await tela.agents.executeAgent({
4985
+ * const { sessionId } = await tela.agents.run({
4966
4986
  * agentId: 'agent-id',
4967
4987
  * message: 'Hello',
4968
4988
  * })
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.
@@ -928,6 +928,7 @@ type SchemaFunction<T> = (schema: SchemaBuilder) => T;
928
928
  type Output<T> = T extends z$1.ZodType ? z$1.infer<T> : T;
929
929
  type ZodTypeOrRecord = z$1.ZodType | Record<string, unknown>;
930
930
 
931
+ type EnvironmentName = 'production' | (string & {});
931
932
  interface BaseExecutionParams {
932
933
  /**
933
934
  * The version ID of the canvas to use for this chat completion.
@@ -1003,6 +1004,12 @@ interface BaseExecutionParams {
1003
1004
  * Tags can be used for filtering, categorization, and analytics.
1004
1005
  */
1005
1006
  tags?: string[];
1007
+ /**
1008
+ * Optional environment name to use for this execution.
1009
+ * The default production environment is always available, and custom
1010
+ * environment names can be configured in Tela.
1011
+ */
1012
+ environmentName?: EnvironmentName;
1006
1013
  /**
1007
1014
  * Custom HTTP headers to include in the request.
1008
1015
  * Useful for passing canvas event IDs.
@@ -1960,7 +1967,7 @@ interface BatchItem<TInput> {
1960
1967
  /**
1961
1968
  * Parameters excluded from batch execution (managed internally).
1962
1969
  */
1963
- type ExcludedParams = 'versionId' | 'canvasId' | 'applicationId' | 'async' | 'stream' | 'webhookUrl' | 'skipResultValidation';
1970
+ type ExcludedParams = 'versionId' | 'canvasId' | 'applicationId' | 'async' | 'stream' | 'webhookUrl' | 'environmentName' | 'skipResultValidation';
1964
1971
  /**
1965
1972
  * Webhook configuration for batch completion notifications.
1966
1973
  *
@@ -4166,18 +4173,16 @@ declare class Vault {
4166
4173
  /**
4167
4174
  * Types for the Agents API.
4168
4175
  *
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.
4176
+ * Execution runs through the Tela gateway (`POST /agent/:id/run`): {@link RunAgentParams}
4177
+ * carries a per-variable {@link AgentRunInputs} map that the wrapper flattens into the
4178
+ * wire `inputSchema` array (each entry tagged with its variable `name`), uploading any
4179
+ * {@link TelaFile} inputs to the vault along the way.
4174
4180
  *
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.
4181
+ * Streaming, timeline, cancellation, and model updates are still delegated to
4182
+ * `@meistrari/agent-sdk`, so those session/agent contract types are re-exported here
4183
+ * (single source of truth) rather than redefined. A Tela agent is addressed by id and
4184
+ * resolved to the underlying `organizationName`/`repository` (via the gateway `/agent`
4185
+ * routes) for those delegated calls.
4181
4186
  *
4182
4187
  * @module Resources
4183
4188
  */
@@ -4241,34 +4246,86 @@ interface ListAgentsQuery {
4241
4246
  projectId?: string;
4242
4247
  includeProjects?: boolean;
4243
4248
  }
4249
+ /** A file input whose vault reference is already known. */
4250
+ interface AgentFileEntry {
4251
+ type?: 'file';
4252
+ /** A `vault://` reference. */
4253
+ vaultRef: string;
4254
+ /** The user-facing filename. */
4255
+ filename: string;
4256
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4257
+ metadata?: string;
4258
+ }
4259
+ /** A {@link TelaFile} to upload to the vault before the run, with optional metadata. */
4260
+ interface AgentUploadEntry {
4261
+ type?: 'file';
4262
+ /** The file to upload; its vault reference is derived automatically. */
4263
+ file: TelaFile;
4264
+ /** Overrides the uploaded filename; defaults to the {@link TelaFile}'s name. */
4265
+ filename?: string;
4266
+ /** Optional metadata string forwarded to the agent (≤16,384 chars). */
4267
+ metadata?: string;
4268
+ }
4269
+ /** A text input. */
4270
+ interface AgentTextEntry {
4271
+ type: 'text';
4272
+ /** The text content (≤10MB). */
4273
+ content: string;
4274
+ }
4244
4275
  /**
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.
4276
+ * One input value for a variable. A bare {@link TelaFile} is sugar for
4277
+ * `{ file }` it is uploaded to the vault automatically.
4248
4278
  */
4249
- type AgentExecuteInput = AgentInput | TelaFile;
4279
+ type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
4250
4280
  /**
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).
4281
+ * Per-variable inputs: the key is the variable `name`, the value is one entry or
4282
+ * an array of entries. The wrapper flattens this into the wire `inputSchema`
4283
+ * array, tagging every entry with its variable name.
4284
+ */
4285
+ type AgentRunInputs = Record<string, AgentRunInputEntry | AgentRunInputEntry[]>;
4286
+ /** Webhook registrations accepted by {@link Agents.run}; forwarded to `/agent/:id/run` unchanged. */
4287
+ type AgentRunWebhooks = ExecuteAgentRequest['webhooks'];
4288
+ /**
4289
+ * A single wire `inputSchema` entry as sent to `POST /agent/:id/run`. Produced by
4290
+ * flattening {@link AgentRunInputs}.
4291
+ */
4292
+ type AgentRunInputItem = {
4293
+ type: 'file';
4294
+ name: string;
4295
+ vaultRef: string;
4296
+ filename: string;
4297
+ metadata?: string;
4298
+ } | {
4299
+ type: 'text';
4300
+ name: string;
4301
+ content: string;
4302
+ };
4303
+ /**
4304
+ * Parameters for {@link Agents.run} — starting or continuing an agent session via
4305
+ * the Tela gateway (`POST /agent/:id/run`).
4257
4306
  *
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.
4307
+ * Start a new session with just `agentId` (+ `message`); continue an existing one
4308
+ * by also passing its `sessionId`.
4261
4309
  */
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[];
4310
+ interface RunAgentParams {
4311
+ /** The Tela agent id (path param). Always required — `/agent/:id/run`. */
4312
+ agentId: string;
4313
+ /** The turn message (required by the API for both new and continued sessions). */
4314
+ message: string;
4315
+ /** Continue an existing session by id; omit to start a new one. */
4316
+ sessionId?: string;
4317
+ /** Key/value environment variables for the run. */
4318
+ environmentVariables?: Record<string, string>;
4319
+ /** Per-variable inputs, flattened into the wire `inputSchema` array. */
4320
+ inputs?: AgentRunInputs;
4321
+ /**
4322
+ * Optional session webhook registrations. On continuation, passing this
4323
+ * replaces the existing set; omitting it keeps the current registration.
4324
+ */
4325
+ webhooks?: AgentRunWebhooks;
4271
4326
  }
4327
+ /** Response of `POST /agent/:id/run`, matching the agent-sdk execute response union. */
4328
+ type RunAgentResponse = ExecuteAgentResponse;
4272
4329
  /**
4273
4330
  * Parameters for updating an agent's model — mirrors the agent-sdk
4274
4331
  * `UpdateAgentModelRequest`, with `agentId` in place of `repository`.
@@ -4285,21 +4342,19 @@ interface UpdateAgentModelParams {
4285
4342
  /**
4286
4343
  * Agents API resource (`tela.agents`).
4287
4344
  *
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:
4345
+ * Execution runs through the Tela gateway (`run` → `POST /agent/:id/run`): the
4346
+ * wrapper flattens the per-variable `inputs` map into the wire `inputSchema`
4347
+ * array and uploads any `TelaFile` inputs to the vault first. Streaming,
4348
+ * timeline, cancellation, and model updates are delegated to `@meistrari/agent-sdk`
4349
+ * (which talks to the `/v4/*` endpoints). The wrapper adds the Tela-specific bits:
4292
4350
  *
4293
4351
  * - **`agentId` resolution** — a Tela agent is addressed by id; the wrapper
4294
4352
  * resolves it to the underlying `organizationName`/`repository` via the Tela
4295
- * gateway `/agent` routes before delegating an execution.
4353
+ * gateway `/agent` routes for the delegated agent-sdk calls.
4296
4354
  * - **vault integration** — `TelaFile` inputs are uploaded to the vault and
4297
4355
  * passed to the agent as `vault://` references.
4298
4356
  * - **auth** — Tela credentials are mapped onto an agent-sdk `AuthStrategy`.
4299
4357
  *
4300
- * Webhook registration comes for free: `webhooks` is part of the agent-sdk
4301
- * execute contract and passes straight through.
4302
- *
4303
4358
  * @module Resources
4304
4359
  */
4305
4360
 
@@ -4326,14 +4381,17 @@ type AgentsConfig = {
4326
4381
  * ```typescript
4327
4382
  * const tela = new TelaSDK({ apiKey: '...' })
4328
4383
  *
4329
- * // Start a session by agent id (resolved to org/repo under the hood).
4330
- * const { sessionId } = await tela.agents.executeAgent({
4384
+ * // Start a session by agent id (`POST /agent/:id/run`).
4385
+ * const { sessionId } = await tela.agents.run({
4331
4386
  * agentId: 'agent-123',
4332
4387
  * message: 'Summarize the latest tickets',
4333
- * webhooks: [{ url: 'https://example.com/hook', events: ['session.completed'] }],
4388
+ * inputs: {
4389
+ * report: tela.createFile('https://example.com/q3.pdf'),
4390
+ * notes: { type: 'text', content: 'Focus on churn.' },
4391
+ * },
4334
4392
  * })
4335
4393
  *
4336
- * // Stream / inspect / cancel by session id (straight pass-through).
4394
+ * // Stream / inspect / cancel by session id (agent-sdk pass-through).
4337
4395
  * for await (const event of await tela.agents.streamSession(sessionId))
4338
4396
  * console.log(event.kind)
4339
4397
  * const timeline = await tela.agents.fetchTimeline(sessionId)
@@ -4377,21 +4435,17 @@ declare class Agents {
4377
4435
  */
4378
4436
  get(agentId: string): Promise<AgentRecord>;
4379
4437
  /**
4380
- * Starts (or continues/recovers) an agent session, delegating to the
4381
- * agent-sdk client (`POST /v4/agents/execute`).
4438
+ * Starts (or continues) an agent session via the Tela gateway
4439
+ * (`POST /agent/:id/run`).
4382
4440
  *
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.
4441
+ * - **New session**: pass `agentId` (+ `message`).
4442
+ * - **Continue**: pass `agentId` and the existing `sessionId`.
4387
4443
  *
4388
- * After the request shape is validated, `TelaFile` inputs are uploaded to
4389
- * the vault; `webhooks` pass through to register lifecycle callbacks.
4390
- *
4391
- * @throws {Error} If neither `agentId` nor `sessionId` is provided, or if
4392
- * both are provided.
4444
+ * The per-variable `inputs` map is flattened into the wire `inputSchema`
4445
+ * array (each entry tagged with its variable name); any `TelaFile` inputs are
4446
+ * uploaded to the vault first. Returns the `sessionId` to stream/inspect.
4393
4447
  */
4394
- executeAgent(params: ExecuteAgentParams): Promise<ExecuteAgentResponse>;
4448
+ run(params: RunAgentParams): Promise<RunAgentResponse>;
4395
4449
  /**
4396
4450
  * Updates an agent's model, delegating to the agent-sdk client
4397
4451
  * (`PUT /v4/agents/:repository/model`). The `agentId` is resolved to the
@@ -4404,10 +4458,16 @@ declare class Agents {
4404
4458
  */
4405
4459
  private resolveAgent;
4406
4460
  /**
4407
- * Uploads any {@link TelaFile} inputs to the vault, turning the input list
4408
- * into agent-sdk {@link AgentInput}s (`vault://` references pass through).
4461
+ * Flattens the per-variable {@link AgentRunInputs} map into the wire
4462
+ * `inputSchema` array, tagging each entry with its variable name and
4463
+ * uploading any {@link TelaFile} entries to the vault.
4464
+ */
4465
+ private buildInputSchema;
4466
+ /**
4467
+ * Resolves a single {@link AgentRunInputEntry} into a wire
4468
+ * {@link AgentRunInputItem}, uploading {@link TelaFile}s to the vault.
4409
4469
  */
4410
- private uploadInputs;
4470
+ private resolveEntry;
4411
4471
  }
4412
4472
 
4413
4473
  /**
@@ -4554,13 +4614,13 @@ declare class TelaSDK extends BaseClient {
4554
4614
  */
4555
4615
  vault: Vault;
4556
4616
  /**
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`.
4617
+ * Agents API resource. Run an agent by `agentId` via the Tela gateway
4618
+ * (`POST /agent/:id/run`), then stream events, fetch the timeline, or cancel
4619
+ * by `sessionId` (delegated to `@meistrari/agent-sdk`).
4560
4620
  *
4561
4621
  * @example
4562
4622
  * ```typescript
4563
- * const { sessionId } = await tela.agents.executeAgent({
4623
+ * const { sessionId } = await tela.agents.run({
4564
4624
  * agentId: 'agent-id',
4565
4625
  * message: 'Hello',
4566
4626
  * })
@@ -4627,4 +4687,4 @@ declare class TelaSDK extends BaseClient {
4627
4687
  */
4628
4688
  declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
4629
4689
 
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 };
4690
+ 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, type EnvironmentName, 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 };