@primitive.ai/prim 0.1.0-alpha.127 → 0.1.0-alpha.129

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 +76 -5
  2. package/dist/{chunk-HZI5PBN4.js → chunk-BVGASV3B.js} +2047 -138
  3. package/dist/{chunk-72NIZMZN.js → chunk-DYXCJ6WZ.js} +15 -10
  4. package/dist/{chunk-TNWI3JWK.js → chunk-FHDTJP2C.js} +4 -2
  5. package/dist/{chunk-C4QNBSWB.js → chunk-HDL3UXYJ.js} +8 -8
  6. package/dist/{chunk-RV3JFSMX.js → chunk-IJ3W2YBM.js} +4 -4
  7. package/dist/{chunk-O65UVJZH.js → chunk-IZAEAALI.js} +2 -2
  8. package/dist/{chunk-H74RDXKP.js → chunk-KZNOT2YH.js} +2 -2
  9. package/dist/{chunk-R4EYLEIK.js → chunk-L7U3G4XR.js} +2 -2
  10. package/dist/{chunk-MGKSZSTV.js → chunk-LBZJD2I4.js} +3 -5
  11. package/dist/{chunk-UUQT5GMO.js → chunk-MMMY57UA.js} +22 -837
  12. package/dist/{chunk-H6X52UVF.js → chunk-NWWTFQP2.js} +1 -1
  13. package/dist/{chunk-WGTUNUIS.js → chunk-QSDWWEHF.js} +5 -5
  14. package/dist/{chunk-NVDPKW7Z.js → chunk-RAEOSDQ6.js} +3 -51
  15. package/dist/{chunk-KFRGVHGB.js → chunk-RS5ADTDF.js} +6 -6
  16. package/dist/{chunk-A5VTE43F.js → chunk-RWJ7WHTJ.js} +2 -2
  17. package/dist/{chunk-VVFVENU4.js → chunk-SJE7OWVS.js} +6 -6
  18. package/dist/{chunk-L6IL4N6Y.js → chunk-USJ4JGDC.js} +34 -34
  19. package/dist/{chunk-JCKOW45X.js → chunk-YPHDV5AS.js} +2 -2
  20. package/dist/{chunk-F3FDVHR7.js → chunk-YSV43WLK.js} +1 -1
  21. package/dist/{chunk-URYZDQFH.js → chunk-ZKIBD5MO.js} +3 -5
  22. package/dist/daemon/server.js +1769 -487
  23. package/dist/hook-runtime/daemon/server.js +1769 -487
  24. package/dist/hook-runtime/hooks/post-commit.js +611 -337
  25. package/dist/hook-runtime/hooks/post-rewrite.js +606 -332
  26. package/dist/hook-runtime/hooks/post-tool-use.js +1841 -683
  27. package/dist/hook-runtime/hooks/pre-commit.js +1713 -434
  28. package/dist/hook-runtime/hooks/pre-tool-use-worker.js +1308 -150
  29. package/dist/hook-runtime/hooks/prim-hook.js +1863 -705
  30. package/dist/hook-runtime/hooks/session-end.js +538 -385
  31. package/dist/hook-runtime/hooks/session-start.js +1379 -233
  32. package/dist/hook-runtime/index.js +5438 -4052
  33. package/dist/hook-runtime/statusline-main.js +547 -273
  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 +18 -18
  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 +64 -22
  42. package/dist/index.js +396 -52
  43. package/dist/statusline-main.js +547 -273
  44. package/package.json +1 -1
@@ -4,7 +4,7 @@ import {
4
4
  machineContext,
5
5
  primConfigDirectory,
6
6
  resolveAuthCredential
7
- } from "./chunk-HZI5PBN4.js";
7
+ } from "./chunk-BVGASV3B.js";
8
8
 
9
9
  // src/daemon/principal.ts
10
10
  import { createHash } from "crypto";
