@meistrari/tela-sdk-js 2.13.0 → 2.13.1
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 +59 -44
- package/dist/index.cjs +259 -586
- package/dist/index.d.cts +176 -368
- package/dist/index.d.mts +176 -368
- package/dist/index.d.ts +176 -368
- package/dist/index.mjs +260 -586
- 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` 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.
|
|
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:
|
|
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 — resolved to org/repo under the hood.
|
|
736
|
+
const started = await tela.agents.executeAgent({
|
|
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
|
+
`executeAgent` returns the agent-sdk `ExecuteAgentResponse` (`{ success: true, sessionId } | { success: false, error }`). 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,66 @@ 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
764
|
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
const execution = await agent.execute({ prompt: 'Refactor the auth module' })
|
|
762
|
-
execution.on('status', status => console.log(status))
|
|
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** — pass file inputs as `TelaFile`s (uploaded to the vault automatically) or ready `vault://` references:
|
|
772
771
|
|
|
773
772
|
```typescript
|
|
774
|
-
await
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
})
|
|
773
|
+
await tela.agents.executeAgent({
|
|
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
|
+
],
|
|
780
|
+
})
|
|
782
781
|
```
|
|
783
782
|
|
|
784
|
-
**Multi-turn** — continue
|
|
783
|
+
**Multi-turn / recover** — continue or recover an existing session by `sessionId` (omit `agentId`):
|
|
785
784
|
|
|
786
785
|
```typescript
|
|
787
|
-
|
|
788
|
-
await
|
|
789
|
-
await execution.continue({ prompt: 'Now implement step 1' }).result
|
|
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
|
|
790
788
|
```
|
|
791
789
|
|
|
792
|
-
**
|
|
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.
|
|
793
791
|
|
|
794
792
|
```typescript
|
|
795
|
-
|
|
796
|
-
|
|
793
|
+
import { verifyWebhookSignature } from '@meistrari/tela-sdk-js'
|
|
794
|
+
import type { SessionWebhookEventPayload } from '@meistrari/tela-sdk-js'
|
|
795
|
+
|
|
796
|
+
await tela.agents.executeAgent({
|
|
797
|
+
agentId,
|
|
798
|
+
message: 'Audit the README for typos',
|
|
799
|
+
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
|
+
}],
|
|
804
|
+
})
|
|
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
|
|
797
815
|
```
|
|
798
816
|
|
|
799
|
-
**
|
|
817
|
+
**Model updates** — set an agent's model by id:
|
|
800
818
|
|
|
801
819
|
```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')
|
|
820
|
+
await tela.agents.updateAgentModel({ agentId, model: 'claude-opus-4-8', commitMessage: 'bump model' })
|
|
806
821
|
```
|
|
807
822
|
|
|
808
|
-
|
|
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.
|
|
809
824
|
|
|
810
825
|
## Migration Guide from v1.x to v2
|
|
811
826
|
|