@theokit/sdk 5.9.0 → 5.9.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.
- package/CHANGELOG.md +26 -0
- package/dist/{agent-ZM4FDDL7.cjs → agent-5M7WLUWH.cjs} +7 -7
- package/dist/{agent-ZM4FDDL7.cjs.map → agent-5M7WLUWH.cjs.map} +1 -1
- package/dist/{agent-6STOEBGQ.js → agent-R5RERYFU.js} +6 -6
- package/dist/{agent-6STOEBGQ.js.map → agent-R5RERYFU.js.map} +1 -1
- package/dist/{chunk-BM6PDJW3.cjs → chunk-56BCEM26.cjs} +27 -27
- package/dist/{chunk-BM6PDJW3.cjs.map → chunk-56BCEM26.cjs.map} +1 -1
- package/dist/{chunk-DDRX4LYS.js → chunk-7QJYKVP6.js} +3 -3
- package/dist/{chunk-DDRX4LYS.js.map → chunk-7QJYKVP6.js.map} +1 -1
- package/dist/{chunk-J4SA2ZEJ.cjs → chunk-KIKKTW5O.cjs} +4 -4
- package/dist/{chunk-J4SA2ZEJ.cjs.map → chunk-KIKKTW5O.cjs.map} +1 -1
- package/dist/{chunk-5WR33BHA.cjs → chunk-LL4QA3DI.cjs} +4 -4
- package/dist/{chunk-5WR33BHA.cjs.map → chunk-LL4QA3DI.cjs.map} +1 -1
- package/dist/{chunk-OCEQ6DW2.cjs → chunk-N6OEX5TN.cjs} +2 -2
- package/dist/chunk-N6OEX5TN.cjs.map +1 -0
- package/dist/{chunk-PYFBS6OQ.js → chunk-OOM236Z4.js} +6 -6
- package/dist/{chunk-PYFBS6OQ.js.map → chunk-OOM236Z4.js.map} +1 -1
- package/dist/{chunk-7GDHFV2M.js → chunk-OPAKPEPG.js} +2 -2
- package/dist/chunk-OPAKPEPG.js.map +1 -0
- package/dist/{chunk-UKBBYVNS.js → chunk-QCIARBLS.js} +3 -3
- package/dist/{chunk-UKBBYVNS.js.map → chunk-QCIARBLS.js.map} +1 -1
- package/dist/{chunk-KTA7YTZQ.cjs → chunk-XKZFIP7Z.cjs} +4 -4
- package/dist/{chunk-KTA7YTZQ.cjs.map → chunk-XKZFIP7Z.cjs.map} +1 -1
- package/dist/{chunk-PQCTDMUI.js → chunk-ZHWKT2NI.js} +3 -3
- package/dist/{chunk-PQCTDMUI.js.map → chunk-ZHWKT2NI.js.map} +1 -1
- package/dist/context/index.cjs +6 -6
- package/dist/context/index.js +3 -3
- package/dist/context-3FZRAO5K.js +7 -0
- package/dist/{context-SXR2HLHT.js.map → context-3FZRAO5K.js.map} +1 -1
- package/dist/{context-ZOULM2RB.cjs → context-B5J4GX2F.cjs} +7 -7
- package/dist/{context-ZOULM2RB.cjs.map → context-B5J4GX2F.cjs.map} +1 -1
- package/dist/cron.cjs +6 -6
- package/dist/cron.js +5 -5
- package/dist/eval.cjs +5 -5
- package/dist/eval.js +4 -4
- package/dist/index.cjs +23 -23
- package/dist/index.js +7 -7
- package/dist/internal/runtime/hooks/hooks-source.d.ts +24 -0
- package/docs/error-codes.md +3 -3
- package/package.json +1 -1
- package/dist/chunk-7GDHFV2M.js.map +0 -1
- package/dist/chunk-OCEQ6DW2.cjs.map +0 -1
- package/dist/context-SXR2HLHT.js +0 -7
package/dist/context/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
3
|
+
var chunkXKZFIP7Z_cjs = require('../chunk-XKZFIP7Z.cjs');
|
|
4
|
+
require('../chunk-N6OEX5TN.cjs');
|
|
5
5
|
require('../chunk-KRD3GQAA.cjs');
|
|
6
6
|
var chunkSWALPLFQ_cjs = require('../chunk-SWALPLFQ.cjs');
|
|
7
7
|
require('../chunk-SA6K24NB.cjs');
|
|
@@ -17,20 +17,20 @@ function resolveContextImports(content, basePath, options) {
|
|
|
17
17
|
maxBytesPerFile: options.maxBytesPerFile,
|
|
18
18
|
projectRoot: options.projectRoot
|
|
19
19
|
};
|
|
20
|
-
return
|
|
20
|
+
return chunkXKZFIP7Z_cjs.resolveImports(content, basePath, internalOptions);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
Object.defineProperty(exports, "parseRules", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkXKZFIP7Z_cjs.parseRules; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "runDiscovery", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkXKZFIP7Z_cjs.runDiscovery; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "shouldActivateRule", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkXKZFIP7Z_cjs.shouldActivateRule; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "DEFAULT_DISCOVERY_SPECS", {
|
|
36
36
|
enumerable: true,
|
package/dist/context/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveImports } from '../chunk-
|
|
2
|
-
export { parseRules, runDiscovery, shouldActivateRule } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
import { resolveImports } from '../chunk-7QJYKVP6.js';
|
|
2
|
+
export { parseRules, runDiscovery, shouldActivateRule } from '../chunk-7QJYKVP6.js';
|
|
3
|
+
import '../chunk-OPAKPEPG.js';
|
|
4
4
|
import '../chunk-KVNWIAO4.js';
|
|
5
5
|
export { DEFAULT_DISCOVERY_SPECS, withheldSpecs } from '../chunk-4QCJAJAG.js';
|
|
6
6
|
import '../chunk-UKMBRMGT.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { currentPersonalityContext, warnPersonalitySwitchInsideFork, withPersonalityContext } from './chunk-ZHWKT2NI.js';
|
|
2
|
+
import './chunk-OPAKPEPG.js';
|
|
3
|
+
import './chunk-X7EUUHXU.js';
|
|
4
|
+
import './chunk-B5MHRQJZ.js';
|
|
5
|
+
import './chunk-CZJ6Q7CW.js';
|
|
6
|
+
//# sourceMappingURL=context-3FZRAO5K.js.map
|
|
7
|
+
//# sourceMappingURL=context-3FZRAO5K.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"context-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"context-3FZRAO5K.js"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkKIKKTW5O_cjs = require('./chunk-KIKKTW5O.cjs');
|
|
4
|
+
require('./chunk-N6OEX5TN.cjs');
|
|
5
5
|
require('./chunk-TY56BKSK.cjs');
|
|
6
6
|
require('./chunk-UNFBHV46.cjs');
|
|
7
7
|
require('./chunk-6LHQPOMI.cjs');
|
|
@@ -10,15 +10,15 @@ require('./chunk-6LHQPOMI.cjs');
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "currentPersonalityContext", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkKIKKTW5O_cjs.currentPersonalityContext; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "warnPersonalitySwitchInsideFork", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkKIKKTW5O_cjs.warnPersonalitySwitchInsideFork; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "withPersonalityContext", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkKIKKTW5O_cjs.withPersonalityContext; }
|
|
22
22
|
});
|
|
23
|
-
//# sourceMappingURL=context-
|
|
24
|
-
//# sourceMappingURL=context-
|
|
23
|
+
//# sourceMappingURL=context-B5J4GX2F.cjs.map
|
|
24
|
+
//# sourceMappingURL=context-B5J4GX2F.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"context-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"context-B5J4GX2F.cjs"}
|
package/dist/cron.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkLL4QA3DI_cjs = require('./chunk-LL4QA3DI.cjs');
|
|
4
|
+
require('./chunk-56BCEM26.cjs');
|
|
5
5
|
require('./chunk-J6GXS5A2.cjs');
|
|
6
6
|
require('./chunk-PSLCVSCS.cjs');
|
|
7
7
|
require('./chunk-BUUUWQMB.cjs');
|
|
8
8
|
require('./chunk-TTBIQTO5.cjs');
|
|
9
|
-
require('./chunk-
|
|
9
|
+
require('./chunk-KIKKTW5O.cjs');
|
|
10
10
|
require('./chunk-BV2MWEMV.cjs');
|
|
11
11
|
require('./chunk-MEUBLCM4.cjs');
|
|
12
12
|
require('./chunk-GHX4P3V2.cjs');
|
|
@@ -20,8 +20,8 @@ require('./chunk-WPO3VCY4.cjs');
|
|
|
20
20
|
require('./chunk-QOGNZMHD.cjs');
|
|
21
21
|
require('./chunk-YIFFF23U.cjs');
|
|
22
22
|
require('./chunk-2ZPEDVLM.cjs');
|
|
23
|
-
require('./chunk-
|
|
24
|
-
require('./chunk-
|
|
23
|
+
require('./chunk-XKZFIP7Z.cjs');
|
|
24
|
+
require('./chunk-N6OEX5TN.cjs');
|
|
25
25
|
require('./chunk-KRD3GQAA.cjs');
|
|
26
26
|
require('./chunk-RQMCOFAI.cjs');
|
|
27
27
|
require('./chunk-MUUQ2WFJ.cjs');
|
|
@@ -63,7 +63,7 @@ require('./chunk-6LHQPOMI.cjs');
|
|
|
63
63
|
|
|
64
64
|
Object.defineProperty(exports, "Cron", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkLL4QA3DI_cjs.Cron; }
|
|
67
67
|
});
|
|
68
68
|
//# sourceMappingURL=cron.cjs.map
|
|
69
69
|
//# sourceMappingURL=cron.cjs.map
|
package/dist/cron.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { Cron } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { Cron } from './chunk-QCIARBLS.js';
|
|
2
|
+
import './chunk-OOM236Z4.js';
|
|
3
3
|
import './chunk-XKMVJ443.js';
|
|
4
4
|
import './chunk-5522X223.js';
|
|
5
5
|
import './chunk-K2BQQ445.js';
|
|
6
6
|
import './chunk-R2C3HXR3.js';
|
|
7
|
-
import './chunk-
|
|
7
|
+
import './chunk-ZHWKT2NI.js';
|
|
8
8
|
import './chunk-2SFBB54R.js';
|
|
9
9
|
import './chunk-HOHR75KF.js';
|
|
10
10
|
import './chunk-H73MEMQB.js';
|
|
@@ -18,8 +18,8 @@ import './chunk-TE6XVTOA.js';
|
|
|
18
18
|
import './chunk-24MGQDK3.js';
|
|
19
19
|
import './chunk-2WXHA33T.js';
|
|
20
20
|
import './chunk-HKCKOAIO.js';
|
|
21
|
-
import './chunk-
|
|
22
|
-
import './chunk-
|
|
21
|
+
import './chunk-7QJYKVP6.js';
|
|
22
|
+
import './chunk-OPAKPEPG.js';
|
|
23
23
|
import './chunk-KVNWIAO4.js';
|
|
24
24
|
import './chunk-SVQIW5RJ.js';
|
|
25
25
|
import './chunk-FD2UT76F.js';
|
package/dist/eval.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk7NQ7HJ3E_cjs = require('./chunk-7NQ7HJ3E.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk56BCEM26_cjs = require('./chunk-56BCEM26.cjs');
|
|
5
5
|
require('./chunk-J6GXS5A2.cjs');
|
|
6
6
|
require('./chunk-PSLCVSCS.cjs');
|
|
7
7
|
var chunkBUUUWQMB_cjs = require('./chunk-BUUUWQMB.cjs');
|
|
8
8
|
require('./chunk-TTBIQTO5.cjs');
|
|
9
|
-
require('./chunk-
|
|
9
|
+
require('./chunk-KIKKTW5O.cjs');
|
|
10
10
|
require('./chunk-BV2MWEMV.cjs');
|
|
11
11
|
require('./chunk-MEUBLCM4.cjs');
|
|
12
12
|
require('./chunk-GHX4P3V2.cjs');
|
|
@@ -20,8 +20,8 @@ require('./chunk-WPO3VCY4.cjs');
|
|
|
20
20
|
require('./chunk-QOGNZMHD.cjs');
|
|
21
21
|
require('./chunk-YIFFF23U.cjs');
|
|
22
22
|
require('./chunk-2ZPEDVLM.cjs');
|
|
23
|
-
require('./chunk-
|
|
24
|
-
require('./chunk-
|
|
23
|
+
require('./chunk-XKZFIP7Z.cjs');
|
|
24
|
+
require('./chunk-N6OEX5TN.cjs');
|
|
25
25
|
require('./chunk-KRD3GQAA.cjs');
|
|
26
26
|
require('./chunk-RQMCOFAI.cjs');
|
|
27
27
|
require('./chunk-MUUQ2WFJ.cjs');
|
|
@@ -796,7 +796,7 @@ function makeDefaultEmbedder(opts) {
|
|
|
796
796
|
let runtime;
|
|
797
797
|
return (texts) => {
|
|
798
798
|
if (runtime === void 0) {
|
|
799
|
-
runtime =
|
|
799
|
+
runtime = chunk56BCEM26_cjs.openRouterMemoryEmbeddingProviderAdapter.create(embedderCreateOptions(opts));
|
|
800
800
|
}
|
|
801
801
|
return runtime.then((rt) => rt.embed(texts));
|
|
802
802
|
};
|
package/dist/eval.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { shellEscapePosix, LocalSandbox } from './chunk-GMSRRJ53.js';
|
|
2
|
-
import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-
|
|
2
|
+
import { openRouterMemoryEmbeddingProviderAdapter } from './chunk-OOM236Z4.js';
|
|
3
3
|
import './chunk-XKMVJ443.js';
|
|
4
4
|
import './chunk-5522X223.js';
|
|
5
5
|
import { getTracer } from './chunk-K2BQQ445.js';
|
|
6
6
|
import './chunk-R2C3HXR3.js';
|
|
7
|
-
import './chunk-
|
|
7
|
+
import './chunk-ZHWKT2NI.js';
|
|
8
8
|
import './chunk-2SFBB54R.js';
|
|
9
9
|
import './chunk-HOHR75KF.js';
|
|
10
10
|
import './chunk-H73MEMQB.js';
|
|
@@ -18,8 +18,8 @@ import './chunk-TE6XVTOA.js';
|
|
|
18
18
|
import './chunk-24MGQDK3.js';
|
|
19
19
|
import './chunk-2WXHA33T.js';
|
|
20
20
|
import './chunk-HKCKOAIO.js';
|
|
21
|
-
import './chunk-
|
|
22
|
-
import './chunk-
|
|
21
|
+
import './chunk-7QJYKVP6.js';
|
|
22
|
+
import './chunk-OPAKPEPG.js';
|
|
23
23
|
import './chunk-KVNWIAO4.js';
|
|
24
24
|
import './chunk-SVQIW5RJ.js';
|
|
25
25
|
import './chunk-FD2UT76F.js';
|
package/dist/index.cjs
CHANGED
|
@@ -9,13 +9,13 @@ require('./chunk-D5KXKBEN.cjs');
|
|
|
9
9
|
var chunkMPQJE3G4_cjs = require('./chunk-MPQJE3G4.cjs');
|
|
10
10
|
require('./chunk-6PB5AQCY.cjs');
|
|
11
11
|
require('./chunk-VTYY7XL5.cjs');
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var chunkLL4QA3DI_cjs = require('./chunk-LL4QA3DI.cjs');
|
|
13
|
+
var chunk56BCEM26_cjs = require('./chunk-56BCEM26.cjs');
|
|
14
14
|
var chunkJ6GXS5A2_cjs = require('./chunk-J6GXS5A2.cjs');
|
|
15
15
|
require('./chunk-PSLCVSCS.cjs');
|
|
16
16
|
require('./chunk-BUUUWQMB.cjs');
|
|
17
17
|
require('./chunk-TTBIQTO5.cjs');
|
|
18
|
-
require('./chunk-
|
|
18
|
+
require('./chunk-KIKKTW5O.cjs');
|
|
19
19
|
require('./chunk-BV2MWEMV.cjs');
|
|
20
20
|
require('./chunk-MEUBLCM4.cjs');
|
|
21
21
|
require('./chunk-GHX4P3V2.cjs');
|
|
@@ -29,8 +29,8 @@ require('./chunk-WPO3VCY4.cjs');
|
|
|
29
29
|
require('./chunk-QOGNZMHD.cjs');
|
|
30
30
|
var chunkYIFFF23U_cjs = require('./chunk-YIFFF23U.cjs');
|
|
31
31
|
require('./chunk-2ZPEDVLM.cjs');
|
|
32
|
-
require('./chunk-
|
|
33
|
-
require('./chunk-
|
|
32
|
+
require('./chunk-XKZFIP7Z.cjs');
|
|
33
|
+
require('./chunk-N6OEX5TN.cjs');
|
|
34
34
|
require('./chunk-KRD3GQAA.cjs');
|
|
35
35
|
require('./chunk-RQMCOFAI.cjs');
|
|
36
36
|
require('./chunk-MUUQ2WFJ.cjs');
|
|
@@ -76,8 +76,8 @@ var os = require('os');
|
|
|
76
76
|
// src/agent-factory.ts
|
|
77
77
|
function createAgentFactory(common) {
|
|
78
78
|
return {
|
|
79
|
-
forSession: (agentId, overrides) =>
|
|
80
|
-
getOrCreate: (agentId, overrides) =>
|
|
79
|
+
forSession: (agentId, overrides) => chunk56BCEM26_cjs.Agent.create(mergeAgentOptions(common, overrides, agentId)),
|
|
80
|
+
getOrCreate: (agentId, overrides) => chunk56BCEM26_cjs.Agent.getOrCreate(agentId, mergeAgentOptions(common, overrides, agentId))
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
function mergeAgentOptions(common, overrides, agentId) {
|
|
@@ -1373,7 +1373,7 @@ var Memory = {
|
|
|
1373
1373
|
return await peer.IndexManager.open(openArgs);
|
|
1374
1374
|
}
|
|
1375
1375
|
const { IndexManager } = await import('./index-manager-ZGJN25FD.cjs');
|
|
1376
|
-
openArgs.embedding = await resolveEmbedding(opts.embedding,
|
|
1376
|
+
openArgs.embedding = await resolveEmbedding(opts.embedding, chunk56BCEM26_cjs.MEMORY_EMBEDDING_ADAPTERS);
|
|
1377
1377
|
return await IndexManager.open(openArgs);
|
|
1378
1378
|
},
|
|
1379
1379
|
/**
|
|
@@ -1384,7 +1384,7 @@ var Memory = {
|
|
|
1384
1384
|
*/
|
|
1385
1385
|
async runDreamingSweep(opts) {
|
|
1386
1386
|
const peer = await tryLoadSdkMemoryPeer();
|
|
1387
|
-
const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS :
|
|
1387
|
+
const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS : chunk56BCEM26_cjs.MEMORY_EMBEDDING_ADAPTERS;
|
|
1388
1388
|
const sweepArgs = await buildDreamingSweepArgs(opts, catalog);
|
|
1389
1389
|
const result = peer !== null ? (
|
|
1390
1390
|
// biome-ignore lint/suspicious/noExplicitAny: peer is dynamically loaded — structural compat ensured by sdk-memory
|
|
@@ -1994,7 +1994,7 @@ function guardSessionDestruction(sessionId, live) {
|
|
|
1994
1994
|
// src/session-messages.ts
|
|
1995
1995
|
async function readSessionMessages2(options) {
|
|
1996
1996
|
const cwd = options.cwd ?? process.cwd();
|
|
1997
|
-
const baseDir =
|
|
1997
|
+
const baseDir = chunk56BCEM26_cjs.resolveSessionDir({ sessionDir: options.sessionDir });
|
|
1998
1998
|
return chunkYIFFF23U_cjs.readSessionMessages(new chunkB3XXQX6L_cjs.FsSessionStore({ baseDir, cwd }), options.sessionId);
|
|
1999
1999
|
}
|
|
2000
2000
|
|
|
@@ -2011,7 +2011,7 @@ function isBuiltAgent(m) {
|
|
|
2011
2011
|
return typeof m.send === "function";
|
|
2012
2012
|
}
|
|
2013
2013
|
async function materialize(def, index) {
|
|
2014
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
2014
|
+
const { Agent: Agent2 } = await import('./agent-5M7WLUWH.cjs');
|
|
2015
2015
|
return Agent2.create({
|
|
2016
2016
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
2017
2017
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -2153,7 +2153,7 @@ var FIXTURE_USER = {
|
|
|
2153
2153
|
};
|
|
2154
2154
|
var FIXTURE_MODELS = [
|
|
2155
2155
|
{
|
|
2156
|
-
id:
|
|
2156
|
+
id: chunk56BCEM26_cjs.DEFAULT_AGENTIC_MODEL_ID,
|
|
2157
2157
|
name: "Gemini 2.0 Flash",
|
|
2158
2158
|
displayName: "Gemini 2.0 Flash",
|
|
2159
2159
|
parameters: [
|
|
@@ -2356,7 +2356,7 @@ var Theokit = class {
|
|
|
2356
2356
|
envVars: p.envVars
|
|
2357
2357
|
}));
|
|
2358
2358
|
},
|
|
2359
|
-
embeddingAdapters: () => Object.entries(
|
|
2359
|
+
embeddingAdapters: () => Object.entries(chunk56BCEM26_cjs.MEMORY_EMBEDDING_ADAPTERS).map(([id, adapter]) => ({
|
|
2360
2360
|
id,
|
|
2361
2361
|
transport: adapter.transport,
|
|
2362
2362
|
defaultModel: adapter.defaultModel
|
|
@@ -2575,43 +2575,43 @@ Object.defineProperty(exports, "fn", {
|
|
|
2575
2575
|
});
|
|
2576
2576
|
Object.defineProperty(exports, "Cron", {
|
|
2577
2577
|
enumerable: true,
|
|
2578
|
-
get: function () { return
|
|
2578
|
+
get: function () { return chunkLL4QA3DI_cjs.Cron; }
|
|
2579
2579
|
});
|
|
2580
2580
|
Object.defineProperty(exports, "Agent", {
|
|
2581
2581
|
enumerable: true,
|
|
2582
|
-
get: function () { return
|
|
2582
|
+
get: function () { return chunk56BCEM26_cjs.Agent; }
|
|
2583
2583
|
});
|
|
2584
2584
|
Object.defineProperty(exports, "AgentBuilder", {
|
|
2585
2585
|
enumerable: true,
|
|
2586
|
-
get: function () { return
|
|
2586
|
+
get: function () { return chunk56BCEM26_cjs.AgentBuilder; }
|
|
2587
2587
|
});
|
|
2588
2588
|
Object.defineProperty(exports, "Tool", {
|
|
2589
2589
|
enumerable: true,
|
|
2590
|
-
get: function () { return
|
|
2590
|
+
get: function () { return chunk56BCEM26_cjs.Tool; }
|
|
2591
2591
|
});
|
|
2592
2592
|
Object.defineProperty(exports, "ToolError", {
|
|
2593
2593
|
enumerable: true,
|
|
2594
|
-
get: function () { return
|
|
2594
|
+
get: function () { return chunk56BCEM26_cjs.ToolError; }
|
|
2595
2595
|
});
|
|
2596
2596
|
Object.defineProperty(exports, "UsageAccumulator", {
|
|
2597
2597
|
enumerable: true,
|
|
2598
|
-
get: function () { return
|
|
2598
|
+
get: function () { return chunk56BCEM26_cjs.UsageAccumulator; }
|
|
2599
2599
|
});
|
|
2600
2600
|
Object.defineProperty(exports, "computeCost", {
|
|
2601
2601
|
enumerable: true,
|
|
2602
|
-
get: function () { return
|
|
2602
|
+
get: function () { return chunk56BCEM26_cjs.computeCost; }
|
|
2603
2603
|
});
|
|
2604
2604
|
Object.defineProperty(exports, "getPricingEntry", {
|
|
2605
2605
|
enumerable: true,
|
|
2606
|
-
get: function () { return
|
|
2606
|
+
get: function () { return chunk56BCEM26_cjs.getPricingEntry; }
|
|
2607
2607
|
});
|
|
2608
2608
|
Object.defineProperty(exports, "managedSettingsPathFor", {
|
|
2609
2609
|
enumerable: true,
|
|
2610
|
-
get: function () { return
|
|
2610
|
+
get: function () { return chunk56BCEM26_cjs.managedSettingsPathFor; }
|
|
2611
2611
|
});
|
|
2612
2612
|
Object.defineProperty(exports, "readManagedSettings", {
|
|
2613
2613
|
enumerable: true,
|
|
2614
|
-
get: function () { return
|
|
2614
|
+
get: function () { return chunk56BCEM26_cjs.readManagedSettings; }
|
|
2615
2615
|
});
|
|
2616
2616
|
Object.defineProperty(exports, "emitRunEvent", {
|
|
2617
2617
|
enumerable: true,
|
package/dist/index.js
CHANGED
|
@@ -8,15 +8,15 @@ import { Workflow, agentStep } from './chunk-MU7IAA7G.js';
|
|
|
8
8
|
export { Workflow, agentStep, fn } from './chunk-MU7IAA7G.js';
|
|
9
9
|
import './chunk-HV4V63CO.js';
|
|
10
10
|
import './chunk-HY66GLM6.js';
|
|
11
|
-
export { Cron } from './chunk-
|
|
12
|
-
import { MEMORY_EMBEDDING_ADAPTERS, resolveSessionDir, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-
|
|
13
|
-
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry, managedSettingsPathFor, readManagedSettings } from './chunk-
|
|
11
|
+
export { Cron } from './chunk-QCIARBLS.js';
|
|
12
|
+
import { MEMORY_EMBEDDING_ADAPTERS, resolveSessionDir, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-OOM236Z4.js';
|
|
13
|
+
export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry, managedSettingsPathFor, readManagedSettings } from './chunk-OOM236Z4.js';
|
|
14
14
|
import { configure, submit, list, get, cancel, subscribe } from './chunk-XKMVJ443.js';
|
|
15
15
|
export { emitRunEvent } from './chunk-XKMVJ443.js';
|
|
16
16
|
import './chunk-5522X223.js';
|
|
17
17
|
import './chunk-K2BQQ445.js';
|
|
18
18
|
import './chunk-R2C3HXR3.js';
|
|
19
|
-
import './chunk-
|
|
19
|
+
import './chunk-ZHWKT2NI.js';
|
|
20
20
|
import './chunk-2SFBB54R.js';
|
|
21
21
|
import './chunk-HOHR75KF.js';
|
|
22
22
|
import './chunk-H73MEMQB.js';
|
|
@@ -30,8 +30,8 @@ import './chunk-TE6XVTOA.js';
|
|
|
30
30
|
import './chunk-24MGQDK3.js';
|
|
31
31
|
import { readSessionMessages } from './chunk-2WXHA33T.js';
|
|
32
32
|
import './chunk-HKCKOAIO.js';
|
|
33
|
-
import './chunk-
|
|
34
|
-
import './chunk-
|
|
33
|
+
import './chunk-7QJYKVP6.js';
|
|
34
|
+
import './chunk-OPAKPEPG.js';
|
|
35
35
|
import './chunk-KVNWIAO4.js';
|
|
36
36
|
import './chunk-SVQIW5RJ.js';
|
|
37
37
|
import './chunk-FD2UT76F.js';
|
|
@@ -2016,7 +2016,7 @@ function isBuiltAgent(m) {
|
|
|
2016
2016
|
return typeof m.send === "function";
|
|
2017
2017
|
}
|
|
2018
2018
|
async function materialize(def, index) {
|
|
2019
|
-
const { Agent: Agent2 } = await import('./agent-
|
|
2019
|
+
const { Agent: Agent2 } = await import('./agent-R5RERYFU.js');
|
|
2020
2020
|
return Agent2.create({
|
|
2021
2021
|
// `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
|
|
2022
2022
|
// here means "declare nothing and let the default apply" — forwarding the literal would create
|
|
@@ -78,3 +78,27 @@ export interface HookCommand {
|
|
|
78
78
|
export interface HookConfig {
|
|
79
79
|
hooks?: Partial<Record<HookEvent, HookCommand[]>>;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Fields a Claude Code hook entry may declare that this runtime does not implement.
|
|
83
|
+
*
|
|
84
|
+
* Listed rather than lumped into "unknown" because the two are different facts to the operator
|
|
85
|
+
* reading the error: a typo is theirs to fix, and a field written for another runtime is a tree
|
|
86
|
+
* that was never going to work here. The same split is made for subagent frontmatter, for the same
|
|
87
|
+
* reason — an operator migrating a `.claude/` tree learned one key per round trip otherwise.
|
|
88
|
+
*
|
|
89
|
+
* `if` is the one that made refusal the right answer rather than a warning. Dropped, it fails OPEN:
|
|
90
|
+
* a deny hook narrowed to one dangerous command shape silently becomes a deny hook over every call
|
|
91
|
+
* of that tool. Every other field in this set loses a convenience; this one inverts the intent.
|
|
92
|
+
*
|
|
93
|
+
* Exported for the same reason {@link CLAUDE_CODE_EVENT_MAP} is: so the set is DERIVED by whoever
|
|
94
|
+
* states it, rather than restated and left to drift. The README documents this list, and
|
|
95
|
+
* `tests/the-readme-hooks-shape-matches-the-loader.test.ts` reads it from here — #638, where the
|
|
96
|
+
* README told a consumer to validate "against the shape above" and no shape was above it.
|
|
97
|
+
*/
|
|
98
|
+
export declare const UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS: Set<string>;
|
|
99
|
+
/**
|
|
100
|
+
* What `parseClaudeCodeCommand` reads. Anything else is refused.
|
|
101
|
+
*
|
|
102
|
+
* Exported for the README gate — see the note on the set above.
|
|
103
|
+
*/
|
|
104
|
+
export declare const ACCEPTED_HOOK_FIELDS: Set<string>;
|
package/docs/error-codes.md
CHANGED
|
@@ -79,11 +79,11 @@ Branch on `code`, never on the message: messages carry context (an id, a path, a
|
|
|
79
79
|
| `handoff_target_required` | domain | ConfigurationError | `packages/sdk-handoff/src/handoff.ts:111` |
|
|
80
80
|
| `hitl_timeout` | domain | HitlTimeoutError | `packages/sdk/src/internal/runtime/tools/hitl-middleware.ts:42` +1 |
|
|
81
81
|
| `hook_denied` | domain | ConfigurationError | `packages/sdk/src/internal/local-agent/local-agent.ts:454` |
|
|
82
|
-
| `hooks_invalid_command` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:
|
|
82
|
+
| `hooks_invalid_command` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:415` |
|
|
83
83
|
| `hooks_json_invalid` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:252` +2 |
|
|
84
84
|
| `hooks_read_error` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:243` |
|
|
85
|
-
| `hooks_unsupported_field` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:
|
|
86
|
-
| `hooks_unsupported_type` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:
|
|
85
|
+
| `hooks_unsupported_field` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:393` |
|
|
86
|
+
| `hooks_unsupported_type` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:409` |
|
|
87
87
|
| `interactive_unavailable` | domain | InteractiveUnavailableError | `packages/sdk/src/interactive/types.ts:28` +1 |
|
|
88
88
|
| `INTERNAL_SERVER_ERROR` | domain | — | `packages/sdk/src/server/errors-envelope.ts:100` |
|
|
89
89
|
| `invalid_argument` | domain | TheokitAgentError | `packages/sdk/src/compaction.ts:79` |
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/runtime/hooks/hooks-source.ts"],"names":[],"mappings":";;;;;;;AA8DO,IAAM,qBAA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;AACxC,EAAA,IAAI,OAAO,GAAA,CAAI,OAAA,KAAY,QAAA,IAAY,GAAA,CAAI,UAAU,CAAA,EAAG;AACtD,IAAA,EAAA,CAAG,SAAA,GAAY,IAAA,CAAK,KAAA,CAAM,GAAA,CAAI,UAAU,GAAI,CAAA;AAAA,EAC9C;AACA,EAAA,OAAO,EAAA;AACT","file":"chunk-7GDHFV2M.js","sourcesContent":["/**\n * Single source of truth for loading the hooks config (ADR 0016 — reverses\n * D74/D77 for hooks: JSON is canonical again, in the Claude Code shape).\n *\n * `.theokit/hooks.json` (Claude-Code-shaped JSON) is the only supported form.\n * A stray legacy `.theokit/hooks/*.md` dir (no hooks.json) is NOT loaded — it\n * warns to migrate and yields no hooks. Absent both → empty config.\n *\n * Consumed by `hooks-executor.ts` (runtime dispatch).\n *\n * Config SHAPE is Claude Code's `settings.json` hooks:\n * { \"hooks\": { \"PreToolUse\": [ { \"matcher\": \"shell\",\n * \"hooks\": [ { \"type\": \"command\", \"command\": \"…\", \"timeout\": 30 } ] } ] } }\n *\n * The shape, not the event COVERAGE. Four of the thirty-three documented events are fired by this\n * runtime — see {@link CLAUDE_CODE_EVENT_MAP} for which, why the rest are refused rather than\n * mapped, and the order in which they should be added. An event outside the set is reported to the\n * operator rather than skipped in silence.\n *\n * @internal\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { ConfigurationError } from \"../../../errors.js\";\nimport { diag, diagFailure } from \"../../diagnostics.js\";\nimport { projectConfigRoots, theokitConfigRoot } from \"../../persistence/paths.js\";\nimport type { CompatSourceDeclaration } from \"../compat/foreign-config-sources.js\";\n\n/** The five lifecycle events the SDK runtime actually fires. */\nexport type HookEvent = \"preRun\" | \"postRun\" | \"preToolUse\" | \"postToolUse\" | \"stop\";\n\n/**\n * The Claude Code event names this runtime actually FIRES, and the internal event each becomes.\n *\n * Exported so the supported set is stated rather than implied. It used to be private, and the\n * docblock above claimed a shape \"identical to Claude Code's `settings.json` hooks\" while accepting\n * four of the thirty-three documented events — a claim nothing could contradict.\n *\n * A Claude Code event with no firing point here — `SessionStart`, `SubagentStop`, `PreCompact`,\n * `Notification`, `SessionEnd` among them — is skipped with a report rather than silently accepted,\n * because it would never run.\n *\n * ## Why this map is not simply grown\n *\n * Mapping a name the runtime does not fire is strictly WORSE than refusing it. An operator declaring\n * `PreCompact` today gets a report saying it will not fire; with the name mapped they would get\n * silence and a guard that never runs — a declared veto that does not exist. The map grows when the\n * seam exists, one event at a time.\n *\n * ## Priority, when it does grow\n *\n * The blocking events first. An unwired veto loses a CAPABILITY; an unwired observer loses a\n * SIGNAL. Thirteen of the sixteen the spec marks \"Can block? Yes\" are unwired, and\n * `tests/internal/runtime/hooks/the-supported-event-set-is-stated.test.ts` lists them in the order\n * they should be taken, so the next person does not re-derive which is which.\n *\n * `postRun` is reachable through this SDK's own config and has no entry here on purpose: it fires\n * per RUN, and no documented Claude Code event means that. `SessionEnd` is the near miss, and a\n * session is not a run.\n */\nexport const CLAUDE_CODE_EVENT_MAP: Readonly<Record<string, HookEvent>> = {\n PreToolUse: \"preToolUse\",\n PostToolUse: \"postToolUse\",\n UserPromptSubmit: \"preRun\",\n Stop: \"stop\",\n};\n\nexport interface HookCommand {\n command: string;\n matcher?: string;\n timeoutMs?: number;\n /**\n * #637 — the event key as written in the config file (`PreToolUse`), carried so the approval\n * gate can report the vocabulary the consumer's stored fingerprint was taken against.\n *\n * REQUIRED, not optional: `parseClaudeCodeCommand` is the only producer of a `HookCommand` in\n * this package, so every command has one. An optional field would hand every reader a fallback\n * branch for a case that cannot occur — and if an in-memory producer is added later, required is\n * what forces it to supply a value instead of inheriting a silent `undefined`.\n */\n sourceEvent: string;\n /**\n * The config file this command was declared in.\n *\n * Carried so the executor can supply the runtime contract the declaring DIALECT presumes — a\n * command from `.claude/settings.json` is written against Claude Code's runtime and expects\n * `$CLAUDE_PROJECT_DIR` to exist (#522). Absent for a command built in memory, which is native by\n * construction.\n */\n sourcePath?: string;\n}\n\nexport interface HookConfig {\n hooks?: Partial<Record<HookEvent, HookCommand[]>>;\n}\n\nconst warned = new Set<string>();\n\n/**\n * Emit a stderr warn once per process per unique key. Helps surface the\n * deprecation path without spamming when the loader is called many times\n * during a session (cron + send + skills all hit this).\n *\n * Note: spawned workers (cron, subagent) start fresh processes — warn\n * re-emits there, by design (1 per process boot, not per call).\n *\n * @internal\n */\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n diag(`${message}\\n`);\n}\n\n/**\n * A warn-once that is NOT dropped when the host installed no diagnostics sink.\n *\n * `diag` is silent by default and that is right for chatter — a library must not assume the host's\n * stderr is a free-form log, because in a TUI it is the render surface. A configuration the operator\n * WROTE and this runtime will not honour is not chatter. `diagFailure`'s own docblock records the\n * precedent, `theokit-sdk#189`: an MCP server failed to start, the only report went to `diag()`, the\n * embedding UI never read it, and \"the user saw an agent with missing tools and no reason given\".\n *\n * A dropped hook is that shape with a sharper edge, because the missing thing is a guard: the\n * operator declared a refusal, it silently does not exist, and nothing distinguishes that from a\n * refusal that ran and approved.\n *\n * The asymmetry that decides it is quoted from the same place: a corrupted frame is visible and\n * recoverable, while a silently dropped failure is neither.\n *\n * @internal\n */\nexport function warnFailureOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n diagFailure(`${message}\\n`);\n}\n\n/** Reset for tests; not exported via barrel. @internal */\nexport function _resetWarnOnceForTests(): void {\n warned.clear();\n}\n\n/**\n * Load hooks from `.theokit/hooks.json` (Claude-Code-shaped — the only supported\n * form). A stray legacy `.theokit/hooks/*.md` markdown dir (no `hooks.json`) is\n * NOT loaded — it emits a one-time migration warn and yields no hooks.\n *\n * @internal\n */\nexport async function loadHookConfig(\n cwd: string,\n compatSources: readonly CompatSourceDeclaration[] = [],\n): Promise<HookConfig> {\n const merged: HookConfig = {};\n let sawAny = false;\n for (const path of hookConfigCandidates(cwd, compatSources)) {\n if (!existsSync(path)) continue;\n sawAny = true;\n // Stamped at merge, where the file is still known. One line later the commands are pooled per\n // event and every trace of which dialect declared them is gone — which is how a Claude Code\n // command came to be run without Claude Code's runtime (#522).\n mergeInto(merged, stampSource(await readHookFile(path), path));\n }\n if (!sawAny && existsSync(join(theokitConfigRoot(cwd), \"hooks\"))) {\n warnOnce(\n \"hooks-md-unsupported\",\n \"[theokit-sdk] .theokit/hooks/*.md hooks are no longer supported (ADR 0016) — migrate to a Claude-Code-shaped .theokit/hooks.json\",\n );\n }\n return merged;\n}\n\n/**\n * Every file that may declare hooks, in precedence order.\n *\n * `hooks.json` under each project config root, then the Claude Code CLI's own settings files — which\n * is where the CLI actually keeps hooks, so a repository set up for it presents its hooks here\n * without being converted. `settings.local.json` is the CLI's personal-override file and sits beside\n * the shared one rather than replacing it.\n *\n * The shape never needed translating: `parseClaudeCodeConfig` reads the `hooks` key off whatever\n * object it is given, and a settings file is that same object with other keys alongside.\n */\nfunction hookConfigCandidates(\n cwd: string,\n compatSources: readonly CompatSourceDeclaration[],\n): string[] {\n const roots = projectConfigRoots(cwd, compatSources, \"hooks\");\n return [\n ...roots.map((root) => join(root, \"hooks.json\")),\n ...roots.map((root) => join(root, \"settings.json\")),\n ...roots.map((root) => join(root, \"settings.local.json\")),\n ];\n}\n\n/**\n * Record which file each command came from.\n *\n * A command already carrying a `sourcePath` keeps it: nothing produces that today, and a nested\n * config that declared its own origin would be describing something this function cannot see.\n */\nfunction stampSource(config: HookConfig, sourcePath: string): HookConfig {\n if (config.hooks === undefined) return config;\n const hooks: NonNullable<HookConfig[\"hooks\"]> = {};\n for (const [event, commands] of Object.entries(config.hooks) as [\n HookEvent,\n HookCommand[] | undefined,\n ][]) {\n if (commands === undefined) continue;\n hooks[event] = commands.map((c) => ({ sourcePath, ...c }));\n }\n return { hooks };\n}\n\n/**\n * Append one source's commands onto the accumulator, per event.\n *\n * MERGED, not first-wins, and the distinction is deliberate. An agent or a skill is a NAMED\n * declaration: two files claiming one name collide, and the explicit namespace should win. Hooks are\n * unnamed lists — two files declaring `PreToolUse` are two sets of commands an operator wrote, and\n * keeping only one drops the other in silence, which is the failure class this package guards\n * against everywhere else.\n */\nfunction mergeInto(target: HookConfig, source: HookConfig): void {\n for (const [event, commands] of Object.entries(source.hooks ?? {}) as [\n HookEvent,\n HookCommand[] | undefined,\n ][]) {\n if (commands === undefined || commands.length === 0) continue;\n target.hooks ??= {};\n target.hooks[event] = [...(target.hooks[event] ?? []), ...commands];\n }\n}\n\nasync function readHookFile(jsonPath: string): Promise<HookConfig> {\n let raw: string;\n try {\n raw = await readFile(jsonPath, \"utf8\");\n } catch (cause) {\n throw new ConfigurationError(`Failed to read hooks config: ${jsonPath}`, {\n code: \"hooks_read_error\",\n cause,\n });\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n throw new ConfigurationError(`Invalid JSON in hooks config: ${jsonPath}`, {\n code: \"hooks_json_invalid\",\n cause,\n });\n }\n return parseClaudeCodeConfig(parsed, jsonPath);\n}\n\n/**\n * Narrow an unknown to a record, or throw a typed config error.\n *\n * `hint` names the shape that WOULD be accepted, and exists because the message without it names\n * only the validator's expectation. Measured on a consumer in 2026-09: a flat `hooks` array in a\n * `.theokit/settings.json` made this throw on every turn, and `expected an object at \"hooks\"` gave\n * the operator nothing to act on — the file parses fine for the product that wrote it, and it is\n * this independent read of the same path that fails. An error on a refusal path should carry the\n * fix, not the diagnosis.\n */\nfunction asRecord(\n value: unknown,\n path: string,\n where: string,\n hint?: string,\n): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigurationError(\n `hooks: expected an object at ${where} in ${path}${hint === undefined ? \"\" : ` — ${hint}`}`,\n { code: \"hooks_json_invalid\" },\n );\n }\n return value as Record<string, unknown>;\n}\n\n/**\n * The shape this loader accepts, quoted back on the one refusal an operator is most likely to hit:\n * `hooks` keyed by event, each event an array of matcher groups.\n */\nconst HOOKS_SHAPE_HINT =\n 'hooks are keyed by event, e.g. { \"hooks\": { \"PreToolUse\": [ { \"hooks\": ' +\n '[ { \"type\": \"command\", \"command\": \"…\" } ] } ] } }';\n\n/** Narrow an unknown to an array, or throw a typed config error. */\nfunction asArray(value: unknown, path: string, where: string): unknown[] {\n if (!Array.isArray(value)) {\n throw new ConfigurationError(`hooks: expected an array at ${where} in ${path}`, {\n code: \"hooks_json_invalid\",\n });\n }\n return value;\n}\n\n/**\n * Parse Claude Code's nested hooks config into the SDK's flat internal shape:\n * `{ hooks: { PreToolUse: [{ matcher?, hooks: [{ type:\"command\", command, timeout? }] }] } }`\n * → `{ hooks: { preToolUse: [{ command, matcher?, timeoutMs? }] } }`. Each group's\n * `matcher` applies to every command it wraps; `timeout` (seconds) → `timeoutMs`.\n */\nfunction parseClaudeCodeConfig(raw: unknown, path: string): HookConfig {\n const root = asRecord(raw, path, \"the root\");\n if (root.hooks === undefined) return {};\n const hooksRec = asRecord(root.hooks, path, `\"hooks\"`, HOOKS_SHAPE_HINT);\n const grouped: Partial<Record<HookEvent, HookCommand[]>> = {};\n\n for (const [ccEvent, groups] of Object.entries(hooksRec)) {\n const event = CLAUDE_CODE_EVENT_MAP[ccEvent];\n if (event === undefined) {\n // The operator wrote this event and it will not fire. Reported through the channel that\n // survives an absent sink — see `warnFailureOnce`.\n warnFailureOnce(\n `hooks-event-${ccEvent}`,\n `[theokit-sdk] hooks: event \"${ccEvent}\" is not fired by the SDK runtime (supported: ${Object.keys(CLAUDE_CODE_EVENT_MAP).join(\", \")}) — skipping`,\n );\n continue;\n }\n grouped[event] = [...(grouped[event] ?? []), ...flattenEventGroups(groups, path, ccEvent)];\n }\n return { hooks: grouped };\n}\n\n/** Flatten one Claude Code event's matcher-groups into internal HookCommands. */\nfunction flattenEventGroups(groups: unknown, path: string, ccEvent: string): HookCommand[] {\n const commands: HookCommand[] = [];\n for (const rawGroup of asArray(groups, path, `hooks.${ccEvent}`)) {\n const group = asRecord(rawGroup, path, `hooks.${ccEvent}[]`);\n const matcher = group.matcher === undefined ? undefined : String(group.matcher);\n for (const rawCmd of asArray(group.hooks, path, `hooks.${ccEvent}[].hooks`)) {\n commands.push(parseClaudeCodeCommand(rawCmd, matcher, path, ccEvent));\n }\n }\n return commands;\n}\n\n/**\n * Fields a Claude Code hook entry may declare that this runtime does not implement.\n *\n * Listed rather than lumped into \"unknown\" because the two are different facts to the operator\n * reading the error: a typo is theirs to fix, and a field written for another runtime is a tree\n * that was never going to work here. The same split is made for subagent frontmatter, for the same\n * reason — an operator migrating a `.claude/` tree learned one key per round trip otherwise.\n *\n * `if` is the one that made refusal the right answer rather than a warning. Dropped, it fails OPEN:\n * a deny hook narrowed to one dangerous command shape silently becomes a deny hook over every call\n * of that tool. Every other field in this set loses a convenience; this one inverts the intent.\n */\nconst UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS = new Set([\n \"if\",\n \"args\",\n \"statusMessage\",\n \"once\",\n \"async\",\n \"asyncRewake\",\n \"shell\",\n]);\n\n/** What `parseClaudeCodeCommand` reads. Anything else is refused. */\nconst ACCEPTED_HOOK_FIELDS = new Set([\"type\", \"command\", \"timeout\"]);\n\n/**\n * Refuse a hook entry that declares a field this parser does not read.\n *\n * The parser used to take `type`, `command` and `timeout` and discard the rest in silence, while\n * `packages/agents` — reading the same file one layer up — already refused an unknown key loudly\n * through a `.strict()` schema. Two layers disagreeing about whether a field is an error is bad on\n * its own; the permissive one being the layer that actually runs the hook is the defect.\n */\nfunction rejectUnreadHookFields(cmd: Record<string, unknown>, path: string, ccEvent: string): void {\n for (const key of Object.keys(cmd)) {\n if (ACCEPTED_HOOK_FIELDS.has(key)) continue;\n const origin = UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS.has(key)\n ? ` — \"${key}\" is a Claude Code hook field that this runtime does not implement. The same ` +\n `applies to: ${[...UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS].filter((f) => f !== key).join(\", \")}`\n : \"\";\n throw new ConfigurationError(\n `hooks.${ccEvent}: unsupported field \"${key}\" (accepted: ${[...ACCEPTED_HOOK_FIELDS].join(\", \")}) in ${path}${origin}`,\n { code: \"hooks_unsupported_field\" },\n );\n }\n}\n\n/** One `{ type:\"command\", command, timeout? }` entry → an internal HookCommand. */\nfunction parseClaudeCodeCommand(\n raw: unknown,\n matcher: string | undefined,\n path: string,\n ccEvent: string,\n): HookCommand {\n const cmd = asRecord(raw, path, `hooks.${ccEvent}[].hooks[]`);\n if (cmd.type !== \"command\") {\n throw new ConfigurationError(\n `hooks: only { \"type\": \"command\" } is supported (got ${JSON.stringify(cmd.type)}) in ${path}`,\n { code: \"hooks_unsupported_type\" },\n );\n }\n if (typeof cmd.command !== \"string\" || cmd.command.length === 0) {\n throw new ConfigurationError(`hooks: \"command\" must be a non-empty string in ${path}`, {\n code: \"hooks_invalid_command\",\n });\n }\n // After the type/command checks, so a `{ type: \"http\", url }` entry still fails for its own\n // reason rather than for its `url`.\n rejectUnreadHookFields(cmd, path, ccEvent);\n const hc: HookCommand = { command: cmd.command, sourceEvent: ccEvent };\n if (matcher !== undefined) hc.matcher = matcher;\n if (typeof cmd.timeout === \"number\" && cmd.timeout > 0) {\n hc.timeoutMs = Math.round(cmd.timeout * 1000);\n }\n return hc;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal/runtime/hooks/hooks-source.ts"],"names":["diag","diagFailure","existsSync","join","theokitConfigRoot","projectConfigRoots","readFile","ConfigurationError"],"mappings":";;;;;;;;;AA8DO,IAAM,qBAAA,GAA6D;AAAA,EACxE,UAAA,EAAY,YAAA;AAAA,EACZ,WAAA,EAAa,aAAA;AAAA,EACb,gBAAA,EAAkB,QAAA;AAAA,EAClB,IAAA,EAAM;AACR,CAAA;AA+BA,IAAM,MAAA,uBAAa,GAAA,EAAY;AAYxB,SAAS,QAAA,CAAS,KAAa,OAAA,EAAuB;AAC3D,EAAA,IAAI,MAAA,CAAO,GAAA,CAAI,GAAG,CAAA,EAAG;AACrB,EAAA,MAAA,CAAO,IAAI,G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verses\n * D74/D77 for hooks: JSON is canonical again, in the Claude Code shape).\n *\n * `.theokit/hooks.json` (Claude-Code-shaped JSON) is the only supported form.\n * A stray legacy `.theokit/hooks/*.md` dir (no hooks.json) is NOT loaded — it\n * warns to migrate and yields no hooks. Absent both → empty config.\n *\n * Consumed by `hooks-executor.ts` (runtime dispatch).\n *\n * Config SHAPE is Claude Code's `settings.json` hooks:\n * { \"hooks\": { \"PreToolUse\": [ { \"matcher\": \"shell\",\n * \"hooks\": [ { \"type\": \"command\", \"command\": \"…\", \"timeout\": 30 } ] } ] } }\n *\n * The shape, not the event COVERAGE. Four of the thirty-three documented events are fired by this\n * runtime — see {@link CLAUDE_CODE_EVENT_MAP} for which, why the rest are refused rather than\n * mapped, and the order in which they should be added. An event outside the set is reported to the\n * operator rather than skipped in silence.\n *\n * @internal\n */\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { ConfigurationError } from \"../../../errors.js\";\nimport { diag, diagFailure } from \"../../diagnostics.js\";\nimport { projectConfigRoots, theokitConfigRoot } from \"../../persistence/paths.js\";\nimport type { CompatSourceDeclaration } from \"../compat/foreign-config-sources.js\";\n\n/** The five lifecycle events the SDK runtime actually fires. */\nexport type HookEvent = \"preRun\" | \"postRun\" | \"preToolUse\" | \"postToolUse\" | \"stop\";\n\n/**\n * The Claude Code event names this runtime actually FIRES, and the internal event each becomes.\n *\n * Exported so the supported set is stated rather than implied. It used to be private, and the\n * docblock above claimed a shape \"identical to Claude Code's `settings.json` hooks\" while accepting\n * four of the thirty-three documented events — a claim nothing could contradict.\n *\n * A Claude Code event with no firing point here — `SessionStart`, `SubagentStop`, `PreCompact`,\n * `Notification`, `SessionEnd` among them — is skipped with a report rather than silently accepted,\n * because it would never run.\n *\n * ## Why this map is not simply grown\n *\n * Mapping a name the runtime does not fire is strictly WORSE than refusing it. An operator declaring\n * `PreCompact` today gets a report saying it will not fire; with the name mapped they would get\n * silence and a guard that never runs — a declared veto that does not exist. The map grows when the\n * seam exists, one event at a time.\n *\n * ## Priority, when it does grow\n *\n * The blocking events first. An unwired veto loses a CAPABILITY; an unwired observer loses a\n * SIGNAL. Thirteen of the sixteen the spec marks \"Can block? Yes\" are unwired, and\n * `tests/internal/runtime/hooks/the-supported-event-set-is-stated.test.ts` lists them in the order\n * they should be taken, so the next person does not re-derive which is which.\n *\n * `postRun` is reachable through this SDK's own config and has no entry here on purpose: it fires\n * per RUN, and no documented Claude Code event means that. `SessionEnd` is the near miss, and a\n * session is not a run.\n */\nexport const CLAUDE_CODE_EVENT_MAP: Readonly<Record<string, HookEvent>> = {\n PreToolUse: \"preToolUse\",\n PostToolUse: \"postToolUse\",\n UserPromptSubmit: \"preRun\",\n Stop: \"stop\",\n};\n\nexport interface HookCommand {\n command: string;\n matcher?: string;\n timeoutMs?: number;\n /**\n * #637 — the event key as written in the config file (`PreToolUse`), carried so the approval\n * gate can report the vocabulary the consumer's stored fingerprint was taken against.\n *\n * REQUIRED, not optional: `parseClaudeCodeCommand` is the only producer of a `HookCommand` in\n * this package, so every command has one. An optional field would hand every reader a fallback\n * branch for a case that cannot occur — and if an in-memory producer is added later, required is\n * what forces it to supply a value instead of inheriting a silent `undefined`.\n */\n sourceEvent: string;\n /**\n * The config file this command was declared in.\n *\n * Carried so the executor can supply the runtime contract the declaring DIALECT presumes — a\n * command from `.claude/settings.json` is written against Claude Code's runtime and expects\n * `$CLAUDE_PROJECT_DIR` to exist (#522). Absent for a command built in memory, which is native by\n * construction.\n */\n sourcePath?: string;\n}\n\nexport interface HookConfig {\n hooks?: Partial<Record<HookEvent, HookCommand[]>>;\n}\n\nconst warned = new Set<string>();\n\n/**\n * Emit a stderr warn once per process per unique key. Helps surface the\n * deprecation path without spamming when the loader is called many times\n * during a session (cron + send + skills all hit this).\n *\n * Note: spawned workers (cron, subagent) start fresh processes — warn\n * re-emits there, by design (1 per process boot, not per call).\n *\n * @internal\n */\nexport function warnOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n diag(`${message}\\n`);\n}\n\n/**\n * A warn-once that is NOT dropped when the host installed no diagnostics sink.\n *\n * `diag` is silent by default and that is right for chatter — a library must not assume the host's\n * stderr is a free-form log, because in a TUI it is the render surface. A configuration the operator\n * WROTE and this runtime will not honour is not chatter. `diagFailure`'s own docblock records the\n * precedent, `theokit-sdk#189`: an MCP server failed to start, the only report went to `diag()`, the\n * embedding UI never read it, and \"the user saw an agent with missing tools and no reason given\".\n *\n * A dropped hook is that shape with a sharper edge, because the missing thing is a guard: the\n * operator declared a refusal, it silently does not exist, and nothing distinguishes that from a\n * refusal that ran and approved.\n *\n * The asymmetry that decides it is quoted from the same place: a corrupted frame is visible and\n * recoverable, while a silently dropped failure is neither.\n *\n * @internal\n */\nexport function warnFailureOnce(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n diagFailure(`${message}\\n`);\n}\n\n/** Reset for tests; not exported via barrel. @internal */\nexport function _resetWarnOnceForTests(): void {\n warned.clear();\n}\n\n/**\n * Load hooks from `.theokit/hooks.json` (Claude-Code-shaped — the only supported\n * form). A stray legacy `.theokit/hooks/*.md` markdown dir (no `hooks.json`) is\n * NOT loaded — it emits a one-time migration warn and yields no hooks.\n *\n * @internal\n */\nexport async function loadHookConfig(\n cwd: string,\n compatSources: readonly CompatSourceDeclaration[] = [],\n): Promise<HookConfig> {\n const merged: HookConfig = {};\n let sawAny = false;\n for (const path of hookConfigCandidates(cwd, compatSources)) {\n if (!existsSync(path)) continue;\n sawAny = true;\n // Stamped at merge, where the file is still known. One line later the commands are pooled per\n // event and every trace of which dialect declared them is gone — which is how a Claude Code\n // command came to be run without Claude Code's runtime (#522).\n mergeInto(merged, stampSource(await readHookFile(path), path));\n }\n if (!sawAny && existsSync(join(theokitConfigRoot(cwd), \"hooks\"))) {\n warnOnce(\n \"hooks-md-unsupported\",\n \"[theokit-sdk] .theokit/hooks/*.md hooks are no longer supported (ADR 0016) — migrate to a Claude-Code-shaped .theokit/hooks.json\",\n );\n }\n return merged;\n}\n\n/**\n * Every file that may declare hooks, in precedence order.\n *\n * `hooks.json` under each project config root, then the Claude Code CLI's own settings files — which\n * is where the CLI actually keeps hooks, so a repository set up for it presents its hooks here\n * without being converted. `settings.local.json` is the CLI's personal-override file and sits beside\n * the shared one rather than replacing it.\n *\n * The shape never needed translating: `parseClaudeCodeConfig` reads the `hooks` key off whatever\n * object it is given, and a settings file is that same object with other keys alongside.\n */\nfunction hookConfigCandidates(\n cwd: string,\n compatSources: readonly CompatSourceDeclaration[],\n): string[] {\n const roots = projectConfigRoots(cwd, compatSources, \"hooks\");\n return [\n ...roots.map((root) => join(root, \"hooks.json\")),\n ...roots.map((root) => join(root, \"settings.json\")),\n ...roots.map((root) => join(root, \"settings.local.json\")),\n ];\n}\n\n/**\n * Record which file each command came from.\n *\n * A command already carrying a `sourcePath` keeps it: nothing produces that today, and a nested\n * config that declared its own origin would be describing something this function cannot see.\n */\nfunction stampSource(config: HookConfig, sourcePath: string): HookConfig {\n if (config.hooks === undefined) return config;\n const hooks: NonNullable<HookConfig[\"hooks\"]> = {};\n for (const [event, commands] of Object.entries(config.hooks) as [\n HookEvent,\n HookCommand[] | undefined,\n ][]) {\n if (commands === undefined) continue;\n hooks[event] = commands.map((c) => ({ sourcePath, ...c }));\n }\n return { hooks };\n}\n\n/**\n * Append one source's commands onto the accumulator, per event.\n *\n * MERGED, not first-wins, and the distinction is deliberate. An agent or a skill is a NAMED\n * declaration: two files claiming one name collide, and the explicit namespace should win. Hooks are\n * unnamed lists — two files declaring `PreToolUse` are two sets of commands an operator wrote, and\n * keeping only one drops the other in silence, which is the failure class this package guards\n * against everywhere else.\n */\nfunction mergeInto(target: HookConfig, source: HookConfig): void {\n for (const [event, commands] of Object.entries(source.hooks ?? {}) as [\n HookEvent,\n HookCommand[] | undefined,\n ][]) {\n if (commands === undefined || commands.length === 0) continue;\n target.hooks ??= {};\n target.hooks[event] = [...(target.hooks[event] ?? []), ...commands];\n }\n}\n\nasync function readHookFile(jsonPath: string): Promise<HookConfig> {\n let raw: string;\n try {\n raw = await readFile(jsonPath, \"utf8\");\n } catch (cause) {\n throw new ConfigurationError(`Failed to read hooks config: ${jsonPath}`, {\n code: \"hooks_read_error\",\n cause,\n });\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (cause) {\n throw new ConfigurationError(`Invalid JSON in hooks config: ${jsonPath}`, {\n code: \"hooks_json_invalid\",\n cause,\n });\n }\n return parseClaudeCodeConfig(parsed, jsonPath);\n}\n\n/**\n * Narrow an unknown to a record, or throw a typed config error.\n *\n * `hint` names the shape that WOULD be accepted, and exists because the message without it names\n * only the validator's expectation. Measured on a consumer in 2026-09: a flat `hooks` array in a\n * `.theokit/settings.json` made this throw on every turn, and `expected an object at \"hooks\"` gave\n * the operator nothing to act on — the file parses fine for the product that wrote it, and it is\n * this independent read of the same path that fails. An error on a refusal path should carry the\n * fix, not the diagnosis.\n */\nfunction asRecord(\n value: unknown,\n path: string,\n where: string,\n hint?: string,\n): Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new ConfigurationError(\n `hooks: expected an object at ${where} in ${path}${hint === undefined ? \"\" : ` — ${hint}`}`,\n { code: \"hooks_json_invalid\" },\n );\n }\n return value as Record<string, unknown>;\n}\n\n/**\n * The shape this loader accepts, quoted back on the one refusal an operator is most likely to hit:\n * `hooks` keyed by event, each event an array of matcher groups.\n */\nconst HOOKS_SHAPE_HINT =\n 'hooks are keyed by event, e.g. { \"hooks\": { \"PreToolUse\": [ { \"hooks\": ' +\n '[ { \"type\": \"command\", \"command\": \"…\" } ] } ] } }';\n\n/** Narrow an unknown to an array, or throw a typed config error. */\nfunction asArray(value: unknown, path: string, where: string): unknown[] {\n if (!Array.isArray(value)) {\n throw new ConfigurationError(`hooks: expected an array at ${where} in ${path}`, {\n code: \"hooks_json_invalid\",\n });\n }\n return value;\n}\n\n/**\n * Parse Claude Code's nested hooks config into the SDK's flat internal shape:\n * `{ hooks: { PreToolUse: [{ matcher?, hooks: [{ type:\"command\", command, timeout? }] }] } }`\n * → `{ hooks: { preToolUse: [{ command, matcher?, timeoutMs? }] } }`. Each group's\n * `matcher` applies to every command it wraps; `timeout` (seconds) → `timeoutMs`.\n */\nfunction parseClaudeCodeConfig(raw: unknown, path: string): HookConfig {\n const root = asRecord(raw, path, \"the root\");\n if (root.hooks === undefined) return {};\n const hooksRec = asRecord(root.hooks, path, `\"hooks\"`, HOOKS_SHAPE_HINT);\n const grouped: Partial<Record<HookEvent, HookCommand[]>> = {};\n\n for (const [ccEvent, groups] of Object.entries(hooksRec)) {\n const event = CLAUDE_CODE_EVENT_MAP[ccEvent];\n if (event === undefined) {\n // The operator wrote this event and it will not fire. Reported through the channel that\n // survives an absent sink — see `warnFailureOnce`.\n warnFailureOnce(\n `hooks-event-${ccEvent}`,\n `[theokit-sdk] hooks: event \"${ccEvent}\" is not fired by the SDK runtime (supported: ${Object.keys(CLAUDE_CODE_EVENT_MAP).join(\", \")}) — skipping`,\n );\n continue;\n }\n grouped[event] = [...(grouped[event] ?? []), ...flattenEventGroups(groups, path, ccEvent)];\n }\n return { hooks: grouped };\n}\n\n/** Flatten one Claude Code event's matcher-groups into internal HookCommands. */\nfunction flattenEventGroups(groups: unknown, path: string, ccEvent: string): HookCommand[] {\n const commands: HookCommand[] = [];\n for (const rawGroup of asArray(groups, path, `hooks.${ccEvent}`)) {\n const group = asRecord(rawGroup, path, `hooks.${ccEvent}[]`);\n const matcher = group.matcher === undefined ? undefined : String(group.matcher);\n for (const rawCmd of asArray(group.hooks, path, `hooks.${ccEvent}[].hooks`)) {\n commands.push(parseClaudeCodeCommand(rawCmd, matcher, path, ccEvent));\n }\n }\n return commands;\n}\n\n/**\n * Fields a Claude Code hook entry may declare that this runtime does not implement.\n *\n * Listed rather than lumped into \"unknown\" because the two are different facts to the operator\n * reading the error: a typo is theirs to fix, and a field written for another runtime is a tree\n * that was never going to work here. The same split is made for subagent frontmatter, for the same\n * reason — an operator migrating a `.claude/` tree learned one key per round trip otherwise.\n *\n * `if` is the one that made refusal the right answer rather than a warning. Dropped, it fails OPEN:\n * a deny hook narrowed to one dangerous command shape silently becomes a deny hook over every call\n * of that tool. Every other field in this set loses a convenience; this one inverts the intent.\n */\nconst UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS = new Set([\n \"if\",\n \"args\",\n \"statusMessage\",\n \"once\",\n \"async\",\n \"asyncRewake\",\n \"shell\",\n]);\n\n/** What `parseClaudeCodeCommand` reads. Anything else is refused. */\nconst ACCEPTED_HOOK_FIELDS = new Set([\"type\", \"command\", \"timeout\"]);\n\n/**\n * Refuse a hook entry that declares a field this parser does not read.\n *\n * The parser used to take `type`, `command` and `timeout` and discard the rest in silence, while\n * `packages/agents` — reading the same file one layer up — already refused an unknown key loudly\n * through a `.strict()` schema. Two layers disagreeing about whether a field is an error is bad on\n * its own; the permissive one being the layer that actually runs the hook is the defect.\n */\nfunction rejectUnreadHookFields(cmd: Record<string, unknown>, path: string, ccEvent: string): void {\n for (const key of Object.keys(cmd)) {\n if (ACCEPTED_HOOK_FIELDS.has(key)) continue;\n const origin = UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS.has(key)\n ? ` — \"${key}\" is a Claude Code hook field that this runtime does not implement. The same ` +\n `applies to: ${[...UNIMPLEMENTED_CLAUDE_CODE_HOOK_FIELDS].filter((f) => f !== key).join(\", \")}`\n : \"\";\n throw new ConfigurationError(\n `hooks.${ccEvent}: unsupported field \"${key}\" (accepted: ${[...ACCEPTED_HOOK_FIELDS].join(\", \")}) in ${path}${origin}`,\n { code: \"hooks_unsupported_field\" },\n );\n }\n}\n\n/** One `{ type:\"command\", command, timeout? }` entry → an internal HookCommand. */\nfunction parseClaudeCodeCommand(\n raw: unknown,\n matcher: string | undefined,\n path: string,\n ccEvent: string,\n): HookCommand {\n const cmd = asRecord(raw, path, `hooks.${ccEvent}[].hooks[]`);\n if (cmd.type !== \"command\") {\n throw new ConfigurationError(\n `hooks: only { \"type\": \"command\" } is supported (got ${JSON.stringify(cmd.type)}) in ${path}`,\n { code: \"hooks_unsupported_type\" },\n );\n }\n if (typeof cmd.command !== \"string\" || cmd.command.length === 0) {\n throw new ConfigurationError(`hooks: \"command\" must be a non-empty string in ${path}`, {\n code: \"hooks_invalid_command\",\n });\n }\n // After the type/command checks, so a `{ type: \"http\", url }` entry still fails for its own\n // reason rather than for its `url`.\n rejectUnreadHookFields(cmd, path, ccEvent);\n const hc: HookCommand = { command: cmd.command, sourceEvent: ccEvent };\n if (matcher !== undefined) hc.matcher = matcher;\n if (typeof cmd.timeout === \"number\" && cmd.timeout > 0) {\n hc.timeoutMs = Math.round(cmd.timeout * 1000);\n }\n return hc;\n}\n"]}
|
package/dist/context-SXR2HLHT.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { currentPersonalityContext, warnPersonalitySwitchInsideFork, withPersonalityContext } from './chunk-PQCTDMUI.js';
|
|
2
|
-
import './chunk-7GDHFV2M.js';
|
|
3
|
-
import './chunk-X7EUUHXU.js';
|
|
4
|
-
import './chunk-B5MHRQJZ.js';
|
|
5
|
-
import './chunk-CZJ6Q7CW.js';
|
|
6
|
-
//# sourceMappingURL=context-SXR2HLHT.js.map
|
|
7
|
-
//# sourceMappingURL=context-SXR2HLHT.js.map
|