@uipath/common 1.199.0-preview.97 → 1.200.0-preview.109
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/formatter.d.ts +19 -0
- package/dist/guid.js +10 -0
- package/dist/host-global-options.d.ts +26 -0
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.js +124 -35
- package/dist/index.d.ts +4 -0
- package/dist/index.js +467 -70
- package/dist/packager-tool-import.d.ts +28 -0
- package/dist/polling/terminal-statuses.d.ts +3 -3
- package/dist/solution-project-artifacts.d.ts +43 -0
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +49 -30
- package/dist/telemetry/node-appinsights-telemetry-provider.d.ts +20 -12
- package/dist/telemetry/node.d.ts +1 -1
- package/dist/telemetry/session-id.d.ts +54 -9
- package/dist/telemetry/telemetry-events.d.ts +11 -1
- package/dist/telemetry/telemetry-init.d.ts +18 -3
- package/dist/telemetry/telemetry-service.d.ts +5 -0
- package/dist/telemetry/telemetry-spool.d.ts +68 -0
- package/dist/tool-module-import.d.ts +9 -0
- package/dist/tool-provider.d.ts +34 -2
- package/package.json +6 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import a tool's `packager-tool` entry point and run its registration.
|
|
3
|
+
*
|
|
4
|
+
* Its own module so tests can stand in for it. The real entry points are
|
|
5
|
+
* multi-megabyte tool bundles; loading one takes seconds and blocks the event
|
|
6
|
+
* loop while it evaluates, which is far too slow for a unit test.
|
|
7
|
+
*/
|
|
8
|
+
/** Named export every in-repo `packager-tool` entry point must provide. */
|
|
9
|
+
export declare const REGISTER_EXPORT = "registerPackagerFactories";
|
|
10
|
+
/** Shape of a `packager-tool` entry point's module namespace. */
|
|
11
|
+
export interface PackagerToolModule {
|
|
12
|
+
[REGISTER_EXPORT]?: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Import `specifier` and call its `registerPackagerFactories` export. Returns
|
|
16
|
+
* the failure instead of throwing so the caller can decide what to say.
|
|
17
|
+
*
|
|
18
|
+
* Registration is a call, not an import side effect, so a run that reaches
|
|
19
|
+
* the same factories through two tool bundles registers them once — from the
|
|
20
|
+
* one caller that is about to pack.
|
|
21
|
+
*
|
|
22
|
+
* Tools published before that change register at import and ship no export.
|
|
23
|
+
* They still work: the import above already registered them, so treat a
|
|
24
|
+
* missing export as a legacy entry point instead of a failure. Tools that live
|
|
25
|
+
* in this repo must export it — `scripts/lint-packager-tool-exports.ts` fails
|
|
26
|
+
* the build if one doesn't.
|
|
27
|
+
*/
|
|
28
|
+
export declare function importPackagerTool(specifier: string): Promise<Error | undefined>;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* isTerminalStatus("FAULTED") // true
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export declare function isTerminalStatus(status: string): boolean;
|
|
23
|
+
export declare function isTerminalStatus(status: string | null | undefined): boolean;
|
|
24
24
|
/**
|
|
25
25
|
* Check if a status string represents a failure state (case-insensitive).
|
|
26
26
|
*
|
|
@@ -34,7 +34,7 @@ export declare function isTerminalStatus(status: string): boolean;
|
|
|
34
34
|
* isFailureStatus("Cancelled") // true
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export declare function isFailureStatus(status: string): boolean;
|
|
37
|
+
export declare function isFailureStatus(status: string | null | undefined): boolean;
|
|
38
38
|
/**
|
|
39
39
|
* Check if a status string represents a successful terminal state (case-insensitive).
|
|
40
40
|
*
|
|
@@ -47,4 +47,4 @@ export declare function isFailureStatus(status: string): boolean;
|
|
|
47
47
|
* isSuccessStatus("Running") // false
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
export declare function isSuccessStatus(status: string): boolean;
|
|
50
|
+
export declare function isSuccessStatus(status: string | null | undefined): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `ensureProjectArtifacts` used by every `*-tool init` path (agent,
|
|
3
|
+
* case, codedapp, flow, maestro). Lives here so the five tools don't each
|
|
4
|
+
* carry a copy; each tool re-exports it from its own
|
|
5
|
+
* `src/services/project-artifacts.ts` shim (the browser-build
|
|
6
|
+
* `excludedImports` stub mechanism resolves only relative paths under each
|
|
7
|
+
* tool's own src tree).
|
|
8
|
+
*/
|
|
9
|
+
/** Options forwarded to solution-tool's `addProjectArtifactsToSolutionAsync`. */
|
|
10
|
+
export interface EnsureProjectArtifactsArgs {
|
|
11
|
+
/** Absolute path to the solution directory (containing the `.uipx`). */
|
|
12
|
+
solutionDir: string;
|
|
13
|
+
/** Stable project key — must match the `Id` in `.uipx` `Projects[]`. */
|
|
14
|
+
projectId: string;
|
|
15
|
+
/** Display name for the project; typically the project folder name. */
|
|
16
|
+
projectName: string;
|
|
17
|
+
/** Project type as written to `project.uiproj` (e.g. `Flow`, `Agent`). */
|
|
18
|
+
projectType: string;
|
|
19
|
+
/** Optional SDK subType (AppV2: `"Coded"` / `"CodedAction"`). */
|
|
20
|
+
projectSubType?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result envelope. Structurally identical to `ProjectArtifactsResult` in
|
|
24
|
+
* `@uipath/solution-sdk/resources` — declared here too because this
|
|
25
|
+
* package sits below `solution-sdk` in the dependency graph and cannot import
|
|
26
|
+
* from it.
|
|
27
|
+
*/
|
|
28
|
+
export interface ProjectArtifactsResult {
|
|
29
|
+
/** True when artifact resources were generated. */
|
|
30
|
+
Created: boolean;
|
|
31
|
+
/** Error message when `Created` is `false`. */
|
|
32
|
+
Error?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate the `resources/solution_folder/...` artifact-resource entries for
|
|
36
|
+
* a project that has just been registered in its parent solution's `.uipx`.
|
|
37
|
+
*
|
|
38
|
+
* The implementation is resolved at runtime from the installed
|
|
39
|
+
* `@uipath/solution-tool` (through the CLI host's tool-module provider, which
|
|
40
|
+
* installs it on demand), so the multi-megabyte resource-builder chain is
|
|
41
|
+
* never bundled into the calling tool.
|
|
42
|
+
*/
|
|
43
|
+
export declare function ensureProjectArtifacts(args: EnsureProjectArtifactsArgs): Promise<ProjectArtifactsResult>;
|
|
@@ -5,7 +5,7 @@ export type { IContextStorage } from "./context-storage.js";
|
|
|
5
5
|
export { buildEnvironmentProperties, type NormalizedEnvironment, normalizeBaseUrl, normalizeEnvironment, } from "./environment-info.js";
|
|
6
6
|
export { type CiProvider, detectExecutionContext, EXECUTION_CONTEXT_VALUES, type ExecutionContext, type ExecutionContextDetection, type ExecutionContextDetectionOptions, getExecutionContextTelemetryProperties, setExecutionContextAuthSignal, } from "./execution-context.js";
|
|
7
7
|
export { redactError, redactProperties, redactProperty, redactValue, } from "./pii-redactor.js";
|
|
8
|
-
export { getConfiguredTelemetrySessionId, getTelemetrySessionId,
|
|
8
|
+
export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./session-id.js";
|
|
9
9
|
export type { ITelemetryProvider } from "./telemetry-provider.js";
|
|
10
10
|
export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry-service.js";
|
|
11
11
|
export { TELEMETRY_OPERATION_ID_PROPERTY, TELEMETRY_PARENT_ID_PROPERTY, TELEMETRY_SPAN_ID_PROPERTY, TelemetryService, } from "./telemetry-service.js";
|
package/dist/telemetry/index.js
CHANGED
|
@@ -86,7 +86,7 @@ var COMMAND_ATTRIBUTION = commandAttribution([
|
|
|
86
86
|
["agents", "build", ["uip.codedagent", "uip.agent"]],
|
|
87
87
|
["agenthub", "build", ["uip.agenthub"]],
|
|
88
88
|
["coded-apps", "build", ["uip.codedapp"]],
|
|
89
|
-
["functions", "build", ["uip.functions"]],
|
|
89
|
+
["functions", "build", ["uip.function", "uip.functions"]],
|
|
90
90
|
["solution", "build", ["uip.solution"]],
|
|
91
91
|
["maestro", "build", ["uip.maestro", "uip.case", "uip.flow"]],
|
|
92
92
|
["llm-observability", "troubleshoot", ["uip.traces"]],
|
|
@@ -588,8 +588,18 @@ function getInboundTraceContext() {
|
|
|
588
588
|
|
|
589
589
|
// src/telemetry/session-id.ts
|
|
590
590
|
var TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
591
|
-
var
|
|
592
|
-
var
|
|
591
|
+
var SESSION_ID_MAX_LENGTH = 64;
|
|
592
|
+
var RANDOM_SESSION_ID_LENGTH = 32;
|
|
593
|
+
var TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
|
|
594
|
+
var CONTROL_CHARACTERS = /\p{Cc}/gu;
|
|
595
|
+
var INHERITED_SESSION_SOURCES = [
|
|
596
|
+
{ envVar: "CLAUDE_CODE_SESSION_ID", source: "claude-code" },
|
|
597
|
+
{ envVar: "CODEX_THREAD_ID", source: "codex" },
|
|
598
|
+
{ envVar: "ANTIGRAVITY_TRAJECTORY_ID", source: "antigravity" },
|
|
599
|
+
{ envVar: "TERM_SESSION_ID", source: "terminal" },
|
|
600
|
+
{ envVar: "WT_SESSION", source: "terminal" }
|
|
601
|
+
];
|
|
602
|
+
var telemetrySessionSlot = singleton("TelemetrySession");
|
|
593
603
|
var telemetryOperationIdSlot = singleton("TelemetryOperationId");
|
|
594
604
|
function getProcessEnv2() {
|
|
595
605
|
return globalThis.process?.env;
|
|
@@ -598,27 +608,45 @@ function normalizeSessionId(value) {
|
|
|
598
608
|
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") {
|
|
599
609
|
return;
|
|
600
610
|
}
|
|
601
|
-
const
|
|
602
|
-
return
|
|
611
|
+
const cleaned = String(value).replace(CONTROL_CHARACTERS, "").trim().slice(0, SESSION_ID_MAX_LENGTH);
|
|
612
|
+
return cleaned || undefined;
|
|
603
613
|
}
|
|
604
614
|
function getConfiguredTelemetrySessionId() {
|
|
605
615
|
return normalizeSessionId(getProcessEnv2()?.[TELEMETRY_SESSION_ID_ENV]);
|
|
606
616
|
}
|
|
607
|
-
function
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
617
|
+
function getInheritedSession(env) {
|
|
618
|
+
for (const candidate of INHERITED_SESSION_SOURCES) {
|
|
619
|
+
const handle = normalizeSessionId(env[candidate.envVar]);
|
|
620
|
+
if (handle) {
|
|
621
|
+
return { id: handle, source: candidate.source };
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
function generateRandomSession() {
|
|
627
|
+
const bytes = new Uint8Array(RANDOM_SESSION_ID_LENGTH / 2);
|
|
628
|
+
crypto.getRandomValues(bytes);
|
|
629
|
+
let hex = "";
|
|
630
|
+
for (const byte of bytes) {
|
|
631
|
+
hex += byte.toString(16).padStart(2, "0");
|
|
611
632
|
}
|
|
612
|
-
|
|
633
|
+
return { id: hex, source: "random" };
|
|
634
|
+
}
|
|
635
|
+
function resolveTelemetrySession() {
|
|
636
|
+
const existing = telemetrySessionSlot.get();
|
|
613
637
|
if (existing) {
|
|
614
638
|
return existing;
|
|
615
639
|
}
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
640
|
+
const declaredHandle = getConfiguredTelemetrySessionId();
|
|
641
|
+
const resolved = declaredHandle ? { id: declaredHandle, source: "declared" } : getInheritedSession(getProcessEnv2() ?? {}) ?? generateRandomSession();
|
|
642
|
+
telemetrySessionSlot.set(resolved);
|
|
643
|
+
return resolved;
|
|
619
644
|
}
|
|
620
|
-
function
|
|
621
|
-
return
|
|
645
|
+
function getTelemetrySessionId() {
|
|
646
|
+
return resolveTelemetrySession().id;
|
|
647
|
+
}
|
|
648
|
+
function getTelemetrySessionSource() {
|
|
649
|
+
return resolveTelemetrySession().source;
|
|
622
650
|
}
|
|
623
651
|
function getTelemetryOperationId() {
|
|
624
652
|
const existing = telemetryOperationIdSlot.get();
|
|
@@ -734,14 +762,11 @@ class TelemetryService {
|
|
|
734
762
|
}
|
|
735
763
|
async trackDependencyOperation(name, type, fn, properties) {
|
|
736
764
|
const parentContext = this.getCurrentContext();
|
|
737
|
-
|
|
738
|
-
throw new Error("trackDependencyOperation must be called within a trackRequest block.");
|
|
739
|
-
}
|
|
740
|
-
const childContext = {
|
|
765
|
+
const childContext = parentContext !== undefined ? {
|
|
741
766
|
operationId: parentContext.operationId,
|
|
742
767
|
parentId: parentContext.id,
|
|
743
768
|
id: this.generateId()
|
|
744
|
-
};
|
|
769
|
+
} : this.createRequestContext();
|
|
745
770
|
const startTime = performance.now();
|
|
746
771
|
try {
|
|
747
772
|
const result = await this.contextStorage.run(childContext, fn);
|
|
@@ -762,24 +787,18 @@ class TelemetryService {
|
|
|
762
787
|
}
|
|
763
788
|
enrichPropertiesWithContext(properties, context) {
|
|
764
789
|
const globalProperties = getGlobalTelemetryProperties();
|
|
765
|
-
const existingSessionId = properties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? this.defaultProperties?.[TELEMETRY_SESSION_ID_PROPERTY] ?? globalProperties?.[TELEMETRY_SESSION_ID_PROPERTY];
|
|
766
|
-
const sessionId = resolveTelemetrySessionId(existingSessionId);
|
|
767
790
|
const enriched = {
|
|
768
791
|
...getExecutionContextTelemetryProperties(),
|
|
769
792
|
...globalProperties,
|
|
770
793
|
...this.defaultProperties,
|
|
771
794
|
...redactProperties(properties ?? {}),
|
|
795
|
+
[TELEMETRY_SESSION_SOURCE_PROPERTY]: getTelemetrySessionSource(),
|
|
772
796
|
...context ? {
|
|
773
797
|
[TELEMETRY_OPERATION_ID_PROPERTY]: context.operationId,
|
|
774
798
|
...context.parentId !== undefined ? { [TELEMETRY_PARENT_ID_PROPERTY]: context.parentId } : {},
|
|
775
799
|
[TELEMETRY_SPAN_ID_PROPERTY]: context.id
|
|
776
800
|
} : {}
|
|
777
801
|
};
|
|
778
|
-
if (sessionId === undefined) {
|
|
779
|
-
delete enriched[TELEMETRY_SESSION_ID_PROPERTY];
|
|
780
|
-
} else {
|
|
781
|
-
enriched[TELEMETRY_SESSION_ID_PROPERTY] = sessionId;
|
|
782
|
-
}
|
|
783
802
|
return enriched;
|
|
784
803
|
}
|
|
785
804
|
generateId() {
|
|
@@ -797,7 +816,6 @@ class TelemetryService {
|
|
|
797
816
|
}
|
|
798
817
|
export {
|
|
799
818
|
setExecutionContextAuthSignal,
|
|
800
|
-
resolveTelemetrySessionId,
|
|
801
819
|
redactValue,
|
|
802
820
|
redactProperty,
|
|
803
821
|
redactProperties,
|
|
@@ -805,6 +823,7 @@ export {
|
|
|
805
823
|
normalizeSkillName,
|
|
806
824
|
normalizeEnvironment,
|
|
807
825
|
normalizeBaseUrl,
|
|
826
|
+
getTelemetrySessionSource,
|
|
808
827
|
getTelemetrySessionId,
|
|
809
828
|
getExecutionContextTelemetryProperties,
|
|
810
829
|
getConfiguredTelemetrySessionId,
|
|
@@ -814,7 +833,7 @@ export {
|
|
|
814
833
|
buildCommandTelemetryAttribution,
|
|
815
834
|
TelemetryService,
|
|
816
835
|
TELEMETRY_SPAN_ID_PROPERTY,
|
|
817
|
-
|
|
836
|
+
TELEMETRY_SESSION_SOURCE_PROPERTY,
|
|
818
837
|
TELEMETRY_SESSION_ID_ENV,
|
|
819
838
|
TELEMETRY_PARENT_ID_PROPERTY,
|
|
820
839
|
TELEMETRY_OPERATION_ID_PROPERTY,
|
|
@@ -823,4 +842,4 @@ export {
|
|
|
823
842
|
BrowserContextStorage
|
|
824
843
|
};
|
|
825
844
|
|
|
826
|
-
//# debugId=
|
|
845
|
+
//# debugId=E05A0A007C0249BF64756E2164756E21
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { ITelemetryProvider } from "./telemetry-provider.js";
|
|
2
2
|
import { type TelemetryProperties } from "./telemetry-service.js";
|
|
3
3
|
export { getGlobalTelemetryProperties, setGlobalTelemetryProperties, } from "./global-telemetry-properties.js";
|
|
4
|
+
/**
|
|
5
|
+
* Envelopes still buffered in the SDK channel at exit, plus the ingestion
|
|
6
|
+
* endpoint they were headed to. The envelopes are fully formed (tags, ikey,
|
|
7
|
+
* time already baked in) — POSTing them newline-joined and gzipped to
|
|
8
|
+
* `endpointUrl` with `Content-Type: application/x-json-stream` is exactly
|
|
9
|
+
* what the SDK's own sender would have done.
|
|
10
|
+
*/
|
|
11
|
+
export interface PendingTelemetryEnvelopes {
|
|
12
|
+
endpointUrl: string;
|
|
13
|
+
envelopes: unknown[];
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* Node.js Application Insights telemetry provider.
|
|
6
17
|
* Uses the `applicationinsights` Node SDK (not the browser SDK).
|
|
@@ -43,18 +54,6 @@ export declare class NodeAppInsightsTelemetryProvider implements ITelemetryProvi
|
|
|
43
54
|
* inside a scope.
|
|
44
55
|
*/
|
|
45
56
|
private consumeCorrelation;
|
|
46
|
-
/**
|
|
47
|
-
* Promote a `session_id` custom dimension onto the native `ai.session.id`
|
|
48
|
-
* context tag and strip it from the dimension bag. Session belongs in the
|
|
49
|
-
* native session tag — the App Insights Sessions blade reads it there — so
|
|
50
|
-
* shipping it as a custom dimension too is redundant and drifts (the raw
|
|
51
|
-
* tag vs. a redactor-hashed dimension). Only the AppInsights provider does
|
|
52
|
-
* this; fallback providers (logger/console) keep `session_id` as a
|
|
53
|
-
* dimension, since they have no native session field.
|
|
54
|
-
*
|
|
55
|
-
* `merged` is a fresh per-call object, so deleting in place is safe.
|
|
56
|
-
*/
|
|
57
|
-
private promoteSessionTag;
|
|
58
57
|
/**
|
|
59
58
|
* Native correlation tags for a LEAF item (event/exception). It has no item
|
|
60
59
|
* id of its own, so it nests under the current operation: `operation_Id` is
|
|
@@ -79,6 +78,15 @@ export declare class NodeAppInsightsTelemetryProvider implements ITelemetryProvi
|
|
|
79
78
|
trackRequest(name: string, duration: number, success: boolean, properties?: TelemetryProperties): Promise<void>;
|
|
80
79
|
trackDependency(name: string, type: string, duration: number, success: boolean, properties?: TelemetryProperties, resultCode?: string): Promise<void>;
|
|
81
80
|
flush(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Take the envelopes still buffered in the SDK channel (nothing has sent
|
|
83
|
+
* them yet), clearing the batch timer and the buffer so a later
|
|
84
|
+
* {@link shutdown} has nothing left to send or hold the event loop open
|
|
85
|
+
* with. Returns `undefined` when draining isn't possible (no client, no
|
|
86
|
+
* endpoint, or an unexpected SDK shape) — callers must then fall back to
|
|
87
|
+
* a normal in-process {@link flush}.
|
|
88
|
+
*/
|
|
89
|
+
drainPendingEnvelopes(): PendingTelemetryEnvelopes | undefined;
|
|
82
90
|
/**
|
|
83
91
|
* Dispose the Application Insights SDK so its internal channels,
|
|
84
92
|
* keep-alive sockets, and timers are closed — allowing the Node.js
|
package/dist/telemetry/node.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { detectAgent, detectAgentVersion } from "./detect-agent.js";
|
|
|
4
4
|
export { buildEnvironmentProperties, type NormalizedEnvironment, normalizeBaseUrl, normalizeEnvironment, } from "./environment-info.js";
|
|
5
5
|
export { type CiProvider, detectExecutionContext, EXECUTION_CONTEXT_VALUES, type ExecutionContext, type ExecutionContextDetection, type ExecutionContextDetectionOptions, getExecutionContextTelemetryProperties, setExecutionContextAuthSignal, } from "./execution-context.js";
|
|
6
6
|
export { NodeContextStorage } from "./node-context-storage.js";
|
|
7
|
-
export { getConfiguredTelemetrySessionId, getTelemetrySessionId,
|
|
7
|
+
export { getConfiguredTelemetrySessionId, getTelemetrySessionId, getTelemetrySessionSource, TELEMETRY_SESSION_ID_ENV, TELEMETRY_SESSION_SOURCE_PROPERTY, } from "./session-id.js";
|
|
8
8
|
export type { ITelemetryProvider } from "./telemetry-provider.js";
|
|
9
9
|
export type { ITelemetryService, TelemetryContext, TelemetryProperties, } from "./telemetry-service.js";
|
|
10
10
|
export { TELEMETRY_OPERATION_ID_PROPERTY, TELEMETRY_PARENT_ID_PROPERTY, TELEMETRY_SPAN_ID_PROPERTY, TelemetryService, } from "./telemetry-service.js";
|
|
@@ -1,15 +1,61 @@
|
|
|
1
1
|
export declare const TELEMETRY_SESSION_ID_ENV = "UIPATH_SESSION_ID";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Hard ceiling on the emitted session id. App Insights caps `ai.session.id` at
|
|
4
|
+
* 64 characters and truncates past it silently, so the CLI cuts to the same
|
|
5
|
+
* limit itself rather than shipping a value the backend will quietly reshape.
|
|
6
|
+
*
|
|
7
|
+
* Two handles that share their first 64 characters therefore collapse into one
|
|
8
|
+
* session. Accepted: no observed host exports a handle anywhere near this long
|
|
9
|
+
* (every one of them is a UUID or shorter), and hashing to dodge it would make
|
|
10
|
+
* every id opaque — a host could no longer find its own `UIPATH_SESSION_ID` in
|
|
11
|
+
* the data.
|
|
12
|
+
*/
|
|
13
|
+
export declare const SESSION_ID_MAX_LENGTH = 64;
|
|
14
|
+
/** Width of the minted fallback id when no host handle exists. */
|
|
15
|
+
export declare const RANDOM_SESSION_ID_LENGTH = 32;
|
|
16
|
+
/**
|
|
17
|
+
* Custom dimension naming which handle the session id came from. A `terminal`
|
|
18
|
+
* session is not comparable to a `claude-code` one (see the Session Id section
|
|
19
|
+
* of TELEMETRY_GUIDE.md), and the id alone does not say which it is — the
|
|
20
|
+
* handles pass through as the host exported them, with no source marker. Low
|
|
21
|
+
* cardinality by construction: one of {@link TelemetrySessionSource}.
|
|
22
|
+
*/
|
|
23
|
+
export declare const TELEMETRY_SESSION_SOURCE_PROPERTY = "session_id_source";
|
|
24
|
+
/**
|
|
25
|
+
* Where a session id came from — the value of the
|
|
26
|
+
* {@link TELEMETRY_SESSION_SOURCE_PROPERTY} dimension.
|
|
27
|
+
*
|
|
28
|
+
* - `declared`: the host set `UIPATH_SESSION_ID` on purpose. The only boundary
|
|
29
|
+
* someone chose; everything else is inferred.
|
|
30
|
+
* - `claude-code` / `codex` / `antigravity`: one agent conversation.
|
|
31
|
+
* - `terminal`: a terminal tab or pane, which can stay open for weeks and
|
|
32
|
+
* splits when the user splits a pane.
|
|
33
|
+
* - `random`: no host handle at all, so one CLI process.
|
|
34
|
+
*/
|
|
35
|
+
export type TelemetrySessionSource = "declared" | "claude-code" | "codex" | "antigravity" | "terminal" | "random";
|
|
36
|
+
/**
|
|
37
|
+
* The `UIPATH_SESSION_ID` handle as the host exported it (trimmed, control
|
|
38
|
+
* characters stripped, cut to {@link SESSION_ID_MAX_LENGTH}), or undefined when
|
|
39
|
+
* unset. Same value {@link getTelemetrySessionId} emits when it is set.
|
|
40
|
+
*/
|
|
3
41
|
export declare function getConfiguredTelemetrySessionId(): string | undefined;
|
|
4
42
|
/**
|
|
5
|
-
* Resolve the
|
|
43
|
+
* Resolve the session id for App Insights' native `ai.session.id` tag. Session
|
|
44
|
+
* lives on that tag and nowhere else — no custom dimension mirrors it.
|
|
6
45
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
46
|
+
* The id is the host's handle verbatim, so a host that exports
|
|
47
|
+
* `UIPATH_SESSION_ID` can find its own sessions by that literal value. Which
|
|
48
|
+
* handle produced it rides the {@link TELEMETRY_SESSION_SOURCE_PROPERTY}
|
|
49
|
+
* dimension, since the id itself carries no source marker — the same string
|
|
50
|
+
* exported as `TERM_SESSION_ID` and as `UIPATH_SESSION_ID` is one id on two
|
|
51
|
+
* sources.
|
|
10
52
|
*/
|
|
11
53
|
export declare function getTelemetrySessionId(): string;
|
|
12
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Which handle this process's session id came from — emitted on every telemetry
|
|
56
|
+
* item as {@link TELEMETRY_SESSION_SOURCE_PROPERTY}.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getTelemetrySessionSource(): TelemetrySessionSource;
|
|
13
59
|
/**
|
|
14
60
|
* Resolve the per-invocation operation id used for App Insights' native
|
|
15
61
|
* `operation_Id` tag.
|
|
@@ -24,8 +70,7 @@ export declare function resolveTelemetrySessionId(existingSessionId: unknown): s
|
|
|
24
70
|
* transaction and with the API telemetry it triggers.
|
|
25
71
|
*
|
|
26
72
|
* The value is a 32-hex string (a UUID with dashes stripped). That is the shape
|
|
27
|
-
* App Insights expects for `operation_Id`, and
|
|
28
|
-
*
|
|
29
|
-
* raw on every path.
|
|
73
|
+
* App Insights expects for `operation_Id`, and it is left untouched by the PII
|
|
74
|
+
* redactor, so the emitted value matches raw on every path.
|
|
30
75
|
*/
|
|
31
76
|
export declare function getTelemetryOperationId(): string;
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical CLI event names.
|
|
3
|
+
*
|
|
4
|
+
* Every name lives under the `uip.*` namespace so a single
|
|
5
|
+
* `name startswith "uip."` filter selects all CLI telemetry — a snake_case
|
|
6
|
+
* name outside it is invisible to every downstream pipeline (STUD-80942).
|
|
7
|
+
*/
|
|
1
8
|
export declare const CommonTelemetryEvents: {
|
|
2
9
|
readonly Error: "uip.error";
|
|
3
|
-
|
|
10
|
+
/** A ship (publish/deploy/upload) completed. The command that shipped is
|
|
11
|
+
* carried by the `command_name` dimension; `ship_kind`/`target` describe
|
|
12
|
+
* what was shipped where. */
|
|
13
|
+
readonly ShipSucceeded: "uip.ship.succeeded";
|
|
4
14
|
};
|
|
@@ -41,8 +41,23 @@ export interface TelemetryInitOptions {
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function telemetryInit(options?: TelemetryInitOptions): Promise<void>;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* Must be awaited
|
|
46
|
-
*
|
|
44
|
+
* Deliver all buffered telemetry before the process exits.
|
|
45
|
+
* Must be awaited on every exit path.
|
|
46
|
+
*
|
|
47
|
+
* Normally hands the buffered envelopes to a detached sidecar process (see
|
|
48
|
+
* {@link trySidecarHandoff}) so the exit is instant. Falls back to the
|
|
49
|
+
* in-process flush — one ingestion round-trip, capped at
|
|
50
|
+
* FLUSH_SHUTDOWN_TIMEOUT_MS — when the sidecar handoff isn't available or
|
|
51
|
+
* UIPATH_TELEMETRY_SYNC_FLUSH=1 forces it.
|
|
47
52
|
*/
|
|
48
53
|
export declare function telemetryFlushAndShutdown(): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Dispose the telemetry SDK without sending — buffered events are dropped
|
|
56
|
+
* on purpose. For exits where delivery is not worth a network round-trip
|
|
57
|
+
* (help/version display).
|
|
58
|
+
*
|
|
59
|
+
* Shares the memo slot with {@link telemetryFlushAndShutdown}: whichever
|
|
60
|
+
* runs first wins, so a later flush call on the same exit path awaits the
|
|
61
|
+
* already-finished shutdown instead of opening a network connection.
|
|
62
|
+
*/
|
|
63
|
+
export declare function telemetryShutdownWithoutFlush(): Promise<void>;
|
|
@@ -193,6 +193,11 @@ export interface ITelemetryService {
|
|
|
193
193
|
* @remarks
|
|
194
194
|
* Tracks this operation as a dependency in Application Insights, automatically correlated
|
|
195
195
|
* to the parent request using the context from IContextStorage.
|
|
196
|
+
*
|
|
197
|
+
* With no enclosing request the dependency is emitted as a trace root (no
|
|
198
|
+
* `operation_ParentId`) rather than being dropped or throwing — a reusable
|
|
199
|
+
* unit of work stays a dependency even when the host that called it never
|
|
200
|
+
* opened a request of ours.
|
|
196
201
|
*/
|
|
197
202
|
trackDependencyOperation<T>(name: string, type: string, fn: () => Promise<T>, properties?: TelemetryProperties): Promise<T>;
|
|
198
203
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hidden argv verb that makes the CLI entry point run the spool sender
|
|
3
|
+
* instead of the normal Commander pipeline. Never registered as a command —
|
|
4
|
+
* the entry point matches it on raw argv before the program is built.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TELEMETRY_DRAIN_ARGV = "__uip-drain-telemetry";
|
|
7
|
+
/**
|
|
8
|
+
* Register the script path that handles {@link TELEMETRY_DRAIN_ARGV}.
|
|
9
|
+
* Called once by the CLI entry point at startup; until it is called, the
|
|
10
|
+
* exit path keeps the in-process flush (no sidecar is ever spawned).
|
|
11
|
+
*/
|
|
12
|
+
export declare function setTelemetrySidecarEntry(entryPath: string): void;
|
|
13
|
+
export declare function getTelemetrySidecarEntry(): string | undefined;
|
|
14
|
+
/** Contents of one spool file. */
|
|
15
|
+
export interface TelemetrySpoolPayload {
|
|
16
|
+
/** Full ingestion URL (`<IngestionEndpoint>/v2.1/track`). */
|
|
17
|
+
endpointUrl: string;
|
|
18
|
+
/** Fully-formed App Insights envelopes, exactly as the SDK buffered them. */
|
|
19
|
+
envelopes: unknown[];
|
|
20
|
+
}
|
|
21
|
+
/** A pending spool file claimed for sending (renamed to `.sending`). */
|
|
22
|
+
export interface ClaimedSpoolFile {
|
|
23
|
+
/** The claimed (`.sending`) path — delete it after a successful send. */
|
|
24
|
+
claimedPath: string;
|
|
25
|
+
payload: TelemetrySpoolPayload;
|
|
26
|
+
}
|
|
27
|
+
/** Spool files older than this are deleted unsent — stale telemetry has no value. */
|
|
28
|
+
export declare const MAX_SPOOL_AGE_MS: number;
|
|
29
|
+
/** Hard cap on spool files; oldest beyond this are deleted (offline machines). */
|
|
30
|
+
export declare const MAX_SPOOL_FILES = 50;
|
|
31
|
+
export declare function getTelemetrySpoolDir(): string;
|
|
32
|
+
/**
|
|
33
|
+
* Persist pending envelopes for the sidecar. Writes to a `.tmp` name first
|
|
34
|
+
* and renames into place so a concurrently-running sender never claims a
|
|
35
|
+
* half-written file. Returns the spool file path.
|
|
36
|
+
*/
|
|
37
|
+
export declare function writeTelemetrySpoolFile(payload: TelemetrySpoolPayload): Promise<string>;
|
|
38
|
+
/**
|
|
39
|
+
* Claim every pending spool file for sending. Claiming renames the file to
|
|
40
|
+
* `.sending` — an atomic operation, so when two senders sweep concurrently
|
|
41
|
+
* only one wins each file and nothing is delivered twice. Files that fail
|
|
42
|
+
* the rename are skipped (another sender owns them).
|
|
43
|
+
*
|
|
44
|
+
* Bad content is split two ways on purpose: a file that cannot be READ is
|
|
45
|
+
* released for a later attempt (on Windows a concurrent handle shows up as a
|
|
46
|
+
* transient EBUSY, and deleting there would throw telemetry away for a problem
|
|
47
|
+
* that resolves itself), while a file that reads fine but does not parse or
|
|
48
|
+
* does not match the payload shape is deleted — no future sweep can make it
|
|
49
|
+
* valid, so keeping it would just burn a claim on every run until the age cap.
|
|
50
|
+
*/
|
|
51
|
+
export declare function claimPendingSpoolFiles(): Promise<ClaimedSpoolFile[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Return a claimed file to the pending pool so a future sender retries it.
|
|
54
|
+
* Best-effort: if the rename fails the file stays `.sending` and the age
|
|
55
|
+
* cap eventually removes it.
|
|
56
|
+
*/
|
|
57
|
+
export declare function releaseClaimedSpoolFile(claimedPath: string): Promise<void>;
|
|
58
|
+
/** Delete a claimed file after its envelopes were delivered. Best-effort. */
|
|
59
|
+
export declare function discardClaimedSpoolFile(claimedPath: string): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Enforce the spool bounds: delete any file older than
|
|
62
|
+
* {@link MAX_SPOOL_AGE_MS} — including `.sending` files orphaned by a
|
|
63
|
+
* crashed sender and `.tmp` files orphaned by a crashed writer — and keep at
|
|
64
|
+
* most {@link MAX_SPOOL_FILES} pending files, deleting the oldest beyond
|
|
65
|
+
* that. Run by the sender before claiming, so an unreachable endpoint can't
|
|
66
|
+
* grow the spool without bound.
|
|
67
|
+
*/
|
|
68
|
+
export declare function sweepTelemetrySpool(): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic import of another tool's library entry point (e.g.
|
|
3
|
+
* `@uipath/solution-tool/init`).
|
|
4
|
+
*
|
|
5
|
+
* Its own module so tests can stand in for it, and so the specifier stays a
|
|
6
|
+
* plain variable — bundlers then leave the `import()` to run at runtime
|
|
7
|
+
* instead of inlining the multi-megabyte target bundle into the caller.
|
|
8
|
+
*/
|
|
9
|
+
export declare function importToolModule(specifier: string): Promise<unknown>;
|
package/dist/tool-provider.d.ts
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cross-module bridge for packager factory resolution.
|
|
2
|
+
* Cross-module bridge for packager factory and tool-module resolution.
|
|
3
3
|
*/
|
|
4
4
|
export type PackagerFactoryProvider = (verb: string) => Promise<void>;
|
|
5
5
|
export declare function setPackagerFactoryProvider(provider: PackagerFactoryProvider): void;
|
|
6
|
-
export
|
|
6
|
+
export type ToolModuleProvider = (verb: string, moduleName: string) => Promise<unknown>;
|
|
7
|
+
export declare function setToolModuleProvider(provider: ToolModuleProvider): void;
|
|
8
|
+
/**
|
|
9
|
+
* Resolve another tool's library entry point (its `dist/<module>.js` subpath
|
|
10
|
+
* export) at runtime and return the module namespace.
|
|
11
|
+
*
|
|
12
|
+
* Prefers the registered provider (installed by the CLI — it can install the
|
|
13
|
+
* tool on demand and imports the entry by absolute path). With no provider —
|
|
14
|
+
* a library caller — falls back to importing `<packageName>/<moduleName>`,
|
|
15
|
+
* which resolves when the tool package is installed next to the caller.
|
|
16
|
+
*
|
|
17
|
+
* This is how one tool uses another tool's code without bundling it: the
|
|
18
|
+
* multi-megabyte implementation ships once, in the tool that owns it.
|
|
19
|
+
*
|
|
20
|
+
* @param verb - CLI tool verb that owns the module (e.g. `"solution"`).
|
|
21
|
+
* @param packageName - npm package behind that verb, used for the fallback
|
|
22
|
+
* import (e.g. `"@uipath/solution-tool"`).
|
|
23
|
+
* @param moduleName - subpath entry to load (e.g. `"init"`, `"resource"`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function ensureToolModule(verb: string, packageName: string, moduleName: string): Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the packager factory for a tool verb.
|
|
28
|
+
*
|
|
29
|
+
* Prefers the registered provider (installed by the CLI). With no provider —
|
|
30
|
+
* a library caller — falls back to the tool package's own `packager-tool`
|
|
31
|
+
* entry point: imports it and calls its `registerPackagerFactories` export.
|
|
32
|
+
*
|
|
33
|
+
* @param verb - CLI tool verb that owns the factory (e.g. `"maestro"`).
|
|
34
|
+
* @param packageName - npm package behind that verb. Drives the fallback
|
|
35
|
+
* import and is the one thing the error asks for. Omit when unknown; there is
|
|
36
|
+
* then no fallback and no package to name.
|
|
37
|
+
*/
|
|
38
|
+
export declare function ensurePackagerFactory(verb: string, packageName?: string): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/common",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.200.0-preview.109",
|
|
5
5
|
"description": "Common infrastructure needed by uip tools.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"types": "./dist/catch-error.d.ts",
|
|
29
29
|
"default": "./dist/catch-error.js"
|
|
30
30
|
},
|
|
31
|
+
"./guid": {
|
|
32
|
+
"types": "./dist/guid.d.ts",
|
|
33
|
+
"default": "./dist/guid.js"
|
|
34
|
+
},
|
|
31
35
|
"./sdk-user-agent": {
|
|
32
36
|
"browser": {
|
|
33
37
|
"types": "./dist/sdk-user-agent.d.ts",
|
|
@@ -67,5 +71,5 @@
|
|
|
67
71
|
"mihaigirleanu",
|
|
68
72
|
"vlad-uipath"
|
|
69
73
|
],
|
|
70
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "fcc01cdae81bbd0c25d3d4fc287537a9d19d99f4"
|
|
71
75
|
}
|