@primitive.ai/prim 0.1.0-alpha.124 → 0.1.0-alpha.126

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +27 -0
  2. package/dist/{chunk-5KPDY5GF.js → chunk-5D2C6RCH.js} +4 -4
  3. package/dist/{chunk-3OKVMKK2.js → chunk-6KXQQ7CQ.js} +3 -3
  4. package/dist/{chunk-EER7VG3P.js → chunk-74DQDWLW.js} +2 -2
  5. package/dist/{chunk-KMWXI7KO.js → chunk-BFYJLI7V.js} +1 -1
  6. package/dist/{chunk-TS2NX6YT.js → chunk-C5VBPHOS.js} +9 -8
  7. package/dist/{chunk-ZMH6GJUG.js → chunk-DT7E3SD5.js} +4 -4
  8. package/dist/{chunk-6W72SEXC.js → chunk-EZXIKEMA.js} +3 -3
  9. package/dist/{chunk-6WKJWW6D.js → chunk-FYYHBOOM.js} +2 -2
  10. package/dist/{chunk-DGZX3MID.js → chunk-JFWJN2ME.js} +3 -3
  11. package/dist/{chunk-A6YTFBQ4.js → chunk-KKUDAQQZ.js} +7 -8
  12. package/dist/{chunk-WLVEXOHC.js → chunk-L32WYFJT.js} +1 -1
  13. package/dist/{chunk-6VJ7C2B5.js → chunk-NBNQI3YJ.js} +2 -2
  14. package/dist/{chunk-KTXJJE5K.js → chunk-ND6TYHNI.js} +2 -2
  15. package/dist/{chunk-Q2PVD5W2.js → chunk-NJBN3WXF.js} +37 -5
  16. package/dist/{chunk-5MH2C5QG.js → chunk-O73J3KQQ.js} +7121 -5513
  17. package/dist/{chunk-EWV7VIZ3.js → chunk-PPZ56EVJ.js} +1 -1
  18. package/dist/{chunk-WQFJ5TEG.js → chunk-R6NDP7OF.js} +2 -2
  19. package/dist/{chunk-5BZWFN62.js → chunk-TI37ME2D.js} +12 -8
  20. package/dist/{chunk-6PSCGY2A.js → chunk-YP4OXKNX.js} +4 -2
  21. package/dist/{chunk-QZWLZH6D.js → chunk-ZKXNJB6U.js} +3 -3
  22. package/dist/daemon/server.js +7128 -5507
  23. package/dist/hook-runtime/daemon/server.js +7128 -5507
  24. package/dist/hook-runtime/hooks/post-commit.js +7106 -5496
  25. package/dist/hook-runtime/hooks/post-rewrite.js +7106 -5496
  26. package/dist/hook-runtime/hooks/post-tool-use.js +3595 -1977
  27. package/dist/hook-runtime/hooks/pre-commit.js +17 -7
  28. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +3796 -2184
  29. package/dist/hook-runtime/hooks/prim-hook.js +7117 -5502
  30. package/dist/hook-runtime/hooks/session-end.js +11 -4
  31. package/dist/hook-runtime/hooks/session-start.js +3584 -1970
  32. package/dist/hook-runtime/index.js +6376 -4464
  33. package/dist/hook-runtime/statusline-main.js +11 -4
  34. package/dist/hooks/post-commit.js +7 -7
  35. package/dist/hooks/post-rewrite.js +6 -6
  36. package/dist/hooks/post-tool-use.js +15 -15
  37. package/dist/hooks/pre-commit.js +4 -4
  38. package/dist/hooks/pre-tool-use-worker.js +9 -9
  39. package/dist/hooks/prim-hook.js +16 -16
  40. package/dist/hooks/session-end.js +4 -4
  41. package/dist/hooks/session-start.js +11 -11
  42. package/dist/index.js +9117 -8836
  43. package/dist/statusline-main.js +11 -4
  44. package/package.json +1 -1
@@ -3,7 +3,7 @@ import {
3
3
  isTerminalSafeText,
4
4
  terminalSafeLine,
5
5
  terminalSafeText
6
- } from "./chunk-QZWLZH6D.js";
6
+ } from "./chunk-ZKXNJB6U.js";
7
7
 
8
8
  // src/decisions/feedback.ts
9
9
  var FEEDBACK_PROTOCOL_VERSION = 2;
@@ -11,10 +11,10 @@ import {
11
11
  saveRun,
12
12
  sessionExcluded,
13
13
  sessionKey
14
- } from "./chunk-A6YTFBQ4.js";
14
+ } from "./chunk-KKUDAQQZ.js";
15
15
  import {
16
16
  packageVersion
17
- } from "./chunk-Q2PVD5W2.js";
17
+ } from "./chunk-NJBN3WXF.js";
18
18
 
19
19
  // src/demo/isolation.ts
20
20
  import { existsSync } from "fs";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  isMoveIngestRequest,
3
3
  scheduleCollectScopeRefresh
4
- } from "./chunk-5MH2C5QG.js";
4
+ } from "./chunk-O73J3KQQ.js";
5
5
  import {
6
6
  getPinnedClient,
7
7
  getSiteUrl
8
- } from "./chunk-QZWLZH6D.js";
8
+ } from "./chunk-ZKXNJB6U.js";
9
9
  import {
10
10
  machineApiUrl,
11
11
  machineJournalBucket,
12
12
  parseMachineIdentity
13
- } from "./chunk-Q2PVD5W2.js";
13
+ } from "./chunk-NJBN3WXF.js";
14
14
 
15
15
  // src/protocol/decision-lifecycle.ts
16
16
  var DECISION_LIFECYCLE_PROTOCOL_VERSION = 2;
