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

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 (47) hide show
  1. package/README.md +81 -5
  2. package/dist/{chunk-5ME3WD3P.js → chunk-3OKVMKK2.js} +6 -3
  3. package/dist/chunk-5BZWFN62.js +206 -0
  4. package/dist/{chunk-QG3GASJO.js → chunk-5KPDY5GF.js} +4 -4
  5. package/dist/{chunk-HLMC7VS4.js → chunk-5MH2C5QG.js} +3878 -2644
  6. package/dist/{chunk-NMZSCSMY.js → chunk-6PSCGY2A.js} +11 -1
  7. package/dist/{chunk-OXW6PSPT.js → chunk-6VJ7C2B5.js} +15 -3
  8. package/dist/{chunk-DQ4I3FLF.js → chunk-6W72SEXC.js} +3 -3
  9. package/dist/{chunk-4M23K2KZ.js → chunk-6WKJWW6D.js} +2 -2
  10. package/dist/{chunk-JYPVPYW3.js → chunk-A6YTFBQ4.js} +3 -3
  11. package/dist/{chunk-7LXRFXZG.js → chunk-DGZX3MID.js} +3 -3
  12. package/dist/{chunk-4NUGCUQC.js → chunk-EER7VG3P.js} +2 -2
  13. package/dist/{chunk-JZC2LHS6.js → chunk-EWV7VIZ3.js} +1 -1
  14. package/dist/{chunk-WN7OURQ3.js → chunk-KMWXI7KO.js} +1 -1
  15. package/dist/{chunk-HG7FJK7R.js → chunk-KTXJJE5K.js} +2 -2
  16. package/dist/{chunk-4GYJHN26.js → chunk-Q2PVD5W2.js} +1575 -549
  17. package/dist/{chunk-S3ZIMGXV.js → chunk-QZWLZH6D.js} +76 -2
  18. package/dist/{chunk-ZQ7UK5US.js → chunk-TS2NX6YT.js} +31 -9
  19. package/dist/{chunk-AKGRY7OU.js → chunk-WLVEXOHC.js} +145 -63
  20. package/dist/{chunk-FT673ALA.js → chunk-WQFJ5TEG.js} +2 -2
  21. package/dist/{chunk-T2T45KF6.js → chunk-ZMH6GJUG.js} +4 -4
  22. package/dist/daemon/server.js +7795 -5449
  23. package/dist/hook-runtime/daemon/server.js +7795 -5449
  24. package/dist/hook-runtime/hooks/post-commit.js +5828 -4329
  25. package/dist/hook-runtime/hooks/post-rewrite.js +4331 -2833
  26. package/dist/hook-runtime/hooks/post-tool-use.js +5242 -2892
  27. package/dist/hook-runtime/hooks/pre-commit.js +1253 -280
  28. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +4272 -1982
  29. package/dist/hook-runtime/hooks/pre-tool-use.js +13 -3
  30. package/dist/hook-runtime/hooks/prim-hook.js +4719 -2479
  31. package/dist/hook-runtime/hooks/session-end.js +393 -140
  32. package/dist/hook-runtime/hooks/session-start.js +4207 -1998
  33. package/dist/hook-runtime/index.js +6157 -3544
  34. package/dist/hook-runtime/statusline-main.js +368 -122
  35. package/dist/hooks/post-commit.js +7 -7
  36. package/dist/hooks/post-rewrite.js +6 -6
  37. package/dist/hooks/post-tool-use.js +31 -21
  38. package/dist/hooks/pre-commit.js +4 -4
  39. package/dist/hooks/pre-tool-use-worker.js +88 -18
  40. package/dist/hooks/pre-tool-use.js +13 -3
  41. package/dist/hooks/prim-hook.js +16 -16
  42. package/dist/hooks/session-end.js +4 -4
  43. package/dist/hooks/session-start.js +16 -12
  44. package/dist/index.js +230 -150
  45. package/dist/statusline-main.js +368 -122
  46. package/package.json +5 -2
  47. package/dist/chunk-RRAC76LJ.js +0 -36
