@primitive.ai/prim 0.1.0-alpha.123 → 0.1.0-alpha.125

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 (45) hide show
  1. package/README.md +90 -0
  2. package/dist/{chunk-RUEIVZ6T.js → chunk-2BEUR3DU.js} +2 -2
  3. package/dist/{chunk-5ME3WD3P.js → chunk-6KXQQ7CQ.js} +6 -3
  4. package/dist/{chunk-CWV5ZQR6.js → chunk-6OPSSJHO.js} +5 -5
  5. package/dist/{chunk-4NUGCUQC.js → chunk-74DQDWLW.js} +2 -2
  6. package/dist/{chunk-WN7OURQ3.js → chunk-BFYJLI7V.js} +1 -1
  7. package/dist/{chunk-T2T45KF6.js → chunk-DT7E3SD5.js} +4 -4
  8. package/dist/{chunk-DQ4I3FLF.js → chunk-EZXIKEMA.js} +3 -3
  9. package/dist/{chunk-4M23K2KZ.js → chunk-FYYHBOOM.js} +2 -2
  10. package/dist/{chunk-3WQ7SBOZ.js → chunk-HPA7RGSZ.js} +3 -3
  11. package/dist/{chunk-NL5VU7EU.js → chunk-JFWJN2ME.js} +3 -3
  12. package/dist/{chunk-GOMEWFMG.js → chunk-L32WYFJT.js} +143 -61
  13. package/dist/{chunk-OXW6PSPT.js → chunk-NBNQI3YJ.js} +15 -3
  14. package/dist/{chunk-LOFMI3D4.js → chunk-ND6TYHNI.js} +2 -2
  15. package/dist/{chunk-4GYJHN26.js → chunk-NJBN3WXF.js} +1607 -549
  16. package/dist/{chunk-HLMC7VS4.js → chunk-O73J3KQQ.js} +5702 -2860
  17. package/dist/{chunk-JZC2LHS6.js → chunk-PPZ56EVJ.js} +1 -1
  18. package/dist/{chunk-FXXMDO7D.js → chunk-R35M4RCY.js} +4 -4
  19. package/dist/chunk-TI37ME2D.js +210 -0
  20. package/dist/{chunk-NMZSCSMY.js → chunk-YP4OXKNX.js} +13 -1
  21. package/dist/{chunk-S3ZIMGXV.js → chunk-ZKXNJB6U.js} +76 -2
  22. package/dist/daemon/server.js +12321 -8354
  23. package/dist/hook-runtime/daemon/server.js +12321 -8354
  24. package/dist/hook-runtime/hooks/post-commit.js +6743 -3634
  25. package/dist/hook-runtime/hooks/post-rewrite.js +6776 -3668
  26. package/dist/hook-runtime/hooks/post-tool-use.js +7108 -3140
  27. package/dist/hook-runtime/hooks/pre-commit.js +1263 -280
  28. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +15115 -11297
  29. package/dist/hook-runtime/hooks/prim-hook.js +10879 -7024
  30. package/dist/hook-runtime/hooks/session-end.js +399 -139
  31. package/dist/hook-runtime/hooks/session-start.js +13277 -9454
  32. package/dist/hook-runtime/index.js +17575 -13050
  33. package/dist/hook-runtime/statusline-main.js +375 -122
  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 +31 -21
  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 +16 -12
  42. package/dist/index.js +9124 -8763
  43. package/dist/statusline-main.js +375 -122
  44. package/package.json +3 -1
  45. package/dist/chunk-RRAC76LJ.js +0 -36
package/README.md CHANGED
@@ -660,3 +660,93 @@ characters. Use the same ID in commands and at
660
660
  `shortId` compatibility field contains the eight characters without the prefix.
661
661
  Existing full record IDs remain accepted as inputs. Upgrade the backend before
662
662
  this CLI; an unavailable identity produces an error rather than a storage ID.
