@agenticprimitives/fabric 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.
- package/CLAUDE.md +67 -0
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/case-machine.d.ts +76 -0
- package/dist/case-machine.d.ts.map +1 -0
- package/dist/case-machine.js +83 -0
- package/dist/case-machine.js.map +1 -0
- package/dist/client/index.d.ts +114 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +76 -0
- package/dist/client/index.js.map +1 -0
- package/dist/cloudflare/authority-verdict-cache.d.ts +27 -0
- package/dist/cloudflare/authority-verdict-cache.d.ts.map +1 -0
- package/dist/cloudflare/authority-verdict-cache.js +66 -0
- package/dist/cloudflare/authority-verdict-cache.js.map +1 -0
- package/dist/cloudflare/channel-store.d.ts +61 -0
- package/dist/cloudflare/channel-store.d.ts.map +1 -0
- package/dist/cloudflare/channel-store.js +124 -0
- package/dist/cloudflare/channel-store.js.map +1 -0
- package/dist/cloudflare/exchange-store.d.ts +16 -0
- package/dist/cloudflare/exchange-store.d.ts.map +1 -0
- package/dist/cloudflare/exchange-store.js +45 -0
- package/dist/cloudflare/exchange-store.js.map +1 -0
- package/dist/cloudflare/gateway-tools.d.ts +28 -0
- package/dist/cloudflare/gateway-tools.d.ts.map +1 -0
- package/dist/cloudflare/gateway-tools.js +45 -0
- package/dist/cloudflare/gateway-tools.js.map +1 -0
- package/dist/cloudflare/index.d.ts +13 -0
- package/dist/cloudflare/index.d.ts.map +1 -0
- package/dist/cloudflare/index.js +20 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/cloudflare/orchestration-runtime.d.ts +28 -0
- package/dist/cloudflare/orchestration-runtime.d.ts.map +1 -0
- package/dist/cloudflare/orchestration-runtime.js +35 -0
- package/dist/cloudflare/orchestration-runtime.js.map +1 -0
- package/dist/cloudflare/outbox-store.d.ts +24 -0
- package/dist/cloudflare/outbox-store.d.ts.map +1 -0
- package/dist/cloudflare/outbox-store.js +42 -0
- package/dist/cloudflare/outbox-store.js.map +1 -0
- package/dist/cloudflare/principal-gateway-do.d.ts +234 -0
- package/dist/cloudflare/principal-gateway-do.d.ts.map +1 -0
- package/dist/cloudflare/principal-gateway-do.js +369 -0
- package/dist/cloudflare/principal-gateway-do.js.map +1 -0
- package/dist/cloudflare/provenance-store.d.ts +9 -0
- package/dist/cloudflare/provenance-store.d.ts.map +1 -0
- package/dist/cloudflare/provenance-store.js +36 -0
- package/dist/cloudflare/provenance-store.js.map +1 -0
- package/dist/cloudflare/receipt-signer.d.ts +26 -0
- package/dist/cloudflare/receipt-signer.d.ts.map +1 -0
- package/dist/cloudflare/receipt-signer.js +69 -0
- package/dist/cloudflare/receipt-signer.js.map +1 -0
- package/dist/cloudflare/request-id-ledger.d.ts +13 -0
- package/dist/cloudflare/request-id-ledger.d.ts.map +1 -0
- package/dist/cloudflare/request-id-ledger.js +38 -0
- package/dist/cloudflare/request-id-ledger.js.map +1 -0
- package/dist/cloudflare/sql-vault.d.ts +10 -0
- package/dist/cloudflare/sql-vault.d.ts.map +1 -0
- package/dist/cloudflare/sql-vault.js +98 -0
- package/dist/cloudflare/sql-vault.js.map +1 -0
- package/dist/communicative-act.d.ts +47 -0
- package/dist/communicative-act.d.ts.map +1 -0
- package/dist/communicative-act.js +36 -0
- package/dist/communicative-act.js.map +1 -0
- package/dist/delivery-envelope.d.ts +38 -0
- package/dist/delivery-envelope.d.ts.map +1 -0
- package/dist/delivery-envelope.js +43 -0
- package/dist/delivery-envelope.js.map +1 -0
- package/dist/exchange-record.d.ts +131 -0
- package/dist/exchange-record.d.ts.map +1 -0
- package/dist/exchange-record.js +25 -0
- package/dist/exchange-record.js.map +1 -0
- package/dist/exchange-reducer.d.ts +25 -0
- package/dist/exchange-reducer.d.ts.map +1 -0
- package/dist/exchange-reducer.js +108 -0
- package/dist/exchange-reducer.js.map +1 -0
- package/dist/exchange-state.d.ts +56 -0
- package/dist/exchange-state.d.ts.map +1 -0
- package/dist/exchange-state.js +81 -0
- package/dist/exchange-state.js.map +1 -0
- package/dist/gateway-surface.d.ts +24 -0
- package/dist/gateway-surface.d.ts.map +1 -0
- package/dist/gateway-surface.js +33 -0
- package/dist/gateway-surface.js.map +1 -0
- package/dist/inbox-doc.d.ts +32 -0
- package/dist/inbox-doc.d.ts.map +1 -0
- package/dist/inbox-doc.js +57 -0
- package/dist/inbox-doc.js.map +1 -0
- package/dist/inbox-projection.d.ts +15 -0
- package/dist/inbox-projection.d.ts.map +1 -0
- package/dist/inbox-projection.js +28 -0
- package/dist/inbox-projection.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/interactions/audited.d.ts +12 -0
- package/dist/interactions/audited.d.ts.map +1 -0
- package/dist/interactions/audited.js +67 -0
- package/dist/interactions/audited.js.map +1 -0
- package/dist/interactions/builders.d.ts +24 -0
- package/dist/interactions/builders.d.ts.map +1 -0
- package/dist/interactions/builders.js +48 -0
- package/dist/interactions/builders.js.map +1 -0
- package/dist/interactions/cards.d.ts +32 -0
- package/dist/interactions/cards.d.ts.map +1 -0
- package/dist/interactions/cards.js +20 -0
- package/dist/interactions/cards.js.map +1 -0
- package/dist/interactions/index.d.ts +15 -0
- package/dist/interactions/index.d.ts.map +1 -0
- package/dist/interactions/index.js +23 -0
- package/dist/interactions/index.js.map +1 -0
- package/dist/interactions/machine.d.ts +19 -0
- package/dist/interactions/machine.d.ts.map +1 -0
- package/dist/interactions/machine.js +31 -0
- package/dist/interactions/machine.js.map +1 -0
- package/dist/interactions/mandates.d.ts +64 -0
- package/dist/interactions/mandates.d.ts.map +1 -0
- package/dist/interactions/mandates.js +62 -0
- package/dist/interactions/mandates.js.map +1 -0
- package/dist/interactions/relationship.d.ts +29 -0
- package/dist/interactions/relationship.d.ts.map +1 -0
- package/dist/interactions/relationship.js +31 -0
- package/dist/interactions/relationship.js.map +1 -0
- package/dist/interactions/risk.d.ts +39 -0
- package/dist/interactions/risk.d.ts.map +1 -0
- package/dist/interactions/risk.js +49 -0
- package/dist/interactions/risk.js.map +1 -0
- package/dist/interactions/runs.d.ts +26 -0
- package/dist/interactions/runs.d.ts.map +1 -0
- package/dist/interactions/runs.js +80 -0
- package/dist/interactions/runs.js.map +1 -0
- package/dist/interactions/store.d.ts +20 -0
- package/dist/interactions/store.d.ts.map +1 -0
- package/dist/interactions/store.js +68 -0
- package/dist/interactions/store.js.map +1 -0
- package/dist/interactions/tickets.d.ts +68 -0
- package/dist/interactions/tickets.d.ts.map +1 -0
- package/dist/interactions/tickets.js +49 -0
- package/dist/interactions/tickets.js.map +1 -0
- package/dist/interactions/types.d.ts +160 -0
- package/dist/interactions/types.d.ts.map +1 -0
- package/dist/interactions/types.js +7 -0
- package/dist/interactions/types.js.map +1 -0
- package/dist/messaging/board.d.ts +54 -0
- package/dist/messaging/board.d.ts.map +1 -0
- package/dist/messaging/board.js +90 -0
- package/dist/messaging/board.js.map +1 -0
- package/dist/messaging/conversation.d.ts +35 -0
- package/dist/messaging/conversation.d.ts.map +1 -0
- package/dist/messaging/conversation.js +72 -0
- package/dist/messaging/conversation.js.map +1 -0
- package/dist/messaging/delivery.d.ts +19 -0
- package/dist/messaging/delivery.d.ts.map +1 -0
- package/dist/messaging/delivery.js +56 -0
- package/dist/messaging/delivery.js.map +1 -0
- package/dist/messaging/directory.d.ts +32 -0
- package/dist/messaging/directory.d.ts.map +1 -0
- package/dist/messaging/directory.js +35 -0
- package/dist/messaging/directory.js.map +1 -0
- package/dist/messaging/envelope.d.ts +14 -0
- package/dist/messaging/envelope.d.ts.map +1 -0
- package/dist/messaging/envelope.js +71 -0
- package/dist/messaging/envelope.js.map +1 -0
- package/dist/messaging/hash.d.ts +19 -0
- package/dist/messaging/hash.d.ts.map +1 -0
- package/dist/messaging/hash.js +36 -0
- package/dist/messaging/hash.js.map +1 -0
- package/dist/messaging/index.d.ts +16 -0
- package/dist/messaging/index.d.ts.map +1 -0
- package/dist/messaging/index.js +29 -0
- package/dist/messaging/index.js.map +1 -0
- package/dist/messaging/projector.d.ts +58 -0
- package/dist/messaging/projector.d.ts.map +1 -0
- package/dist/messaging/projector.js +103 -0
- package/dist/messaging/projector.js.map +1 -0
- package/dist/messaging/receipts.d.ts +5 -0
- package/dist/messaging/receipts.d.ts.map +1 -0
- package/dist/messaging/receipts.js +19 -0
- package/dist/messaging/receipts.js.map +1 -0
- package/dist/messaging/rules.d.ts +84 -0
- package/dist/messaging/rules.d.ts.map +1 -0
- package/dist/messaging/rules.js +109 -0
- package/dist/messaging/rules.js.map +1 -0
- package/dist/messaging/store.d.ts +24 -0
- package/dist/messaging/store.d.ts.map +1 -0
- package/dist/messaging/store.js +120 -0
- package/dist/messaging/store.js.map +1 -0
- package/dist/messaging/types.d.ts +166 -0
- package/dist/messaging/types.d.ts.map +1 -0
- package/dist/messaging/types.js +7 -0
- package/dist/messaging/types.js.map +1 -0
- package/dist/messaging/vault-store.d.ts +37 -0
- package/dist/messaging/vault-store.d.ts.map +1 -0
- package/dist/messaging/vault-store.js +62 -0
- package/dist/messaging/vault-store.js.map +1 -0
- package/dist/record-catalog.d.ts +22 -0
- package/dist/record-catalog.d.ts.map +1 -0
- package/dist/record-catalog.js +35 -0
- package/dist/record-catalog.js.map +1 -0
- package/package.json +82 -0
- package/spec.md +15 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-doc.js","sourceRoot":"","sources":["../src/inbox-doc.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,oGAAoG;AACpG,iGAAiG;AACjG,sGAAsG;AACtG,0DAA0D;AAC1D,OAAO,EACL,4BAA4B,GAM7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,8BAA8B,GAM/B,MAAM,yBAAyB,CAAC;AAkBjC,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE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OAAO,KAAK,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACrF,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChC,UAAU,CAAC,WAAW,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC;IACvE,OAAO,IAAI,CAAC;AACd,CAAC;AAED;kGACkG;AAClG,MAAM,UAAU,kBAAkB,CAAC,GAAgB,EAAE,UAAoC;IACvF,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,GAAG,CAAC,aAAa,GAAG,CAAC,GAAG,QAAQ,EAAE,UAAU,CAAC,CAAC;QAC9C,OAAO;IACT,CAAC;IACD,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { InboxItemV1, MessageEnvelopeV1 } from './messaging/index.js';
|
|
2
|
+
import type { ExchangeEventV1 } from './exchange-record.js';
|
|
3
|
+
/** A `kind:'message'` fabric event — the inbox-relevant slice of the stream. */
|
|
4
|
+
export type InboxProjectionEvent = Extract<ExchangeEventV1, {
|
|
5
|
+
kind: 'message';
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Project a `message`-kind fabric event onto the inbox row for its message. Pure; `prev === undefined`
|
|
9
|
+
* seeds the row from the envelope. Adapts the fabric event to messaging's `MessageEventV1` and delegates to
|
|
10
|
+
* the absorbed `applyMessageEvent` reducer, so folder/unread semantics stay identical across the absorption.
|
|
11
|
+
*/
|
|
12
|
+
export declare function projectInboxItem(prev: InboxItemV1 | undefined, envelope: MessageEnvelopeV1, event: InboxProjectionEvent): InboxItemV1;
|
|
13
|
+
export { applyMessageEvent, applyInboxRules, createInMemoryInboxProjector } from './messaging/index.js';
|
|
14
|
+
export type { InboxItemV1, InboxRuleV1, InboxProjector, CreateInboxProjectorOpts, FolderKind, } from './messaging/index.js';
|
|
15
|
+
//# sourceMappingURL=inbox-projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-projection.d.ts","sourceRoot":"","sources":["../src/inbox-projection.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAkB,MAAM,sBAAsB,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,eAAe,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAEjF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,oBAAoB,GAC1B,WAAW,CAUb;AAGD,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACxG,YAAY,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,wBAAwB,EACxB,UAAU,GACX,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Inbox projection (spec 316 §b) — the per-message inbox row is a PROJECTION over the fabric event stream,
|
|
2
|
+
// resident in the recipient's vault, maintained by the gateway DO. This absorbs messaging's pure inbox
|
|
3
|
+
// reducer: a `kind:'message'` `ExchangeEventV1` (a read-receipt / lifecycle fact) folds onto an `InboxItemV1`
|
|
4
|
+
// exactly as `applyMessageEvent` does — `delivered` ⇒ unread, `read` ⇒ read, `archived`/`deleted` ⇒ folder,
|
|
5
|
+
// etc. The record reducer (`applyExchangeEvent`) records the event; THIS projects it into the inbox view.
|
|
6
|
+
//
|
|
7
|
+
// (The reducer + projector are absorbed as internal fabric surface; `messaging`'s inbox modules are retired
|
|
8
|
+
// into the fabric in the atomic messaging+interactions absorption step.)
|
|
9
|
+
import { applyMessageEvent } from './messaging/index.js';
|
|
10
|
+
/**
|
|
11
|
+
* Project a `message`-kind fabric event onto the inbox row for its message. Pure; `prev === undefined`
|
|
12
|
+
* seeds the row from the envelope. Adapts the fabric event to messaging's `MessageEventV1` and delegates to
|
|
13
|
+
* the absorbed `applyMessageEvent` reducer, so folder/unread semantics stay identical across the absorption.
|
|
14
|
+
*/
|
|
15
|
+
export function projectInboxItem(prev, envelope, event) {
|
|
16
|
+
const messageEvent = {
|
|
17
|
+
version: 'ap.message.event.v1',
|
|
18
|
+
messageId: event.messageId,
|
|
19
|
+
actor: event.actor,
|
|
20
|
+
eventType: event.eventType,
|
|
21
|
+
at: event.at,
|
|
22
|
+
evidenceRef: event.evidenceRef,
|
|
23
|
+
};
|
|
24
|
+
return applyMessageEvent(prev, envelope, messageEvent);
|
|
25
|
+
}
|
|
26
|
+
// Re-export the pure inbox-projection surface so `fabric` is the one import for inbox views + rules.
|
|
27
|
+
export { applyMessageEvent, applyInboxRules, createInMemoryInboxProjector } from './messaging/index.js';
|
|
28
|
+
//# sourceMappingURL=inbox-projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbox-projection.js","sourceRoot":"","sources":["../src/inbox-projection.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,uGAAuG;AACvG,8GAA8G;AAC9G,4GAA4G;AAC5G,0GAA0G;AAC1G,EAAE;AACF,4GAA4G;AAC5G,yEAAyE;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAOzD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAA6B,EAC7B,QAA2B,EAC3B,KAA2B;IAE3B,MAAM,YAAY,GAAmB;QACnC,OAAO,EAAE,qBAAqB;QAC9B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC;IACF,OAAO,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AACzD,CAAC;AAED,qGAAqG;AACrG,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { canTaskTransition, canExchangeTransition, expectedExecForCase, isExecCaseConsistent, EXEC_CASE_COUPLING, TRANSPORT_SET_EXEC, EXEC_STATES, CASE_STATES, } from './exchange-state.js';
|
|
2
|
+
export type { ExecState, CaseState } from './exchange-state.js';
|
|
3
|
+
export { hashExchangeEnvelope, hashIntentEnvelope, actorOf } from './exchange-record.js';
|
|
4
|
+
export type { ExchangeId, ExchangeEnvelopeV1, IntentEnvelopeV1, ExchangeRecordV1, ExchangeEventV1, ArtifactRef, } from './exchange-record.js';
|
|
5
|
+
export { performativeForKind } from './communicative-act.js';
|
|
6
|
+
export type { Performative, CommunicativeActV1, SemanticContentRef, EvidenceRef, } from './communicative-act.js';
|
|
7
|
+
export { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, } from './case-machine.js';
|
|
8
|
+
export type { FabricCaseV1, CaseFsmFields, CaseTransition, CaseTransitionEventV1, CaseResult, CaseRejection, } from './case-machine.js';
|
|
9
|
+
export { applyExchangeEvent, caseViewFromRecord } from './exchange-reducer.js';
|
|
10
|
+
export type { ExchangeApplyResult } from './exchange-reducer.js';
|
|
11
|
+
export { projectInboxItem, applyMessageEvent, applyInboxRules, createInMemoryInboxProjector, } from './inbox-projection.js';
|
|
12
|
+
export type { InboxProjectionEvent, InboxItemV1, InboxRuleV1, InboxProjector, CreateInboxProjectorOpts, FolderKind, } from './inbox-projection.js';
|
|
13
|
+
export { buildGatewaySurfaceCommitment, hashGatewaySurfaceCommitment, verifyGatewaySurfaceCommitment, } from './gateway-surface.js';
|
|
14
|
+
export type { GatewaySurfaceCommitmentV1 } from './gateway-surface.js';
|
|
15
|
+
export { buildDeliveryEnvelope, admitDeliveryEnvelope, deliveryToExchangeRecord, } from './delivery-envelope.js';
|
|
16
|
+
export type { DeliveryEnvelopeV1, DeliveryAdmission } from './delivery-envelope.js';
|
|
17
|
+
export { emptyInboxData, parseInboxData, hydrateInboxStores, mergeContextRefs, upsertConversation, type InboxDataV1, } from './inbox-doc.js';
|
|
18
|
+
export { RECORD_CATALOG, catalogEntryFor, type RecordCatalogEntry } from './record-catalog.js';
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE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AChB,kBAAkB,EAClB,KAAK,WAAW,GACjB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @agenticprimitives/fabric — the Agentic Interaction Fabric (spec 316).
|
|
2
|
+
//
|
|
3
|
+
// The A2A-native substrate that absorbs messaging (envelope/inbox) + interactions (case/run) into one
|
|
4
|
+
// canonical exchange object over a two-level exec/case FSM. Transport-agnostic core; the Cloudflare
|
|
5
|
+
// PrincipalGatewayDO adapter ships from ./cloudflare (added in a later wave).
|
|
6
|
+
//
|
|
7
|
+
// Wave 1 (this slice): the two-level exec/case state machine spine. Envelope + inbox reducers + case
|
|
8
|
+
// payloads are absorbed from messaging/interactions in the subsequent Wave-1 steps.
|
|
9
|
+
export { canTaskTransition, canExchangeTransition, expectedExecForCase, isExecCaseConsistent, EXEC_CASE_COUPLING, TRANSPORT_SET_EXEC, EXEC_STATES, CASE_STATES, } from './exchange-state.js';
|
|
10
|
+
// The canonical exchange object (spec 316 §b) — absorbs the messaging envelope + composes the two-level FSM.
|
|
11
|
+
export { hashExchangeEnvelope, hashIntentEnvelope, actorOf } from './exchange-record.js';
|
|
12
|
+
// Fabric semantic acts (spec 324 §9) — the speech-act layer over the transport envelope. Never authority.
|
|
13
|
+
export { performativeForKind } from './communicative-act.js';
|
|
14
|
+
// The absorbed case (business-substate) machine — interactions FSM re-anchored on the 11-state CaseState.
|
|
15
|
+
export { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, } from './case-machine.js';
|
|
16
|
+
// The unified exchange-event reducer (spec 316 §b/§2) — one append-only stream, one reducer over the record.
|
|
17
|
+
export { applyExchangeEvent, caseViewFromRecord } from './exchange-reducer.js';
|
|
18
|
+
// Inbox projection (spec 316 §b) — the vault-resident inbox row projected from the message-event slice.
|
|
19
|
+
export { projectInboxItem, applyMessageEvent, applyInboxRules, createInMemoryInboxProjector, } from './inbox-projection.js';
|
|
20
|
+
// Gateway surface commitment (spec 316 §4.1 / W4 — decentralized discovery; the atl:gatewayRoot preimage).
|
|
21
|
+
export { buildGatewaySurfaceCommitment, hashGatewaySurfaceCommitment, verifyGatewaySurfaceCommitment, } from './gateway-surface.js';
|
|
22
|
+
// Peer delivery envelope (spec 316 §4 / W4 — decentralized p2p delivery + admission).
|
|
23
|
+
export { buildDeliveryEnvelope, admitDeliveryEnvelope, deliveryToExchangeRecord, } from './delivery-envelope.js';
|
|
24
|
+
// The event-sourced inbox document + pure operations (spec 322 W1) — every app renders/mutates the
|
|
25
|
+
// same `inbox.data` record through these; storage and side effects stay with the caller.
|
|
26
|
+
export { emptyInboxData, parseInboxData, hydrateInboxStores, mergeContextRefs, upsertConversation, } from './inbox-doc.js';
|
|
27
|
+
// The registered record catalog (spec 322 §1) — resource pattern → type tag + ontology binding +
|
|
28
|
+
// classification floor. The catalog, never the resource string, carries the semantics.
|
|
29
|
+
export { RECORD_CATALOG, catalogEntryFor } from './record-catalog.js';
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,EAAE;AACF,sGAAsG;AACtG,oGAAoG;AACpG,8EAA8E;AAC9E,EAAE;AACF,qGAAqG;AACrG,oFAAoF;AAEpF,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAG7B,6GAA6G;AAC7G,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAUzF,0GAA0G;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAQ7D,0GAA0G;AAC1G,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAU3B,6GAA6G;AAC7G,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG/E,wGAAwG;AACxG,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAU/B,2GAA2G;AAC3G,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,sBAAsB,CAAC;AAG9B,sFAAsF;AACtF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,wBAAwB,CAAC;AAGhC,mGAAmG;AACnG,yFAAyF;AACzF,OAAO,EACL,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AAExB,iGAAiG;AACjG,uFAAuF;AACvF,OAAO,EAAE,cAAc,EAAE,eAAe,EAA2B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AuditSink } from '@agenticprimitives/audit';
|
|
2
|
+
import { type TransitionResult } from './machine.js';
|
|
3
|
+
import type { InteractionStore } from './store.js';
|
|
4
|
+
import type { InteractionTransitionEventV1 } from './types.js';
|
|
5
|
+
export interface AuditedInteractionStore {
|
|
6
|
+
applyEvent(event: InteractionTransitionEventV1): Promise<TransitionResult>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createAuditedInteractionStore(opts: {
|
|
9
|
+
store: InteractionStore;
|
|
10
|
+
audit: AuditSink;
|
|
11
|
+
}): AuditedInteractionStore;
|
|
12
|
+
//# sourceMappingURL=audited.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audited.d.ts","sourceRoot":"","sources":["../../src/interactions/audited.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAA8B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC5E;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,KAAK,EAAE,gBAAgB,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,uBAAuB,CAkE1B"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Audited transition application (spec 309 §8.8): privileged lifecycle
|
|
2
|
+
// outcomes (approve/deny/issue/deliver/revoke…) must leave a durable audit row.
|
|
3
|
+
//
|
|
4
|
+
// Fail-closed ordering: simulate (pure) → AUDIT (await) → commit. If the audit
|
|
5
|
+
// write throws, the transition is NOT committed. Rejections are audited as
|
|
6
|
+
// `denied` — a denial is a security outcome, not an error.
|
|
7
|
+
import { applyInteractionTransition } from './machine.js';
|
|
8
|
+
export function createAuditedInteractionStore(opts) {
|
|
9
|
+
const { store, audit } = opts;
|
|
10
|
+
function base(event) {
|
|
11
|
+
return {
|
|
12
|
+
id: globalThis.crypto.randomUUID(),
|
|
13
|
+
timestamp: new Date().toISOString(),
|
|
14
|
+
actor: { type: 'user', id: event.actor },
|
|
15
|
+
subject: { type: 'interaction', id: event.interactionId },
|
|
16
|
+
// Ids/hashes/decisions only — never request bodies or PII (spec 309 §9).
|
|
17
|
+
context: {
|
|
18
|
+
transition: event.transition,
|
|
19
|
+
at: event.at,
|
|
20
|
+
messageId: event.messageId ?? null,
|
|
21
|
+
authorityKind: event.authorityRef?.kind ?? null,
|
|
22
|
+
authorityHash: event.authorityRef?.hash ?? null,
|
|
23
|
+
idempotencyKey: event.idempotencyKey ?? null,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
async applyEvent(event) {
|
|
29
|
+
const current = store.getCase(event.interactionId);
|
|
30
|
+
if (!current) {
|
|
31
|
+
await audit.write({
|
|
32
|
+
...base(event),
|
|
33
|
+
action: 'interactions.transition.reject',
|
|
34
|
+
outcome: 'denied',
|
|
35
|
+
reason: 'wrong-case',
|
|
36
|
+
});
|
|
37
|
+
return { ok: false, reason: 'wrong-case' };
|
|
38
|
+
}
|
|
39
|
+
// Idempotent replay is a no-op: no new audit row, no re-application.
|
|
40
|
+
if (event.idempotencyKey !== undefined &&
|
|
41
|
+
store.listEvents(event.interactionId).some((e) => e.idempotencyKey === event.idempotencyKey)) {
|
|
42
|
+
return { ok: true, case: current };
|
|
43
|
+
}
|
|
44
|
+
// Pure simulation decides accept/reject BEFORE any side effect.
|
|
45
|
+
const simulated = applyInteractionTransition(current, event);
|
|
46
|
+
if (!simulated.ok) {
|
|
47
|
+
await audit.write({
|
|
48
|
+
...base(event),
|
|
49
|
+
action: 'interactions.transition.reject',
|
|
50
|
+
outcome: 'denied',
|
|
51
|
+
reason: simulated.reason,
|
|
52
|
+
});
|
|
53
|
+
return simulated;
|
|
54
|
+
}
|
|
55
|
+
// Audit BEFORE commit — a failed write blocks the transition.
|
|
56
|
+
const accept = base(event);
|
|
57
|
+
await audit.write({
|
|
58
|
+
...accept,
|
|
59
|
+
action: 'interactions.transition.accept',
|
|
60
|
+
outcome: 'success',
|
|
61
|
+
context: { ...accept.context, toState: simulated.case.state },
|
|
62
|
+
});
|
|
63
|
+
return store.applyEvent(event);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=audited.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audited.js","sourceRoot":"","sources":["../../src/interactions/audited.ts"],"names":[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
2
|
+
import type { CanonicalAgentId } from '@agenticprimitives/types';
|
|
3
|
+
import type { InteractionCaseV1, InteractionId, InteractionInterruptId, InteractionKind, InteractionRunId } from './types.js';
|
|
4
|
+
export declare function generateInteractionId(): InteractionId;
|
|
5
|
+
export declare function generateRunId(): InteractionRunId;
|
|
6
|
+
export declare function generateInterruptId(): InteractionInterruptId;
|
|
7
|
+
export interface CreateInteractionCaseInput {
|
|
8
|
+
id?: InteractionId;
|
|
9
|
+
kind: InteractionKind;
|
|
10
|
+
subject: string;
|
|
11
|
+
requester: CanonicalAgentId;
|
|
12
|
+
responder: CanonicalAgentId;
|
|
13
|
+
resourceOwner?: CanonicalAgentId;
|
|
14
|
+
rootMessageId: MessageId;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
expiresAt?: string;
|
|
17
|
+
}
|
|
18
|
+
/** New cases always start in `draft` — entering the lifecycle requires a
|
|
19
|
+
* signed `submit` from the requester (no pre-advanced states). */
|
|
20
|
+
export declare function createInteractionCase(input: CreateInteractionCaseInput): InteractionCaseV1;
|
|
21
|
+
/** Canonical hash of a case snapshot (sorted-key JSON, same convention as
|
|
22
|
+
* messaging/verification-receipts) — for receipts, audit rows, and dedupe. */
|
|
23
|
+
export declare function hashInteractionCase(c: InteractionCaseV1): Promise<Hex32>;
|
|
24
|
+
//# sourceMappingURL=builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../src/interactions/builders.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoC,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACrG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAUpB,wBAAgB,qBAAqB,IAAI,aAAa,CAErD;AAED,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED,wBAAgB,mBAAmB,IAAI,sBAAsB,CAE5D;AAED,MAAM,WAAW,0BAA0B;IACzC,EAAE,CAAC,EAAE,aAAa,CAAC;IACnB,IAAI,EAAE,eAAe,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,gBAAgB,CAAC;IAC5B,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;mEACmE;AACnE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,GAAG,iBAAiB,CAqB1F;AAED;+EAC+E;AAC/E,wBAAsB,mBAAmB,CAAC,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC,CAE9E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Case + payload builders and interaction hashing (spec 309 §6).
|
|
2
|
+
import { canonicalizeMessage, sha256Hex32 } from '../messaging/index.js';
|
|
3
|
+
function randomSuffix() {
|
|
4
|
+
const bytes = new Uint8Array(16);
|
|
5
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
6
|
+
return Array.from(bytes)
|
|
7
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
8
|
+
.join('');
|
|
9
|
+
}
|
|
10
|
+
export function generateInteractionId() {
|
|
11
|
+
return `int_${randomSuffix()}`;
|
|
12
|
+
}
|
|
13
|
+
export function generateRunId() {
|
|
14
|
+
return `run_${randomSuffix()}`;
|
|
15
|
+
}
|
|
16
|
+
export function generateInterruptId() {
|
|
17
|
+
return `irq_${randomSuffix()}`;
|
|
18
|
+
}
|
|
19
|
+
/** New cases always start in `draft` — entering the lifecycle requires a
|
|
20
|
+
* signed `submit` from the requester (no pre-advanced states). */
|
|
21
|
+
export function createInteractionCase(input) {
|
|
22
|
+
if (input.expiresAt !== undefined && Date.parse(input.expiresAt) <= Date.parse(input.createdAt)) {
|
|
23
|
+
throw new Error(`interaction expiry ${input.expiresAt} is not after creation ${input.createdAt}`);
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
version: 'ap.interaction.v1',
|
|
27
|
+
id: input.id ?? generateInteractionId(),
|
|
28
|
+
kind: input.kind,
|
|
29
|
+
subject: input.subject,
|
|
30
|
+
requester: input.requester,
|
|
31
|
+
responder: input.responder,
|
|
32
|
+
resourceOwner: input.resourceOwner,
|
|
33
|
+
state: 'draft',
|
|
34
|
+
createdAt: input.createdAt,
|
|
35
|
+
updatedAt: input.createdAt,
|
|
36
|
+
expiresAt: input.expiresAt,
|
|
37
|
+
rootMessageId: input.rootMessageId,
|
|
38
|
+
latestMessageId: input.rootMessageId,
|
|
39
|
+
evidenceRefs: [],
|
|
40
|
+
authorityRefs: [],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Canonical hash of a case snapshot (sorted-key JSON, same convention as
|
|
44
|
+
* messaging/verification-receipts) — for receipts, audit rows, and dedupe. */
|
|
45
|
+
export async function hashInteractionCase(c) {
|
|
46
|
+
return sha256Hex32(canonicalizeMessage(c));
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=builders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../../src/interactions/builders.ts"],"names":[],"mappings":"AAAA,iEAAiE;AAEjE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAA8B,MAAM,uBAAuB,CAAC;AAUrG,SAAS,YAAY;IACnB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,UAAU,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC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;KAClB,CAAC;AACJ,CAAC;AAED;+EAC+E;AAC/E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,CAAoB;IAC5D,OAAO,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { VaultRef } from '@agenticprimitives/vault';
|
|
2
|
+
import type { SignatureProof } from '../messaging/index.js';
|
|
3
|
+
import type { InteractionId, InteractionTransitionType } from './types.js';
|
|
4
|
+
export type ActionCardKind = 'access-request' | 'entitlement-request' | 'credential-review' | 'tool-approval' | 'delegation-review' | 'policy-exception' | 'revocation-notice' | 'needs-information';
|
|
5
|
+
/** An action the card offers. It maps to a lifecycle transition — pressing a
|
|
6
|
+
* button can only propose a SIGNED transition event; it grants nothing. */
|
|
7
|
+
export interface ActionDescriptorV1 {
|
|
8
|
+
actionId: string;
|
|
9
|
+
label: string;
|
|
10
|
+
transition: InteractionTransitionType;
|
|
11
|
+
style?: 'primary' | 'secondary' | 'destructive';
|
|
12
|
+
/** Ref to an input schema when the action needs data (needs-info answers). */
|
|
13
|
+
inputSchemaRef?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ActionCardV1 {
|
|
16
|
+
version: 'ap.interaction.action-card.v1';
|
|
17
|
+
cardId: string;
|
|
18
|
+
interactionId: InteractionId;
|
|
19
|
+
cardKind: ActionCardKind;
|
|
20
|
+
title: string;
|
|
21
|
+
summary?: string;
|
|
22
|
+
/** Vault refs the renderer MAY resolve (recipient-side authorization applies). */
|
|
23
|
+
dataRefs?: VaultRef[];
|
|
24
|
+
/** Ref to an ActionRiskMetadataV1 record backing the card's risk display. */
|
|
25
|
+
riskRef?: string;
|
|
26
|
+
allowedActions: ActionDescriptorV1[];
|
|
27
|
+
proposedBy?: SignatureProof;
|
|
28
|
+
}
|
|
29
|
+
export type CardValidationError = 'bad_version' | 'empty_title' | 'no_actions' | 'duplicate_action_id';
|
|
30
|
+
/** Structural gate before a card is stored/forwarded to a renderer. */
|
|
31
|
+
export declare function validateActionCard(card: ActionCardV1): CardValidationError[];
|
|
32
|
+
//# sourceMappingURL=cards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cards.d.ts","sourceRoot":"","sources":["../../src/interactions/cards.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,MAAM,cAAc,GACtB,gBAAgB,GAChB,qBAAqB,GACrB,mBAAmB,GACnB,eAAe,GACf,mBAAmB,GACnB,kBAAkB,GAClB,mBAAmB,GACnB,mBAAmB,CAAC;AAExB;4EAC4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,yBAAyB,CAAC;IACtC,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,aAAa,CAAC;IAChD,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,+BAA+B,CAAC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;IACtB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACrC,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,aAAa,GACb,YAAY,GACZ,qBAAqB,CAAC;AAE1B,uEAAuE;AACvE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,YAAY,GAAG,mBAAmB,EAAE,CAU5E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ActionCardV1 — the TRANSPORT half (spec 309 §6.2): a declarative
|
|
2
|
+
// approval/request card the sender PROPOSES. The receiving Home chooses how
|
|
3
|
+
// (and whether) to render it with trusted native components — never arbitrary
|
|
4
|
+
// remote UI. The render/uiProfile half lives in spec 310 (`home`).
|
|
5
|
+
/** Structural gate before a card is stored/forwarded to a renderer. */
|
|
6
|
+
export function validateActionCard(card) {
|
|
7
|
+
const errors = [];
|
|
8
|
+
if (card.version !== 'ap.interaction.action-card.v1')
|
|
9
|
+
errors.push('bad_version');
|
|
10
|
+
if (!card.title?.trim())
|
|
11
|
+
errors.push('empty_title');
|
|
12
|
+
if (!Array.isArray(card.allowedActions) || card.allowedActions.length === 0) {
|
|
13
|
+
errors.push('no_actions');
|
|
14
|
+
}
|
|
15
|
+
else if (new Set(card.allowedActions.map((a) => a.actionId)).size !== card.allowedActions.length) {
|
|
16
|
+
errors.push('duplicate_action_id');
|
|
17
|
+
}
|
|
18
|
+
return errors;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=cards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cards.js","sourceRoot":"","sources":["../../src/interactions/cards.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,4EAA4E;AAC5E,8EAA8E;AAC9E,mEAAmE;AAgDnE,uEAAuE;AACvE,MAAM,UAAU,kBAAkB,CAAC,IAAkB;IACnD,MAAM,MAAM,GAA0B,EAAE,CAAC;IACzC,IAAI,IAAI,CAAC,OAAO,KAAK,+BAA+B;QAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjF,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE;QAAE,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5E,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;SAAM,IAAI,IAAI,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;QACnG,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "@agenticprimitives/fabric/interactions";
|
|
2
|
+
export declare const PACKAGE_STATUS: "w5-mandates+tickets";
|
|
3
|
+
export declare const SPEC_REF = "specs/309-messaging-and-interactions.md";
|
|
4
|
+
export { type InteractionId, type InteractionRunId, type InteractionInterruptId, type InteractionKind, type InteractionState, type AuthorityRef, type InteractionCaseV1, type InteractionTransitionType, type InteractionTransitionEventV1, type AccessRequestV1, type EntitlementRequestV1, type ApprovalDecisionV1, type NeedsInfoV1, type CredentialDeliveryV1, type RevocationNoticeV1, type InteractionRunState, type InteractionRunEventType, type InteractionRunV1, type InteractionRunEventV1, type InteractionInterruptV1, type InteractionResumeV1, } from './types.js';
|
|
5
|
+
export { TERMINAL_STATES, isTerminalState, type TransitionRejection, type TransitionResult, applyInteractionTransition, } from './machine.js';
|
|
6
|
+
export { generateInteractionId, generateRunId, generateInterruptId, type CreateInteractionCaseInput, createInteractionCase, hashInteractionCase, } from './builders.js';
|
|
7
|
+
export { type RunRejection, type RunStepResult, startRun, raiseInterrupt, applyResume, completeRun, failRun, } from './runs.js';
|
|
8
|
+
export { type InteractionStore, createInMemoryInteractionStore } from './store.js';
|
|
9
|
+
export { type AuditedInteractionStore, createAuditedInteractionStore } from './audited.js';
|
|
10
|
+
export { type MandateResourceScope, type MandateConstraints, type InteractionMandateV1, type MandateCoverageReason, type MandateCoverageResult, checkMandateCoversRequest, type MandateVerificationReason, type MandateVerificationResult, type MandateVerificationPort, precheckMandateSignature, } from './mandates.js';
|
|
11
|
+
export { type PresentationDefinitionRef, type CredentialFormat, type PermissionTicketV1, type ClaimsChallengeV1, type ClaimsPresentationV1, type CreatePermissionTicketInput, createPermissionTicket, isTicketExpired, type ChallengeAnswerReason, type ChallengeAnswerResult, checkPresentationAnswersChallenge, } from './tickets.js';
|
|
12
|
+
export { type DataSensitivity, type ActionRiskMetadataV1, type RiskDisposition, type RiskEvaluationOpts, type RiskEvaluation, evaluateActionRisk, } from './risk.js';
|
|
13
|
+
export { type ActionCardKind, type ActionDescriptorV1, type ActionCardV1, type CardValidationError, validateActionCard, } from './cards.js';
|
|
14
|
+
export { type InteractionExchangeRecordV1, buildExchangeRecord, type RelationshipExchangePort, } from './relationship.js';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interactions/index.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,YAAY,2CAA2C,CAAC;AACrE,eAAO,MAAM,cAAc,EAAG,qBAA8B,CAAC;AAC7D,eAAO,MAAM,QAAQ,4CAA4C,CAAC;AAElE,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB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,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,KAAK,2BAA2B,EAChC,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @agenticprimitives/interactions — typed, signed, resumable request/response/
|
|
2
|
+
// approval/credential-delivery lifecycles over messages (spec 309 part B).
|
|
3
|
+
// W3 slice: InteractionCaseV1 + the fail-closed state machine, typed payloads,
|
|
4
|
+
// run/interrupt/resume primitives, case hashing, and an in-memory store with
|
|
5
|
+
// idempotent replay + deterministic expiry.
|
|
6
|
+
//
|
|
7
|
+
// Doctrine: interactions NEVER mint authority. Approval here is a lifecycle
|
|
8
|
+
// fact; the resulting delegation / entitlement / credential is produced and
|
|
9
|
+
// verified by the owning packages and carried by reference (AuthorityRef).
|
|
10
|
+
export const PACKAGE_NAME = '@agenticprimitives/fabric/interactions';
|
|
11
|
+
export const PACKAGE_STATUS = 'w5-mandates+tickets';
|
|
12
|
+
export const SPEC_REF = 'specs/309-messaging-and-interactions.md';
|
|
13
|
+
export { TERMINAL_STATES, isTerminalState, applyInteractionTransition, } from './machine.js';
|
|
14
|
+
export { generateInteractionId, generateRunId, generateInterruptId, createInteractionCase, hashInteractionCase, } from './builders.js';
|
|
15
|
+
export { startRun, raiseInterrupt, applyResume, completeRun, failRun, } from './runs.js';
|
|
16
|
+
export { createInMemoryInteractionStore } from './store.js';
|
|
17
|
+
export { createAuditedInteractionStore } from './audited.js';
|
|
18
|
+
export { checkMandateCoversRequest, precheckMandateSignature, } from './mandates.js';
|
|
19
|
+
export { createPermissionTicket, isTicketExpired, checkPresentationAnswersChallenge, } from './tickets.js';
|
|
20
|
+
export { evaluateActionRisk, } from './risk.js';
|
|
21
|
+
export { validateActionCard, } from './cards.js';
|
|
22
|
+
export { buildExchangeRecord, } from './relationship.js';
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interactions/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAC7E,4CAA4C;AAC5C,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAE3E,MAAM,CAAC,MAAM,YAAY,GAAG,wCAAwC,CAAC;AACrE,MAAM,CAAC,MAAM,cAAc,GAAG,qBAA8B,CAAC;AAC7D,MAAM,CAAC,MAAM,QAAQ,GAAG,yCAAyC,CAAC;AA0BlE,OAAO,EACL,eAAe,EACf,eAAe,EAGf,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,mBAAmB,EAEnB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAGL,QAAQ,EACR,cAAc,EACd,WAAW,EACX,WAAW,EACX,OAAO,GACR,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAyB,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EAAgC,6BAA6B,EAAE,MAAM,cAAc,CAAC;AAE3F,OAAO,EAML,yBAAyB,EAIzB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAOL,sBAAsB,EACtB,eAAe,EAGf,iCAAiC,GAClC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAML,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAKL,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,mBAAmB,GAEpB,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { isTerminalCaseState, type CaseRejection } from '../case-machine.js';
|
|
2
|
+
import type { InteractionCaseV1, InteractionState, InteractionTransitionEventV1 } from './types.js';
|
|
3
|
+
export declare const TERMINAL_STATES: readonly InteractionState[];
|
|
4
|
+
export declare const isTerminalState: typeof isTerminalCaseState;
|
|
5
|
+
export type TransitionRejection = CaseRejection;
|
|
6
|
+
export type TransitionResult = {
|
|
7
|
+
ok: true;
|
|
8
|
+
case: InteractionCaseV1;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
reason: TransitionRejection;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Apply a lifecycle event to an interaction case. Adapter over the shared 11-state case machine: maps the
|
|
15
|
+
* interactions `interactionId` onto the case `caseId` and delegates to `applyCaseTransition`. Pure,
|
|
16
|
+
* fail-closed, role-checked — unchanged semantics for the surviving transitions.
|
|
17
|
+
*/
|
|
18
|
+
export declare function applyInteractionTransition(current: InteractionCaseV1, event: InteractionTransitionEventV1): TransitionResult;
|
|
19
|
+
//# sourceMappingURL=machine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../src/interactions/machine.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,mBAAmB,EAEnB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAEpG,eAAO,MAAM,eAAe,EAAE,SAAS,gBAAgB,EAAyB,CAAC;AACjF,eAAO,MAAM,eAAe,4BAAsB,CAAC;AAEnD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACrC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,4BAA4B,GAClC,gBAAgB,CAclB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The interaction state machine — RECONCILED onto the fabric's 11-state case machine (13→11, spec 316 §2).
|
|
2
|
+
// This module no longer defines its own FSM; it ADAPTS the interactions event shape (`interactionId`) onto
|
|
3
|
+
// the shared `applyCaseTransition` and re-exports the machine surface under the interactions names, so the
|
|
4
|
+
// absorbed stores (`store.ts`/`audited.ts`) — which are transition-agnostic — keep working unchanged.
|
|
5
|
+
//
|
|
6
|
+
// `delivered`/`seen` are gone (inbox facts); `admit`/`view` are gone (inbox message events). The
|
|
7
|
+
// happy-path re-anchors on `submitted`/`triaged` (see `../case-machine.ts`).
|
|
8
|
+
import { applyCaseTransition, isTerminalCaseState, TERMINAL_CASE_STATES, } from '../case-machine.js';
|
|
9
|
+
export const TERMINAL_STATES = TERMINAL_CASE_STATES;
|
|
10
|
+
export const isTerminalState = isTerminalCaseState;
|
|
11
|
+
/**
|
|
12
|
+
* Apply a lifecycle event to an interaction case. Adapter over the shared 11-state case machine: maps the
|
|
13
|
+
* interactions `interactionId` onto the case `caseId` and delegates to `applyCaseTransition`. Pure,
|
|
14
|
+
* fail-closed, role-checked — unchanged semantics for the surviving transitions.
|
|
15
|
+
*/
|
|
16
|
+
export function applyInteractionTransition(current, event) {
|
|
17
|
+
return applyCaseTransition(current, {
|
|
18
|
+
version: 'ap.case.event.v1',
|
|
19
|
+
caseId: event.interactionId,
|
|
20
|
+
transition: event.transition,
|
|
21
|
+
actor: event.actor,
|
|
22
|
+
at: event.at,
|
|
23
|
+
messageId: event.messageId,
|
|
24
|
+
reason: event.reason,
|
|
25
|
+
idempotencyKey: event.idempotencyKey,
|
|
26
|
+
evidenceRef: event.evidenceRef,
|
|
27
|
+
authorityRef: event.authorityRef,
|
|
28
|
+
signature: event.signature,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=machine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"machine.js","sourceRoot":"","sources":["../../src/interactions/machine.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,2GAA2G;AAC3G,2GAA2G;AAC3G,sGAAsG;AACtG,EAAE;AACF,iGAAiG;AACjG,6EAA6E;AAE7E,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,CAAC,MAAM,eAAe,GAAgC,oBAAoB,CAAC;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAOnD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA0B,EAC1B,KAAmC;IAEnC,OAAO,mBAAmB,CAAC,OAAO,EAAE;QAClC,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,KAAK,CAAC,aAAa;QAC3B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,SAAS,EAAE,KAAK,CAAC,SAAS;KAC3B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CanonicalAgentId } from '@agenticprimitives/types';
|
|
2
|
+
import type { Hex32, SignatureProof } from '../messaging/index.js';
|
|
3
|
+
import type { AccessRequestV1, AuthorityRef } from './types.js';
|
|
4
|
+
export interface MandateResourceScope {
|
|
5
|
+
resource: string;
|
|
6
|
+
fields?: string[];
|
|
7
|
+
purpose?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MandateConstraints {
|
|
10
|
+
expiresAt?: string;
|
|
11
|
+
approvalRequired?: boolean;
|
|
12
|
+
onwardSharingAllowed?: boolean;
|
|
13
|
+
maxDataSensitivity?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface InteractionMandateV1 {
|
|
16
|
+
version: 'ap.interaction.mandate.v1';
|
|
17
|
+
mandateId: string;
|
|
18
|
+
/** Whose intent this is (the delegator of the underlying token). */
|
|
19
|
+
principal: CanonicalAgentId;
|
|
20
|
+
/** The agent authorized to ASK (the delegate of the underlying token). */
|
|
21
|
+
actingAgent: CanonicalAgentId;
|
|
22
|
+
relyingApp?: string;
|
|
23
|
+
allowedActions: string[];
|
|
24
|
+
resourceScope: MandateResourceScope;
|
|
25
|
+
constraints: MandateConstraints;
|
|
26
|
+
/** The delegation token that IS the authority — referenced, never embedded. */
|
|
27
|
+
delegationHash: Hex32;
|
|
28
|
+
/** Verification-receipt of the consent ceremony (spec 303). */
|
|
29
|
+
consentReceipt?: AuthorityRef;
|
|
30
|
+
signature?: SignatureProof;
|
|
31
|
+
}
|
|
32
|
+
export type MandateCoverageReason = 'covered' | 'wrong-acting-agent' | 'action-not-allowed' | 'resource-mismatch' | 'field-outside-scope' | 'purpose-mismatch' | 'mandate-expired';
|
|
33
|
+
export interface MandateCoverageResult {
|
|
34
|
+
covered: boolean;
|
|
35
|
+
reason: MandateCoverageReason;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Pure, fail-closed scope check: does this mandate's DECLARED scope cover the
|
|
39
|
+
* request? A `covered` result is necessary but NOT sufficient — callers must
|
|
40
|
+
* also verify the mandate (signature + underlying delegation + receipt) via
|
|
41
|
+
* `MandateVerificationPort` before treating it as backing authority.
|
|
42
|
+
*/
|
|
43
|
+
export declare function checkMandateCoversRequest(mandate: InteractionMandateV1, request: Pick<AccessRequestV1, 'resource' | 'actions' | 'fields' | 'purpose'>, requestedBy: CanonicalAgentId, atIso: string): MandateCoverageResult;
|
|
44
|
+
export type MandateVerificationReason = 'verified' | 'unsigned-mandate' | 'signer-not-principal' | 'delegation-invalid' | 'delegation-revoked' | 'receipt-invalid';
|
|
45
|
+
export interface MandateVerificationResult {
|
|
46
|
+
verified: boolean;
|
|
47
|
+
reason: MandateVerificationReason;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Port for the checks this package must NOT re-implement (ADR-0013 — one
|
|
51
|
+
* mechanism): delegation validity/revocation lives in `delegation` +
|
|
52
|
+
* chain-state; receipt verification lives in `verification-receipts`.
|
|
53
|
+
* Consumers wire those packages behind this port.
|
|
54
|
+
*/
|
|
55
|
+
export interface MandateVerificationPort {
|
|
56
|
+
verifyMandate(mandate: InteractionMandateV1): Promise<MandateVerificationResult>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Structural pre-check consumers run BEFORE the port: an unsigned mandate, or
|
|
60
|
+
* one whose signer is not the principal, is advisory — never authorization
|
|
61
|
+
* (spec 309 §8.11). Fail-closed.
|
|
62
|
+
*/
|
|
63
|
+
export declare function precheckMandateSignature(mandate: InteractionMandateV1): MandateVerificationResult;
|
|
64
|
+
//# sourceMappingURL=mandates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mandates.d.ts","sourceRoot":"","sources":["../../src/interactions/mandates.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;C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EtB,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,yBAAyB,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;CAClF;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,oBAAoB,GAAG,yBAAyB,CAMjG"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// InteractionMandateV1 (spec 309 §6.2) — a signed statement of PRINCIPAL
|
|
2
|
+
// intent: "agent X may request resource R for purpose P under constraints C
|
|
3
|
+
// until T", generalized from AP2's signed-mandate idea.
|
|
4
|
+
//
|
|
5
|
+
// Doctrine mapping: the AUTHORITY behind a mandate is a `delegation` token
|
|
6
|
+
// (spec 202/270) referenced by hash, plus a `verification-receipt` of the
|
|
7
|
+
// consent ceremony (spec 303). This package carries the references and does
|
|
8
|
+
// the pure SCOPE-COVERAGE check; verifying the delegation signature/revocation
|
|
9
|
+
// and the receipt is the injected verifier's job (spec 309 §8.11: an unsigned
|
|
10
|
+
// or unverified mandate is advisory metadata, never an authorization).
|
|
11
|
+
/**
|
|
12
|
+
* Pure, fail-closed scope check: does this mandate's DECLARED scope cover the
|
|
13
|
+
* request? A `covered` result is necessary but NOT sufficient — callers must
|
|
14
|
+
* also verify the mandate (signature + underlying delegation + receipt) via
|
|
15
|
+
* `MandateVerificationPort` before treating it as backing authority.
|
|
16
|
+
*/
|
|
17
|
+
export function checkMandateCoversRequest(mandate, request, requestedBy, atIso) {
|
|
18
|
+
if (requestedBy !== mandate.actingAgent) {
|
|
19
|
+
return { covered: false, reason: 'wrong-acting-agent' };
|
|
20
|
+
}
|
|
21
|
+
if (mandate.constraints.expiresAt !== undefined &&
|
|
22
|
+
Date.parse(atIso) >= Date.parse(mandate.constraints.expiresAt)) {
|
|
23
|
+
return { covered: false, reason: 'mandate-expired' };
|
|
24
|
+
}
|
|
25
|
+
if (!request.actions.every((a) => mandate.allowedActions.includes(a))) {
|
|
26
|
+
return { covered: false, reason: 'action-not-allowed' };
|
|
27
|
+
}
|
|
28
|
+
if (request.resource !== mandate.resourceScope.resource) {
|
|
29
|
+
return { covered: false, reason: 'resource-mismatch' };
|
|
30
|
+
}
|
|
31
|
+
// A field-scoped mandate denies any requested field outside its grant; an
|
|
32
|
+
// unscoped mandate covers all fields (entitlements-package convention).
|
|
33
|
+
if (mandate.resourceScope.fields !== undefined) {
|
|
34
|
+
const granted = mandate.resourceScope.fields;
|
|
35
|
+
if ((request.fields ?? []).some((f) => !granted.includes(f))) {
|
|
36
|
+
return { covered: false, reason: 'field-outside-scope' };
|
|
37
|
+
}
|
|
38
|
+
if (request.fields === undefined) {
|
|
39
|
+
// Unscoped request against a field-scoped mandate asks for everything.
|
|
40
|
+
return { covered: false, reason: 'field-outside-scope' };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (mandate.resourceScope.purpose !== undefined &&
|
|
44
|
+
request.purpose !== mandate.resourceScope.purpose) {
|
|
45
|
+
return { covered: false, reason: 'purpose-mismatch' };
|
|
46
|
+
}
|
|
47
|
+
return { covered: true, reason: 'covered' };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Structural pre-check consumers run BEFORE the port: an unsigned mandate, or
|
|
51
|
+
* one whose signer is not the principal, is advisory — never authorization
|
|
52
|
+
* (spec 309 §8.11). Fail-closed.
|
|
53
|
+
*/
|
|
54
|
+
export function precheckMandateSignature(mandate) {
|
|
55
|
+
if (mandate.signature === undefined)
|
|
56
|
+
return { verified: false, reason: 'unsigned-mandate' };
|
|
57
|
+
if (mandate.signature.signer !== mandate.principal) {
|
|
58
|
+
return { verified: false, reason: 'signer-not-principal' };
|
|
59
|
+
}
|
|
60
|
+
return { verified: true, reason: 'verified' };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=mandates.js.map
|