@theokit/sdk 4.63.3 → 4.63.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/{agent-3JK7VXNN.js → agent-A5XMIVNP.js} +6 -6
  3. package/dist/{agent-3JK7VXNN.js.map → agent-A5XMIVNP.js.map} +1 -1
  4. package/dist/{agent-PVINJTUR.cjs → agent-UX7WFI6B.cjs} +7 -7
  5. package/dist/{agent-PVINJTUR.cjs.map → agent-UX7WFI6B.cjs.map} +1 -1
  6. package/dist/chunk-247ZTLNU.js +73 -0
  7. package/dist/chunk-247ZTLNU.js.map +1 -0
  8. package/dist/{chunk-GPKAF7SG.js → chunk-32WTYBUH.js} +3 -3
  9. package/dist/{chunk-GPKAF7SG.js.map → chunk-32WTYBUH.js.map} +1 -1
  10. package/dist/{chunk-CQBXOJ6U.cjs → chunk-43ZQRWAP.cjs} +5 -5
  11. package/dist/{chunk-CQBXOJ6U.cjs.map → chunk-43ZQRWAP.cjs.map} +1 -1
  12. package/dist/{chunk-JJ3OVRUM.cjs → chunk-7VT4P3Z4.cjs} +136 -35
  13. package/dist/chunk-7VT4P3Z4.cjs.map +1 -0
  14. package/dist/chunk-AKJP2STZ.cjs +81 -0
  15. package/dist/chunk-AKJP2STZ.cjs.map +1 -0
  16. package/dist/{chunk-ZWRG4NWT.cjs → chunk-GMLBYDW4.cjs} +4 -4
  17. package/dist/{chunk-ZWRG4NWT.cjs.map → chunk-GMLBYDW4.cjs.map} +1 -1
  18. package/dist/{chunk-LXI4XZEC.js → chunk-LKBEROHN.js} +3 -3
  19. package/dist/{chunk-LXI4XZEC.js.map → chunk-LKBEROHN.js.map} +1 -1
  20. package/dist/{chunk-25BD2R5G.js → chunk-LYTOXSRH.js} +113 -12
  21. package/dist/chunk-LYTOXSRH.js.map +1 -0
  22. package/dist/{chunk-K5OJUYSZ.js → chunk-NDGGJQTZ.js} +13 -4
  23. package/dist/chunk-NDGGJQTZ.js.map +1 -0
  24. package/dist/{chunk-ZCIRZE37.cjs → chunk-VCLBZAZU.cjs} +14 -5
  25. package/dist/chunk-VCLBZAZU.cjs.map +1 -0
  26. package/dist/{context-AGQ3DIZU.cjs → context-WFLTTMK3.cjs} +7 -7
  27. package/dist/{context-AGQ3DIZU.cjs.map → context-WFLTTMK3.cjs.map} +1 -1
  28. package/dist/context-WI2DFG7V.js +7 -0
  29. package/dist/{context-GQRFBCLP.js.map → context-WI2DFG7V.js.map} +1 -1
  30. package/dist/cron.cjs +6 -6
  31. package/dist/cron.js +5 -5
  32. package/dist/eval.cjs +5 -5
  33. package/dist/eval.js +4 -4
  34. package/dist/index.cjs +20 -20
  35. package/dist/index.js +7 -7
  36. package/dist/internal/agent-loop/replay-messages.d.ts +41 -0
  37. package/dist/internal/local-agent/local-option-keys.d.ts +2 -0
  38. package/dist/internal/persistence/index.cjs +4 -4
  39. package/dist/internal/persistence/index.js +1 -1
  40. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +92 -0
  41. package/dist/internal/runtime/hooks/hooks-executor.d.ts +9 -0
  42. package/dist/internal/runtime/hooks/hooks-source.d.ts +9 -0
  43. package/dist/subagents-loader-UCNO7FUH.cjs +17 -0
  44. package/dist/{subagents-loader-YEUFFPAL.cjs.map → subagents-loader-UCNO7FUH.cjs.map} +1 -1
  45. package/dist/subagents-loader-XP5ERVDZ.js +8 -0
  46. package/dist/{subagents-loader-CRT5LLL3.js.map → subagents-loader-XP5ERVDZ.js.map} +1 -1
  47. package/dist/subagents-loader.cjs +3 -3
  48. package/dist/subagents-loader.js +2 -2
  49. package/docs/error-codes.md +5 -5
  50. package/package.json +1 -1
  51. package/dist/chunk-25BD2R5G.js.map +0 -1
  52. package/dist/chunk-AQO3NSRG.cjs +0 -41
  53. package/dist/chunk-AQO3NSRG.cjs.map +0 -1
  54. package/dist/chunk-JJ3OVRUM.cjs.map +0 -1
  55. package/dist/chunk-K5OJUYSZ.js.map +0 -1
  56. package/dist/chunk-UFLD2HEV.js +0 -35
  57. package/dist/chunk-UFLD2HEV.js.map +0 -1
  58. package/dist/chunk-ZCIRZE37.cjs.map +0 -1
  59. package/dist/context-GQRFBCLP.js +0 -7
  60. package/dist/subagents-loader-CRT5LLL3.js +0 -8
  61. package/dist/subagents-loader-YEUFFPAL.cjs +0 -17
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The foreign configuration dialects this SDK can read, and what each one PRESUMES.
3
+ *
4
+ * ## Why a registry and not a list of directory names
5
+ *
6
+ * `projectConfigRoots` returned `[".theokit", ".claude"]` — two paths — and that shape is what
7
+ * usetheokit/theokit-sdk#522 fell through. A path says WHERE a file lives. It does not say how the
8
+ * file is parsed, and it does not say what runtime the commands inside it were written against.
9
+ *
10
+ * Claude Code defines `$CLAUDE_PROJECT_DIR` for the hook commands in its `settings.json`, and its
11
+ * documentation tells authors to reach project files through it — an absolute path would break for
12
+ * every other person on the team, so the shape that failed here is the shape upstream recommends.
13
+ * This SDK read the file and ran the command without the variable. `sh` expands an unset variable to
14
+ * the empty string, so
15
+ *
16
+ * bash "$CLAUDE_PROJECT_DIR/.claude/hooks/guard.sh" became bash "/.claude/hooks/guard.sh"
17
+ *
18
+ * which does not exist, which a hook runner correctly reads as a refusal. Every turn denied, in any
19
+ * repository that also had Claude Code set up, with a message naming a file that was present and
20
+ * executable all along.
21
+ *
22
+ * Importing a format means accepting the contract that format presumes. An adapter is where that
23
+ * contract is written down, so the next dialect (`.codex/` is the obvious one) declares its own
24
+ * instead of inheriting a hole.
25
+ *
26
+ * ## What an adapter deliberately does NOT do
27
+ *
28
+ * It does not make the foreign source trusted, and it does not make its hooks permissive: a script
29
+ * that exits non-zero is still a refusal. It supplies the variables the format's authors were
30
+ * entitled to assume, and nothing else — `env` here is merged over the scrubbed inherit policy by
31
+ * `spawnAndCollect`, so it adds names rather than widening what a child can see.
32
+ *
33
+ * @internal
34
+ */
35
+ /** The Claude Code CLI's project configuration directory. */
36
+ export declare const CLAUDE_DIR_NAME = ".claude";
37
+ /** A configuration dialect this SDK understands. `theokit` is native; the rest are foreign. */
38
+ export interface ConfigSourceAdapter {
39
+ /** Stable identifier, and what a consumer names to opt in. */
40
+ readonly kind: string;
41
+ /** The project-relative directory the dialect keeps its configuration in. */
42
+ readonly dirName: string;
43
+ /**
44
+ * Variables the dialect's own runtime defines for commands it executes.
45
+ *
46
+ * Empty for the native source: a `.theokit/` hook is written against THIS runtime and inherits it
47
+ * already. Non-empty is what makes a foreign command runnable rather than silently broken.
48
+ */
49
+ runtimeEnv(cwd: string): Record<string, string>;
50
+ }
51
+ /** The native source. Always read, never opted into, always first for precedence. */
52
+ export declare const NATIVE_SOURCE: ConfigSourceAdapter;
53
+ /**
54
+ * Claude Code.
55
+ *
56
+ * `CLAUDE_PROJECT_DIR` is the documented way for a hook command in `settings.json` to reach a file
57
+ * in the project. Only that one variable is supplied: `$CLAUDE_PLUGIN_ROOT` and the rest of that
58
+ * runtime's surface are NOT defined here, because supplying a name whose value this SDK would have
59
+ * to invent is worse than leaving it unset — an invented root sends a script somewhere real and
60
+ * wrong, where an unset one fails loudly.
61
+ */
62
+ export declare const CLAUDE_CODE_SOURCE: ConfigSourceAdapter;
63
+ /**
64
+ * The adapter whose directory an absolute config path sits under, or `undefined` for a path that
65
+ * belongs to no registered dialect.
66
+ *
67
+ * Matched on the path SEGMENT rather than with `includes`, so a workspace that happens to live under
68
+ * `/home/me/.claude-backups/repo` does not read as a Claude Code source.
69
+ */
70
+ export declare function adapterForConfigPath(path: string): ConfigSourceAdapter | undefined;
71
+ /**
72
+ * Variable references in a shell command that nothing will define.
73
+ *
74
+ * The second half of #522, and the half that cost the debugging session. `sh` expands an unset
75
+ * variable to the empty string and says nothing, so the failure surfaces ten characters later as a
76
+ * path: `bash: /.claude/hooks/guard.sh: No such file or directory` — which reads as "your script is
77
+ * missing" while the script is present and executable. Nothing in that message contains the name of
78
+ * the variable that was actually missing, so the reader looks in the wrong place.
79
+ *
80
+ * Checked against BOTH the process environment and the variables the dialect supplies, because
81
+ * either is a legitimate source: a hook may reasonably use `$HOME`.
82
+ *
83
+ * ## What it deliberately does not try to be
84
+ *
85
+ * This is not a shell parser. It finds `$NAME` and `${NAME}` outside single quotes, which is the
86
+ * shape a config file's hook commands take. It does NOT understand `${NAME:-default}` (a default
87
+ * makes the variable optional, so it is not reported), assignments earlier in the same command, or
88
+ * variables a sourced script exports. A false NEGATIVE there costs the old behaviour — the confusing
89
+ * path error — and a false positive would deny a hook that would have worked, so the parse errs
90
+ * toward silence and the check only ever ADDS a name to a failure that already happened.
91
+ */
92
+ export declare function undefinedVariablesIn(command: string, supplied: Readonly<Record<string, string>>, env?: Readonly<Record<string, string | undefined>>): string[];
@@ -4,6 +4,15 @@ export interface HookCommand {
4
4
  matcher?: string;
5
5
  /** Optional timeout in ms; defaults to 30s. */
6
6
  timeoutMs?: number;
7
+ /**
8
+ * The config file this command was declared in.
9
+ *
10
+ * Carried so the executor can supply the runtime contract the declaring DIALECT presumes — a
11
+ * command from `.claude/settings.json` is written against Claude Code's runtime and expects
12
+ * `$CLAUDE_PROJECT_DIR` to exist (#522). Absent for a command built in memory, which is native by
13
+ * construction.
14
+ */
15
+ sourcePath?: string;
7
16
  }
