@nyte-ai/core 0.0.18 → 0.0.19

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 (175) hide show
  1. package/README.md +1 -1
  2. package/THIRD-PARTY-NOTICES.md +66 -0
  3. package/dist/chunks/{compose-q1b0tppc.js → compose-0827b2k4.js} +4 -4
  4. package/dist/chunks/{compose-j3tkz0tb.js → compose-1g03zpvn.js} +6 -6
  5. package/dist/chunks/{compose-2g3enfv5.js → compose-31zqcfte.js} +4 -4
  6. package/dist/chunks/{compose-4b1zf3p0.js → compose-4770pb1s.js} +62 -46
  7. package/dist/chunks/{compose-madtxnp1.js → compose-47f47sgy.js} +7 -7
  8. package/dist/chunks/{compose-1z7q169s.js → compose-5489evqa.js} +67 -39
  9. package/dist/chunks/{compose-yk3y0jap.js → compose-54svedb8.js} +7 -7
  10. package/dist/chunks/{compose-9tqm6g18.js → compose-57j0pme0.js} +4 -4
  11. package/dist/chunks/{compose-k8aghhv2.js → compose-5cmp34zp.js} +16 -16
  12. package/dist/chunks/compose-5rg7askh.js +52 -0
  13. package/dist/chunks/{compose-mryw0674.js → compose-5z835ej2.js} +6 -1
  14. package/dist/chunks/{compose-7k6nsmtq.js → compose-6gt28900.js} +11 -14
  15. package/dist/chunks/{compose-q1n2dgrs.js → compose-6m60v1pk.js} +4 -4
  16. package/dist/chunks/{compose-2eg8w67t.js → compose-6r5ymwyr.js} +15 -4
  17. package/dist/chunks/{compose-q1ts0v6k.js → compose-767bb340.js} +1 -1
  18. package/dist/chunks/{compose-pgeemk2b.js → compose-a7k9h27z.js} +6 -5
  19. package/dist/chunks/{compose-wgphshsn.js → compose-azq5jxr2.js} +7 -7
  20. package/dist/chunks/compose-bd8c5n7k.js +32 -0
  21. package/dist/chunks/{compose-drdej9yt.js → compose-c2rnebv0.js} +3 -3
  22. package/dist/chunks/compose-c4238qkb.js +105 -0
  23. package/dist/chunks/{compose-djq2bt61.js → compose-ccrh32hd.js} +6 -6
  24. package/dist/chunks/{compose-kb22bkpt.js → compose-cqpjcx2t.js} +12 -1
  25. package/dist/chunks/{compose-dbx6ftbm.js → compose-csh5vv2t.js} +42 -4
  26. package/dist/chunks/{compose-jc22rsz4.js → compose-dbsn3bsy.js} +2 -2
  27. package/dist/chunks/{compose-rehp8epe.js → compose-eemt6sea.js} +7 -7
  28. package/dist/chunks/{compose-r7dx7rpz.js → compose-exfx5b4d.js} +72 -15
  29. package/dist/chunks/{compose-p3q14yt1.js → compose-g2a1f1yx.js} +5 -5
  30. package/dist/chunks/compose-gvm49f4b.js +155 -0
  31. package/dist/chunks/{compose-9m19b27b.js → compose-gvrqkyn4.js} +7 -7
  32. package/dist/chunks/{compose-1jz2j92f.js → compose-gxjc6vz9.js} +30 -2
  33. package/dist/chunks/{compose-s2aew2c9.js → compose-gxvetm0j.js} +5 -5
  34. package/dist/chunks/{compose-cq1zx4gp.js → compose-h14pmqv3.js} +1 -1
  35. package/dist/chunks/{compose-5w5bbakh.js → compose-h3pch7ch.js} +5 -5
  36. package/dist/chunks/{compose-r12cnkpc.js → compose-hf6xkwdw.js} +10 -10
  37. package/dist/chunks/{compose-aa73dbe8.js → compose-hms4hf6p.js} +92 -49
  38. package/dist/chunks/{compose-jjchxce6.js → compose-j42p9wfs.js} +1 -1
  39. package/dist/chunks/{compose-vmhv4e00.js → compose-jehg40ce.js} +13 -12
  40. package/dist/chunks/{compose-5tkyrzr0.js → compose-jhs91x01.js} +4 -4
  41. package/dist/chunks/{compose-xd0kdp3t.js → compose-jrqn6xhy.js} +8 -8
  42. package/dist/chunks/{compose-ef936rsa.js → compose-ks2rdteq.js} +27 -11
  43. package/dist/chunks/{compose-k35b75k9.js → compose-kwkna3cg.js} +2 -4
  44. package/dist/chunks/{compose-gaps3heh.js → compose-m1ecjzm2.js} +8 -8
  45. package/dist/chunks/{compose-xtkavyrw.js → compose-m6nsbnkk.js} +17 -9
  46. package/dist/chunks/{compose-y478gv6x.js → compose-mamr4qwf.js} +4 -4
  47. package/dist/chunks/{compose-j12n448k.js → compose-nj4nj5n9.js} +36 -3
  48. package/dist/chunks/{compose-cdy4q5mv.js → compose-pe0cgbv0.js} +17 -16
  49. package/dist/chunks/{compose-xpfr4wt3.js → compose-pnsvwd3m.js} +7 -4
  50. package/dist/chunks/{compose-52afaf3v.js → compose-prchdrqk.js} +7 -7
  51. package/dist/chunks/{compose-7pc3p5ex.js → compose-q1d09qpr.js} +8 -8
  52. package/dist/chunks/{compose-amr0k1m1.js → compose-q1rrtq3a.js} +2 -2
  53. package/dist/chunks/{compose-0bpspysf.js → compose-qknd62yj.js} +5 -5
  54. package/dist/chunks/{compose-b5xz0dj7.js → compose-qwbe95qs.js} +2 -2
  55. package/dist/chunks/{compose-064y3n82.js → compose-r1pxdxbw.js} +5 -5
  56. package/dist/chunks/{compose-7b8ajk7a.js → compose-rd5e5nxg.js} +8 -8
  57. package/dist/chunks/{compose-gg8b9b21.js → compose-s5522cth.js} +23 -18
  58. package/dist/chunks/{compose-t53j8yxv.js → compose-se7wwcq1.js} +1 -1
  59. package/dist/chunks/{compose-dc2ns6gd.js → compose-seyhq3fb.js} +10 -10
  60. package/dist/chunks/{compose-ffk8dnbh.js → compose-smsafpqe.js} +3 -3
  61. package/dist/chunks/{compose-eqr5qwp1.js → compose-tb5ywdfk.js} +56 -21
  62. package/dist/chunks/{compose-dckpgtks.js → compose-ts08bth2.js} +3 -3
  63. package/dist/chunks/{compose-1gd9vkye.js → compose-v9yf9mrh.js} +3 -3
  64. package/dist/chunks/{compose-n10w4nkk.js → compose-vn7b7fdj.js} +12 -3
  65. package/dist/chunks/{compose-kmzr06mw.js → compose-w2ac7xjx.js} +8 -5
  66. package/dist/chunks/{compose-rpq9n0nz.js → compose-xaegezm3.js} +84 -26
  67. package/dist/chunks/{compose-6vf6dkk2.js → compose-xhtgytrh.js} +2 -2
  68. package/dist/chunks/{compose-4tb2vn84.js → compose-y6xgbg2h.js} +1 -1
  69. package/dist/chunks/{compose-yn2et568.js → compose-y9c31w4e.js} +118 -9
  70. package/dist/chunks/{compose-h272znxk.js → compose-z6hbq6y0.js} +7 -7
  71. package/dist/chunks/{compose-d2s80zg2.js → compose-zch4zapc.js} +5 -5
  72. package/dist/src/agent/compaction.js +39 -37
  73. package/dist/src/agent/images.d.ts +7 -0
  74. package/dist/src/agent/images.js +8 -0
  75. package/dist/src/agent/request.js +28 -28
  76. package/dist/src/agent/tool-runner.d.ts +1 -7
  77. package/dist/src/agent/tool-runner.js +29 -28
  78. package/dist/src/agent/transcript.d.ts +0 -1
  79. package/dist/src/agent/transcript.js +35 -33
  80. package/dist/src/agent/turn.js +43 -41
  81. package/dist/src/api/connection.js +56 -53
  82. package/dist/src/api/head.js +39 -39
  83. package/dist/src/api/part.js +20 -20
  84. package/dist/src/api/server.js +45 -42
  85. package/dist/src/api/session.js +44 -44
  86. package/dist/src/builtins/environment.js +1 -1
  87. package/dist/src/compose.d.ts +6 -7
  88. package/dist/src/compose.js +68 -64
  89. package/dist/src/contract/fold.d.ts +1 -3
  90. package/dist/src/contract/host.d.ts +30 -1
  91. package/dist/src/contract/host.js +4 -2
  92. package/dist/src/contract/kernel.d.ts +6 -35
  93. package/dist/src/contract/records.d.ts +69 -3
  94. package/dist/src/contract/records.js +5 -1
  95. package/dist/src/contract/session.d.ts +2 -1
  96. package/dist/src/contract/workspace.d.ts +5 -3
  97. package/dist/src/drive/execution.js +43 -40
  98. package/dist/src/drive/interruptions.d.ts +7 -0
  99. package/dist/src/drive/interruptions.js +17 -0
  100. package/dist/src/engine/admission.js +22 -22
  101. package/dist/src/engine/batches.js +21 -21
  102. package/dist/src/engine/branch-summary.js +20 -20
  103. package/dist/src/engine/durable.d.ts +0 -2
  104. package/dist/src/engine/durable.js +19 -19
  105. package/dist/src/engine/fence.js +19 -19
  106. package/dist/src/engine/jobs.d.ts +1 -0
  107. package/dist/src/engine/jobs.js +27 -25
  108. package/dist/src/engine/move.js +22 -22
  109. package/dist/src/engine/presence.d.ts +39 -0
  110. package/dist/src/engine/presence.js +16 -0
  111. package/dist/src/engine/principals.js +16 -16
  112. package/dist/src/engine/receipts.js +20 -20
  113. package/dist/src/engine/runs.d.ts +1 -1
  114. package/dist/src/engine/runs.js +23 -23
  115. package/dist/src/engine/start.js +33 -33
  116. package/dist/src/engine/surface.d.ts +4 -0
  117. package/dist/src/engine/surface.js +13 -0
  118. package/dist/src/engine/waits.d.ts +5 -15
  119. package/dist/src/engine/waits.js +22 -18
  120. package/dist/src/env/browser.js +25 -25
  121. package/dist/src/env/environment.js +27 -27
  122. package/dist/src/env/mcp.js +29 -29
  123. package/dist/src/env/trust.js +28 -28
  124. package/dist/src/env/workspaces.js +31 -31
  125. package/dist/src/env/worktrees.js +32 -32
  126. package/dist/src/extend/activation.js +32 -32
  127. package/dist/src/extend/hooks.js +21 -21
  128. package/dist/src/extend/models.d.ts +2 -1
  129. package/dist/src/extend/models.js +30 -28
  130. package/dist/src/extend/plugin-api.js +17 -17
  131. package/dist/src/extend/plugin-runtime.js +38 -38
  132. package/dist/src/extend/registry.js +25 -25
  133. package/dist/src/extend/resources.js +29 -29
  134. package/dist/src/extend/setting-layers.js +4 -4
  135. package/dist/src/extend/settings.js +35 -35
  136. package/dist/src/extend/workspace-commands.js +39 -39
  137. package/dist/src/fold/calls.js +5 -5
  138. package/dist/src/fold/checkpoint.js +11 -11
  139. package/dist/src/fold/code.d.ts +1 -2
  140. package/dist/src/fold/code.js +1 -1
  141. package/dist/src/fold/commit.d.ts +0 -4
  142. package/dist/src/fold/commit.js +15 -15
  143. package/dist/src/fold/draft.js +4 -4
  144. package/dist/src/fold/fold.js +7 -7
  145. package/dist/src/fold/paths.js +5 -5
  146. package/dist/src/fold/project.d.ts +3 -1
  147. package/dist/src/fold/project.js +8 -6
  148. package/dist/src/fold/reads.js +5 -5
  149. package/dist/src/fold/seen.js +18 -18
  150. package/dist/src/fold/view.d.ts +1 -1
  151. package/dist/src/fold/view.js +19 -19
  152. package/dist/src/fold/watch.js +14 -14
  153. package/dist/src/harness.d.ts +2 -1
  154. package/dist/src/harness.js +71 -67
  155. package/dist/src/index.d.ts +2 -2
  156. package/dist/src/index.js +4 -2
  157. package/dist/src/server.js +66 -62
  158. package/dist/src/store/inspect.js +4 -4
  159. package/dist/src/store/log.d.ts +0 -2
  160. package/dist/src/store/log.js +2 -2
  161. package/dist/src/store/memory-store.js +5 -5
  162. package/dist/src/store/migrations.js +3 -3
  163. package/dist/src/store/model-state.d.ts +6 -1
  164. package/dist/src/store/model-state.js +14 -4
  165. package/dist/src/store/parts.js +4 -4
  166. package/dist/src/store/refs.d.ts +6 -5
  167. package/dist/src/store/refs.js +11 -1
  168. package/dist/src/store/session-index.js +2 -2
  169. package/dist/src/store/session.d.ts +3 -1
  170. package/dist/src/store/session.js +5 -3
  171. package/dist/src/store.d.ts +1 -1
  172. package/dist/src/store.js +11 -7
  173. package/dist/src/testing.d.ts +2 -0
  174. package/dist/src/testing.js +77 -65
  175. package/package.json +4 -4
