@agentick/core 0.0.1 → 0.1.9
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/dist/.tsbuildinfo.build +1 -1
- package/package.json +8 -3
- package/dist/.tsbuildinfo +0 -1
- package/dist/agent.d.ts +0 -32
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -26
- package/dist/agent.js.map +0 -1
- package/dist/aidk-instance.d.ts +0 -294
- package/dist/aidk-instance.d.ts.map +0 -1
- package/dist/aidk-instance.js +0 -340
- package/dist/aidk-instance.js.map +0 -1
- package/dist/compiler/content-block-registry.d.ts +0 -11
- package/dist/compiler/content-block-registry.d.ts.map +0 -1
- package/dist/compiler/content-block-registry.js +0 -312
- package/dist/compiler/content-block-registry.js.map +0 -1
- package/dist/compiler/extractors.d.ts +0 -68
- package/dist/compiler/extractors.d.ts.map +0 -1
- package/dist/compiler/extractors.js +0 -547
- package/dist/compiler/extractors.js.map +0 -1
- package/dist/compiler/fiber.d.ts +0 -61
- package/dist/compiler/fiber.d.ts.map +0 -1
- package/dist/compiler/fiber.js +0 -244
- package/dist/compiler/fiber.js.map +0 -1
- package/dist/component/tentickle-component.d.ts +0 -185
- package/dist/component/tentickle-component.d.ts.map +0 -1
- package/dist/component/tentickle-component.js +0 -182
- package/dist/component/tentickle-component.js.map +0 -1
- package/dist/core/channel-helpers.d.ts +0 -31
- package/dist/core/channel-helpers.d.ts.map +0 -1
- package/dist/core/channel-helpers.js +0 -62
- package/dist/core/channel-helpers.js.map +0 -1
- package/dist/core/channel.d.ts +0 -164
- package/dist/core/channel.d.ts.map +0 -1
- package/dist/core/channel.js +0 -199
- package/dist/core/channel.js.map +0 -1
- package/dist/core/context.d.ts +0 -412
- package/dist/core/context.d.ts.map +0 -1
- package/dist/core/context.js +0 -290
- package/dist/core/context.js.map +0 -1
- package/dist/core/event-buffer.d.ts +0 -212
- package/dist/core/event-buffer.d.ts.map +0 -1
- package/dist/core/event-buffer.js +0 -346
- package/dist/core/event-buffer.js.map +0 -1
- package/dist/core/execution-helpers.d.ts +0 -179
- package/dist/core/execution-helpers.d.ts.map +0 -1
- package/dist/core/execution-helpers.js +0 -212
- package/dist/core/execution-helpers.js.map +0 -1
- package/dist/core/execution-tracker.d.ts +0 -53
- package/dist/core/execution-tracker.d.ts.map +0 -1
- package/dist/core/execution-tracker.js +0 -309
- package/dist/core/execution-tracker.js.map +0 -1
- package/dist/core/index.d.ts +0 -58
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -58
- package/dist/core/index.js.map +0 -1
- package/dist/core/logger.d.ts +0 -341
- package/dist/core/logger.d.ts.map +0 -1
- package/dist/core/logger.js +0 -346
- package/dist/core/logger.js.map +0 -1
- package/dist/core/metrics-helpers.d.ts +0 -40
- package/dist/core/metrics-helpers.d.ts.map +0 -1
- package/dist/core/metrics-helpers.js +0 -72
- package/dist/core/metrics-helpers.js.map +0 -1
- package/dist/core/otel-provider.d.ts +0 -54
- package/dist/core/otel-provider.d.ts.map +0 -1
- package/dist/core/otel-provider.js +0 -107
- package/dist/core/otel-provider.js.map +0 -1
- package/dist/core/procedure-graph.d.ts +0 -136
- package/dist/core/procedure-graph.d.ts.map +0 -1
- package/dist/core/procedure-graph.js +0 -272
- package/dist/core/procedure-graph.js.map +0 -1
- package/dist/core/procedure.d.ts +0 -755
- package/dist/core/procedure.d.ts.map +0 -1
- package/dist/core/procedure.js +0 -899
- package/dist/core/procedure.js.map +0 -1
- package/dist/core/stream.d.ts +0 -106
- package/dist/core/stream.d.ts.map +0 -1
- package/dist/core/stream.js +0 -186
- package/dist/core/stream.js.map +0 -1
- package/dist/core/telemetry.d.ts +0 -182
- package/dist/core/telemetry.d.ts.map +0 -1
- package/dist/core/telemetry.js +0 -124
- package/dist/core/telemetry.js.map +0 -1
- package/dist/engine/execution-graph.d.ts +0 -104
- package/dist/engine/execution-graph.d.ts.map +0 -1
- package/dist/engine/execution-graph.js +0 -257
- package/dist/engine/execution-graph.js.map +0 -1
- package/dist/hooks/policy-context.d.ts.map +0 -1
- package/dist/jsx/components/agent.d.ts +0 -64
- package/dist/jsx/components/agent.d.ts.map +0 -1
- package/dist/jsx/components/agent.js +0 -80
- package/dist/jsx/components/agent.js.map +0 -1
- package/dist/model/simple-adapter.d.ts +0 -176
- package/dist/model/simple-adapter.d.ts.map +0 -1
- package/dist/model/simple-adapter.js +0 -264
- package/dist/model/simple-adapter.js.map +0 -1
- package/dist/state/boundary.d.ts +0 -347
- package/dist/state/boundary.d.ts.map +0 -1
- package/dist/state/boundary.js +0 -341
- package/dist/state/boundary.js.map +0 -1
- package/dist/state/context.d.ts +0 -138
- package/dist/state/context.d.ts.map +0 -1
- package/dist/state/context.js +0 -139
- package/dist/state/context.js.map +0 -1
- package/dist/state/hooks.d.ts +0 -798
- package/dist/state/hooks.d.ts.map +0 -1
- package/dist/state/hooks.js +0 -1437
- package/dist/state/hooks.js.map +0 -1
- package/dist/state/index.d.ts +0 -72
- package/dist/state/index.d.ts.map +0 -1
- package/dist/state/index.js +0 -73
- package/dist/state/index.js.map +0 -1
- package/dist/state/signal.d.ts +0 -223
- package/dist/state/signal.d.ts.map +0 -1
- package/dist/state/signal.js +0 -699
- package/dist/state/signal.js.map +0 -1
- package/dist/state/use-state.d.ts +0 -210
- package/dist/state/use-state.d.ts.map +0 -1
- package/dist/state/use-state.js +0 -327
- package/dist/state/use-state.js.map +0 -1
- package/dist/tentickle-instance.d.ts +0 -285
- package/dist/tentickle-instance.d.ts.map +0 -1
- package/dist/tentickle-instance.js +0 -700
- package/dist/tentickle-instance.js.map +0 -1
- package/dist/testing/test-model.d.ts +0 -132
- package/dist/testing/test-model.d.ts.map +0 -1
- package/dist/testing/test-model.js +0 -260
- package/dist/testing/test-model.js.map +0 -1
- package/dist/v2/reconciler/host-config.d.ts +0 -31
- package/dist/v2/reconciler/host-config.d.ts.map +0 -1
- package/dist/v2/reconciler/host-config.js +0 -197
- package/dist/v2/reconciler/host-config.js.map +0 -1
- package/dist/v2/reconciler/index.d.ts +0 -7
- package/dist/v2/reconciler/index.d.ts.map +0 -1
- package/dist/v2/reconciler/index.js +0 -7
- package/dist/v2/reconciler/index.js.map +0 -1
- package/dist/v2/reconciler/reconciler.d.ts +0 -39
- package/dist/v2/reconciler/reconciler.d.ts.map +0 -1
- package/dist/v2/reconciler/reconciler.js +0 -54
- package/dist/v2/reconciler/reconciler.js.map +0 -1
- package/dist/v2/reconciler/types.d.ts +0 -64
- package/dist/v2/reconciler/types.d.ts.map +0 -1
- package/dist/v2/reconciler/types.js +0 -20
- package/dist/v2/reconciler/types.js.map +0 -1
- package/dist/v2/renderers/index.d.ts +0 -7
- package/dist/v2/renderers/index.d.ts.map +0 -1
- package/dist/v2/renderers/index.js +0 -7
- package/dist/v2/renderers/index.js.map +0 -1
- package/dist/v2/renderers/markdown.d.ts +0 -16
- package/dist/v2/renderers/markdown.d.ts.map +0 -1
- package/dist/v2/renderers/markdown.js +0 -65
- package/dist/v2/renderers/markdown.js.map +0 -1
- package/dist/v2/renderers/types.d.ts +0 -26
- package/dist/v2/renderers/types.d.ts.map +0 -1
- package/dist/v2/renderers/types.js +0 -6
- package/dist/v2/renderers/types.js.map +0 -1
- package/dist/v2/renderers/xml.d.ts +0 -17
- package/dist/v2/renderers/xml.d.ts.map +0 -1
- package/dist/v2/renderers/xml.js +0 -73
- package/dist/v2/renderers/xml.js.map +0 -1
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { type ExecutionHandle, type ExecutionStatus, type ExecutionType, type ExecutionTreeNode } from "./execution-types";
|
|
2
|
-
/**
|
|
3
|
-
* Execution context stored in the graph
|
|
4
|
-
*/
|
|
5
|
-
interface ExecutionContext {
|
|
6
|
-
pid: string;
|
|
7
|
-
parentPid?: string;
|
|
8
|
-
rootPid: string;
|
|
9
|
-
type: ExecutionType;
|
|
10
|
-
status: ExecutionStatus;
|
|
11
|
-
startedAt: Date;
|
|
12
|
-
completedAt?: Date;
|
|
13
|
-
handle: ExecutionHandle;
|
|
14
|
-
error?: {
|
|
15
|
-
message: string;
|
|
16
|
-
stack?: string;
|
|
17
|
-
phase?: string;
|
|
18
|
-
};
|
|
19
|
-
metadata?: Record<string, unknown>;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Execution graph for tracking parent-child relationships
|
|
23
|
-
*/
|
|
24
|
-
export declare class ExecutionGraph {
|
|
25
|
-
private executions;
|
|
26
|
-
private executionsForStatus;
|
|
27
|
-
private executionsByType;
|
|
28
|
-
private childrenMap;
|
|
29
|
-
/**
|
|
30
|
-
* Register a new execution
|
|
31
|
-
*/
|
|
32
|
-
register(handle: ExecutionHandle, parentPid?: string): void;
|
|
33
|
-
private setExecution;
|
|
34
|
-
/**
|
|
35
|
-
* Update execution status
|
|
36
|
-
*/
|
|
37
|
-
updateStatus(pid: string, status: ExecutionStatus, error?: Error, phase?: string): void;
|
|
38
|
-
/**
|
|
39
|
-
* Get execution context by PID
|
|
40
|
-
*/
|
|
41
|
-
get(pid: string): ExecutionContext | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* Get execution handle by PID
|
|
44
|
-
*/
|
|
45
|
-
getHandle(pid: string): ExecutionHandle | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Get all child executions for a parent
|
|
48
|
-
*/
|
|
49
|
-
getChildren(parentPid: string): ExecutionHandle[];
|
|
50
|
-
/**
|
|
51
|
-
* Get outstanding child executions for a parent (not yet completed)
|
|
52
|
-
*/
|
|
53
|
-
getOutstandingChildren(parentPid: string): ExecutionHandle[];
|
|
54
|
-
/**
|
|
55
|
-
* Get orphaned child executions (parent completed but child still running)
|
|
56
|
-
*/
|
|
57
|
-
getOrphanedChildren(): ExecutionHandle[];
|
|
58
|
-
/**
|
|
59
|
-
* Get execution tree starting from a root PID
|
|
60
|
-
*/
|
|
61
|
-
getExecutionTree(rootPid: string): ExecutionTreeNode | undefined;
|
|
62
|
-
/**
|
|
63
|
-
* Build a tree node recursively
|
|
64
|
-
*/
|
|
65
|
-
private buildTreeNode;
|
|
66
|
-
/**
|
|
67
|
-
* Get metrics for an execution context
|
|
68
|
-
*/
|
|
69
|
-
private getMetricsForContext;
|
|
70
|
-
/**
|
|
71
|
-
* Get all active (running) executions
|
|
72
|
-
*/
|
|
73
|
-
getActiveExecutions(): ExecutionHandle[];
|
|
74
|
-
/**
|
|
75
|
-
* Get all executions
|
|
76
|
-
*/
|
|
77
|
-
getAllExecutions(): ExecutionHandle[];
|
|
78
|
-
/**
|
|
79
|
-
* Get executions by status
|
|
80
|
-
*/
|
|
81
|
-
getExecutionsByStatus(status: ExecutionStatus): ExecutionHandle[];
|
|
82
|
-
/**
|
|
83
|
-
* Get executions by type
|
|
84
|
-
*/
|
|
85
|
-
getExecutionsByType(type: ExecutionType): ExecutionHandle[];
|
|
86
|
-
/**
|
|
87
|
-
* Remove execution from graph (cleanup)
|
|
88
|
-
*/
|
|
89
|
-
remove(pid: string): void;
|
|
90
|
-
/**
|
|
91
|
-
* Clear all executions
|
|
92
|
-
*/
|
|
93
|
-
clear(): void;
|
|
94
|
-
/**
|
|
95
|
-
* Get count of executions
|
|
96
|
-
*/
|
|
97
|
-
getCount(): number;
|
|
98
|
-
/**
|
|
99
|
-
* Get count of active executions
|
|
100
|
-
*/
|
|
101
|
-
getActiveCount(): number;
|
|
102
|
-
}
|
|
103
|
-
export {};
|
|
104
|
-
//# sourceMappingURL=execution-graph.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution-graph.d.ts","sourceRoot":"","sources":["../../src/engine/execution-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,iBAAiB,EAGvB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,UAAU,gBAAgB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB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IAqBrB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAwB5B;;OAEG;IACH,mBAAmB,IAAI,eAAe,EAAE;IAIxC;;OAEG;IACH,gBAAgB,IAAI,eAAe,EAAE;IAIrC;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,EAAE;IAMjE;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,eAAe,EAAE;IAM3D;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IA+BzB;;OAEG;IACH,KAAK,IAAI,IAAI;IAOb;;OAEG;IACH,QAAQ,IAAI,MAAM;IAIlB;;OAEG;IACH,cAAc,IAAI,MAAM;CAGzB"}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { ExecutionStatuses, ExecutionTypes, } from "./execution-types";
|
|
2
|
-
/**
|
|
3
|
-
* Execution graph for tracking parent-child relationships
|
|
4
|
-
*/
|
|
5
|
-
export class ExecutionGraph {
|
|
6
|
-
executions = new Map();
|
|
7
|
-
executionsForStatus = new Map();
|
|
8
|
-
executionsByType = new Map();
|
|
9
|
-
childrenMap = new Map(); // parentPid -> Set<childPid>
|
|
10
|
-
/**
|
|
11
|
-
* Register a new execution
|
|
12
|
-
*/
|
|
13
|
-
register(handle, parentPid) {
|
|
14
|
-
const context = {
|
|
15
|
-
pid: handle.pid,
|
|
16
|
-
parentPid,
|
|
17
|
-
rootPid: handle.rootPid,
|
|
18
|
-
type: handle.type,
|
|
19
|
-
status: handle.status,
|
|
20
|
-
startedAt: handle.startedAt,
|
|
21
|
-
completedAt: handle.completedAt,
|
|
22
|
-
handle,
|
|
23
|
-
};
|
|
24
|
-
this.setExecution(handle, context);
|
|
25
|
-
// Track parent-child relationship
|
|
26
|
-
if (parentPid) {
|
|
27
|
-
if (!this.childrenMap.has(parentPid)) {
|
|
28
|
-
this.childrenMap.set(parentPid, new Set());
|
|
29
|
-
}
|
|
30
|
-
this.childrenMap.get(parentPid).add(handle.pid);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
setExecution(handle, context) {
|
|
34
|
-
this.executions.set(handle.pid, context);
|
|
35
|
-
for (const status of ExecutionStatuses) {
|
|
36
|
-
this.executionsForStatus.get(status)?.delete(handle.pid);
|
|
37
|
-
}
|
|
38
|
-
this.executionsByType.get(handle.type)?.delete(handle.pid);
|
|
39
|
-
const statusSet = this.executionsForStatus.get(handle.status) || new Set();
|
|
40
|
-
statusSet.add(handle.pid);
|
|
41
|
-
this.executionsForStatus.set(handle.status, statusSet);
|
|
42
|
-
const typeSet = this.executionsByType.get(handle.type) || new Set();
|
|
43
|
-
typeSet.add(handle.pid);
|
|
44
|
-
this.executionsByType.set(handle.type, typeSet);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Update execution status
|
|
48
|
-
*/
|
|
49
|
-
updateStatus(pid, status, error, phase) {
|
|
50
|
-
const context = this.executions.get(pid);
|
|
51
|
-
if (!context) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
context.status = status;
|
|
55
|
-
context.completedAt =
|
|
56
|
-
status === "completed" || status === "failed" || status === "cancelled"
|
|
57
|
-
? new Date()
|
|
58
|
-
: undefined;
|
|
59
|
-
if (error) {
|
|
60
|
-
context.error = {
|
|
61
|
-
message: error.message,
|
|
62
|
-
stack: error.stack,
|
|
63
|
-
phase,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
this.setExecution(context.handle, context);
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get execution context by PID
|
|
70
|
-
*/
|
|
71
|
-
get(pid) {
|
|
72
|
-
return this.executions.get(pid);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Get execution handle by PID
|
|
76
|
-
*/
|
|
77
|
-
getHandle(pid) {
|
|
78
|
-
return this.executions.get(pid)?.handle;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get all child executions for a parent
|
|
82
|
-
*/
|
|
83
|
-
getChildren(parentPid) {
|
|
84
|
-
const childPids = this.childrenMap.get(parentPid);
|
|
85
|
-
if (!childPids) {
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
return Array.from(childPids)
|
|
89
|
-
.map((pid) => this.getHandle(pid))
|
|
90
|
-
.filter((handle) => handle !== undefined);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get outstanding child executions for a parent (not yet completed)
|
|
94
|
-
*/
|
|
95
|
-
getOutstandingChildren(parentPid) {
|
|
96
|
-
return this.getChildren(parentPid).filter((handle) => handle.status === "running");
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Get orphaned child executions (parent completed but child still running)
|
|
100
|
-
*/
|
|
101
|
-
getOrphanedChildren() {
|
|
102
|
-
const orphaned = [];
|
|
103
|
-
for (const [_pid, context] of this.executions.entries()) {
|
|
104
|
-
// Skip root executions
|
|
105
|
-
if (context.type === "root") {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
// Check if parent exists and is completed
|
|
109
|
-
if (context.parentPid) {
|
|
110
|
-
const parent = this.executions.get(context.parentPid);
|
|
111
|
-
if (parent &&
|
|
112
|
-
(parent.status === "completed" ||
|
|
113
|
-
parent.status === "failed" ||
|
|
114
|
-
parent.status === "cancelled") &&
|
|
115
|
-
context.status === "running") {
|
|
116
|
-
orphaned.push(context.handle);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return orphaned;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Get execution tree starting from a root PID
|
|
124
|
-
*/
|
|
125
|
-
getExecutionTree(rootPid) {
|
|
126
|
-
const root = this.executions.get(rootPid);
|
|
127
|
-
if (!root) {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
return this.buildTreeNode(rootPid);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Build a tree node recursively
|
|
134
|
-
*/
|
|
135
|
-
buildTreeNode(pid) {
|
|
136
|
-
const context = this.executions.get(pid);
|
|
137
|
-
if (!context) {
|
|
138
|
-
throw new Error(`Execution ${pid} not found`);
|
|
139
|
-
}
|
|
140
|
-
const children = this.getChildren(pid).map((child) => this.buildTreeNode(child.pid));
|
|
141
|
-
return {
|
|
142
|
-
pid: context.pid,
|
|
143
|
-
parentPid: context.parentPid,
|
|
144
|
-
rootPid: context.rootPid,
|
|
145
|
-
type: context.type,
|
|
146
|
-
status: context.status,
|
|
147
|
-
startedAt: context.startedAt,
|
|
148
|
-
completedAt: context.completedAt,
|
|
149
|
-
children,
|
|
150
|
-
metrics: this.getMetricsForContext(context),
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Get metrics for an execution context
|
|
155
|
-
*/
|
|
156
|
-
getMetricsForContext(context) {
|
|
157
|
-
const duration = context.completedAt
|
|
158
|
-
? context.completedAt.getTime() - context.startedAt.getTime()
|
|
159
|
-
: Date.now() - context.startedAt.getTime();
|
|
160
|
-
return {
|
|
161
|
-
pid: context.pid,
|
|
162
|
-
parentPid: context.parentPid,
|
|
163
|
-
rootPid: context.rootPid,
|
|
164
|
-
type: context.type,
|
|
165
|
-
status: context.status,
|
|
166
|
-
startedAt: context.startedAt,
|
|
167
|
-
completedAt: context.completedAt,
|
|
168
|
-
duration,
|
|
169
|
-
tickCount: 0, // TODO: Track tick count
|
|
170
|
-
error: context.error
|
|
171
|
-
? {
|
|
172
|
-
message: context.error.message,
|
|
173
|
-
phase: context.error.phase,
|
|
174
|
-
}
|
|
175
|
-
: undefined,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Get all active (running) executions
|
|
180
|
-
*/
|
|
181
|
-
getActiveExecutions() {
|
|
182
|
-
return this.getExecutionsByStatus("running");
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Get all executions
|
|
186
|
-
*/
|
|
187
|
-
getAllExecutions() {
|
|
188
|
-
return Array.from(this.executions.values()).map((ctx) => ctx.handle);
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get executions by status
|
|
192
|
-
*/
|
|
193
|
-
getExecutionsByStatus(status) {
|
|
194
|
-
return Array.from(this.executionsForStatus.get(status) || [])
|
|
195
|
-
.map((pid) => this.getHandle(pid))
|
|
196
|
-
.filter((handle) => handle !== undefined);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get executions by type
|
|
200
|
-
*/
|
|
201
|
-
getExecutionsByType(type) {
|
|
202
|
-
return Array.from(this.executionsByType.get(type) || [])
|
|
203
|
-
.map((pid) => this.getHandle(pid))
|
|
204
|
-
.filter((handle) => handle !== undefined);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Remove execution from graph (cleanup)
|
|
208
|
-
*/
|
|
209
|
-
remove(pid) {
|
|
210
|
-
const context = this.executions.get(pid);
|
|
211
|
-
if (!context) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
// Remove from parent's children
|
|
215
|
-
if (context.parentPid) {
|
|
216
|
-
const children = this.childrenMap.get(context.parentPid);
|
|
217
|
-
if (children) {
|
|
218
|
-
children.delete(pid);
|
|
219
|
-
if (children.size === 0) {
|
|
220
|
-
this.childrenMap.delete(context.parentPid);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
// Remove children references
|
|
225
|
-
this.childrenMap.delete(pid);
|
|
226
|
-
// Remove execution
|
|
227
|
-
this.executions.delete(pid);
|
|
228
|
-
for (const status of ExecutionStatuses) {
|
|
229
|
-
this.executionsForStatus.get(status)?.delete(pid);
|
|
230
|
-
}
|
|
231
|
-
for (const type of ExecutionTypes) {
|
|
232
|
-
this.executionsByType.get(type)?.delete(pid);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Clear all executions
|
|
237
|
-
*/
|
|
238
|
-
clear() {
|
|
239
|
-
this.executions.clear();
|
|
240
|
-
this.executionsForStatus.clear();
|
|
241
|
-
this.executionsByType.clear();
|
|
242
|
-
this.childrenMap.clear();
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Get count of executions
|
|
246
|
-
*/
|
|
247
|
-
getCount() {
|
|
248
|
-
return this.executions.size;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Get count of active executions
|
|
252
|
-
*/
|
|
253
|
-
getActiveCount() {
|
|
254
|
-
return this.executionsForStatus.get("running")?.size || 0;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
//# sourceMappingURL=execution-graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"execution-graph.js","sourceRoot":"","sources":["../../src/engine/execution-graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAsB3B;;GAEG;AACH,MAAM,OAAO,cAAc;IACjB,UAAU,GAAG,IAAI,GAAG,EAA4B,CAAC;IACjD,mBAAmB,GAAG,IAAI,GAAG,EAAgC,CAAC;IAC9D,gBAAgB,GAAG,IAAI,GAAG,EAA8B,CAAC;IACzD,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC,CAAC,6BAA6B;IAEnF;;OAEG;IACH,QAAQ,CAAC,MAAuB,EAAE,SAAkB;QAClD,MAAM,OAAO,GAAqB;YAChC,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,SAAS;YACT,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,MAAM;SACP,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEnC,kCAAkC;QAClC,IAAI,SAAS,EAAE,CAAC;YACd,IAA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IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy-context.d.ts","sourceRoot":"","sources":["../../src/hooks/policy-context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AASzE,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,KAAK,EAAE,CAAC,CAAC;QAAC,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACtD,SAAS,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC3B;AAMD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EACzC,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,GACpD,gBAAgB,CAAC,CAAC,CAAC,CAqBrB"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Component
|
|
3
|
-
*
|
|
4
|
-
* High-level component that renders common agent boilerplate:
|
|
5
|
-
* system prompt, tools, knobs, timeline, and model configuration.
|
|
6
|
-
*
|
|
7
|
-
* Used directly by Level 1/2 users who write components, and
|
|
8
|
-
* indirectly by Level 0 users via createAgent().
|
|
9
|
-
*/
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { type KnobDescriptor } from "../../hooks/knob";
|
|
12
|
-
import type { ToolClass } from "../../tool/tool";
|
|
13
|
-
import type { EngineModel } from "../../model/model";
|
|
14
|
-
export interface AgentProps {
|
|
15
|
-
/** System prompt. Rendered as <section id="system" audience="model">. */
|
|
16
|
-
system?: string;
|
|
17
|
-
/** Model adapter. Rendered as <Model model={...} />. */
|
|
18
|
-
model?: EngineModel;
|
|
19
|
-
/** Tools (ToolClass values). Each rendered as a JSX component. */
|
|
20
|
-
tools?: ToolClass[];
|
|
21
|
-
/** Declarative knobs. Each binds via useKnob(name, descriptor). */
|
|
22
|
-
knobs?: Record<string, KnobDescriptor<any, any>>;
|
|
23
|
-
/** Additional children (extra sections, tools, etc.). */
|
|
24
|
-
children?: React.ReactNode;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* High-level agent component that renders common boilerplate.
|
|
28
|
-
*
|
|
29
|
-
* Renders in order:
|
|
30
|
-
* 1. Model configuration (if provided)
|
|
31
|
-
* 2. System prompt section (if provided)
|
|
32
|
-
* 3. Tool components
|
|
33
|
-
* 4. KnobBinding children (each calls useKnob, renders null)
|
|
34
|
-
* 5. User's children
|
|
35
|
-
* 6. <Knobs /> — aggregated knob section + set_knob tool
|
|
36
|
-
* 7. <Timeline /> — conversation history (last, so messages are at bottom of context)
|
|
37
|
-
*
|
|
38
|
-
* @example Level 1: Wrap with a component
|
|
39
|
-
* ```tsx
|
|
40
|
-
* function MyAgent() {
|
|
41
|
-
* return (
|
|
42
|
-
* <Agent
|
|
43
|
-
* system="You are a helpful assistant."
|
|
44
|
-
* model={openai("gpt-4o")}
|
|
45
|
-
* tools={[SearchTool, CalculatorTool]}
|
|
46
|
-
* knobs={{ mode: knob("quick", { description: "Research depth", options: ["quick", "deep"] }) }}
|
|
47
|
-
* >
|
|
48
|
-
* <MyCustomSection />
|
|
49
|
-
* </Agent>
|
|
50
|
-
* );
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @example Level 0: Used internally by createAgent()
|
|
55
|
-
* ```tsx
|
|
56
|
-
* createAgent({
|
|
57
|
-
* system: "You are helpful.",
|
|
58
|
-
* tools: [SearchTool],
|
|
59
|
-
* knobs: { mode: knob("quick", { description: "Depth" }) },
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export declare function Agent({ system, model, tools, knobs, children }: AgentProps): React.ReactElement;
|
|
64
|
-
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/jsx/components/agent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAerD,MAAM,WAAW,UAAU;IACzB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wDAAwD;IACxD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,kEAAkE;IAClE,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IACpB,mEAAmE;IACnE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACjD,yDAAyD;IACzD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,YAAY,CAqB/F"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Agent Component
|
|
3
|
-
*
|
|
4
|
-
* High-level component that renders common agent boilerplate:
|
|
5
|
-
* system prompt, tools, knobs, timeline, and model configuration.
|
|
6
|
-
*
|
|
7
|
-
* Used directly by Level 1/2 users who write components, and
|
|
8
|
-
* indirectly by Level 0 users via createAgent().
|
|
9
|
-
*/
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { Model } from "./model";
|
|
12
|
-
import { Timeline } from "./timeline";
|
|
13
|
-
import { Knobs } from "../../hooks/knobs-component";
|
|
14
|
-
import { useKnob } from "../../hooks/knob";
|
|
15
|
-
const h = React.createElement;
|
|
16
|
-
/**
|
|
17
|
-
* Internal: calls useKnob for a declarative knob prop. Renders nothing.
|
|
18
|
-
*
|
|
19
|
-
* Satisfies React's rules of hooks — can't call hooks in a loop,
|
|
20
|
-
* but CAN render components in a loop (each gets its own hook state).
|
|
21
|
-
*/
|
|
22
|
-
function KnobBinding({ name, descriptor }) {
|
|
23
|
-
useKnob(name, descriptor);
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* High-level agent component that renders common boilerplate.
|
|
28
|
-
*
|
|
29
|
-
* Renders in order:
|
|
30
|
-
* 1. Model configuration (if provided)
|
|
31
|
-
* 2. System prompt section (if provided)
|
|
32
|
-
* 3. Tool components
|
|
33
|
-
* 4. KnobBinding children (each calls useKnob, renders null)
|
|
34
|
-
* 5. User's children
|
|
35
|
-
* 6. <Knobs /> — aggregated knob section + set_knob tool
|
|
36
|
-
* 7. <Timeline /> — conversation history (last, so messages are at bottom of context)
|
|
37
|
-
*
|
|
38
|
-
* @example Level 1: Wrap with a component
|
|
39
|
-
* ```tsx
|
|
40
|
-
* function MyAgent() {
|
|
41
|
-
* return (
|
|
42
|
-
* <Agent
|
|
43
|
-
* system="You are a helpful assistant."
|
|
44
|
-
* model={openai("gpt-4o")}
|
|
45
|
-
* tools={[SearchTool, CalculatorTool]}
|
|
46
|
-
* knobs={{ mode: knob("quick", { description: "Research depth", options: ["quick", "deep"] }) }}
|
|
47
|
-
* >
|
|
48
|
-
* <MyCustomSection />
|
|
49
|
-
* </Agent>
|
|
50
|
-
* );
|
|
51
|
-
* }
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @example Level 0: Used internally by createAgent()
|
|
55
|
-
* ```tsx
|
|
56
|
-
* createAgent({
|
|
57
|
-
* system: "You are helpful.",
|
|
58
|
-
* tools: [SearchTool],
|
|
59
|
-
* knobs: { mode: knob("quick", { description: "Depth" }) },
|
|
60
|
-
* });
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export function Agent({ system, model, tools, knobs, children }) {
|
|
64
|
-
return h(React.Fragment, null,
|
|
65
|
-
// 1. Model configuration
|
|
66
|
-
model && h(Model, { model }),
|
|
67
|
-
// 2. System prompt section
|
|
68
|
-
system && h("section", { id: "system", audience: "model" }, system),
|
|
69
|
-
// 3. Tool components
|
|
70
|
-
...(tools ?? []).map((T) => h(T, { key: T.metadata?.name })),
|
|
71
|
-
// 4. Knob bindings
|
|
72
|
-
...Object.entries(knobs ?? {}).map(([name, desc]) => h(KnobBinding, { key: name, name, descriptor: desc })),
|
|
73
|
-
// 5. User's children
|
|
74
|
-
children,
|
|
75
|
-
// 6. Knobs section + set_knob tool
|
|
76
|
-
h(Knobs),
|
|
77
|
-
// 7. Timeline
|
|
78
|
-
h(Timeline));
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=agent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../../src/jsx/components/agent.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAA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