663
+
664
+ ### Machine credentials
665
+
666
+ An administrator issues a separate WorkOS M2M application for each installation
667
+ or workload. Configure its application client ID and enter the secret at the
668
+ hidden prompt:
669
+
670
+ ```sh
671
+ prim auth configure-machine --client-id client_APPLICATION
672
+ prim auth status --json
673
+ prim setup
674
+ ```
675
+
676
+ For automated secret delivery, pipe the secret to
677
+ `prim auth configure-machine --client-id client_APPLICATION --client-secret-stdin`.
678
+ Never pass a secret as a command-line argument. CI can instead inject both
679
+ `PRIM_M2M_CLIENT_ID` and `PRIM_M2M_CLIENT_SECRET`, along with the selected
680
+ `PRIM_API_URL`. A complete environment pair overrides saved credentials;
681
+ partial pairs and a conflicting `PRIM_TOKEN` fail explicitly. Injected
682
+ credentials and tokens are never saved. Prim shares only verified identity
683
+ metadata with local hooks, tied to that credential generation and token expiry.
684
+
685
+ Injected credentials share access tokens through an authenticated, memory-only
686
+ local broker. Provider retry delays are shared across processes and survive
687
+ restarts without saving secrets or tokens. The broker runs from the copied
688
+ runtime and exits after five minutes without authenticated requests.
689
+
690
+ On macOS, launchd cannot inherit credentials from your terminal. Stop any
691
+ existing daemon and run `prim daemon start --foreground` in the environment
692
+ that supplies the machine credentials. Restart it with the new environment when
693
+ rotating credentials. Prim rejects launchd configuration in environment mode;
694
+ use saved machine credentials for a daemon that starts across logins.
695
+
696
+ Prim verifies the exchange and the API's protected machine identity before
697
+ activating credentials. It uses the OS credential store by default (persistent
698
+ Secret Service on Linux). If that store is unavailable on initial configuration,
699
+ Prim uses owner-only files in its private configuration directory. Once a store
700
+ is selected, a locked or failing keychain produces a recovery error rather than
701
+ falling back to an old credential. `prim auth clear` removes saved credentials;
702
+ unset injected environment variables separately.
703
+
704
+ Tokens renew with another client-credentials exchange, without refresh tokens.
705
+ Auth status reports identity, organization, effective scopes, storage, and expiry.
706
+ Use `prim doctor` for journal and daemon recovery details (JSON on stdout). Machine access
707
+ covers capture, checks, presence, organization-visible Decision reads, and the
708
+ machine's own Decision lifecycle. Manage GitHub App installation and human API
709
+ keys in the web application; the personal onboarding demo is not a machine task.
710
+
711
+ Flush pending activity under its original credentials before migration where
712
+ possible (`prim moves flush`). Machine capture uses separate, identity-bound
713
+ journals. Legacy activity and activity from another machine are retained rather
714
+ than reassigned. Terminal credential failures pause delivery while local capture
715
+ continues. Ask the administrator to enable or rotate the same machine, then run
716
+ `configure-machine` again. Do not edit or move journal records between identities.
717
+ For injected credentials, restart with the replacement environment. After
718
+ verifying the replacement, the administrator must revoke the old WorkOS client
719
+ secret; clearing local storage does not revoke it.
720
+
721
+ For concurrent backend/CLI development, `pnpm contracts:update --worktree <path>`
722
+ imports an explicitly unpublished backend contract. Canonical provenance remains
723
+ blocked until the backend is published and imported with
724
+ `pnpm contracts:update --revision <full-commit>`. Production releases must pass
725
+ `pnpm contracts:provenance`.
726
+
727
+ ### Developer installation enrollment
728
+
729
+ When automatic enrollment is enabled by your organization, run `prim setup`.
730
+ Sign in once and select your organization; Prim registers this installation and
731
+ stores its machine credentials in the OS credential store (or the existing private
732
+ file fallback). Repeated setup reuses the installation. No WorkOS dashboard access
733
+ or copying of client secrets is required. `prim auth enroll` also enrolls an already
734
+ signed-in installation.
735
+
736
+ The installation authenticates the request while your account owns the Decisions.
737
+ Your private drafts, existing Decisions, and normal lifecycle permissions remain
738
+ available. Human/agent attribution and adoption rules stay the same. The installation
739
+ is recorded as provenance. Administrators can manage enrollment policy and revoke
740
+ installations in the web application's Settings → Developer installations.
741
+
742
+ Setup attempts to deliver pending legacy captures before changing credentials.
743
+ Any remaining activity stays under its original authorization; inspect it with
744
+ `prim moves status`. It is never uploaded under newly assigned authorship.
745
+ `prim auth status` reports the installation, authorized user, storage backend, and
746
+ expiry without revealing credentials. If older-secret retirement is pending, rerun
747
+ `prim auth enroll` to retry it.
748
+
749
+ On a server without enrollment, setup retains legacy authentication. Existing
750
+ manually configured machines and CI credentials remain service identities; routine
751
+ setup does not convert them into developer installations. GitHub installation and
752
+ API-key administration remain available in the web application.
@@ -11,10 +11,10 @@ import {
11
11
  saveRun,
12
12
  sessionExcluded,
13
13
  sessionKey
14
- } from "./chunk-3WQ7SBOZ.js";
14
+ } from "./chunk-HPA7RGSZ.js";
15
15
  import {
16
16
  packageVersion
17
- } from "./chunk-4GYJHN26.js";
17
+ } from "./chunk-NJBN3WXF.js";
18
18
 
