@agentick/kernel 0.0.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/LICENSE +21 -0
- package/README.md +401 -0
- package/dist/.tsbuildinfo.build +1 -0
- package/dist/channel-helpers.d.ts +32 -0
- package/dist/channel-helpers.d.ts.map +1 -0
- package/dist/channel-helpers.js +62 -0
- package/dist/channel-helpers.js.map +1 -0
- package/dist/channel.d.ts +164 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +199 -0
- package/dist/channel.js.map +1 -0
- package/dist/context.d.ts +412 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +289 -0
- package/dist/context.js.map +1 -0
- package/dist/event-buffer.d.ts +208 -0
- package/dist/event-buffer.d.ts.map +1 -0
- package/dist/event-buffer.js +335 -0
- package/dist/event-buffer.js.map +1 -0
- package/dist/execution-helpers.d.ts +179 -0
- package/dist/execution-helpers.d.ts.map +1 -0
- package/dist/execution-helpers.js +212 -0
- package/dist/execution-helpers.js.map +1 -0
- package/dist/execution-tracker.d.ts +61 -0
- package/dist/execution-tracker.d.ts.map +1 -0
- package/dist/execution-tracker.js +319 -0
- package/dist/execution-tracker.js.map +1 -0
- package/dist/guard.d.ts +65 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +15 -0
- package/dist/guard.js.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +341 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +346 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics-helpers.d.ts +40 -0
- package/dist/metrics-helpers.d.ts.map +1 -0
- package/dist/metrics-helpers.js +72 -0
- package/dist/metrics-helpers.js.map +1 -0
- package/dist/otel-provider.d.ts +54 -0
- package/dist/otel-provider.d.ts.map +1 -0
- package/dist/otel-provider.js +107 -0
- package/dist/otel-provider.js.map +1 -0
- package/dist/procedure-graph.d.ts +136 -0
- package/dist/procedure-graph.d.ts.map +1 -0
- package/dist/procedure-graph.js +272 -0
- package/dist/procedure-graph.js.map +1 -0
- package/dist/procedure.d.ts +757 -0
- package/dist/procedure.d.ts.map +1 -0
- package/dist/procedure.js +895 -0
- package/dist/procedure.js.map +1 -0
- package/dist/schema.d.ts +153 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +385 -0
- package/dist/schema.js.map +1 -0
- package/dist/stream.d.ts +106 -0
- package/dist/stream.d.ts.map +1 -0
- package/dist/stream.js +186 -0
- package/dist/stream.js.map +1 -0
- package/dist/telemetry.d.ts +182 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +124 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/testing.d.ts +55 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +96 -0
- package/dist/testing.js.map +1 -0
- package/package.json +48 -0
package/dist/testing.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel Testing Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides `createTestProcedure` — a lightweight Procedure stub for testing
|
|
5
|
+
* code that *consumes* procedures without needing real middleware, context
|
|
6
|
+
* propagation, or execution tracking.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createTestProcedure } from "@agentick/kernel/testing";
|
|
11
|
+
*
|
|
12
|
+
* const proc = createTestProcedure({ handler: async (x: number) => x * 2 });
|
|
13
|
+
* const result = await proc(5).result; // 10
|
|
14
|
+
* expect(proc._callCount).toBe(1);
|
|
15
|
+
* expect(proc._lastArgs).toEqual([5]);
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @module @agentick/kernel/testing
|
|
19
|
+
*/
|
|
20
|
+
import { createProcedurePromise, PROCEDURE_SYMBOL } from "./procedure";
|
|
21
|
+
// ============================================================================
|
|
22
|
+
// Implementation
|
|
23
|
+
// ============================================================================
|
|
24
|
+
/**
|
|
25
|
+
* Create a test procedure stub.
|
|
26
|
+
*
|
|
27
|
+
* Callable + branded with `PROCEDURE_SYMBOL` so `isProcedure()` returns true.
|
|
28
|
+
* Returns `ProcedurePromise` so `.result` chaining works.
|
|
29
|
+
*
|
|
30
|
+
* Chainable methods (`.use()`, `.withContext()`, etc.) are no-ops returning self.
|
|
31
|
+
* This is intentional — test procedures are for testing code that *calls*
|
|
32
|
+
* procedures, not for testing middleware.
|
|
33
|
+
*/
|
|
34
|
+
export function createTestProcedure(options = {}) {
|
|
35
|
+
const handler = options.handler ?? (() => undefined);
|
|
36
|
+
const calls = [];
|
|
37
|
+
let nextResponse = null;
|
|
38
|
+
let persistentResponse = null;
|
|
39
|
+
function resolveOverride(override) {
|
|
40
|
+
return typeof override === "function" ? override() : override;
|
|
41
|
+
}
|
|
42
|
+
const callable = (...args) => {
|
|
43
|
+
calls.push({ args, timestamp: Date.now() });
|
|
44
|
+
const promise = Promise.resolve().then(() => {
|
|
45
|
+
// One-shot override takes priority
|
|
46
|
+
if (nextResponse !== null) {
|
|
47
|
+
const override = nextResponse;
|
|
48
|
+
nextResponse = null;
|
|
49
|
+
return resolveOverride(override.value);
|
|
50
|
+
}
|
|
51
|
+
// Persistent override
|
|
52
|
+
if (persistentResponse !== null) {
|
|
53
|
+
return resolveOverride(persistentResponse.value);
|
|
54
|
+
}
|
|
55
|
+
// Default handler
|
|
56
|
+
return handler(...args);
|
|
57
|
+
});
|
|
58
|
+
return createProcedurePromise(promise);
|
|
59
|
+
};
|
|
60
|
+
// Attach Procedure interface methods as no-ops
|
|
61
|
+
callable.exec = callable;
|
|
62
|
+
callable.use = () => callable;
|
|
63
|
+
callable.withContext = () => callable;
|
|
64
|
+
callable.withMiddleware = () => callable;
|
|
65
|
+
callable.withTimeout = () => callable;
|
|
66
|
+
callable.withMetadata = () => callable;
|
|
67
|
+
callable.pipe = () => callable;
|
|
68
|
+
// Brand
|
|
69
|
+
callable[PROCEDURE_SYMBOL] = true;
|
|
70
|
+
// Test-specific API
|
|
71
|
+
Object.defineProperty(callable, "_calls", {
|
|
72
|
+
get: () => calls,
|
|
73
|
+
enumerable: true,
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(callable, "_callCount", {
|
|
76
|
+
get: () => calls.length,
|
|
77
|
+
enumerable: true,
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(callable, "_lastArgs", {
|
|
80
|
+
get: () => calls.at(-1)?.args,
|
|
81
|
+
enumerable: true,
|
|
82
|
+
});
|
|
83
|
+
callable.respondWith = (value) => {
|
|
84
|
+
nextResponse = { value };
|
|
85
|
+
};
|
|
86
|
+
callable.setResponse = (value) => {
|
|
87
|
+
persistentResponse = { value };
|
|
88
|
+
};
|
|
89
|
+
callable.reset = () => {
|
|
90
|
+
calls.length = 0;
|
|
91
|
+
nextResponse = null;
|
|
92
|
+
persistentResponse = null;
|
|
93
|
+
};
|
|
94
|
+
return callable;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA6BvE,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAqC,EAAE;IAEvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAoB,CAAC;IAEzE,MAAM,KAAK,GAA8C,EAAE,CAAC;IAC5D,IAAI,YAAY,GAAgE,IAAI,CAAC;IACrF,IAAI,kBAAkB,GAAgE,IAAI,CAAC;IAE3F,SAAS,eAAe,CAAC,QAAmD;QAC1E,OAAO,OAAO,QAA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
+
"license": "ISC",
|
|
10
|
+
"author": "Ryan Lindgren",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./testing": {
|
|
22
|
+
"types": "./dist/testing.d.ts",
|
|
23
|
+
"import": "./dist/testing.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"pino": "^9.6.0",
|
|
31
|
+
"zod": "^4.2.1",
|
|
32
|
+
"zod-to-json-schema": "^3.25.1",
|
|
33
|
+
"@agentick/shared": "0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"pino-pretty": "^13.0.0"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"test": "echo \"Tests run from workspace root\"",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.build.json --noEmit",
|
|
42
|
+
"lint": "oxlint src/",
|
|
43
|
+
"format:check": "oxfmt --check src/",
|
|
44
|
+
"clean": "rm -rf dist",
|
|
45
|
+
"dev": "tsc --watch"
|
|
46
|
+
},
|
|
47
|
+
"types": "./dist/index.d.ts"
|
|
48
|
+
}
|