@@ -1,11 +1,11 @@
1
1
  import {
2
- getClient,
3
- terminalSafeLine
4
- } from "./chunk-NVDPKW7Z.js";
2
+ getClient
3
+ } from "./chunk-RAEOSDQ6.js";
5
4
  import {
6
5
  localGitConfigValue,
7
- setLocalGitConfigValue
8
- } from "./chunk-HZI5PBN4.js";
6
+ setLocalGitConfigValue,
7
+ terminalSafeLine
8
+ } from "./chunk-BVGASV3B.js";
9
9
  import {
10
10
  __commonJS,
11
11
  __toESM
@@ -31,9 +31,10 @@ import {
31
31
  rejectedCredentialsMessage,
32
32
  resolveAuthCredential,
33
33
  syncDirectory,
34
+ terminalSafeLine,
34
35
  withFileLock,
35
36
  workosConnectTokenEndpoint
36
- } from "./chunk-HZI5PBN4.js";
37
+ } from "./chunk-BVGASV3B.js";
37
38
 
38
39
  // src/decisions/identity.ts
39
40
  var PUBLIC_ID = /^dec_[0-9a-f]{8}$/u;
@@ -112,51 +113,6 @@ function publicDecisionResponse(value) {
112
113
  return replace(projected);
113
114
  }
114
115
 
115
- // src/lib/terminal-safe.ts
116
- function replaceIsolatedSurrogates(value) {
117
- let out = "";
118
- for (let index = 0; index < value.length; index += 1) {
119
- const unit = value.charCodeAt(index);
120
- if (unit >= 55296 && unit <= 56319) {
121
- const next = value.charCodeAt(index + 1);
122
- if (next >= 56320 && next <= 57343) {
123
- out += value[index] + value[index + 1];
124
- index += 1;
125
- } else {
126
- out += "\uFFFD";
127
- }
128
- } else if (unit >= 56320 && unit <= 57343) {
129
- out += "\uFFFD";
130
- } else {
131
- out += value[index];
132
- }
133
- }
134
- return out;
135
- }
136
- function isUnsafeTerminalCodePoint(point) {
137
- const c0OrC1 = point <= 31 || point >= 127 && point <= 159;
138
- const bidiOrZeroWidth = point === 173 || // soft hyphen
139
- point === 1564 || // Arabic letter mark
140
- point === 6158 || // Mongolian vowel separator
141
- point >= 8203 && point <= 8207 || // zero-width + directional marks
142
- point >= 8234 && point <= 8238 || // bidi embeddings/overrides
143
- point >= 8288 && point <= 8303 || // word joiner + bidi isolates/controls
144
- point >= 65529 && point <= 65531 || // interlinear annotation controls
145
- point === 65279 || // zero-width no-break space / BOM
146
- point >= 917504 && point <= 917631;
147
- return c0OrC1 || bidiOrZeroWidth;
148
- }
149
- function terminalSafeText(value) {
150
- return Array.from(replaceIsolatedSurrogates(value)).filter((character) => !isUnsafeTerminalCodePoint(character.codePointAt(0) ?? 0)).join("");
151
- }
152
- function terminalSafeLine(value) {
153
- return terminalSafeText(value.replace(/\s+/gu, " ")).replace(/\s+/gu, " ").trim();
154
- }
155
- function isTerminalSafeText(value) {
156
- return terminalSafeText(value) === value;
157
- }
158
- var stripControlChars = terminalSafeText;
159
-
160
116
  // src/client.ts
161
117
  import { createHash } from "crypto";
162
118
  import { chmodSync as chmodSync2, existsSync, mkdirSync, readFileSync as readFileSync2, rmSync } from "fs";
