@adastracomputing/ink 0.1.0-alpha.3 → 0.1.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 (64) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +15 -3
  3. package/dist/audit/inclusion-receipt.d.ts +142 -0
  4. package/dist/audit/inclusion-receipt.js +496 -0
  5. package/dist/crypto/ink.d.ts +178 -0
  6. package/dist/crypto/ink.js +915 -0
  7. package/dist/crypto/keys.d.ts +42 -0
  8. package/dist/crypto/keys.js +179 -0
  9. package/dist/crypto/multi-key-verify.d.ts +29 -0
  10. package/dist/crypto/multi-key-verify.js +153 -0
  11. package/dist/crypto/sign.d.ts +17 -0
  12. package/dist/crypto/sign.js +152 -0
  13. package/dist/crypto/verify.js +1 -0
  14. package/dist/discovery/agent-card.d.ts +83 -0
  15. package/dist/discovery/agent-card.js +545 -0
  16. package/dist/index.d.ts +13 -0
  17. package/dist/index.js +16 -0
  18. package/dist/ink/checkpoint.d.ts +19 -0
  19. package/dist/ink/checkpoint.js +69 -0
  20. package/dist/ink/discovery-gating.d.ts +247 -0
  21. package/dist/ink/discovery-gating.js +94 -0
  22. package/dist/ink/handshake-budget.d.ts +90 -0
  23. package/dist/ink/handshake-budget.js +397 -0
  24. package/dist/ink/receipts.d.ts +31 -0
  25. package/dist/ink/receipts.js +89 -0
  26. package/dist/ink/transport-auth.d.ts +47 -0
  27. package/dist/ink/transport-auth.js +77 -0
  28. package/dist/middleware/ink-auth.d.ts +68 -0
  29. package/dist/middleware/ink-auth.js +214 -0
  30. package/dist/models/agent-card.d.ts +170 -0
  31. package/dist/models/agent-card.js +107 -0
  32. package/dist/models/ink-audit.d.ts +344 -0
  33. package/dist/models/ink-audit.js +167 -0
  34. package/dist/models/ink-handshake.d.ts +129 -0
  35. package/dist/models/ink-handshake.js +89 -0
  36. package/dist/models/intent.d.ts +437 -0
  37. package/dist/models/intent.js +172 -0
  38. package/dist/models/key-entry.d.ts +60 -0
  39. package/dist/models/key-entry.js +13 -0
  40. package/dist/models/profile.d.ts +61 -0
  41. package/dist/models/profile.js +24 -0
  42. package/package.json +15 -11
  43. package/specs/ink-auditability.md +2 -2
  44. package/specs/ink-containment-phase1-implementation-spec.md +1 -1
  45. package/src/audit/inclusion-receipt.ts +0 -604
  46. package/src/crypto/ink.ts +0 -1046
  47. package/src/crypto/keys.ts +0 -210
  48. package/src/crypto/multi-key-verify.ts +0 -170
  49. package/src/crypto/sign.ts +0 -155
  50. package/src/discovery/agent-card.ts +0 -508
  51. package/src/index.ts +0 -73
  52. package/src/ink/checkpoint.ts +0 -75
  53. package/src/ink/discovery-gating.ts +0 -147
  54. package/src/ink/handshake-budget.ts +0 -413
  55. package/src/ink/receipts.ts +0 -114
  56. package/src/ink/transport-auth.ts +0 -96
  57. package/src/middleware/ink-auth.ts +0 -263
  58. package/src/models/agent-card.ts +0 -63
  59. package/src/models/ink-audit.ts +0 -205
  60. package/src/models/ink-handshake.ts +0 -123
  61. package/src/models/intent.ts +0 -201
  62. package/src/models/key-entry.ts +0 -52
  63. package/src/models/profile.ts +0 -31
  64. /package/{src/crypto/verify.ts → dist/crypto/verify.d.ts} +0 -0
