@theokit/sdk 4.42.0 → 4.42.1

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 (35) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/{agent-HGDXQEQQ.cjs → agent-DRUORJTU.cjs} +5 -5
  3. package/dist/{agent-HGDXQEQQ.cjs.map → agent-DRUORJTU.cjs.map} +1 -1
  4. package/dist/{agent-WUVYXIFX.js → agent-MVYGMWPM.js} +4 -4
  5. package/dist/{agent-WUVYXIFX.js.map → agent-MVYGMWPM.js.map} +1 -1
  6. package/dist/{chunk-YHQ3DG24.cjs → chunk-4OQXDCMN.cjs} +10 -10
  7. package/dist/chunk-4OQXDCMN.cjs.map +1 -0
  8. package/dist/{chunk-22EMHGBO.cjs → chunk-GAXYZXYY.cjs} +8 -7
  9. package/dist/chunk-GAXYZXYY.cjs.map +1 -0
  10. package/dist/{chunk-EYEZDADP.cjs → chunk-HLGEXZZP.cjs} +5 -5
  11. package/dist/{chunk-EYEZDADP.cjs.map → chunk-HLGEXZZP.cjs.map} +1 -1
  12. package/dist/{chunk-MPD5EGJ6.js → chunk-O67XODD5.js} +3 -3
  13. package/dist/{chunk-MPD5EGJ6.js.map → chunk-O67XODD5.js.map} +1 -1
  14. package/dist/{chunk-KO5V6L3E.js → chunk-V5V5A6B7.js} +5 -5
  15. package/dist/chunk-V5V5A6B7.js.map +1 -0
  16. package/dist/{chunk-Q2PPSHBS.js → chunk-ZZAAQOAZ.js} +9 -9
  17. package/dist/chunk-ZZAAQOAZ.js.map +1 -0
  18. package/dist/context/index.cjs +5 -5
  19. package/dist/context/index.js +2 -2
  20. package/dist/cron.cjs +4 -4
  21. package/dist/cron.js +3 -3
  22. package/dist/eval.cjs +3 -3
  23. package/dist/eval.js +2 -2
  24. package/dist/index.cjs +19 -19
  25. package/dist/index.js +5 -5
  26. package/dist/internal/runtime/context/path-containment.d.ts +24 -0
  27. package/dist/server/auth/index.d.cts +207 -11
  28. package/dist/server/auth/index.d.ts +207 -11
  29. package/dist/server/errors-envelope.d.cts +12 -6
  30. package/dist/server/errors-envelope.d.ts +12 -6
  31. package/package.json +13 -12
  32. package/dist/chunk-22EMHGBO.cjs.map +0 -1
  33. package/dist/chunk-KO5V6L3E.js.map +0 -1
  34. package/dist/chunk-Q2PPSHBS.js.map +0 -1
  35. package/dist/chunk-YHQ3DG24.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.42.1
4
+
5
+ ### Patch Changes
6
+
7
+ - dc18357: **Security.** Fix a containment check that admitted a sibling directory and any symlink.
8
+
9
+ `.theokit/context/*.md` frontmatter carries a `path:`, so the value is repository-controlled —
10
+ untrusted whenever the repository came from somewhere else. `loadSources` guarded it with
11
+ `absolute.startsWith(resolvePath(cwd))`, which fails twice:
12
+
13
+ - **No separator boundary.** With `cwd = /home/user/proj`, the value `../proj-evil/secret.md`
14
+ resolves to `/home/user/proj-evil/secret.md`, which starts with `/home/user/proj`. A sibling
15
+ directory whose name merely extends the project's is admitted; no traversal past the parent is
16
+ needed.
17
+ - **Lexical, not real.** A symlink whose name sits inside the root and whose target does not passes
18
+ any comparison made before symlink resolution.
19
+
20
+ Measured against the pre-fix code: the file outside the root was READ and its content reached the
21
+ context snapshot. The obvious escapes (`../../etc/passwd`, an absolute path) were refused, and
22
+ refusing them is what made the check look correct in review.
23
+
24
+ The correct rule already existed in the package as a private function in the import resolver, written
25
+ for the 4.41.1 patch. It now lives in `path-containment.ts` and both readers of repository-supplied
26
+ paths share it — one rule, one representation, so the two cannot drift apart again.
27
+
28
+ **A second, independent defect fixed alongside it.** `refresh()` carried every legacy source into the
29
+ aggregator without filtering, and then stamped `"included"` on everything the budget kept — so the
30
+ containment verdict was computed and discarded three statements later, and `snapshot()` reported an
31
+ excluded source as included. Nothing leaked through that path (the content was empty), but a consumer
32
+ auditing "what is in my context" got the wrong answer.
33
+
3
34
  ## 4.42.0