@@ -1,8 +1,10 @@
1
1
  import {
2
2
  decodeJwtPayload,
3
+ hasMachineConfiguration,
4
+ machineContext,
3
5
  primConfigDirectory,
4
6
  resolveAuthCredential
5
- } from "./chunk-4GYJHN26.js";
7
+ } from "./chunk-Q2PVD5W2.js";
6
8
 
7
9
  // src/daemon/principal.ts
8
10
  import { createHash } from "crypto";
@@ -14,6 +16,14 @@ function sha256(value) {
14
16
  return createHash("sha256").update(value).digest("hex");
15
17
  }
16
18
  function resolveDaemonPrincipal(token = resolveAuthCredential()?.token) {
19
+ if (hasMachineConfiguration()) {
20
+ const machine = machineContext();
21
+ return machine ? {
22
+ principalId: sha256(`${machine.issuer}\0${machine.clientId}`),
23
+ organizationId: machine.workosOrganizationId,
24
+ credentialFingerprint: sha256(machine.generation)
25
+ } : void 0;
26
+ }
17
27
  if (!token) return void 0;
18
28
  const payload = decodeJwtPayload(token);
19
29
  const subject = boundedClaim(payload?.sub);
@@ -1,13 +1,17 @@
1
1
  import {
2
2
  getSiteUrl
3
- } from "./chunk-S3ZIMGXV.js";
3
+ } from "./chunk-QZWLZH6D.js";
4
4
  import {
5
5
  atomicWriteFile,
6
6
  ensureDurableDirectory,
7
+ hasMachineConfiguration,
7
8
  jwtOrganizationId,
9
+ machineCaptureActor,
10
+ machineContext,
11
+ machineJournalBucket,
8
12
  primConfigDirectory,
9
13
  resolveAuthCredential
10
- } from "./chunk-4GYJHN26.js";
14
+ } from "./chunk-Q2PVD5W2.js";
11
15
 
12
16
  // src/journal.ts
13
17
  import {
@@ -149,7 +153,10 @@ function journalPath(orgId) {
149
153
  return join2(bucketDir(orgId), JOURNAL_BASENAME);
150
154
  }
151
155
  function appendMove(move, orgId) {
152
- appendMoveToPath(journalPath(orgId), move);
156
+ const actor = machineCaptureActor();
157
+ const captured = actor ? { ...move, captureActor: actor } : move;
158
+ appendMoveToPath(journalPath(actor ? machineJournalBucket(actor) : orgId), captured);
159
+ return captured;
153
160
  }
154
161
  function parseMoves(content) {
155
162
  const moves = [];
@@ -401,10 +408,15 @@ function fromWorkspaceFile(startDir) {
401
408
  }
402
409
  }
403
410
  function fromDefaultOrg(_cwd) {
411
+ if (hasMachineConfiguration()) return machineContext()?.workosOrganizationId;
404
412
  const credential = resolveAuthCredential();
405
413
  return credential ? jwtOrganizationId(credential.token) : void 0;
406
414
  }
407
415
  function resolveOrg(args) {
416
+ if (hasMachineConfiguration()) {
417
+ const orgId = machineContext()?.workosOrganizationId;
418
+ return { orgId, source: orgId ? "defaultOrg" : "unbound" };
419
+ }
408
420
  const fromSession = fromSessionMarker(args.sessionId);
409
421
  if (fromSession) {
410
422
  return { orgId: fromSession, source: "session" };
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  daemonRequest
3
- } from "./chunk-NMZSCSMY.js";
3
+ } from "./chunk-6PSCGY2A.js";
4
4
  import {
5
5
  getClient,
6
6
  getSiteUrl,
7
7
  terminalSafeLine
8
- } from "./chunk-S3ZIMGXV.js";
8
+ } from "./chunk-QZWLZH6D.js";
9
9
  import {
10
10
  canonicalGitRoot,
11
11
  canonicalRepositoryPath,
12
12
  currentBranch,
13
13
  repoSyncId
14
- } from "./chunk-4GYJHN26.js";
14
+ } from "./chunk-Q2PVD5W2.js";
15
15
 
