@intx/inference 0.1.2 → 0.2.2

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 (97) hide show
  1. package/LICENSE +176 -0
  2. package/dist/actions.d.ts +16 -0
  3. package/dist/actions.js +200 -0
  4. package/dist/adapter.d.ts +38 -0
  5. package/dist/adapter.js +31 -0
  6. package/dist/assembly.d.ts +68 -0
  7. package/dist/assembly.js +132 -0
  8. package/dist/audit-collector.d.ts +10 -0
  9. package/dist/audit-collector.js +139 -0
  10. package/dist/auth.d.ts +24 -0
  11. package/{src/auth.ts → dist/auth.js} +13 -19
  12. package/dist/authz-extension.d.ts +32 -0
  13. package/dist/authz-extension.js +100 -0
  14. package/dist/correlation.d.ts +25 -0
  15. package/dist/correlation.js +32 -0
  16. package/dist/default-director.d.ts +111 -0
  17. package/dist/default-director.js +199 -0
  18. package/dist/director.d.ts +6 -0
  19. package/dist/director.js +56 -0
  20. package/dist/errors.d.ts +18 -0
  21. package/dist/errors.js +83 -0
  22. package/dist/gates.d.ts +27 -0
  23. package/dist/gates.js +80 -0
  24. package/dist/harness.d.ts +147 -0
  25. package/dist/harness.js +1319 -0
  26. package/dist/index.d.ts +37 -0
  27. package/dist/index.js +21 -0
  28. package/dist/manifest.d.ts +31 -0
  29. package/dist/manifest.js +44 -0
  30. package/dist/providers/anthropic.d.ts +33 -0
  31. package/dist/providers/anthropic.js +670 -0
  32. package/dist/providers/google-genai-files.d.ts +48 -0
  33. package/dist/providers/google-genai-files.js +205 -0
  34. package/dist/providers/google-genai.d.ts +3 -0
  35. package/dist/providers/google-genai.js +1196 -0
  36. package/dist/providers/index.d.ts +38 -0
  37. package/dist/providers/index.js +56 -0
  38. package/dist/providers/openai.d.ts +3 -0
  39. package/dist/providers/openai.js +609 -0
  40. package/dist/reactor.d.ts +50 -0
  41. package/dist/reactor.js +920 -0
  42. package/dist/retry-policy.d.ts +31 -0
  43. package/{src/retry-policy.ts → dist/retry-policy.js} +41 -53
  44. package/dist/sse.d.ts +1 -0
  45. package/dist/sse.js +63 -0
  46. package/dist/state.d.ts +23 -0
  47. package/dist/state.js +100 -0
  48. package/dist/tool-name.d.ts +6 -0
  49. package/dist/tool-name.js +110 -0
  50. package/dist/transform.d.ts +11 -0
  51. package/dist/transform.js +117 -0
  52. package/dist/transforms/index.d.ts +2 -0
  53. package/dist/transforms/index.js +1 -0
  54. package/dist/transforms/size-cap.d.ts +12 -0
  55. package/dist/transforms/size-cap.js +80 -0
  56. package/dist/turns.d.ts +21 -0
  57. package/dist/turns.js +135 -0
  58. package/package.json +21 -6
  59. package/src/actions.ts +0 -245
  60. package/src/adapter.ts +0 -57
  61. package/src/assembly.test.ts +0 -728
  62. package/src/assembly.ts +0 -250
  63. package/src/audit-collector.test.ts +0 -332
  64. package/src/audit-collector.ts +0 -172
  65. package/src/auth.test.ts +0 -117
  66. package/src/authz-extension.test.ts +0 -269
  67. package/src/authz-extension.ts +0 -145
  68. package/src/correlation.ts +0 -61
  69. package/src/default-director.test.ts +0 -314
  70. package/src/default-director.ts +0 -344
  71. package/src/director.ts +0 -87
  72. package/src/errors.test.ts +0 -133
  73. package/src/errors.ts +0 -115
  74. package/src/gates.ts +0 -128
  75. package/src/harness.test.ts +0 -655
  76. package/src/harness.ts +0 -1571
  77. package/src/index.ts +0 -76
  78. package/src/providers/anthropic.test.ts +0 -771
  79. package/src/providers/anthropic.ts +0 -810
  80. package/src/providers/google-genai-files.ts +0 -289
  81. package/src/providers/google-genai.ts +0 -1518
  82. package/src/providers/openai.ts +0 -719
  83. package/src/providers/registry.ts +0 -33
  84. package/src/reactor.test.ts +0 -3660
  85. package/src/reactor.ts +0 -1058
  86. package/src/scheduler.test.ts +0 -41
  87. package/src/sse.test.ts +0 -133
  88. package/src/sse.ts +0 -76
  89. package/src/state.ts +0 -135
  90. package/src/transform.test.ts +0 -207
  91. package/src/transform.ts +0 -159
  92. package/src/transforms/index.ts +0 -2
  93. package/src/transforms/size-cap.test.ts +0 -172
  94. package/src/transforms/size-cap.ts +0 -110
  95. package/src/turns.ts +0 -54
  96. package/tsconfig.json +0 -4
  97. package/tsconfig.tsbuildinfo +0 -1