@@ -33,6 +33,9 @@ function endedRunRef2(id, run) {
33
33
  function liveRef2(id, run) {
34
34
  return `sessions/${id}/live/${run}`;
35
35
  }
36
+ function runCallsPrefix2(id, run) {
37
+ return `sessions/${id}/calls/${run}:`;
38
+ }
36
39
  function partRef2(id, part) {
37
40
  return `sessions/${id}/parts/${part}`;
38
41
  }
@@ -57,6 +60,14 @@ function kvRef2(scope, owner, key) {
57
60
  function leaseRef2(id, head) {
58
61
  return `sessions/${id}/leases/${head}`;
59
62
  }
63
+ var PROCESSES2 = "processes/";
64
+ function processRef2(instance) {
65
+ return `${PROCESSES2}${instance}`;
66
+ }
67
+ var JOBS2 = "jobs/";
68
+ function jobRef2(id) {
69
+ return `${JOBS2}${id}`;
70
+ }
60
71
  function hostIdentityRef2() {
61
72
  return "host/identity";
62
73
  }
@@ -64,4 +75,4 @@ function hostPrincipalsRef2() {
64
75
  return "host/principals";
65
76
  }
66
77
 
67
- export { sessionRef2, parseSessionRef2, parseHeadRef2, headRef2, inboxRef2, seenRef2, runRef2, endedRunRef2, liveRef2, partRef2, receiptRef2, callRef2, workspaceRef2, trustRef2, trustTarget2, kvRef2, leaseRef2, hostIdentityRef2, hostPrincipalsRef2 };
78
+ export { sessionRef2, parseSessionRef2, parseHeadRef2, headRef2, inboxRef2, seenRef2, runRef2, endedRunRef2, liveRef2, runCallsPrefix2, partRef2, receiptRef2, callRef2, workspaceRef2, trustRef2, trustTarget2, kvRef2, leaseRef2, PROCESSES2, processRef2, JOBS2, jobRef2, hostIdentityRef2, hostPrincipalsRef2 };
@@ -1,15 +1,53 @@
1
1
  import {
2
2
  decodeKvValue2
3
- } from "./compose-1jz2j92f.js";
3
+ } from "./compose-gxjc6vz9.js";
4
4
  import {
5
5
  kvRef2
6
- } from "./compose-kb22bkpt.js";
6
+ } from "./compose-cqpjcx2t.js";
7
7
 
