@constal/sdk 6.12.0 → 6.13.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 +27 -0
- package/package.json +1 -1
- package/publish/api.json +1 -1
- package/publish/index.d.ts +24 -2
package/README.md
CHANGED
|
@@ -232,6 +232,33 @@ for sleeping within the current Run.
|
|
|
232
232
|
See [Schedule Agent follow-ups](https://constal.ai/docs/agents/schedules) for replay,
|
|
233
233
|
delivery, authority, and cancellation semantics.
|
|
234
234
|
|
|
235
|
+
## Calls with a connection
|
|
236
|
+
|
|
237
|
+
`ctx.fetch` makes an https request with one of the Run's owner's connections,
|
|
238
|
+
named by its binding key. The Agent never holds the Credential's value:
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
const response = await ctx.fetch("https://api.example.com/v1/tickets", {
|
|
242
|
+
method: "POST",
|
|
243
|
+
headers: { "content-type": "application/json" },
|
|
244
|
+
body: JSON.stringify({ title: "Fix the failing build" }),
|
|
245
|
+
}, { connection: "tickets" });
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
`connection` is required. The platform finds the enabled Credential binding of
|
|
249
|
+
that key in the Agent's tenant and namespace owned by the Run's customer, or by
|
|
250
|
+
its tenant when the Run has none, and matches the request against the
|
|
251
|
+
Credential's `destinations`: https only, the most specific destination wins, and
|
|
252
|
+
a request none matches is refused. It decides the use with `credential:use`
|
|
253
|
+
Policy (`origin.kind` is `agent`), sets the header the destination's `present`
|
|
254
|
+
names in place of any the Agent sent, never follows a redirect, and redacts the
|
|
255
|
+
value from the answer's headers and body.
|
|
256
|
+
|
|
257
|
+
The answer, its body whole, is journaled at the call's position: a replay gets
|
|
258
|
+
the same Response without calling again, and a refused call throws the same
|
|
259
|
+
error, with the platform's `status`. Inside a Tool, GET, HEAD and OPTIONS are
|
|
260
|
+
read-only, PUT and DELETE idempotent, and any other method non-idempotent.
|
|
261
|
+
|
|
235
262
|
## Model evaluation
|
|
236
263
|
|
|
237
264
|
`ctx.evaluate` judges one state against typed questions through an evaluation
|
package/package.json
CHANGED
package/publish/api.json
CHANGED
package/publish/index.d.ts
CHANGED
|
@@ -3456,8 +3456,12 @@ interface ReduceFact {
|
|
|
3456
3456
|
stage: StageInfo;
|
|
3457
3457
|
}
|
|
3458
3458
|
type ScopeJournalKind = "turn" | "tool" | "step";
|
|
3459
|
-
/**
|
|
3460
|
-
|
|
3459
|
+
/**
|
|
3460
|
+
* `journal`: what the Agent read of `ctx.journal.paged` at that point, recorded as its `value` so a replay reads the same.
|
|
3461
|
+
* `fetch`: a ctx.fetch's answer, which its Session journals (its `value`: status, status text, headers, base64 body), or its
|
|
3462
|
+
* refusal (`error`).
|
|
3463
|
+
*/
|
|
3464
|
+
type LocalJournalKind = "clock" | "random" | "score" | "commit" | "await" | "spawn" | "map" | "reduce" | "view" | "page" | "truncate" | "cancel" | "capability" | "schedule" | "journal" | "fetch";
|
|
3461
3465
|
type JournalKind = ScopeJournalKind | LocalJournalKind | "invoke" | "send";
|
|
3462
3466
|
/** Stable identity available to Agent code. Platform execution and deployment
|
|
3463
3467
|
* metadata intentionally remain outside the public Agent context. */
|
|
@@ -3603,6 +3607,24 @@ interface Ctx {
|
|
|
3603
3607
|
sandboxPool(resource: CRN): SandboxPool;
|
|
3604
3608
|
invoke<T>(resource: CRN, op: string, args: unknown, opts?: InvokeOpts): Promise<T>;
|
|
3605
3609
|
invokeAsync<T>(resource: CRN, op: string, args: unknown, opts?: InvokeOpts): InvocationHandle<T>;
|
|
3610
|
+
/**
|
|
3611
|
+
* An https request with one of the Run's owner's connections (docs/sandbox-egress-connections.md section 6). `connection`
|
|
3612
|
+
* is a binding key in the Agent's tenant and namespace: the enabled Credential binding of that key its owner holds, its
|
|
3613
|
+
* customer's when the Run has one, else its tenant's. There is no fetch without one, and nothing in the Run ever holds
|
|
3614
|
+
* the Credential's value. The platform matches the request against the Credential's `destinations` (https only; the most
|
|
3615
|
+
* specific wins; a request none matches is refused, as a connection was named), decides each use with `credential:use`
|
|
3616
|
+
* Policy (`origin.kind` `agent`, `egress.destination`, `egress.position`), presents the value as the matched destination's
|
|
3617
|
+
* `present` says, in place of any header of that name the Agent sent, forwards the request without following a redirect
|
|
3618
|
+
* (a 3xx is the answer), and redacts the value from the answer's headers and body.
|
|
3619
|
+
*
|
|
3620
|
+
* The answer (status, headers and whole body) is journaled at the call's position, so a replay answers it from the journal
|
|
3621
|
+
* without calling again; a refusal is journaled too, and throws the same Error with the platform's `status` at replay. A
|
|
3622
|
+
* request's method is its effect under a Tool's ceiling: GET, HEAD and OPTIONS read-only, PUT and DELETE idempotent, any
|
|
3623
|
+
* other non-idempotent.
|
|
3624
|
+
*/
|
|
3625
|
+
fetch(input: string | Request, init: RequestInit | undefined, opts: {
|
|
3626
|
+
connection: string;
|
|
3627
|
+
}): Promise<Response>;
|
|
3606
3628
|
request(policy: PolicyCRN, grant: CapabilityGrant): Handle<CapabilityRef>;
|
|
3607
3629
|
analytics: AnalyticsClient;
|
|
3608
3630
|
/**
|