@uipath/agent-tool 1.203.0-preview.212 → 1.204.0-preview.211

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/index.js CHANGED
@@ -2,13 +2,17 @@
2
2
  import {
3
3
  metadata,
4
4
  registerCommands
5
- } from "./packager-tool-bdc2kdaq.js";
5
+ } from "./packager-tool-qdh8wsed.js";
6
6
  import"./packager-tool-4mna26cc.js";
7
7
  import"./packager-tool-c23zrhj8.js";
8
- import"./packager-tool-fq0ks8zk.js";
8
+ import"./packager-tool-hm6kh89x.js";
9
+ import"./packager-tool-22j48tpa.js";
10
+ import"./packager-tool-kb4fk2pb.js";
11
+ import"./packager-tool-nqcmgnpm.js";
12
+ import"./packager-tool-xhvv7tkq.js";
9
13
  import {
10
14
  Command
11
- } from "./packager-tool-tnz82jk0.js";
15
+ } from "./packager-tool-ryge2f2x.js";
12
16
  import"./packager-tool-mc1499dc.js";
13
17
  import"./packager-tool-b098y4a2.js";
14
18
  import"./packager-tool-1yh8g550.js";
@@ -19,4 +23,4 @@ program.name(metadata.commandPrefix).description(metadata.description).version(m
19
23
  await registerCommands(program);
20
24
  await program.parseAsync(process.argv);
21
25
 
22
- //# debugId=3B74D6D1ADF7C3FE64756E2164756E21
26
+ //# debugId=829F3B3A086F0A5D64756E2164756E21
@@ -0,0 +1,138 @@
1
+ import {
2
+ getLoginStatusAsync
3
+ } from "./packager-tool-xhvv7tkq.js";
4
+ import {
5
+ catchError
6
+ } from "./packager-tool-ryge2f2x.js";
7
+ import {
8
+ __require
9
+ } from "./packager-tool-1yh8g550.js";
10
+
11
+ // src/services/memory-runtime-service.ts
12
+ async function resolveAuth() {
13
+ const [loginError, loginStatus] = await catchError(getLoginStatusAsync({ ensureTokenValidityMinutes: 10 }));
14
+ if (loginError) {
15
+ throw new Error(loginError.message);
16
+ }
17
+ if (loginStatus.loginStatus !== "Logged in" || !loginStatus.baseUrl) {
18
+ throw new Error("Not authenticated. Run 'uip login' first.");
19
+ }
20
+ if (!loginStatus.tenantName || !loginStatus.organizationId) {
21
+ throw new Error("The session has no tenant or organization. Run 'uip login tenant set <tenant-name>'.");
22
+ }
23
+ if (!loginStatus.accessToken) {
24
+ throw new Error("The session reports logged in but has no access token. Run 'uip login' again to refresh it.");
25
+ }
26
+ return {
27
+ baseUrl: loginStatus.baseUrl,
28
+ orgId: loginStatus.organizationId,
29
+ tenantName: loginStatus.tenantName,
30
+ token: loginStatus.accessToken
31
+ };
32
+ }
33
+ function memoryBaseUrl(auth) {
34
+ return `${auth.baseUrl}/${encodeURIComponent(auth.orgId)}/${encodeURIComponent(auth.tenantName)}/llmopstenant_/api/Memory`;
35
+ }
36
+ async function memoryFetch(auth, path, options = {}) {
37
+ const headers = {
38
+ Authorization: `Bearer ${auth.token}`,
39
+ Accept: "application/json"
40
+ };
41
+ if (options.folderKey !== undefined) {
42
+ headers["X-UiPath-FolderKey"] = options.folderKey;
43
+ }
44
+ if (options.body !== undefined) {
45
+ headers["Content-Type"] = "application/json";
46
+ }
47
+ return fetch(`${memoryBaseUrl(auth)}${path}`, {
48
+ method: options.method ?? "GET",
49
+ headers,
50
+ body: options.body !== undefined ? JSON.stringify(options.body) : undefined
51
+ });
52
+ }
53
+ async function failWith(response, context) {
54
+ if (response.status === 401) {
55
+ throw new Error("Not authenticated. Run 'uip login' first.");
56
+ }
57
+ if (response.status === 403) {
58
+ throw new Error(`Insufficient permissions for ${context}. Memory items need Logs.View / Logs.Create on the folder the memory space lives in.`);
59
+ }
60
+ if (response.status === 404) {
61
+ throw new Error(`${context} was not found.`);
62
+ }
63
+ const text = await response.text();
64
+ const [parseError, parsed] = catchError(() => JSON.parse(text));
65
+ const detail = !parseError && typeof parsed?.errorMessage === "string" ? `${parsed.errorMessage}${typeof parsed.code === "string" ? ` (${parsed.code})` : ""}` : text;
66
+ throw new Error(`Memory store rejected ${context}: ${response.status} ${response.statusText}. ${detail}`);
67
+ }
68
+ async function readJson(response, context) {
69
+ const text = await response.text();
70
+ if (!text)
71
+ return;
72
+ const [parseError, parsed] = catchError(() => JSON.parse(text));
73
+ if (parseError) {
74
+ throw new Error(`Memory store answered ${response.status} for ${context} but the body was not JSON: ${text.slice(0, 200)}`);
75
+ }
76
+ return parsed;
77
+ }
78
+ async function resolveRuntimeFolder(input) {
79
+ const { resolveFolder } = await import("./index-q0fkqv6h.js");
80
+ const [resolveError, folder] = await catchError(resolveFolder(input));
81
+ if (resolveError) {
82
+ if (input.folderPath !== undefined && input.folderKey === undefined && resolveError.message.startsWith("Folder not found")) {
83
+ throw new Error(`${resolveError.message} Personal Workspace and debug folders cannot be resolved by path; pass --folder-key instead ('uip or folders list' shows the Key, 'uip solution deploy list' shows FolderKey).`);
84
+ }
85
+ throw resolveError;
86
+ }
87
+ if (!folder) {
88
+ throw new Error("A folder is required to reach the runtime memory space. Pass --folder-path or --folder-key.");
89
+ }
90
+ return { key: folder.key, path: folder.path };
91
+ }
92
+ async function findRuntimeMemorySpace(name, folderKey) {
93
+ const auth = await resolveAuth();
94
+ const response = await memoryFetch(auth, "");
95
+ if (!response.ok) {
96
+ await failWith(response, "the memory space list");
97
+ }
98
+ const spaces = await readJson(response, "the memory space list") ?? [];
99
+ const wanted = name.toLowerCase();
100
+ const match = spaces.find((space) => space.name?.toLowerCase() === wanted && (space.folderKey ?? "").toLowerCase() === folderKey.toLowerCase());
101
+ if (!match) {
102
+ throw new Error(`Memory space "${name}" was not found in that folder. It is created when the solution that declares it is deployed; check 'uip solution deploy list' and pass the deployment folder with --folder-path.`);
103
+ }
104
+ return match;
105
+ }
106
+ async function listRuntimeMemoryItems(spaceId, folderKey, memoryType) {
107
+ const auth = await resolveAuth();
108
+ const query = memoryType === undefined ? "" : `?memoryType=${memoryType}`;
109
+ const context = `memory space ${spaceId}`;
110
+ const response = await memoryFetch(auth, `/${spaceId}/items${query}`, {
111
+ folderKey
112
+ });
113
+ if (!response.ok) {
114
+ await failWith(response, context);
115
+ }
116
+ return await readJson(response, context) ?? [];
117
+ }
118
+ async function addRuntimeMemoryItem(spaceId, folderKey, request) {
119
+ const auth = await resolveAuth();
120
+ const context = `memory space ${spaceId}`;
121
+ const response = await memoryFetch(auth, `/${spaceId}/items`, {
122
+ method: "POST",
123
+ folderKey,
124
+ body: request
125
+ });
126
+ if (!response.ok) {
127
+ await failWith(response, context);
128
+ }
129
+ return readJson(response, context);
130
+ }
131
+ export {
132
+ addRuntimeMemoryItem,
133
+ findRuntimeMemorySpace,
134
+ listRuntimeMemoryItems,
135
+ resolveRuntimeFolder
136
+ };
137
+
138
+ //# debugId=EE21839693C3EC8F64756E2164756E21