8
8
  // src/store/model-state.ts
9
- import { ModelRefType } from "@nyte-ai/schema";
9
+ import { ModelRefType, ThinkingType } from "@nyte-ai/schema";
10
+ import { Type } from "typebox";
10
11
  import { Value } from "typebox/value";
11
12
  var CHECK_INTERVAL_MS = 60000;
12
13
  var MODEL_PREFERENCE2 = kvRef2("host", "models", "default");
14
+ var THINKING_PREFERENCES = kvRef2("host", "models", "thinking/");
15
+ var MODEL_LISTINGS = kvRef2("host", "models", "listing/");
16
+ var SavedListingType = Type.Enum(["hidden", "favorite"]);
17
+ function modelListingRef2(model) {
18
+ return `${MODEL_LISTINGS}${model.provider}/${model.id}`;
19
+ }
20
+ async function readModelListings2(store) {
21
+ const refs = await store.refs.list(MODEL_LISTINGS);
22
+ const entries = await Promise.all(refs.map(async (ref) => {
23
+ if (ref.target === null)
24
+ return [];
25
+ const value = decodeKvValue2(await store.objects.get(ref.target));
26
+ return Value.Check(SavedListingType, value) ? [[ref.name.slice(MODEL_LISTINGS.length), value]] : [];
27
+ }));
28
+ return new Map(entries.flat());
29
+ }
30
+ function thinkingPreferenceRef2(model) {
31
+ return `${THINKING_PREFERENCES}${model.provider}/${model.id}`;
32
+ }
33
+ async function readThinkingPreference2(store, model) {
34
+ const ref = await store.refs.get(thinkingPreferenceRef2(model));
35
+ return ref === null || ref.target === null ? undefined : decodeThinking(await store.objects.get(ref.target));
36
+ }
37
+ async function readThinkingPreferences2(store) {
38
+ const refs = await store.refs.list(THINKING_PREFERENCES);
39
+ const entries = await Promise.all(refs.map(async (ref) => {
40
+ if (ref.target === null)
41
+ return [];
42
+ const level = decodeThinking(await store.objects.get(ref.target));
43
+ return level === undefined ? [] : [[ref.name.slice(THINKING_PREFERENCES.length), level]];
44
+ }));
45
+ return new Map(entries.flat());
46
+ }
47
+ function decodeThinking(object) {
48
+ const value = decodeKvValue2(object);
49
+ return Value.Check(ThinkingType, value) ? value : undefined;
50
+ }
13
51
  async function readModelSelection2(store) {
14
52
  const ref = await store.refs.get(MODEL_PREFERENCE2);
15
53
  const value = ref === null || ref.target === null ? undefined : decodeKvValue2(await store.objects.get(ref.target));
@@ -147,4 +185,4 @@ function createModelState2(changed) {
147
185
  };
148
186
  }
