jeopi-agent-core 16.2.13

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 (66) hide show
  1. package/CHANGELOG.md +1016 -0
  2. package/README.md +473 -0
  3. package/dist/types/agent-loop.d.ts +66 -0
  4. package/dist/types/agent.d.ts +427 -0
  5. package/dist/types/append-only-context.d.ts +133 -0
  6. package/dist/types/compaction/branch-summarization.d.ts +101 -0
  7. package/dist/types/compaction/compaction-v2-streaming.d.ts +82 -0
  8. package/dist/types/compaction/compaction.d.ts +283 -0
  9. package/dist/types/compaction/entries.d.ts +110 -0
  10. package/dist/types/compaction/errors.d.ts +26 -0
  11. package/dist/types/compaction/index.d.ts +12 -0
  12. package/dist/types/compaction/messages.d.ts +77 -0
  13. package/dist/types/compaction/openai.d.ts +77 -0
  14. package/dist/types/compaction/pruning.d.ts +105 -0
  15. package/dist/types/compaction/shake.d.ts +92 -0
  16. package/dist/types/compaction/tool-protection.d.ts +17 -0
  17. package/dist/types/compaction/utils.d.ts +58 -0
  18. package/dist/types/compaction.d.ts +1 -0
  19. package/dist/types/index.d.ts +12 -0
  20. package/dist/types/proxy.d.ts +85 -0
  21. package/dist/types/replay-policy.d.ts +5 -0
  22. package/dist/types/run-collector.d.ts +196 -0
  23. package/dist/types/telemetry.d.ts +590 -0
  24. package/dist/types/thinking.d.ts +17 -0
  25. package/dist/types/tokenizer.d.ts +1 -0
  26. package/dist/types/types.d.ts +640 -0
  27. package/dist/types/utils/yield.d.ts +71 -0
  28. package/package.json +78 -0
  29. package/src/agent-loop.ts +2188 -0
  30. package/src/agent.ts +1457 -0
  31. package/src/append-only-context.ts +348 -0
  32. package/src/compaction/branch-summarization.ts +370 -0
  33. package/src/compaction/compaction-v2-streaming.ts +719 -0
  34. package/src/compaction/compaction.ts +1553 -0
  35. package/src/compaction/entries.ts +142 -0
  36. package/src/compaction/errors.ts +31 -0
  37. package/src/compaction/index.ts +13 -0
  38. package/src/compaction/messages.ts +237 -0
  39. package/src/compaction/openai.ts +581 -0
  40. package/src/compaction/prompts/auto-handoff-threshold-focus.md +1 -0
  41. package/src/compaction/prompts/branch-summary-context.md +5 -0
  42. package/src/compaction/prompts/branch-summary-preamble.md +2 -0
  43. package/src/compaction/prompts/branch-summary.md +30 -0
  44. package/src/compaction/prompts/compaction-short-summary.md +9 -0
  45. package/src/compaction/prompts/compaction-summary-context.md +5 -0
  46. package/src/compaction/prompts/compaction-summary.md +38 -0
  47. package/src/compaction/prompts/compaction-turn-prefix.md +17 -0
  48. package/src/compaction/prompts/compaction-update-summary.md +45 -0
  49. package/src/compaction/prompts/file-operations.md +5 -0
  50. package/src/compaction/prompts/handoff-document.md +49 -0
  51. package/src/compaction/prompts/snapcompact-archive-context.md +3 -0
  52. package/src/compaction/prompts/summarization-system.md +3 -0
  53. package/src/compaction/pruning.ts +424 -0
  54. package/src/compaction/shake.ts +429 -0
  55. package/src/compaction/tool-protection.ts +55 -0
  56. package/src/compaction/utils.ts +323 -0
  57. package/src/compaction.ts +1 -0
  58. package/src/index.ts +24 -0
  59. package/src/proxy.ts +376 -0
  60. package/src/replay-policy.ts +13 -0
  61. package/src/run-collector.ts +631 -0
  62. package/src/telemetry.ts +2034 -0
  63. package/src/thinking.ts +19 -0
  64. package/src/tokenizer.ts +17 -0
  65. package/src/types.ts +718 -0
  66. package/src/utils/yield.ts +183 -0
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Cooperative yield utility for preventing Bun event-loop busy-wait.
3
+ *
4
+ * ## Root Cause
5
+ *
6
+ * Bun 1.3.x (JavaScriptCore) event loop busy-waits (spins in userspace)
7
+ * when the only pending work is an unresolved Promise — even if there are
8
+ * active I/O watchers (stdin, child process pipes, etc.). The event loop
9
+ * continuously polls for microtask resolution instead of blocking in
10
+ * `epoll_wait`, consuming ~100% of a CPU core.
11
+ *
12
+ * This affects any `await` on a never-resolved Promise, including:
13
+ * - `Promise.withResolvers()` used for user input callbacks
14
+ * - `await proc.exited` for long-running child processes
15
+ * - Agent loop iterations waiting for the next tool call
16
+ *
17
+ * ## Fix
18
+ *
19
+ * A recurring `setInterval` keeps the event loop sleeping in `epoll_wait`.
20
+ * The `EventLoopKeepalive` class and `keepaliveWhile()` wrapper provide a
21
+ * clean way to install and clean up this keepalive timer.
22
+ *
23
+ * The older `yieldIfDue()` and `ExponentialYield` approaches (compensated
24
+ * sleep loops) are retained for the agent-loop hot-path where Promises
25
+ * resolve frequently and the keepalive alone is insufficient.
26
+ */
27
+ export declare class EventLoopKeepalive {
28
+ #private;
29
+ [Symbol.dispose](): void;
30
+ }
31
+ /**
32
+ * Cooperative yield gate. Sleeps for at least {@link YieldGateOptions.sleepMs}
33
+ * but at most once every {@link YieldGateOptions.intervalMs}; hot-path callers
34
+ * invoke it freely and only the slow path actually sleeps.
35
+ *
36
+ * The clock and sleep are injectable so tests drive the gate logic without
37
+ * touching process-global `Date.now`/`scheduler.wait` — globals a concurrent
38
+ * test file can restore mid-run, which previously made the shared gate flake.
39
+ */
40
+ export interface YieldGateOptions {
41
+ now?: () => number;
42
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
43
+ intervalMs?: number;
44
+ sleepMs?: number;
45
+ }
46
+ export declare class YieldGate {
47
+ #private;
48
+ constructor(opts?: YieldGateOptions);
49
+ yieldIfDue(signal?: AbortSignal): Promise<void>;
50
+ }
51
+ /**
52
+ * Yield to the Bun event loop, sleeping for at least 20 ms — but at most once
53
+ * every {@link YIELD_INTERVAL_MS} across all callers.
54
+ */
55
+ export declare function yieldIfDue(): Promise<void>;
56
+ export declare class ExponentialYield {
57
+ #private;
58
+ constructor(opts?: {
59
+ minMs?: number;
60
+ maxMs?: number;
61
+ multiplier?: number;
62
+ });
63
+ notifyActivity(): void;
64
+ sleep(signal?: AbortSignal): Promise<number>;
65
+ /**
66
+ * Race `racers` against an exponentially-backed-off cooperative yield.
67
+ * The losing sleep is cancelled as soon as a racer settles, so no stray
68
+ * timers keep the event loop alive past the racer's resolution.
69
+ */
70
+ race<T>(racers: Array<Promise<T>>): Promise<T>;
71
+ }
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "type": "module",
3
+ "name": "jeopi-agent-core",
4
+ "version": "16.2.13",
5
+ "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
+ "homepage": "https://github.com/akillness/jeopi",
7
+ "author": "Can Boluk",
8
+ "contributors": [
9
+ "Mario Zechner"
10
+ ],
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/akillness/jeopi.git",
15
+ "directory": "packages/agent"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/akillness/jeopi/issues"
19
+ },
20
+ "keywords": [
21
+ "ai",
22
+ "agent",
23
+ "llm",
24
+ "transport",
25
+ "state-management"
26
+ ],
27
+ "main": "./src/index.ts",
28
+ "types": "./dist/types/index.d.ts",
29
+ "scripts": {
30
+ "check": "biome check . && bun run check:types",
31
+ "check:types": "tsgo -p tsconfig.json --noEmit",
32
+ "lint": "biome lint .",
33
+ "test": "bun test --parallel",
34
+ "fix": "biome check --write --unsafe .",
35
+ "fmt": "biome format --write ."
36
+ },
37
+ "dependencies": {
38
+ "jeopi-ai": "16.2.13",
39
+ "jeopi-catalog": "16.2.13",
40
+ "jeopi-natives": "16.2.13",
41
+ "jeopi-utils": "16.2.13",
42
+ "jeopi-wire": "16.2.13",
43
+ "jeopi-snapcompact": "16.2.13",
44
+ "@opentelemetry/api": "^1.9.1"
45
+ },
46
+ "devDependencies": {
47
+ "@opentelemetry/context-async-hooks": "^2.7.1",
48
+ "@opentelemetry/sdk-trace-base": "^2.7.1",
49
+ "@types/bun": "^1.3.14"
50
+ },
51
+ "engines": {
52
+ "bun": ">=1.3.14"
53
+ },
54
+ "files": [
55
+ "src",
56
+ "README.md",
57
+ "CHANGELOG.md",
58
+ "dist/types"
59
+ ],
60
+ "exports": {
61
+ ".": {
62
+ "types": "./dist/types/index.d.ts",
63
+ "import": "./src/index.ts"
64
+ },
65
+ "./compaction": {
66
+ "types": "./dist/types/compaction.d.ts",
67
+ "import": "./src/compaction.ts"
68
+ },
69
+ "./compaction/*": {
70
+ "types": "./dist/types/compaction/*.d.ts",
71
+ "import": "./src/compaction/*.ts"
72
+ },
73
+ "./*": {
74
+ "types": "./dist/types/*.d.ts",
75
+ "import": "./src/*.ts"
76
+ }
77
+ }
78
+ }