plugin-agent-orchestrator 1.0.32 → 1.0.33
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/README.md +114 -114
- package/package.json +1 -1
- package/src/client-v2/components/AgentRunsTab.tsx +494 -494
- package/src/client-v2/components/TracingTab.tsx +432 -432
- package/src/client-v2/hooks/useApiRequest.ts +121 -121
- package/src/server/resources/agent-monitor.ts +482 -482
- package/src/server/services/ExecutionSpanService.ts +110 -110
- package/src/server/services/NativeSubAgentObserver.ts +507 -507
- package/src/server/skill-hub/plugin.ts +1016 -1016
- package/src/server/skill-hub/tasks/SkillExecutionTask.ts +470 -470
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import { toPlain } from '../utils/ctx-utils';
|
|
2
|
-
|
|
3
|
-
export const ORCHESTRATOR_TRACE_CONTEXT_KEY = '__orchestratorTraceContext';
|
|
4
|
-
|
|
5
|
-
export type OrchestratorTraceContext = {
|
|
6
|
-
rootRunId: string;
|
|
7
|
-
spanId?: string;
|
|
8
|
-
parentSpanId?: string;
|
|
9
|
-
toolCallId?: string;
|
|
10
|
-
leaderUsername?: string;
|
|
11
|
-
employeeUsername?: string;
|
|
12
|
-
toolName?: string;
|
|
13
|
-
agentLoopRunId?: string;
|
|
14
|
-
agentLoopStepId?: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type SpanValues = {
|
|
18
|
-
rootRunId: string;
|
|
19
|
-
parentSpanId?: string;
|
|
20
|
-
source?: string;
|
|
21
|
-
parentSessionId?: string;
|
|
22
|
-
subSessionId?: string;
|
|
23
|
-
toolCallId?: string;
|
|
24
|
-
type: string;
|
|
25
|
-
status: string;
|
|
26
|
-
leaderUsername?: string;
|
|
27
|
-
employeeUsername?: string;
|
|
28
|
-
toolName?: string;
|
|
29
|
-
title?: string;
|
|
30
|
-
input?: any;
|
|
31
|
-
output?: string;
|
|
32
|
-
error?: string;
|
|
33
|
-
durationMs?: number;
|
|
34
|
-
startedAt?: Date;
|
|
35
|
-
endedAt?: Date;
|
|
36
|
-
orchestratorLogId?: string | number;
|
|
37
|
-
skillExecutionId?: string | number;
|
|
38
|
-
metadata?: any;
|
|
39
|
-
userId?: string | number;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export class ExecutionSpanService {
|
|
43
|
-
constructor(private readonly plugin: any) {}
|
|
44
|
-
|
|
45
|
-
async create(values: SpanValues) {
|
|
46
|
-
try {
|
|
47
|
-
const repo = this.plugin.db.getRepository('agentExecutionSpans');
|
|
48
|
-
if (!repo) return null;
|
|
49
|
-
|
|
50
|
-
const record = await repo.create({
|
|
51
|
-
values: {
|
|
52
|
-
...values,
|
|
53
|
-
startedAt: values.startedAt || new Date(),
|
|
54
|
-
createdAt: new Date(),
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
return toPlain(record);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
this.plugin.app.logger?.warn?.('[AgentOrchestrator] Failed to create execution span', error);
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
async update(spanId: string | number | undefined, values: Record<string, any>) {
|
|
65
|
-
if (!spanId) return null;
|
|
66
|
-
try {
|
|
67
|
-
const repo = this.plugin.db.getRepository('agentExecutionSpans');
|
|
68
|
-
if (!repo) return null;
|
|
69
|
-
await repo.update({
|
|
70
|
-
filterByTk: spanId,
|
|
71
|
-
values: {
|
|
72
|
-
...values,
|
|
73
|
-
updatedAt: new Date(),
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
return { id: spanId };
|
|
77
|
-
} catch (error) {
|
|
78
|
-
this.plugin.app.logger?.warn?.(`[AgentOrchestrator] Failed to update execution span ${spanId}`, error);
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async finish(
|
|
84
|
-
spanId: string | number | undefined,
|
|
85
|
-
status: 'success' | 'error' | 'canceled' | 'timeout',
|
|
86
|
-
startedAt: number,
|
|
87
|
-
values: Record<string, any> = {},
|
|
88
|
-
) {
|
|
89
|
-
return this.update(spanId, {
|
|
90
|
-
...values,
|
|
91
|
-
status,
|
|
92
|
-
endedAt: new Date(),
|
|
93
|
-
durationMs: Date.now() - startedAt,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function getOrchestratorTraceContext(ctx: any): OrchestratorTraceContext | null {
|
|
99
|
-
return (
|
|
100
|
-
ctx?.[ORCHESTRATOR_TRACE_CONTEXT_KEY] ||
|
|
101
|
-
ctx?.state?.orchestratorTraceContext ||
|
|
102
|
-
ctx?.runtime?.context?.orchestratorTraceContext ||
|
|
103
|
-
null
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function setOrchestratorTraceContext(ctx: any, traceContext: OrchestratorTraceContext) {
|
|
108
|
-
ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY] = traceContext;
|
|
109
|
-
return ctx;
|
|
110
|
-
}
|
|
1
|
+
import { toPlain } from '../utils/ctx-utils';
|
|
2
|
+
|
|
3
|
+
export const ORCHESTRATOR_TRACE_CONTEXT_KEY = '__orchestratorTraceContext';
|
|
4
|
+
|
|
5
|
+
export type OrchestratorTraceContext = {
|
|
6
|
+
rootRunId: string;
|
|
7
|
+
spanId?: string;
|
|
8
|
+
parentSpanId?: string;
|
|
9
|
+
toolCallId?: string;
|
|
10
|
+
leaderUsername?: string;
|
|
11
|
+
employeeUsername?: string;
|
|
12
|
+
toolName?: string;
|
|
13
|
+
agentLoopRunId?: string;
|
|
14
|
+
agentLoopStepId?: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type SpanValues = {
|
|
18
|
+
rootRunId: string;
|
|
19
|
+
parentSpanId?: string;
|
|
20
|
+
source?: string;
|
|
21
|
+
parentSessionId?: string;
|
|
22
|
+
subSessionId?: string;
|
|
23
|
+
toolCallId?: string;
|
|
24
|
+
type: string;
|
|
25
|
+
status: string;
|
|
26
|
+
leaderUsername?: string;
|
|
27
|
+
employeeUsername?: string;
|
|
28
|
+
toolName?: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
input?: any;
|
|
31
|
+
output?: string;
|
|
32
|
+
error?: string;
|
|
33
|
+
durationMs?: number;
|
|
34
|
+
startedAt?: Date;
|
|
35
|
+
endedAt?: Date;
|
|
36
|
+
orchestratorLogId?: string | number;
|
|
37
|
+
skillExecutionId?: string | number;
|
|
38
|
+
metadata?: any;
|
|
39
|
+
userId?: string | number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export class ExecutionSpanService {
|
|
43
|
+
constructor(private readonly plugin: any) {}
|
|
44
|
+
|
|
45
|
+
async create(values: SpanValues) {
|
|
46
|
+
try {
|
|
47
|
+
const repo = this.plugin.db.getRepository('agentExecutionSpans');
|
|
48
|
+
if (!repo) return null;
|
|
49
|
+
|
|
50
|
+
const record = await repo.create({
|
|
51
|
+
values: {
|
|
52
|
+
...values,
|
|
53
|
+
startedAt: values.startedAt || new Date(),
|
|
54
|
+
createdAt: new Date(),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
return toPlain(record);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
this.plugin.app.logger?.warn?.('[AgentOrchestrator] Failed to create execution span', error);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async update(spanId: string | number | undefined, values: Record<string, any>) {
|
|
65
|
+
if (!spanId) return null;
|
|
66
|
+
try {
|
|
67
|
+
const repo = this.plugin.db.getRepository('agentExecutionSpans');
|
|
68
|
+
if (!repo) return null;
|
|
69
|
+
await repo.update({
|
|
70
|
+
filterByTk: spanId,
|
|
71
|
+
values: {
|
|
72
|
+
...values,
|
|
73
|
+
updatedAt: new Date(),
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
return { id: spanId };
|
|
77
|
+
} catch (error) {
|
|
78
|
+
this.plugin.app.logger?.warn?.(`[AgentOrchestrator] Failed to update execution span ${spanId}`, error);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async finish(
|
|
84
|
+
spanId: string | number | undefined,
|
|
85
|
+
status: 'success' | 'error' | 'canceled' | 'timeout',
|
|
86
|
+
startedAt: number,
|
|
87
|
+
values: Record<string, any> = {},
|
|
88
|
+
) {
|
|
89
|
+
return this.update(spanId, {
|
|
90
|
+
...values,
|
|
91
|
+
status,
|
|
92
|
+
endedAt: new Date(),
|
|
93
|
+
durationMs: Date.now() - startedAt,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function getOrchestratorTraceContext(ctx: any): OrchestratorTraceContext | null {
|
|
99
|
+
return (
|
|
100
|
+
ctx?.[ORCHESTRATOR_TRACE_CONTEXT_KEY] ||
|
|
101
|
+
ctx?.state?.orchestratorTraceContext ||
|
|
102
|
+
ctx?.runtime?.context?.orchestratorTraceContext ||
|
|
103
|
+
null
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function setOrchestratorTraceContext(ctx: any, traceContext: OrchestratorTraceContext) {
|
|
108
|
+
ctx[ORCHESTRATOR_TRACE_CONTEXT_KEY] = traceContext;
|
|
109
|
+
return ctx;
|
|
110
|
+
}
|