@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/README.md
CHANGED
|
@@ -718,27 +718,35 @@ This is particularly useful when reading task input files: `tela.tasks.getInputF
|
|
|
718
718
|
|
|
719
719
|
### Agents API
|
|
720
720
|
|
|
721
|
-
|
|
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
|
+
|
|
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
|
+
>
|
|
725
|
+
> ```typescript
|
|
726
|
+
> const tela = new TelaSDK({ apiKey: 'your-api-key', agentBaseURL: 'https://agents.example.com' })
|
|
727
|
+
> ```
|
|
722
728
|
|
|
723
729
|
```typescript
|
|
724
730
|
const tela = new TelaSDK({ apiKey: 'your-api-key' })
|
|
725
731
|
|
|
726
|
-
// Discover agents
|
|
732
|
+
// Discover agents (Tela gateway)
|
|
727
733
|
const agents = await tela.agents.list()
|
|
728
|
-
const agent = await tela.agents.get(agents[0].id)
|
|
729
734
|
|
|
730
|
-
//
|
|
731
|
-
const
|
|
732
|
-
|
|
733
|
-
|
|
735
|
+
// Start a session by agentId.
|
|
736
|
+
const started = await tela.agents.run({
|
|
737
|
+
agentId: agents[0].id,
|
|
738
|
+
message: 'Summarize the latest tickets',
|
|
739
|
+
})
|
|
740
|
+
if (!started.success)
|
|
741
|
+
throw new Error(started.error)
|
|
734
742
|
|
|
735
|
-
|
|
743
|
+
const { sessionId } = started
|
|
736
744
|
```
|
|
737
745
|
|
|
738
|
-
`
|
|
746
|
+
`run` returns `{ success, sessionId }` — execution is async, so stream the session's events by id:
|
|
739
747
|
|
|
740
748
|
```typescript
|
|
741
|
-
for await (const event of
|
|
749
|
+
for await (const event of await tela.agents.streamSession(sessionId)) {
|
|
742
750
|
switch (event.kind) {
|
|
743
751
|
case 'status':
|
|
744
752
|
console.log('status:', event.status)
|
|
@@ -753,59 +761,74 @@ for await (const event of agent.execute({ prompt: 'Investigate the failing build
|
|
|
753
761
|
throw new Error(event.error)
|
|
754
762
|
}
|
|
755
763
|
}
|
|
756
|
-
```
|
|
757
|
-
|
|
758
|
-
Or subscribe to lifecycle events and read state:
|
|
759
764
|
|
|
760
|
-
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
execution.on('step', steps => console.log(steps))
|
|
764
|
-
execution.on('result', result => console.log(result))
|
|
765
|
-
execution.on('error', err => console.error(err))
|
|
766
|
-
|
|
767
|
-
await execution.result
|
|
768
|
-
console.log(execution.sessionId, execution.status)
|
|
765
|
+
// Timeline metrics (duration, token/cost) and cancellation, by session id:
|
|
766
|
+
const timeline = await tela.agents.fetchTimeline(sessionId)
|
|
767
|
+
await tela.agents.cancelSession(sessionId)
|
|
769
768
|
```
|
|
770
769
|
|
|
771
|
-
**Inputs
|
|
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.
|
|
772
771
|
|
|
773
772
|
```typescript
|
|
774
|
-
await
|
|
775
|
-
|
|
773
|
+
await tela.agents.run({
|
|
774
|
+
agentId,
|
|
775
|
+
message: 'Review this contract against the references',
|
|
776
776
|
inputs: {
|
|
777
|
-
|
|
778
|
-
|
|
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.' },
|
|
779
785
|
},
|
|
780
|
-
|
|
781
|
-
})
|
|
786
|
+
environmentVariables: { LOCALE: 'en-US' },
|
|
787
|
+
})
|
|
782
788
|
```
|
|
783
789
|
|
|
784
|
-
**Multi-turn** — continue
|
|
790
|
+
**Multi-turn** — continue an existing session by passing its `sessionId` alongside the `agentId`:
|
|
785
791
|
|
|
786
792
|
```typescript
|
|
787
|
-
|
|
788
|
-
await execution.result
|
|
789
|
-
await execution.continue({ prompt: 'Now implement step 1' }).result
|
|
793
|
+
await tela.agents.run({ agentId, sessionId, message: 'Now implement step 1' })
|
|
790
794
|
```
|
|
791
795
|
|
|
792
|
-
**
|
|
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.
|
|
793
797
|
|
|
794
798
|
```typescript
|
|
795
|
-
await
|
|
796
|
-
|
|
799
|
+
await tela.agents.run({
|
|
800
|
+
agentId,
|
|
801
|
+
message: 'Summarize the latest tickets',
|
|
802
|
+
webhooks: [{
|
|
803
|
+
url: 'https://example.com/hooks/agent-session',
|
|
804
|
+
events: ['session.completed', 'session.failed', 'session.cancelled'],
|
|
805
|
+
secret: 'whsec_a-long-random-string',
|
|
806
|
+
}],
|
|
807
|
+
})
|
|
797
808
|
```
|
|
798
809
|
|
|
799
|
-
|
|
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
|
+
|
|
812
|
+
**Model updates** — set an agent's model by id:
|
|
800
813
|
|
|
801
814
|
```typescript
|
|
802
|
-
|
|
803
|
-
const timeline = await tela.agents.getTimeline('session-uuid') // duration + token/cost metrics
|
|
804
|
-
await tela.agents.cancel('session-uuid')
|
|
805
|
-
await tela.agents.endSession('session-uuid')
|
|
815
|
+
await tela.agents.updateAgentModel({ agentId, model: 'claude-opus-4-8', commitMessage: 'bump model' })
|
|
806
816
|
```
|
|
807
817
|
|
|
808
|
-
|
|
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
|
+
```
|
|
809
832
|
|
|
810
833
|
## Migration Guide from v1.x to v2
|
|
811
834
|
|