@tangle-network/agent-interface 0.26.1 → 0.27.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/dist/index.d.ts CHANGED
@@ -5,7 +5,9 @@
5
5
  * This package defines the contract between the sidecar and provider implementations.
6
6
  */
7
7
  import type { InteractionRequest, InteractionResponse } from "./interaction.js";
8
+ import type { AgentExecutionOutcome, DurablePlan, PlanContinuation, SdkPlanHost } from "./plan.js";
8
9
  export type * from "./environment-provider.js";
10
+ export * from "./plan.js";
9
11
  export type BackendCapabilities = {
10
12
  streaming: boolean;
11
13
  toolUse: boolean;
@@ -218,6 +220,11 @@ export type StreamEvent = MessagePartUpdatedEvent | {
218
220
  type: "interaction.cancel";
219
221
  id: string;
220
222
  reason?: string;
223
+ }
224
+ /** A durable plan was committed. This event is observational, not a live ask. */
225
+ | {
226
+ type: "plan.submitted";
227
+ plan: DurablePlan;
221
228
  };
222
229
  export type ToolInvocation = {
223
230
  toolName: string;
@@ -267,8 +274,11 @@ export type AgentExecutionInput = {
267
274
  * client-initiated retries of the same intent.
268
275
  */
269
276
  turnId?: string;
277
+ /** Server-owned continuation of a previously committed plan decision. */
278
+ planContinuation?: PlanContinuation;
270
279
  };
271
280
  export type AgentExecutionResult = {
281
+ outcome: AgentExecutionOutcome;
272
282
  text: string;
273
283
  toolInvocations: ToolInvocation[];
274
284
  reasoning?: string[];
@@ -491,6 +501,7 @@ export interface SdkTraceContext {
491
501
  export type SdkHostServices = {
492
502
  memoryHost: SdkMemoryHost;
493
503
  toolHost: SdkToolHost;
504
+ planHost: SdkPlanHost;
494
505
  recorder: SdkRecorder;
495
506
  providerConfig: ProviderConfig;
496
507
  traceContext?: SdkTraceContext;
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * Shared types and interfaces for SDK provider adapters.
5
5
  * This package defines the contract between the sidecar and provider implementations.
6
6
  */
7
+ export * from "./plan.js";
7
8
  /** Helper to check part type */
8
9
  export function isTextPart(part) {
9
10
  return part.type === "text";
package/dist/plan.d.ts ADDED
@@ -0,0 +1,126 @@
1
+ import { z } from "zod";
2
+ /** Harnesses with an enforceable durable-plan continuation contract. */
3
+ export declare const PlanProviderKindSchema: z.ZodEnum<{
4
+ "claude-code": "claude-code";
5
+ codex: "codex";
6
+ opencode: "opencode";
7
+ }>;
8
+ export type PlanProviderKind = z.infer<typeof PlanProviderKindSchema>;
9
+ /**
10
+ * Credential-free provider correlation committed with the plan. This union is
11
+ * deliberately closed: adding plan support for another harness requires an
12
+ * explicit resume contract instead of smuggling opaque metadata through.
13
+ */
14
+ export declare const PlanProviderStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
+ kind: z.ZodLiteral<"claude-code">;
16
+ version: z.ZodLiteral<1>;
17
+ nativeSessionId: z.ZodString;
18
+ }, z.core.$strict>, z.ZodObject<{
19
+ kind: z.ZodLiteral<"codex">;
20
+ version: z.ZodLiteral<1>;
21
+ threadId: z.ZodString;
22
+ }, z.core.$strict>, z.ZodObject<{
23
+ kind: z.ZodLiteral<"opencode">;
24
+ version: z.ZodLiteral<1>;
25
+ }, z.core.$strict>], "kind">;
26
+ export type PlanProviderState = z.infer<typeof PlanProviderStateSchema>;
27
+ /**
28
+ * A plan committed by the runtime before the planning turn is allowed to end.
29
+ * The full body is part of the contract so consumers never reconstruct it from
30
+ * rendered chat text.
31
+ */
32
+ export declare const DurablePlanSchema: z.ZodObject<{
33
+ id: z.ZodString;
34
+ revision: z.ZodNumber;
35
+ title: z.ZodOptional<z.ZodString>;
36
+ body: z.ZodString;
37
+ submittedAt: z.ZodString;
38
+ }, z.core.$strict>;
39
+ export type DurablePlan = z.infer<typeof DurablePlanSchema>;
40
+ /** Provider-originated data required to commit a plan exactly once. */
41
+ export declare const PlanSubmissionSchema: z.ZodObject<{
42
+ title: z.ZodOptional<z.ZodString>;
43
+ body: z.ZodString;
44
+ sourceToolCallId: z.ZodString;
45
+ providerState: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
+ kind: z.ZodLiteral<"claude-code">;
47
+ version: z.ZodLiteral<1>;
48
+ nativeSessionId: z.ZodString;
49
+ }, z.core.$strict>, z.ZodObject<{
50
+ kind: z.ZodLiteral<"codex">;
51
+ version: z.ZodLiteral<1>;
52
+ threadId: z.ZodString;
53
+ }, z.core.$strict>, z.ZodObject<{
54
+ kind: z.ZodLiteral<"opencode">;
55
+ version: z.ZodLiteral<1>;
56
+ }, z.core.$strict>], "kind">;
57
+ }, z.core.$strict>;
58
+ export type PlanSubmission = z.infer<typeof PlanSubmissionSchema>;
59
+ /** The human verdict that starts the next turn. */
60
+ export declare const PlanDecisionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
61
+ outcome: z.ZodLiteral<"approved">;
62
+ }, z.core.$strict>, z.ZodObject<{
63
+ outcome: z.ZodLiteral<"rejected">;
64
+ feedback: z.ZodString;
65
+ }, z.core.$strict>], "outcome">;
66
+ export type PlanDecision = z.infer<typeof PlanDecisionSchema>;
67
+ /**
68
+ * Typed server-originated continuation. Adapters consume this instead of
69
+ * inferring approval from a free-form user message.
70
+ */
71
+ export declare const PlanContinuationSchema: z.ZodObject<{
72
+ version: z.ZodLiteral<1>;
73
+ plan: z.ZodObject<{
74
+ id: z.ZodString;
75
+ revision: z.ZodNumber;
76
+ title: z.ZodOptional<z.ZodString>;
77
+ body: z.ZodString;
78
+ submittedAt: z.ZodString;
79
+ }, z.core.$strict>;
80
+ sourceToolCallId: z.ZodString;
81
+ decision: z.ZodDiscriminatedUnion<[z.ZodObject<{
82
+ outcome: z.ZodLiteral<"approved">;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ outcome: z.ZodLiteral<"rejected">;
85
+ feedback: z.ZodString;
86
+ }, z.core.$strict>], "outcome">;
87
+ providerState: z.ZodDiscriminatedUnion<[z.ZodObject<{
88
+ kind: z.ZodLiteral<"claude-code">;
89
+ version: z.ZodLiteral<1>;
90
+ nativeSessionId: z.ZodString;
91
+ }, z.core.$strict>, z.ZodObject<{
92
+ kind: z.ZodLiteral<"codex">;
93
+ version: z.ZodLiteral<1>;
94
+ threadId: z.ZodString;
95
+ }, z.core.$strict>, z.ZodObject<{
96
+ kind: z.ZodLiteral<"opencode">;
97
+ version: z.ZodLiteral<1>;
98
+ }, z.core.$strict>], "kind">;
99
+ }, z.core.$strict>;
100
+ export type PlanContinuation = z.infer<typeof PlanContinuationSchema>;
101
+ /** Terminal meaning of a successfully completed adapter invocation. */
102
+ export declare const AgentExecutionOutcomeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ type: z.ZodLiteral<"completed">;
104
+ }, z.core.$strict>, z.ZodObject<{
105
+ type: z.ZodLiteral<"awaiting_plan_decision">;
106
+ plan: z.ZodObject<{
107
+ id: z.ZodString;
108
+ revision: z.ZodNumber;
109
+ title: z.ZodOptional<z.ZodString>;
110
+ body: z.ZodString;
111
+ submittedAt: z.ZodString;
112
+ }, z.core.$strict>;
113
+ }, z.core.$strict>], "type">;
114
+ export type AgentExecutionOutcome = z.infer<typeof AgentExecutionOutcomeSchema>;
115
+ /**
116
+ * Per-turn host command used by providers to commit a plan. Implementations
117
+ * bind project, host-session, and turn identity outside provider-controlled
118
+ * input and must resolve only after the durable write commits.
119
+ */
120
+ export interface SdkPlanHost {
121
+ submit(submission: PlanSubmission): Promise<DurablePlan>;
122
+ /** Publish a committed plan only after the provider turn has terminalized. */
123
+ confirm(planId: string): Promise<void>;
124
+ /** Compensate a committed plan when provider terminalization cannot be proven. */
125
+ withdraw(planId: string, reason: string): Promise<void>;
126
+ }
package/dist/plan.js ADDED
@@ -0,0 +1,77 @@
1
+ import { z } from "zod";
2
+ /** Harnesses with an enforceable durable-plan continuation contract. */
3
+ export const PlanProviderKindSchema = z.enum([
4
+ "claude-code",
5
+ "codex",
6
+ "opencode",
7
+ ]);
8
+ /**
9
+ * Credential-free provider correlation committed with the plan. This union is
10
+ * deliberately closed: adding plan support for another harness requires an
11
+ * explicit resume contract instead of smuggling opaque metadata through.
12
+ */
13
+ export const PlanProviderStateSchema = z.discriminatedUnion("kind", [
14
+ z.object({
15
+ kind: z.literal("claude-code"),
16
+ version: z.literal(1),
17
+ nativeSessionId: z.string().min(1),
18
+ }).strict(),
19
+ z.object({
20
+ kind: z.literal("codex"),
21
+ version: z.literal(1),
22
+ threadId: z.string().min(1),
23
+ }).strict(),
24
+ z.object({
25
+ kind: z.literal("opencode"),
26
+ version: z.literal(1),
27
+ }).strict(),
28
+ ]);
29
+ /**
30
+ * A plan committed by the runtime before the planning turn is allowed to end.
31
+ * The full body is part of the contract so consumers never reconstruct it from
32
+ * rendered chat text.
33
+ */
34
+ export const DurablePlanSchema = z.object({
35
+ id: z.string().min(1),
36
+ revision: z.number().int().positive(),
37
+ title: z.string().trim().min(1).optional(),
38
+ body: z.string().trim().min(1),
39
+ submittedAt: z.string().datetime({ offset: true }),
40
+ }).strict();
41
+ /** Provider-originated data required to commit a plan exactly once. */
42
+ export const PlanSubmissionSchema = z.object({
43
+ title: z.string().trim().min(1).optional(),
44
+ body: z.string().trim().min(1),
45
+ /** Stable provider tool-call identity reused when a lost acknowledgement retries. */
46
+ sourceToolCallId: z.string().min(1),
47
+ /** Credential-free correlation required to resume the deferred turn. */
48
+ providerState: PlanProviderStateSchema,
49
+ }).strict();
50
+ /** The human verdict that starts the next turn. */
51
+ export const PlanDecisionSchema = z.discriminatedUnion("outcome", [
52
+ z.object({ outcome: z.literal("approved") }).strict(),
53
+ z.object({
54
+ outcome: z.literal("rejected"),
55
+ feedback: z.string().trim().min(1),
56
+ }).strict(),
57
+ ]);
58
+ /**
59
+ * Typed server-originated continuation. Adapters consume this instead of
60
+ * inferring approval from a free-form user message.
61
+ */
62
+ export const PlanContinuationSchema = z.object({
63
+ version: z.literal(1),
64
+ plan: DurablePlanSchema,
65
+ sourceToolCallId: z.string().min(1),
66
+ decision: PlanDecisionSchema,
67
+ /** Exact payload previously committed with the plan submission. */
68
+ providerState: PlanProviderStateSchema,
69
+ }).strict();
70
+ /** Terminal meaning of a successfully completed adapter invocation. */
71
+ export const AgentExecutionOutcomeSchema = z.discriminatedUnion("type", [
72
+ z.object({ type: z.literal("completed") }).strict(),
73
+ z.object({
74
+ type: z.literal("awaiting_plan_decision"),
75
+ plan: DurablePlanSchema,
76
+ }).strict(),
77
+ ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-interface",
3
- "version": "0.26.1",
3
+ "version": "0.27.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",