ezlogs-nextjs 0.1.2 → 0.1.3

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.
@@ -1,4 +1,4 @@
1
- import { a as ActorFromRequest } from '../configuration-aUYgA8-h.cjs';
1
+ import { a as ActorFromRequest } from '../configuration-3Pei_XZ_.cjs';
2
2
 
3
3
  /**
4
4
  * Returns an `ActorFromRequest` that pulls the current user from
@@ -1,4 +1,4 @@
1
- import { a as ActorFromRequest } from '../configuration-aUYgA8-h.js';
1
+ import { a as ActorFromRequest } from '../configuration-3Pei_XZ_.js';
2
2
 
3
3
  /**
4
4
  * Returns an `ActorFromRequest` that pulls the current user from
@@ -30,6 +30,23 @@ interface ActorContext {
30
30
  * absent. Auto-detection from the User-Agent fills this when the
31
31
  * request looks like it came from an LLM client. */
32
32
  kind?: ActorKind;
33
+ /** The human principal who authorized this agent / hybrid action.
34
+ * Optional — only meaningful when `kind` is `"hybrid"` (or sometimes
35
+ * `"agent"` if the customer wants to surface the human owner of
36
+ * the running agent). Drives the "Claude updated employee, on
37
+ * behalf of Razvan" framing on the server's AiExplainer. */
38
+ principal?: ActorPrincipal;
39
+ }
40
+ /**
41
+ * Sub-actor representing the human principal who authorized an agent
42
+ * action. Always human; mirrors the shape of `ActorContext` minus the
43
+ * `kind` field (principals don't nest indefinitely).
44
+ */
45
+ interface ActorPrincipal {
46
+ /** Stable identifier (e.g. `user.id`). REQUIRED. */
47
+ id: string;
48
+ /** Human-readable label. Optional. */
49
+ label?: string;
33
50
  }
34
51
  /**
35
52
  * Minimal request-shape contract for `actorFromRequest`. We don't import
@@ -204,4 +221,4 @@ interface InitOptions {
204
221
  */
205
222
  type DatabaseReader = (sql: string, params: ReadonlyArray<unknown>) => Promise<unknown>;
206
223
 
207
- export type { ActorContext as A, DisplayNameMap as D, InitOptions as I, ActorFromRequest as a };
224
+ export type { ActorContext as A, DisplayNameMap as D, InitOptions as I, ActorFromRequest as a, ActorPrincipal as b };
@@ -30,6 +30,23 @@ interface ActorContext {
30
30
  * absent. Auto-detection from the User-Agent fills this when the
31
31
  * request looks like it came from an LLM client. */
32
32
  kind?: ActorKind;
33
+ /** The human principal who authorized this agent / hybrid action.
34
+ * Optional — only meaningful when `kind` is `"hybrid"` (or sometimes
35
+ * `"agent"` if the customer wants to surface the human owner of
36
+ * the running agent). Drives the "Claude updated employee, on
37
+ * behalf of Razvan" framing on the server's AiExplainer. */
38
+ principal?: ActorPrincipal;
39
+ }
40
+ /**
41
+ * Sub-actor representing the human principal who authorized an agent
42
+ * action. Always human; mirrors the shape of `ActorContext` minus the
43
+ * `kind` field (principals don't nest indefinitely).
44
+ */
45
+ interface ActorPrincipal {
46
+ /** Stable identifier (e.g. `user.id`). REQUIRED. */
47
+ id: string;
48
+ /** Human-readable label. Optional. */
49
+ label?: string;
33
50
  }
34
51
  /**
35
52
  * Minimal request-shape contract for `actorFromRequest`. We don't import
@@ -204,4 +221,4 @@ interface InitOptions {
204
221
  */
205
222
  type DatabaseReader = (sql: string, params: ReadonlyArray<unknown>) => Promise<unknown>;
206
223
 
207
- export type { ActorContext as A, DisplayNameMap as D, InitOptions as I, ActorFromRequest as a };
224
+ export type { ActorContext as A, DisplayNameMap as D, InitOptions as I, ActorFromRequest as a, ActorPrincipal as b };
package/dist/index.cjs CHANGED
@@ -472,6 +472,23 @@ function validateActor(input) {
472
472
  result.kind = kind;
473
473
  }
474
474
  }
475
+ const principal = sanitizePrincipal(obj.principal);
476
+ if (principal) result.principal = principal;
477
+ return result;
478
+ }
479
+ function sanitizePrincipal(input) {
480
+ if (input === null || input === void 0) return null;
481
+ if (typeof input !== "object") return null;
482
+ if (Array.isArray(input)) return null;
483
+ const obj = input;
484
+ const rawId = obj.id;
485
+ if (rawId === null || rawId === void 0) return null;
486
+ const id = String(rawId);
487
+ if (id === "") return null;
488
+ const result = { id };
489
+ if (obj.label !== void 0 && obj.label !== null) {
490
+ result.label = String(obj.label);
491
+ }
475
492
  return result;
476
493
  }
477
494
  function describe2(value) {
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InitOptions } from './configuration-aUYgA8-h.cjs';
2
- export { A as ActorContext, a as ActorFromRequest, D as DisplayNameMap } from './configuration-aUYgA8-h.cjs';
1
+ import { I as InitOptions } from './configuration-3Pei_XZ_.cjs';
2
+ export { A as ActorContext, a as ActorFromRequest, b as ActorPrincipal, D as DisplayNameMap } from './configuration-3Pei_XZ_.cjs';
3
3
 
4
4
  /**
5
5
  * EventBuilder — port of ez_logs_agent/lib/ez_logs_agent/event_builder.rb.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InitOptions } from './configuration-aUYgA8-h.js';
2
- export { A as ActorContext, a as ActorFromRequest, D as DisplayNameMap } from './configuration-aUYgA8-h.js';
1
+ import { I as InitOptions } from './configuration-3Pei_XZ_.js';
2
+ export { A as ActorContext, a as ActorFromRequest, b as ActorPrincipal, D as DisplayNameMap } from './configuration-3Pei_XZ_.js';
3
3
 
4
4
  /**
5
5
  * EventBuilder — port of ez_logs_agent/lib/ez_logs_agent/event_builder.rb.
package/dist/index.js CHANGED
@@ -470,6 +470,23 @@ function validateActor(input) {
470
470
  result.kind = kind;
471
471
  }
472
472
  }
473
+ const principal = sanitizePrincipal(obj.principal);
474
+ if (principal) result.principal = principal;
475
+ return result;
476
+ }
477
+ function sanitizePrincipal(input) {
478
+ if (input === null || input === void 0) return null;
479
+ if (typeof input !== "object") return null;
480
+ if (Array.isArray(input)) return null;
481
+ const obj = input;
482
+ const rawId = obj.id;
483
+ if (rawId === null || rawId === void 0) return null;
484
+ const id = String(rawId);
485
+ if (id === "") return null;
486
+ const result = { id };
487
+ if (obj.label !== void 0 && obj.label !== null) {
488
+ result.label = String(obj.label);
489
+ }
473
490
  return result;
474
491
  }
475
492
  function describe2(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezlogs-nextjs",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "EZLogs agent for Next.js — capture HTTP, database, and background-job events as plain-English Action cards.",
5
5
  "license": "MIT",
6
6
  "author": "EZLogs",