4
35
 
5
36
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkYHQ3DG24_cjs = require('./chunk-YHQ3DG24.cjs');
3
+ var chunk4OQXDCMN_cjs = require('./chunk-4OQXDCMN.cjs');
4
4
  require('./chunk-FAUKVJCC.cjs');
5
5
  require('./chunk-BV2MWEMV.cjs');
6
6
  require('./chunk-KCQUYQ3V.cjs');
@@ -13,7 +13,7 @@ require('./chunk-FZ4YMZA3.cjs');
13
13
  require('./chunk-GH52NOCL.cjs');
14
14
  require('./chunk-HECR7KF5.cjs');
15
15
  require('./chunk-BBZYXVLZ.cjs');
16
- require('./chunk-22EMHGBO.cjs');
16
+ require('./chunk-GAXYZXYY.cjs');
17
17
  require('./chunk-6X2HUT4A.cjs');
18
18
  require('./chunk-7PESI6YD.cjs');
19
19
  require('./chunk-S4Q5OMIK.cjs');
@@ -50,7 +50,7 @@ require('./chunk-ZHPET3LZ.cjs');
50
50
 
51
51
  Object.defineProperty(exports, "Agent", {
52
52
  enumerable: true,
53
- get: function () { return chunkYHQ3DG24_cjs.Agent; }
53
+ get: function () { return chunk4OQXDCMN_cjs.Agent; }
54
54
  });
55
- //# sourceMappingURL=agent-HGDXQEQQ.cjs.map
56
- //# sourceMappingURL=agent-HGDXQEQQ.cjs.map
55
+ //# sourceMappingURL=agent-DRUORJTU.cjs.map
56
+ //# sourceMappingURL=agent-DRUORJTU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-HGDXQEQQ.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-DRUORJTU.cjs"}
@@ -1,4 +1,4 @@
1
- export { Agent } from './chunk-KO5V6L3E.js';
1
+ export { Agent } from './chunk-V5V5A6B7.js';
2
2
  import './chunk-UJ7HK7BX.js';
3
3
  import './chunk-2SFBB54R.js';
4
4
  import './chunk-GNMPCZNN.js';
@@ -11,7 +11,7 @@ import './chunk-ZTEAJAE6.js';
11
11
  import './chunk-RJBHWM6D.js';
12
12
  import './chunk-J5RW43IR.js';
13
13
  import './chunk-AM2CNBKE.js';
14
- import './chunk-Q2PPSHBS.js';
14
+ import './chunk-ZZAAQOAZ.js';
15
15
  import './chunk-ZS6SLELQ.js';
16
16
  import './chunk-LLE7HPRI.js';
17
17
  import './chunk-SNKY3C2L.js';
@@ -43,5 +43,5 @@ import './chunk-6FSQ3CHQ.js';
43
43
  import './chunk-OLLOUAUJ.js';
44
44
  import './chunk-MRKSSN36.js';
45
45
  import './chunk-PBML2FHN.js';
46
- //# sourceMappingURL=agent-WUVYXIFX.js.map
47
- //# sourceMappingURL=agent-WUVYXIFX.js.map
46
+ //# sourceMappingURL=agent-MVYGMWPM.js.map
47
+ //# sourceMappingURL=agent-MVYGMWPM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-WUVYXIFX.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-MVYGMWPM.js"}
@@ -8,7 +8,7 @@ var chunkQFFNMJAS_cjs = require('./chunk-QFFNMJAS.cjs');
8
8
  var chunkGH52NOCL_cjs = require('./chunk-GH52NOCL.cjs');
9
9
  var chunkHECR7KF5_cjs = require('./chunk-HECR7KF5.cjs');
10
10
  var chunkBBZYXVLZ_cjs = require('./chunk-BBZYXVLZ.cjs');
