veryfront 0.1.924 → 0.1.926
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/esm/cli/commands/workflow/command.d.ts +1 -0
- package/esm/cli/commands/workflow/command.d.ts.map +1 -1
- package/esm/cli/commands/workflow/command.js +41 -16
- package/esm/deno.js +1 -1
- package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts +11 -8
- package/esm/extensions/ext-observability-opentelemetry/src/index.d.ts.map +1 -1
- package/esm/extensions/ext-observability-opentelemetry/src/index.js +113 -49
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/esm/src/workflow/worker/dynamic-run-entrypoint.d.ts.map +1 -1
- package/esm/src/workflow/worker/dynamic-run-entrypoint.js +16 -10
- package/esm/src/workflow/worker/run-entrypoint.d.ts.map +1 -1
- package/esm/src/workflow/worker/run-entrypoint.js +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/workflow/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/workflow/command.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,sBAAsB,EAAE,GAC/B,MAAM,EAAE,CAUV;AAuFD,wBAAsB,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAyF7E"}
|
|
@@ -2,6 +2,9 @@ import * as dntShim from "../../../_dnt.shims.js";
|
|
|
2
2
|
import { cliLogger } from "../../utils/index.js";
|
|
3
3
|
import { exitProcess } from "../../utils/index.js";
|
|
4
4
|
import { withProjectSourceContext } from "../../shared/project-source-context.js";
|
|
5
|
+
import { agentRegistry } from "../../../src/agent/composition/index.js";
|
|
6
|
+
import { discoverProjectAgentRuntime } from "../../../src/agent/project/agent-runtime.js";
|
|
7
|
+
import { toolRegistry } from "../../../src/tool/registry.js";
|
|
5
8
|
import { sanitizeRunOutputForLogging } from "../../utils/sanitize-run-output.js";
|
|
6
9
|
import { writeRunResultIfConfigured } from "../../utils/write-run-result.js";
|
|
7
10
|
import { getEnv } from "../../../src/platform/index.js";
|
|
@@ -16,18 +19,39 @@ export function formatWorkflowDiscoveryErrors(errors) {
|
|
|
16
19
|
}
|
|
17
20
|
return lines;
|
|
18
21
|
}
|
|
19
|
-
|
|
22
|
+
function formatRuntimeDiscoveryError(error) {
|
|
23
|
+
return {
|
|
24
|
+
filePath: error.file,
|
|
25
|
+
error: error.error.message,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function withProjectStepRegistries(config) {
|
|
29
|
+
return {
|
|
30
|
+
...config,
|
|
31
|
+
executor: {
|
|
32
|
+
...config.executor,
|
|
33
|
+
stepExecutor: {
|
|
34
|
+
...config.executor?.stepExecutor,
|
|
35
|
+
agentRegistry: config.executor?.stepExecutor?.agentRegistry ?? agentRegistry,
|
|
36
|
+
toolRegistry: config.executor?.stepExecutor?.toolRegistry ?? toolRegistry,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async function createWorkflowClient(config) {
|
|
20
42
|
const { createWorkflowClient } = await import("../../../src/workflow/api/workflow-client.js");
|
|
43
|
+
const clientConfig = withProjectStepRegistries(config);
|
|
21
44
|
const redisUrl = getEnv("REDIS_URL")?.trim();
|
|
22
45
|
if (!redisUrl) {
|
|
23
|
-
return createWorkflowClient(
|
|
46
|
+
return createWorkflowClient(clientConfig);
|
|
24
47
|
}
|
|
25
48
|
const { RedisBackend } = await import("../../../src/workflow/backends/redis.js");
|
|
49
|
+
const debug = clientConfig.debug ?? false;
|
|
26
50
|
const backend = new RedisBackend({ url: redisUrl, debug });
|
|
27
51
|
if (backend.initialize) {
|
|
28
52
|
await backend.initialize();
|
|
29
53
|
}
|
|
30
|
-
return createWorkflowClient({
|
|
54
|
+
return createWorkflowClient({ ...clientConfig, backend });
|
|
31
55
|
}
|
|
32
56
|
async function waitForWorkflowExit(client, runId) {
|
|
33
57
|
while (true) {
|
|
@@ -79,37 +103,38 @@ export async function workflowCommand(options) {
|
|
|
79
103
|
return;
|
|
80
104
|
}
|
|
81
105
|
}
|
|
82
|
-
const
|
|
83
|
-
await withProjectSourceContext(
|
|
106
|
+
const projectDir = options.projectDir ?? dntShim.Deno.cwd();
|
|
107
|
+
await withProjectSourceContext(projectDir, async ({ adapter, proxyContext }) => {
|
|
84
108
|
const sourceLabel = proxyContext?.branchRef
|
|
85
109
|
? `branch ${proxyContext.branchRef}`
|
|
86
110
|
: proxyContext
|
|
87
111
|
? "main"
|
|
88
|
-
: `${
|
|
112
|
+
: `${projectDir}/workflows/...`;
|
|
89
113
|
cliLogger.info(`Discovering workflows in ${sourceLabel}`);
|
|
90
|
-
const discovery = await
|
|
91
|
-
projectDir
|
|
114
|
+
const discovery = await discoverProjectAgentRuntime({
|
|
115
|
+
projectDir,
|
|
92
116
|
adapter,
|
|
93
|
-
|
|
94
|
-
debug: options.debug,
|
|
117
|
+
verbose: options.debug,
|
|
95
118
|
});
|
|
119
|
+
const workflows = [...discovery.workflows.values()];
|
|
96
120
|
if (discovery.errors.length > 0 && options.debug) {
|
|
97
|
-
for (const err of discovery.errors) {
|
|
121
|
+
for (const err of discovery.errors.map(formatRuntimeDiscoveryError)) {
|
|
98
122
|
cliLogger.warn(` Warning: ${err.filePath}: ${err.error}`);
|
|
99
123
|
}
|
|
100
124
|
}
|
|
101
|
-
const workflow =
|
|
125
|
+
const workflow = workflows.find((candidate) => candidate.id === workflowId);
|
|
102
126
|
if (!workflow) {
|
|
103
127
|
cliLogger.error(`Workflow "${workflowId}" not found.`);
|
|
104
128
|
if (discovery.errors.length > 0 && !options.debug) {
|
|
105
129
|
cliLogger.warn("Some workflow files could not be loaded:");
|
|
106
|
-
|
|
130
|
+
const errors = discovery.errors.map(formatRuntimeDiscoveryError);
|
|
131
|
+
for (const line of formatWorkflowDiscoveryErrors(errors)) {
|
|
107
132
|
cliLogger.warn(line);
|
|
108
133
|
}
|
|
109
134
|
}
|
|
110
|
-
if (
|
|
135
|
+
if (workflows.length > 0) {
|
|
111
136
|
cliLogger.info("Available workflows:");
|
|
112
|
-
for (const candidate of
|
|
137
|
+
for (const candidate of workflows) {
|
|
113
138
|
cliLogger.info(` - ${candidate.id}`);
|
|
114
139
|
}
|
|
115
140
|
}
|
|
@@ -119,7 +144,7 @@ export async function workflowCommand(options) {
|
|
|
119
144
|
exitProcess(1);
|
|
120
145
|
return;
|
|
121
146
|
}
|
|
122
|
-
const client = await createWorkflowClient(options.debug);
|
|
147
|
+
const client = await createWorkflowClient({ debug: options.debug });
|
|
123
148
|
try {
|
|
124
149
|
client.register(workflow.definition);
|
|
125
150
|
cliLogger.info(`Running workflow: ${workflow.id}`);
|
package/esm/deno.js
CHANGED
|
@@ -7,6 +7,13 @@ import type { NodeTelemetryInitializeOptions, NodeTelemetryProvider, SpanData, T
|
|
|
7
7
|
interface ShimTracerProvider {
|
|
8
8
|
getTracer(name: string, version?: string): unknown;
|
|
9
9
|
}
|
|
10
|
+
type MetricsAPI = {
|
|
11
|
+
getMeter(name: string | undefined, version?: string): unknown;
|
|
12
|
+
};
|
|
13
|
+
type TraceAPI = {
|
|
14
|
+
getActiveSpan(): unknown;
|
|
15
|
+
getSpan(ctx: unknown): unknown;
|
|
16
|
+
};
|
|
10
17
|
type EnvReader = (name: string) => string | undefined;
|
|
11
18
|
export interface ResolvedOtlpExtensionConfig {
|
|
12
19
|
serviceName: string;
|
|
@@ -23,18 +30,14 @@ export declare function resolveOtlpExtensionConfig(read?: EnvReader): ResolvedOt
|
|
|
23
30
|
declare class OtlpTracingExporter implements TracingExporter {
|
|
24
31
|
private sdkProvider;
|
|
25
32
|
private meterProvider;
|
|
26
|
-
private
|
|
33
|
+
private metricsApi;
|
|
34
|
+
private traceApi;
|
|
27
35
|
start(_ctxConfig: Record<string, unknown>): Promise<void>;
|
|
28
36
|
export(_spans: SpanData[]): Promise<void>;
|
|
29
37
|
shutdown(): Promise<void>;
|
|
30
38
|
getProvider(): ShimTracerProvider;
|
|
31
|
-
getMetricsAPI():
|
|
32
|
-
|
|
33
|
-
} | null;
|
|
34
|
-
getTraceAPI(): {
|
|
35
|
-
getActiveSpan(): unknown;
|
|
36
|
-
getSpan(ctx: unknown): unknown;
|
|
37
|
-
} | null;
|
|
39
|
+
getMetricsAPI(): MetricsAPI | null;
|
|
40
|
+
getTraceAPI(): TraceAPI | null;
|
|
38
41
|
}
|
|
39
42
|
declare class OpenTelemetryNodeTelemetryProvider implements NodeTelemetryProvider {
|
|
40
43
|
private sdk;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-observability-opentelemetry/src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EACV,8BAA8B,EAC9B,qBAAqB,EACrB,QAAQ,EACR,eAAe,EAChB,MAAM,gDAAgD,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-observability-opentelemetry/src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EACV,8BAA8B,EAC9B,qBAAqB,EACrB,QAAQ,EACR,eAAe,EAChB,MAAM,gDAAgD,CAAC;AAExD;;;GAGG;AACH,UAAU,kBAAkB;IAC1B,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACpD;AAsBD,KAAK,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AACpF,KAAK,QAAQ,GAAG;IAAE,aAAa,IAAI,OAAO,CAAC;IAAC,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAAA;CAAE,CAAC;AAuG7E,KAAK,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;CACrC;AAgCD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,QAAQ,GAAG,SAAS,GAC3B,MAAM,GAAG,SAAS,CAKpB;AAED,wBAAgB,0BAA0B,CACxC,IAAI,GAAE,SAAmB,GACxB,2BAA2B,CAqB7B;AAED,cAAM,mBAAoB,YAAW,eAAe;IAClD,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,QAAQ,CAAyB;IAEnC,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IA2EzD,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAKzC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB/B,WAAW,IAAI,kBAAkB;IAKjC,aAAa,IAAI,UAAU,GAAG,IAAI;IAIlC,WAAW,IAAI,QAAQ,GAAG,IAAI;CAG/B;AAED,cAAM,kCAAmC,YAAW,qBAAqB;IACvE,OAAO,CAAC,GAAG,CAA8C;IAEnD,UAAU,CAAC,OAAO,EAAE,8BAA8B,GAAG,OAAO,CAAC,OAAO,CAAC;IA6CrE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAQhC;AAED;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,EAAE,gBAqCvB,CAAC;AAEF,eAAe,gBAAgB,CAAC;AAChC,OAAO,EAAE,kCAAkC,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -14,17 +14,82 @@
|
|
|
14
14
|
* @module extensions/ext-observability-opentelemetry
|
|
15
15
|
*/
|
|
16
16
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const NOOP_SPAN = {
|
|
18
|
+
setAttribute() {
|
|
19
|
+
return NOOP_SPAN;
|
|
20
|
+
},
|
|
21
|
+
setAttributes() {
|
|
22
|
+
return NOOP_SPAN;
|
|
23
|
+
},
|
|
24
|
+
setStatus() {
|
|
25
|
+
return NOOP_SPAN;
|
|
26
|
+
},
|
|
27
|
+
recordException() { },
|
|
28
|
+
addEvent() {
|
|
29
|
+
return NOOP_SPAN;
|
|
30
|
+
},
|
|
31
|
+
end() { },
|
|
32
|
+
spanContext() {
|
|
33
|
+
return {
|
|
34
|
+
traceId: "00000000000000000000000000000000",
|
|
35
|
+
spanId: "0000000000000000",
|
|
36
|
+
traceFlags: 0,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
updateName() { },
|
|
40
|
+
};
|
|
41
|
+
const NOOP_TRACER = {
|
|
42
|
+
startSpan() {
|
|
43
|
+
return NOOP_SPAN;
|
|
44
|
+
},
|
|
45
|
+
startActiveSpan(_name, optionsOrFn, contextOrFn, fn) {
|
|
46
|
+
const callback = typeof optionsOrFn === "function"
|
|
47
|
+
? optionsOrFn
|
|
48
|
+
: typeof contextOrFn === "function"
|
|
49
|
+
? contextOrFn
|
|
50
|
+
: fn;
|
|
51
|
+
return callback?.(NOOP_SPAN);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const NOOP_TRACER_PROVIDER = {
|
|
55
|
+
getTracer() {
|
|
56
|
+
return NOOP_TRACER;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
async function loadOpenTelemetryRuntime() {
|
|
60
|
+
try {
|
|
61
|
+
const [api, autoInstrumentations, core, contextAsyncHooks, sdkNode, metricsExporter, sdkMetrics, sdkTraceBase, traceExporter, resources, semanticConventions,] = await Promise.all([
|
|
62
|
+
import("@opentelemetry/api"),
|
|
63
|
+
import("@opentelemetry/auto-instrumentations-node"),
|
|
64
|
+
import("@opentelemetry/core"),
|
|
65
|
+
import("@opentelemetry/context-async-hooks"),
|
|
66
|
+
import("@opentelemetry/sdk-node"),
|
|
67
|
+
import("@opentelemetry/exporter-metrics-otlp-http"),
|
|
68
|
+
import("@opentelemetry/sdk-metrics"),
|
|
69
|
+
import("@opentelemetry/sdk-trace-base"),
|
|
70
|
+
import("@opentelemetry/exporter-trace-otlp-http"),
|
|
71
|
+
import("@opentelemetry/resources"),
|
|
72
|
+
import("@opentelemetry/semantic-conventions"),
|
|
73
|
+
]);
|
|
74
|
+
return {
|
|
75
|
+
api,
|
|
76
|
+
autoInstrumentations,
|
|
77
|
+
core,
|
|
78
|
+
contextAsyncHooks,
|
|
79
|
+
sdkNode,
|
|
80
|
+
metricsExporter,
|
|
81
|
+
sdkMetrics,
|
|
82
|
+
sdkTraceBase,
|
|
83
|
+
traceExporter,
|
|
84
|
+
resources,
|
|
85
|
+
semanticConventions,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
90
|
+
throw new Error(`OpenTelemetry observability requires the optional @opentelemetry packages to be installed. ${detail}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
28
93
|
function readEnv(name) {
|
|
29
94
|
try {
|
|
30
95
|
return dntShim.dntGlobalThis.Deno?.env
|
|
@@ -81,57 +146,62 @@ export function resolveOtlpExtensionConfig(read = readEnv) {
|
|
|
81
146
|
class OtlpTracingExporter {
|
|
82
147
|
sdkProvider = null;
|
|
83
148
|
meterProvider = null;
|
|
84
|
-
|
|
149
|
+
metricsApi = null;
|
|
150
|
+
traceApi = null;
|
|
85
151
|
async start(_ctxConfig) {
|
|
86
152
|
const cfg = resolveOtlpExtensionConfig(readEnv);
|
|
87
153
|
// Honor OTEL_TRACES_ENABLED: when unset/false, skip exporter wiring so
|
|
88
154
|
// deployments opting out never create OTLP traffic or set globals.
|
|
89
155
|
if (!cfg.tracesEnabled && !cfg.metricsEnabled)
|
|
90
156
|
return;
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
[
|
|
157
|
+
const otel = await loadOpenTelemetryRuntime();
|
|
158
|
+
const resource = otel.resources.resourceFromAttributes({
|
|
159
|
+
[otel.semanticConventions.ATTR_SERVICE_NAME]: cfg.serviceName,
|
|
160
|
+
[otel.semanticConventions.ATTR_SERVICE_VERSION]: cfg.serviceVersion,
|
|
94
161
|
});
|
|
95
162
|
if (cfg.tracesEnabled) {
|
|
96
163
|
if (!cfg.tracesUrl) {
|
|
97
164
|
throw new Error("OTEL_TRACES_ENABLED=true requires OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT");
|
|
98
165
|
}
|
|
99
|
-
const exporter = new OTLPTraceExporter({
|
|
166
|
+
const exporter = new otel.traceExporter.OTLPTraceExporter({
|
|
100
167
|
url: cfg.tracesUrl,
|
|
101
168
|
headers: cfg.headers,
|
|
102
169
|
});
|
|
103
|
-
const provider = new BasicTracerProvider({
|
|
170
|
+
const provider = new otel.sdkTraceBase.BasicTracerProvider({
|
|
104
171
|
resource,
|
|
105
|
-
spanProcessors: [new BatchSpanProcessor(exporter)],
|
|
172
|
+
spanProcessors: [new otel.sdkTraceBase.BatchSpanProcessor(exporter)],
|
|
106
173
|
});
|
|
107
174
|
// Wire OTel SDK globals so the real API delegates to this provider.
|
|
108
175
|
// The shim also gets wired separately in bootstrap.ts via getProvider().
|
|
109
|
-
trace.setGlobalTracerProvider(provider);
|
|
110
|
-
const contextManager = new AsyncLocalStorageContextManager();
|
|
176
|
+
otel.api.trace.setGlobalTracerProvider(provider);
|
|
177
|
+
const contextManager = new otel.contextAsyncHooks.AsyncLocalStorageContextManager();
|
|
111
178
|
contextManager.enable();
|
|
112
|
-
const propagator = new W3CTraceContextPropagator();
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
propagation.setGlobalPropagator(propagator);
|
|
116
|
-
otelContext.setGlobalContextManager(contextManager);
|
|
179
|
+
const propagator = new otel.core.W3CTraceContextPropagator();
|
|
180
|
+
otel.api.propagation.setGlobalPropagator(propagator);
|
|
181
|
+
otel.api.context.setGlobalContextManager(contextManager);
|
|
117
182
|
this.sdkProvider = provider;
|
|
183
|
+
this.traceApi = {
|
|
184
|
+
getActiveSpan: () => otel.api.trace.getActiveSpan(),
|
|
185
|
+
getSpan: (ctx) => otel.api.trace.getSpan(ctx),
|
|
186
|
+
};
|
|
118
187
|
}
|
|
119
188
|
if (cfg.metricsEnabled) {
|
|
120
189
|
if (!cfg.metricsUrl) {
|
|
121
190
|
throw new Error("OTEL_METRICS_ENABLED=true requires OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_METRICS_ENDPOINT");
|
|
122
191
|
}
|
|
123
|
-
|
|
124
|
-
exporter: new OTLPMetricExporter({
|
|
192
|
+
const metricReader = new otel.sdkMetrics.PeriodicExportingMetricReader({
|
|
193
|
+
exporter: new otel.metricsExporter.OTLPMetricExporter({
|
|
125
194
|
url: cfg.metricsUrl,
|
|
126
195
|
headers: cfg.headers,
|
|
127
196
|
}),
|
|
128
197
|
exportIntervalMillis: cfg.metricsExportIntervalMillis,
|
|
129
198
|
});
|
|
130
|
-
this.meterProvider = new MeterProvider({
|
|
199
|
+
this.meterProvider = new otel.sdkMetrics.MeterProvider({
|
|
131
200
|
resource,
|
|
132
|
-
readers: [
|
|
201
|
+
readers: [metricReader],
|
|
133
202
|
});
|
|
134
|
-
metrics.setGlobalMeterProvider(this.meterProvider);
|
|
203
|
+
otel.api.metrics.setGlobalMeterProvider(this.meterProvider);
|
|
204
|
+
this.metricsApi = otel.api.metrics;
|
|
135
205
|
}
|
|
136
206
|
}
|
|
137
207
|
// eslint-disable-next-line require-await
|
|
@@ -146,7 +216,6 @@ class OtlpTracingExporter {
|
|
|
146
216
|
}
|
|
147
217
|
finally {
|
|
148
218
|
this.meterProvider = null;
|
|
149
|
-
this.metricReader = null;
|
|
150
219
|
}
|
|
151
220
|
}
|
|
152
221
|
if (this.sdkProvider) {
|
|
@@ -161,43 +230,38 @@ class OtlpTracingExporter {
|
|
|
161
230
|
getProvider() {
|
|
162
231
|
if (this.sdkProvider)
|
|
163
232
|
return this.sdkProvider;
|
|
164
|
-
|
|
165
|
-
// called (e.g., test scaffolding without full setup).
|
|
166
|
-
return trace.getTracerProvider();
|
|
233
|
+
return NOOP_TRACER_PROVIDER;
|
|
167
234
|
}
|
|
168
235
|
getMetricsAPI() {
|
|
169
|
-
|
|
170
|
-
return metrics;
|
|
236
|
+
return this.metricsApi;
|
|
171
237
|
}
|
|
172
238
|
getTraceAPI() {
|
|
173
|
-
|
|
174
|
-
return null;
|
|
175
|
-
return {
|
|
176
|
-
getActiveSpan: () => trace.getActiveSpan(),
|
|
177
|
-
getSpan: (ctx) => trace.getSpan(ctx),
|
|
178
|
-
};
|
|
239
|
+
return this.traceApi;
|
|
179
240
|
}
|
|
180
241
|
}
|
|
181
242
|
class OpenTelemetryNodeTelemetryProvider {
|
|
182
243
|
sdk = null;
|
|
183
244
|
async initialize(options) {
|
|
184
|
-
const
|
|
245
|
+
const otel = await loadOpenTelemetryRuntime();
|
|
246
|
+
const resource = otel.resources.resourceFromAttributes({
|
|
185
247
|
"service.name": options.serviceName,
|
|
186
248
|
"service.version": options.serviceVersion,
|
|
187
249
|
"deployment.environment": options.deploymentEnvironment,
|
|
188
250
|
});
|
|
189
|
-
const traceExporter = new OTLPTraceExporter({
|
|
190
|
-
|
|
251
|
+
const traceExporter = new otel.traceExporter.OTLPTraceExporter({
|
|
252
|
+
headers: options.exporterHeaders,
|
|
253
|
+
});
|
|
254
|
+
const sdk = new otel.sdkNode.NodeSDK({
|
|
191
255
|
resource,
|
|
192
|
-
sampler: new ParentBasedSampler({
|
|
193
|
-
root: new TraceIdRatioBasedSampler(options.samplingRatio),
|
|
256
|
+
sampler: new otel.sdkTraceBase.ParentBasedSampler({
|
|
257
|
+
root: new otel.sdkTraceBase.TraceIdRatioBasedSampler(options.samplingRatio),
|
|
194
258
|
}),
|
|
195
|
-
spanProcessor: new BatchSpanProcessor(traceExporter, {
|
|
259
|
+
spanProcessor: new otel.sdkTraceBase.BatchSpanProcessor(traceExporter, {
|
|
196
260
|
maxExportBatchSize: 100,
|
|
197
261
|
scheduledDelayMillis: 500,
|
|
198
262
|
}),
|
|
199
263
|
instrumentations: [
|
|
200
|
-
getNodeAutoInstrumentations({
|
|
264
|
+
otel.autoInstrumentations.getNodeAutoInstrumentations({
|
|
201
265
|
"@opentelemetry/instrumentation-fs": { enabled: options.instrumentation.fs },
|
|
202
266
|
"@opentelemetry/instrumentation-http": { enabled: options.instrumentation.http },
|
|
203
267
|
"@opentelemetry/instrumentation-express": { enabled: options.instrumentation.express },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-run-entrypoint.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/dynamic-run-entrypoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"dynamic-run-entrypoint.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/dynamic-run-entrypoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AASH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAY5D;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,kCAAkC;IACjD,uCAAuC;IACvC,OAAO,EAAE,eAAe,CAAC;IAEzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,kCAAkC,GACzC,OAAO,CAAC,MAAM,CAAC,CAmIjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,yCAAyC;IACxD,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IAEjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,gDAAgD;AAChD,wBAAsB,kCAAkC,CACtD,OAAO,EAAE,yCAAyC,GACjD,OAAO,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CAchC"}
|
|
@@ -28,7 +28,9 @@ import { logger as baseLogger } from "../../utils/index.js";
|
|
|
28
28
|
import { getEnv } from "../../platform/compat/process.js";
|
|
29
29
|
import { enhanceAdapterWithFS } from "../../platform/adapters/fs/integration.js";
|
|
30
30
|
import { denoAdapter } from "../../platform/adapters/runtime/deno/index.js";
|
|
31
|
-
import {
|
|
31
|
+
import { agentRegistry } from "../../agent/composition/index.js";
|
|
32
|
+
import { discoverProjectAgentRuntime } from "../../agent/project/agent-runtime.js";
|
|
33
|
+
import { toolRegistry } from "../../tool/registry.js";
|
|
32
34
|
import { WorkflowExecutor } from "../executor/workflow-executor.js";
|
|
33
35
|
import { failRunExecution, getFinalRunExitCode, getTenantFromEnv, hydrateRunContextEnv, runWithTenantContext, } from "./shared.js";
|
|
34
36
|
const logger = baseLogger.component("dynamic-workflow-run-entrypoint");
|
|
@@ -100,37 +102,41 @@ export async function runDynamicWorkflowRun(config) {
|
|
|
100
102
|
if (debug) {
|
|
101
103
|
logger.info("FS adapter initialized");
|
|
102
104
|
}
|
|
103
|
-
// Discover workflows
|
|
104
|
-
const discoveryResult = await
|
|
105
|
+
// Discover workflows and the project-local agent/tool registries they may reference.
|
|
106
|
+
const discoveryResult = await discoverProjectAgentRuntime({
|
|
105
107
|
projectDir: "", // Root of project (relative paths with API)
|
|
106
108
|
adapter,
|
|
107
|
-
|
|
108
|
-
debug,
|
|
109
|
+
verbose: debug,
|
|
109
110
|
});
|
|
110
111
|
if (discoveryResult.errors.length > 0 && debug) {
|
|
111
112
|
logger.warn("Some workflow files failed to load:", discoveryResult.errors);
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
const workflows = [...discoveryResult.workflows.values()];
|
|
115
|
+
if (workflows.length === 0) {
|
|
114
116
|
logger.error("No workflows discovered");
|
|
115
117
|
return DYNAMIC_EXIT_CODES.DISCOVERY_FAILED;
|
|
116
118
|
}
|
|
117
119
|
if (debug) {
|
|
118
|
-
logger.info(`[DynamicWorkflowRun] Discovered ${
|
|
120
|
+
logger.info(`[DynamicWorkflowRun] Discovered ${workflows.length} workflows:`, workflows.map((w) => w.id));
|
|
119
121
|
}
|
|
120
122
|
// Find the matching workflow
|
|
121
|
-
const workflow =
|
|
123
|
+
const workflow = workflows.find((w) => w.id === run.workflowId);
|
|
122
124
|
if (!workflow) {
|
|
123
125
|
logger.error(`Workflow not found: ${run.workflowId}`);
|
|
124
|
-
logger.error(`[DynamicWorkflowRun] Available workflows: ${
|
|
126
|
+
logger.error(`[DynamicWorkflowRun] Available workflows: ${workflows.map((w) => w.id).join(", ")}`);
|
|
125
127
|
return DYNAMIC_EXIT_CODES.NOT_FOUND;
|
|
126
128
|
}
|
|
127
129
|
if (debug) {
|
|
128
|
-
logger.info(`Found workflow "${workflow.id}"
|
|
130
|
+
logger.info(`Found workflow "${workflow.id}"`);
|
|
129
131
|
}
|
|
130
132
|
// Create executor and register the workflow
|
|
131
133
|
const executor = new WorkflowExecutor({
|
|
132
134
|
backend,
|
|
133
135
|
debug,
|
|
136
|
+
stepExecutor: {
|
|
137
|
+
agentRegistry,
|
|
138
|
+
toolRegistry,
|
|
139
|
+
},
|
|
134
140
|
});
|
|
135
141
|
executor.register(workflow.definition);
|
|
136
142
|
// Execute the workflow
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-entrypoint.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/run-entrypoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"run-entrypoint.d.ts","sourceRoot":"","sources":["../../../../src/src/workflow/worker/run-entrypoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAWtD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C,uCAAuC;IACvC,OAAO,EAAE,eAAe,CAAC;IAEzB,wBAAwB;IACxB,QAAQ,EAAE,gBAAgB,CAAC;IAE3B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;CAKb,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAgEzF;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,kCAAkC;IACjD,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IAEjB,4BAA4B;IAC5B,SAAS,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IAErD,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wCAAwC;AACxC,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,CA8BhC"}
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { logger as baseLogger } from "../../utils/index.js";
|
|
23
23
|
import { getEnv } from "../../platform/compat/process.js";
|
|
24
|
+
import { agentRegistry } from "../../agent/composition/index.js";
|
|
25
|
+
import { toolRegistry } from "../../tool/registry.js";
|
|
24
26
|
import { failRunExecution, getFinalRunExitCode, getTenantFromEnv, hydrateRunContextEnv, runWithTenantContext, } from "./shared.js";
|
|
25
27
|
const logger = baseLogger.component("workflow-run-entrypoint");
|
|
26
28
|
/**
|
|
@@ -122,6 +124,10 @@ export async function createWorkflowRunEntrypoint(options) {
|
|
|
122
124
|
const executor = new WorkflowExecutor({
|
|
123
125
|
backend,
|
|
124
126
|
debug: options.debug,
|
|
127
|
+
stepExecutor: {
|
|
128
|
+
agentRegistry,
|
|
129
|
+
toolRegistry,
|
|
130
|
+
},
|
|
125
131
|
});
|
|
126
132
|
// Register workflows
|
|
127
133
|
for (const wf of options.workflows) {
|