@jr2/agent-protocol 0.6.0 → 0.7.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jr2/agent-protocol",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "The jr2 Orchestrator↔Agent wire: defineEvent and nothing else.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -103,8 +103,30 @@ const NAME_RE = /^[a-zA-Z0-9_-]+$/;
103
103
  */
104
104
  export const SENDER_KEY = "sender";
105
105
 
106
- /** Who delivered an event: an Agent by its slot, or a Gate by its invoke id (ADR-0015). */
107
- export type Sender = { readonly party: "agent" | "gate"; readonly id: string };
106
+ /**
107
+ * Who delivered an event: an Agent by its slot, or a Gate by its invoke id (ADR-0015).
108
+ *
109
+ * A Gate's event also carries the Caller that answered it (ADR-0011, ADR-0078): `via` and `name`
110
+ * name it, `onBehalfOf` is the party that it says it acts for, and `checked` names the fields that
111
+ * jr2 verified. `via` and `name` are always checked, because an authenticator made them;
112
+ * `onBehalfOf` is checked only for a Hook, whose signature covers the payload that it comes from.
113
+ * An event that a Gate gives with no Caller (its `look`) has none of these fields.
114
+ */
115
+ export type Sender = {
116
+ readonly party: "agent" | "gate";
117
+ readonly id: string;
118
+ /** The authenticator that made the Caller: `token`, `jwt` or `hook`. A Gate's event only. */
119
+ readonly via?: "token" | "jwt" | "hook";
120
+ /** The Caller's name for that authenticator. A Gate's event only. */
121
+ readonly name?: string;
122
+ /** The party that the Caller says it acts for. A claim, unless `checked` names it. */
123
+ readonly onBehalfOf?: string;
124
+ /** The fields of the Caller that jr2 verified. */
125
+ readonly checked?: readonly SenderCallerField[];
126
+ };
127
+
128
+ /** A field of a {@link Sender}'s Caller that jr2 can verify. */
129
+ export type SenderCallerField = "via" | "name" | "onBehalfOf";
108
130
 
109
131
  /**
110
132
  * Define one workflow event: an event that an Agent or the caller of a Gate may send into your