16
16
  // src/daemon/proxy.ts
17
17
  var DAEMON_HTTP_TIMEOUT_MS = 1e4;
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-EZXEWFDG.js";
4
4
  import {
5
5
  scrubEnvironmentPaths
6
- } from "./chunk-4NUGCUQC.js";
6
+ } from "./chunk-EER7VG3P.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
- } from "./chunk-4GYJHN26.js";
9
+ } from "./chunk-Q2PVD5W2.js";
10
10
 
11
11
  // src/hooks/prim-hook-core.ts
12
12
  import { createHash, randomUUID } from "crypto";
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  inspectHookRuntime
3
- } from "./chunk-AKGRY7OU.js";
3
+ } from "./chunk-WLVEXOHC.js";
4
4
  import {
5
5
  isDemoStatusResponse
6
- } from "./chunk-HLMC7VS4.js";
6
+ } from "./chunk-5MH2C5QG.js";
7
7
  import {
8
8
  atomicWriteFile,
9
9
  primConfigDirectory,
10
10
  withFileLock,
11
11
  withFileLockSync
12
- } from "./chunk-4GYJHN26.js";
12
+ } from "./chunk-Q2PVD5W2.js";
13
13
 
14
14
  // src/hooks/pre-tool-use-scoring.ts
15
15
  import { isAbsolute, relative, sep } from "path";
@@ -9,11 +9,11 @@ import {
9
9
  hookBlockContractVersion,
10
10
  inspectGitHookEntrypoint,
11
11
  managedHookBlock
12
- } from "./chunk-AKGRY7OU.js";
12
+ } from "./chunk-WLVEXOHC.js";
13
13
  import {
14
14
  HttpError,
15
15
  getClient
16
- } from "./chunk-S3ZIMGXV.js";
16
+ } from "./chunk-QZWLZH6D.js";
17
17
  import {
18
18
  atomicWriteFile,
19
19
  binFile,
@@ -27,7 +27,7 @@ import {
27
27
  setRepoSyncId,
28
28
  setRepositoryBindingState,
29
29
  withFileLock
30
- } from "./chunk-4GYJHN26.js";
30
+ } from "./chunk-Q2PVD5W2.js";
31
31
 
32
32
  // src/commands/skill.ts
33
33
  import { createHash as createHash3 } from "crypto";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-HLMC7VS4.js";
3
+ } from "./chunk-5MH2C5QG.js";
4
4
  import {
5
5
  terminalSafeLine
6
- } from "./chunk-S3ZIMGXV.js";
6
+ } from "./chunk-QZWLZH6D.js";
7
7
 
8
8
  // src/hooks/redact.ts
9
9
  import { existsSync, readFileSync, statSync } from "fs";
@@ -3,7 +3,7 @@ import {
3
3
  isTerminalSafeText,
4
4
  terminalSafeLine,
5
5
  terminalSafeText
6
- } from "./chunk-S3ZIMGXV.js";
6
+ } from "./chunk-QZWLZH6D.js";
7
7
 
8
8
  // src/decisions/feedback.ts
9
9
  var FEEDBACK_PROTOCOL_VERSION = 2;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  atomicWriteFile,
3
3
  repoActiveFlag
4
- } from "./chunk-4GYJHN26.js";
4
+ } from "./chunk-Q2PVD5W2.js";
5
5
 
6
6
  // src/lib/commit-heartbeat.ts
7
7
  import { execFileSync } from "child_process";
@@ -2,10 +2,10 @@ import {
2
2
  cursorHooksPath,
3
3
  hasExactCursorHandler,
4
4
  readCursorHooks
5
- } from "./chunk-AKGRY7OU.js";
5
+ } from "./chunk-WLVEXOHC.js";
6
6
  import {
7
7
  resolveRepositoryContext
8
- } from "./chunk-4GYJHN26.js";
8
+ } from "./chunk-Q2PVD5W2.js";
9
9
 
10
10
  // src/hooks/cursor-coexistence.ts
11
11
  var CURSOR_EVENTS = /* @__PURE__ */ new Set([