groundswell 0.0.3 → 1.0.0
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 +26 -9
- package/dist/cache/cache-key.d.ts +20 -0
- package/dist/cache/cache-key.d.ts.map +1 -1
- package/dist/cache/cache-key.js +9 -0
- package/dist/cache/cache-key.js.map +1 -1
- package/dist/core/agent.d.ts +120 -29
- package/dist/core/agent.d.ts.map +1 -1
- package/dist/core/agent.js +584 -177
- package/dist/core/agent.js.map +1 -1
- package/dist/core/mcp-handler.d.ts +63 -5
- package/dist/core/mcp-handler.d.ts.map +1 -1
- package/dist/core/mcp-handler.js +184 -4
- package/dist/core/mcp-handler.js.map +1 -1
- package/dist/core/workflow-context.d.ts +6 -2
- package/dist/core/workflow-context.d.ts.map +1 -1
- package/dist/core/workflow-context.js +99 -4
- package/dist/core/workflow-context.js.map +1 -1
- package/dist/core/workflow.d.ts +315 -13
- package/dist/core/workflow.d.ts.map +1 -1
- package/dist/core/workflow.js +552 -30
- package/dist/core/workflow.js.map +1 -1
- package/dist/debugger/event-replayer.d.ts +422 -0
- package/dist/debugger/event-replayer.d.ts.map +1 -0
- package/dist/debugger/event-replayer.js +639 -0
- package/dist/debugger/event-replayer.js.map +1 -0
- package/dist/debugger/tree-debugger.d.ts +170 -1
- package/dist/debugger/tree-debugger.d.ts.map +1 -1
- package/dist/debugger/tree-debugger.js +423 -1
- package/dist/debugger/tree-debugger.js.map +1 -1
- package/dist/decorators/step.d.ts.map +1 -1
- package/dist/decorators/step.js +129 -47
- package/dist/decorators/step.js.map +1 -1
- package/dist/harnesses/claude-code-harness.d.ts +391 -0
- package/dist/harnesses/claude-code-harness.d.ts.map +1 -0
- package/dist/harnesses/claude-code-harness.js +1076 -0
- package/dist/harnesses/claude-code-harness.js.map +1 -0
- package/dist/harnesses/harness-registry.d.ts +440 -0
- package/dist/harnesses/harness-registry.d.ts.map +1 -0
- package/dist/harnesses/harness-registry.js +543 -0
- package/dist/harnesses/harness-registry.js.map +1 -0
- package/dist/harnesses/index.d.ts +12 -0
- package/dist/harnesses/index.d.ts.map +1 -0
- package/dist/harnesses/index.js +11 -0
- package/dist/harnesses/index.js.map +1 -0
- package/dist/harnesses/pi-harness.d.ts +219 -0
- package/dist/harnesses/pi-harness.d.ts.map +1 -0
- package/dist/harnesses/pi-harness.js +676 -0
- package/dist/harnesses/pi-harness.js.map +1 -0
- package/dist/harnesses/pi-schema-converter.d.ts +24 -0
- package/dist/harnesses/pi-schema-converter.d.ts.map +1 -0
- package/dist/harnesses/pi-schema-converter.js +81 -0
- package/dist/harnesses/pi-schema-converter.js.map +1 -0
- package/dist/harnesses/register-defaults.d.ts +24 -0
- package/dist/harnesses/register-defaults.d.ts.map +1 -0
- package/dist/harnesses/register-defaults.js +40 -0
- package/dist/harnesses/register-defaults.js.map +1 -0
- package/dist/harnesses/session-store.d.ts +201 -0
- package/dist/harnesses/session-store.d.ts.map +1 -0
- package/dist/harnesses/session-store.js +254 -0
- package/dist/harnesses/session-store.js.map +1 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/reflection/reflection.d.ts.map +1 -1
- package/dist/reflection/reflection.js +19 -4
- package/dist/reflection/reflection.js.map +1 -1
- package/dist/types/agent.d.ts +1253 -2
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/agent.js +418 -1
- package/dist/types/agent.js.map +1 -1
- package/dist/types/decorators.d.ts +10 -1
- package/dist/types/decorators.d.ts.map +1 -1
- package/dist/types/events.d.ts +26 -0
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/harnesses.d.ts +474 -0
- package/dist/types/harnesses.d.ts.map +1 -0
- package/dist/types/harnesses.js +2 -0
- package/dist/types/harnesses.js.map +1 -0
- package/dist/types/index.d.ts +9 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/providers.d.ts +691 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/providers.js +14 -0
- package/dist/types/providers.js.map +1 -0
- package/dist/types/restart.d.ts +132 -0
- package/dist/types/restart.d.ts.map +1 -0
- package/dist/types/restart.js +2 -0
- package/dist/types/restart.js.map +1 -0
- package/dist/types/streaming.d.ts +194 -0
- package/dist/types/streaming.d.ts.map +1 -0
- package/dist/types/streaming.js +67 -0
- package/dist/types/streaming.js.map +1 -0
- package/dist/types/workflow-context.d.ts +137 -1
- package/dist/types/workflow-context.d.ts.map +1 -1
- package/dist/utils/agent-validation.d.ts +88 -0
- package/dist/utils/agent-validation.d.ts.map +1 -0
- package/dist/utils/agent-validation.js +87 -0
- package/dist/utils/agent-validation.js.map +1 -0
- package/dist/utils/delay.d.ts +7 -0
- package/dist/utils/delay.d.ts.map +1 -0
- package/dist/utils/delay.js +9 -0
- package/dist/utils/delay.js.map +1 -0
- package/dist/utils/harness-config.d.ts +180 -0
- package/dist/utils/harness-config.d.ts.map +1 -0
- package/dist/utils/harness-config.js +311 -0
- package/dist/utils/harness-config.js.map +1 -0
- package/dist/utils/index.d.ts +9 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +8 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/model-spec.d.ts +110 -0
- package/dist/utils/model-spec.d.ts.map +1 -0
- package/dist/utils/model-spec.js +149 -0
- package/dist/utils/model-spec.js.map +1 -0
- package/dist/utils/provider-config.d.ts +10 -0
- package/dist/utils/provider-config.d.ts.map +1 -0
- package/dist/utils/provider-config.js +10 -0
- package/dist/utils/provider-config.js.map +1 -0
- package/dist/utils/restart-analysis.d.ts +202 -0
- package/dist/utils/restart-analysis.d.ts.map +1 -0
- package/dist/utils/restart-analysis.js +426 -0
- package/dist/utils/restart-analysis.js.map +1 -0
- package/dist/utils/session-serialization.d.ts +118 -0
- package/dist/utils/session-serialization.d.ts.map +1 -0
- package/dist/utils/session-serialization.js +217 -0
- package/dist/utils/session-serialization.js.map +1 -0
- package/package.json +31 -5
- package/CHANGELOG.md +0 -188
- package/dist/__tests__/adversarial/attachChild-performance.test.d.ts +0 -16
- package/dist/__tests__/adversarial/attachChild-performance.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/attachChild-performance.test.js +0 -187
- package/dist/__tests__/adversarial/attachChild-performance.test.js.map +0 -1
- package/dist/__tests__/adversarial/circular-reference.test.d.ts +0 -13
- package/dist/__tests__/adversarial/circular-reference.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/circular-reference.test.js +0 -92
- package/dist/__tests__/adversarial/circular-reference.test.js.map +0 -1
- package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts +0 -16
- package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/complex-circular-reference.test.js +0 -127
- package/dist/__tests__/adversarial/complex-circular-reference.test.js.map +0 -1
- package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts +0 -21
- package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/concurrent-task-failures.test.js +0 -667
- package/dist/__tests__/adversarial/concurrent-task-failures.test.js.map +0 -1
- package/dist/__tests__/adversarial/deep-analysis.test.d.ts +0 -6
- package/dist/__tests__/adversarial/deep-analysis.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/deep-analysis.test.js +0 -877
- package/dist/__tests__/adversarial/deep-analysis.test.js.map +0 -1
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts +0 -13
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js +0 -186
- package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js.map +0 -1
- package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts +0 -6
- package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/e2e-prd-validation.test.js +0 -626
- package/dist/__tests__/adversarial/e2e-prd-validation.test.js.map +0 -1
- package/dist/__tests__/adversarial/edge-case.test.d.ts +0 -6
- package/dist/__tests__/adversarial/edge-case.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/edge-case.test.js +0 -857
- package/dist/__tests__/adversarial/edge-case.test.js.map +0 -1
- package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts +0 -20
- package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/error-merge-strategy.test.js +0 -907
- package/dist/__tests__/adversarial/error-merge-strategy.test.js.map +0 -1
- package/dist/__tests__/adversarial/incremental-performance.test.d.ts +0 -2
- package/dist/__tests__/adversarial/incremental-performance.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/incremental-performance.test.js +0 -113
- package/dist/__tests__/adversarial/incremental-performance.test.js.map +0 -1
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts +0 -22
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js +0 -383
- package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js.map +0 -1
- package/dist/__tests__/adversarial/observer-propagation.test.d.ts +0 -21
- package/dist/__tests__/adversarial/observer-propagation.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/observer-propagation.test.js +0 -404
- package/dist/__tests__/adversarial/observer-propagation.test.js.map +0 -1
- package/dist/__tests__/adversarial/parent-validation.test.d.ts +0 -13
- package/dist/__tests__/adversarial/parent-validation.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/parent-validation.test.js +0 -128
- package/dist/__tests__/adversarial/parent-validation.test.js.map +0 -1
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts +0 -20
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.js +0 -482
- package/dist/__tests__/adversarial/prd-12-2-compliance.test.js.map +0 -1
- package/dist/__tests__/adversarial/prd-compliance.test.d.ts +0 -6
- package/dist/__tests__/adversarial/prd-compliance.test.d.ts.map +0 -1
- package/dist/__tests__/adversarial/prd-compliance.test.js +0 -886
- package/dist/__tests__/adversarial/prd-compliance.test.js.map +0 -1
- package/dist/__tests__/compatibility/backward-compatibility.test.d.ts +0 -22
- package/dist/__tests__/compatibility/backward-compatibility.test.d.ts.map +0 -1
- package/dist/__tests__/compatibility/backward-compatibility.test.js +0 -1843
- package/dist/__tests__/compatibility/backward-compatibility.test.js.map +0 -1
- package/dist/__tests__/helpers/index.d.ts +0 -10
- package/dist/__tests__/helpers/index.d.ts.map +0 -1
- package/dist/__tests__/helpers/index.js +0 -10
- package/dist/__tests__/helpers/index.js.map +0 -1
- package/dist/__tests__/helpers/tree-verification.d.ts +0 -90
- package/dist/__tests__/helpers/tree-verification.d.ts.map +0 -1
- package/dist/__tests__/helpers/tree-verification.js +0 -202
- package/dist/__tests__/helpers/tree-verification.js.map +0 -1
- package/dist/__tests__/integration/agent-workflow.test.d.ts +0 -2
- package/dist/__tests__/integration/agent-workflow.test.d.ts.map +0 -1
- package/dist/__tests__/integration/agent-workflow.test.js +0 -256
- package/dist/__tests__/integration/agent-workflow.test.js.map +0 -1
- package/dist/__tests__/integration/bidirectional-consistency.test.d.ts +0 -14
- package/dist/__tests__/integration/bidirectional-consistency.test.d.ts.map +0 -1
- package/dist/__tests__/integration/bidirectional-consistency.test.js +0 -668
- package/dist/__tests__/integration/bidirectional-consistency.test.js.map +0 -1
- package/dist/__tests__/integration/observer-logging.test.d.ts +0 -2
- package/dist/__tests__/integration/observer-logging.test.d.ts.map +0 -1
- package/dist/__tests__/integration/observer-logging.test.js +0 -517
- package/dist/__tests__/integration/observer-logging.test.js.map +0 -1
- package/dist/__tests__/integration/tree-mirroring.test.d.ts +0 -2
- package/dist/__tests__/integration/tree-mirroring.test.d.ts.map +0 -1
- package/dist/__tests__/integration/tree-mirroring.test.js +0 -117
- package/dist/__tests__/integration/tree-mirroring.test.js.map +0 -1
- package/dist/__tests__/integration/workflow-reparenting.test.d.ts +0 -12
- package/dist/__tests__/integration/workflow-reparenting.test.d.ts.map +0 -1
- package/dist/__tests__/integration/workflow-reparenting.test.js +0 -239
- package/dist/__tests__/integration/workflow-reparenting.test.js.map +0 -1
- package/dist/__tests__/unit/agent.test.d.ts +0 -2
- package/dist/__tests__/unit/agent.test.d.ts.map +0 -1
- package/dist/__tests__/unit/agent.test.js +0 -143
- package/dist/__tests__/unit/agent.test.js.map +0 -1
- package/dist/__tests__/unit/cache-key.test.d.ts +0 -5
- package/dist/__tests__/unit/cache-key.test.d.ts.map +0 -1
- package/dist/__tests__/unit/cache-key.test.js +0 -145
- package/dist/__tests__/unit/cache-key.test.js.map +0 -1
- package/dist/__tests__/unit/cache.test.d.ts +0 -5
- package/dist/__tests__/unit/cache.test.d.ts.map +0 -1
- package/dist/__tests__/unit/cache.test.js +0 -132
- package/dist/__tests__/unit/cache.test.js.map +0 -1
- package/dist/__tests__/unit/context.test.d.ts +0 -2
- package/dist/__tests__/unit/context.test.d.ts.map +0 -1
- package/dist/__tests__/unit/context.test.js +0 -220
- package/dist/__tests__/unit/context.test.js.map +0 -1
- package/dist/__tests__/unit/decorators.test.d.ts +0 -2
- package/dist/__tests__/unit/decorators.test.d.ts.map +0 -1
- package/dist/__tests__/unit/decorators.test.js +0 -162
- package/dist/__tests__/unit/decorators.test.js.map +0 -1
- package/dist/__tests__/unit/introspection-tools.test.d.ts +0 -5
- package/dist/__tests__/unit/introspection-tools.test.d.ts.map +0 -1
- package/dist/__tests__/unit/introspection-tools.test.js +0 -191
- package/dist/__tests__/unit/introspection-tools.test.js.map +0 -1
- package/dist/__tests__/unit/logger.test.d.ts +0 -2
- package/dist/__tests__/unit/logger.test.d.ts.map +0 -1
- package/dist/__tests__/unit/logger.test.js +0 -241
- package/dist/__tests__/unit/logger.test.js.map +0 -1
- package/dist/__tests__/unit/observable.test.d.ts +0 -2
- package/dist/__tests__/unit/observable.test.d.ts.map +0 -1
- package/dist/__tests__/unit/observable.test.js +0 -251
- package/dist/__tests__/unit/observable.test.js.map +0 -1
- package/dist/__tests__/unit/prompt.test.d.ts +0 -2
- package/dist/__tests__/unit/prompt.test.d.ts.map +0 -1
- package/dist/__tests__/unit/prompt.test.js +0 -113
- package/dist/__tests__/unit/prompt.test.js.map +0 -1
- package/dist/__tests__/unit/reflection.test.d.ts +0 -5
- package/dist/__tests__/unit/reflection.test.d.ts.map +0 -1
- package/dist/__tests__/unit/reflection.test.js +0 -160
- package/dist/__tests__/unit/reflection.test.js.map +0 -1
- package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts +0 -2
- package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts.map +0 -1
- package/dist/__tests__/unit/tree-debugger-incremental.test.js +0 -136
- package/dist/__tests__/unit/tree-debugger-incremental.test.js.map +0 -1
- package/dist/__tests__/unit/tree-debugger.test.d.ts +0 -2
- package/dist/__tests__/unit/tree-debugger.test.d.ts.map +0 -1
- package/dist/__tests__/unit/tree-debugger.test.js +0 -69
- package/dist/__tests__/unit/tree-debugger.test.js.map +0 -1
- package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts +0 -2
- package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts.map +0 -1
- package/dist/__tests__/unit/utils/workflow-error-utils.test.js +0 -154
- package/dist/__tests__/unit/utils/workflow-error-utils.test.js.map +0 -1
- package/dist/__tests__/unit/workflow-detachChild.test.d.ts +0 -2
- package/dist/__tests__/unit/workflow-detachChild.test.d.ts.map +0 -1
- package/dist/__tests__/unit/workflow-detachChild.test.js +0 -76
- package/dist/__tests__/unit/workflow-detachChild.test.js.map +0 -1
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts +0 -2
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts.map +0 -1
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js +0 -122
- package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js.map +0 -1
- package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts +0 -2
- package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts.map +0 -1
- package/dist/__tests__/unit/workflow-isDescendantOf.test.js +0 -140
- package/dist/__tests__/unit/workflow-isDescendantOf.test.js.map +0 -1
- package/dist/__tests__/unit/workflow.test.d.ts +0 -2
- package/dist/__tests__/unit/workflow.test.d.ts.map +0 -1
- package/dist/__tests__/unit/workflow.test.js +0 -330
- package/dist/__tests__/unit/workflow.test.js.map +0 -1
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
-
var useValue = arguments.length > 2;
|
|
3
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
-
}
|
|
6
|
-
return useValue ? value : void 0;
|
|
7
|
-
};
|
|
8
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
-
var _, done = false;
|
|
14
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
-
var context = {};
|
|
16
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
-
if (kind === "accessor") {
|
|
21
|
-
if (result === void 0) continue;
|
|
22
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
-
}
|
|
27
|
-
else if (_ = accept(result)) {
|
|
28
|
-
if (kind === "field") initializers.unshift(_);
|
|
29
|
-
else descriptor[key] = _;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
-
done = true;
|
|
34
|
-
};
|
|
35
|
-
import { describe, it, expect } from 'vitest';
|
|
36
|
-
import { Workflow, Step, ObservedState, getObservedState } from '../../index.js';
|
|
37
|
-
describe('@Step decorator', () => {
|
|
38
|
-
let StepTestWorkflow = (() => {
|
|
39
|
-
let _classSuper = Workflow;
|
|
40
|
-
let _instanceExtraInitializers = [];
|
|
41
|
-
let _myStep_decorators;
|
|
42
|
-
return class StepTestWorkflow extends _classSuper {
|
|
43
|
-
static {
|
|
44
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
45
|
-
_myStep_decorators = [Step({ trackTiming: true })];
|
|
46
|
-
__esDecorate(this, null, _myStep_decorators, { kind: "method", name: "myStep", static: false, private: false, access: { has: obj => "myStep" in obj, get: obj => obj.myStep }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
47
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
48
|
-
}
|
|
49
|
-
stepCalled = (__runInitializers(this, _instanceExtraInitializers), false);
|
|
50
|
-
async myStep() {
|
|
51
|
-
this.stepCalled = true;
|
|
52
|
-
return 'step result';
|
|
53
|
-
}
|
|
54
|
-
async run() {
|
|
55
|
-
await this.myStep();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
})();
|
|
59
|
-
it('should execute the original method', async () => {
|
|
60
|
-
const wf = new StepTestWorkflow();
|
|
61
|
-
await wf.run();
|
|
62
|
-
expect(wf.stepCalled).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
it('should emit stepStart and stepEnd events', async () => {
|
|
65
|
-
const wf = new StepTestWorkflow();
|
|
66
|
-
const events = [];
|
|
67
|
-
wf.addObserver({
|
|
68
|
-
onLog: () => { },
|
|
69
|
-
onEvent: (e) => events.push(e),
|
|
70
|
-
onStateUpdated: () => { },
|
|
71
|
-
onTreeChanged: () => { },
|
|
72
|
-
});
|
|
73
|
-
await wf.run();
|
|
74
|
-
const startEvent = events.find((e) => e.type === 'stepStart');
|
|
75
|
-
const endEvent = events.find((e) => e.type === 'stepEnd');
|
|
76
|
-
expect(startEvent).toBeDefined();
|
|
77
|
-
expect(endEvent).toBeDefined();
|
|
78
|
-
if (endEvent?.type === 'stepEnd') {
|
|
79
|
-
expect(endEvent.duration).toBeGreaterThanOrEqual(0);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
it('should wrap errors in WorkflowError', async () => {
|
|
83
|
-
let FailingWorkflow = (() => {
|
|
84
|
-
let _classSuper = Workflow;
|
|
85
|
-
let _instanceExtraInitializers = [];
|
|
86
|
-
let _failingStep_decorators;
|
|
87
|
-
return class FailingWorkflow extends _classSuper {
|
|
88
|
-
static {
|
|
89
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
90
|
-
_failingStep_decorators = [Step()];
|
|
91
|
-
__esDecorate(this, null, _failingStep_decorators, { kind: "method", name: "failingStep", static: false, private: false, access: { has: obj => "failingStep" in obj, get: obj => obj.failingStep }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
92
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
93
|
-
}
|
|
94
|
-
async failingStep() {
|
|
95
|
-
throw new Error('Step failed');
|
|
96
|
-
}
|
|
97
|
-
async run() {
|
|
98
|
-
await this.failingStep();
|
|
99
|
-
}
|
|
100
|
-
constructor() {
|
|
101
|
-
super(...arguments);
|
|
102
|
-
__runInitializers(this, _instanceExtraInitializers);
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
})();
|
|
106
|
-
const wf = new FailingWorkflow();
|
|
107
|
-
await expect(wf.run()).rejects.toMatchObject({
|
|
108
|
-
message: 'Step failed',
|
|
109
|
-
workflowId: wf.id,
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
describe('@ObservedState decorator', () => {
|
|
114
|
-
let StateTestWorkflow = (() => {
|
|
115
|
-
let _classSuper = Workflow;
|
|
116
|
-
let _publicField_decorators;
|
|
117
|
-
let _publicField_initializers = [];
|
|
118
|
-
let _publicField_extraInitializers = [];
|
|
119
|
-
let _secretField_decorators;
|
|
120
|
-
let _secretField_initializers = [];
|
|
121
|
-
let _secretField_extraInitializers = [];
|
|
122
|
-
let _hiddenField_decorators;
|
|
123
|
-
let _hiddenField_initializers = [];
|
|
124
|
-
let _hiddenField_extraInitializers = [];
|
|
125
|
-
return class StateTestWorkflow extends _classSuper {
|
|
126
|
-
static {
|
|
127
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
128
|
-
_publicField_decorators = [ObservedState()];
|
|
129
|
-
_secretField_decorators = [ObservedState({ redact: true })];
|
|
130
|
-
_hiddenField_decorators = [ObservedState({ hidden: true })];
|
|
131
|
-
__esDecorate(null, null, _publicField_decorators, { kind: "field", name: "publicField", static: false, private: false, access: { has: obj => "publicField" in obj, get: obj => obj.publicField, set: (obj, value) => { obj.publicField = value; } }, metadata: _metadata }, _publicField_initializers, _publicField_extraInitializers);
|
|
132
|
-
__esDecorate(null, null, _secretField_decorators, { kind: "field", name: "secretField", static: false, private: false, access: { has: obj => "secretField" in obj, get: obj => obj.secretField, set: (obj, value) => { obj.secretField = value; } }, metadata: _metadata }, _secretField_initializers, _secretField_extraInitializers);
|
|
133
|
-
__esDecorate(null, null, _hiddenField_decorators, { kind: "field", name: "hiddenField", static: false, private: false, access: { has: obj => "hiddenField" in obj, get: obj => obj.hiddenField, set: (obj, value) => { obj.hiddenField = value; } }, metadata: _metadata }, _hiddenField_initializers, _hiddenField_extraInitializers);
|
|
134
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
135
|
-
}
|
|
136
|
-
publicField = __runInitializers(this, _publicField_initializers, 'public');
|
|
137
|
-
secretField = (__runInitializers(this, _publicField_extraInitializers), __runInitializers(this, _secretField_initializers, 'secret'));
|
|
138
|
-
hiddenField = (__runInitializers(this, _secretField_extraInitializers), __runInitializers(this, _hiddenField_initializers, 'hidden'));
|
|
139
|
-
async run() { }
|
|
140
|
-
constructor() {
|
|
141
|
-
super(...arguments);
|
|
142
|
-
__runInitializers(this, _hiddenField_extraInitializers);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
})();
|
|
146
|
-
it('should include public fields in snapshot', () => {
|
|
147
|
-
const wf = new StateTestWorkflow();
|
|
148
|
-
const state = getObservedState(wf);
|
|
149
|
-
expect(state.publicField).toBe('public');
|
|
150
|
-
});
|
|
151
|
-
it('should redact secret fields', () => {
|
|
152
|
-
const wf = new StateTestWorkflow();
|
|
153
|
-
const state = getObservedState(wf);
|
|
154
|
-
expect(state.secretField).toBe('***');
|
|
155
|
-
});
|
|
156
|
-
it('should exclude hidden fields', () => {
|
|
157
|
-
const wf = new StateTestWorkflow();
|
|
158
|
-
const state = getObservedState(wf);
|
|
159
|
-
expect('hiddenField' in state).toBe(false);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
//# sourceMappingURL=decorators.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/decorators.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAQ,aAAa,EAAE,gBAAgB,EAAmC,MAAM,gBAAgB,CAAC;AAExH,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;QACzB,gBAAgB;0BAAS,QAAQ;;;qBAAjC,gBAAiB,SAAQ,WAAQ;;;sCAGpC,IAAI,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;gBAC5B,qKAAM,MAAM,6DAGX;;;YAND,UAAU,IADN,mDAAgB,EACP,KAAK,EAAC;YAGnB,KAAK,CAAC,MAAM;gBACV,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;gBACvB,OAAO,aAAa,CAAC;YACvB,CAAC;YAED,KAAK,CAAC,GAAG;gBACP,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;YACtB,CAAC;;;IAGH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,EAAE,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAClC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC;QACf,MAAM,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,EAAE,GAAG,IAAI,gBAAgB,EAAE,CAAC;QAClC,MAAM,MAAM,GAAoB,EAAE,CAAC;QAEnC,EAAE,CAAC,WAAW,CAAC;YACb,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;YACf,OAAO,EAA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,iBAAiB,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACnC,MAAM,CAAC,aAAa,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"introspection-tools.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/introspection-tools.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for introspection tools
|
|
3
|
-
*/
|
|
4
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
5
|
-
import { INTROSPECTION_TOOLS, handleInspectCurrentNode, handleReadAncestorChain, handleListSiblingsChildren, handleInspectPriorOutputs, handleInspectCacheStatus, handleRequestSpawnWorkflow, executeIntrospectionTool, } from '../../tools/introspection.js';
|
|
6
|
-
import { runInContext } from '../../core/context.js';
|
|
7
|
-
import { defaultCache } from '../../cache/cache.js';
|
|
8
|
-
describe('Introspection Tools', () => {
|
|
9
|
-
describe('INTROSPECTION_TOOLS', () => {
|
|
10
|
-
it('should export 6 tools', () => {
|
|
11
|
-
expect(INTROSPECTION_TOOLS).toHaveLength(6);
|
|
12
|
-
});
|
|
13
|
-
it('should have valid tool definitions', () => {
|
|
14
|
-
for (const tool of INTROSPECTION_TOOLS) {
|
|
15
|
-
expect(tool.name).toBeDefined();
|
|
16
|
-
expect(tool.description).toBeDefined();
|
|
17
|
-
expect(tool.input_schema).toBeDefined();
|
|
18
|
-
expect(tool.input_schema.type).toBe('object');
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
it('should include all expected tool names', () => {
|
|
22
|
-
const names = INTROSPECTION_TOOLS.map((t) => t.name);
|
|
23
|
-
expect(names).toContain('inspect_current_node');
|
|
24
|
-
expect(names).toContain('read_ancestor_chain');
|
|
25
|
-
expect(names).toContain('list_siblings_children');
|
|
26
|
-
expect(names).toContain('inspect_prior_outputs');
|
|
27
|
-
expect(names).toContain('inspect_cache_status');
|
|
28
|
-
expect(names).toContain('request_spawn_workflow');
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
describe('handlers', () => {
|
|
32
|
-
const createTestNode = (id, name, parent = null) => ({
|
|
33
|
-
id,
|
|
34
|
-
name,
|
|
35
|
-
parent,
|
|
36
|
-
children: [],
|
|
37
|
-
status: 'running',
|
|
38
|
-
logs: [],
|
|
39
|
-
events: [],
|
|
40
|
-
stateSnapshot: null,
|
|
41
|
-
});
|
|
42
|
-
const createContext = (node) => ({
|
|
43
|
-
workflowNode: node,
|
|
44
|
-
emitEvent: () => { },
|
|
45
|
-
workflowId: 'test-workflow',
|
|
46
|
-
});
|
|
47
|
-
describe('handleInspectCurrentNode', () => {
|
|
48
|
-
it('should throw when not in workflow context', async () => {
|
|
49
|
-
await expect(handleInspectCurrentNode()).rejects.toThrow('Not in workflow context');
|
|
50
|
-
});
|
|
51
|
-
it('should return current node info', async () => {
|
|
52
|
-
const parent = createTestNode('parent-1', 'Parent');
|
|
53
|
-
const node = createTestNode('child-1', 'Child', parent);
|
|
54
|
-
parent.children.push(node);
|
|
55
|
-
const result = await runInContext(createContext(node), () => handleInspectCurrentNode());
|
|
56
|
-
expect(result.id).toBe('child-1');
|
|
57
|
-
expect(result.name).toBe('Child');
|
|
58
|
-
expect(result.status).toBe('running');
|
|
59
|
-
expect(result.parentId).toBe('parent-1');
|
|
60
|
-
expect(result.parentName).toBe('Parent');
|
|
61
|
-
expect(result.depth).toBe(1);
|
|
62
|
-
});
|
|
63
|
-
it('should handle root node (no parent)', async () => {
|
|
64
|
-
const node = createTestNode('root-1', 'Root');
|
|
65
|
-
const result = await runInContext(createContext(node), () => handleInspectCurrentNode());
|
|
66
|
-
expect(result.parentId).toBeUndefined();
|
|
67
|
-
expect(result.depth).toBe(0);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('handleReadAncestorChain', () => {
|
|
71
|
-
it('should throw when not in workflow context', async () => {
|
|
72
|
-
await expect(handleReadAncestorChain({})).rejects.toThrow('Not in workflow context');
|
|
73
|
-
});
|
|
74
|
-
it('should return ancestor chain', async () => {
|
|
75
|
-
const root = createTestNode('root-1', 'Root');
|
|
76
|
-
const parent = createTestNode('parent-1', 'Parent', root);
|
|
77
|
-
root.children.push(parent);
|
|
78
|
-
const child = createTestNode('child-1', 'Child', parent);
|
|
79
|
-
parent.children.push(child);
|
|
80
|
-
const result = await runInContext(createContext(child), () => handleReadAncestorChain({}));
|
|
81
|
-
expect(result.ancestors).toHaveLength(2);
|
|
82
|
-
expect(result.ancestors[0].id).toBe('parent-1');
|
|
83
|
-
expect(result.ancestors[1].id).toBe('root-1');
|
|
84
|
-
expect(result.totalDepth).toBe(2);
|
|
85
|
-
});
|
|
86
|
-
it('should respect maxDepth limit', async () => {
|
|
87
|
-
const root = createTestNode('root-1', 'Root');
|
|
88
|
-
const parent = createTestNode('parent-1', 'Parent', root);
|
|
89
|
-
root.children.push(parent);
|
|
90
|
-
const child = createTestNode('child-1', 'Child', parent);
|
|
91
|
-
parent.children.push(child);
|
|
92
|
-
const result = await runInContext(createContext(child), () => handleReadAncestorChain({ maxDepth: 1 }));
|
|
93
|
-
expect(result.ancestors).toHaveLength(1);
|
|
94
|
-
expect(result.ancestors[0].id).toBe('parent-1');
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
describe('handleListSiblingsChildren', () => {
|
|
98
|
-
it('should throw when not in workflow context', async () => {
|
|
99
|
-
await expect(handleListSiblingsChildren({ type: 'children' })).rejects.toThrow('Not in workflow context');
|
|
100
|
-
});
|
|
101
|
-
it('should return children', async () => {
|
|
102
|
-
const parent = createTestNode('parent-1', 'Parent');
|
|
103
|
-
const child1 = createTestNode('child-1', 'Child 1', parent);
|
|
104
|
-
const child2 = createTestNode('child-2', 'Child 2', parent);
|
|
105
|
-
parent.children.push(child1, child2);
|
|
106
|
-
const result = await runInContext(createContext(parent), () => handleListSiblingsChildren({ type: 'children' }));
|
|
107
|
-
expect(result.type).toBe('children');
|
|
108
|
-
expect(result.nodes).toHaveLength(2);
|
|
109
|
-
});
|
|
110
|
-
it('should return siblings (excluding self)', async () => {
|
|
111
|
-
const parent = createTestNode('parent-1', 'Parent');
|
|
112
|
-
const child1 = createTestNode('child-1', 'Child 1', parent);
|
|
113
|
-
const child2 = createTestNode('child-2', 'Child 2', parent);
|
|
114
|
-
parent.children.push(child1, child2);
|
|
115
|
-
const result = await runInContext(createContext(child1), () => handleListSiblingsChildren({ type: 'siblings' }));
|
|
116
|
-
expect(result.type).toBe('siblings');
|
|
117
|
-
expect(result.nodes).toHaveLength(1);
|
|
118
|
-
expect(result.nodes[0].id).toBe('child-2');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
describe('handleInspectPriorOutputs', () => {
|
|
122
|
-
it('should throw when not in workflow context', async () => {
|
|
123
|
-
await expect(handleInspectPriorOutputs({})).rejects.toThrow('Not in workflow context');
|
|
124
|
-
});
|
|
125
|
-
it('should return completed sibling outputs', async () => {
|
|
126
|
-
const parent = createTestNode('parent-1', 'Parent');
|
|
127
|
-
const completed = createTestNode('completed-1', 'Completed', parent);
|
|
128
|
-
completed.status = 'completed';
|
|
129
|
-
// Add a valid workflow event for testing
|
|
130
|
-
completed.events.push({
|
|
131
|
-
type: 'stepEnd',
|
|
132
|
-
node: completed,
|
|
133
|
-
step: 'test-step',
|
|
134
|
-
duration: 100,
|
|
135
|
-
}); // Cast to avoid strict type checking in tests
|
|
136
|
-
const current = createTestNode('current-1', 'Current', parent);
|
|
137
|
-
parent.children.push(completed, current);
|
|
138
|
-
const result = await runInContext(createContext(current), () => handleInspectPriorOutputs({}));
|
|
139
|
-
expect(result).toHaveLength(1);
|
|
140
|
-
expect(result[0].nodeId).toBe('completed-1');
|
|
141
|
-
expect(result[0].status).toBe('completed');
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
describe('handleInspectCacheStatus', () => {
|
|
145
|
-
beforeEach(async () => {
|
|
146
|
-
await defaultCache.clear();
|
|
147
|
-
});
|
|
148
|
-
it('should return false for missing cache key', async () => {
|
|
149
|
-
const result = await handleInspectCacheStatus({
|
|
150
|
-
promptHash: 'nonexistent-key',
|
|
151
|
-
});
|
|
152
|
-
expect(result.exists).toBe(false);
|
|
153
|
-
expect(result.key).toBe('nonexistent-key');
|
|
154
|
-
});
|
|
155
|
-
it('should return true for existing cache key', async () => {
|
|
156
|
-
await defaultCache.set('test-key', { data: 'test' });
|
|
157
|
-
const result = await handleInspectCacheStatus({ promptHash: 'test-key' });
|
|
158
|
-
expect(result.exists).toBe(true);
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
describe('handleRequestSpawnWorkflow', () => {
|
|
162
|
-
it('should throw when not in workflow context', async () => {
|
|
163
|
-
await expect(handleRequestSpawnWorkflow({ name: 'Test', description: 'Test workflow' })).rejects.toThrow('Not in workflow context');
|
|
164
|
-
});
|
|
165
|
-
it('should return spawn request', async () => {
|
|
166
|
-
const node = createTestNode('node-1', 'Node');
|
|
167
|
-
const result = await runInContext(createContext(node), () => handleRequestSpawnWorkflow({
|
|
168
|
-
name: 'NewWorkflow',
|
|
169
|
-
description: 'A new workflow',
|
|
170
|
-
}));
|
|
171
|
-
expect(result.name).toBe('NewWorkflow');
|
|
172
|
-
expect(result.description).toBe('A new workflow');
|
|
173
|
-
expect(result.requestId).toMatch(/^spawn-/);
|
|
174
|
-
expect(result.status).toBe('pending');
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
describe('executeIntrospectionTool', () => {
|
|
179
|
-
it('should execute tool by name', async () => {
|
|
180
|
-
await defaultCache.set('cache-test', 'value');
|
|
181
|
-
const result = await executeIntrospectionTool('inspect_cache_status', {
|
|
182
|
-
promptHash: 'cache-test',
|
|
183
|
-
});
|
|
184
|
-
expect(result).toMatchObject({ exists: true, key: 'cache-test' });
|
|
185
|
-
});
|
|
186
|
-
it('should throw for unknown tool', async () => {
|
|
187
|
-
await expect(executeIntrospectionTool('unknown_tool', {})).rejects.toThrow('Unknown introspection tool');
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
//# sourceMappingURL=introspection-tools.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"introspection-tools.test.js","sourceRoot":"","sources":["../../../src/__tests__/unit/introspection-tools.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAa,MAAM,QAAQ,CAAC;AACrE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,YAAY,EAA8B,MAAM,uBAAuB,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;QACnC,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;YAC/B,MAAM,CAAC,mBAAmB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,KAAK,MAAM,IAAI,IAAI,mBAAmB,EAAE,CAAC;gBACvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;gBACvC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;gBACxC,MAAM,C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MAAM,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;YAC7C,MAAM,MAAM,CACV,wBAAwB,CAAC,cAAc,EAAE,EAAE,CAAC,CAC7C,CAAC,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/unit/logger.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { Workflow } from '../../core/workflow';
|
|
3
|
-
describe('WorkflowLogger.child()', () => {
|
|
4
|
-
describe('with Partial<LogEntry> containing parentLogId', () => {
|
|
5
|
-
it('should create child logger with parentLogId from Partial<LogEntry>', async () => {
|
|
6
|
-
class TestWorkflow extends Workflow {
|
|
7
|
-
async run() {
|
|
8
|
-
const childLogger = this.logger.child({ parentLogId: 'parent-123' });
|
|
9
|
-
childLogger.info('Child message');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const workflow = new TestWorkflow();
|
|
13
|
-
await workflow.run();
|
|
14
|
-
expect(workflow.node.logs.length).toBe(1);
|
|
15
|
-
expect(workflow.node.logs[0].parentLogId).toBe('parent-123');
|
|
16
|
-
expect(workflow.node.logs[0].message).toBe('Child message');
|
|
17
|
-
});
|
|
18
|
-
it('should handle parentLogId with special characters', async () => {
|
|
19
|
-
class TestWorkflow extends Workflow {
|
|
20
|
-
async run() {
|
|
21
|
-
const childLogger = this.logger.child({ parentLogId: 'parent-with-dashes-and_underscores' });
|
|
22
|
-
childLogger.info('Test');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const workflow = new TestWorkflow();
|
|
26
|
-
await workflow.run();
|
|
27
|
-
expect(workflow.node.logs[0].parentLogId).toBe('parent-with-dashes-and_underscores');
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('with Partial<LogEntry> containing id field', () => {
|
|
31
|
-
it('should not use id field as parentLogId', async () => {
|
|
32
|
-
class TestWorkflow extends Workflow {
|
|
33
|
-
async run() {
|
|
34
|
-
// id field should NOT be used as parentLogId
|
|
35
|
-
const childLogger = this.logger.child({ id: 'custom-id' });
|
|
36
|
-
childLogger.info('Test message');
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const workflow = new TestWorkflow();
|
|
40
|
-
await workflow.run();
|
|
41
|
-
// parentLogId is undefined because implementation only checks input.parentLogId
|
|
42
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined();
|
|
43
|
-
expect(workflow.node.logs[0].message).toBe('Test message');
|
|
44
|
-
});
|
|
45
|
-
it('should handle both id and parentLogId fields', async () => {
|
|
46
|
-
class TestWorkflow extends Workflow {
|
|
47
|
-
async run() {
|
|
48
|
-
// parentLogId should be used, not id
|
|
49
|
-
const childLogger = this.logger.child({ id: 'custom-id', parentLogId: 'correct-parent' });
|
|
50
|
-
childLogger.info('Test');
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const workflow = new TestWorkflow();
|
|
54
|
-
await workflow.run();
|
|
55
|
-
expect(workflow.node.logs[0].parentLogId).toBe('correct-parent');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
describe('with empty Partial<LogEntry>', () => {
|
|
59
|
-
it('should create child logger with undefined parentLogId from empty object', async () => {
|
|
60
|
-
class TestWorkflow extends Workflow {
|
|
61
|
-
async run() {
|
|
62
|
-
const childLogger = this.logger.child({});
|
|
63
|
-
childLogger.info('Child log with empty parent metadata');
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const workflow = new TestWorkflow();
|
|
67
|
-
await workflow.run();
|
|
68
|
-
expect(workflow.node.logs.length).toBe(1);
|
|
69
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined();
|
|
70
|
-
expect(workflow.node.logs[0].message).toBe('Child log with empty parent metadata');
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
describe('with string parameter (backward compatibility)', () => {
|
|
74
|
-
it('should create child logger with parentLogId from string', async () => {
|
|
75
|
-
class TestWorkflow extends Workflow {
|
|
76
|
-
async run() {
|
|
77
|
-
const childLogger = this.logger.child('parent-id-123');
|
|
78
|
-
childLogger.info('Child message');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const workflow = new TestWorkflow();
|
|
82
|
-
await workflow.run();
|
|
83
|
-
expect(workflow.node.logs.length).toBe(1);
|
|
84
|
-
expect(workflow.node.logs[0].parentLogId).toBe('parent-id-123');
|
|
85
|
-
expect(workflow.node.logs[0].message).toBe('Child message');
|
|
86
|
-
});
|
|
87
|
-
it('should create child logger with parentLogId from string containing parentLogId', async () => {
|
|
88
|
-
class TestWorkflow extends Workflow {
|
|
89
|
-
async run() {
|
|
90
|
-
// String value is used directly as parentLogId
|
|
91
|
-
const childLogger = this.logger.child('log-abc-123');
|
|
92
|
-
childLogger.warn('Warning message');
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
const workflow = new TestWorkflow();
|
|
96
|
-
await workflow.run();
|
|
97
|
-
expect(workflow.node.logs[0].parentLogId).toBe('log-abc-123');
|
|
98
|
-
expect(workflow.node.logs[0].level).toBe('warn');
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
describe('with empty string', () => {
|
|
102
|
-
it('should create child logger with undefined parentLogId from empty string', async () => {
|
|
103
|
-
class TestWorkflow extends Workflow {
|
|
104
|
-
async run() {
|
|
105
|
-
const childLogger = this.logger.child('');
|
|
106
|
-
childLogger.info('Child log with empty parent');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const workflow = new TestWorkflow();
|
|
110
|
-
await workflow.run();
|
|
111
|
-
expect(workflow.node.logs.length).toBe(1);
|
|
112
|
-
// Empty string is falsy, so parentLogId becomes undefined in log entry
|
|
113
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined();
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('child logger with different log levels', () => {
|
|
117
|
-
it.each([
|
|
118
|
-
{ level: 'debug', method: 'debug' },
|
|
119
|
-
{ level: 'info', method: 'info' },
|
|
120
|
-
{ level: 'warn', method: 'warn' },
|
|
121
|
-
{ level: 'error', method: 'error' },
|
|
122
|
-
])('should log at $level level with child logger', async ({ level, method }) => {
|
|
123
|
-
class TestWorkflow extends Workflow {
|
|
124
|
-
async run() {
|
|
125
|
-
const childLogger = this.logger.child({ parentLogId: 'parent-123' });
|
|
126
|
-
childLogger[method](`Test ${level} message`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const workflow = new TestWorkflow();
|
|
130
|
-
await workflow.run();
|
|
131
|
-
expect(workflow.node.logs[0].level).toBe(level);
|
|
132
|
-
expect(workflow.node.logs[0].parentLogId).toBe('parent-123');
|
|
133
|
-
expect(workflow.node.logs[0].message).toBe(`Test ${level} message`);
|
|
134
|
-
});
|
|
135
|
-
it('should support logging with data parameter at all levels', async () => {
|
|
136
|
-
class TestWorkflow extends Workflow {
|
|
137
|
-
async run() {
|
|
138
|
-
const childLogger = this.logger.child({ parentLogId: 'parent-data' });
|
|
139
|
-
childLogger.debug('Debug message', { debugData: true });
|
|
140
|
-
childLogger.info('Info message', { infoData: 123 });
|
|
141
|
-
childLogger.warn('Warn message', { warnData: 'warning' });
|
|
142
|
-
childLogger.error('Error message', { errorData: { code: 500 } });
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const workflow = new TestWorkflow();
|
|
146
|
-
await workflow.run();
|
|
147
|
-
expect(workflow.node.logs.length).toBe(4);
|
|
148
|
-
expect(workflow.node.logs[0].data).toEqual({ debugData: true });
|
|
149
|
-
expect(workflow.node.logs[1].data).toEqual({ infoData: 123 });
|
|
150
|
-
expect(workflow.node.logs[2].data).toEqual({ warnData: 'warning' });
|
|
151
|
-
expect(workflow.node.logs[3].data).toEqual({ errorData: { code: 500 } });
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
describe('parent-child log hierarchy', () => {
|
|
155
|
-
it('should maintain parent-child relationship in log entries', async () => {
|
|
156
|
-
class TestWorkflow extends Workflow {
|
|
157
|
-
async run() {
|
|
158
|
-
// Log from parent logger
|
|
159
|
-
this.logger.info('Parent message');
|
|
160
|
-
// Get the parent log entry ID
|
|
161
|
-
const parentLogId = this.node.logs[0].id;
|
|
162
|
-
// Create child logger with that ID
|
|
163
|
-
const childLogger = this.logger.child({ parentLogId });
|
|
164
|
-
childLogger.info('Child message');
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
const workflow = new TestWorkflow();
|
|
168
|
-
await workflow.run();
|
|
169
|
-
// Verify hierarchy
|
|
170
|
-
expect(workflow.node.logs.length).toBe(2);
|
|
171
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined(); // Root log
|
|
172
|
-
expect(workflow.node.logs[1].parentLogId).toBe(workflow.node.logs[0].id); // Child log
|
|
173
|
-
expect(workflow.node.logs[0].message).toBe('Parent message');
|
|
174
|
-
expect(workflow.node.logs[1].message).toBe('Child message');
|
|
175
|
-
});
|
|
176
|
-
it('should support multi-level nesting with child loggers', async () => {
|
|
177
|
-
class TestWorkflow extends Workflow {
|
|
178
|
-
async run() {
|
|
179
|
-
// Root log
|
|
180
|
-
this.logger.info('Root message');
|
|
181
|
-
const rootLogId = this.node.logs[0].id;
|
|
182
|
-
// First level child
|
|
183
|
-
const child1 = this.logger.child({ parentLogId: rootLogId });
|
|
184
|
-
child1.info('Level 1 child');
|
|
185
|
-
const level1LogId = this.node.logs[1].id;
|
|
186
|
-
// Second level child
|
|
187
|
-
const child2 = this.logger.child({ parentLogId: level1LogId });
|
|
188
|
-
child2.info('Level 2 child');
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const workflow = new TestWorkflow();
|
|
192
|
-
await workflow.run();
|
|
193
|
-
expect(workflow.node.logs.length).toBe(3);
|
|
194
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined();
|
|
195
|
-
expect(workflow.node.logs[1].parentLogId).toBe(workflow.node.logs[0].id);
|
|
196
|
-
expect(workflow.node.logs[2].parentLogId).toBe(workflow.node.logs[1].id);
|
|
197
|
-
});
|
|
198
|
-
it('should support string-based parent-child hierarchy', async () => {
|
|
199
|
-
class TestWorkflow extends Workflow {
|
|
200
|
-
async run() {
|
|
201
|
-
// Log from parent
|
|
202
|
-
this.logger.info('Parent log');
|
|
203
|
-
const parentLogId = this.node.logs[0].id;
|
|
204
|
-
// Create child using string parentLogId (backward compatibility)
|
|
205
|
-
const childLogger = this.logger.child(parentLogId);
|
|
206
|
-
childLogger.info('Child log');
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
const workflow = new TestWorkflow();
|
|
210
|
-
await workflow.run();
|
|
211
|
-
expect(workflow.node.logs.length).toBe(2);
|
|
212
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined();
|
|
213
|
-
expect(workflow.node.logs[1].parentLogId).toBe(workflow.node.logs[0].id);
|
|
214
|
-
});
|
|
215
|
-
it('should allow multiple child loggers from same parent', async () => {
|
|
216
|
-
class TestWorkflow extends Workflow {
|
|
217
|
-
async run() {
|
|
218
|
-
// Parent log
|
|
219
|
-
this.logger.info('Parent');
|
|
220
|
-
const parentLogId = this.node.logs[0].id;
|
|
221
|
-
// Multiple children from same parent
|
|
222
|
-
const child1 = this.logger.child({ parentLogId });
|
|
223
|
-
child1.info('First child');
|
|
224
|
-
const child2 = this.logger.child({ parentLogId });
|
|
225
|
-
child2.info('Second child');
|
|
226
|
-
const child3 = this.logger.child({ parentLogId });
|
|
227
|
-
child3.info('Third child');
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
const workflow = new TestWorkflow();
|
|
231
|
-
await workflow.run();
|
|
232
|
-
expect(workflow.node.logs.length).toBe(4);
|
|
233
|
-
expect(workflow.node.logs[0].parentLogId).toBeUndefined();
|
|
234
|
-
// All children should have the same parent
|
|
235
|
-
expect(workflow.node.logs[1].parentLogId).toBe(workflow.node.logs[0].id);
|
|
236
|
-
expect(workflow.node.logs[2].parentLogId).toBe(workflow.node.logs[0].id);
|
|
237
|
-
expect(workflow.node.logs[3].parentLogId).toBe(workflow.node.logs[0].id);
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
//# sourceMappingURL=logger.test.js.map
|