@@ -1,123 +0,0 @@
1
- import { z } from "zod";
2
-
3
- // ── Transport identifiers (INK Containment §7) ──
4
-
5
- export const InkTransportSchema = z.enum([
6
- "ink_http",
7
- "ink_ws",
8
- "extension_api",
9
- "voice",
10
- "line_phone",
11
- "human_review_queue",
12
- ]);
13
-
14
- export type InkTransport = z.infer<typeof InkTransportSchema>;
15
-
16
- // ── Backoff hints (INK Containment §5.2) ──
17
-
18
- export const InkBackoffHintSchema = z.object({
19
- retryAfterSeconds: z.number().int().positive().optional(),
20
- cooldownUntil: z.string().datetime().optional(),
21
- backoffClass: z.enum(["sender", "intent_ref", "counterparty"]).optional(),
22
- });
23
-
24
- export type InkBackoffHint = z.infer<typeof InkBackoffHintSchema>;
25
-
26
- // ── Agent Card visibility (INK Containment §6) ──
27
-
28
- export const AgentCardVisibilitySchema = z.enum([
29
- "public",
30
- "network_only",
31
- "capability_gated",
32
- "private",
33
- ]);
34
-
35
- export type AgentCardVisibility = z.infer<typeof AgentCardVisibilitySchema>;
36
-
37
- // ── Challenge (network.tulpa.challenge) — Stage 2a ──
38
-
39
- export const ChallengeTypeSchema = z.enum([
40
- "mutual_connection_proof",
41
- "identity_verification",
42
- "availability_query",
43
- "context_request",
44
- "none",
45
- ]);
46
-
47
- export type ChallengeType = z.infer<typeof ChallengeTypeSchema>;
48
-
49
- export const InkChallengeSchema = z.object({
50
- protocol: z.literal("ink/0.1"),
51
- type: z.literal("network.tulpa.challenge"),
52
- intentRef: z.string(),
53
- challengeType: ChallengeTypeSchema,
54
- fields: z.array(z.string()).optional(),
55
- availableWindows: z.array(z.string()).optional(),
56
- contextFields: z.array(z.string()).optional(),
57
- nonce: z.string(),
58
- timestamp: z.string().datetime(),
59
- });
60
-
61
- export type InkChallenge = z.infer<typeof InkChallengeSchema>;
62
-
63
- // ── Rejection (network.tulpa.rejection) — Stage 2b ──
64
-
65
- export const RejectionReasonSchema = z.enum([
66
- "policy_violation",
67
- "trust_threshold",
68
- "capacity",
69
- "unsupported_intent",
70
- "rate_limited",
71
- "expired",
72
- // Containment extension (Phase 1)
73
- "handshake_budget_exhausted",
74
- "counterparty_cooldown",
75
- "sender_rate_limited",
76
- "delegation_budget_exhausted",
77
- "transport_scope_violation",
78
- ]);
79
-
80
- export type RejectionReason = z.infer<typeof RejectionReasonSchema>;
81
-
82
- export const InkRejectionSchema = z.object({
83
- protocol: z.literal("ink/0.1"),
84
- type: z.literal("network.tulpa.rejection"),
85
- intentRef: z.string(),
86
- reason: RejectionReasonSchema,
87
- detail: z.string().max(500).optional(),
88
- retryAfter: z.string().optional(),
89
- backoffHint: InkBackoffHintSchema.optional(),
90
- nonce: z.string(),
91
- timestamp: z.string().datetime(),
92
- });
93
-
94
- export type InkRejection = z.infer<typeof InkRejectionSchema>;
95
-
96
- // ── Resolution (network.tulpa.resolution) — Stage 3 ──
97
-
98
- export const ResolutionOutcomeSchema = z.enum([
99
- "accepted",
100
- "declined",
101
- "escalated_to_human",
102
- "expired",
103
- ]);
104
-
105
- export type ResolutionOutcome = z.infer<typeof ResolutionOutcomeSchema>;
106
-
107
- export const ResolutionDetailsSchema = z.object({
108
- scheduledAt: z.string().optional(),
109
- duration: z.string().optional(),
110
- }).passthrough();
111
-
112
- export const InkResolutionSchema = z.object({
113
- protocol: z.literal("ink/0.1"),
114
- type: z.literal("network.tulpa.resolution"),
115
- intentRef: z.string(),
116
- outcome: ResolutionOutcomeSchema,
117
- details: ResolutionDetailsSchema.optional(),
118
- counterpartyDid: z.string().optional(),
119
- nonce: z.string(),
120
- timestamp: z.string().datetime(),
121
- });
122
-
123
- export type InkResolution = z.infer<typeof InkResolutionSchema>;
@@ -1,201 +0,0 @@
1
- import { z } from "zod";
2
- import { ProfileSnapshotSchema } from "./profile.js";
3
-
4
- // --- Intent Types ---
5
-
6
- export const IntentTypeSchema = z.enum([
7
- "schedule_meeting",
8
- "schedule_meeting_response",
9
- "intro_request",
10
- "intro_response",
11
- "opportunity",
12
- "opportunity_response",
13
- "follow_up",
14
- "ask",
15
- "ask_response",
16
- "connection_request",
17
- "connection_response",
18
- "context_share",
19
- "ping",
20
- "retract",
21
- "multi_party_sync",
22
- ]);
23
-
24
- export type IntentType = z.infer<typeof IntentTypeSchema>;
25
-
26
- // --- Intent Payloads ---
27
-
28
- export const ScheduleMeetingPayloadSchema = z.object({
29
- proposedTimes: z.array(z.string()).min(1).max(10),
30
- topic: z.string().max(500),
31
- format: z.enum(["video", "phone", "in_person", "async"]),
32
- urgency: z.enum(["low", "normal", "urgent"]),
33
- context: z.string().max(2000).optional(),
34
- location: z.string().max(500).optional(),
35
- });
36
-
37
- export const ScheduleMeetingResponsePayloadSchema = z.object({
38
- status: z.enum(["accepted", "declined", "countered"]),
39
- confirmedTime: z.string().optional(),
40
- counterTimes: z.array(z.string()).max(10).optional(),
41
- meetingLink: z.string().url().optional(),
42
- note: z.string().max(1000).optional(),
43
- declineReason: z
44
- .enum(["unavailable", "not_interested", "too_busy", "deferred"])
45
- .optional(),
46
- });
47
-
48
- export const IntroRequestPayloadSchema = z.object({
49
- target: z.string(),
50
- reason: z.string().max(2000),
51
- context: z.string().max(2000).optional(),
52
- urgency: z.enum(["low", "normal"]),
53
- });
54
-
55
- export const IntroResponsePayloadSchema = z.object({
56
- status: z.enum(["forwarded", "declined", "pending_target"]),
57
- note: z.string().max(1000).optional(),
58
- targetResponse: z.enum(["accepted", "declined", "pending"]).optional(),
59
- });
60
-
61
- export const OpportunityPayloadSchema = z.object({
62
- type: z.enum([
63
- "role",
64
- "investment",
65
- "collaboration",
66
- "advisory",
67
- "event",
68
- "other",
69
- ]),
70
- title: z.string().max(500),
71
- org: z.string().max(200).optional(),
72
- description: z.string().max(5000),
73
- matchReason: z.string().max(2000),
74
- expiresAt: z.string().optional(),
75
- url: z.string().url().optional(),
76
- });
77
-
78
- export const OpportunityResponsePayloadSchema = z.object({
79
- status: z.enum(["interested", "not_interested", "maybe_later"]),
80
- note: z.string().max(1000).optional(),
81
- followUpIntent: IntentTypeSchema.optional(),
82
- });
83
-
84
- export const ConnectionRequestPayloadSchema = z.object({
85
- method: z.enum(["qr", "intro", "discovery", "import"]),
86
- introducedBy: z.string().optional(),
87
- context: z.string().max(2000),
88
- profileSnapshot: ProfileSnapshotSchema,
89
- });
90
-
91
- export const ConnectionResponsePayloadSchema = z.object({
92
- status: z.enum(["accepted", "declined", "pending"]),
93
- profileSnapshot: ProfileSnapshotSchema.optional(),
94
- note: z.string().max(1000).optional(),
95
- });
96
-
97
- export const FollowUpPayloadSchema = z.object({
98
- referenceId: z.string(),
99
- message: z.string().max(5000),
100
- actionRequested: z.enum(["reply", "schedule", "review", "none"]).optional(),
101
- });
102
-
103
- export const AskPayloadSchema = z.object({
104
- question: z.string().max(5000),
105
- context: z.string().max(2000).optional(),
106
- responseFormat: z.enum(["text", "choice"]).optional(),
107
- choices: z.array(z.string().max(500)).max(10).optional(),
108
- deadline: z.string().optional(),
109
- });
110
-
111
- export const AskResponsePayloadSchema = z.object({
112
- answer: z.string().max(5000),
113
- choiceIndex: z.number().int().min(0).optional(),
114
- });
115
-
116
- export const PingPayloadSchema = z.object({
117
- note: z.string().max(1000).optional(),
118
- });
119
-
120
- export const RetractPayloadSchema = z.object({
121
- targetMessageId: z.string(),
122
- reason: z.string().max(1000).optional(),
123
- });
124
-
125
- export const ContextSharePayloadSchema = z.object({
126
- context: z.string().max(5000),
127
- category: z.enum(["professional_background", "project_update", "expertise", "availability", "general"]),
128
- referenceId: z.string().optional(),
129
- expiresAt: z.string().optional(),
130
- });
131
-
132
- export const MultiPartySyncPayloadSchema = z.object({
133
- enclaveType: z.enum(["meeting_sync"]),
134
- purpose: z.string().max(500),
135
- participants: z.array(z.string()).min(2).max(20),
136
- expiresAt: z.string(),
137
- });
138
-
139
- // --- Payload discriminated union ---
140
-
141
- const payloadSchemas = {
142
- schedule_meeting: ScheduleMeetingPayloadSchema,
143
- schedule_meeting_response: ScheduleMeetingResponsePayloadSchema,
144
- intro_request: IntroRequestPayloadSchema,
145
- intro_response: IntroResponsePayloadSchema,
146
- opportunity: OpportunityPayloadSchema,
147
- opportunity_response: OpportunityResponsePayloadSchema,
148
- follow_up: FollowUpPayloadSchema,
149
- ask: AskPayloadSchema,
150
- ask_response: AskResponsePayloadSchema,
151
- connection_request: ConnectionRequestPayloadSchema,
152
- connection_response: ConnectionResponsePayloadSchema,
153
- context_share: ContextSharePayloadSchema,
154
- ping: PingPayloadSchema,
155
- retract: RetractPayloadSchema,
156
- multi_party_sync: MultiPartySyncPayloadSchema,
157
- } as const;
158
-
159
- // --- Message Envelope ---
160
-
161
- export const MessageProvenanceSchema = z.object({
162
- origin: z.enum(["human", "agent_approved", "agent_autonomous"]),
163
- extensionId: z.string(),
164
- installationId: z.string().uuid(),
165
- }).optional();
166
-
167
- export const MessageEnvelopeSchema = z.object({
168
- protocol: z.literal("ink/0.1"),
169
- id: z.string(),
170
- correlationId: z.string(),
171
- createdAt: z.string(),
172
- expiresAt: z.string().optional(),
173
- from: z.string(),
174
- to: z.string(),
175
- intent: IntentTypeSchema,
176
- payload: z.unknown(),
177
- signature: z.string(),
178
- signingKeyId: z.string().optional(),
179
- provenance: MessageProvenanceSchema,
180
- });
181
-
182
- export type MessageEnvelope = z.infer<typeof MessageEnvelopeSchema>;
183
-
184
- /**
185
- * Validate a message envelope AND its payload based on the intent type.
186
- * Returns the validated message or throws a ZodError.
187
- */
188
- export function validateMessage(raw: unknown): MessageEnvelope {
189
- const envelope = MessageEnvelopeSchema.parse(raw);
190
- const payloadSchema = payloadSchemas[envelope.intent];
191
- // Validate payload strictly — reject unknown fields
192
- payloadSchema.strict().parse(envelope.payload);
193
- return envelope;
194
- }
195
-
196
- /**
197
- * Get the payload schema for a given intent type.
198
- */
199
- export function getPayloadSchema(intent: IntentType) {
200
- return payloadSchemas[intent];
201
- }
@@ -1,52 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const KeyStatusSchema = z.enum(["active", "retired", "revoked"]);
4
- export type KeyStatus = z.infer<typeof KeyStatusSchema>;
5
-
6
- export const KeyRoleSchema = z.enum(["signing", "encryption"]);
7
- export type KeyRole = z.infer<typeof KeyRoleSchema>;
8
-
9
- export const KeyEntrySchema = z.object({
10
- keyId: z.string().min(1),
11
- algorithm: z.enum(["Ed25519", "X25519"]),
12
- publicKeyMultibase: z.string().startsWith("z"),
13
- status: KeyStatusSchema,
14
- validFrom: z.string().datetime(),
15
- validUntil: z.string().datetime().optional(),
16
- revokedAt: z.string().datetime().optional(),
17
- revokeReason: z.string().optional(),
18
- });
19
-
20
- export type KeyEntry = z.infer<typeof KeyEntrySchema>;
21
-
22
- export interface CandidateKey {
23
- keyId: string;
24
- publicKey: Uint8Array;
25
- status: KeyStatus;
26
- /** ISO 8601 timestamp the key becomes usable. Verifier rejects messages
27
- * whose `body.timestamp` falls outside [validFrom, validUntil]. Optional
28
- * for backward compat with legacy callers that don't track windows. */
29
- validFrom?: string;
30
- /** ISO 8601 timestamp the key stops being usable. Typically set when a
31
- * key transitions to `retired`. A retired key with no validUntil keeps
32
- * verifying indefinitely (legacy behavior); set validUntil to bound it. */
33
- validUntil?: string;
34
- /** ISO 8601 timestamp the key was revoked. Defensive: status === "revoked"
35
- * already blocks verification; this field documents the moment. */
36
- revokedAt?: string;
37
- }
38
-
39
- export interface StoredKey {
40
- keyId: string;
41
- agentId: string;
42
- role: KeyRole;
43
- algorithm: string;
44
- publicKeyMultibase: string;
45
- privateKey: Uint8Array | null;
46
- status: KeyStatus;
47
- validFrom: string;
48
- validUntil: string | null;
49
- revokedAt: string | null;
50
- createdAt: string;
51
- updatedAt: string;
52
- }
@@ -1,31 +0,0 @@
1
- import { z } from "zod";
2
-
3
- export const AvailabilityConfigSchema = z.object({
4
- timezone: z.string(),
5
- meetingHours: z.string().optional(),
6
- responseSla: z.string().optional(),
7
- });
8
-
9
- export const ProfileSnapshotSchema = z.object({
10
- headline: z.string().max(500),
11
- skills: z.array(z.string().max(100)).max(50),
12
- interests: z.array(z.string().max(100)).max(50),
13
- availability: AvailabilityConfigSchema.optional(),
14
- openTo: z.array(z.string().max(100)).max(20),
15
- });
16
-
17
- export const ProfileSchema = z.object({
18
- agentId: z.string(),
19
- handle: z.string(),
20
- displayName: z.string().max(200),
21
- bio: z.string().max(2000),
22
- snapshots: z.object({
23
- public: ProfileSnapshotSchema,
24
- connected: ProfileSnapshotSchema,
25
- custom: z.record(z.string(), ProfileSnapshotSchema),
26
- }),
27
- });
28
-
29
- export type AvailabilityConfig = z.infer<typeof AvailabilityConfigSchema>;
30
- export type ProfileSnapshot = z.infer<typeof ProfileSnapshotSchema>;
31
- export type Profile = z.infer<typeof ProfileSchema>;