@meistrari/tela-sdk-js 2.13.0 → 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 +65 -42
- package/dist/index.cjs +275 -583
- package/dist/index.d.cts +221 -360
- package/dist/index.d.mts +221 -360
- package/dist/index.d.ts +221 -360
- package/dist/index.mjs +276 -583
- package/package.json +2 -2
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 {
|
|
5
|
-
export { SessionStatus, SessionStreamEvent } 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.
|
|
@@ -4164,58 +4164,42 @@ declare class Vault {
|
|
|
4164
4164
|
}
|
|
4165
4165
|
|
|
4166
4166
|
/**
|
|
4167
|
-
* Types for the Agents API
|
|
4167
|
+
* Types for the Agents API.
|
|
4168
4168
|
*
|
|
4169
|
-
*
|
|
4170
|
-
*
|
|
4171
|
-
*
|
|
4172
|
-
*
|
|
4173
|
-
* transformation.
|
|
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
|
-
*
|
|
4176
|
-
*
|
|
4177
|
-
*
|
|
4178
|
-
* the
|
|
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.
|
|
4179
4179
|
*
|
|
4180
4180
|
* @module Resources
|
|
4181
4181
|
*/
|
|
4182
4182
|
|
|
4183
|
-
/**
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
usage: {
|
|
4204
|
-
duration: number;
|
|
4205
|
-
turns: number;
|
|
4206
|
-
completionTokens: number;
|
|
4207
|
-
promptTokens: number;
|
|
4208
|
-
totalTokens: number;
|
|
4209
|
-
completionCost: number;
|
|
4210
|
-
promptCost: number;
|
|
4211
|
-
totalCost: number;
|
|
4212
|
-
[key: string]: unknown;
|
|
4213
|
-
};
|
|
4214
|
-
content?: string;
|
|
4215
|
-
structuredContent?: Record<string, unknown>;
|
|
4216
|
-
childEventIds?: string[];
|
|
4217
|
-
[key: string]: unknown;
|
|
4218
|
-
}
|
|
4183
|
+
/** A `status` session event. */
|
|
4184
|
+
type SessionStatusEvent = Extract<SessionStreamEvent, {
|
|
4185
|
+
kind: 'status';
|
|
4186
|
+
}>;
|
|
4187
|
+
/** A `steps` session event. */
|
|
4188
|
+
type SessionStepsEvent = Extract<SessionStreamEvent, {
|
|
4189
|
+
kind: 'steps';
|
|
4190
|
+
}>;
|
|
4191
|
+
/** A `result` session event. */
|
|
4192
|
+
type SessionResultEvent = Extract<SessionStreamEvent, {
|
|
4193
|
+
kind: 'result';
|
|
4194
|
+
}>;
|
|
4195
|
+
/** An `error` session event. */
|
|
4196
|
+
type SessionErrorEvent = Extract<SessionStreamEvent, {
|
|
4197
|
+
kind: 'error';
|
|
4198
|
+
}>;
|
|
4199
|
+
/** A `timeline-finalize` session event. */
|
|
4200
|
+
type SessionTimelineFinalizeEvent = Extract<SessionStreamEvent, {
|
|
4201
|
+
kind: 'timeline-finalize';
|
|
4202
|
+
}>;
|
|
4219
4203
|
/** A declared input variable on an agent (from the agent record). */
|
|
4220
4204
|
interface AgentInputVariable {
|
|
4221
4205
|
id?: string;
|
|
@@ -4226,6 +4210,9 @@ interface AgentInputVariable {
|
|
|
4226
4210
|
}
|
|
4227
4211
|
/**
|
|
4228
4212
|
* An agent record as returned by `GET /agent` and `GET /agent/:id`.
|
|
4213
|
+
*
|
|
4214
|
+
* Carries the `organizationName`/`repository` the agent-sdk addresses agents by;
|
|
4215
|
+
* the wrapper resolves an `agentId` to these before delegating an execution.
|
|
4229
4216
|
*/
|
|
4230
4217
|
interface AgentRecord {
|
|
4231
4218
|
id: string;
|
|
@@ -4252,11 +4239,50 @@ interface ListAgentsQuery {
|
|
|
4252
4239
|
projectId?: string;
|
|
4253
4240
|
includeProjects?: boolean;
|
|
4254
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
|
+
}
|
|
4268
|
+
/**
|
|
4269
|
+
* One input value for a variable. A bare {@link TelaFile} is sugar for
|
|
4270
|
+
* `{ file }` — it is uploaded to the vault automatically.
|
|
4271
|
+
*/
|
|
4272
|
+
type AgentRunInputEntry = AgentFileEntry | AgentUploadEntry | AgentTextEntry | TelaFile;
|
|
4255
4273
|
/**
|
|
4256
|
-
*
|
|
4257
|
-
*
|
|
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.
|
|
4258
4277
|
*/
|
|
4259
|
-
type
|
|
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 = {
|
|
4260
4286
|
type: 'file';
|
|
4261
4287
|
name: string;
|
|
4262
4288
|
vaultRef: string;
|
|
@@ -4267,293 +4293,78 @@ type AgentInputItem = {
|
|
|
4267
4293
|
name: string;
|
|
4268
4294
|
content: string;
|
|
4269
4295
|
};
|
|
4270
|
-
/** An ad-hoc file attachment (a vault reference + filename). */
|
|
4271
|
-
interface AgentAttachment {
|
|
4272
|
-
vaultRef: string;
|
|
4273
|
-
filename: string;
|
|
4274
|
-
}
|
|
4275
|
-
/**
|
|
4276
|
-
* Session timeline summary from `GET /agent/sessions/:id/timeline`.
|
|
4277
|
-
*/
|
|
4278
|
-
interface AgentTimeline {
|
|
4279
|
-
durationMs?: number;
|
|
4280
|
-
toolCalls?: number;
|
|
4281
|
-
apiCalls?: number;
|
|
4282
|
-
tokensIn?: number;
|
|
4283
|
-
tokensOut?: number;
|
|
4284
|
-
cachedTokens?: number;
|
|
4285
|
-
totalCostUsd?: number;
|
|
4286
|
-
cacheSavingsUsd?: number;
|
|
4287
|
-
prompt?: Record<string, unknown>;
|
|
4288
|
-
spans?: Array<Record<string, unknown>>;
|
|
4289
|
-
events?: Array<Record<string, unknown>>;
|
|
4290
|
-
continuation?: Record<string, unknown>;
|
|
4291
|
-
[key: string]: unknown;
|
|
4292
|
-
}
|
|
4293
4296
|
/**
|
|
4294
|
-
* Parameters for
|
|
4297
|
+
* Parameters for {@link Agents.run} — starting or continuing an agent session via
|
|
4298
|
+
* the Tela gateway (`POST /agent/:id/run`).
|
|
4299
|
+
*
|
|
4300
|
+
* Start a new session with just `agentId` (+ `message`); continue an existing one
|
|
4301
|
+
* by also passing its `sessionId`.
|
|
4295
4302
|
*/
|
|
4296
|
-
interface
|
|
4297
|
-
/** The
|
|
4298
|
-
|
|
4299
|
-
/**
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
/**
|
|
4305
|
-
* Values for the agent's declared input variables, keyed by name.
|
|
4306
|
-
* `TelaFile`s are uploaded to the vault automatically; strings are sent as text.
|
|
4307
|
-
*/
|
|
4308
|
-
inputs?: Record<string, TelaFile | string>;
|
|
4309
|
-
/** Ad-hoc file attachments — `TelaFile`s are uploaded; `AgentAttachment`s pass through. */
|
|
4310
|
-
attachments?: Array<TelaFile | AgentAttachment>;
|
|
4311
|
-
/** Environment variables made available to the agent run. */
|
|
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. */
|
|
4312
4311
|
environmentVariables?: Record<string, string>;
|
|
4312
|
+
/** Per-variable inputs, flattened into the wire `inputSchema` array. */
|
|
4313
|
+
inputs?: AgentRunInputs;
|
|
4313
4314
|
/**
|
|
4314
|
-
*
|
|
4315
|
-
*
|
|
4315
|
+
* Optional session webhook registrations. On continuation, passing this
|
|
4316
|
+
* replaces the existing set; omitting it keeps the current registration.
|
|
4316
4317
|
*/
|
|
4317
|
-
|
|
4318
|
-
/** Git ref (branch/tag/commit) to run. Draft mode only. */
|
|
4319
|
-
ref?: string;
|
|
4320
|
-
/** Enable multi-turn. Draft mode only. */
|
|
4321
|
-
isMultiturn?: boolean;
|
|
4322
|
-
/** Extra headers to attach to the execute request. */
|
|
4323
|
-
headers?: Record<string, string>;
|
|
4318
|
+
webhooks?: AgentRunWebhooks;
|
|
4324
4319
|
}
|
|
4325
|
-
|
|
4320
|
+
/** Response of `POST /agent/:id/run`, matching the agent-sdk execute response union. */
|
|
4321
|
+
type RunAgentResponse = ExecuteAgentResponse;
|
|
4326
4322
|
/**
|
|
4327
|
-
*
|
|
4328
|
-
*
|
|
4329
|
-
* `AgentExecution` drives a single agent session through the Tela API: it
|
|
4330
|
-
* creates (or continues) the session via `POST /agent/:id/run` (or `/test` for
|
|
4331
|
-
* the draft), then streams the session's events from `GET /agent/sessions/:id`
|
|
4332
|
-
* (SSE). It mirrors the promise-like + event-emitter ergonomics of
|
|
4333
|
-
* {@link CanvasExecution}: you can `await execution.result`, iterate
|
|
4334
|
-
* `execution.stream`, or subscribe to `status`/`step`/`result`/`error` events.
|
|
4335
|
-
*
|
|
4336
|
-
* @module Resources
|
|
4337
|
-
*/
|
|
4338
|
-
|
|
4339
|
-
/** The execution mode: the published version (`/run`) or the draft (`/test`). */
|
|
4340
|
-
type AgentExecutionMode = 'run' | 'test';
|
|
4341
|
-
/**
|
|
4342
|
-
* Events emitted by {@link AgentExecution} during a session's lifecycle.
|
|
4343
|
-
*
|
|
4344
|
-
* @property status - Emitted when the session status changes.
|
|
4345
|
-
* @property step - Emitted for each `steps` event, with the newly produced steps.
|
|
4346
|
-
* @property result - Emitted when the session produces a result payload.
|
|
4347
|
-
* @property error - Emitted when the session fails (an `error` event or `failed` status).
|
|
4323
|
+
* Parameters for updating an agent's model — mirrors the agent-sdk
|
|
4324
|
+
* `UpdateAgentModelRequest`, with `agentId` in place of `repository`.
|
|
4348
4325
|
*/
|
|
4349
|
-
interface
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
* Construction context for an {@link AgentExecution}.
|
|
4357
|
-
*/
|
|
4358
|
-
interface AgentExecutionContext {
|
|
4359
|
-
client: BaseClient;
|
|
4360
|
-
/** The agent id. Omitted for executions resumed from an existing session. */
|
|
4361
|
-
agentId?: string;
|
|
4362
|
-
/** Execution mode. Defaults to `run` (published). */
|
|
4363
|
-
mode?: AgentExecutionMode;
|
|
4364
|
-
/** An existing session id to resume. */
|
|
4365
|
-
sessionId?: string;
|
|
4366
|
-
/** Delay (ms) between session-stream reconnects. Defaults to 2000. */
|
|
4367
|
-
reconnectDelayMs?: number;
|
|
4368
|
-
}
|
|
4369
|
-
/**
|
|
4370
|
-
* A promise-like handle returned by `Agent.execute()` / `AgentExecution.continue()`.
|
|
4371
|
-
*
|
|
4372
|
-
* - `await` it to get the started {@link AgentExecution} (after the session is created).
|
|
4373
|
-
* - `.result` resolves with the session's result payload.
|
|
4374
|
-
* - `.stream` is a live, typed async iterator of session events.
|
|
4375
|
-
*
|
|
4376
|
-
* Consume **either** `.result` **or** `.stream` for a given execution — they
|
|
4377
|
-
* share a single underlying generator and cannot both be read.
|
|
4378
|
-
*/
|
|
4379
|
-
type AgentExecutionPromiseLike = PromiseLike<AgentExecution> & {
|
|
4380
|
-
result: Promise<AgentSessionResult>;
|
|
4381
|
-
stream: AsyncGenerator<SessionStreamEvent>;
|
|
4382
|
-
};
|
|
4383
|
-
/**
|
|
4384
|
-
* Manages the lifecycle of a single agent session.
|
|
4385
|
-
*
|
|
4386
|
-
* @fires status - When the session status transitions.
|
|
4387
|
-
* @fires step - For each batch of steps produced.
|
|
4388
|
-
* @fires result - When the session yields a result payload.
|
|
4389
|
-
* @fires error - When the session fails.
|
|
4390
|
-
*
|
|
4391
|
-
* @example
|
|
4392
|
-
* ```typescript
|
|
4393
|
-
* const agent = await tela.agents.get('agent-id')
|
|
4394
|
-
* const execution = agent.execute({ prompt: 'Summarize the latest tickets' })
|
|
4395
|
-
*
|
|
4396
|
-
* execution.on('step', steps => console.log(steps))
|
|
4397
|
-
* const result = await execution.result
|
|
4398
|
-
* ```
|
|
4399
|
-
*/
|
|
4400
|
-
declare class AgentExecution extends Emittery<AgentExecutionEvents> {
|
|
4401
|
-
private _sessionId;
|
|
4402
|
-
private _status;
|
|
4403
|
-
private _cursor;
|
|
4404
|
-
private _resultPromise;
|
|
4405
|
-
private _stream;
|
|
4406
|
-
private _abortController;
|
|
4407
|
-
private readonly _client;
|
|
4408
|
-
private readonly _agentId;
|
|
4409
|
-
private readonly _mode;
|
|
4410
|
-
private readonly _reconnectDelayMs;
|
|
4411
|
-
constructor(context: AgentExecutionContext);
|
|
4412
|
-
/**
|
|
4413
|
-
* Builds a resumable execution bound to an existing session id.
|
|
4414
|
-
*
|
|
4415
|
-
* Used by `tela.agents.getSession()`. The returned execution can `.stream`,
|
|
4416
|
-
* `.result`, `.cancel`, or `.recover` — but not `.continue` (a new turn
|
|
4417
|
-
* needs the agent id).
|
|
4418
|
-
*/
|
|
4419
|
-
static fromSession(sessionId: string, client: BaseClient): AgentExecution;
|
|
4420
|
-
/**
|
|
4421
|
-
* The session id assigned by the server.
|
|
4422
|
-
*
|
|
4423
|
-
* @throws {ExecutionNotStartedError} If the execution has not started yet.
|
|
4424
|
-
*/
|
|
4425
|
-
get sessionId(): string;
|
|
4426
|
-
/**
|
|
4427
|
-
* The latest known session status.
|
|
4428
|
-
*
|
|
4429
|
-
* @throws {ExecutionNotStartedError} If no status has been observed yet.
|
|
4430
|
-
*/
|
|
4431
|
-
get status(): SessionStatus;
|
|
4432
|
-
private set status(value);
|
|
4433
|
-
/**
|
|
4434
|
-
* Starts (or continues) the session by POSTing to `/agent/:id/run`
|
|
4435
|
-
* (or `/agent/:id/test` in draft mode). Resets any in-flight stream/result
|
|
4436
|
-
* so the next read re-opens.
|
|
4437
|
-
*
|
|
4438
|
-
* @throws {AgentExecutionFailedError} If the server rejects the execution.
|
|
4439
|
-
*/
|
|
4440
|
-
start(params: AgentExecuteParams): Promise<this>;
|
|
4441
|
-
/**
|
|
4442
|
-
* Continues this session with another turn (same `sessionId`).
|
|
4443
|
-
*
|
|
4444
|
-
* @returns A promise-like handle for the new turn (`.result` / `.stream`).
|
|
4445
|
-
*/
|
|
4446
|
-
continue(params: AgentExecuteParams): AgentExecutionPromiseLike;
|
|
4447
|
-
/**
|
|
4448
|
-
* Recovers a failed/terminal session (`POST /agent/sessions/:id/recover`),
|
|
4449
|
-
* then re-opens the stream from the current cursor.
|
|
4450
|
-
*
|
|
4451
|
-
* @throws {ExecutionNotStartedError} If there is no session to recover.
|
|
4452
|
-
* @throws {AgentExecutionFailedError} If recovery is rejected.
|
|
4453
|
-
*/
|
|
4454
|
-
recover(): Promise<this>;
|
|
4455
|
-
/**
|
|
4456
|
-
* A live, typed stream of session events. Memoized: repeated access returns
|
|
4457
|
-
* the same generator. Updates `status` and the resume cursor as it goes.
|
|
4458
|
-
*
|
|
4459
|
-
* @throws {ExecutionNotStartedError} If the session has no id yet.
|
|
4460
|
-
*/
|
|
4461
|
-
get stream(): AsyncGenerator<SessionStreamEvent>;
|
|
4462
|
-
private openStream;
|
|
4463
|
-
private fail;
|
|
4464
|
-
/**
|
|
4465
|
-
* Resolves with the session's result payload, lazily consuming the stream.
|
|
4466
|
-
*
|
|
4467
|
-
* Memoized: repeated access returns the same promise. Resolves on the first
|
|
4468
|
-
* `result` event — for `completed` *or* `waiting_messages`. Inspect
|
|
4469
|
-
* `.status` to tell them apart, and `.continue()` from a paused turn.
|
|
4470
|
-
*
|
|
4471
|
-
* @throws {AgentExecutionFailedError} If the session fails or the stream
|
|
4472
|
-
* ends without producing a result.
|
|
4473
|
-
*/
|
|
4474
|
-
get result(): Promise<AgentSessionResult>;
|
|
4475
|
-
/**
|
|
4476
|
-
* Cancels the session: aborts the open stream immediately, then requests a
|
|
4477
|
-
* server-side cancel (`POST /agent/sessions/:id/cancel`).
|
|
4478
|
-
*/
|
|
4479
|
-
cancel(): Promise<void>;
|
|
4480
|
-
/**
|
|
4481
|
-
* Resolves the agent's input values into {@link AgentInputItem}s, uploading
|
|
4482
|
-
* any `TelaFile`s to the vault and passing strings through as text.
|
|
4483
|
-
*/
|
|
4484
|
-
private resolveInputs;
|
|
4485
|
-
/**
|
|
4486
|
-
* Resolves attachments to {@link AgentAttachment}s, uploading any `TelaFile`s.
|
|
4487
|
-
*/
|
|
4488
|
-
private resolveAttachments;
|
|
4326
|
+
interface UpdateAgentModelParams {
|
|
4327
|
+
/** The Tela agent id, resolved to the underlying repository. */
|
|
4328
|
+
agentId: string;
|
|
4329
|
+
/** The model to set, as accepted by the agent-sdk model contract. */
|
|
4330
|
+
model: UpdateAgentModelRequest['model'];
|
|
4331
|
+
/** Optional commit message recorded for the change. */
|
|
4332
|
+
commitMessage?: string;
|
|
4489
4333
|
}
|
|
4490
4334
|
|
|
4491
4335
|
/**
|
|
4492
|
-
*
|
|
4336
|
+
* Agents API resource (`tela.agents`).
|
|
4493
4337
|
*
|
|
4494
|
-
*
|
|
4495
|
-
*
|
|
4496
|
-
*
|
|
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:
|
|
4497
4343
|
*
|
|
4498
|
-
*
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
*
|
|
4503
|
-
*
|
|
4504
|
-
* @category Resources
|
|
4344
|
+
* - **`agentId` resolution** — a Tela agent is addressed by id; the wrapper
|
|
4345
|
+
* resolves it to the underlying `organizationName`/`repository` via the Tela
|
|
4346
|
+
* gateway `/agent` routes for the delegated agent-sdk calls.
|
|
4347
|
+
* - **vault integration** — `TelaFile` inputs are uploaded to the vault and
|
|
4348
|
+
* passed to the agent as `vault://` references.
|
|
4349
|
+
* - **auth** — Tela credentials are mapped onto an agent-sdk `AuthStrategy`.
|
|
4505
4350
|
*
|
|
4506
|
-
* @
|
|
4507
|
-
* ```typescript
|
|
4508
|
-
* const agent = await tela.agents.get('agent-id')
|
|
4509
|
-
* const result = await agent.execute({ prompt: 'Hello' }).result
|
|
4510
|
-
* ```
|
|
4351
|
+
* @module Resources
|
|
4511
4352
|
*/
|
|
4512
|
-
declare class Agent {
|
|
4513
|
-
private readonly _client;
|
|
4514
|
-
private readonly _record;
|
|
4515
|
-
constructor(client: BaseClient, record: AgentRecord);
|
|
4516
|
-
/** The agent id. */
|
|
4517
|
-
get id(): string;
|
|
4518
|
-
/** The agent's display title. */
|
|
4519
|
-
get title(): string;
|
|
4520
|
-
/** The organization that owns the agent's repository. */
|
|
4521
|
-
get organizationName(): string;
|
|
4522
|
-
/** The agent's repository name. */
|
|
4523
|
-
get repository(): string;
|
|
4524
|
-
/** The agent's declared input variables. */
|
|
4525
|
-
get inputSchema(): AgentInputVariable[];
|
|
4526
|
-
/** The published commit id, or `null` if the agent has never been published. */
|
|
4527
|
-
get publishedId(): string | null;
|
|
4528
|
-
/** Whether the agent supports multi-turn sessions. */
|
|
4529
|
-
get isMultiturn(): boolean;
|
|
4530
|
-
/** The full agent record as returned by the API. */
|
|
4531
|
-
get record(): AgentRecord;
|
|
4532
|
-
/**
|
|
4533
|
-
* Executes the agent. By default this runs the **published** version
|
|
4534
|
-
* (`POST /agent/:id/run`); pass `{ draft: true }` to run the current draft
|
|
4535
|
-
* (`POST /agent/:id/test`).
|
|
4536
|
-
*
|
|
4537
|
-
* Returns a promise-like handle: `await` it for the {@link AgentExecution},
|
|
4538
|
-
* read `.result` for the final payload, or iterate `.stream` for live events.
|
|
4539
|
-
*
|
|
4540
|
-
* @param params - Execution parameters (notably `prompt`, `inputs`, `draft`).
|
|
4541
|
-
*/
|
|
4542
|
-
execute(params?: AgentExecuteParams): AgentExecutionPromiseLike;
|
|
4543
|
-
}
|
|
4544
4353
|
|
|
4545
4354
|
/**
|
|
4546
|
-
* Agents
|
|
4547
|
-
*
|
|
4548
|
-
* Phase 1 covers the execution lifecycle: discovering agents, getting a handle,
|
|
4549
|
-
* running them by id, and reading/controlling session state. All calls go to
|
|
4550
|
-
* the Tela API's `/agent/*` routes (which proxy to the agent runtime), reusing
|
|
4551
|
-
* the SDK's existing baseURL and authentication. The routes are camelCase-native,
|
|
4552
|
-
* so every request opts out of case transformation.
|
|
4355
|
+
* Configuration for the {@link Agents} resource.
|
|
4553
4356
|
*
|
|
4554
|
-
*
|
|
4357
|
+
* Provide either a pre-built agent-sdk `client` (used for testing/advanced use),
|
|
4358
|
+
* or the pieces needed to build one (`agentBaseURL`, `authStrategy`, and an
|
|
4359
|
+
* optional `vaultURL` for reference resolution).
|
|
4555
4360
|
*/
|
|
4556
|
-
|
|
4361
|
+
type AgentsConfig = {
|
|
4362
|
+
client: AgentClient;
|
|
4363
|
+
} | {
|
|
4364
|
+
agentBaseURL: string;
|
|
4365
|
+
vaultURL?: string;
|
|
4366
|
+
authStrategy: AuthStrategy;
|
|
4367
|
+
};
|
|
4557
4368
|
/**
|
|
4558
4369
|
* Agents API resource.
|
|
4559
4370
|
*
|
|
@@ -4563,62 +4374,93 @@ declare class Agent {
|
|
|
4563
4374
|
* ```typescript
|
|
4564
4375
|
* const tela = new TelaSDK({ apiKey: '...' })
|
|
4565
4376
|
*
|
|
4566
|
-
*
|
|
4567
|
-
* const
|
|
4568
|
-
*
|
|
4377
|
+
* // Start a session by agent id (`POST /agent/:id/run`).
|
|
4378
|
+
* const { sessionId } = await tela.agents.run({
|
|
4379
|
+
* agentId: 'agent-123',
|
|
4380
|
+
* message: 'Summarize the latest tickets',
|
|
4381
|
+
* inputs: {
|
|
4382
|
+
* report: tela.createFile('https://example.com/q3.pdf'),
|
|
4383
|
+
* notes: { type: 'text', content: 'Focus on churn.' },
|
|
4384
|
+
* },
|
|
4385
|
+
* })
|
|
4569
4386
|
*
|
|
4570
|
-
* //
|
|
4571
|
-
* const
|
|
4572
|
-
*
|
|
4387
|
+
* // Stream / inspect / cancel by session id (agent-sdk pass-through).
|
|
4388
|
+
* for await (const event of await tela.agents.streamSession(sessionId))
|
|
4389
|
+
* console.log(event.kind)
|
|
4390
|
+
* const timeline = await tela.agents.fetchTimeline(sessionId)
|
|
4573
4391
|
* ```
|
|
4574
4392
|
*/
|
|
4575
4393
|
declare class Agents {
|
|
4394
|
+
/** The delegated agent-sdk client (the `/v4/*` execution backend). */
|
|
4576
4395
|
private readonly client;
|
|
4577
|
-
|
|
4396
|
+
/** The Tela gateway client (`/agent` discovery + vault upload). */
|
|
4397
|
+
private readonly gateway;
|
|
4398
|
+
/** Memoized `agentId` → `{ organizationName, repository }` resolutions. */
|
|
4399
|
+
private readonly resolved;
|
|
4578
4400
|
/**
|
|
4579
|
-
*
|
|
4401
|
+
* Streams a session's events. Pass-through to the agent-sdk client
|
|
4402
|
+
* (`GET /v4/sessions/:id`).
|
|
4580
4403
|
*/
|
|
4581
|
-
|
|
4404
|
+
readonly streamSession: AgentClient['streamSession'];
|
|
4582
4405
|
/**
|
|
4583
|
-
* Fetches
|
|
4406
|
+
* Fetches the session timeline summary. Pass-through to the agent-sdk client
|
|
4407
|
+
* (`GET /v4/sessions/:id/timeline`).
|
|
4584
4408
|
*/
|
|
4585
|
-
|
|
4409
|
+
readonly fetchTimeline: AgentClient['fetchTimeline'];
|
|
4586
4410
|
/**
|
|
4587
|
-
*
|
|
4588
|
-
*
|
|
4589
|
-
* Convenience shortcut equivalent to `(await get(id)).execute(params)` but
|
|
4590
|
-
* skipping the metadata fetch. Defaults to the published version; pass
|
|
4591
|
-
* `{ draft: true }` to run the draft.
|
|
4411
|
+
* Cancels a running session. Pass-through to the agent-sdk client
|
|
4412
|
+
* (`POST /v4/sessions/:id/cancel`).
|
|
4592
4413
|
*/
|
|
4593
|
-
|
|
4414
|
+
readonly cancelSession: AgentClient['cancelSession'];
|
|
4594
4415
|
/**
|
|
4595
|
-
*
|
|
4596
|
-
*
|
|
4597
|
-
* that was started elsewhere.
|
|
4416
|
+
* Resolves a `vault://` reference to bytes/stream/json. Pass-through to the
|
|
4417
|
+
* agent-sdk client.
|
|
4598
4418
|
*/
|
|
4599
|
-
|
|
4419
|
+
readonly resolveReference: AgentClient['resolveReference'];
|
|
4420
|
+
constructor(gateway: BaseClient, config: AgentsConfig);
|
|
4600
4421
|
/**
|
|
4601
|
-
*
|
|
4602
|
-
*
|
|
4422
|
+
* Lists the agents available in the workspace (optionally filtered by
|
|
4423
|
+
* project) via the Tela gateway (`GET /agent`).
|
|
4603
4424
|
*/
|
|
4604
|
-
|
|
4425
|
+
list(query?: ListAgentsQuery): Promise<AgentRecord[]>;
|
|
4605
4426
|
/**
|
|
4606
|
-
*
|
|
4427
|
+
* Fetches an agent record by id via the Tela gateway (`GET /agent/:id`).
|
|
4607
4428
|
*/
|
|
4608
|
-
|
|
4609
|
-
success?: boolean;
|
|
4610
|
-
}>;
|
|
4429
|
+
get(agentId: string): Promise<AgentRecord>;
|
|
4611
4430
|
/**
|
|
4612
|
-
*
|
|
4613
|
-
*
|
|
4431
|
+
* Starts (or continues) an agent session via the Tela gateway
|
|
4432
|
+
* (`POST /agent/:id/run`).
|
|
4433
|
+
*
|
|
4434
|
+
* - **New session**: pass `agentId` (+ `message`).
|
|
4435
|
+
* - **Continue**: pass `agentId` and the existing `sessionId`.
|
|
4436
|
+
*
|
|
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.
|
|
4614
4440
|
*/
|
|
4615
|
-
|
|
4441
|
+
run(params: RunAgentParams): Promise<RunAgentResponse>;
|
|
4616
4442
|
/**
|
|
4617
|
-
*
|
|
4443
|
+
* Updates an agent's model, delegating to the agent-sdk client
|
|
4444
|
+
* (`PUT /v4/agents/:repository/model`). The `agentId` is resolved to the
|
|
4445
|
+
* underlying repository first.
|
|
4618
4446
|
*/
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4447
|
+
updateAgentModel(params: UpdateAgentModelParams): Promise<UpdateAgentModelResponse>;
|
|
4448
|
+
/**
|
|
4449
|
+
* Resolves an `agentId` to its `organizationName`/`repository`, memoizing the
|
|
4450
|
+
* lookup. Backed by the Tela gateway `GET /agent/:id`.
|
|
4451
|
+
*/
|
|
4452
|
+
private resolveAgent;
|
|
4453
|
+
/**
|
|
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.
|
|
4462
|
+
*/
|
|
4463
|
+
private resolveEntry;
|
|
4622
4464
|
}
|
|
4623
4465
|
|
|
4624
4466
|
/**
|
|
@@ -4656,6 +4498,20 @@ interface TelaSDKOptions extends Omit<BaseClientOptions, 'baseURL'> {
|
|
|
4656
4498
|
* The base URL for the Tela API. Defaults to 'https://api.tela.com'.
|
|
4657
4499
|
*/
|
|
4658
4500
|
baseURL?: string;
|
|
4501
|
+
/**
|
|
4502
|
+
* Base URL for the agent execution backend (the agent-sdk `/v4/*` service)
|
|
4503
|
+
* that `tela.agents` delegates to. Defaults to `baseURL`.
|
|
4504
|
+
*
|
|
4505
|
+
* Set this to the reachable v4 service URL when it differs from the main Tela
|
|
4506
|
+
* API host — the agent-sdk client calls fixed `/v4/agents` and `/v4/sessions`
|
|
4507
|
+
* paths.
|
|
4508
|
+
*/
|
|
4509
|
+
agentBaseURL?: string;
|
|
4510
|
+
/**
|
|
4511
|
+
* Vault service URL used by `tela.agents.resolveReference`. Defaults to
|
|
4512
|
+
* `` `${baseURL}/_services/vault` ``.
|
|
4513
|
+
*/
|
|
4514
|
+
vaultURL?: string;
|
|
4659
4515
|
}
|
|
4660
4516
|
/**
|
|
4661
4517
|
* The main class for interacting with the Tela API.
|
|
@@ -4681,7 +4537,7 @@ declare class TelaSDK extends BaseClient {
|
|
|
4681
4537
|
/**
|
|
4682
4538
|
* Creates a new instance of the TelaSDK.
|
|
4683
4539
|
*/
|
|
4684
|
-
constructor({ baseURL, apiKey, jwt, dataToken, ...rest }: TelaSDKOptions);
|
|
4540
|
+
constructor({ baseURL, apiKey, jwt, dataToken, agentBaseURL, vaultURL, ...rest }: TelaSDKOptions);
|
|
4685
4541
|
get authToken(): string;
|
|
4686
4542
|
private validateAuth;
|
|
4687
4543
|
protected getAuthHeaders(): Record<string, string>;
|
|
@@ -4751,13 +4607,18 @@ declare class TelaSDK extends BaseClient {
|
|
|
4751
4607
|
*/
|
|
4752
4608
|
vault: Vault;
|
|
4753
4609
|
/**
|
|
4754
|
-
* Agents API resource
|
|
4755
|
-
* stream events,
|
|
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`).
|
|
4756
4613
|
*
|
|
4757
4614
|
* @example
|
|
4758
4615
|
* ```typescript
|
|
4759
|
-
* const
|
|
4760
|
-
*
|
|
4616
|
+
* const { sessionId } = await tela.agents.run({
|
|
4617
|
+
* agentId: 'agent-id',
|
|
4618
|
+
* message: 'Hello',
|
|
4619
|
+
* })
|
|
4620
|
+
* for await (const event of await tela.agents.streamSession(sessionId))
|
|
4621
|
+
* console.log(event.kind)
|
|
4761
4622
|
* ```
|
|
4762
4623
|
*/
|
|
4763
4624
|
agents: Agents;
|
|
@@ -4819,4 +4680,4 @@ declare class TelaSDK extends BaseClient {
|
|
|
4819
4680
|
*/
|
|
4820
4681
|
declare function createTelaClient(opts: TelaSDKOptions): TelaSDK;
|
|
4821
4682
|
|
|
4822
|
-
export { APIError,
|
|
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 };
|