@indexnetwork/protocol 21.0.0-rc.488.1 → 21.0.0-rc.490.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.
Files changed (37) hide show
  1. package/dist/index.d.ts +3 -2
  2. package/dist/index.js +1 -1
  3. package/dist/negotiations/negotiation.agent.d.ts +13 -0
  4. package/dist/negotiations/negotiation.agent.js +64 -6
  5. package/dist/negotiations/negotiation.client-dm.d.ts +50 -0
  6. package/dist/negotiations/negotiation.client-dm.js +66 -0
  7. package/dist/negotiations/negotiation.detail-reader.js +4 -1
  8. package/dist/negotiations/negotiation.expected-speaker.d.ts +16 -2
  9. package/dist/negotiations/negotiation.expected-speaker.js +15 -3
  10. package/dist/negotiations/negotiation.graph.d.ts +110 -1
  11. package/dist/negotiations/negotiation.graph.init.js +51 -22
  12. package/dist/negotiations/negotiation.graph.js +2 -1
  13. package/dist/negotiations/negotiation.graph.shared.d.ts +22 -3
  14. package/dist/negotiations/negotiation.graph.shared.js +31 -4
  15. package/dist/negotiations/negotiation.graph.turn.d.ts +27 -0
  16. package/dist/negotiations/negotiation.graph.turn.js +64 -2
  17. package/dist/negotiations/negotiation.module.d.ts +4 -1
  18. package/dist/negotiations/negotiation.module.js +2 -1
  19. package/dist/negotiations/negotiation.protocol.d.ts +498 -0
  20. package/dist/negotiations/negotiation.question-safety.d.ts +28 -0
  21. package/dist/negotiations/negotiation.question-safety.js +65 -0
  22. package/dist/negotiations/negotiation.scope.d.ts +41 -0
  23. package/dist/negotiations/negotiation.scope.js +39 -0
  24. package/dist/negotiations/negotiation.screen.js +7 -3
  25. package/dist/negotiations/negotiation.state.d.ts +110 -0
  26. package/dist/negotiations/negotiation.tools.js +15 -4
  27. package/dist/opportunities/negotiation-context.loader.d.ts +1 -1
  28. package/dist/opportunities/negotiation-context.loader.js +3 -1
  29. package/dist/questions/question.schema.d.ts +13 -31
  30. package/dist/questions/question.schema.js +9 -15
  31. package/dist/shared/interfaces/database.capabilities.d.ts +1 -1
  32. package/dist/shared/interfaces/database.negotiation.d.ts +24 -0
  33. package/dist/shared/schemas/negotiation-state.schema.d.ts +182 -3
  34. package/dist/shared/schemas/negotiation-state.schema.js +23 -3
  35. package/dist/shared/schemas/structured-question.schema.d.ts +66 -0
  36. package/dist/shared/schemas/structured-question.schema.js +31 -0
  37. package/package.json +1 -1