149
187
 
150
- export { MODEL_PREFERENCE2, readModelSelection2, createModelState2 };
188
+ export { MODEL_PREFERENCE2, modelListingRef2, readModelListings2, thinkingPreferenceRef2, readThinkingPreference2, readThinkingPreferences2, readModelSelection2, createModelState2 };
@@ -4,14 +4,14 @@ import {
4
4
  import {
5
5
  walkCommitPath2,
6
6
  readPositionCommit2
7
- } from "./compose-n10w4nkk.js";
7
+ } from "./compose-vn7b7fdj.js";
8
8
  import {
9
9
  committed2,
10
10
  setTurn2,
11
11
  stale2,
12
12
  reuse2,
13
13
  toPartMessageId2
14
- } from "./compose-cq1zx4gp.js";
14
+ } from "./compose-h14pmqv3.js";
15
15
 
16
16
  // src/fold/paths.ts
17
17
  function finish2(state, draft) {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  decodePartRecord2
3
- } from "./compose-1jz2j92f.js";
3
+ } from "./compose-gxjc6vz9.js";
4
4
  import {
5
5
  partRef2
6
- } from "./compose-kb22bkpt.js";
6
+ } from "./compose-cqpjcx2t.js";
7
7
  import {
8
8
  dev2
9
9
  } from "./compose-n116fnmp.js";
@@ -11,17 +11,17 @@ import {
11
11
  load2,
12
12
  put2,
13
13
  readCall2
14
- } from "./compose-n10w4nkk.js";
14
+ } from "./compose-vn7b7fdj.js";
15
15
  import {
16
16
  storedAnswer2
17
- } from "./compose-drdej9yt.js";
17
+ } from "./compose-c2rnebv0.js";
18
18
  import {
19
19
  waitIndex2,
20
20
  wokenIndex2
21
21
  } from "./compose-0wq555bd.js";
22
22
  import {
23
23
  changeCall2
24
- } from "./compose-xpfr4wt3.js";
24
+ } from "./compose-pnsvwd3m.js";
25
25
  import {
26
26
  holdLease2
27
27
  } from "./compose-vzvm76dn.js";
@@ -30,7 +30,7 @@ import {
30
30
  readParkedWait2,
31
31
  waitingOn2,
32
32
  lapsed2
33
- } from "./compose-ef936rsa.js";
33
+ } from "./compose-ks2rdteq.js";
34
34
 
35
35
  // src/engine/durable.ts
36
36
  import { isJson, isJsonObject, SdkError } from "@nyte-ai/schema";
@@ -88,7 +88,7 @@ async function runStep2(kernel, input) {
88
88
  dev2("durable", "replayed", { session, call });
89
89
  return { kind: "done", value: read(record.result) };
90
90
  }
91
- if (!opened.wrote && input.replay === "never") {
91
+ if (!opened.wrote && record.replay === "never") {
92
92
  return { kind: "interrupted", value: await settle({ kind: "interrupted" }) };
93
93
  }
94
94
  const writes = [];
@@ -3,24 +3,29 @@ import {
3
3
  } from "./compose-q6c7wswc.js";
4
4
  import {
5
5
  put2
6
- } from "./compose-n10w4nkk.js";
6
+ } from "./compose-vn7b7fdj.js";
7
7
  import {
8
8
  convertJsonSchema2,
9
9
  check2
10
10
  } from "./compose-bj54tkph.js";
11
11
  import {
12
12
  commit2
13
- } from "./compose-xpfr4wt3.js";
13
+ } from "./compose-pnsvwd3m.js";
14
14
  import {
15
15
  MODEL_PREFERENCE2,
16
+ modelListingRef2,
17
+ readModelListings2,
18
+ thinkingPreferenceRef2,
19
+ readThinkingPreference2,
20
+ readThinkingPreferences2,
16
21
  readModelSelection2
17
- } from "./compose-dbx6ftbm.js";
22
+ } from "./compose-csh5vv2t.js";
18
23
  import {
19
24
  closable2
20
25
  } from "./compose-zfjxkavf.js";
21
26
  import {
22
27
  bumpGeneration2
23
- } from "./compose-064y3n82.js";
28
+ } from "./compose-r1pxdxbw.js";
24
29
 