@@ -812,7 +768,7 @@ async function machineClient(options = {}, management = false) {
812
768
  if (response.status === 401)
813
769
  throw new HttpError(
814
770
  401,
815
- selected.tokenInjection ? "Machine access was rejected. Check the cloud environment's OAuth 2.0 client credentials network secret, or mint a replacement credential if this one was revoked." : rejectedCredentialsMessage(
771
+ selected.session ? "Primitive rejected this cloud session's token after renewing it. To fix it, start a new cloud session, which identifies you again through GitHub." : selected.tokenInjection ? "Machine access was rejected. Check the cloud environment's OAuth 2.0 client credentials network secret, or mint a replacement credential if this one was revoked." : rejectedCredentialsMessage(
816
772
  "Machine access was rejected. Ask your administrator to check or rotate its credentials."
817
773
  )
818
774
  );
@@ -936,10 +892,6 @@ async function getPinnedManagementClient(options = {}) {
936
892
 
937
893
  export {
938
894
  decisionIdentifier,
939
- terminalSafeText,
940
- terminalSafeLine,
941
- isTerminalSafeText,
942
- stripControlChars,
943
895
  DEFAULT_API_URL,
944
896
  getSiteUrl,
945
897
  getSiteUrlForEnvironment,
@@ -1,24 +1,24 @@
1
1
  import {
2
2
  formatStatusline
3
- } from "./chunk-URYZDQFH.js";
3
+ } from "./chunk-ZKIBD5MO.js";
4
4
  import {
5
5
  daemonPrincipalsMatch,
6
6
  daemonRequest,
7
7
  resolveDaemonPrincipal
8
- } from "./chunk-H6X52UVF.js";
8
+ } from "./chunk-NWWTFQP2.js";
9
9
  import {
10
10
  getSiteUrl,
11
- isSessionEnded,
12
- terminalSafeText
13
- } from "./chunk-NVDPKW7Z.js";
11
+ isSessionEnded
12
+ } from "./chunk-RAEOSDQ6.js";
14
13
  import {
15
14
  decisionIngestionStatus,
16
15
  gitToplevel,
17
16
  packageVersion,
18
17
  primConfigDirectory,
19
18
  repositoryBindingState,
19
+ terminalSafeText,
20
20
  withFileLock
21
- } from "./chunk-HZI5PBN4.js";
21
+ } from "./chunk-BVGASV3B.js";
22
22
 
23
23
  // src/hooks/codex-context.ts
24
24
  import { createHash, randomBytes as randomBytes2 } from "crypto";
@@ -11,10 +11,10 @@ import {
11
11
  saveRun,
12
12
  sessionExcluded,
13
13
  sessionKey
14
- } from "./chunk-MGKSZSTV.js";
14
+ } from "./chunk-LBZJD2I4.js";
15
15
  import {
16
16
  packageVersion
17
- } from "./chunk-HZI5PBN4.js";
17
+ } from "./chunk-BVGASV3B.js";
18
18
 
19
19
  // src/demo/isolation.ts
20
20
  import { existsSync } from "fs";
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  daemonRequest
3
- } from "./chunk-H6X52UVF.js";
3
+ } from "./chunk-NWWTFQP2.js";
4
4
  import {
5
5
  getClient,
6
- getSiteUrl,
7
- terminalSafeLine
8
- } from "./chunk-NVDPKW7Z.js";
6
+ getSiteUrl
7
+ } from "./chunk-RAEOSDQ6.js";
9
8
  import {
10
9
  canonicalGitRoot,
11
10
  canonicalRepositoryPath,
12
11
  cloudSetupPointer,
13
12
  currentBranch,
14
13
  isClaudeCloudSession,
15
- repoSyncId
16
- } from "./chunk-HZI5PBN4.js";
14
+ repoSyncId,
15
+ terminalSafeLine
16
+ } from "./chunk-BVGASV3B.js";
17
17
 
18
18
  // src/daemon/proxy.ts
19
19
  var DAEMON_HTTP_TIMEOUT_MS = 1e4;
@@ -1,18 +1,47 @@
1
1
  import {
2
2
  isMoveIngestRequest,
3
3
  scheduleCollectScopeRefresh
4
- } from "./chunk-WGTUNUIS.js";
4
+ } from "./chunk-QSDWWEHF.js";
5
5
  import {
6
6
  getPinnedClient,
7
7
  getSiteUrl
8
- } from "./chunk-NVDPKW7Z.js";
8
+ } from "./chunk-RAEOSDQ6.js";
9
9
  import {
10
10
  identityPending,
11
11
  machineApiUrl,
12
12
  machineJournalBucket,
13
13
  machinePendingBucket,
14
14
  parseMachineIdentity
15
- } from "./chunk-HZI5PBN4.js";
15
+ } from "./chunk-BVGASV3B.js";
16
+
17
+ // src/ingest-response.ts
18
+ var IngestAcknowledgementError = class extends Error {
19
+ constructor(message) {
20
+ super(message);
21
+ this.name = "IngestAcknowledgementError";
22
+ }
23
+ };
24
+ function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd()) {
25
+ if (typeof value !== "object" || value === null) {
26
+ throw new IngestAcknowledgementError("ingest response was not an object");
27
+ }
28
+ const response = value;
29
+ if (response.disposition !== "persisted") {
30
+ throw new IngestAcknowledgementError("ingest response did not confirm persistence");
31
+ }
32
+ if (response.acknowledged !== expected) {
33
+ throw new IngestAcknowledgementError(
34
+ `ingest acknowledged ${String(response.acknowledged)} of ${String(expected)} moves`
35
+ );
36
+ }
37
+ if (typeof response.collectScopeVersion === "number" && Number.isSafeInteger(response.collectScopeVersion) && response.collectScopeVersion >= 0) {
38
+ const roots = typeof cwd === "string" ? [cwd] : cwd;
39
+ for (const root of new Set(roots)) {
40
+ scheduleCollectScopeRefresh(root, response.collectScopeVersion);
41
+ }
42
+ }
43
+ return value;
44
+ }
16
45
 
