@agenticprimitives/intent-engagement 0.0.0-alpha.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.
@@ -0,0 +1,13 @@
1
+ export declare const PACKAGE_NAME = "@agenticprimitives/intent-engagement";
2
+ export declare const PACKAGE_STATUS: "e1-protocol-core";
3
+ export declare const SPEC_REF = "specs/336-intent-engagement-profile.md";
4
+ export type { Address, IsoTime, ProjectionKind, IntentProjectionV1, EngagementObjective, ClarificationMode, HumanChannel, ProbeProcessingModel, InteractionPolicyV1, EngagementProbeV1, EngagementAcknowledgementV1, EngagementResponseKind, QuestionV1, QuestionSetV1, HumanInteractionRequestV1, EngagementResponseContentV1, EngagementResponseV1, MandateRequirementV1, OfferTermsV1, IndicativeFulfillmentProposalV1, FulfillmentOfferV1, OfferAcceptanceV1, OfferSelectionV1, ExecuteAcceptedOfferV1, FulfillmentReceiptV1, RemoteA2AContextV1, EngagementState, OfferState, EngagementSituationV1, EngagementCampaignV1, ConformanceProfile, } from './documents.js';
5
+ export { RESPONSE_KIND_AXES } from './documents.js';
6
+ export { digestOf, wireProjection, projectionDigest, probeDigest, offerDigest, acceptanceDigest, receiptDigest } from './digests.js';
7
+ export type { EngagementRefusalCode, Refusal, Decision, EngagementCommandV1, EngagementEventV1 } from './reducer.js';
8
+ export { initialEngagement, decideEngagement, evolveEngagement, replayEngagement, stepEngagement } from './reducer.js';
9
+ export type { CandidateSource, CandidateV1, ReceiptSigner } from './ports.js';
10
+ export type { CampaignBudgetV1, OfferEvaluationV1 } from './campaign.js';
11
+ export { openCampaign, selectOffer } from './campaign.js';
12
+ export { fulfillmentReceipt } from './fulfillment.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,yCAAyC,CAAC;AACnE,eAAO,MAAM,cAAc,EAAG,kBAA2B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';
2
+ export const PACKAGE_STATUS = 'e1-protocol-core';
3
+ export const SPEC_REF = 'specs/336-intent-engagement-profile.md';
4
+ export { RESPONSE_KIND_AXES } from './documents.js';
5
+ export { digestOf, wireProjection, projectionDigest, probeDigest, offerDigest, acceptanceDigest, receiptDigest } from './digests.js';
6
+ export { initialEngagement, decideEngagement, evolveEngagement, replayEngagement, stepEngagement } from './reducer.js';
7
+ export { openCampaign, selectOffer } from './campaign.js';
8
+ export { fulfillmentReceipt } from './fulfillment.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,sCAAsC,CAAC;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,kBAA2B,CAAC;AAC1D,MAAM,CAAC,MAAM,QAAQ,GAAG,wCAAwC,CAAC;AASjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAErI,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGvH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Address, FulfillmentReceiptV1 } from './documents.js';
2
+ import type { Hex } from 'viem';
3
+ /** A candidate as discovery ASSERTED it (spec 281 shape, as data): never objective truth, never a score. Each
4
+ * dimension carries its own reasons; the order of qualification is fixed (eligibility → identity → capability
5
+ * evidence → semantic relevance → dynamic utility → relationship/policy) and a description never outranks a
6
+ * missing credential. */
7
+ export interface CandidateV1 {
8
+ agent: Address;
9
+ name?: string;
10
+ cardUrl?: string;
11
+ capabilityEvidence: Array<{
12
+ capability: string;
13
+ source: string;
14
+ observedAt: string;
15
+ }>;
16
+ relationship?: {
17
+ kind: string;
18
+ source: string;
19
+ };
20
+ reasons: string[];
21
+ }
22
+ export interface CandidateSource {
23
+ /** Candidates that declare the capability, from the public tier — evidence, never authority. */
24
+ candidatesFor(input: {
25
+ capability: string;
26
+ limit: number;
27
+ }): Promise<CandidateV1[]>;
28
+ }
29
+ /** Signs a receipt's digest as the executing agent. The key stays with the caller. */
30
+ export interface ReceiptSigner {
31
+ sign(digest: Hex): Promise<Hex>;
32
+ address: Address;
33
+ /** The receipt as signed. */
34
+ seal(receipt: Omit<FulfillmentReceiptV1, 'signature'>): Promise<FulfillmentReceiptV1>;
35
+ }
36
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC;;;0BAG0B;AAC1B,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtF,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,gGAAgG;IAChG,aAAa,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;CACrF;AAED,sFAAsF;AACtF,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,oBAAoB,EAAE,WAAW,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACvF"}
package/dist/ports.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../src/ports.ts"],"names":[],"mappings":""}
@@ -0,0 +1,185 @@
1
+ import type { Hex } from 'viem';
2
+ import type { EngagementProbeV1, EngagementResponseV1, EngagementSituationV1, EngagementState, FulfillmentOfferV1, OfferAcceptanceV1, ExecuteAcceptedOfferV1, IsoTime, Address } from './documents.js';
3
+ export type EngagementRefusalCode = 'duplicate' | 'wrong-state' | 'not-open' | 'unknown-probe' | 'nonce-mismatch' | 'probe-expired' | 'projection-mismatch' | 'intent-mismatch' | 'offer-expired' | 'offer-unsigned' | 'offer-not-firm' | 'offer-mismatch' | 'acceptance-mismatch' | 'acceptance-broadens' | 'offer-not-accepted' | 'mandate-missing' | 'mandate-mismatch' | 'not-the-provider' | 'not-the-requester' | 'campaign-deadline-passed';
4
+ export type Refusal = {
5
+ ok: false;
6
+ code: EngagementRefusalCode;
7
+ reason: string;
8
+ };
9
+ export type Decision<E> = {
10
+ ok: true;
11
+ events: E[];
12
+ } | Refusal;
13
+ export type EngagementCommandV1 = {
14
+ kind: 'SendProbe';
15
+ probe: EngagementProbeV1;
16
+ intentDigest: Hex;
17
+ idempotencyKey: string;
18
+ now: IsoTime;
19
+ } | {
20
+ kind: 'ReceiveAcknowledgement';
21
+ probeId: string;
22
+ provider: Address;
23
+ responseExpectedBy: IsoTime;
24
+ idempotencyKey: string;
25
+ now: IsoTime;
26
+ } | {
27
+ kind: 'ReceiveResponse';
28
+ response: EngagementResponseV1;
29
+ idempotencyKey: string;
30
+ now: IsoTime;
31
+ } | {
32
+ kind: 'AnswerClarification';
33
+ probe: EngagementProbeV1;
34
+ idempotencyKey: string;
35
+ now: IsoTime;
36
+ } | {
37
+ kind: 'SelectOffer';
38
+ offerId: string;
39
+ offerDigest: Hex;
40
+ because: string[];
41
+ idempotencyKey: string;
42
+ now: IsoTime;
43
+ } | {
44
+ kind: 'AcceptOffer';
45
+ acceptance: OfferAcceptanceV1;
46
+ idempotencyKey: string;
47
+ now: IsoTime;
48
+ } | {
49
+ kind: 'PresentMandate';
50
+ mandateRef: Hex;
51
+ requirementIntentDigest: Hex;
52
+ requirementOfferDigest?: Hex;
53
+ idempotencyKey: string;
54
+ now: IsoTime;
55
+ } | {
56
+ kind: 'Execute';
57
+ execute: ExecuteAcceptedOfferV1;
58
+ idempotencyKey: string;
59
+ now: IsoTime;
60
+ } | {
61
+ kind: 'NotSelected';
62
+ because: string;
63
+ idempotencyKey: string;
64
+ now: IsoTime;
65
+ } | {
66
+ kind: 'Expire';
67
+ because: string;
68
+ idempotencyKey: string;
69
+ now: IsoTime;
70
+ } | {
71
+ kind: 'Cancel';
72
+ because: string;
73
+ idempotencyKey: string;
74
+ now: IsoTime;
75
+ } | {
76
+ kind: 'WithdrawOffer';
77
+ offerId: string;
78
+ provider: Address;
79
+ idempotencyKey: string;
80
+ now: IsoTime;
81
+ } | {
82
+ kind: 'SupersedeOffer';
83
+ offer: FulfillmentOfferV1;
84
+ idempotencyKey: string;
85
+ now: IsoTime;
86
+ };
87
+ export type EngagementEventV1 = {
88
+ kind: 'ProbeSent';
89
+ engagementId: string;
90
+ probe: EngagementProbeV1;
91
+ idempotencyKey: string;
92
+ at: IsoTime;
93
+ } | {
94
+ kind: 'Acknowledged';
95
+ engagementId: string;
96
+ probeId: string;
97
+ provider: Address;
98
+ responseExpectedBy: IsoTime;
99
+ idempotencyKey: string;
100
+ at: IsoTime;
101
+ } | {
102
+ kind: 'ResponseReceived';
103
+ engagementId: string;
104
+ response: EngagementResponseV1;
105
+ idempotencyKey: string;
106
+ at: IsoTime;
107
+ } | {
108
+ kind: 'OfferIssued';
109
+ engagementId: string;
110
+ offer: FulfillmentOfferV1;
111
+ offerDigest: Hex;
112
+ idempotencyKey: string;
113
+ at: IsoTime;
114
+ } | {
115
+ kind: 'OfferSuperseded';
116
+ engagementId: string;
117
+ offerId: string;
118
+ by: string;
119
+ idempotencyKey: string;
120
+ at: IsoTime;
121
+ } | {
122
+ kind: 'OfferWithdrawn';
123
+ engagementId: string;
124
+ offerId: string;
125
+ idempotencyKey: string;
126
+ at: IsoTime;
127
+ } | {
128
+ kind: 'ClarificationAnswered';
129
+ engagementId: string;
130
+ probe: EngagementProbeV1;
131
+ idempotencyKey: string;
132
+ at: IsoTime;
133
+ } | {
134
+ kind: 'OfferSelected';
135
+ engagementId: string;
136
+ offerId: string;
137
+ offerDigest: Hex;
138
+ because: string[];
139
+ idempotencyKey: string;
140
+ at: IsoTime;
141
+ } | {
142
+ kind: 'OfferAccepted';
143
+ engagementId: string;
144
+ acceptance: OfferAcceptanceV1;
145
+ idempotencyKey: string;
146
+ at: IsoTime;
147
+ } | {
148
+ kind: 'MandatePresented';
149
+ engagementId: string;
150
+ mandateRef: Hex;
151
+ idempotencyKey: string;
152
+ at: IsoTime;
153
+ } | {
154
+ kind: 'FulfillmentLinked';
155
+ engagementId: string;
156
+ execute: ExecuteAcceptedOfferV1;
157
+ idempotencyKey: string;
158
+ at: IsoTime;
159
+ } | {
160
+ kind: 'Closed';
161
+ engagementId: string;
162
+ state: Extract<EngagementState, `closed-${string}` | 'expired' | 'cancelled'>;
163
+ because: string;
164
+ idempotencyKey: string;
165
+ at: IsoTime;
166
+ };
167
+ export declare function initialEngagement(input: {
168
+ engagementId: string;
169
+ campaignId: string;
170
+ requester: Address;
171
+ candidate: Address;
172
+ now: IsoTime;
173
+ }): EngagementSituationV1;
174
+ export declare function decideEngagement(s: EngagementSituationV1, c: EngagementCommandV1): Decision<EngagementEventV1>;
175
+ /** The state after an event. Total: an event the reducer emitted always applies. */
176
+ export declare function evolveEngagement(s: EngagementSituationV1, e: EngagementEventV1): EngagementSituationV1;
177
+ /** Replay a log. */
178
+ export declare function replayEngagement(initial: EngagementSituationV1, events: readonly EngagementEventV1[]): EngagementSituationV1;
179
+ /** Decide + evolve in one step — the shape a serving plane calls. */
180
+ export declare function stepEngagement(s: EngagementSituationV1, c: EngagementCommandV1): {
181
+ ok: true;
182
+ state: EngagementSituationV1;
183
+ events: EngagementEventV1[];
184
+ } | Refusal;
185
+ //# sourceMappingURL=reducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../src/reducer.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EACV,iBAAiB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,eAAe,EAAE,kBAAkB,EACnG,iBAAiB,EAAc,sBAAsB,EAAE,OAAO,EAAE,OAAO,EACxE,MAAM,gBAAgB,CAAC;AAIxB,MAAM,MAAM,qBAAqB,GAC7B,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,eAAe,GAAG,gBAAgB,GAAG,eAAe,GAAG,qBAAqB,GACvH,iBAAiB,GAAG,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,qBAAqB,GACpH,qBAAqB,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,mBAAmB,GAChI,0BAA0B,CAAC;AAE/B,MAAM,MAAM,OAAO,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,qBAAqB,C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E,qBAAqB,EAAE,CAAC,EAAE,iBAAiB,GAAG,qBAAqB,CA+BtG;AAED,oBAAoB;AACpB,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,SAAS,iBAAiB,EAAE,GAAG,qBAAqB,CAE5H;AAED,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,mBAAmB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,qBAAqB,CAAC;IAAC,MAAM,EAAE,iBAAiB,EAAE,CAAA;CAAE,GAAG,OAAO,CAIlK"}
@@ -0,0 +1,231 @@
1
+ import { acceptanceDigest, offerDigest, projectionDigest } from './digests.js';
2
+ const OPEN = new Set(['new', 'probe-sent', 'waiting-on-provider', 'waiting-on-requester', 'offer-open', 'offer-selected', 'awaiting-mandate']);
3
+ const refuse = (code, reason) => ({ ok: false, code, reason });
4
+ const lc = (s) => s.toLowerCase();
5
+ export function initialEngagement(input) {
6
+ return { type: 'ap.engagement-situation.v1', engagementId: input.engagementId, campaignId: input.campaignId, requester: input.requester, candidate: input.candidate, state: 'new', probes: [], responses: [], offers: {}, seen: [], updatedAt: input.now };
7
+ }
8
+ /** The latest probe that is still open to be answered, or null. */
9
+ function openProbe(s) {
10
+ return s.probes[s.probes.length - 1] ?? null;
11
+ }
12
+ export function decideEngagement(s, c) {
13
+ // IDEMPOTENCY FIRST (§6.2): at-least-once delivery is assumed; a repeat is one command, not two.
14
+ if (s.seen.includes(c.idempotencyKey))
15
+ return { ok: true, events: [] };
16
+ const id = s.engagementId;
17
+ switch (c.kind) {
18
+ case 'SendProbe': {
19
+ if (s.state !== 'new' && s.state !== 'waiting-on-requester')
20
+ return refuse('wrong-state', `a probe is sent from new or waiting-on-requester, not ${s.state}`);
21
+ const p = c.probe;
22
+ // §6.1 — every probe binds ONE intent version + ONE projection digest, and the projection is for THIS candidate.
23
+ if (lc(p.candidate) !== lc(s.candidate) || lc(p.requester) !== lc(s.requester))
24
+ return refuse('wrong-state', 'the probe names other parties than this engagement');
25
+ if (lc(p.intentDigest) !== lc(c.intentDigest))
26
+ return refuse('intent-mismatch', 'the probe does not bind the intent this campaign resolves');
27
+ if (lc(p.projection.intentDigest) !== lc(p.intentDigest))
28
+ return refuse('intent-mismatch', 'the projection is of another intent');
29
+ if (lc(projectionDigest(p.projection)) !== lc(p.projectionDigest))
30
+ return refuse('projection-mismatch', 'the probe\'s projection digest is not the digest of its projection');
31
+ if (p.projection.audience !== 'broadcast' && lc(p.projection.audience) !== lc(p.candidate))
32
+ return refuse('projection-mismatch', 'an engagement projection is audience-bound to the candidate it is sent to');
33
+ return { ok: true, events: [{ kind: 'ProbeSent', engagementId: id, probe: p, idempotencyKey: c.idempotencyKey, at: c.now }] };
34
+ }
35
+ case 'ReceiveAcknowledgement': {
36
+ const p = openProbe(s);
37
+ if (!p || p.probeId !== c.probeId)
38
+ return refuse('unknown-probe', 'the acknowledgement names no open probe');
39
+ if (lc(c.provider) !== lc(s.candidate))
40
+ return refuse('not-the-provider', 'acknowledged by somebody other than the candidate');
41
+ if (s.state !== 'probe-sent')
42
+ return refuse('wrong-state', `an acknowledgement follows a probe, not ${s.state}`);
43
+ return { ok: true, events: [{ kind: 'Acknowledged', engagementId: id, probeId: c.probeId, provider: c.provider, responseExpectedBy: c.responseExpectedBy, idempotencyKey: c.idempotencyKey, at: c.now }] };
44
+ }
45
+ case 'ReceiveResponse': {
46
+ const r = c.response;
47
+ if (!OPEN.has(s.state))
48
+ return refuse('not-open', `this engagement is ${s.state}`);
49
+ const p = s.probes.find((x) => x.probeId === r.inReplyTo);
50
+ if (!p)
51
+ return refuse('unknown-probe', 'the response names no probe of this engagement (§6.2: a valid inReplyTo is required)');
52
+ if (p !== openProbe(s))
53
+ return refuse('unknown-probe', 'the response answers a probe that a later one replaced');
54
+ if (lc(r.provider) !== lc(s.candidate))
55
+ return refuse('not-the-provider', 'the response is from somebody other than the candidate');
56
+ if (r.probeNonce !== p.probeNonce)
57
+ return refuse('nonce-mismatch', 'the response does not echo the probe\'s single-use nonce');
58
+ if (s.responses.some((x) => x.responseId === r.responseId || x.idempotencyKey === r.idempotencyKey))
59
+ return { ok: true, events: [] };
60
+ // §6.2 — an EXPIRED probe cannot produce an acceptable offer.
61
+ const expired = Date.parse(c.now) > Date.parse(p.replyBy);
62
+ const events = [{ kind: 'ResponseReceived', engagementId: id, response: r, idempotencyKey: c.idempotencyKey, at: c.now }];
63
+ if (r.content.kind === 'offer') {
64
+ if (expired)
65
+ return refuse('probe-expired', `the probe's reply-by (${p.replyBy}) has passed — an expired probe cannot produce an acceptable offer`);
66
+ const o = r.content.offer;
67
+ if (o.type === 'ap.fulfillment-offer.v1') {
68
+ // §6.3 — a FIRM offer is provider-signed, bound to the projection reviewed and the intent probed.
69
+ if (!o.signature || o.signature === '0x')
70
+ return refuse('offer-unsigned', 'a firm offer is signed by the provider');
71
+ if (lc(o.provider) !== lc(s.candidate) || lc(o.requester) !== lc(s.requester))
72
+ return refuse('not-the-provider', 'the offer names other parties');
73
+ if (lc(o.basisOfOffer) !== lc(p.projectionDigest))
74
+ return refuse('offer-mismatch', 'the offer\'s basis is not the projection this probe carried');
75
+ if (lc(o.intentDigest) !== lc(p.intentDigest) || lc(o.requirement.intentDigest) !== lc(p.intentDigest))
76
+ return refuse('offer-mismatch', 'the offer (or its requirement) binds another intent');
77
+ if (Date.parse(o.expiresAt) <= Date.parse(c.now))
78
+ return refuse('offer-expired', 'the offer has already expired');
79
+ events.push({ kind: 'OfferIssued', engagementId: id, offer: o, offerDigest: offerDigest(o), idempotencyKey: `${c.idempotencyKey}:offer`, at: c.now });
80
+ }
81
+ // An indicative proposal is recorded as a response and moves the engagement to waiting-on-requester.
82
+ }
83
+ return { ok: true, events };
84
+ }
85
+ case 'AnswerClarification': {
86
+ if (s.state !== 'waiting-on-requester')
87
+ return refuse('wrong-state', 'nothing asked for clarification');
88
+ return decideEngagement({ ...s, state: 'new' }, { kind: 'SendProbe', probe: c.probe, intentDigest: c.probe.intentDigest, idempotencyKey: c.idempotencyKey, now: c.now });
89
+ }
90
+ case 'SelectOffer': {
91
+ if (s.state !== 'offer-open')
92
+ return refuse('wrong-state', `an offer is selected while offers are open, not ${s.state}`);
93
+ const entry = s.offers[c.offerId];
94
+ if (!entry || entry.state !== 'issued')
95
+ return refuse('offer-mismatch', 'no issued offer by that id');
96
+ if (lc(offerDigest(entry.offer)) !== lc(c.offerDigest))
97
+ return refuse('offer-mismatch', 'the selection pins a digest that is not this offer\'s');
98
+ if (Date.parse(entry.offer.expiresAt) <= Date.parse(c.now))
99
+ return refuse('offer-expired', 'the offer expired before it was selected');
100
+ return { ok: true, events: [{ kind: 'OfferSelected', engagementId: id, offerId: c.offerId, offerDigest: c.offerDigest, because: c.because, idempotencyKey: c.idempotencyKey, at: c.now }] };
101
+ }
102
+ case 'AcceptOffer': {
103
+ if (s.state !== 'offer-selected')
104
+ return refuse('wrong-state', `an offer is accepted after it is selected, not ${s.state}`);
105
+ const a = c.acceptance;
106
+ const entry = s.offers[a.offerId];
107
+ if (!entry || entry.state !== 'issued')
108
+ return refuse('offer-mismatch', 'no issued offer by that id');
109
+ // §6.3 — acceptance PINS the digest and cannot broaden: a differing acceptance is a counter-proposal.
110
+ if (lc(a.offerDigest) !== lc(offerDigest(entry.offer)))
111
+ return refuse('acceptance-broadens', 'the acceptance does not pin the offer as issued — a differing acceptance is a counter-proposal, not an acceptance');
112
+ if (lc(a.requester) !== lc(s.requester))
113
+ return refuse('not-the-requester', 'accepted by somebody other than the requester');
114
+ if (!a.signature || a.signature === '0x')
115
+ return refuse('acceptance-mismatch', 'an acceptance is signed by the requester');
116
+ if (Date.parse(entry.offer.expiresAt) <= Date.parse(c.now))
117
+ return refuse('offer-expired', 'the offer expired before acceptance');
118
+ return { ok: true, events: [{ kind: 'OfferAccepted', engagementId: id, acceptance: a, idempotencyKey: c.idempotencyKey, at: c.now }] };
119
+ }
120
+ case 'PresentMandate': {
121
+ if (s.state !== 'awaiting-mandate')
122
+ return refuse('wrong-state', `a mandate is presented after acceptance, not in ${s.state}`);
123
+ const acc = s.acceptance;
124
+ const entry = s.offers[acc.offerId];
125
+ // §6.6 — the mandate binds THIS intent and THIS offer; a mandate for another is not this engagement's.
126
+ if (lc(c.requirementIntentDigest) !== lc(entry.offer.intentDigest))
127
+ return refuse('mandate-mismatch', 'the mandate binds another intent');
128
+ if (c.requirementOfferDigest && lc(c.requirementOfferDigest) !== lc(acc.offerDigest))
129
+ return refuse('mandate-mismatch', 'the mandate authorizes another offer');
130
+ return { ok: true, events: [{ kind: 'MandatePresented', engagementId: id, mandateRef: c.mandateRef, idempotencyKey: c.idempotencyKey, at: c.now }] };
131
+ }
132
+ case 'Execute': {
133
+ // §3.9 — a fulfillment task is created only after: accepted offer + valid acceptance + mandate present.
134
+ if (s.state !== 'awaiting-mandate' || !s.mandateRef)
135
+ return refuse('mandate-missing', 'a fulfillment task cannot exist without its required mandate');
136
+ const e = c.execute;
137
+ const acc = s.acceptance;
138
+ const entry = s.offers[acc.offerId];
139
+ if (e.offerId !== acc.offerId || lc(e.offerDigest) !== lc(offerDigest(entry.offer)))
140
+ return refuse('offer-mismatch', 'execute names another offer');
141
+ if (e.acceptanceId !== acc.acceptanceId || lc(e.acceptanceDigest) !== lc(acceptanceDigest(acc)))
142
+ return refuse('acceptance-mismatch', 'execute names another acceptance');
143
+ if (lc(e.mandateRef) !== lc(s.mandateRef))
144
+ return refuse('mandate-mismatch', 'execute presents another mandate than the one presented');
145
+ return { ok: true, events: [{ kind: 'FulfillmentLinked', engagementId: id, execute: e, idempotencyKey: c.idempotencyKey, at: c.now }] };
146
+ }
147
+ case 'WithdrawOffer': {
148
+ const entry = s.offers[c.offerId];
149
+ if (!entry || entry.state !== 'issued')
150
+ return refuse('offer-mismatch', 'no issued offer to withdraw');
151
+ if (lc(c.provider) !== lc(entry.offer.provider))
152
+ return refuse('not-the-provider', 'only the provider withdraws its offer');
153
+ return { ok: true, events: [{ kind: 'OfferWithdrawn', engagementId: id, offerId: c.offerId, idempotencyKey: c.idempotencyKey, at: c.now }] };
154
+ }
155
+ case 'SupersedeOffer': {
156
+ const o = c.offer;
157
+ if (!o.supersedes)
158
+ return refuse('offer-mismatch', 'a superseding offer names what it supersedes');
159
+ const old = s.offers[o.supersedes];
160
+ if (!old || old.state !== 'issued')
161
+ return refuse('offer-mismatch', 'the superseded offer is not open');
162
+ if (lc(o.provider) !== lc(old.offer.provider))
163
+ return refuse('not-the-provider', 'only the provider revises its offer');
164
+ if (o.revision <= old.offer.revision)
165
+ return refuse('offer-mismatch', 'a revision supersedes with a higher revision number');
166
+ if (!o.signature || o.signature === '0x')
167
+ return refuse('offer-unsigned', 'a firm offer is signed by the provider');
168
+ return { ok: true, events: [
169
+ { kind: 'OfferSuperseded', engagementId: id, offerId: o.supersedes, by: o.offerId, idempotencyKey: `${c.idempotencyKey}:old`, at: c.now },
170
+ { kind: 'OfferIssued', engagementId: id, offer: o, offerDigest: offerDigest(o), idempotencyKey: c.idempotencyKey, at: c.now },
171
+ ] };
172
+ }
173
+ case 'NotSelected':
174
+ case 'Expire':
175
+ case 'Cancel': {
176
+ if (!OPEN.has(s.state))
177
+ return refuse('not-open', `this engagement is already ${s.state}`);
178
+ const state = c.kind === 'NotSelected' ? 'closed-not-selected' : c.kind === 'Expire' ? 'expired' : 'cancelled';
179
+ return { ok: true, events: [{ kind: 'Closed', engagementId: id, state, because: c.because, idempotencyKey: c.idempotencyKey, at: c.now }] };
180
+ }
181
+ }
182
+ }
183
+ /** The state after an event. Total: an event the reducer emitted always applies. */
184
+ export function evolveEngagement(s, e) {
185
+ const seen = s.seen.includes(e.idempotencyKey) ? s.seen : [...s.seen, e.idempotencyKey];
186
+ const base = { ...s, seen, updatedAt: e.at };
187
+ switch (e.kind) {
188
+ case 'ProbeSent': return { ...base, state: 'probe-sent', probes: [...s.probes, e.probe] };
189
+ case 'Acknowledged': return { ...base, state: 'waiting-on-provider' };
190
+ case 'ResponseReceived': {
191
+ const k = e.response.content.kind;
192
+ const responses = [...s.responses, e.response];
193
+ // §3.5 — every kind is a legitimate, recordable outcome; the closing ones close with THEIR reason.
194
+ if (k === 'decline')
195
+ return { ...base, responses, lastResponseKind: k, state: 'closed-declined', closeReason: e.response.content.reason };
196
+ if (k === 'referral')
197
+ return { ...base, responses, lastResponseKind: k, state: 'closed-referred', closeReason: `referred to ${e.response.content.to}` };
198
+ if (k === 'temporarily-unavailable')
199
+ return { ...base, responses, lastResponseKind: k, state: 'closed-unavailable', closeReason: e.response.content.until ? `until ${e.response.content.until}` : 'temporarily unavailable' };
200
+ if (k === 'needs-clarification' || k === 'human-ux-required')
201
+ return { ...base, responses, lastResponseKind: k, state: 'waiting-on-requester' };
202
+ // an offer: the firm one is issued by its own event; an indicative proposal is an answer that waits on us.
203
+ return { ...base, responses, lastResponseKind: k, state: e.response.content.offer.type === 'ap.fulfillment-offer.v1' ? s.state : 'waiting-on-requester' };
204
+ }
205
+ case 'OfferIssued': return { ...base, state: 'offer-open', offers: { ...s.offers, [e.offer.offerId]: { offer: e.offer, state: 'issued' } } };
206
+ case 'OfferSuperseded': return { ...base, offers: { ...s.offers, [e.offerId]: { ...s.offers[e.offerId], state: 'superseded' } } };
207
+ case 'OfferWithdrawn': {
208
+ const offers = { ...s.offers, [e.offerId]: { ...s.offers[e.offerId], state: 'withdrawn' } };
209
+ const anyOpen = Object.values(offers).some((o) => o.state === 'issued');
210
+ return { ...base, offers, state: anyOpen ? s.state : (s.state === 'offer-open' ? 'waiting-on-provider' : s.state) };
211
+ }
212
+ case 'ClarificationAnswered': return { ...base, state: 'probe-sent', probes: [...s.probes, e.probe] };
213
+ case 'OfferSelected': return { ...base, state: 'offer-selected' };
214
+ case 'OfferAccepted': return { ...base, state: 'awaiting-mandate', acceptance: e.acceptance, offers: { ...s.offers, [e.acceptance.offerId]: { ...s.offers[e.acceptance.offerId], state: 'accepted' } } };
215
+ case 'MandatePresented': return { ...base, mandateRef: e.mandateRef };
216
+ case 'FulfillmentLinked': return { ...base, state: 'fulfillment-linked', taskRef: e.execute.idempotencyKey };
217
+ case 'Closed': return { ...base, state: e.state, closeReason: e.because };
218
+ }
219
+ }
220
+ /** Replay a log. */
221
+ export function replayEngagement(initial, events) {
222
+ return events.reduce(evolveEngagement, initial);
223
+ }
224
+ /** Decide + evolve in one step — the shape a serving plane calls. */
225
+ export function stepEngagement(s, c) {
226
+ const d = decideEngagement(s, c);
227
+ if (!d.ok)
228
+ return d;
229
+ return { ok: true, state: replayEngagement(s, d.events), events: d.events };
230
+ }
231
+ //# sourceMappingURL=reducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reducer.js","sourceRoot":"","sources":["../src/reducer.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AA2C/E,MAAM,IAAI,GAAiC,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAC7K,MAAM,MAAM,GAAG,CAAC,IAA2B,EAAE,MAAc,EAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACvG,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAE1C,MAAM,UAAU,iBAAiB,CAAC,KAAyG;IACzI,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,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M,KAAK,kBAAkB,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC;QACtE,KAAK,mBAAmB,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,oBAAoB,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;QAC7G,KAAK,QAAQ,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAC5E,CAAC;AACH,CAAC;AAED,oBAAoB;AACpB,MAAM,UAAU,gBAAgB,CAAC,OAA8B,EAAE,MAAoC;IACnG,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,cAAc,CAAC,CAAwB,EAAE,CAAsB;IAC7E,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,IAAI,CAAC,CAAC,CAAC,EAAE;QAAE,OAAO,CAAC,CAAC;IACpB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AAC9E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@agenticprimitives/intent-engagement",
3
+ "version": "0.0.0-alpha.1",
4
+ "description": "Intent engagement protocol core (spec 336 §8): probe → response → offer → acceptance → mandate requirement → execute → receipt as pure documents, JCS digests, and two deterministic reducers. Transport-free; grants nothing.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ }
11
+ },
12
+ "files": [
13
+ "LICENSE",
14
+ "dist",
15
+ "spec.md",
16
+ "README.md"
17
+ ],
18
+ "devDependencies": {
19
+ "vitest": "^4.1.8"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
27
+ "directory": "packages/intent-engagement"
28
+ },
29
+ "license": "MIT",
30
+ "keywords": [
31
+ "agentic",
32
+ "primitives",
33
+ "intent",
34
+ "engagement",
35
+ "offer",
36
+ "mandate"
37
+ ],
38
+ "dependencies": {
39
+ "viem": "^2.52.2",
40
+ "@agenticprimitives/types": "1.0.0-alpha.22"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.build.json",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit",
45
+ "test": "vitest run",
46
+ "test:unit": "vitest run test/unit --passWithNoTests",
47
+ "test:watch": "vitest",
48
+ "clean": "rm -rf dist"
49
+ }
50
+ }
package/spec.md ADDED
@@ -0,0 +1,5 @@
1
+ # @agenticprimitives/intent-engagement — spec pointer
2
+
3
+ The architect-of-record is [spec 336 — Intent Engagement Profile](../../specs/336-intent-engagement-profile.md) (§8 names this package) and,
4
+ for the harness wave that built it, [spec 384 — Engagement core](../../specs/384-engagement-core-probe-offer-mandate.md).
5
+ This package is the transport-free protocol core: documents, digests, the engagement and offer reducers, reason codes, ports.