19
19
  // src/demo/isolation.ts
20
20
  import { existsSync } from "fs";
@@ -1,9 +1,12 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-HLMC7VS4.js";
3
+ } from "./chunk-O73J3KQQ.js";
4
4
  import {
5
5
  stripControlChars
6
- } from "./chunk-S3ZIMGXV.js";
6
+ } from "./chunk-ZKXNJB6U.js";
7
+ import {
8
+ hasMachineConfiguration
9
+ } from "./chunk-NJBN3WXF.js";
7
10
 
8
11
  // src/lib/delivery-backlog.ts
9
12
  var MS_PER_SECOND = 1e3;
@@ -114,7 +117,7 @@ function formatStatusline(version, snapshot, resolveIngestionStatus, options = {
114
117
  const ingestionSuffix = (status) => status === void 0 ? "" : ` \xB7 Decision ingestion ${status}`;
115
118
  const ingestionStatus = snapshot === null || snapshot.healthy === false ? options.includeIngestionWhenUnavailable ? resolveIngestionStatus() : void 0 : resolveIngestionStatus();
116
119
  if (snapshot?.healthy === false && snapshot.needsReauth) {
117
- return `primitive ${version} (daemon: paused \xB7 run \`prim auth login\`${ingestionSuffix(ingestionStatus)})`;
120
+ return `primitive ${version} (daemon: paused \xB7 run \`${hasMachineConfiguration() ? "prim auth status" : "prim auth login"}\`${ingestionSuffix(ingestionStatus)})`;
118
121
  }
119
122
  const repositoryLabel = repositoryBindingDiagnosticLabel(
120
123
  snapshot !== null && snapshot.healthy !== false || options.includeIngestionWhenUnavailable === true ? options.resolveRepositoryBindingState?.() : void 0
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  analyzeShellTargets,
3
3
  extractFileTargets
4
- } from "./chunk-3WQ7SBOZ.js";
4
+ } from "./chunk-HPA7RGSZ.js";
5
5
  import {
6
6
  DEFAULT_RULES,
7
7
  scrub
8
- } from "./chunk-4NUGCUQC.js";
8
+ } from "./chunk-74DQDWLW.js";
9
9
  import {
10
10
  boundedHealthError,
11
11
  isPreflightResponseV4
12
- } from "./chunk-HLMC7VS4.js";
12
+ } from "./chunk-O73J3KQQ.js";
13
13
  import {
14
14
  getClient,
15
15
  terminalSafeLine
16
- } from "./chunk-S3ZIMGXV.js";
16
+ } from "./chunk-ZKXNJB6U.js";
17
17
  import {
18
18
  canonicalGitRoot,
19
19
  canonicalRepositoryPath
20
- } from "./chunk-4GYJHN26.js";
20
+ } from "./chunk-NJBN3WXF.js";
21
21
 