17
46
  // src/protocol/decision-lifecycle.ts
18
47
  var DECISION_LIFECYCLE_PROTOCOL_VERSION = 2;
@@ -179,41 +208,12 @@ async function inspectJournalDelivery(buckets, options = {}) {
179
208
  };
180
209
  }
181
210
 
182
- // src/ingest-response.ts
183
- var IngestAcknowledgementError = class extends Error {
184
- constructor(message) {
185
- super(message);
186
- this.name = "IngestAcknowledgementError";
187
- }
188
- };
189
- function requireDurableIngestAcknowledgement(value, expected, cwd = process.cwd()) {
190
- if (typeof value !== "object" || value === null) {
191
- throw new IngestAcknowledgementError("ingest response was not an object");
192
- }
193
- const response = value;
194
- if (response.disposition !== "persisted") {
195
- throw new IngestAcknowledgementError("ingest response did not confirm persistence");
196
- }
197
- if (response.acknowledged !== expected) {
198
- throw new IngestAcknowledgementError(
199
- `ingest acknowledged ${String(response.acknowledged)} of ${String(expected)} moves`
200
- );
201
- }
202
- if (typeof response.collectScopeVersion === "number" && Number.isSafeInteger(response.collectScopeVersion) && response.collectScopeVersion >= 0) {
203
- const roots = typeof cwd === "string" ? [cwd] : cwd;
204
- for (const root of new Set(roots)) {
205
- scheduleCollectScopeRefresh(root, response.collectScopeVersion);
206
- }
207
- }
208
- return value;
209
- }
210
-
211
211
  export {
212
+ requireDurableIngestAcknowledgement,
212
213
  InvalidJournalEnvelopeError,
213
214
  parseOrganizationBinding,
214
215
  summarizeRetainedBuckets,
215
216
  classifyJournalBuckets,
216
217
  buildOrganizationBoundMoveRequest,
217
- inspectJournalDelivery,
218
- requireDurableIngestAcknowledgement
218
+ inspectJournalDelivery
219
219
  };
@@ -3,10 +3,10 @@ import {
3
3
  } from "./chunk-EZXEWFDG.js";
4
4
  import {
5
5
  scrubEnvironmentPaths
6
- } from "./chunk-R4EYLEIK.js";
6
+ } from "./chunk-L7U3G4XR.js";
7
7
  import {
8
8
  isValidRepoSyncId
9
- } from "./chunk-HZI5PBN4.js";
9
+ } from "./chunk-BVGASV3B.js";
10
10
 
11
11
  // src/hooks/prim-hook-core.ts
12
12
  import { createHash, randomUUID } from "crypto";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  atomicWriteFile,
3
3
  repoActiveFlag
4
- } from "./chunk-HZI5PBN4.js";
4
+ } from "./chunk-BVGASV3B.js";
5
5
 
6
6
  // src/lib/commit-heartbeat.ts
7
7
  import { execFileSync } from "child_process";
@@ -1,12 +1,10 @@
1
1
  import {
2
2
  boundedHealthError
3
- } from "./chunk-WGTUNUIS.js";
3
+ } from "./chunk-QSDWWEHF.js";
4
4
  import {
5
+ hasMachineConfiguration,
5
6
  stripControlChars
6
- } from "./chunk-NVDPKW7Z.js";
7
- import {
8
- hasMachineConfiguration
9
- } from "./chunk-HZI5PBN4.js";
7
+ } from "./chunk-BVGASV3B.js";
10
8
 
11
9
  // src/lib/delivery-backlog.ts
12
10
  var MS_PER_SECOND = 1e3;