25
30
  // src/extend/models.ts
26
31
  import { SdkError } from "@nyte-ai/schema";
@@ -81,6 +86,14 @@ function createModelsApi2(kernel, models) {
81
86
  bumpGeneration2(kernel);
82
87
  return { kind: "set" };
83
88
  },
89
+ async setListing(refs, listing) {
90
+ if (refs.some((ref) => models.getModel(ref.provider, ref.id) === undefined))
91
+ return { kind: "unknown-model" };
92
+ const target = listing === "shown" ? null : await put2(kernel.store, "kv", listing);
93
+ await commit2(kernel, refs.map((ref) => ({ name: modelListingRef2(ref), target })));
94
+ bumpGeneration2(kernel);
95
+ return { kind: "set" };
96
+ },
84
97
  async verify(provider) {
85
98
  let verification;
86
99
  try {
@@ -109,8 +122,10 @@ function createModelsApi2(kernel, models) {
109
122
  async function modelCatalog(kernel, models) {
110
123
  const generation = kernel.host.current().catalog;
111
124
  const policies = staticPolicies(kernel);
112
- const [preferred, credentials] = await Promise.all([
125
+ const [preferred, remembered, listed, credentials] = await Promise.all([
113
126
  readModelSelection2(kernel.store),
127
+ readThinkingPreferences2(kernel.store),
128
+ readModelListings2(kernel.store),
114
129
  kernel.modelState.read(models)
115
130
  ]);
116
131
  const providers = models.getProviders().map((provider) => {
@@ -119,13 +134,19 @@ async function modelCatalog(kernel, models) {
119
134
  for (const model of catalog)
120
135
  if (model.variant?.mode === "fast" && !fast.has(model.variant.base))
121
136
  fast.set(model.variant.base, { provider: model.provider, id: model.id });
137
+ const base = catalog.filter((model) => model.variant === undefined);
138
+ const listings = Object.fromEntries(base.flatMap((model) => {
139
+ const listing = listed.get(formatModelKey(model));
140
+ return listing === undefined ? [] : [[model.id, listing]];
141
+ }));
122
142
  return {
123
143
  id: provider.id,
124
144
  name: provider.name,
125
145
  credential: credentials.get(provider.id) ?? "unknown",
126
146
  methods: listLoginMethods(provider),
127
147
  limits: readProviderLimits(models, provider.id),
128
- models: catalog.filter((model) => model.variant === undefined).map((model) => projectModel(model, fast.get(model.id) ?? null, policies.get(formatModelKey(model)), provider.capabilities))
148
+ listings,
149
+ models: base.map((model) => projectModel(model, fast.get(model.id) ?? null, policies.get(formatModelKey(model)), provider.capabilities, remembered.get(formatModelKey(model))))
129
150
  };
130
151
  });
131
152
  const fallback = providers.find((provider) => models.getProvider(provider.id)?.explicitOnly !== true && (provider.credential === "configured" || provider.credential === "verified") && provider.models.length > 0)?.models[0]?.ref ?? null;
@@ -138,7 +159,7 @@ function modelInfo2(models, ref, runtime) {
138
159
  return null;
139
160
  const policy = runtime.registries.modelContext.list().findLast((entry) => formatModelKey(entry.model) === formatModelKey(ref));
140
161
  const fast = catalog.find((entry) => entry.variant?.mode === "fast" && entry.variant.base === model.id);
141
- return projectModel(model, fast === undefined ? null : { provider: fast.provider, id: fast.id }, policy, models.getProvider(model.provider)?.capabilities);
162
+ return projectModel(model, fast === undefined ? null : { provider: fast.provider, id: fast.id }, policy, models.getProvider(model.provider)?.capabilities, undefined);
142
163
  }
143
164
  function createLogin2(kernel, models, input) {
144
165
  let pending = null;
@@ -264,13 +285,13 @@ async function defaultModel(kernel, models) {
264
285
  return null;
265
286
  }
266
287
  var NYTE_LOOP = { steer: true };
267
- function projectModel(model, fast, policy, capabilities) {
288
+ function projectModel(model, fast, policy, capabilities, remembered) {
268
289
  return {
269
290
  ref: { provider: model.provider, id: model.id },
270
291
  name: model.name,
271
292
  reasoning: model.reasoning,
272
293
  thinking: acceptedThinkingLevels(model),
273
- defaultThinking: defaultThinkingLevel(model),
294
+ defaultThinking: defaultThinkingLevel(model, remembered),
274
295
  fast,
275
296
  contextWindow: policy?.contextWindow ?? model.contextWindow,
276
297
  compactAt: policy?.compactAt ?? Math.floor(model.contextWindow * 0.8),
@@ -416,7 +437,9 @@ async function resolvePatch(kernel, models, input) {
416
437
  if (model === undefined)
417
438
  return { kind: "unknown-model", model: ref };
418
439
  const issues = [];
419
- const thinking = selectThinkingLevel(model, patch.thinking, selected?.thinking);
440
+ const previous = selected === null ? undefined : models.getModel(selected.model.provider, selected.model.id);
441
+ const kept = previous !== undefined && formatModelKey(baseRef(previous)) === formatModelKey(baseRef(model)) ? selected?.thinking : undefined;
442
+ const thinking = await selectThinkingLevel(kernel, model, patch.thinking, kept);
420
443
  if (thinking === null)
421
444
  issues.push(issue(["thinking"], `${ref.id} does not accept that level.`));
422
445
  const settings = { ...selected?.settings, ...patch.settings };
@@ -442,19 +465,53 @@ async function resolvePatch(kernel, models, input) {
442
465
  settingsVersion: input.version
443
466
  };
444
467
  }
445
- function selectThinkingLevel(model, given, kept) {
468
+ async function selectThinkingLevel(kernel, model, given, kept) {
446
469
  const accepted = acceptedThinkingLevels(model);
447
470
  if (given !== undefined && given !== null)
448
471
  return accepted.includes(given) ? given : null;
449
472
  if (given === undefined && kept !== undefined)
450
473
  return accepted.includes(kept) ? kept : clampThinkingLevel(model, kept);
451
- return defaultThinkingLevel(model);
474
+ return defaultThinkingLevel(model, await readThinkingPreference2(kernel.store, baseRef(model)));
475
+ }
476
+ function baseRef(model) {
477
+ return { provider: model.provider, id: model.variant?.base ?? model.id };
452
478
  }
453
479
  function acceptedThinkingLevels(model) {
454
480
  return ["off", ...getSupportedThinkingLevels(model).filter((level) => level !== "off")];
455
481
  }
456
- function defaultThinkingLevel(model) {
457
- return model.reasoning ? acceptedThinkingLevels(model).find((level) => level !== "off") ?? "off" : "off";
482
+ function defaultThinkingLevel(model, remembered) {
483
+ const accepted = acceptedThinkingLevels(model);
484
+ if (remembered !== undefined && accepted.includes(remembered))
485
+ return remembered;
486
+ return model.reasoning ? accepted.find((level) => level !== "off") ?? "off" : "off";
487
+ }
488
+ async function rememberChoice2(kernel, models, choice, scope) {
489
+ const model = models.getModel(choice.model.provider, choice.model.id);
490
+ if (model === undefined)
491
+ return;
492
+ const base = baseRef(model);
493
+ const preferred = scope === "model" ? await readModelSelection2(kernel.store) : null;
494
+ const updates = [
495
+ ...scope === "model" && (preferred === null || formatModelKey(preferred) !== formatModelKey(choice.model)) ? [
496
+ {
497
+ name: MODEL_PREFERENCE2,
498
+ target: await put2(kernel.store, "kv", {
499
+ provider: choice.model.provider,
500
+ id: choice.model.id
501
+ })
502
+ }
503
+ ] : [],
504
+ ...await readThinkingPreference2(kernel.store, base) === choice.thinking ? [] : [
505
+ {
506
+ name: thinkingPreferenceRef2(base),
507
+ target: await put2(kernel.store, "kv", choice.thinking)
508
+ }
509
+ ]
510
+ ];
511
+ if (updates.length === 0)
512
+ return;
513
+ await commit2(kernel, updates);
514
+ bumpGeneration2(kernel);
458
515
  }
459
516
  function sessionScoped(settings) {
460
517
  return settings.filter((definition) => definition.scope === "session");
@@ -466,4 +523,4 @@ function issue(path, message) {
466
523
  return { severity: "error", path, message };
467
524
  }
468
525
 
469
- export { createModelsApi2, modelInfo2, createLogin2, withLimits2, createConfigurationResolver2, settingsVersion2 };
526
+ export { createModelsApi2, modelInfo2, createLogin2, withLimits2, createConfigurationResolver2, settingsVersion2, rememberChoice2 };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  headRef2,
3
3
  partRef2
4
- } from "./compose-kb22bkpt.js";
4
+ } from "./compose-cqpjcx2t.js";
5
5
  import {
6
6
  EMPTY_REVISION2,
7
7
  STALE2,
@@ -13,16 +13,16 @@ import {
13
13
  walkCommitPath2,
14
14
  toCommitObjectId2,
15
15
  guard2
16
- } from "./compose-n10w4nkk.js";
16
+ } from "./compose-vn7b7fdj.js";
17
17
  import {
18
18
  commit2
19
- } from "./compose-xpfr4wt3.js";
19
+ } from "./compose-pnsvwd3m.js";
20
20
  import {
21
21
  withFold2
22
- } from "./compose-6vf6dkk2.js";
22
+ } from "./compose-xhtgytrh.js";
23
23
  import {
24
24
  fence2
25
- } from "./compose-9m19b27b.js";
25
+ } from "./compose-gvrqkyn4.js";
26
26
 
27
27
  // src/engine/branch-summary.ts
28
28
  import { asId } from "@nyte-ai/schema";
@@ -0,0 +1,155 @@
1
+ import {
2
+ envelope2
3
+ } from "./compose-gxjc6vz9.js";
4
+ import {
5
+ PROCESSES2,
6
+ processRef2
7
+ } from "./compose-cqpjcx2t.js";
8
+ import {
9
+ dev2
10
+ } from "./compose-n116fnmp.js";
11
+
12
+ // src/engine/presence.ts
13
+ import { SdkError } from "@nyte-ai/schema";
14
+ var BEAT_MS2 = 5000;
15
+ var LAPSE_MS2 = 20000;
16
+ var FORGET_MS = 10 * 60000;
17
+ var GAP_MS = 2 * BEAT_MS2;
18
+ var REVOKED2 = "Another Nyte took over this one's work while it was paused, so this host stopped; it reopens on its own.";
19
+ async function openPresence2(raw, input) {
20
+ const name = processRef2(input.instance);
21
+ const body = envelope2("process", {
22
+ instance: input.instance,
23
+ holder: input.holder,
24
+ label: input.member.label,
25
+ pid: input.member.pid,
26
+ capabilities: [...input.member.capabilities],
27
+ startedAt: Date.now()
28
+ }, Date.now());
29
+ const target = await raw.objects.put(body);
30
+ const registered = await raw.refs.set([{ name, target, expect: "absent" }]);
31
+ if (registered.kind !== "set")
32
+ throw new SdkError("internal", `${name} already exists; process instances must be unique.`);
33
+ let revision = registered.revisions[0];
34
+ const revocation = new AbortController;
35
+ const seen = new Map;
36
+ let wroteAt = performance.now();
37
+ let beating = false;
38
+ let closed = false;
39
+ const revoke = () => {
40
+ if (revocation.signal.aborted)
41
+ return;
42
+ dev2("presence", "revoked", { instance: input.instance });
43
+ clearInterval(timer);
44
+ revocation.abort();
45
+ };
46
+ const wrote = () => {
47
+ const now = performance.now();
48
+ if (now - wroteAt > GAP_MS)
49
+ for (const entry of seen.values())
50
+ entry.since = now;
51
+ wroteAt = now;
52
+ };
53
+ const writable = (now) => now - wroteAt <= GAP_MS;
54
+ const observe = (instance, current, now) => {
55
+ const known = seen.get(instance);
56
+ if (known !== undefined && known.revision === current)
57
+ return known;
58
+ const fresh = { revision: current, since: now };
59
+ seen.set(instance, fresh);
60
+ return fresh;
61
+ };
62
+ const beat = async () => {
63
+ if (beating || closed || revocation.signal.aborted)
64
+ return;
65
+ beating = true;
66
+ try {
67
+ const outcome = await raw.refs.set([{ name, target, expect: revision }]);
68
+ if (outcome.kind !== "set")
69
+ return revoke();
70
+ revision = outcome.revisions[0];
71
+ wrote();
72
+ } catch (error) {
73
+ dev2("presence", "beat failed", {
74
+ error: error instanceof Error ? error.message : String(error)
75
+ });
76
+ } finally {
77
+ beating = false;
78
+ }
79
+ };
80
+ const timer = setInterval(() => void beat(), BEAT_MS2);
81
+ const store = {
82
+ ...raw,
83
+ refs: {
84
+ ...raw.refs,
85
+ async set(updates) {
86
+ if (revocation.signal.aborted)
87
+ throw new SdkError("unavailable", REVOKED2);
88
+ const outcome = await raw.refs.set(updates.map((update) => ({ ...update, fences: [...update.fences ?? [], name] })));
89
+ if (outcome.kind === "fenced" && outcome.name === name) {
90
+ revoke();
91
+ throw new SdkError("unavailable", REVOKED2);
92
+ }
93
+ return outcome;
94
+ }
95
+ }
96
+ };
97
+ return {
98
+ instance: input.instance,
99
+ member: input.member,
100
+ store,
101
+ revoked: revocation.signal,
102
+ async holder(instance) {
103
+ if (instance === input.instance)
104
+ return { kind: "me" };
105
+ const ref = await raw.refs.get(processRef2(instance));
106
+ const now = performance.now();
107
+ if (ref === null) {
108
+ seen.delete(instance);
109
+ return { kind: "absent" };
110
+ }
111
+ const lapsed = now - observe(instance, ref.revision, now).since;
112
+ return writable(now) && lapsed >= LAPSE_MS2 ? { kind: "dead", name: ref.name, expect: ref.revision } : { kind: "alive", until: Date.now() + Math.max(LAPSE_MS2 - lapsed, BEAT_MS2) };
113
+ },
114
+ async sweep() {
115
+ const listed = await raw.refs.list(PROCESSES2);
116
+ const now = performance.now();
117
+ const present = new Set;
118
+ for (const ref of listed) {
119
+ const instance = ref.name.slice(PROCESSES2.length);
120
+ present.add(instance);
121
+ if (instance === input.instance)
122
+ continue;
123
+ const known = observe(instance, ref.revision, now);
124
+ if (!writable(now) || now - known.since < FORGET_MS)
125
+ continue;
126
+ await raw.refs.set([{ name: ref.name, target: null, expect: ref.revision }]);
127
+ seen.delete(instance);
128
+ }
129
+ for (const instance of seen.keys())
130
+ if (!present.has(instance))
131
+ seen.delete(instance);
132
+ if (!present.has(input.instance) && !closed)
133
+ revoke();
134
+ },
135
+ async close(leases = []) {
136
+ if (closed)
137
+ return;
138
+ closed = true;
139
+ clearInterval(timer);
140
+ if (revocation.signal.aborted)
141
+ return;
142
+ const leaving = [
143
+ { name, target: null, expect: revision },
144
+ ...leases.map((lease) => ({ name: lease.name, target: null, expect: lease.expect }))
145
+ ];
146
+ const left = await raw.refs.set(leaving).catch(() => null);
147
+ if (left?.kind !== "set")
148
+ await raw.refs.set([{ name, target: null, expect: revision }]).catch(() => {
149
+ return;
150
+ });
151
+ }
152
+ };
153
+ }
154
+
155
+ export { BEAT_MS2, LAPSE_MS2, REVOKED2, openPresence2 };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  decodeRunRecord2
3
- } from "./compose-1jz2j92f.js";
3
+ } from "./compose-gxjc6vz9.js";
4
4
  import {
5
5
  inboxRef2,
6
6
  runRef2,
7
7
  liveRef2
8
- } from "./compose-kb22bkpt.js";
8
+ } from "./compose-cqpjcx2t.js";
9
9
  import {
10
10
  STALE2,
11
11
  load2,
@@ -17,20 +17,20 @@ import {
17
17
  put2,
18
18
  attempt2,
19
19
  readCall2
20
- } from "./compose-n10w4nkk.js";
20
+ } from "./compose-vn7b7fdj.js";
21
21
  import {
22
22
  stoppedParts2
23
- } from "./compose-drdej9yt.js";
23
+ } from "./compose-c2rnebv0.js";
24
24
  import {
25
25
  commit2
26
- } from "./compose-xpfr4wt3.js";
26
+ } from "./compose-pnsvwd3m.js";
27
27
  import {
28
28
  liveParts2,
29
29
  readRunEnd2
30
- } from "./compose-6vf6dkk2.js";
30
+ } from "./compose-xhtgytrh.js";
31
31
  import {
32
32
  readParkedWait2
33
- } from "./compose-ef936rsa.js";
33
+ } from "./compose-ks2rdteq.js";
34
34
 
35
35
  // src/engine/fence.ts
36
36
  var FENCED2 = { class: "aborted", message: "Stopped." };
@@ -8,6 +8,7 @@ import {
8
8
  cyclicWithJson,
9
9
  HeadInfoType,
10
10
  idSchema,
11
+ JobEndType,
11
12
  isJsonObject,
12
13
  JsonObjectType,
13
14
  JsonType,
@@ -71,7 +72,9 @@ var RunRecordType = record({
71
72
  usage: nullable(typed()(UsageType)),
72
73
  requests: Type.Number(),
73
74
  response: Type.Optional(typed()(UsageType)),
74
- parked: list(idSchema())
75
+ parked: list(idSchema()),
76
+ interrupted: Type.Optional(record({ count: Type.Number(), mark: Type.String() })),
77
+ requires: Type.Optional(list(Type.String()))
75
78
  });
76
79
  var PartRecordType = record({
77
80
  id: idSchema(),
@@ -174,6 +177,27 @@ var LeaseType = record({
174
177
  instance: Type.String(),
175
178
  expiresAt: Type.Number()
176
179
  });
180
+ var ProcessRecordType = record({
181
+ instance: Type.String(),
182
+ holder: idSchema(),
183
+ label: Type.String(),
184
+ pid: nullable(Type.Number()),
185
+ capabilities: list(Type.String()),
186
+ startedAt: Type.Number()
187
+ });
188
+ var JobRecordType = record({
189
+ id: idSchema(),
190
+ instance: Type.String(),
191
+ workspace: idSchema(),
192
+ session: idSchema(),
193
+ head: idSchema(),
194
+ startedBy: nullable(idSchema()),
195
+ title: Type.String(),
196
+ command: Type.String(),
197
+ startedAt: Type.Number(),
198
+ end: nullable(typed()(JobEndType)),
199
+ endedAt: nullable(Type.Number())
200
+ });
177
201
  var HostIdentityType = record({ id: idSchema(), createdAt: Type.Number() });
178
202
  var STORED_RECORD_TYPES2 = {
179
203
  session: SessionRecordType,
@@ -186,6 +210,8 @@ var STORED_RECORD_TYPES2 = {
186
210
  workspace: WorkspaceRecordType,
187
211
  trust: TrustRecordType,
188
212
  lease: LeaseType,
213
+ process: ProcessRecordType,
214
+ job: JobRecordType,
189
215
  call: CallRecordType,
190
216
  principals: PrincipalRecordType,
191
217
  identity: HostIdentityType
@@ -205,6 +231,8 @@ var decodeTrustRecord2 = decoder("trust", TrustRecordType);
205
231
  var decodeCallRecord2 = decoder("call", CallRecordType);
206
232
  var decodePrincipalRecord2 = decoder("principals", PrincipalRecordType);
207
233
  var decodeLease2 = decoder("lease", LeaseType);
234
+ var decodeProcessRecord2 = decoder("process", ProcessRecordType);
235
+ var decodeJobRecord2 = decoder("job", JobRecordType);
208
236
  var decodeHostIdentity2 = decoder("identity", HostIdentityType);
209
237
  function decodeKvValue2(object) {
210
238
  return isJsonObject(object) && object.kind === "kv" ? object.body : undefined;
@@ -226,4 +254,4 @@ function nullable(schema) {
226
254
  return Type.Union([schema, Type.Null()]);
227
255
  }
228
256
 
229
- export { STORED_RECORD_TYPES2, envelope2, decodeSessionRecord2, decodeCommitRecord2, decodeRunRecord2, decodeSeenRecord2, decodeInboxRecord2, decodePartRecord2, decodeReceiptRecord2, decodeWorkspaceRecord2, decodeTrustRecord2, decodeCallRecord2, decodePrincipalRecord2, decodeLease2, decodeHostIdentity2, decodeKvValue2 };
257
+ export { STORED_RECORD_TYPES2, envelope2, decodeSessionRecord2, decodeCommitRecord2, decodeRunRecord2, decodeSeenRecord2, decodeInboxRecord2, decodePartRecord2, decodeReceiptRecord2, decodeWorkspaceRecord2, decodeTrustRecord2, decodeCallRecord2, decodePrincipalRecord2, decodeLease2, decodeProcessRecord2, decodeJobRecord2, decodeHostIdentity2, decodeKvValue2 };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./compose-q6c7wswc.js";
4
4
  import {
5
5
  workspaceRef2
6
- } from "./compose-kb22bkpt.js";
6
+ } from "./compose-cqpjcx2t.js";
7
7
  import {
8
8
  dev2
9
9
  } from "./compose-n116fnmp.js";
@@ -11,19 +11,19 @@ import {
11
11
  STALE2,
12
12
  put2,
13
13
  attempt2
14
- } from "./compose-n10w4nkk.js";
14
+ } from "./compose-vn7b7fdj.js";
15
15
  import {
16
16
  commit2
17
- } from "./compose-xpfr4wt3.js";
17
+ } from "./compose-pnsvwd3m.js";
18
18
  import {
19
19
  readWorkspace2,
20
20
  workspaceRecords2
21
- } from "./compose-0bpspysf.js";
21
+ } from "./compose-qknd62yj.js";
22
22
  import {
23
23
  sessionsOn2,
24
24
  byIdentity2,
25
25
  changed2
26
- } from "./compose-eqr5qwp1.js";
26
+ } from "./compose-tb5ywdfk.js";
27
27
 
28
28
  // src/env/worktrees.ts
29
29
  import { asId, SdkError } from "@nyte-ai/schema";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  START2
3
- } from "./compose-n10w4nkk.js";
3
+ } from "./compose-vn7b7fdj.js";
4
4
 
5
5
  // src/fold/draft.ts
6
6
  import { asId } from "@nyte-ai/schema";