@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 +43 -35
- package/dist/index.cjs +62 -42
- package/dist/index.d.cts +128 -68
- package/dist/index.d.mts +128 -68
- package/dist/index.d.ts +128 -68
- package/dist/index.mjs +62 -42
- package/package.json +1 -1
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,
|
|
5
|
-
export {
|
|
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
|
-
*
|
|
4170
|
-
*
|
|
4171
|
-
*
|
|
4172
|
-
*
|
|
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
|
-
*
|
|
4176
|
-
*
|
|
4177
|
-
*
|
|
4178
|
-
*
|
|
4179
|
-
*
|
|
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
|
-
*
|
|
4246
|
-
* `
|
|
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
|
|
4279
|
+
type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
|
|
4250
4280
|
/**
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
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
|
|
4259
|
-
*
|
|
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
|
|
4263
|
-
/**
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
/**
|
|
4270
|
-
|
|
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
|
-
*
|
|
4289
|
-
*
|
|
4290
|
-
*
|
|
4291
|
-
*
|
|
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
|
|
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 (
|
|
4330
|
-
* const { sessionId } = await tela.agents.
|
|
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
|
-
*
|
|
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 (
|
|
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
|
|
4381
|
-
*
|
|
4438
|
+
* Starts (or continues) an agent session via the Tela gateway
|
|
4439
|
+
* (`POST /agent/:id/run`).
|
|
4382
4440
|
*
|
|
4383
|
-
* - **New session**: pass `agentId` (+ `message`).
|
|
4384
|
-
*
|
|
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
|
-
*
|
|
4389
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
4408
|
-
*
|
|
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
|
|
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
|
|
4558
|
-
*
|
|
4559
|
-
*
|
|
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.
|
|
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
|
|
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 };
|
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,
|
|
5
|
-
export {
|
|
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
|
-
*
|
|
4170
|
-
*
|
|
4171
|
-
*
|
|
4172
|
-
*
|
|
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
|
-
*
|
|
4176
|
-
*
|
|
4177
|
-
*
|
|
4178
|
-
*
|
|
4179
|
-
*
|
|
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
|
-
*
|
|
4246
|
-
* `
|
|
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
|
|
4279
|
+
type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
|
|
4250
4280
|
/**
|
|
4251
|
-
*
|
|
4252
|
-
*
|
|
4253
|
-
*
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
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
|
|
4259
|
-
*
|
|
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
|
|
4263
|
-
/**
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
/**
|
|
4270
|
-
|
|
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
|
-
*
|
|
4289
|
-
*
|
|
4290
|
-
*
|
|
4291
|
-
*
|
|
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
|
|
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 (
|
|
4330
|
-
* const { sessionId } = await tela.agents.
|
|
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
|
-
*
|
|
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 (
|
|
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
|
|
4381
|
-
*
|
|
4438
|
+
* Starts (or continues) an agent session via the Tela gateway
|
|
4439
|
+
* (`POST /agent/:id/run`).
|
|
4382
4440
|
*
|
|
4383
|
-
* - **New session**: pass `agentId` (+ `message`).
|
|
4384
|
-
*
|
|
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
|
-
*
|
|
4389
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
4408
|
-
*
|
|
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
|
|
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
|
|
4558
|
-
*
|
|
4559
|
-
*
|
|
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.
|
|
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
|
|
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 };
|