@@ -25,16 +25,99 @@ export declare const NEGOTIATION_CONSULTATION_REASONS: readonly ["unresolved_own
25
25
  export declare const NegotiationConsultationReasonSchema: z.ZodEnum<["unresolved_owner_constraint", "consequential_disclosure_permission", "repeated_non_convergence", "insufficient_commitment_authority"]>;
26
26
  export type NegotiationConsultationReason = z.infer<typeof NegotiationConsultationReasonSchema>;
27
27
  /**
28
- * Payload for a v2 `ask_user` action. Agents may choose only a closed reason;
29
- * disclosure subjects and question wording are always rendered by fixed
30
- * server templates and can never carry model-authored instructions.
28
+ * Payload for a v2 `ask_user` action.
29
+ *
30
+ * `reason` stays the closed enum it has always been: it is admission metadata
31
+ * for the deterministic consultation policy, not copy. `question` is the
32
+ * channel through which the user's own personal agent — the only thing that
33
+ * should be writing questions — hands over the question it authored from the
34
+ * negotiation it is actually having. Free-form keys beyond these two are still
35
+ * rejected by `.strict()`.
31
36
  */
32
37
  export declare const AskUserPayloadSchema: z.ZodObject<{
33
38
  reason: z.ZodEnum<["unresolved_owner_constraint", "consequential_disclosure_permission", "repeated_non_convergence", "insufficient_commitment_authority"]>;
39
+ /**
40
+ * The question the negotiating agent wrote, in the structured shape the UI
41
+ * already renders. Optional: v1 turns, external agents, and the existing
42
+ * enum-only path must all keep validating, so a payload of `{ reason }`
43
+ * alone stays byte-identical in and out.
44
+ *
45
+ * Declared `.nullable().optional()` (not bare `.optional()`) so the enclosing
46
+ * turn schemas survive OpenAI/OpenRouter strict structured-output conversion,
47
+ * which rejects optional-without-nullable fields — the same constraint
48
+ * documented on `QuestionSchema.evidence`. The `.transform()` normalizes an
49
+ * LLM-returned `null` back to `undefined`, so a null is never persisted and
50
+ * `null` and omitted read as absent identically downstream.
51
+ */
52
+ question: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodObject<{
53
+ title: z.ZodString;
54
+ prompt: z.ZodString;
55
+ options: z.ZodArray<z.ZodObject<{
56
+ label: z.ZodString;
57
+ description: z.ZodString;
58
+ }, "strip", z.ZodTypeAny, {
59
+ label: string;
60
+ description: string;
61
+ }, {
62
+ label: string;
63
+ description: string;
64
+ }>, "many">;
65
+ multiSelect: z.ZodBoolean;
66
+ }, "strip", z.ZodTypeAny, {
67
+ prompt: string;
68
+ options: {
69
+ label: string;
70
+ description: string;
71
+ }[];
72
+ title: string;
73
+ multiSelect: boolean;
74
+ }, {
75
+ prompt: string;
76
+ options: {
77
+ label: string;
78
+ description: string;
79
+ }[];
80
+ title: string;
81
+ multiSelect: boolean;
82
+ }>>>, {
83
+ prompt: string;
84
+ options: {
85
+ label: string;
86
+ description: string;
87
+ }[];
88
+ title: string;
89
+ multiSelect: boolean;
90
+ } | undefined, {
91
+ prompt: string;
92
+ options: {
93
+ label: string;
94
+ description: string;
95
+ }[];
96
+ title: string;
97
+ multiSelect: boolean;
98
+ } | null | undefined>;
34
99
  }, "strict", z.ZodTypeAny, {
35
100
  reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority";
101
+ question?: {
102
+ prompt: string;
103
+ options: {
104
+ label: string;
105
+ description: string;
106
+ }[];
107
+ title: string;
108
+ multiSelect: boolean;
109
+ } | undefined;
36
110
  }, {
37
111
  reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority";
112
+ question?: {
113
+ prompt: string;
114
+ options: {
115
+ label: string;
116
+ description: string;
117
+ }[];
118
+ title: string;
119
+ multiSelect: boolean;
120
+ } | null | undefined;
38
121
  }>;
39
122
  export type AskUserPayload = z.infer<typeof AskUserPayloadSchema>;
40
123
  export declare const NegotiationTurnSchema: z.ZodObject<{
@@ -68,10 +151,88 @@ export declare const NegotiationTurnSchema: z.ZodObject<{
68
151
  /** Present when action is `ask_user` (v2, P3.2). */
69
152
  askUser: z.ZodOptional<z.ZodNullable<z.ZodObject<{
70
153
  reason: z.ZodEnum<["unresolved_owner_constraint", "consequential_disclosure_permission", "repeated_non_convergence", "insufficient_commitment_authority"]>;
154
+ /**
155
+ * The question the negotiating agent wrote, in the structured shape the UI
156
+ * already renders. Optional: v1 turns, external agents, and the existing
157
+ * enum-only path must all keep validating, so a payload of `{ reason }`
158
+ * alone stays byte-identical in and out.
159
+ *
160
+ * Declared `.nullable().optional()` (not bare `.optional()`) so the enclosing
161
+ * turn schemas survive OpenAI/OpenRouter strict structured-output conversion,
162
+ * which rejects optional-without-nullable fields — the same constraint
163
+ * documented on `QuestionSchema.evidence`. The `.transform()` normalizes an
164
+ * LLM-returned `null` back to `undefined`, so a null is never persisted and
165
+ * `null` and omitted read as absent identically downstream.
166
+ */
167
+ question: z.ZodEffects<z.ZodOptional<z.ZodNullable<z.ZodObject<{
168
+ title: z.ZodString;
169
+ prompt: z.ZodString;
170
+ options: z.ZodArray<z.ZodObject<{
171
+ label: z.ZodString;
172
+ description: z.ZodString;
173
+ }, "strip", z.ZodTypeAny, {
174
+ label: string;
175
+ description: string;
176
+ }, {
177
+ label: string;
178
+ description: string;
179
+ }>, "many">;
180
+ multiSelect: z.ZodBoolean;
181
+ }, "strip", z.ZodTypeAny, {
182
+ prompt: string;
183
+ options: {
184
+ label: string;
185
+ description: string;
186
+ }[];
187
+ title: string;
188
+ multiSelect: boolean;
189
+ }, {
190
+ prompt: string;
191
+ options: {
192
+ label: string;
193
+ description: string;
194
+ }[];
195
+ title: string;
196
+ multiSelect: boolean;
197
+ }>>>, {
198
+ prompt: string;
199
+ options: {
200
+ label: string;
201
+ description: string;
202
+ }[];
203
+ title: string;
204
+ multiSelect: boolean;
205
+ } | undefined, {
206
+ prompt: string;
207
+ options: {
208
+ label: string;
209
+ description: string;
210
+ }[];
211
+ title: string;
212
+ multiSelect: boolean;
213
+ } | null | undefined>;
71
214
  }, "strict", z.ZodTypeAny, {
72
215
  reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority";
216
+ question?: {
217
+ prompt: string;
218
+ options: {
219
+ label: string;
220
+ description: string;
221
+ }[];
222
+ title: string;
223
+ multiSelect: boolean;
224
+ } | undefined;
73
225
  }, {
74
226
  reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority";
227
+ question?: {
228
+ prompt: string;
229
+ options: {
230
+ label: string;
231
+ description: string;
232
+ }[];
233
+ title: string;
234
+ multiSelect: boolean;
235
+ } | null | undefined;
75
236
  }>>>;
76
237
  }, "strip", z.ZodTypeAny, {
77
238
  action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user";
@@ -85,6 +246,15 @@ export declare const NegotiationTurnSchema: z.ZodObject<{
85
246
  message?: string | null | undefined;
86
247
  askUser?: {
87
248
  reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority";
249
+ question?: {
250
+ prompt: string;
251
+ options: {
252
+ label: string;
253
+ description: string;
254
+ }[];
255
+ title: string;
256
+ multiSelect: boolean;
257
+ } | undefined;
88
258
  } | null | undefined;
89
259
  }, {
90
260
  action: "propose" | "accept" | "reject" | "counter" | "question" | "outreach" | "withdraw" | "decline" | "ask_user";
@@ -98,6 +268,15 @@ export declare const NegotiationTurnSchema: z.ZodObject<{
98
268
  message?: string | null | undefined;
99
269
  askUser?: {
100
270
  reason: "unresolved_owner_constraint" | "consequential_disclosure_permission" | "repeated_non_convergence" | "insufficient_commitment_authority";
271
+ question?: {
272
+ prompt: string;
273
+ options: {
274
+ label: string;
275
+ description: string;
276
+ }[];
277
+ title: string;
278
+ multiSelect: boolean;
279
+ } | null | undefined;
101
280
  } | null | undefined;
102
281
  }>;
103
282
  export type NegotiationTurn = z.infer<typeof NegotiationTurnSchema>;
@@ -4,6 +4,7 @@
4
4
  * LangGraph Annotation.Root stays in the domain file.
5
5
  */
6
6
  import { z } from "zod";
7
+ import { StructuredQuestionSchema } from "./structured-question.schema.js";
7
8
  // ─── Zod schemas (available for runtime validation) ───────────────────────────
8
9
  /**
9
10
  * Union of every negotiation turn action across protocol versions.
@@ -29,12 +30,31 @@ export const NEGOTIATION_CONSULTATION_REASONS = [
29
30
  ];
30
31
  export const NegotiationConsultationReasonSchema = z.enum(NEGOTIATION_CONSULTATION_REASONS);
31
32
  /**
32
- * Payload for a v2 `ask_user` action. Agents may choose only a closed reason;
33
- * disclosure subjects and question wording are always rendered by fixed
34
- * server templates and can never carry model-authored instructions.
33
+ * Payload for a v2 `ask_user` action.
34
+ *
35
+ * `reason` stays the closed enum it has always been: it is admission metadata
36
+ * for the deterministic consultation policy, not copy. `question` is the
37
+ * channel through which the user's own personal agent — the only thing that
38
+ * should be writing questions — hands over the question it authored from the
39
+ * negotiation it is actually having. Free-form keys beyond these two are still
40
+ * rejected by `.strict()`.
35
41
  */
36
42
  export const AskUserPayloadSchema = z.object({
37
43
  reason: NegotiationConsultationReasonSchema,
44
+ /**
45
+ * The question the negotiating agent wrote, in the structured shape the UI
46
+ * already renders. Optional: v1 turns, external agents, and the existing
47
+ * enum-only path must all keep validating, so a payload of `{ reason }`
48
+ * alone stays byte-identical in and out.
49
+ *
50
+ * Declared `.nullable().optional()` (not bare `.optional()`) so the enclosing
51
+ * turn schemas survive OpenAI/OpenRouter strict structured-output conversion,
52
+ * which rejects optional-without-nullable fields — the same constraint
53
+ * documented on `QuestionSchema.evidence`. The `.transform()` normalizes an
54
+ * LLM-returned `null` back to `undefined`, so a null is never persisted and
55
+ * `null` and omitted read as absent identically downstream.
56
+ */
57
+ question: StructuredQuestionSchema.nullable().optional().transform((value) => value ?? undefined),
38
58
  }).strict();
39
59
  export const NegotiationTurnSchema = z.object({
40
60
  action: z.enum(NEGOTIATION_ACTIONS),
@@ -0,0 +1,66 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Canonical structured question shape: the title/prompt/options/multiSelect
4
+ * quartet every question renderer (frontend cards, MCP elicitation) consumes.
5
+ *
6
+ * It lives in `shared/` rather than inside `questions/` for the same reason as
7
+ * `underspecification.schema.ts`: more than one capability needs the shape.
8
+ * The questions capability owns question *generation* and extends this with its
9
+ * own provenance field; the negotiator only needs to hand over a question it
10
+ * authored (`AskUserPayloadSchema` in `negotiation-state.schema.ts`), and
11
+ * `shared/schemas` must not value-import a capability module to reach a shape.
12
+ *
13
+ * Field constraints are tuned for the renderer and are the single source of
14
+ * truth — `questions/question.schema.ts` re-exports rather than redeclares.
15
+ */
16
+ export declare const QuestionOptionSchema: z.ZodObject<{
17
+ /** Display text. Suffix " (Recommended)" on the safest path; list it first. */
18
+ label: z.ZodString;
19
+ /** Explains the consequence of choosing this option, not just its definition. */
20
+ description: z.ZodString;
21
+ }, "strip", z.ZodTypeAny, {
22
+ label: string;
23
+ description: string;
24
+ }, {
25
+ label: string;
26
+ description: string;
27
+ }>;
28
+ export declare const StructuredQuestionSchema: z.ZodObject<{
29
+ /** ≤12 chars. Noun of the decision domain — e.g. "Stage", "Timing", "Role". */
30
+ title: z.ZodString;
31
+ /** ≤2 sentences, ≤400 chars. Ends in a question mark. */
32
+ prompt: z.ZodString;
33
+ /** 2–4 options. No explicit "Other" — clients provide that automatically. */
34
+ options: z.ZodArray<z.ZodObject<{
35
+ /** Display text. Suffix " (Recommended)" on the safest path; list it first. */
36
+ label: z.ZodString;
37
+ /** Explains the consequence of choosing this option, not just its definition. */
38
+ description: z.ZodString;
39
+ }, "strip", z.ZodTypeAny, {
40
+ label: string;
41
+ description: string;
42
+ }, {
43
+ label: string;
44
+ description: string;
45
+ }>, "many">;
46
+ /** True when options are not mutually exclusive (priorities, bundles). */
47
+ multiSelect: z.ZodBoolean;
48
+ }, "strip", z.ZodTypeAny, {
49
+ prompt: string;
50
+ options: {
51
+ label: string;
52
+ description: string;
53
+ }[];
54
+ title: string;
55
+ multiSelect: boolean;
56
+ }, {
57
+ prompt: string;
58
+ options: {
59
+ label: string;
60
+ description: string;
61
+ }[];
62
+ title: string;
63
+ multiSelect: boolean;
64
+ }>;
65
+ export type QuestionOption = z.infer<typeof QuestionOptionSchema>;
66
+ export type StructuredQuestion = z.infer<typeof StructuredQuestionSchema>;
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Canonical structured question shape: the title/prompt/options/multiSelect
4
+ * quartet every question renderer (frontend cards, MCP elicitation) consumes.
5
+ *
6
+ * It lives in `shared/` rather than inside `questions/` for the same reason as
7
+ * `underspecification.schema.ts`: more than one capability needs the shape.
8
+ * The questions capability owns question *generation* and extends this with its
9
+ * own provenance field; the negotiator only needs to hand over a question it
10
+ * authored (`AskUserPayloadSchema` in `negotiation-state.schema.ts`), and
11
+ * `shared/schemas` must not value-import a capability module to reach a shape.
12
+ *
13
+ * Field constraints are tuned for the renderer and are the single source of
14
+ * truth — `questions/question.schema.ts` re-exports rather than redeclares.
15
+ */
16
+ export const QuestionOptionSchema = z.object({
17
+ /** Display text. Suffix " (Recommended)" on the safest path; list it first. */
18
+ label: z.string().min(1).max(120),
19
+ /** Explains the consequence of choosing this option, not just its definition. */
20
+ description: z.string().min(1).max(280),
21
+ });
22
+ export const StructuredQuestionSchema = z.object({
23
+ /** ≤12 chars. Noun of the decision domain — e.g. "Stage", "Timing", "Role". */
24
+ title: z.string().min(1).max(12),
25
+ /** ≤2 sentences, ≤400 chars. Ends in a question mark. */
26
+ prompt: z.string().min(1).max(400),
27
+ /** 2–4 options. No explicit "Other" — clients provide that automatically. */
28
+ options: z.array(QuestionOptionSchema).min(2).max(4),
29
+ /** True when options are not mutually exclusive (priorities, bundles). */
30
+ multiSelect: z.boolean(),
31
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "21.0.0-rc.488.1",
3
+ "version": "21.0.0-rc.490.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",