@tangle-network/agent-interface 0.51.0 → 0.53.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 +4 -0
- package/dist/environment-runtime.d.ts +8 -1
- package/dist/environment-runtime.js +2 -1
- package/dist/environment-terminal.d.ts +14 -2
- package/dist/environment-terminal.js +12 -0
- package/dist/execution-types.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction-permissions.d.ts +12 -0
- package/dist/interaction-permissions.js +6 -0
- package/dist/runtime-control.js +7 -1
- package/dist/stream-events.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ shapes; higher-level packages import from here rather than redefining them.
|
|
|
9
9
|
|
|
10
10
|
`AgentRunControlRef` identifies a retained run without depending on a live JavaScript object and may carry the provider's admission digest so reconstruction can reject changed-input reuse.
|
|
11
11
|
`RuntimeEventEnvelope` adds stable run, event, sequence, cursor, and timestamp fields around the existing `StreamEvent` union, and its runtime schema validates every canonical event variant.
|
|
12
|
+
The canonical `cancelled` status identifies caller cancellation and remains distinct from `failed`.
|
|
12
13
|
Providers advertise `retainedControl` only when exact run, result, event, cancellation, replay, detach, turn, and session identity are all implemented together.
|
|
13
14
|
`AgentEnvironment.metadata` is the detached snapshot returned by create or get, so recovery can check persisted annotations without listing environments.
|
|
14
15
|
Metadata can include caller-authored values and does not prove authorization or authorship.
|
|
@@ -16,6 +17,9 @@ Metadata can include caller-authored values and does not prove authorization or
|
|
|
16
17
|
Its acknowledgement repeats the operation, digest, and run coordinates and distinguishes a known cancellation effect from conflict or unknown state.
|
|
17
18
|
|
|
18
19
|
An environment advertises `interactions` only when it can originate and answer typed requests.
|
|
20
|
+
`RequestedInteractions` defines the strict per-turn posture for `permission`, `question`, and `plan` requests.
|
|
21
|
+
`AgentTurnInput.interactions` and `AgentExecutionInput.interactions` carry that posture through shared execution boundaries.
|
|
22
|
+
An omitted posture leaves provider defaults unchanged, while an empty object enables no interaction kind for that turn.
|
|
19
23
|
`AgentEnvironmentCapabilitiesSchema` strictly validates the complete capability document at runtime, including all-or-nothing durable branching declarations.
|
|
20
24
|
Optional provider methods must be absent when their capability is false so clients cannot expose an action the provider has denied.
|
|
21
25
|
The capability names supported request kinds, answer field types, response scopes, secret answers, concurrency, replay, and response idempotency.
|
|
@@ -3,7 +3,7 @@ import type { AgentProfileCapabilities, AgentProfileValidationResult } from "./a
|
|
|
3
3
|
import type { InputPart } from "./parts.js";
|
|
4
4
|
import type { StreamEvent } from "./stream-events.js";
|
|
5
5
|
import type { TokenUsage } from "./execution-types.js";
|
|
6
|
-
import { type InteractionAcknowledgement, type InteractionCapabilities, type InteractionResponseCommand } from "./interaction.js";
|
|
6
|
+
import { type InteractionAcknowledgement, type InteractionCapabilities, type InteractionResponseCommand, type RequestedInteractions } from "./interaction.js";
|
|
7
7
|
import { type ContextTransferReceipt, type ContextTransferRequest, type NativeContextBoundaryProof, type NativeContextContinuationRequest, type NativeContextContinuationTurn } from "./portable-context.js";
|
|
8
8
|
import { type AgentRunCancellationAcknowledgement, type AgentRunCancellationRequest, type AgentRunControlRef } from "./runtime-control.js";
|
|
9
9
|
import type { AgentWorkspaceBranching } from "./workspace-branching.js";
|
|
@@ -28,6 +28,8 @@ export interface AgentTurnInput {
|
|
|
28
28
|
/** Verified same-session continuation; never carries duplicate history. */
|
|
29
29
|
nativeContinuation?: NativeContextContinuationRequest;
|
|
30
30
|
context?: Record<string, unknown>;
|
|
31
|
+
/** Interaction kinds the provider may originate for this turn. */
|
|
32
|
+
interactions?: RequestedInteractions;
|
|
31
33
|
signal?: AbortSignal;
|
|
32
34
|
providerOptions?: Record<string, unknown>;
|
|
33
35
|
}
|
|
@@ -235,6 +237,11 @@ export declare const AgentTurnInputSchema: z.ZodObject<{
|
|
|
235
237
|
}, z.core.$strict>;
|
|
236
238
|
}, z.core.$strict>>;
|
|
237
239
|
context: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
240
|
+
interactions: z.ZodOptional<z.ZodObject<{
|
|
241
|
+
permission: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
question: z.ZodOptional<z.ZodBoolean>;
|
|
243
|
+
plan: z.ZodOptional<z.ZodBoolean>;
|
|
244
|
+
}, z.core.$strict>>;
|
|
238
245
|
signal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
|
|
239
246
|
providerOptions: z.ZodOptional<z.ZodCustom<Record<string, unknown>, Record<string, unknown>>>;
|
|
240
247
|
}, z.core.$strict>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { InteractionCapabilitiesSchema } from "./interaction.js";
|
|
2
|
+
import { InteractionCapabilitiesSchema, RequestedInteractionsSchema } from "./interaction.js";
|
|
3
3
|
import { ContextTransferReceiptSchema, ContextTransferRequestSchema, NativeContextContinuationAcknowledgementSchema, NativeContextContinuationRequestSchema, nativeContextContinuationAcknowledgementMatches } from "./portable-context.js";
|
|
4
4
|
import { AgentExactRunControlRefSchema, AgentRunControlRefSchema, CanonicalStreamEventSchema } from "./runtime-control.js";
|
|
5
5
|
import { AgentProfileCapabilitiesSchema } from "./environment-profile-capabilities.js";
|
|
@@ -19,6 +19,7 @@ export const AgentTurnInputSchema = z.strictObject({
|
|
|
19
19
|
contextTransfer: ContextTransferRequestSchema.optional(),
|
|
20
20
|
nativeContinuation: NativeContextContinuationRequestSchema.optional(),
|
|
21
21
|
context: boundedJsonRecordSchema.optional(),
|
|
22
|
+
interactions: RequestedInteractionsSchema.optional(),
|
|
22
23
|
signal: z.custom().optional(),
|
|
23
24
|
providerOptions: boundedJsonRecordSchema.optional(),
|
|
24
25
|
});
|
|
@@ -147,11 +147,23 @@ export declare function terminalSessionUsable(ref: TerminalSessionRef, nowIso: s
|
|
|
147
147
|
/** Bind an attach result to the parent execution and terminal it targeted. */
|
|
148
148
|
export declare function terminalAttachResultMatchesRequest(request: TerminalAttachRequest, result: TerminalAttachResult): boolean;
|
|
149
149
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
150
|
+
* The replay cursors a terminal handle can serve.
|
|
151
|
+
*
|
|
152
|
+
* `earliest` is the oldest cursor `events` accepts and `latest` is the newest
|
|
153
|
+
* frame the handle holds. A handle retains a bounded number of frames, so a
|
|
154
|
+
* consumer that holds no cursor, or holds one the handle dropped, reads this
|
|
155
|
+
* window to resume from a cursor that still exists.
|
|
152
156
|
*/
|
|
157
|
+
export declare const TerminalReplayWindowSchema: z.ZodObject<{
|
|
158
|
+
earliest: z.ZodNumber;
|
|
159
|
+
latest: z.ZodNumber;
|
|
160
|
+
}, z.core.$strict>;
|
|
161
|
+
export type TerminalReplayWindow = z.infer<typeof TerminalReplayWindowSchema>;
|
|
162
|
+
/** Live handle for one interactive terminal. */
|
|
153
163
|
export interface AgentTerminalSession {
|
|
154
164
|
readonly ref: TerminalSessionRef;
|
|
165
|
+
/** Cursors this handle can serve, so an evicted cursor is recoverable. */
|
|
166
|
+
readonly cursors: TerminalReplayWindow;
|
|
155
167
|
input(input: TerminalInput, options?: {
|
|
156
168
|
signal?: AbortSignal;
|
|
157
169
|
}): Promise<void>;
|
|
@@ -160,3 +160,15 @@ export function terminalAttachResultMatchesRequest(request, result) {
|
|
|
160
160
|
}
|
|
161
161
|
return true;
|
|
162
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* The replay cursors a terminal handle can serve.
|
|
165
|
+
*
|
|
166
|
+
* `earliest` is the oldest cursor `events` accepts and `latest` is the newest
|
|
167
|
+
* frame the handle holds. A handle retains a bounded number of frames, so a
|
|
168
|
+
* consumer that holds no cursor, or holds one the handle dropped, reads this
|
|
169
|
+
* window to resume from a cursor that still exists.
|
|
170
|
+
*/
|
|
171
|
+
export const TerminalReplayWindowSchema = z.strictObject({
|
|
172
|
+
earliest: z.number().int().nonnegative(),
|
|
173
|
+
latest: z.number().int().nonnegative(),
|
|
174
|
+
});
|
|
@@ -2,6 +2,7 @@ import type { AgentExecutionOutcome, PlanContinuation } from "./plan.js";
|
|
|
2
2
|
import type { InputPart } from "./parts.js";
|
|
3
3
|
import type { ProviderConfig } from "./provider-config.js";
|
|
4
4
|
import type { InteractionExecutionBinding } from "./interaction-envelope.js";
|
|
5
|
+
import type { RequestedInteractions } from "./interaction-permissions.js";
|
|
5
6
|
export type ToolInvocation = {
|
|
6
7
|
toolName: string;
|
|
7
8
|
input: unknown;
|
|
@@ -31,6 +32,8 @@ export type AgentExecutionInput = {
|
|
|
31
32
|
sessionId?: string;
|
|
32
33
|
/** Exact run coordinates required when this turn can emit interactions. */
|
|
33
34
|
interactionBinding?: InteractionExecutionBinding;
|
|
35
|
+
/** Interaction kinds the provider may originate for this turn. */
|
|
36
|
+
interactions?: RequestedInteractions;
|
|
34
37
|
workspaceRoot?: string;
|
|
35
38
|
abortSignal?: AbortSignal;
|
|
36
39
|
headers?: Record<string, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export * from "./host-services.js";
|
|
|
8
8
|
export * from "./mcp.js";
|
|
9
9
|
export * from "./provider-adapter.js";
|
|
10
10
|
export type * from "./environment-provider.js";
|
|
11
|
-
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
11
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
12
12
|
export * from "./plan.js";
|
|
13
13
|
export * from "./runtime-control.js";
|
|
14
14
|
export * from "./portable-context.js";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export * from "./provider-config.js";
|
|
|
7
7
|
export * from "./host-services.js";
|
|
8
8
|
export * from "./mcp.js";
|
|
9
9
|
export * from "./provider-adapter.js";
|
|
10
|
-
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
10
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, AccountUsageSchema, AgentEnvironmentObservationSchema, AgentEnvironmentStatusSchema, ComputeBillingSchema, EnvironmentLifecycleSchema, ModelUsageSchema, ObservationProvenanceSchema, ObservationStateSchema, PlacementDescriptorSchema, ProviderIdentitySchema, ResourceProfileSchema, ResourceUseSampleSchema, SafeEndpointSchema, agentEnvironmentObservationIdentityMatches, assertObservationCredentialFree, observationContainsCredential, observationOf, TerminalAttachRequestSchema, TerminalAttachResultSchema, TerminalDetachAckSchema, TerminalInputSchema, TerminalOutputEventSchema, TerminalReplayWindowSchema, TerminalResizeSchema, TerminalSessionRefSchema, terminalAttachResultMatchesRequest, terminalSessionUsable, } from "./environment-provider.js";
|
|
11
11
|
export * from "./plan.js";
|
|
12
12
|
export * from "./runtime-control.js";
|
|
13
13
|
export * from "./portable-context.js";
|
|
@@ -9,6 +9,18 @@ export declare const InteractionKind: {
|
|
|
9
9
|
readonly Plan: "plan";
|
|
10
10
|
};
|
|
11
11
|
export type WellKnownInteractionKind = (typeof InteractionKind)[keyof typeof InteractionKind];
|
|
12
|
+
/** Interaction kinds a provider may originate for one turn. */
|
|
13
|
+
export type RequestedInteractions = {
|
|
14
|
+
[InteractionKind.Permission]?: boolean;
|
|
15
|
+
[InteractionKind.Question]?: boolean;
|
|
16
|
+
[InteractionKind.Plan]?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** Strict per-turn interaction posture; an empty object enables no kinds. */
|
|
19
|
+
export declare const RequestedInteractionsSchema: z.ZodObject<{
|
|
20
|
+
permission: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
question: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
plan: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
}, z.core.$strict>;
|
|
12
24
|
/** Field name carrying the grant on a `permission` interaction's response. */
|
|
13
25
|
export declare const PERMISSION_GRANT_FIELD = "grant";
|
|
14
26
|
/** Optional free-text field carrying the user's reason on a `permission` response. */
|
|
@@ -10,6 +10,12 @@ export const InteractionKind = {
|
|
|
10
10
|
/** Agent shares a plan/todo list for review/approval. */
|
|
11
11
|
Plan: "plan",
|
|
12
12
|
};
|
|
13
|
+
/** Strict per-turn interaction posture; an empty object enables no kinds. */
|
|
14
|
+
export const RequestedInteractionsSchema = z.strictObject({
|
|
15
|
+
[InteractionKind.Permission]: z.boolean().optional(),
|
|
16
|
+
[InteractionKind.Question]: z.boolean().optional(),
|
|
17
|
+
[InteractionKind.Plan]: z.boolean().optional(),
|
|
18
|
+
});
|
|
13
19
|
/** Field name carrying the grant on a `permission` interaction's response. */
|
|
14
20
|
export const PERMISSION_GRANT_FIELD = "grant";
|
|
15
21
|
/** Optional free-text field carrying the user's reason on a `permission` response. */
|
package/dist/runtime-control.js
CHANGED
|
@@ -291,7 +291,13 @@ export const CanonicalStreamEventSchema = z.discriminatedUnion("type", [
|
|
|
291
291
|
}),
|
|
292
292
|
z.strictObject({
|
|
293
293
|
type: z.literal("status"),
|
|
294
|
-
status: z.enum([
|
|
294
|
+
status: z.enum([
|
|
295
|
+
"started",
|
|
296
|
+
"processing",
|
|
297
|
+
"completed",
|
|
298
|
+
"failed",
|
|
299
|
+
"cancelled",
|
|
300
|
+
]),
|
|
295
301
|
detail: boundedStringSchema.optional(),
|
|
296
302
|
}),
|
|
297
303
|
z.strictObject({
|
package/dist/stream-events.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type MessagePartUpdatedEvent = {
|
|
|
6
6
|
part: Part;
|
|
7
7
|
delta?: string;
|
|
8
8
|
};
|
|
9
|
+
export type StreamStatus = "started" | "processing" | "completed" | "failed" | "cancelled";
|
|
9
10
|
export type StreamEvent = MessagePartUpdatedEvent | {
|
|
10
11
|
type: "tool-heartbeat";
|
|
11
12
|
toolName: string;
|
|
@@ -24,7 +25,7 @@ export type StreamEvent = MessagePartUpdatedEvent | {
|
|
|
24
25
|
elapsedMs?: number;
|
|
25
26
|
} | {
|
|
26
27
|
type: "status";
|
|
27
|
-
status:
|
|
28
|
+
status: StreamStatus;
|
|
28
29
|
detail?: string;
|
|
29
30
|
} | {
|
|
30
31
|
type: "warning";
|