@theokit/sdk 4.45.0 → 4.46.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.46.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dbead57: `foldLayers` / `verifyLayerOrdering` — combine configuration layers in a declared order.
8
+
9
+ Later layers win, `undefined` never overwrites, and named keys ACCUMULATE instead of being
10
+ replaced. That last rule is not a nicety: with plain last-wins a project file DISPLACES the user's
11
+ entries for a list-valued key rather than adding to them, and for a key like `hooks` — arbitrary
12
+ command execution on every tool call — that is the difference between a repository adding a hook and
13
+ a repository removing yours.
14
+
15
+ `verifyLayerOrdering` refuses a chain that is not strictly ascending, naming both layers and both
16
+ precedences. Tolerating it would make resolution depend on array order rather than on declared
17
+ precedence: two sources of truth for one decision.
18
+
19
+ The layer NAMES are the caller's, supplied as data — one product's chain is
20
+ defaults/user/project/profile/env/cli and `profile` is that product's idea. Entries may omit
21
+ `precedence` to mean "this array is already the order".
22
+
23
+ Additive. Nothing calls it yet.
24
+
3
25
  ## 4.45.0
4
26
 
5
27
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -919,6 +919,42 @@ var JobQueue = class {
919
919
  if (next !== void 0) next();
920
920
  }
921
921
  };
922
+
923
+ // src/layer-fold.ts
924
+ var LayerOrderError = class extends chunkYULF6FPB_cjs.TheokitAgentError {
925
+ name = "LayerOrderError";
926
+ };
927
+ function verifyLayerOrdering(layers) {
928
+ let previous;
929
+ for (const current of layers) {
930
+ if (current.precedence === void 0) continue;
931
+ const declared = { layer: current.layer, precedence: current.precedence };
932
+ if (previous !== void 0 && declared.precedence <= previous.precedence) {
933
+ throw new LayerOrderError(
934
+ `layers out of order: \`${declared.layer}\` (precedence ${String(declared.precedence)}) comes after \`${previous.layer}\` (precedence ${String(previous.precedence)}) but does not outrank it`
935
+ );
936
+ }
937
+ previous = declared;
938
+ }
939
+ }
940
+ function foldLayers(entries, accumulatingKeys = []) {
941
+ verifyLayerOrdering(entries);
942
+ const accumulated = new Map(accumulatingKeys.map((k) => [k, []]));
943
+ const combined = {};
944
+ for (const { values } of entries) {
945
+ for (const [key, value] of Object.entries(values)) {
946
+ if (value === void 0) continue;
947
+ const stack = accumulated.get(key);
948
+ if (stack !== void 0 && Array.isArray(value)) {
949
+ stack.push(...value);
950
+ combined[key] = [...stack];
951
+ continue;
952
+ }
953
+ combined[key] = value;
954
+ }
955
+ }
956
+ return combined;
957
+ }
922
958
  function diaryPath(cwd) {
923
959
  return path.join(chunkGH52NOCL_cjs.memoryDir(cwd), "dream-diary.md");
924
960
  }
@@ -2284,6 +2320,7 @@ exports.AgentFactory = AgentFactory;
2284
2320
  exports.Budget = Budget;
2285
2321
  exports.EventBus = EventBus;
2286
2322
  exports.JobQueue = JobQueue;
2323
+ exports.LayerOrderError = LayerOrderError;
2287
2324
  exports.Memory = Memory;
2288
2325
  exports.NoopMemoryProvider = NoopMemoryProvider;
2289
2326
  exports.PermissionEngine = PermissionEngine;
@@ -2305,6 +2342,7 @@ exports.chargeAndCheckThresholds = chargeAndCheckThresholds;
2305
2342
  exports.createCounterBudgetTracker = createCounterBudgetTracker;
2306
2343
  exports.estimateTokens = estimateTokens;
2307
2344
  exports.extractRawId = extractRawId;
2345
+ exports.foldLayers = foldLayers;
2308
2346
  exports.inferApiMode = inferApiMode;
2309
2347
  exports.loadProjectEnv = loadProjectEnv;
2310
2348
  exports.migrateSqliteToLance = migrateSqliteToLance2;
@@ -2316,5 +2354,6 @@ exports.runGoalLoop = runGoalLoop;
2316
2354
  exports.scopedConversationId = scopedConversationId;
2317
2355
  exports.sessionScopePrefix = sessionScopePrefix;
2318
2356
  exports.toShareGptTrajectory = toShareGptTrajectory;
2357
+ exports.verifyLayerOrdering = verifyLayerOrdering;
2319
2358
  //# sourceMappingURL=index.cjs.map
2320
2359
  //# sourceMappingURL=index.cjs.map