@tangle-network/agent-interface 2.7.0 → 2.9.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 +7 -0
- package/dist/environment-runtime.d.ts +1 -1
- package/dist/environment-runtime.js +1 -9
- package/dist/execution-failure.d.ts +24 -0
- package/dist/execution-failure.js +20 -0
- package/dist/execution-types.d.ts +10 -0
- package/dist/execution-types.js +10 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -172,6 +172,13 @@ When caller environment values merge into a bridge or harness process, reject na
|
|
|
172
172
|
Use `isCredentialBearingProfileConfigName(name)` before retaining public config.
|
|
173
173
|
These checks do not apply to a replacement environment owned by caller code.
|
|
174
174
|
|
|
175
|
+
## Failed execution accounting
|
|
176
|
+
|
|
177
|
+
An adapter can reject with `AgentExecutionError` and retain observed usage and timing in its immutable `receipt`.
|
|
178
|
+
Absent fields remain unknown.
|
|
179
|
+
The receipt records a lower bound, not complete accounting or a successful outcome.
|
|
180
|
+
Hosts must preserve it when publishing a failed or cancelled execution.
|
|
181
|
+
|
|
175
182
|
## Exact process environments
|
|
176
183
|
|
|
177
184
|
Providers may expose the optional `exactProcess` capability for isolated, reproducible process execution.
|
|
@@ -5,7 +5,7 @@ import type { Sha256Digest } from "./agent-candidate.js";
|
|
|
5
5
|
import type { AgentProfileCapabilities, AgentProfileValidationResult } from "./agent-profile.js";
|
|
6
6
|
import type { InputPart } from "./parts.js";
|
|
7
7
|
import type { StreamEvent } from "./stream-events.js";
|
|
8
|
-
import type
|
|
8
|
+
import { type TokenUsage } from "./execution-types.js";
|
|
9
9
|
import { type InteractionAcknowledgement, type InteractionCapabilities, type InteractionResponseCommand, type RequestedInteractions } from "./interaction.js";
|
|
10
10
|
import { type ContextTransferReceipt, type ContextTransferRequest, type ContextTransferResult, type NativeContextBoundaryProof, type NativeContextContinuationRequest, type NativeContextContinuationTurn } from "./portable-context.js";
|
|
11
11
|
import { type AgentExactRunControlRef, type AgentRunCancellationAcknowledgement, type AgentRunCancellationRequest, type AgentRunControlRef } from "./runtime-control.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export { AgentRuntimeAttachmentsSchema } from "./runtime-attachments.js";
|
|
3
3
|
import { canonicalCandidateDigest, canonicalCandidateJson, } from "./agent-candidate-schema-common.js";
|
|
4
|
+
import { TokenUsageSchema } from "./execution-types.js";
|
|
4
5
|
import { InteractionCapabilitiesSchema, RequestedInteractionsSchema } from "./interaction.js";
|
|
5
6
|
import { ContextTransferReceiptSchema, ContextTransferRequestSchema, NativeContextBoundaryProofSchema, NativeContextContinuationAcknowledgementSchema, NativeContextContinuationRequestSchema, nativeContextContinuationAcknowledgementMatches } from "./portable-context.js";
|
|
6
7
|
import { AgentExactRunControlRefSchema, AgentRunControlRefSchema, CanonicalStreamEventSchema } from "./runtime-control.js";
|
|
@@ -31,15 +32,6 @@ export const AgentTurnInputSchema = z.strictObject({
|
|
|
31
32
|
signal: z.custom().optional(),
|
|
32
33
|
providerOptions: boundedJsonRecordSchema.optional(),
|
|
33
34
|
});
|
|
34
|
-
const TokenUsageSchema = z.strictObject({
|
|
35
|
-
inputTokens: z.number().int().nonnegative(),
|
|
36
|
-
outputTokens: z.number().int().nonnegative(),
|
|
37
|
-
totalTokens: z.number().int().nonnegative().optional(),
|
|
38
|
-
cacheReadInputTokens: z.number().int().nonnegative().optional(),
|
|
39
|
-
cacheCreationInputTokens: z.number().int().nonnegative().optional(),
|
|
40
|
-
reasoningTokens: z.number().int().nonnegative().optional(),
|
|
41
|
-
cost: z.number().finite().nonnegative().optional(),
|
|
42
|
-
});
|
|
43
35
|
const AgentEnvironmentEventSchema = z.strictObject({
|
|
44
36
|
type: boundedIdentifierSchema,
|
|
45
37
|
data: boundedEventContentRecordSchema,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AgentExecutionFailureReceiptSchema: z.ZodObject<{
|
|
3
|
+
tokenUsage: z.ZodOptional<z.ZodObject<{
|
|
4
|
+
inputTokens: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
outputTokens: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
totalTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
+
cacheReadInputTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
cacheCreationInputTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
reasoningTokens: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
10
|
+
cost: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
11
|
+
}, z.core.$strict>>;
|
|
12
|
+
timing: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
startedAt: z.ZodNumber;
|
|
14
|
+
completedAt: z.ZodNumber;
|
|
15
|
+
durationMs: z.ZodNumber;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
}, z.core.$strict>;
|
|
18
|
+
/** Observed accounting only; a failed execution may have additional unreported usage. */
|
|
19
|
+
export type AgentExecutionFailureReceipt = z.infer<typeof AgentExecutionFailureReceiptSchema>;
|
|
20
|
+
/** Retains observed resource use while preserving the adapter's rejection contract. */
|
|
21
|
+
export declare class AgentExecutionError extends Error {
|
|
22
|
+
readonly receipt: AgentExecutionFailureReceipt;
|
|
23
|
+
constructor(message: string, receipt: AgentExecutionFailureReceipt, options?: ErrorOptions);
|
|
24
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
3
|
+
import { TokenUsageSchema } from "./execution-types.js";
|
|
4
|
+
export const AgentExecutionFailureReceiptSchema = z.strictObject({
|
|
5
|
+
tokenUsage: TokenUsageSchema.partial().optional(),
|
|
6
|
+
timing: z.strictObject({
|
|
7
|
+
startedAt: z.number().finite().nonnegative(),
|
|
8
|
+
completedAt: z.number().finite().nonnegative(),
|
|
9
|
+
durationMs: z.number().finite().nonnegative(),
|
|
10
|
+
}).optional(),
|
|
11
|
+
});
|
|
12
|
+
/** Retains observed resource use while preserving the adapter's rejection contract. */
|
|
13
|
+
export class AgentExecutionError extends Error {
|
|
14
|
+
receipt;
|
|
15
|
+
constructor(message, receipt, options) {
|
|
16
|
+
super(message, options);
|
|
17
|
+
this.name = "AgentExecutionError";
|
|
18
|
+
this.receipt = deepFreeze(AgentExecutionFailureReceiptSchema.parse(receipt));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -3,6 +3,7 @@ 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
5
|
import type { RequestedInteractions } from "./interaction-permissions.js";
|
|
6
|
+
import { z } from "zod";
|
|
6
7
|
export type ToolInvocation = {
|
|
7
8
|
toolName: string;
|
|
8
9
|
input: unknown;
|
|
@@ -18,6 +19,15 @@ export type TokenUsage = {
|
|
|
18
19
|
reasoningTokens?: number;
|
|
19
20
|
cost?: number;
|
|
20
21
|
};
|
|
22
|
+
export declare const TokenUsageSchema: z.ZodObject<{
|
|
23
|
+
inputTokens: z.ZodNumber;
|
|
24
|
+
outputTokens: z.ZodNumber;
|
|
25
|
+
totalTokens: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
cacheReadInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
cacheCreationInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
reasoningTokens: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
}, z.core.$strict>;
|
|
21
31
|
export type ExecutionTiming = {
|
|
22
32
|
startedAt: number;
|
|
23
33
|
completedAt: number;
|
package/dist/execution-types.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const TokenUsageSchema = z.strictObject({
|
|
3
|
+
inputTokens: z.number().int().nonnegative(),
|
|
4
|
+
outputTokens: z.number().int().nonnegative(),
|
|
5
|
+
totalTokens: z.number().int().nonnegative().optional(),
|
|
6
|
+
cacheReadInputTokens: z.number().int().nonnegative().optional(),
|
|
7
|
+
cacheCreationInputTokens: z.number().int().nonnegative().optional(),
|
|
8
|
+
reasoningTokens: z.number().int().nonnegative().optional(),
|
|
9
|
+
cost: z.number().finite().nonnegative().optional(),
|
|
10
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from "./parts.js";
|
|
3
3
|
export * from "./stream-events.js";
|
|
4
4
|
export * from "./execution-types.js";
|
|
5
|
+
export * from "./execution-failure.js";
|
|
5
6
|
export * from "./backend-message.js";
|
|
6
7
|
export * from "./provider-config.js";
|
|
7
8
|
export * from "./host-services.js";
|
|
@@ -40,5 +41,5 @@ export * from "./harness-capabilities.js";
|
|
|
40
41
|
export * from "./profile-schema.js";
|
|
41
42
|
export * from "./profile-security.js";
|
|
42
43
|
export * from "./sandbox-size.js";
|
|
43
|
-
export { CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, CONTRACT_MAX_JSON_BYTES, boundedEventContentJsonSchema, boundedEventContentRecordSchema, boundedEventContentStringSchema, isBoundedEventContentJson, } from "./contract-limits.js";
|
|
44
|
+
export { CONTRACT_MAX_ARRAY_LENGTH, CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, CONTRACT_MAX_IDENTIFIER_LENGTH, CONTRACT_MAX_JSON_BYTES, CONTRACT_MAX_JSON_DEPTH, CONTRACT_MAX_JSON_NODES, CONTRACT_MAX_MAP_ENTRIES, CONTRACT_MAX_STRING_LENGTH, boundedEventContentJsonSchema, boundedEventContentRecordSchema, boundedEventContentStringSchema, isBoundedEventContentJson, } from "./contract-limits.js";
|
|
44
45
|
export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
export * from "./parts.js";
|
|
3
3
|
export * from "./stream-events.js";
|
|
4
4
|
export * from "./execution-types.js";
|
|
5
|
+
export * from "./execution-failure.js";
|
|
5
6
|
export * from "./backend-message.js";
|
|
6
7
|
export * from "./provider-config.js";
|
|
7
8
|
export * from "./host-services.js";
|
|
@@ -38,5 +39,9 @@ export * from "./harness-capabilities.js";
|
|
|
38
39
|
export * from "./profile-schema.js";
|
|
39
40
|
export * from "./profile-security.js";
|
|
40
41
|
export * from "./sandbox-size.js";
|
|
41
|
-
export {
|
|
42
|
+
export {
|
|
43
|
+
// Every bound a consumer may be asked to honour is public, so a package that WRITES values
|
|
44
|
+
// this contract validates can assert its own limits fit — the seam test in agent-provider-tangle
|
|
45
|
+
// does exactly that, after three bound mismatches shipped through it (agent-sdk#311, #312, #314).
|
|
46
|
+
CONTRACT_MAX_ARRAY_LENGTH, CONTRACT_MAX_CONFIDENTIAL_ATTESTATION_QUOTE_LENGTH, CONTRACT_MAX_IDENTIFIER_LENGTH, CONTRACT_MAX_JSON_BYTES, CONTRACT_MAX_JSON_DEPTH, CONTRACT_MAX_JSON_NODES, CONTRACT_MAX_MAP_ENTRIES, CONTRACT_MAX_STRING_LENGTH, boundedEventContentJsonSchema, boundedEventContentRecordSchema, boundedEventContentStringSchema, isBoundedEventContentJson, } from "./contract-limits.js";
|
|
42
47
|
export { AgentEnvironmentEgressPolicySchema } from "./environment-requests.js";
|