8
17
  export interface HookDecision {
9
18
  decision: "allow" | "deny" | "feedback";
@@ -20,6 +20,15 @@ export interface HookCommand {
20
20
  command: string;
21
21
  matcher?: string;
22
22
  timeoutMs?: number;
23
+ /**
24
+ * The config file this command was declared in.
25
+ *
26
+ * Carried so the executor can supply the runtime contract the declaring DIALECT presumes — a
27
+ * command from `.claude/settings.json` is written against Claude Code's runtime and expects
28
+ * `$CLAUDE_PROJECT_DIR` to exist (#522). Absent for a command built in memory, which is native by
29
+ * construction.
30
+ */
31
+ sourcePath?: string;
23
32
  }
24
33
  export interface HookConfig {
25
34
  hooks?: Partial<Record<HookEvent, HookCommand[]>>;
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var chunk43ZQRWAP_cjs = require('./chunk-43ZQRWAP.cjs');
4
+ require('./chunk-AKJP2STZ.cjs');
5
+ require('./chunk-4CLOXP6H.cjs');
6
+ require('./chunk-4ZHTIJNE.cjs');
7
+ require('./chunk-XL7Q7HB2.cjs');
8
+ require('./chunk-EG4QM7ZJ.cjs');
9
+
10
+
11
+
12
+ Object.defineProperty(exports, "loadSubagents", {
13
+ enumerable: true,
14
+ get: function () { return chunk43ZQRWAP_cjs.loadSubagents; }
15
+ });
16
+ //# sourceMappingURL=subagents-loader-UCNO7FUH.cjs.map
17
+ //# sourceMappingURL=subagents-loader-UCNO7FUH.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-YEUFFPAL.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-UCNO7FUH.cjs"}
@@ -0,0 +1,8 @@
1
+ export { loadSubagents } from './chunk-LKBEROHN.js';
2
+ import './chunk-247ZTLNU.js';
3
+ import './chunk-LXQ6HKPS.js';
4
+ import './chunk-ZZMZWBR6.js';
5
+ import './chunk-D4CUGAKZ.js';
6
+ import './chunk-XEQ3TM66.js';
7
+ //# sourceMappingURL=subagents-loader-XP5ERVDZ.js.map
8
+ //# sourceMappingURL=subagents-loader-XP5ERVDZ.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-CRT5LLL3.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-XP5ERVDZ.js"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkCQBXOJ6U_cjs = require('./chunk-CQBXOJ6U.cjs');
4
- require('./chunk-AQO3NSRG.cjs');
3
+ var chunk43ZQRWAP_cjs = require('./chunk-43ZQRWAP.cjs');
4
+ require('./chunk-AKJP2STZ.cjs');
5
5
  require('./chunk-4CLOXP6H.cjs');
6
6
  var chunk4ZHTIJNE_cjs = require('./chunk-4ZHTIJNE.cjs');
7
7
  require('./chunk-XL7Q7HB2.cjs');
@@ -24,7 +24,7 @@ function resolveSources(options) {
24
24
  }
25
25
  async function discoverSubagents(cwd, options) {
26
26
  const sources = resolveSources(options);
27
- return chunkCQBXOJ6U_cjs.loadSubagents(cwd, sources.includes("project"), void 0);
27
+ return chunk43ZQRWAP_cjs.loadSubagents(cwd, sources.includes("project"), void 0);
28
28
  }
29
29
  async function loadSubagentDefinition(name, cwd, options) {
30
30
  return (await discoverSubagents(cwd, options))[name];
@@ -1,5 +1,5 @@
1
- import { loadSubagents } from './chunk-LXI4XZEC.js';
2
- import './chunk-UFLD2HEV.js';
1
+ import { loadSubagents } from './chunk-LKBEROHN.js';
2
+ import './chunk-247ZTLNU.js';
3
3
  import './chunk-LXQ6HKPS.js';
4
4
  import { ConfigurationError } from './chunk-ZZMZWBR6.js';
5
5
  import './chunk-D4CUGAKZ.js';
@@ -68,11 +68,11 @@ Branch on `code`, never on the message: messages carry context (an id, a path, a
68
68
  | `handoff_target_invalid` | domain | ConfigurationError | `packages/sdk-handoff/src/handoff.ts:116` |
69
69
  | `handoff_target_required` | domain | ConfigurationError | `packages/sdk-handoff/src/handoff.ts:111` |
70
70
  | `hitl_timeout` | domain | HitlTimeoutError | `packages/sdk/src/internal/runtime/tools/hitl-middleware.ts:39` |
71
- | `hook_denied` | domain | ConfigurationError | `packages/sdk/src/internal/local-agent/local-agent.ts:429` |
72
- | `hooks_invalid_command` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:234` |
73
- | `hooks_json_invalid` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:152` +2 |
74
- | `hooks_read_error` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:143` |
75
- | `hooks_unsupported_type` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:228` |
71
+ | `hook_denied` | domain | ConfigurationError | `packages/sdk/src/internal/local-agent/local-agent.ts:433` |
72
+ | `hooks_invalid_command` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:265` |
73
+ | `hooks_json_invalid` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:183` +2 |
74
+ | `hooks_read_error` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:174` |
75
+ | `hooks_unsupported_type` | domain | ConfigurationError | `packages/sdk/src/internal/runtime/hooks/hooks-source.ts:259` |
76
76
  | `interactive_unavailable` | domain | InteractiveUnavailableError | `packages/sdk/src/interactive/types.ts:20` |
77
77
  | `INTERNAL_SERVER_ERROR` | domain | — | `packages/sdk/src/server/errors-envelope.ts:100` |
78
78
  | `invalid_argument` | domain | TheokitAgentError | `packages/sdk/src/compaction.ts:79` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theokit/sdk",
3
- "version": "4.63.3",
3
+ "version": "4.63.4",
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/usetheokit/theokit-sdk#readme",