11
- var chunk22EMHGBO_cjs = require('./chunk-22EMHGBO.cjs');
11
+ var chunkGAXYZXYY_cjs = require('./chunk-GAXYZXYY.cjs');
12
12
  var chunk6X2HUT4A_cjs = require('./chunk-6X2HUT4A.cjs');
13
13
  var chunk7PESI6YD_cjs = require('./chunk-7PESI6YD.cjs');
14
14
  var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
@@ -3345,7 +3345,7 @@ var HISTOGRAM_NAMES = {
3345
3345
  };
3346
3346
  function safeRequire(moduleName) {
3347
3347
  try {
3348
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-YHQ3DG24.cjs', document.baseURI).href)));
3348
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4OQXDCMN.cjs', document.baseURI).href)));
3349
3349
  return r(moduleName);
3350
3350
  } catch {
3351
3351
  return void 0;
@@ -3570,7 +3570,7 @@ var cachedOtel;
3570
3570
  function loadOtel() {
3571
3571
  if (cachedOtel === void 0) {
3572
3572
  try {
3573
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-YHQ3DG24.cjs', document.baseURI).href)));
3573
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-4OQXDCMN.cjs', document.baseURI).href)));
3574
3574
  const mod = r("@opentelemetry/api");
3575
3575
  cachedOtel = mod;
3576
3576
  } catch {
@@ -3890,7 +3890,7 @@ function applyAggregateCap(sources, maxTotal) {
3890
3890
  }
3891
3891
  const remaining = maxTotal - totalBytes;
3892
3892
  if (remaining > 0) {
3893
- const { finalContent } = chunk22EMHGBO_cjs.truncateWithMarker(s.content, remaining);
3893
+ const { finalContent } = chunkGAXYZXYY_cjs.truncateWithMarker(s.content, remaining);
3894
3894
  kept.push({ ...s, content: finalContent, truncated: true });
3895
3895
  totalBytes = maxTotal;
3896
3896
  } else {
@@ -3964,15 +3964,15 @@ var FileContextManager = class {
3964
3964
  this.lastScope = [...touchedFiles];
3965
3965
  const config = await loadContextConfig(this.cwd);
3966
3966
  const legacy = await loadSources(config, this.cwd);
3967
- const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunk22EMHGBO_cjs.DEFAULT_MAX_BYTES_PER_FILE;
3967
+ const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkGAXYZXYY_cjs.DEFAULT_MAX_BYTES_PER_FILE;
3968
3968
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
3969
- const discovered = await chunk22EMHGBO_cjs.runDiscovery({
3969
+ const discovered = await chunkGAXYZXYY_cjs.runDiscovery({
3970
3970
  cwd: this.cwd,
3971
3971
  maxBytesPerFile,
3972
3972
  skipLegacyTheokitContext: true,
3973
3973
  touchedFiles
3974
3974
  });
3975
- const legacyAsAggregator = legacy.map((src) => ({
3975
+ const legacyAsAggregator = legacy.filter((src) => src.status !== "excluded").map((src) => ({
3976
3976
  id: src.name,
3977
3977
  source: src.path,
3978
3978
  content: src.tokens.join(""),
@@ -4106,7 +4106,7 @@ async function loadSources(config, cwd) {
4106
4106
  continue;
4107
4107
  }
4108
4108
  const absolute = path.resolve(cwd, source.path);
4109
- if (!absolute.startsWith(path.resolve(cwd))) {
4109
+ if (!chunkGAXYZXYY_cjs.insideRoot(absolute, cwd)) {
4110
4110
  results.push({ ...source, status: "excluded", tokens: [] });
4111
4111
  continue;
4112
4112
  }
@@ -10333,5 +10333,5 @@ exports.generateCronId = generateCronId;
10333
10333
  exports.getPricingEntry = getPricingEntry;
10334
10334
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
10335
10335
  exports.resolveApiKey = resolveApiKey;
10336
- //# sourceMappingURL=chunk-YHQ3DG24.cjs.map
10337
- //# sourceMappingURL=chunk-YHQ3DG24.cjs.map
10336
+ //# sourceMappingURL=chunk-4OQXDCMN.cjs.map
10337
+ //# sourceMappingURL=chunk-4OQXDCMN.cjs.map