@adastracomputing/ink 0.1.0-alpha.2 → 0.1.0-alpha.5
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/CHANGELOG.md +56 -5
- package/CODE_OF_CONDUCT.md +1 -1
- package/README.md +7 -5
- package/SECURITY.md +1 -1
- package/bin/verify-inclusion-impl.mjs +4 -1
- package/dist/audit/inclusion-receipt.d.ts +142 -0
- package/dist/audit/inclusion-receipt.js +496 -0
- package/dist/crypto/ink.d.ts +178 -0
- package/dist/crypto/ink.js +915 -0
- package/dist/crypto/keys.d.ts +42 -0
- package/dist/crypto/keys.js +179 -0
- package/dist/crypto/multi-key-verify.d.ts +29 -0
- package/dist/crypto/multi-key-verify.js +153 -0
- package/dist/crypto/sign.d.ts +17 -0
- package/dist/crypto/sign.js +152 -0
- package/dist/crypto/verify.js +1 -0
- package/dist/discovery/agent-card.d.ts +83 -0
- package/dist/discovery/agent-card.js +545 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +15 -0
- package/dist/ink/checkpoint.d.ts +19 -0
- package/dist/ink/checkpoint.js +69 -0
- package/dist/ink/discovery-gating.d.ts +237 -0
- package/dist/ink/discovery-gating.js +91 -0
- package/dist/ink/handshake-budget.d.ts +90 -0
- package/dist/ink/handshake-budget.js +397 -0
- package/dist/ink/receipts.d.ts +31 -0
- package/dist/ink/receipts.js +89 -0
- package/dist/ink/transport-auth.d.ts +47 -0
- package/dist/ink/transport-auth.js +77 -0
- package/dist/middleware/ink-auth.d.ts +68 -0
- package/dist/middleware/ink-auth.js +214 -0
- package/dist/models/agent-card.d.ts +154 -0
- package/dist/models/agent-card.js +59 -0
- package/dist/models/ink-audit.d.ts +344 -0
- package/dist/models/ink-audit.js +167 -0
- package/dist/models/ink-handshake.d.ts +129 -0
- package/dist/models/ink-handshake.js +89 -0
- package/dist/models/intent.d.ts +437 -0
- package/dist/models/intent.js +172 -0
- package/dist/models/key-entry.d.ts +60 -0
- package/dist/models/key-entry.js +13 -0
- package/dist/models/profile.d.ts +61 -0
- package/dist/models/profile.js +24 -0
- package/docs/maturity.md +3 -3
- package/docs/threat-model.md +1 -1
- package/package.json +17 -13
- package/specs/ink-auditability.md +37 -12
- package/specs/ink-compliance-checklist.md +9 -1
- package/src/audit/inclusion-receipt.ts +0 -268
- package/src/crypto/ink.ts +0 -902
- package/src/crypto/keys.ts +0 -210
- package/src/crypto/multi-key-verify.ts +0 -170
- package/src/crypto/sign.ts +0 -155
- package/src/discovery/agent-card.ts +0 -508
- package/src/index.ts +0 -67
- package/src/ink/checkpoint.ts +0 -75
- package/src/ink/discovery-gating.ts +0 -147
- package/src/ink/handshake-budget.ts +0 -413
- package/src/ink/receipts.ts +0 -114
- package/src/ink/transport-auth.ts +0 -96
- package/src/middleware/ink-auth.ts +0 -263
- package/src/models/agent-card.ts +0 -63
- package/src/models/ink-audit.ts +0 -205
- package/src/models/ink-handshake.ts +0 -123
- package/src/models/intent.ts +0 -201
- package/src/models/key-entry.ts +0 -52
- package/src/models/profile.ts +0 -31
- /package/{src/crypto/verify.ts → dist/crypto/verify.d.ts} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ── Transport identifiers (INK Containment §7) ──
|
|
3
|
+
export const InkTransportSchema = z.enum([
|
|
4
|
+
"ink_http",
|
|
5
|
+
"ink_ws",
|
|
6
|
+
"extension_api",
|
|
7
|
+
"voice",
|
|
8
|
+
"line_phone",
|
|
9
|
+
"human_review_queue",
|
|
10
|
+
]);
|
|
11
|
+
// ── Backoff hints (INK Containment §5.2) ──
|
|
12
|
+
export const InkBackoffHintSchema = z.object({
|
|
13
|
+
retryAfterSeconds: z.number().int().positive().optional(),
|
|
14
|
+
cooldownUntil: z.string().datetime().optional(),
|
|
15
|
+
backoffClass: z.enum(["sender", "intent_ref", "counterparty"]).optional(),
|
|
16
|
+
});
|
|
17
|
+
// ── Agent Card visibility (INK Containment §6) ──
|
|
18
|
+
export const AgentCardVisibilitySchema = z.enum([
|
|
19
|
+
"public",
|
|
20
|
+
"network_only",
|
|
21
|
+
"capability_gated",
|
|
22
|
+
"private",
|
|
23
|
+
]);
|
|
24
|
+
// ── Challenge (network.tulpa.challenge) — Stage 2a ──
|
|
25
|
+
export const ChallengeTypeSchema = z.enum([
|
|
26
|
+
"mutual_connection_proof",
|
|
27
|
+
"identity_verification",
|
|
28
|
+
"availability_query",
|
|
29
|
+
"context_request",
|
|
30
|
+
"none",
|
|
31
|
+
]);
|
|
32
|
+
export const InkChallengeSchema = z.object({
|
|
33
|
+
protocol: z.literal("ink/0.1"),
|
|
34
|
+
type: z.literal("network.tulpa.challenge"),
|
|
35
|
+
intentRef: z.string(),
|
|
36
|
+
challengeType: ChallengeTypeSchema,
|
|
37
|
+
fields: z.array(z.string()).optional(),
|
|
38
|
+
availableWindows: z.array(z.string()).optional(),
|
|
39
|
+
contextFields: z.array(z.string()).optional(),
|
|
40
|
+
nonce: z.string(),
|
|
41
|
+
timestamp: z.string().datetime(),
|
|
42
|
+
});
|
|
43
|
+
// ── Rejection (network.tulpa.rejection) — Stage 2b ──
|
|
44
|
+
export const RejectionReasonSchema = z.enum([
|
|
45
|
+
"policy_violation",
|
|
46
|
+
"trust_threshold",
|
|
47
|
+
"capacity",
|
|
48
|
+
"unsupported_intent",
|
|
49
|
+
"rate_limited",
|
|
50
|
+
"expired",
|
|
51
|
+
// Containment extension (Phase 1)
|
|
52
|
+
"handshake_budget_exhausted",
|
|
53
|
+
"counterparty_cooldown",
|
|
54
|
+
"sender_rate_limited",
|
|
55
|
+
"delegation_budget_exhausted",
|
|
56
|
+
"transport_scope_violation",
|
|
57
|
+
]);
|
|
58
|
+
export const InkRejectionSchema = z.object({
|
|
59
|
+
protocol: z.literal("ink/0.1"),
|
|
60
|
+
type: z.literal("network.tulpa.rejection"),
|
|
61
|
+
intentRef: z.string(),
|
|
62
|
+
reason: RejectionReasonSchema,
|
|
63
|
+
detail: z.string().max(500).optional(),
|
|
64
|
+
retryAfter: z.string().optional(),
|
|
65
|
+
backoffHint: InkBackoffHintSchema.optional(),
|
|
66
|
+
nonce: z.string(),
|
|
67
|
+
timestamp: z.string().datetime(),
|
|
68
|
+
});
|
|
69
|
+
// ── Resolution (network.tulpa.resolution) — Stage 3 ──
|
|
70
|
+
export const ResolutionOutcomeSchema = z.enum([
|
|
71
|
+
"accepted",
|
|
72
|
+
"declined",
|
|
73
|
+
"escalated_to_human",
|
|
74
|
+
"expired",
|
|
75
|
+
]);
|
|
76
|
+
export const ResolutionDetailsSchema = z.object({
|
|
77
|
+
scheduledAt: z.string().optional(),
|
|
78
|
+
duration: z.string().optional(),
|
|
79
|
+
}).passthrough();
|
|
80
|
+
export const InkResolutionSchema = z.object({
|
|
81
|
+
protocol: z.literal("ink/0.1"),
|
|
82
|
+
type: z.literal("network.tulpa.resolution"),
|
|
83
|
+
intentRef: z.string(),
|
|
84
|
+
outcome: ResolutionOutcomeSchema,
|
|
85
|
+
details: ResolutionDetailsSchema.optional(),
|
|
86
|
+
counterpartyDid: z.string().optional(),
|
|
87
|
+
nonce: z.string(),
|
|
88
|
+
timestamp: z.string().datetime(),
|
|
89
|
+
});
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const IntentTypeSchema: z.ZodEnum<{
|
|
3
|
+
schedule_meeting: "schedule_meeting";
|
|
4
|
+
schedule_meeting_response: "schedule_meeting_response";
|
|
5
|
+
intro_request: "intro_request";
|
|
6
|
+
intro_response: "intro_response";
|
|
7
|
+
opportunity: "opportunity";
|
|
8
|
+
opportunity_response: "opportunity_response";
|
|
9
|
+
follow_up: "follow_up";
|
|
10
|
+
ask: "ask";
|
|
11
|
+
ask_response: "ask_response";
|
|
12
|
+
connection_request: "connection_request";
|
|
13
|
+
connection_response: "connection_response";
|
|
14
|
+
context_share: "context_share";
|
|
15
|
+
ping: "ping";
|
|
16
|
+
retract: "retract";
|
|
17
|
+
multi_party_sync: "multi_party_sync";
|
|
18
|
+
}>;
|
|
19
|
+
export type IntentType = z.infer<typeof IntentTypeSchema>;
|
|
20
|
+
export declare const ScheduleMeetingPayloadSchema: z.ZodObject<{
|
|
21
|
+
proposedTimes: z.ZodArray<z.ZodString>;
|
|
22
|
+
topic: z.ZodString;
|
|
23
|
+
format: z.ZodEnum<{
|
|
24
|
+
video: "video";
|
|
25
|
+
phone: "phone";
|
|
26
|
+
in_person: "in_person";
|
|
27
|
+
async: "async";
|
|
28
|
+
}>;
|
|
29
|
+
urgency: z.ZodEnum<{
|
|
30
|
+
low: "low";
|
|
31
|
+
normal: "normal";
|
|
32
|
+
urgent: "urgent";
|
|
33
|
+
}>;
|
|
34
|
+
context: z.ZodOptional<z.ZodString>;
|
|
35
|
+
location: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export declare const ScheduleMeetingResponsePayloadSchema: z.ZodObject<{
|
|
38
|
+
status: z.ZodEnum<{
|
|
39
|
+
accepted: "accepted";
|
|
40
|
+
declined: "declined";
|
|
41
|
+
countered: "countered";
|
|
42
|
+
}>;
|
|
43
|
+
confirmedTime: z.ZodOptional<z.ZodString>;
|
|
44
|
+
counterTimes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
meetingLink: z.ZodOptional<z.ZodString>;
|
|
46
|
+
note: z.ZodOptional<z.ZodString>;
|
|
47
|
+
declineReason: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
unavailable: "unavailable";
|
|
49
|
+
not_interested: "not_interested";
|
|
50
|
+
too_busy: "too_busy";
|
|
51
|
+
deferred: "deferred";
|
|
52
|
+
}>>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export declare const IntroRequestPayloadSchema: z.ZodObject<{
|
|
55
|
+
target: z.ZodString;
|
|
56
|
+
reason: z.ZodString;
|
|
57
|
+
context: z.ZodOptional<z.ZodString>;
|
|
58
|
+
urgency: z.ZodEnum<{
|
|
59
|
+
low: "low";
|
|
60
|
+
normal: "normal";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
export declare const IntroResponsePayloadSchema: z.ZodObject<{
|
|
64
|
+
status: z.ZodEnum<{
|
|
65
|
+
declined: "declined";
|
|
66
|
+
forwarded: "forwarded";
|
|
67
|
+
pending_target: "pending_target";
|
|
68
|
+
}>;
|
|
69
|
+
note: z.ZodOptional<z.ZodString>;
|
|
70
|
+
targetResponse: z.ZodOptional<z.ZodEnum<{
|
|
71
|
+
accepted: "accepted";
|
|
72
|
+
declined: "declined";
|
|
73
|
+
pending: "pending";
|
|
74
|
+
}>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export declare const OpportunityPayloadSchema: z.ZodObject<{
|
|
77
|
+
type: z.ZodEnum<{
|
|
78
|
+
role: "role";
|
|
79
|
+
investment: "investment";
|
|
80
|
+
collaboration: "collaboration";
|
|
81
|
+
advisory: "advisory";
|
|
82
|
+
event: "event";
|
|
83
|
+
other: "other";
|
|
84
|
+
}>;
|
|
85
|
+
title: z.ZodString;
|
|
86
|
+
org: z.ZodOptional<z.ZodString>;
|
|
87
|
+
description: z.ZodString;
|
|
88
|
+
matchReason: z.ZodString;
|
|
89
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
90
|
+
url: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
export declare const OpportunityResponsePayloadSchema: z.ZodObject<{
|
|
93
|
+
status: z.ZodEnum<{
|
|
94
|
+
not_interested: "not_interested";
|
|
95
|
+
interested: "interested";
|
|
96
|
+
maybe_later: "maybe_later";
|
|
97
|
+
}>;
|
|
98
|
+
note: z.ZodOptional<z.ZodString>;
|
|
99
|
+
followUpIntent: z.ZodOptional<z.ZodEnum<{
|
|
100
|
+
schedule_meeting: "schedule_meeting";
|
|
101
|
+
schedule_meeting_response: "schedule_meeting_response";
|
|
102
|
+
intro_request: "intro_request";
|
|
103
|
+
intro_response: "intro_response";
|
|
104
|
+
opportunity: "opportunity";
|
|
105
|
+
opportunity_response: "opportunity_response";
|
|
106
|
+
follow_up: "follow_up";
|
|
107
|
+
ask: "ask";
|
|
108
|
+
ask_response: "ask_response";
|
|
109
|
+
connection_request: "connection_request";
|
|
110
|
+
connection_response: "connection_response";
|
|
111
|
+
context_share: "context_share";
|
|
112
|
+
ping: "ping";
|
|
113
|
+
retract: "retract";
|
|
114
|
+
multi_party_sync: "multi_party_sync";
|
|
115
|
+
}>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export declare const ConnectionRequestPayloadSchema: z.ZodObject<{
|
|
118
|
+
method: z.ZodEnum<{
|
|
119
|
+
qr: "qr";
|
|
120
|
+
intro: "intro";
|
|
121
|
+
discovery: "discovery";
|
|
122
|
+
import: "import";
|
|
123
|
+
}>;
|
|
124
|
+
introducedBy: z.ZodOptional<z.ZodString>;
|
|
125
|
+
context: z.ZodString;
|
|
126
|
+
profileSnapshot: z.ZodObject<{
|
|
127
|
+
headline: z.ZodString;
|
|
128
|
+
skills: z.ZodArray<z.ZodString>;
|
|
129
|
+
interests: z.ZodArray<z.ZodString>;
|
|
130
|
+
availability: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
timezone: z.ZodString;
|
|
132
|
+
meetingHours: z.ZodOptional<z.ZodString>;
|
|
133
|
+
responseSla: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
openTo: z.ZodArray<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
export declare const ConnectionResponsePayloadSchema: z.ZodObject<{
|
|
139
|
+
status: z.ZodEnum<{
|
|
140
|
+
accepted: "accepted";
|
|
141
|
+
declined: "declined";
|
|
142
|
+
pending: "pending";
|
|
143
|
+
}>;
|
|
144
|
+
profileSnapshot: z.ZodOptional<z.ZodObject<{
|
|
145
|
+
headline: z.ZodString;
|
|
146
|
+
skills: z.ZodArray<z.ZodString>;
|
|
147
|
+
interests: z.ZodArray<z.ZodString>;
|
|
148
|
+
availability: z.ZodOptional<z.ZodObject<{
|
|
149
|
+
timezone: z.ZodString;
|
|
150
|
+
meetingHours: z.ZodOptional<z.ZodString>;
|
|
151
|
+
responseSla: z.ZodOptional<z.ZodString>;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
openTo: z.ZodArray<z.ZodString>;
|
|
154
|
+
}, z.core.$strip>>;
|
|
155
|
+
note: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
export declare const FollowUpPayloadSchema: z.ZodObject<{
|
|
158
|
+
referenceId: z.ZodString;
|
|
159
|
+
message: z.ZodString;
|
|
160
|
+
actionRequested: z.ZodOptional<z.ZodEnum<{
|
|
161
|
+
reply: "reply";
|
|
162
|
+
schedule: "schedule";
|
|
163
|
+
review: "review";
|
|
164
|
+
none: "none";
|
|
165
|
+
}>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export declare const AskPayloadSchema: z.ZodObject<{
|
|
168
|
+
question: z.ZodString;
|
|
169
|
+
context: z.ZodOptional<z.ZodString>;
|
|
170
|
+
responseFormat: z.ZodOptional<z.ZodEnum<{
|
|
171
|
+
text: "text";
|
|
172
|
+
choice: "choice";
|
|
173
|
+
}>>;
|
|
174
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
175
|
+
deadline: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, z.core.$strip>;
|
|
177
|
+
export declare const AskResponsePayloadSchema: z.ZodObject<{
|
|
178
|
+
answer: z.ZodString;
|
|
179
|
+
choiceIndex: z.ZodOptional<z.ZodNumber>;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
export declare const PingPayloadSchema: z.ZodObject<{
|
|
182
|
+
note: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export declare const RetractPayloadSchema: z.ZodObject<{
|
|
185
|
+
targetMessageId: z.ZodString;
|
|
186
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
export declare const ContextSharePayloadSchema: z.ZodObject<{
|
|
189
|
+
context: z.ZodString;
|
|
190
|
+
category: z.ZodEnum<{
|
|
191
|
+
availability: "availability";
|
|
192
|
+
professional_background: "professional_background";
|
|
193
|
+
project_update: "project_update";
|
|
194
|
+
expertise: "expertise";
|
|
195
|
+
general: "general";
|
|
196
|
+
}>;
|
|
197
|
+
referenceId: z.ZodOptional<z.ZodString>;
|
|
198
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
export declare const MultiPartySyncPayloadSchema: z.ZodObject<{
|
|
201
|
+
enclaveType: z.ZodEnum<{
|
|
202
|
+
meeting_sync: "meeting_sync";
|
|
203
|
+
}>;
|
|
204
|
+
purpose: z.ZodString;
|
|
205
|
+
participants: z.ZodArray<z.ZodString>;
|
|
206
|
+
expiresAt: z.ZodString;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
export declare const MessageProvenanceSchema: z.ZodOptional<z.ZodObject<{
|
|
209
|
+
origin: z.ZodEnum<{
|
|
210
|
+
human: "human";
|
|
211
|
+
agent_approved: "agent_approved";
|
|
212
|
+
agent_autonomous: "agent_autonomous";
|
|
213
|
+
}>;
|
|
214
|
+
extensionId: z.ZodString;
|
|
215
|
+
installationId: z.ZodString;
|
|
216
|
+
}, z.core.$strip>>;
|
|
217
|
+
export declare const MessageEnvelopeSchema: z.ZodObject<{
|
|
218
|
+
protocol: z.ZodLiteral<"ink/0.1">;
|
|
219
|
+
id: z.ZodString;
|
|
220
|
+
correlationId: z.ZodString;
|
|
221
|
+
createdAt: z.ZodString;
|
|
222
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
223
|
+
from: z.ZodString;
|
|
224
|
+
to: z.ZodString;
|
|
225
|
+
intent: z.ZodEnum<{
|
|
226
|
+
schedule_meeting: "schedule_meeting";
|
|
227
|
+
schedule_meeting_response: "schedule_meeting_response";
|
|
228
|
+
intro_request: "intro_request";
|
|
229
|
+
intro_response: "intro_response";
|
|
230
|
+
opportunity: "opportunity";
|
|
231
|
+
opportunity_response: "opportunity_response";
|
|
232
|
+
follow_up: "follow_up";
|
|
233
|
+
ask: "ask";
|
|
234
|
+
ask_response: "ask_response";
|
|
235
|
+
connection_request: "connection_request";
|
|
236
|
+
connection_response: "connection_response";
|
|
237
|
+
context_share: "context_share";
|
|
238
|
+
ping: "ping";
|
|
239
|
+
retract: "retract";
|
|
240
|
+
multi_party_sync: "multi_party_sync";
|
|
241
|
+
}>;
|
|
242
|
+
payload: z.ZodUnknown;
|
|
243
|
+
signature: z.ZodString;
|
|
244
|
+
signingKeyId: z.ZodOptional<z.ZodString>;
|
|
245
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
246
|
+
origin: z.ZodEnum<{
|
|
247
|
+
human: "human";
|
|
248
|
+
agent_approved: "agent_approved";
|
|
249
|
+
agent_autonomous: "agent_autonomous";
|
|
250
|
+
}>;
|
|
251
|
+
extensionId: z.ZodString;
|
|
252
|
+
installationId: z.ZodString;
|
|
253
|
+
}, z.core.$strip>>;
|
|
254
|
+
}, z.core.$strip>;
|
|
255
|
+
export type MessageEnvelope = z.infer<typeof MessageEnvelopeSchema>;
|
|
256
|
+
/**
|
|
257
|
+
* Validate a message envelope AND its payload based on the intent type.
|
|
258
|
+
* Returns the validated message or throws a ZodError.
|
|
259
|
+
*/
|
|
260
|
+
export declare function validateMessage(raw: unknown): MessageEnvelope;
|
|
261
|
+
/**
|
|
262
|
+
* Get the payload schema for a given intent type.
|
|
263
|
+
*/
|
|
264
|
+
export declare function getPayloadSchema(intent: IntentType): z.ZodObject<{
|
|
265
|
+
proposedTimes: z.ZodArray<z.ZodString>;
|
|
266
|
+
topic: z.ZodString;
|
|
267
|
+
format: z.ZodEnum<{
|
|
268
|
+
video: "video";
|
|
269
|
+
phone: "phone";
|
|
270
|
+
in_person: "in_person";
|
|
271
|
+
async: "async";
|
|
272
|
+
}>;
|
|
273
|
+
urgency: z.ZodEnum<{
|
|
274
|
+
low: "low";
|
|
275
|
+
normal: "normal";
|
|
276
|
+
urgent: "urgent";
|
|
277
|
+
}>;
|
|
278
|
+
context: z.ZodOptional<z.ZodString>;
|
|
279
|
+
location: z.ZodOptional<z.ZodString>;
|
|
280
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
281
|
+
status: z.ZodEnum<{
|
|
282
|
+
accepted: "accepted";
|
|
283
|
+
declined: "declined";
|
|
284
|
+
countered: "countered";
|
|
285
|
+
}>;
|
|
286
|
+
confirmedTime: z.ZodOptional<z.ZodString>;
|
|
287
|
+
counterTimes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
288
|
+
meetingLink: z.ZodOptional<z.ZodString>;
|
|
289
|
+
note: z.ZodOptional<z.ZodString>;
|
|
290
|
+
declineReason: z.ZodOptional<z.ZodEnum<{
|
|
291
|
+
unavailable: "unavailable";
|
|
292
|
+
not_interested: "not_interested";
|
|
293
|
+
too_busy: "too_busy";
|
|
294
|
+
deferred: "deferred";
|
|
295
|
+
}>>;
|
|
296
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
297
|
+
target: z.ZodString;
|
|
298
|
+
reason: z.ZodString;
|
|
299
|
+
context: z.ZodOptional<z.ZodString>;
|
|
300
|
+
urgency: z.ZodEnum<{
|
|
301
|
+
low: "low";
|
|
302
|
+
normal: "normal";
|
|
303
|
+
}>;
|
|
304
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
305
|
+
status: z.ZodEnum<{
|
|
306
|
+
declined: "declined";
|
|
307
|
+
forwarded: "forwarded";
|
|
308
|
+
pending_target: "pending_target";
|
|
309
|
+
}>;
|
|
310
|
+
note: z.ZodOptional<z.ZodString>;
|
|
311
|
+
targetResponse: z.ZodOptional<z.ZodEnum<{
|
|
312
|
+
accepted: "accepted";
|
|
313
|
+
declined: "declined";
|
|
314
|
+
pending: "pending";
|
|
315
|
+
}>>;
|
|
316
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
317
|
+
type: z.ZodEnum<{
|
|
318
|
+
role: "role";
|
|
319
|
+
investment: "investment";
|
|
320
|
+
collaboration: "collaboration";
|
|
321
|
+
advisory: "advisory";
|
|
322
|
+
event: "event";
|
|
323
|
+
other: "other";
|
|
324
|
+
}>;
|
|
325
|
+
title: z.ZodString;
|
|
326
|
+
org: z.ZodOptional<z.ZodString>;
|
|
327
|
+
description: z.ZodString;
|
|
328
|
+
matchReason: z.ZodString;
|
|
329
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
330
|
+
url: z.ZodOptional<z.ZodString>;
|
|
331
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
332
|
+
status: z.ZodEnum<{
|
|
333
|
+
not_interested: "not_interested";
|
|
334
|
+
interested: "interested";
|
|
335
|
+
maybe_later: "maybe_later";
|
|
336
|
+
}>;
|
|
337
|
+
note: z.ZodOptional<z.ZodString>;
|
|
338
|
+
followUpIntent: z.ZodOptional<z.ZodEnum<{
|
|
339
|
+
schedule_meeting: "schedule_meeting";
|
|
340
|
+
schedule_meeting_response: "schedule_meeting_response";
|
|
341
|
+
intro_request: "intro_request";
|
|
342
|
+
intro_response: "intro_response";
|
|
343
|
+
opportunity: "opportunity";
|
|
344
|
+
opportunity_response: "opportunity_response";
|
|
345
|
+
follow_up: "follow_up";
|
|
346
|
+
ask: "ask";
|
|
347
|
+
ask_response: "ask_response";
|
|
348
|
+
connection_request: "connection_request";
|
|
349
|
+
connection_response: "connection_response";
|
|
350
|
+
context_share: "context_share";
|
|
351
|
+
ping: "ping";
|
|
352
|
+
retract: "retract";
|
|
353
|
+
multi_party_sync: "multi_party_sync";
|
|
354
|
+
}>>;
|
|
355
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
356
|
+
method: z.ZodEnum<{
|
|
357
|
+
qr: "qr";
|
|
358
|
+
intro: "intro";
|
|
359
|
+
discovery: "discovery";
|
|
360
|
+
import: "import";
|
|
361
|
+
}>;
|
|
362
|
+
introducedBy: z.ZodOptional<z.ZodString>;
|
|
363
|
+
context: z.ZodString;
|
|
364
|
+
profileSnapshot: z.ZodObject<{
|
|
365
|
+
headline: z.ZodString;
|
|
366
|
+
skills: z.ZodArray<z.ZodString>;
|
|
367
|
+
interests: z.ZodArray<z.ZodString>;
|
|
368
|
+
availability: z.ZodOptional<z.ZodObject<{
|
|
369
|
+
timezone: z.ZodString;
|
|
370
|
+
meetingHours: z.ZodOptional<z.ZodString>;
|
|
371
|
+
responseSla: z.ZodOptional<z.ZodString>;
|
|
372
|
+
}, z.core.$strip>>;
|
|
373
|
+
openTo: z.ZodArray<z.ZodString>;
|
|
374
|
+
}, z.core.$strip>;
|
|
375
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
376
|
+
status: z.ZodEnum<{
|
|
377
|
+
accepted: "accepted";
|
|
378
|
+
declined: "declined";
|
|
379
|
+
pending: "pending";
|
|
380
|
+
}>;
|
|
381
|
+
profileSnapshot: z.ZodOptional<z.ZodObject<{
|
|
382
|
+
headline: z.ZodString;
|
|
383
|
+
skills: z.ZodArray<z.ZodString>;
|
|
384
|
+
interests: z.ZodArray<z.ZodString>;
|
|
385
|
+
availability: z.ZodOptional<z.ZodObject<{
|
|
386
|
+
timezone: z.ZodString;
|
|
387
|
+
meetingHours: z.ZodOptional<z.ZodString>;
|
|
388
|
+
responseSla: z.ZodOptional<z.ZodString>;
|
|
389
|
+
}, z.core.$strip>>;
|
|
390
|
+
openTo: z.ZodArray<z.ZodString>;
|
|
391
|
+
}, z.core.$strip>>;
|
|
392
|
+
note: z.ZodOptional<z.ZodString>;
|
|
393
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
394
|
+
referenceId: z.ZodString;
|
|
395
|
+
message: z.ZodString;
|
|
396
|
+
actionRequested: z.ZodOptional<z.ZodEnum<{
|
|
397
|
+
reply: "reply";
|
|
398
|
+
schedule: "schedule";
|
|
399
|
+
review: "review";
|
|
400
|
+
none: "none";
|
|
401
|
+
}>>;
|
|
402
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
403
|
+
question: z.ZodString;
|
|
404
|
+
context: z.ZodOptional<z.ZodString>;
|
|
405
|
+
responseFormat: z.ZodOptional<z.ZodEnum<{
|
|
406
|
+
text: "text";
|
|
407
|
+
choice: "choice";
|
|
408
|
+
}>>;
|
|
409
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
410
|
+
deadline: z.ZodOptional<z.ZodString>;
|
|
411
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
412
|
+
answer: z.ZodString;
|
|
413
|
+
choiceIndex: z.ZodOptional<z.ZodNumber>;
|
|
414
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
415
|
+
note: z.ZodOptional<z.ZodString>;
|
|
416
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
417
|
+
targetMessageId: z.ZodString;
|
|
418
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
419
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
420
|
+
context: z.ZodString;
|
|
421
|
+
category: z.ZodEnum<{
|
|
422
|
+
availability: "availability";
|
|
423
|
+
professional_background: "professional_background";
|
|
424
|
+
project_update: "project_update";
|
|
425
|
+
expertise: "expertise";
|
|
426
|
+
general: "general";
|
|
427
|
+
}>;
|
|
428
|
+
referenceId: z.ZodOptional<z.ZodString>;
|
|
429
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
430
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
431
|
+
enclaveType: z.ZodEnum<{
|
|
432
|
+
meeting_sync: "meeting_sync";
|
|
433
|
+
}>;
|
|
434
|
+
purpose: z.ZodString;
|
|
435
|
+
participants: z.ZodArray<z.ZodString>;
|
|
436
|
+
expiresAt: z.ZodString;
|
|
437
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { ProfileSnapshotSchema } from "./profile.js";
|
|
3
|
+
// --- Intent Types ---
|
|
4
|
+
export const IntentTypeSchema = z.enum([
|
|
5
|
+
"schedule_meeting",
|
|
6
|
+
"schedule_meeting_response",
|
|
7
|
+
"intro_request",
|
|
8
|
+
"intro_response",
|
|
9
|
+
"opportunity",
|
|
10
|
+
"opportunity_response",
|
|
11
|
+
"follow_up",
|
|
12
|
+
"ask",
|
|
13
|
+
"ask_response",
|
|
14
|
+
"connection_request",
|
|
15
|
+
"connection_response",
|
|
16
|
+
"context_share",
|
|
17
|
+
"ping",
|
|
18
|
+
"retract",
|
|
19
|
+
"multi_party_sync",
|
|
20
|
+
]);
|
|
21
|
+
// --- Intent Payloads ---
|
|
22
|
+
export const ScheduleMeetingPayloadSchema = z.object({
|
|
23
|
+
proposedTimes: z.array(z.string()).min(1).max(10),
|
|
24
|
+
topic: z.string().max(500),
|
|
25
|
+
format: z.enum(["video", "phone", "in_person", "async"]),
|
|
26
|
+
urgency: z.enum(["low", "normal", "urgent"]),
|
|
27
|
+
context: z.string().max(2000).optional(),
|
|
28
|
+
location: z.string().max(500).optional(),
|
|
29
|
+
});
|
|
30
|
+
export const ScheduleMeetingResponsePayloadSchema = z.object({
|
|
31
|
+
status: z.enum(["accepted", "declined", "countered"]),
|
|
32
|
+
confirmedTime: z.string().optional(),
|
|
33
|
+
counterTimes: z.array(z.string()).max(10).optional(),
|
|
34
|
+
meetingLink: z.string().url().optional(),
|
|
35
|
+
note: z.string().max(1000).optional(),
|
|
36
|
+
declineReason: z
|
|
37
|
+
.enum(["unavailable", "not_interested", "too_busy", "deferred"])
|
|
38
|
+
.optional(),
|
|
39
|
+
});
|
|
40
|
+
export const IntroRequestPayloadSchema = z.object({
|
|
41
|
+
target: z.string(),
|
|
42
|
+
reason: z.string().max(2000),
|
|
43
|
+
context: z.string().max(2000).optional(),
|
|
44
|
+
urgency: z.enum(["low", "normal"]),
|
|
45
|
+
});
|
|
46
|
+
export const IntroResponsePayloadSchema = z.object({
|
|
47
|
+
status: z.enum(["forwarded", "declined", "pending_target"]),
|
|
48
|
+
note: z.string().max(1000).optional(),
|
|
49
|
+
targetResponse: z.enum(["accepted", "declined", "pending"]).optional(),
|
|
50
|
+
});
|
|
51
|
+
export const OpportunityPayloadSchema = z.object({
|
|
52
|
+
type: z.enum([
|
|
53
|
+
"role",
|
|
54
|
+
"investment",
|
|
55
|
+
"collaboration",
|
|
56
|
+
"advisory",
|
|
57
|
+
"event",
|
|
58
|
+
"other",
|
|
59
|
+
]),
|
|
60
|
+
title: z.string().max(500),
|
|
61
|
+
org: z.string().max(200).optional(),
|
|
62
|
+
description: z.string().max(5000),
|
|
63
|
+
matchReason: z.string().max(2000),
|
|
64
|
+
expiresAt: z.string().optional(),
|
|
65
|
+
url: z.string().url().optional(),
|
|
66
|
+
});
|
|
67
|
+
export const OpportunityResponsePayloadSchema = z.object({
|
|
68
|
+
status: z.enum(["interested", "not_interested", "maybe_later"]),
|
|
69
|
+
note: z.string().max(1000).optional(),
|
|
70
|
+
followUpIntent: IntentTypeSchema.optional(),
|
|
71
|
+
});
|
|
72
|
+
export const ConnectionRequestPayloadSchema = z.object({
|
|
73
|
+
method: z.enum(["qr", "intro", "discovery", "import"]),
|
|
74
|
+
introducedBy: z.string().optional(),
|
|
75
|
+
context: z.string().max(2000),
|
|
76
|
+
profileSnapshot: ProfileSnapshotSchema,
|
|
77
|
+
});
|
|
78
|
+
export const ConnectionResponsePayloadSchema = z.object({
|
|
79
|
+
status: z.enum(["accepted", "declined", "pending"]),
|
|
80
|
+
profileSnapshot: ProfileSnapshotSchema.optional(),
|
|
81
|
+
note: z.string().max(1000).optional(),
|
|
82
|
+
});
|
|
83
|
+
export const FollowUpPayloadSchema = z.object({
|
|
84
|
+
referenceId: z.string(),
|
|
85
|
+
message: z.string().max(5000),
|
|
86
|
+
actionRequested: z.enum(["reply", "schedule", "review", "none"]).optional(),
|
|
87
|
+
});
|
|
88
|
+
export const AskPayloadSchema = z.object({
|
|
89
|
+
question: z.string().max(5000),
|
|
90
|
+
context: z.string().max(2000).optional(),
|
|
91
|
+
responseFormat: z.enum(["text", "choice"]).optional(),
|
|
92
|
+
choices: z.array(z.string().max(500)).max(10).optional(),
|
|
93
|
+
deadline: z.string().optional(),
|
|
94
|
+
});
|
|
95
|
+
export const AskResponsePayloadSchema = z.object({
|
|
96
|
+
answer: z.string().max(5000),
|
|
97
|
+
choiceIndex: z.number().int().min(0).optional(),
|
|
98
|
+
});
|
|
99
|
+
export const PingPayloadSchema = z.object({
|
|
100
|
+
note: z.string().max(1000).optional(),
|
|
101
|
+
});
|
|
102
|
+
export const RetractPayloadSchema = z.object({
|
|
103
|
+
targetMessageId: z.string(),
|
|
104
|
+
reason: z.string().max(1000).optional(),
|
|
105
|
+
});
|
|
106
|
+
export const ContextSharePayloadSchema = z.object({
|
|
107
|
+
context: z.string().max(5000),
|
|
108
|
+
category: z.enum(["professional_background", "project_update", "expertise", "availability", "general"]),
|
|
109
|
+
referenceId: z.string().optional(),
|
|
110
|
+
expiresAt: z.string().optional(),
|
|
111
|
+
});
|
|
112
|
+
export const MultiPartySyncPayloadSchema = z.object({
|
|
113
|
+
enclaveType: z.enum(["meeting_sync"]),
|
|
114
|
+
purpose: z.string().max(500),
|
|
115
|
+
participants: z.array(z.string()).min(2).max(20),
|
|
116
|
+
expiresAt: z.string(),
|
|
117
|
+
});
|
|
118
|
+
// --- Payload discriminated union ---
|
|
119
|
+
const payloadSchemas = {
|
|
120
|
+
schedule_meeting: ScheduleMeetingPayloadSchema,
|
|
121
|
+
schedule_meeting_response: ScheduleMeetingResponsePayloadSchema,
|
|
122
|
+
intro_request: IntroRequestPayloadSchema,
|
|
123
|
+
intro_response: IntroResponsePayloadSchema,
|
|
124
|
+
opportunity: OpportunityPayloadSchema,
|
|
125
|
+
opportunity_response: OpportunityResponsePayloadSchema,
|
|
126
|
+
follow_up: FollowUpPayloadSchema,
|
|
127
|
+
ask: AskPayloadSchema,
|
|
128
|
+
ask_response: AskResponsePayloadSchema,
|
|
129
|
+
connection_request: ConnectionRequestPayloadSchema,
|
|
130
|
+
connection_response: ConnectionResponsePayloadSchema,
|
|
131
|
+
context_share: ContextSharePayloadSchema,
|
|
132
|
+
ping: PingPayloadSchema,
|
|
133
|
+
retract: RetractPayloadSchema,
|
|
134
|
+
multi_party_sync: MultiPartySyncPayloadSchema,
|
|
135
|
+
};
|
|
136
|
+
// --- Message Envelope ---
|
|
137
|
+
export const MessageProvenanceSchema = z.object({
|
|
138
|
+
origin: z.enum(["human", "agent_approved", "agent_autonomous"]),
|
|
139
|
+
extensionId: z.string(),
|
|
140
|
+
installationId: z.string().uuid(),
|
|
141
|
+
}).optional();
|
|
142
|
+
export const MessageEnvelopeSchema = z.object({
|
|
143
|
+
protocol: z.literal("ink/0.1"),
|
|
144
|
+
id: z.string(),
|
|
145
|
+
correlationId: z.string(),
|
|
146
|
+
createdAt: z.string(),
|
|
147
|
+
expiresAt: z.string().optional(),
|
|
148
|
+
from: z.string(),
|
|
149
|
+
to: z.string(),
|
|
150
|
+
intent: IntentTypeSchema,
|
|
151
|
+
payload: z.unknown(),
|
|
152
|
+
signature: z.string(),
|
|
153
|
+
signingKeyId: z.string().optional(),
|
|
154
|
+
provenance: MessageProvenanceSchema,
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* Validate a message envelope AND its payload based on the intent type.
|
|
158
|
+
* Returns the validated message or throws a ZodError.
|
|
159
|
+
*/
|
|
160
|
+
export function validateMessage(raw) {
|
|
161
|
+
const envelope = MessageEnvelopeSchema.parse(raw);
|
|
162
|
+
const payloadSchema = payloadSchemas[envelope.intent];
|
|
163
|
+
// Validate payload strictly — reject unknown fields
|
|
164
|
+
payloadSchema.strict().parse(envelope.payload);
|
|
165
|
+
return envelope;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get the payload schema for a given intent type.
|
|
169
|
+
*/
|
|
170
|
+
export function getPayloadSchema(intent) {
|
|
171
|
+
return payloadSchemas[intent];
|
|
172
|
+
}
|