@theokit/sdk 4.42.1 → 4.43.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 +53 -0
- package/dist/{agent-MVYGMWPM.js → agent-GKX5FE5K.js} +5 -5
- package/dist/{agent-MVYGMWPM.js.map → agent-GKX5FE5K.js.map} +1 -1
- package/dist/{agent-DRUORJTU.cjs → agent-JA4ILE5O.cjs} +6 -6
- package/dist/{agent-DRUORJTU.cjs.map → agent-JA4ILE5O.cjs.map} +1 -1
- package/dist/{chunk-ZZAAQOAZ.js → chunk-3NLOQEJR.js} +3 -3
- package/dist/{chunk-ZZAAQOAZ.js.map → chunk-3NLOQEJR.js.map} +1 -1
- package/dist/{chunk-UJ7IQJAG.js → chunk-4NAKHID5.js} +8 -21
- package/dist/chunk-4NAKHID5.js.map +1 -0
- package/dist/{chunk-HLGEXZZP.cjs → chunk-74VVGK7P.cjs} +5 -5
- package/dist/{chunk-HLGEXZZP.cjs.map → chunk-74VVGK7P.cjs.map} +1 -1
- package/dist/{chunk-YPEPCZHF.cjs → chunk-L5YO6PWL.cjs} +7 -20
- package/dist/chunk-L5YO6PWL.cjs.map +1 -0
- package/dist/{chunk-O67XODD5.js → chunk-MZQHVN7C.js} +3 -3
- package/dist/{chunk-O67XODD5.js.map → chunk-MZQHVN7C.js.map} +1 -1
- package/dist/{chunk-4OQXDCMN.cjs → chunk-TSK4VVBW.cjs} +9 -9
- package/dist/{chunk-4OQXDCMN.cjs.map → chunk-TSK4VVBW.cjs.map} +1 -1
- package/dist/{chunk-GAXYZXYY.cjs → chunk-UU7MAO2D.cjs} +8 -8
- package/dist/{chunk-GAXYZXYY.cjs.map → chunk-UU7MAO2D.cjs.map} +1 -1
- package/dist/{chunk-V5V5A6B7.js → chunk-XARLSCKA.js} +3 -3
- package/dist/{chunk-V5V5A6B7.js.map → chunk-XARLSCKA.js.map} +1 -1
- package/dist/context/index.cjs +7 -7
- package/dist/context/index.js +3 -3
- package/dist/cron.cjs +5 -5
- package/dist/cron.js +4 -4
- package/dist/eval.cjs +4 -4
- package/dist/eval.js +3 -3
- package/dist/index.cjs +20 -20
- package/dist/index.js +6 -6
- package/dist/project.cjs +3 -3
- package/dist/project.js +1 -1
- package/package.json +12 -13
- package/dist/chunk-UJ7IQJAG.js.map +0 -1
- package/dist/chunk-YPEPCZHF.cjs.map +0 -1
package/dist/context/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUU7MAO2D_cjs = require('../chunk-UU7MAO2D.cjs');
|
|
4
|
+
var chunkL5YO6PWL_cjs = require('../chunk-L5YO6PWL.cjs');
|
|
5
5
|
|
|
6
6
|
// src/context/index.ts
|
|
7
7
|
function resolveContextImports(content, basePath, options) {
|
|
@@ -11,24 +11,24 @@ function resolveContextImports(content, basePath, options) {
|
|
|
11
11
|
maxBytesPerFile: options.maxBytesPerFile,
|
|
12
12
|
projectRoot: options.projectRoot
|
|
13
13
|
};
|
|
14
|
-
return
|
|
14
|
+
return chunkUU7MAO2D_cjs.resolveImports(content, basePath, internalOptions);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
Object.defineProperty(exports, "parseRules", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkUU7MAO2D_cjs.parseRules; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "runDiscovery", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkUU7MAO2D_cjs.runDiscovery; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "shouldActivateRule", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkUU7MAO2D_cjs.shouldActivateRule; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "DEFAULT_DISCOVERY_SPECS", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkL5YO6PWL_cjs.DEFAULT_DISCOVERY_SPECS; }
|
|
32
32
|
});
|
|
33
33
|
exports.resolveContextImports = resolveContextImports;
|
|
34
34
|
//# sourceMappingURL=index.cjs.map
|
package/dist/context/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveImports } from '../chunk-
|
|
2
|
-
export { parseRules, runDiscovery, shouldActivateRule } from '../chunk-
|
|
3
|
-
export { DEFAULT_DISCOVERY_SPECS } from '../chunk-
|
|
1
|
+
import { resolveImports } from '../chunk-3NLOQEJR.js';
|
|
2
|
+
export { parseRules, runDiscovery, shouldActivateRule } from '../chunk-3NLOQEJR.js';
|
|
3
|
+
export { DEFAULT_DISCOVERY_SPECS } from '../chunk-4NAKHID5.js';
|
|
4
4
|
|
|
5
5
|
// src/context/index.ts
|
|
6
6
|
function resolveContextImports(content, basePath, options) {
|
package/dist/cron.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk74VVGK7P_cjs = require('./chunk-74VVGK7P.cjs');
|
|
4
|
+
require('./chunk-TSK4VVBW.cjs');
|
|
5
5
|
require('./chunk-FAUKVJCC.cjs');
|
|
6
6
|
require('./chunk-BV2MWEMV.cjs');
|
|
7
7
|
require('./chunk-KCQUYQ3V.cjs');
|
|
@@ -14,7 +14,7 @@ require('./chunk-FZ4YMZA3.cjs');
|
|
|
14
14
|
require('./chunk-GH52NOCL.cjs');
|
|
15
15
|
require('./chunk-HECR7KF5.cjs');
|
|
16
16
|
require('./chunk-BBZYXVLZ.cjs');
|
|
17
|
-
require('./chunk-
|
|
17
|
+
require('./chunk-UU7MAO2D.cjs');
|
|
18
18
|
require('./chunk-6X2HUT4A.cjs');
|
|
19
19
|
require('./chunk-7PESI6YD.cjs');
|
|
20
20
|
require('./chunk-S4Q5OMIK.cjs');
|
|
@@ -23,7 +23,7 @@ require('./chunk-MUUQ2WFJ.cjs');
|
|
|
23
23
|
require('./chunk-6JSIEDKL.cjs');
|
|
24
24
|
require('./chunk-B4YA6BRS.cjs');
|
|
25
25
|
require('./chunk-NINIJCHU.cjs');
|
|
26
|
-
require('./chunk-
|
|
26
|
+
require('./chunk-L5YO6PWL.cjs');
|
|
27
27
|
require('./chunk-VJ26EKGJ.cjs');
|
|
28
28
|
require('./chunk-OEFFPR2S.cjs');
|
|
29
29
|
require('./chunk-27DYRARU.cjs');
|
|
@@ -51,7 +51,7 @@ require('./chunk-ZHPET3LZ.cjs');
|
|
|
51
51
|
|
|
52
52
|
Object.defineProperty(exports, "Cron", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunk74VVGK7P_cjs.Cron; }
|
|
55
55
|
});
|
|
56
56
|
//# sourceMappingURL=cron.cjs.map
|
|
57
57
|
//# sourceMappingURL=cron.cjs.map
|
package/dist/cron.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Cron } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { Cron } from './chunk-MZQHVN7C.js';
|
|
2
|
+
import './chunk-XARLSCKA.js';
|
|
3
3
|
import './chunk-UJ7HK7BX.js';
|
|
4
4
|
import './chunk-2SFBB54R.js';
|
|
5
5
|
import './chunk-GNMPCZNN.js';
|
|
@@ -12,7 +12,7 @@ import './chunk-ZTEAJAE6.js';
|
|
|
12
12
|
import './chunk-RJBHWM6D.js';
|
|
13
13
|
import './chunk-J5RW43IR.js';
|
|
14
14
|
import './chunk-AM2CNBKE.js';
|
|
15
|
-
import './chunk-
|
|
15
|
+
import './chunk-3NLOQEJR.js';
|
|
16
16
|
import './chunk-ZS6SLELQ.js';
|
|
17
17
|
import './chunk-LLE7HPRI.js';
|
|
18
18
|
import './chunk-SNKY3C2L.js';
|
|
@@ -21,7 +21,7 @@ import './chunk-FD2UT76F.js';
|
|
|
21
21
|
import './chunk-U54XCYG3.js';
|
|
22
22
|
import './chunk-RP5HQVLD.js';
|
|
23
23
|
import './chunk-6X6ID4MO.js';
|
|
24
|
-
import './chunk-
|
|
24
|
+
import './chunk-4NAKHID5.js';
|
|
25
25
|
import './chunk-7AD3ZTZL.js';
|
|
26
26
|
import './chunk-AZ6FKDQR.js';
|
|
27
27
|
import './chunk-Q4DTGCSD.js';
|
package/dist/eval.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkR3CKCRK3_cjs = require('./chunk-R3CKCRK3.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkTSK4VVBW_cjs = require('./chunk-TSK4VVBW.cjs');
|
|
5
5
|
require('./chunk-FAUKVJCC.cjs');
|
|
6
6
|
require('./chunk-BV2MWEMV.cjs');
|
|
7
7
|
require('./chunk-KCQUYQ3V.cjs');
|
|
@@ -14,7 +14,7 @@ require('./chunk-FZ4YMZA3.cjs');
|
|
|
14
14
|
require('./chunk-GH52NOCL.cjs');
|
|
15
15
|
require('./chunk-HECR7KF5.cjs');
|
|
16
16
|
require('./chunk-BBZYXVLZ.cjs');
|
|
17
|
-
require('./chunk-
|
|
17
|
+
require('./chunk-UU7MAO2D.cjs');
|
|
18
18
|
require('./chunk-6X2HUT4A.cjs');
|
|
19
19
|
require('./chunk-7PESI6YD.cjs');
|
|
20
20
|
require('./chunk-S4Q5OMIK.cjs');
|
|
@@ -23,7 +23,7 @@ require('./chunk-MUUQ2WFJ.cjs');
|
|
|
23
23
|
require('./chunk-6JSIEDKL.cjs');
|
|
24
24
|
require('./chunk-B4YA6BRS.cjs');
|
|
25
25
|
var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
|
|
26
|
-
require('./chunk-
|
|
26
|
+
require('./chunk-L5YO6PWL.cjs');
|
|
27
27
|
require('./chunk-VJ26EKGJ.cjs');
|
|
28
28
|
require('./chunk-OEFFPR2S.cjs');
|
|
29
29
|
require('./chunk-27DYRARU.cjs');
|
|
@@ -774,7 +774,7 @@ function makeDefaultEmbedder(opts) {
|
|
|
774
774
|
let runtime;
|
|
775
775
|
return (texts) => {
|
|
776
776
|
if (runtime === void 0) {
|
|
777
|
-
runtime =
|
|
777
|
+
runtime = chunkTSK4VVBW_cjs.openRouterMemoryEmbeddingProviderAdapter.create(embedderCreateOptions(opts));
|
|
778
778
|
}
|
|
779
779
|
return runtime.then((rt) => rt.embed(texts));
|
|
780
780
|
};
|
package/dist/eval.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shellEscapePosix, LocalSandbox } from './chunk-DEZ75ET5.js';
|
|
2
|
-
import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-
|
|
2
|
+
import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-XARLSCKA.js';
|
|
3
3
|
import './chunk-UJ7HK7BX.js';
|
|
4
4
|
import './chunk-2SFBB54R.js';
|
|
5
5
|
import './chunk-GNMPCZNN.js';
|
|
@@ -12,7 +12,7 @@ import './chunk-ZTEAJAE6.js';
|
|
|
12
12
|
import './chunk-RJBHWM6D.js';
|
|
13
13
|
import './chunk-J5RW43IR.js';
|
|
14
14
|
import './chunk-AM2CNBKE.js';
|
|
15
|
-
import './chunk-
|
|
15
|
+
import './chunk-3NLOQEJR.js';
|
|
16
16
|
import './chunk-ZS6SLELQ.js';
|
|
17
17
|
import './chunk-LLE7HPRI.js';
|
|
18
18
|
import './chunk-SNKY3C2L.js';
|
|
@@ -21,7 +21,7 @@ import './chunk-FD2UT76F.js';
|
|
|
21
21
|
import './chunk-U54XCYG3.js';
|
|
22
22
|
import './chunk-RP5HQVLD.js';
|
|
23
23
|
import { getAgentFacade } from './chunk-6X6ID4MO.js';
|
|
24
|
-
import './chunk-
|
|
24
|
+
import './chunk-4NAKHID5.js';
|
|
25
25
|
import './chunk-7AD3ZTZL.js';
|
|
26
26
|
import './chunk-AZ6FKDQR.js';
|
|
27
27
|
import './chunk-Q4DTGCSD.js';
|
package/dist/index.cjs
CHANGED
|
@@ -8,8 +8,8 @@ require('./chunk-WIGJGFH4.cjs');
|
|
|
8
8
|
var chunkJO76RWCA_cjs = require('./chunk-JO76RWCA.cjs');
|
|
9
9
|
require('./chunk-RBQYHEZD.cjs');
|
|
10
10
|
require('./chunk-PNVDQL5Y.cjs');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var chunk74VVGK7P_cjs = require('./chunk-74VVGK7P.cjs');
|
|
12
|
+
var chunkTSK4VVBW_cjs = require('./chunk-TSK4VVBW.cjs');
|
|
13
13
|
require('./chunk-FAUKVJCC.cjs');
|
|
14
14
|
require('./chunk-BV2MWEMV.cjs');
|
|
15
15
|
var chunkKCQUYQ3V_cjs = require('./chunk-KCQUYQ3V.cjs');
|
|
@@ -22,7 +22,7 @@ require('./chunk-FZ4YMZA3.cjs');
|
|
|
22
22
|
var chunkGH52NOCL_cjs = require('./chunk-GH52NOCL.cjs');
|
|
23
23
|
require('./chunk-HECR7KF5.cjs');
|
|
24
24
|
require('./chunk-BBZYXVLZ.cjs');
|
|
25
|
-
require('./chunk-
|
|
25
|
+
require('./chunk-UU7MAO2D.cjs');
|
|
26
26
|
require('./chunk-6X2HUT4A.cjs');
|
|
27
27
|
require('./chunk-7PESI6YD.cjs');
|
|
28
28
|
require('./chunk-S4Q5OMIK.cjs');
|
|
@@ -31,7 +31,7 @@ require('./chunk-MUUQ2WFJ.cjs');
|
|
|
31
31
|
require('./chunk-6JSIEDKL.cjs');
|
|
32
32
|
require('./chunk-B4YA6BRS.cjs');
|
|
33
33
|
require('./chunk-NINIJCHU.cjs');
|
|
34
|
-
require('./chunk-
|
|
34
|
+
require('./chunk-L5YO6PWL.cjs');
|
|
35
35
|
require('./chunk-VJ26EKGJ.cjs');
|
|
36
36
|
require('./chunk-OEFFPR2S.cjs');
|
|
37
37
|
require('./chunk-27DYRARU.cjs');
|
|
@@ -63,8 +63,8 @@ var fs = require('fs');
|
|
|
63
63
|
// src/agent-factory.ts
|
|
64
64
|
function createAgentFactory(common) {
|
|
65
65
|
return {
|
|
66
|
-
forSession: (agentId, overrides) =>
|
|
67
|
-
getOrCreate: (agentId, overrides) =>
|
|
66
|
+
forSession: (agentId, overrides) => chunkTSK4VVBW_cjs.Agent.create(mergeAgentOptions(common, overrides, agentId)),
|
|
67
|
+
getOrCreate: (agentId, overrides) => chunkTSK4VVBW_cjs.Agent.getOrCreate(agentId, mergeAgentOptions(common, overrides, agentId))
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
function mergeAgentOptions(common, overrides, agentId) {
|
|
@@ -1168,7 +1168,7 @@ var Memory = {
|
|
|
1168
1168
|
return await peer.IndexManager.open(openArgs);
|
|
1169
1169
|
}
|
|
1170
1170
|
const { IndexManager } = await import('./index-manager-YFFEPISE.cjs');
|
|
1171
|
-
openArgs.embedding = await resolveEmbedding(opts.embedding,
|
|
1171
|
+
openArgs.embedding = await resolveEmbedding(opts.embedding, chunkTSK4VVBW_cjs.MEMORY_EMBEDDING_ADAPTERS);
|
|
1172
1172
|
return await IndexManager.open(openArgs);
|
|
1173
1173
|
},
|
|
1174
1174
|
/**
|
|
@@ -1179,7 +1179,7 @@ var Memory = {
|
|
|
1179
1179
|
*/
|
|
1180
1180
|
async runDreamingSweep(opts) {
|
|
1181
1181
|
const peer = await tryLoadSdkMemoryPeer();
|
|
1182
|
-
const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS :
|
|
1182
|
+
const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS : chunkTSK4VVBW_cjs.MEMORY_EMBEDDING_ADAPTERS;
|
|
1183
1183
|
const sweepArgs = await buildDreamingSweepArgs(opts, catalog);
|
|
1184
1184
|
const result = peer !== null ? (
|
|
1185
1185
|
// biome-ignore lint/suspicious/noExplicitAny: peer is dynamically loaded — structural compat ensured by sdk-memory
|
|
@@ -1601,7 +1601,7 @@ function isBuiltAgent(m) {
|
|
|
1601
1601
|
return typeof m.send === "function";
|
|
1602
1602
|
}
|
|
1603
1603
|
async function materialize(def, index) {
|
|
1604
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1604
|
+
const { Agent: Agent2 } = await import('./agent-JA4ILE5O.cjs');
|
|
1605
1605
|
return Agent2.create({
|
|
1606
1606
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
1607
1607
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -1743,7 +1743,7 @@ var FIXTURE_USER = {
|
|
|
1743
1743
|
};
|
|
1744
1744
|
var FIXTURE_MODELS = [
|
|
1745
1745
|
{
|
|
1746
|
-
id:
|
|
1746
|
+
id: chunkTSK4VVBW_cjs.DEFAULT_AGENTIC_MODEL_ID,
|
|
1747
1747
|
name: "Gemini 2.0 Flash",
|
|
1748
1748
|
displayName: "Gemini 2.0 Flash",
|
|
1749
1749
|
parameters: [
|
|
@@ -1946,7 +1946,7 @@ var Theokit = class {
|
|
|
1946
1946
|
envVars: p.envVars
|
|
1947
1947
|
}));
|
|
1948
1948
|
},
|
|
1949
|
-
embeddingAdapters: () => Object.entries(
|
|
1949
|
+
embeddingAdapters: () => Object.entries(chunkTSK4VVBW_cjs.MEMORY_EMBEDDING_ADAPTERS).map(([id, adapter]) => ({
|
|
1950
1950
|
id,
|
|
1951
1951
|
transport: adapter.transport,
|
|
1952
1952
|
defaultModel: adapter.defaultModel
|
|
@@ -1978,7 +1978,7 @@ function resolveLocalProviderBaseUrl(providerName, fallback) {
|
|
|
1978
1978
|
return fallback;
|
|
1979
1979
|
}
|
|
1980
1980
|
async function executeCatalogRequest(request) {
|
|
1981
|
-
const apiKey =
|
|
1981
|
+
const apiKey = chunkTSK4VVBW_cjs.resolveApiKey(request.apiKey);
|
|
1982
1982
|
if (apiKey === void 0) {
|
|
1983
1983
|
throw new chunkYULF6FPB_cjs.AuthenticationError("Missing API key", { code: "missing_api_key" });
|
|
1984
1984
|
}
|
|
@@ -2104,35 +2104,35 @@ Object.defineProperty(exports, "GenerateObjectError", {
|
|
|
2104
2104
|
});
|
|
2105
2105
|
Object.defineProperty(exports, "Cron", {
|
|
2106
2106
|
enumerable: true,
|
|
2107
|
-
get: function () { return
|
|
2107
|
+
get: function () { return chunk74VVGK7P_cjs.Cron; }
|
|
2108
2108
|
});
|
|
2109
2109
|
Object.defineProperty(exports, "Agent", {
|
|
2110
2110
|
enumerable: true,
|
|
2111
|
-
get: function () { return
|
|
2111
|
+
get: function () { return chunkTSK4VVBW_cjs.Agent; }
|
|
2112
2112
|
});
|
|
2113
2113
|
Object.defineProperty(exports, "AgentBuilder", {
|
|
2114
2114
|
enumerable: true,
|
|
2115
|
-
get: function () { return
|
|
2115
|
+
get: function () { return chunkTSK4VVBW_cjs.AgentBuilder; }
|
|
2116
2116
|
});
|
|
2117
2117
|
Object.defineProperty(exports, "Tool", {
|
|
2118
2118
|
enumerable: true,
|
|
2119
|
-
get: function () { return
|
|
2119
|
+
get: function () { return chunkTSK4VVBW_cjs.Tool; }
|
|
2120
2120
|
});
|
|
2121
2121
|
Object.defineProperty(exports, "ToolError", {
|
|
2122
2122
|
enumerable: true,
|
|
2123
|
-
get: function () { return
|
|
2123
|
+
get: function () { return chunkTSK4VVBW_cjs.ToolError; }
|
|
2124
2124
|
});
|
|
2125
2125
|
Object.defineProperty(exports, "UsageAccumulator", {
|
|
2126
2126
|
enumerable: true,
|
|
2127
|
-
get: function () { return
|
|
2127
|
+
get: function () { return chunkTSK4VVBW_cjs.UsageAccumulator; }
|
|
2128
2128
|
});
|
|
2129
2129
|
Object.defineProperty(exports, "computeCost", {
|
|
2130
2130
|
enumerable: true,
|
|
2131
|
-
get: function () { return
|
|
2131
|
+
get: function () { return chunkTSK4VVBW_cjs.computeCost; }
|
|
2132
2132
|
});
|
|
2133
2133
|
Object.defineProperty(exports, "getPricingEntry", {
|
|
2134
2134
|
enumerable: true,
|
|
2135
|
-
get: function () { return
|
|
2135
|
+
get: function () { return chunkTSK4VVBW_cjs.getPricingEntry; }
|
|
2136
2136
|
});
|
|
2137
2137
|
Object.defineProperty(exports, "emitRunEvent", {
|
|
2138
2138
|
enumerable: true,
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import './chunk-O3IZ7JEL.js';
|
|
|
6
6
|
import { Workflow, agentStep } from './chunk-EON4YTR6.js';
|
|
7
7
|
import './chunk-HK4HRLWE.js';
|
|
8
8
|
import './chunk-CAH3G4IS.js';
|
|
9
|
-
export { Cron } from './chunk-
|
|
10
|
-
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-
|
|
11
|
-
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-
|
|
9
|
+
export { Cron } from './chunk-MZQHVN7C.js';
|
|
10
|
+
import { MEMORY_EMBEDDING_ADAPTERS, resolveApiKey, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-XARLSCKA.js';
|
|
11
|
+
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-XARLSCKA.js';
|
|
12
12
|
import './chunk-UJ7HK7BX.js';
|
|
13
13
|
import './chunk-2SFBB54R.js';
|
|
14
14
|
import { configure, submit, list, get, cancel, subscribe } from './chunk-GNMPCZNN.js';
|
|
@@ -22,7 +22,7 @@ import './chunk-ZTEAJAE6.js';
|
|
|
22
22
|
import { lanceStoragePath, LanceIndex, readFactsFromMarkdown, defaultIndexPath, openMemoryDb, memoryDir } from './chunk-RJBHWM6D.js';
|
|
23
23
|
import './chunk-J5RW43IR.js';
|
|
24
24
|
import './chunk-AM2CNBKE.js';
|
|
25
|
-
import './chunk-
|
|
25
|
+
import './chunk-3NLOQEJR.js';
|
|
26
26
|
import './chunk-ZS6SLELQ.js';
|
|
27
27
|
import './chunk-LLE7HPRI.js';
|
|
28
28
|
import './chunk-SNKY3C2L.js';
|
|
@@ -31,7 +31,7 @@ import './chunk-FD2UT76F.js';
|
|
|
31
31
|
import './chunk-U54XCYG3.js';
|
|
32
32
|
import './chunk-RP5HQVLD.js';
|
|
33
33
|
import './chunk-6X6ID4MO.js';
|
|
34
|
-
import './chunk-
|
|
34
|
+
import './chunk-4NAKHID5.js';
|
|
35
35
|
import './chunk-7AD3ZTZL.js';
|
|
36
36
|
import './chunk-AZ6FKDQR.js';
|
|
37
37
|
import './chunk-Q4DTGCSD.js';
|
|
@@ -1604,7 +1604,7 @@ function isBuiltAgent(m) {
|
|
|
1604
1604
|
return typeof m.send === "function";
|
|
1605
1605
|
}
|
|
1606
1606
|
async function materialize(def, index) {
|
|
1607
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
1607
|
+
const { Agent: Agent2 } = await import('./agent-GKX5FE5K.js');
|
|
1608
1608
|
return Agent2.create({
|
|
1609
1609
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
1610
1610
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
package/dist/project.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkL5YO6PWL_cjs = require('./chunk-L5YO6PWL.cjs');
|
|
4
4
|
var chunkNETYW4V3_cjs = require('./chunk-NETYW4V3.cjs');
|
|
5
5
|
var chunkYULF6FPB_cjs = require('./chunk-YULF6FPB.cjs');
|
|
6
6
|
require('./chunk-ZHPET3LZ.cjs');
|
|
@@ -11,7 +11,7 @@ var DEFAULT_FILENAME = "THEO.md";
|
|
|
11
11
|
async function readProjectInstructions(cwd, options) {
|
|
12
12
|
const filename = options?.filename ?? DEFAULT_FILENAME;
|
|
13
13
|
const scope = options?.scope ?? "nearest";
|
|
14
|
-
const paths =
|
|
14
|
+
const paths = chunkL5YO6PWL_cjs.walkUpForFile(cwd, filename, options?.stopDir);
|
|
15
15
|
const files = [];
|
|
16
16
|
for (const path of paths) {
|
|
17
17
|
try {
|
|
@@ -30,7 +30,7 @@ function reduceContent(files, scope) {
|
|
|
30
30
|
}
|
|
31
31
|
async function writeProjectInstructions(cwd, content, options) {
|
|
32
32
|
const filename = options?.filename ?? DEFAULT_FILENAME;
|
|
33
|
-
if (!
|
|
33
|
+
if (!chunkL5YO6PWL_cjs.isSafePattern(filename)) {
|
|
34
34
|
throw new chunkYULF6FPB_cjs.ConfigurationError(
|
|
35
35
|
`writeProjectInstructions: unsafe filename ${JSON.stringify(filename)} (no path traversal, separators, or absolute paths)`,
|
|
36
36
|
{ code: "unsafe_filename" }
|
package/dist/project.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { walkUpForFile, isSafePattern } from './chunk-
|
|
1
|
+
import { walkUpForFile, isSafePattern } from './chunk-4NAKHID5.js';
|
|
2
2
|
import { replaceFileAtomic } from './chunk-VQFSEKU5.js';
|
|
3
3
|
import { ConfigurationError } from './chunk-MRKSSN36.js';
|
|
4
4
|
import './chunk-PBML2FHN.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.43.0",
|
|
4
4
|
"description": "TypeScript SDK for the Theo agent harness — same surface, local or cloud.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/usetheodev/theokit-sdk#readme",
|
|
@@ -349,17 +349,6 @@
|
|
|
349
349
|
"**/agent.js",
|
|
350
350
|
"**/agent.cjs"
|
|
351
351
|
],
|
|
352
|
-
"scripts": {
|
|
353
|
-
"build": "tsup && cp src/internal/providers/provider-catalog.json dist/provider-catalog.json && node scripts/copy-docs.mjs",
|
|
354
|
-
"test": "vitest run --no-file-parallelism",
|
|
355
|
-
"test:watch": "vitest",
|
|
356
|
-
"eval": "vitest run --no-file-parallelism tests/eval/suites",
|
|
357
|
-
"test:contract": "vitest run --no-file-parallelism tests/theokit-consumer-contract.test.ts",
|
|
358
|
-
"prepublishOnly": "pnpm build && pnpm test:contract && node ../../scripts/check-publish-no-workspace.mjs .",
|
|
359
|
-
"typecheck": "tsc --noEmit",
|
|
360
|
-
"clean": "rm -rf dist",
|
|
361
|
-
"docs:json": "typedoc --options typedoc.json"
|
|
362
|
-
},
|
|
363
352
|
"peerDependencies": {
|
|
364
353
|
"@lancedb/lancedb": "^0.30.0",
|
|
365
354
|
"@types/ws": ">=8.0.0",
|
|
@@ -427,5 +416,15 @@
|
|
|
427
416
|
"typedoc": "^0.28.19",
|
|
428
417
|
"ws": "^8.18.0",
|
|
429
418
|
"zod": "^4.0.0"
|
|
419
|
+
},
|
|
420
|
+
"scripts": {
|
|
421
|
+
"build": "tsup && cp src/internal/providers/provider-catalog.json dist/provider-catalog.json && node scripts/copy-docs.mjs",
|
|
422
|
+
"test": "vitest run --no-file-parallelism",
|
|
423
|
+
"test:watch": "vitest",
|
|
424
|
+
"eval": "vitest run --no-file-parallelism tests/eval/suites",
|
|
425
|
+
"test:contract": "vitest run --no-file-parallelism tests/theokit-consumer-contract.test.ts",
|
|
426
|
+
"typecheck": "tsc --noEmit",
|
|
427
|
+
"clean": "rm -rf dist",
|
|
428
|
+
"docs:json": "typedoc --options typedoc.json"
|
|
430
429
|
}
|
|
431
|
-
}
|
|
430
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/runtime/context/context-discovery.ts"],"names":[],"mappings":";;;;;AAsDO,IAAM,uBAAA,GAAwD;AAAA,EACnE;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,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,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,EAAK,OAAO,CAAA;AAC7B,EAAA,IAAI,CAAC,UAAA,CAAW,GAAG,CAAA,SAAU,EAAC;AAE9B,EAAA,MAAM,MAAA,GAAS,gBAAgB,QAAQ,CAAA;AACvC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,MAAM,QAAQ,GAAG,CAAA;AAAA,EAC7B,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACA,EAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,KAAM,OAAO,IAAA,CAAK,CAAC,CAAC,CAAA,CAAE,IAAA,EAAK;AAC3D,EAAA,OAAO,OAAA,CAAQ,IAAI,CAAC,CAAA,KAAM,QAAQ,IAAA,CAAK,GAAA,EAAK,CAAC,CAAC,CAAC,CAAA;AACjD;AAEA,SAAS,gBAAgB,QAAA,EAA0B;AACjD,EAAA,MAAM,OAAA,GAAU,SAAS,OAAA,CAAQ,mBAAA,EAAqB,MAAM,CAAA,CAAE,OAAA,CAAQ,OAAO,IAAI,CAAA;AACjF,EAAA,OAAO,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,OAAO,CAAA,CAAA,CAAG,CAAA;AAClC","file":"chunk-UJ7IQJAG.js","sourcesContent":["/**\n * Context file discovery (T1.1, ADRs D150 / D151).\n *\n * Discovers context files via three scopes:\n * - `cwd-only` — single dir, single path lookup\n * - `git-root-walk` — walk cwd → git-root, collect every directory's match\n * (nearest-first ordering)\n * - `globbed` — glob pattern relative to cwd (e.g. `.cursor/rules/*.mdc`)\n *\n * Pure `existsSync` checks — **no `.gitignore` parsing** (EC-A, KISS) and\n * **no invented `.theokitignore`** (EC-B). Paths normalized via\n * `realpath` to dedup symlink chains pointing to the same physical file\n * (EC-F). Git worktrees work transparently because `.git` exists as a\n * file in that case (EC-N).\n *\n * @internal\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\n/** Single filename (\"AGENTS.md\") or relative glob (\".cursor/rules/*.mdc\"). */\nexport type DiscoveryScope = \"cwd-only\" | \"git-root-walk\" | \"globbed\";\n\n/** Parser to apply once file is read. */\nexport type DiscoveryParser = \"plain-markdown\" | \"mdc\" | \"frontmatter-zod\" | \"rules-frontmatter\";\n\n/**\n * Specification for one discoverable context source. The default registry\n * `DEFAULT_DISCOVERY_SPECS` covers the 2026 industry-standard set.\n *\n * @internal\n */\nexport interface DiscoverySpec {\n /** Stable identifier — used as `<source name=\"\">` and telemetry key. */\n readonly id: string;\n /** Priority for merge (lower = earlier in prompt). */\n readonly priority: number;\n /** Filename (cwd-only/git-root-walk) or glob (globbed). */\n readonly pattern: string;\n readonly scope: DiscoveryScope;\n readonly parser: DiscoveryParser;\n /** Whether to follow `@path` import directives (CLAUDE.md / GEMINI.md). */\n readonly followImports: boolean;\n}\n\n/**\n * 2026 industry-standard context file registry. Sorted by priority\n * ascending — earlier in prompt = more general, last-writer-wins on\n * conflict (D152 concat-by-priority).\n *\n * @internal\n */\nexport const DEFAULT_DISCOVERY_SPECS: ReadonlyArray<DiscoverySpec> = [\n {\n id: \"AGENTS.md\",\n pattern: \"AGENTS.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 10,\n },\n {\n id: \"GEMINI.md\",\n pattern: \"GEMINI.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 20,\n },\n {\n id: \"CLAUDE.md\",\n pattern: \"CLAUDE.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 30,\n },\n {\n id: \"cursor-rules\",\n pattern: \".cursor/rules/*.mdc\",\n scope: \"globbed\",\n parser: \"mdc\",\n followImports: false,\n priority: 40,\n },\n {\n id: \"theokit-rules\",\n pattern: \".theokit/rules/*.md\",\n scope: \"globbed\",\n parser: \"rules-frontmatter\",\n followImports: false,\n priority: 45,\n },\n {\n id: \"theokit-context\",\n pattern: \".theokit/context/*.md\",\n scope: \"globbed\",\n parser: \"frontmatter-zod\",\n followImports: false,\n priority: 50,\n },\n {\n id: \"THEO.md\",\n pattern: \".theokit/THEO.md\",\n scope: \"cwd-only\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 60,\n },\n];\n\nconst SAFE_FILENAME = /^[a-zA-Z0-9_.\\-/*]+$/;\nconst TRAVERSAL_RE = /(^|\\/)\\.\\.(\\/|$)/;\n\n/**\n * Reject patterns that contain path traversal (`..`) or non-allowed\n * characters (D81 parity, EC-4).\n *\n * @internal\n */\nexport function isSafePattern(pattern: string): boolean {\n if (typeof pattern !== \"string\" || pattern.length === 0) return false;\n if (TRAVERSAL_RE.test(pattern)) return false;\n if (isAbsolute(pattern)) return false;\n return SAFE_FILENAME.test(pattern);\n}\n\n/**\n * Walk upward from `cwd` looking for the closest directory containing\n * a `.git` entry (file OR directory — worktrees use a `.git` FILE,\n * EC-N). Returns the absolute path of that directory, or `undefined`\n * when no git root exists at or above `cwd`.\n *\n * @internal\n */\nexport function findGitRoot(cwd: string): string | undefined {\n if (typeof cwd !== \"string\" || cwd.length === 0) return undefined;\n let current = resolve(cwd);\n // Guard against infinite loops on weird filesystems.\n for (let i = 0; i < 64; i += 1) {\n if (existsSync(join(current, \".git\"))) return current;\n const parent = dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n return undefined;\n}\n\n/**\n * Walk `cwd` upward to `stopDir` (inclusive) collecting every existing\n * occurrence of `filename`. Returns absolute, realpath-deduped paths in\n * nearest-first order (innermost dir first).\n *\n * No `.gitignore` parsing (EC-A). Realpath collapses symlink chains\n * pointing to the same physical file (EC-F). Filesystem races (file\n * deleted mid-walk) are skipped silently (EC-5).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: walk-up loop combines validation + realpath dedup + FS-race handling + stopDir guard in a single bounded loop; splitting fragments the dedup invariant.\nexport function walkUpForFile(\n cwd: string,\n filename: string,\n stopDir: string | undefined,\n): string[] {\n if (!isSafePattern(filename)) {\n return [];\n }\n const start = resolve(cwd);\n const stop = stopDir !== undefined ? resolve(stopDir) : undefined;\n const found: string[] = [];\n const seenReal = new Set<string>();\n let current = start;\n // 64-level depth cap.\n for (let i = 0; i < 64; i += 1) {\n const candidate = join(current, filename);\n if (existsSync(candidate)) {\n let real: string;\n try {\n real = realpathSync(candidate);\n } catch {\n // FS race (deleted mid-walk) — skip.\n real = candidate;\n }\n if (!seenReal.has(real)) {\n seenReal.add(real);\n found.push(real);\n }\n }\n if (stop !== undefined && current === stop) break;\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return found;\n}\n\n/**\n * Glob-style discovery scoped to a single directory under cwd (e.g.\n * `.cursor/rules/*.mdc`). Flat — does NOT recurse into subdirectories\n * (EC-R: nested directories deferred to v2). Returns absolute,\n * lex-sorted paths.\n *\n * @internal\n */\nexport async function walkUpForGlob(cwd: string, pattern: string): Promise<string[]> {\n if (!isSafePattern(pattern)) return [];\n const lastSlash = pattern.lastIndexOf(\"/\");\n if (lastSlash < 0) {\n // Single filename — treat as cwd-only single match.\n const candidate = join(cwd, pattern);\n return existsSync(candidate) ? [resolve(candidate)] : [];\n }\n const dirPart = pattern.slice(0, lastSlash);\n const filePart = pattern.slice(lastSlash + 1);\n const dir = join(cwd, dirPart);\n if (!existsSync(dir)) return [];\n // Build a regex from the file part — supports only `*` wildcard.\n const fileRe = filePartToRegex(filePart);\n let entries: string[];\n try {\n entries = await readdir(dir);\n } catch {\n return [];\n }\n const matched = entries.filter((e) => fileRe.test(e)).sort();\n return matched.map((e) => resolve(join(dir, e)));\n}\n\nfunction filePartToRegex(filePart: string): RegExp {\n const escaped = filePart.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\").replace(/\\*/g, \".*\");\n return new RegExp(`^${escaped}$`);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/runtime/context/context-discovery.ts"],"names":["isAbsolute","resolve","existsSync","join","dirname","realpathSync","readdir"],"mappings":";;;;;;;AAsDO,IAAM,uBAAA,GAAwD;AAAA,EACnE;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,IAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,IAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,cAAA;AAAA,IACJ,OAAA,EAAS,qBAAA;AAAA,IACT,KAAA,EAAO,SAAA;AAAA,IACP,MAAA,EAAQ,KAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,eAAA;AAAA,IACJ,OAAA,EAAS,qBAAA;AAAA,IACT,KAAA,EAAO,SAAA;AAAA,IACP,MAAA,EAAQ,mBAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,iBAAA;AAAA,IACJ,OAAA,EAAS,uBAAA;AAAA,IACT,KAAA,EAAO,SAAA;AAAA,IACP,MAAA,EAAQ,iBA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ourcesContent":["/**\n * Context file discovery (T1.1, ADRs D150 / D151).\n *\n * Discovers context files via three scopes:\n * - `cwd-only` — single dir, single path lookup\n * - `git-root-walk` — walk cwd → git-root, collect every directory's match\n * (nearest-first ordering)\n * - `globbed` — glob pattern relative to cwd (e.g. `.cursor/rules/*.mdc`)\n *\n * Pure `existsSync` checks — **no `.gitignore` parsing** (EC-A, KISS) and\n * **no invented `.theokitignore`** (EC-B). Paths normalized via\n * `realpath` to dedup symlink chains pointing to the same physical file\n * (EC-F). Git worktrees work transparently because `.git` exists as a\n * file in that case (EC-N).\n *\n * @internal\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\n/** Single filename (\"AGENTS.md\") or relative glob (\".cursor/rules/*.mdc\"). */\nexport type DiscoveryScope = \"cwd-only\" | \"git-root-walk\" | \"globbed\";\n\n/** Parser to apply once file is read. */\nexport type DiscoveryParser = \"plain-markdown\" | \"mdc\" | \"frontmatter-zod\" | \"rules-frontmatter\";\n\n/**\n * Specification for one discoverable context source. The default registry\n * `DEFAULT_DISCOVERY_SPECS` covers the 2026 industry-standard set.\n *\n * @internal\n */\nexport interface DiscoverySpec {\n /** Stable identifier — used as `<source name=\"\">` and telemetry key. */\n readonly id: string;\n /** Priority for merge (lower = earlier in prompt). */\n readonly priority: number;\n /** Filename (cwd-only/git-root-walk) or glob (globbed). */\n readonly pattern: string;\n readonly scope: DiscoveryScope;\n readonly parser: DiscoveryParser;\n /** Whether to follow `@path` import directives (CLAUDE.md / GEMINI.md). */\n readonly followImports: boolean;\n}\n\n/**\n * 2026 industry-standard context file registry. Sorted by priority\n * ascending — earlier in prompt = more general, last-writer-wins on\n * conflict (D152 concat-by-priority).\n *\n * @internal\n */\nexport const DEFAULT_DISCOVERY_SPECS: ReadonlyArray<DiscoverySpec> = [\n {\n id: \"AGENTS.md\",\n pattern: \"AGENTS.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 10,\n },\n {\n id: \"GEMINI.md\",\n pattern: \"GEMINI.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 20,\n },\n {\n id: \"CLAUDE.md\",\n pattern: \"CLAUDE.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 30,\n },\n {\n id: \"cursor-rules\",\n pattern: \".cursor/rules/*.mdc\",\n scope: \"globbed\",\n parser: \"mdc\",\n followImports: false,\n priority: 40,\n },\n {\n id: \"theokit-rules\",\n pattern: \".theokit/rules/*.md\",\n scope: \"globbed\",\n parser: \"rules-frontmatter\",\n followImports: false,\n priority: 45,\n },\n {\n id: \"theokit-context\",\n pattern: \".theokit/context/*.md\",\n scope: \"globbed\",\n parser: \"frontmatter-zod\",\n followImports: false,\n priority: 50,\n },\n {\n id: \"THEO.md\",\n pattern: \".theokit/THEO.md\",\n scope: \"cwd-only\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 60,\n },\n];\n\nconst SAFE_FILENAME = /^[a-zA-Z0-9_.\\-/*]+$/;\nconst TRAVERSAL_RE = /(^|\\/)\\.\\.(\\/|$)/;\n\n/**\n * Reject patterns that contain path traversal (`..`) or non-allowed\n * characters (D81 parity, EC-4).\n *\n * @internal\n */\nexport function isSafePattern(pattern: string): boolean {\n if (typeof pattern !== \"string\" || pattern.length === 0) return false;\n if (TRAVERSAL_RE.test(pattern)) return false;\n if (isAbsolute(pattern)) return false;\n return SAFE_FILENAME.test(pattern);\n}\n\n/**\n * Walk upward from `cwd` looking for the closest directory containing\n * a `.git` entry (file OR directory — worktrees use a `.git` FILE,\n * EC-N). Returns the absolute path of that directory, or `undefined`\n * when no git root exists at or above `cwd`.\n *\n * @internal\n */\nexport function findGitRoot(cwd: string): string | undefined {\n if (typeof cwd !== \"string\" || cwd.length === 0) return undefined;\n let current = resolve(cwd);\n // Guard against infinite loops on weird filesystems.\n for (let i = 0; i < 64; i += 1) {\n if (existsSync(join(current, \".git\"))) return current;\n const parent = dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n return undefined;\n}\n\n/**\n * Walk `cwd` upward to `stopDir` (inclusive) collecting every existing\n * occurrence of `filename`. Returns absolute, realpath-deduped paths in\n * nearest-first order (innermost dir first).\n *\n * No `.gitignore` parsing (EC-A). Realpath collapses symlink chains\n * pointing to the same physical file (EC-F). Filesystem races (file\n * deleted mid-walk) are skipped silently (EC-5).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: walk-up loop combines validation + realpath dedup + FS-race handling + stopDir guard in a single bounded loop; splitting fragments the dedup invariant.\nexport function walkUpForFile(\n cwd: string,\n filename: string,\n stopDir: string | undefined,\n): string[] {\n if (!isSafePattern(filename)) {\n return [];\n }\n const start = resolve(cwd);\n const stop = stopDir !== undefined ? resolve(stopDir) : undefined;\n const found: string[] = [];\n const seenReal = new Set<string>();\n let current = start;\n // 64-level depth cap.\n for (let i = 0; i < 64; i += 1) {\n const candidate = join(current, filename);\n if (existsSync(candidate)) {\n let real: string;\n try {\n real = realpathSync(candidate);\n } catch {\n // FS race (deleted mid-walk) — skip.\n real = candidate;\n }\n if (!seenReal.has(real)) {\n seenReal.add(real);\n found.push(real);\n }\n }\n if (stop !== undefined && current === stop) break;\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return found;\n}\n\n/**\n * Glob-style discovery scoped to a single directory under cwd (e.g.\n * `.cursor/rules/*.mdc`). Flat — does NOT recurse into subdirectories\n * (EC-R: nested directories deferred to v2). Returns absolute,\n * lex-sorted paths.\n *\n * @internal\n */\nexport async function walkUpForGlob(cwd: string, pattern: string): Promise<string[]> {\n if (!isSafePattern(pattern)) return [];\n const lastSlash = pattern.lastIndexOf(\"/\");\n if (lastSlash < 0) {\n // Single filename — treat as cwd-only single match.\n const candidate = join(cwd, pattern);\n return existsSync(candidate) ? [resolve(candidate)] : [];\n }\n const dirPart = pattern.slice(0, lastSlash);\n const filePart = pattern.slice(lastSlash + 1);\n const dir = join(cwd, dirPart);\n if (!existsSync(dir)) return [];\n // Build a regex from the file part — supports only `*` wildcard.\n const fileRe = filePartToRegex(filePart);\n let entries: string[];\n try {\n entries = await readdir(dir);\n } catch {\n return [];\n }\n const matched = entries.filter((e) => fileRe.test(e)).sort();\n return matched.map((e) => resolve(join(dir, e)));\n}\n\nfunction filePartToRegex(filePart: string): RegExp {\n const escaped = filePart.replace(/[.+^${}()|[\\]\\\\]/g, \"\\\\$&\").replace(/\\*/g, \".*\");\n return new RegExp(`^${escaped}$`);\n}\n"]}
|