22
22
  // src/hooks/approval-copy.ts
23
23
  var MAX_EXCERPT_CHARS = 80;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-HLMC7VS4.js";
3
+ } from "./chunk-O73J3KQQ.js";
4
4
  import {
5
5
  terminalSafeLine
6
- } from "./chunk-S3ZIMGXV.js";
6
+ } from "./chunk-ZKXNJB6U.js";
7
7
 
8
8
  // src/hooks/redact.ts
9
9
  import { existsSync, readFileSync, statSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  atomicWriteFile,
3
3
  repoActiveFlag
4
- } from "./chunk-4GYJHN26.js";
4
+ } from "./chunk-NJBN3WXF.js";
5
5
 
6
6
  // src/lib/commit-heartbeat.ts
7
7
  import { execFileSync } from "child_process";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  formatStatusline
3
- } from "./chunk-5ME3WD3P.js";
3
+ } from "./chunk-6KXQQ7CQ.js";
4
4
  import {
5
5
  daemonPrincipalsMatch,
6
6
  daemonRequest,
7
7
  resolveDaemonPrincipal
8
- } from "./chunk-NMZSCSMY.js";
8
+ } from "./chunk-YP4OXKNX.js";
9
9
  import {
10
10
  getSiteUrl,
11
11
  isSessionEnded,
12
12
  terminalSafeText
13
- } from "./chunk-S3ZIMGXV.js";
13
+ } from "./chunk-ZKXNJB6U.js";
14
14
  import {
15
15
  decisionIngestionStatus,
16
16
  gitToplevel,
@@ -18,7 +18,7 @@ import {
18
18
  primConfigDirectory,
19
19
  repositoryBindingState,
20
20
  withFileLock
21
- } from "./chunk-4GYJHN26.js";
21
+ } from "./chunk-NJBN3WXF.js";
22
22
 
23
23
  // src/hooks/codex-context.ts
24
24
  import { createHash, randomBytes as randomBytes2 } from "crypto";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  daemonRequest
3
- } from "./chunk-NMZSCSMY.js";
3
+ } from "./chunk-YP4OXKNX.js";
4
4
  import {
5
5
  getClient,
6
6
  getSiteUrl,
7
7
  terminalSafeLine
8
- } from "./chunk-S3ZIMGXV.js";
8
+ } from "./chunk-ZKXNJB6U.js";
9
9
  import {
10
10
  canonicalGitRoot,
11
11
  canonicalRepositoryPath,
12
12
  currentBranch,
13
13
  repoSyncId
14
- } from "./chunk-4GYJHN26.js";
14
+ } from "./chunk-NJBN3WXF.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-74DQDWLW.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
- } from "./chunk-4GYJHN26.js";
9
+ } from "./chunk-NJBN3WXF.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-GOMEWFMG.js";
3
+ } from "./chunk-L32WYFJT.js";
4
4
  import {
5
5
  isDemoStatusResponse
6
- } from "./chunk-HLMC7VS4.js";
6
+ } from "./chunk-O73J3KQQ.js";
7
7
  import {
8
8
  atomicWriteFile,
9
9
  primConfigDirectory,
10
10
  withFileLock,
11
11
  withFileLockSync
12
- } from "./chunk-4GYJHN26.js";
12
+ } from "./chunk-NJBN3WXF.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-GOMEWFMG.js";
12
+ } from "./chunk-L32WYFJT.js";
13
13
  import {
14
14
  HttpError,
15
15
  getClient
16
- } from "./chunk-S3ZIMGXV.js";
16
+ } from "./chunk-ZKXNJB6U.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-NJBN3WXF.js";
31
31
 
32
32
  // src/commands/skill.ts
33
33
  import { createHash as createHash3 } from "crypto";