package/src/gates.ts DELETED
@@ -1,128 +0,0 @@
1
- // Gate management for the agent reactor.
2
- //
3
- // Gates block the reactor until an external condition resolves. Each gate has
4
- // a type, an ID, and a mandatory timeout. The gate manager owns all active
5
- // gates and exposes methods to register, clear, and time out gates.
6
- //
7
- // (INFERENCE.md § Gates, Gate Timeouts, Gate Behavior During Suspension)
8
-
9
- import type { GateType } from "@intx/types/runtime";
10
-
11
- export type GateRecord = {
12
- gateId: string;
13
- type: GateType;
14
- timeoutAt: number;
15
- correlationId: string | undefined;
16
- resolve: (reason: "resolved" | "timeout" | "shutdown") => void;
17
- onCleared: (
18
- gateId: string,
19
- reason: "resolved" | "timeout" | "shutdown",
20
- ) => void;
21
- timer: ReturnType<typeof setTimeout>;
22
- };
23
-
24
- export type GateSnapshot = {
25
- gateId: string;
26
- type: GateType;
27
- timeoutAt: number;
28
- };
29
-
30
- /**
31
- * Manages active gates. All gates must have a positive timeout.
32
- */
33
- export function createGateManager() {
34
- const gates = new Map<string, GateRecord>();
35
-
36
- function register(
37
- gateId: string,
38
- type: GateType,
39
- timeoutMs: number,
40
- correlationId: string | undefined,
41
- onCleared: (
42
- gateId: string,
43
- reason: "resolved" | "timeout" | "shutdown",
44
- ) => void,
45
- ): Promise<"resolved" | "timeout" | "shutdown"> {
46
- if (timeoutMs <= 0) {
47
- throw new Error(
48
- `Gate "${gateId}" must have a positive timeout (got ${timeoutMs})`,
49
- );
50
- }
51
-
52
- if (gates.has(gateId)) {
53
- throw new Error(`Gate "${gateId}" is already registered`);
54
- }
55
-
56
- const timeoutAt = Date.now() + timeoutMs;
57
- let resolveGate!: (reason: "resolved" | "timeout" | "shutdown") => void;
58
-
59
- const promise = new Promise<"resolved" | "timeout" | "shutdown">(
60
- (resolve) => {
61
- resolveGate = resolve;
62
- },
63
- );
64
-
65
- const timer = setTimeout(() => {
66
- if (gates.has(gateId)) {
67
- gates.delete(gateId);
68
- resolveGate("timeout");
69
- onCleared(gateId, "timeout");
70
- }
71
- }, timeoutMs);
72
-
73
- gates.set(gateId, {
74
- gateId,
75
- type,
76
- timeoutAt,
77
- correlationId,
78
- resolve: resolveGate,
79
- onCleared,
80
- timer,
81
- });
82
-
83
- return promise;
84
- }
85
-
86
- function clear(gateId: string): boolean {
87
- const gate = gates.get(gateId);
88
- if (gate === undefined) return false;
89
- clearTimeout(gate.timer);
90
- gates.delete(gateId);
91
- gate.resolve("resolved");
92
- gate.onCleared(gateId, "resolved");
93
- return true;
94
- }
95
-
96
- function shutdown(): void {
97
- const entries = Array.from(gates.values());
98
- gates.clear();
99
- for (const gate of entries) {
100
- clearTimeout(gate.timer);
101
- gate.resolve("shutdown");
102
- gate.onCleared(gate.gateId, "shutdown");
103
- }
104
- }
105
-
106
- function findByCorrelationId(correlationId: string): GateRecord | undefined {
107
- for (const gate of gates.values()) {
108
- if (gate.correlationId === correlationId) return gate;
109
- }
110
- return undefined;
111
- }
112
-
113
- function snapshot(): GateSnapshot[] {
114
- return Array.from(gates.values()).map((g) => ({
115
- gateId: g.gateId,
116
- type: g.type,
117
- timeoutAt: g.timeoutAt,
118
- }));
119
- }
120
-
121
- function has(gateId: string): boolean {
122
- return gates.has(gateId);
123
- }
124
-
125
- return { register, clear, shutdown, findByCorrelationId, snapshot, has };
126
- }
127
-
128
- export type GateManager = ReturnType<typeof createGateManager>;