@@ -36,7 +36,7 @@ function parseOrganizationBinding(value) {
36
36
  return { state: "server_contract_unavailable" };
37
37
  }
38
38
  const record = value;
39
- if (record.organizationBindingVersion === 2) {
39
+ if (record.organizationBindingVersion === 2 || record.organizationBindingVersion === 3) {
40
40
  try {
41
41
  const principal = record.principal;
42
42
  const identity = parseMachineIdentity(record, String(principal.clientId));
@@ -88,7 +88,8 @@ function classifyJournalBuckets(buckets, binding) {
88
88
  if (binding.captureAuthorityKind === "workos_m2m") {
89
89
  if (binding.clientId && bucket === machineJournalBucket({
90
90
  apiUrl: machineApiUrl(getSiteUrl()),
91
- clientId: binding.clientId
91
+ clientId: binding.clientId,
92
+ authorizedUserId: binding.authorizedUserId
92
93
  }))
93
94
  deliverableBuckets.add(bucket);
94
95
  else
@@ -119,13 +120,16 @@ function buildOrganizationBoundMoveRequest(batch, binding) {
119
120
  }
120
121
  const { captureActor, ...wireMove } = move;
121
122
  if (binding.captureAuthorityKind === "workos_m2m") {
122
- if (!captureActor || captureActor.clientId !== binding.clientId || captureActor.apiUrl !== machineApiUrl(getSiteUrl()) || captureActor.machineId && captureActor.machineId !== binding.machineId || captureActor.organizationId && captureActor.organizationId !== binding.organizationId)
123
+ if (!captureActor || captureActor.clientId !== binding.clientId || captureActor.authorizedUserId !== binding.authorizedUserId || captureActor.apiUrl !== machineApiUrl(getSiteUrl()) || captureActor.machineId && captureActor.machineId !== binding.machineId || captureActor.organizationId && captureActor.organizationId !== binding.organizationId)
123
124
  throw new InvalidJournalEnvelopeError();
124
125
  } else if (captureActor) throw new InvalidJournalEnvelopeError();
125
126
  return {
126
127
  ...wireMove,
127
- envelopeVersion: binding.captureAuthorityKind === "workos_m2m" ? 5 : 4,
128
- ...binding.captureAuthorityKind === "workos_m2m" ? { capturedMachineId: binding.machineId } : {},
128
+ envelopeVersion: binding.captureAuthorityKind === "workos_m2m" ? binding.authorizedUserId ? 6 : 5 : 4,
129
+ ...binding.captureAuthorityKind === "workos_m2m" ? {
130
+ capturedMachineId: binding.machineId,
131
+ ...binding.authorizedUserId ? { capturedUserId: binding.authorizedUserId } : {}
132
+ } : {},
129
133
  capturedOrganizationId,
130
134
  captureAuthorityKind: binding.captureAuthorityKind,
131
135
  decisionLifecycleProtocolVersion: DECISION_LIFECYCLE_PROTOCOL_VERSION
@@ -4,7 +4,7 @@ import {
4
4
  machineContext,
5
5
  primConfigDirectory,
6
6
  resolveAuthCredential
7
- } from "./chunk-Q2PVD5W2.js";
7
+ } from "./chunk-NJBN3WXF.js";
8
8
 
9
9
  // src/daemon/principal.ts
10
10
  import { createHash } from "crypto";
@@ -19,7 +19,9 @@ function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
19
19
  if (hasMachineConfiguration()) {
20
20
  const machine = machineContext();
21
21
  return machine ? {
22
- principalId: sha256(`${machine.issuer}\0${machine.clientId}`),
22
+ principalId: sha256(
23
+ `${machine.issuer}\0${machine.clientId}${machine.authorizedUserId ? `\0${machine.authorizedUserId}` : ""}`
24
+ ),
23
25
  organizationId: machine.workosOrganizationId,
24
26
  credentialFingerprint: sha256(machine.generation)
25
27
  } : void 0;
@@ -29,7 +29,7 @@ import {
29
29
  syncDirectory,
30
30
  withFileLock,
31
31
  workosConnectTokenEndpoint
32
- } from "./chunk-Q2PVD5W2.js";
32
+ } from "./chunk-NJBN3WXF.js";
33
33
 
34
34
  // src/decisions/identity.ts
35
35
  var PUBLIC_ID = /^dec_[0-9a-f]{8}$/u;
@@ -762,7 +762,7 @@ async function machineClient(options = {}, management = false) {
762
762
  throw new HttpError(409, "Machine identity changed; restart the operation.");
763
763
  }
764
764
  const current = await acquireMachineCredential({ signal: requestOptions.signal });
765
- if (!current || current.generation !== selected.generation || current.machineId !== selected.machineId || current.organizationId !== selected.organizationId)
765
+ if (!current || current.generation !== selected.generation || current.machineId !== selected.machineId || current.authorizedUserId !== selected.authorizedUserId || current.organizationId !== selected.organizationId)
766
766
  throw new HttpError(409, "Machine identity changed; restart the operation.");
767
767
  let response = await fetchWithToken(
768
768
  method,
@@ -777,7 +777,7 @@ async function machineClient(options = {}, management = false) {
777
777
  force: true,
778
778
  signal: requestOptions.signal
779
779
  });
780
- if (!renewed || renewed.generation !== selected.generation || renewed.machineId !== selected.machineId || renewed.organizationId !== selected.organizationId) {
780
+ if (!renewed || renewed.generation !== selected.generation || renewed.machineId !== selected.machineId || renewed.authorizedUserId !== selected.authorizedUserId || renewed.organizationId !== selected.organizationId) {
781
781
  throw new HttpError(409, "Machine identity changed; restart the operation.");
782
782
  }
783
783
  response = await fetchWithToken(