nolo-cli 0.1.32 → 0.1.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.
Files changed (230) hide show
  1. package/README.md +0 -6
  2. package/agent-runtime/agentRecordConfig.ts +2 -0
  3. package/agent-runtime/hostAdapter.ts +1 -0
  4. package/agent-runtime/index.ts +0 -21
  5. package/agent-runtime/localToolPolicy.ts +6 -13
  6. package/agent-runtime/localWorkspaceTools.ts +30 -333
  7. package/agent-runtime/platformChatProvider.ts +1 -4
  8. package/agent-runtime/runtimeToolPolicy.ts +47 -32
  9. package/agentAliases.ts +14 -83
  10. package/agentCommandSupport.ts +3 -6
  11. package/agentInternalCommandEntries.ts +2 -13
  12. package/agentListCommands.ts +19 -28
  13. package/agentMachineCommands.ts +40 -336
  14. package/agentPullCommand.ts +36 -56
  15. package/agentRecordCommands.ts +3 -5
  16. package/agentRecordHelpers.ts +22 -189
  17. package/agentRunCommand.ts +438 -107
  18. package/agentRuntimeLocal.ts +0 -10
  19. package/ai/agent/cliExecutor.ts +19 -323
  20. package/authCommands.ts +2 -36
  21. package/cli/agentAliases.ts +14 -83
  22. package/cli/agentCommandSupport.ts +3 -6
  23. package/cli/agentInternalCommandEntries.ts +2 -13
  24. package/cli/agentListCommands.ts +19 -28
  25. package/cli/agentMachineCommands.ts +40 -336
  26. package/cli/agentPullCommand.ts +36 -56
  27. package/cli/agentRecordCommands.ts +3 -5
  28. package/cli/agentRecordHelpers.ts +22 -189
  29. package/cli/agentRunCommand.ts +438 -107
  30. package/cli/agentRuntimeLocal.ts +0 -10
  31. package/cli/authCommands.ts +2 -36
  32. package/cli/cliEnvHelpers.ts +21 -162
  33. package/cli/client/agentRun.ts +853 -57
  34. package/cli/client/localRuntimeAdapter.ts +22 -159
  35. package/cli/client/streamingOutput.ts +3 -1
  36. package/cli/client/taskRunPrompt.ts +24 -7
  37. package/cli/commandRegistry.ts +2 -3
  38. package/cli/connectorRunArtifact.ts +10 -34
  39. package/cli/connectorWebSocketTarget.ts +6 -10
  40. package/cli/internalCommandEntries.ts +0 -8
  41. package/cli/localRuntimeDb.ts +2 -39
  42. package/cli/machineCommands.ts +189 -190
  43. package/cli/machineDaemonCommands.ts +165 -9
  44. package/cli/machineHeartbeatCommands.ts +2 -1
  45. package/cli/machineStatusCommands.ts +13 -5
  46. package/cli/machineWatchCommands.ts +1 -1
  47. package/cli/machineWsRunDispatch.ts +14 -48
  48. package/cli/machineWsSession.ts +0 -2
  49. package/cli/offlineMarxistsAgentCommand.ts +314 -0
  50. package/cli/runtimeDoctorCommands.ts +69 -18
  51. package/cli/scriptCommandEntries.ts +45 -5
  52. package/cli/tableCommands.ts +133 -33
  53. package/cli/taskRunCommand.ts +211 -16
  54. package/cli/tui/session.ts +372 -43
  55. package/cli/workflowInternalCommandEntries.ts +0 -20
  56. package/cliEnvHelpers.ts +21 -162
  57. package/client/agentConfigResolver.test.ts +2 -0
  58. package/client/agentRun.test.ts +12 -208
  59. package/client/agentRun.ts +853 -57
  60. package/client/localRuntimeAdapter.test.ts +9 -168
  61. package/client/localRuntimeAdapter.ts +22 -159
  62. package/client/localToolPolicy.test.ts +4 -28
  63. package/client/streamingOutput.ts +3 -1
  64. package/client/taskRunPrompt.ts +24 -7
  65. package/commandRegistry.ts +2 -3
  66. package/connectorRunArtifact.ts +10 -34
  67. package/connectorWebSocketTarget.ts +6 -10
  68. package/database/server/db.ts +34 -15
  69. package/internalCommandEntries.ts +0 -8
  70. package/localRuntimeDb.ts +2 -39
  71. package/machineCommands.ts +189 -190
  72. package/machineDaemonCommands.ts +165 -9
  73. package/machineHeartbeatCommands.ts +2 -1
  74. package/machineStatusCommands.ts +13 -5
  75. package/machineWatchCommands.ts +1 -1
  76. package/machineWsRunDispatch.ts +14 -48
  77. package/machineWsSession.ts +0 -2
  78. package/offlineMarxistsAgentCommand.ts +314 -0
  79. package/package.json +49 -193
  80. package/runtimeDoctorCommands.ts +69 -18
  81. package/scriptCommandEntries.ts +45 -5
  82. package/tableCommands.ts +133 -33
  83. package/taskRunCommand.ts +211 -16
  84. package/tui/session.ts +372 -43
  85. package/workflowInternalCommandEntries.ts +0 -20
  86. package/agent-runtime/dialogStatus.ts +0 -139
  87. package/agent-runtime/hostRuntimeConfig.ts +0 -86
  88. package/agentCreateCustomCommands.ts +0 -278
  89. package/agentDialogsCommands.ts +0 -227
  90. package/agentDoctorCommands.ts +0 -203
  91. package/agentRunLocalWorkspace.ts +0 -182
  92. package/agentRunParsing.ts +0 -298
  93. package/agentSuperviseCommands.ts +0 -8
  94. package/agentUnpublishCommands.ts +0 -113
  95. package/ai/agent/agentRunDialogLineage.ts +0 -56
  96. package/ai/policy/types.ts +0 -64
  97. package/ai/skills/skillSummaryMarker.ts +0 -26
  98. package/app/types.ts +0 -358
  99. package/build.ts +0 -16
  100. package/buildPublish.ts +0 -138
  101. package/buildPublishArtifactAssembly.ts +0 -724
  102. package/buildPublishImportAnalysis.ts +0 -242
  103. package/chat/messages/fetchMessages.ts +0 -84
  104. package/chat/messages/types.ts +0 -185
  105. package/cli/agentCreateCustomCommands.ts +0 -278
  106. package/cli/agentDialogsCommands.ts +0 -227
  107. package/cli/agentDoctorCommands.ts +0 -203
  108. package/cli/agentRunLocalWorkspace.ts +0 -182
  109. package/cli/agentRunParsing.ts +0 -298
  110. package/cli/agentSuperviseCommands.ts +0 -8
  111. package/cli/agentUnpublishCommands.ts +0 -113
  112. package/cli/buildPublish.ts +0 -138
  113. package/cli/buildPublishArtifactAssembly.ts +0 -724
  114. package/cli/buildPublishImportAnalysis.ts +0 -242
  115. package/cli/cliIoTypes.ts +0 -3
  116. package/cli/cliRuntimeDoctorReport.ts +0 -193
  117. package/cli/client/agentRunInput.ts +0 -10
  118. package/cli/client/agentRunLocalExecution.ts +0 -124
  119. package/cli/client/agentRunLocalExecutor.ts +0 -179
  120. package/cli/client/agentRunRuntimeSelection.ts +0 -145
  121. package/cli/client/agentRunServerTransport.ts +0 -397
  122. package/cli/client/agentRunTaskRunRecorder.ts +0 -176
  123. package/cli/customCodingAgentFlow.ts +0 -208
  124. package/cli/customCodingAgentRecord.ts +0 -179
  125. package/cli/dialogDataAccess.ts +0 -186
  126. package/cli/dialogInternalCommandEntries.ts +0 -11
  127. package/cli/dialogReadCommands.ts +0 -180
  128. package/cli/dialogReadHelpers.ts +0 -226
  129. package/cli/dialogStatusCommands.ts +0 -123
  130. package/cli/docInternalCommandEntries.ts +0 -20
  131. package/cli/hybridReadHelpers.ts +0 -109
  132. package/cli/machineCommandPrompts.ts +0 -79
  133. package/cli/machineCommandResolution.ts +0 -43
  134. package/cli/noloReadBridgePrompt.ts +0 -16
  135. package/cli/pageCreateCommands.ts +0 -219
  136. package/cli/pageDeleteCommands.ts +0 -167
  137. package/cli/pageReadCommands.ts +0 -151
  138. package/cli/pageUpdateCommands.ts +0 -249
  139. package/cli/pageWriteHelpers.ts +0 -209
  140. package/cli/publishPackage.ts +0 -36
  141. package/cli/runtimeInternalCommandEntries.ts +0 -15
  142. package/cli/runtimePassthroughCommands.ts +0 -22
  143. package/cli/scriptPassthroughHelpers.ts +0 -28
  144. package/cli/secretScanHelpers.ts +0 -31
  145. package/cli/spaceAttachCommands.ts +0 -134
  146. package/cli/spaceCategoryCommands.ts +0 -263
  147. package/cli/spaceCommands.ts +0 -295
  148. package/cli/spaceDeleteCommands.ts +0 -312
  149. package/cli/spaceInternalCommandEntries.ts +0 -21
  150. package/cli/spaceMutationHelpers.ts +0 -135
  151. package/cli/spaceReadCommands.ts +0 -323
  152. package/cli/tableDataOutput.ts +0 -41
  153. package/cli/tableDataSafety.ts +0 -26
  154. package/cli/tableMetaCommands.ts +0 -307
  155. package/cli/tableMutationCommands.ts +0 -266
  156. package/cli/tableQueryParsing.ts +0 -90
  157. package/cli/tableQueryRequest.ts +0 -53
  158. package/cli/taskRunActions.ts +0 -122
  159. package/cli/taskRunParsing.ts +0 -86
  160. package/cli/taskRunPromptShared.ts +0 -55
  161. package/cli/tui/tuiCatalog.ts +0 -22
  162. package/cli/tui/tuiCommandInterpreter.ts +0 -253
  163. package/cli/tui/tuiPresentation.ts +0 -146
  164. package/cliIoTypes.ts +0 -3
  165. package/cliRuntimeDoctorReport.ts +0 -193
  166. package/client/agentRunInput.ts +0 -10
  167. package/client/agentRunLocalExecution.test.ts +0 -123
  168. package/client/agentRunLocalExecution.ts +0 -124
  169. package/client/agentRunLocalExecutor.ts +0 -179
  170. package/client/agentRunRuntimeSelection.test.ts +0 -159
  171. package/client/agentRunRuntimeSelection.ts +0 -145
  172. package/client/agentRunServerTransport.ts +0 -397
  173. package/client/agentRunTaskRunRecorder.ts +0 -176
  174. package/connector-experimental/daemonLauncher.ts +0 -223
  175. package/create/space/spaceKeys.ts +0 -65
  176. package/create/types.ts +0 -21
  177. package/customCodingAgentFlow.ts +0 -208
  178. package/customCodingAgentRecord.ts +0 -179
  179. package/database/keys.ts +0 -765
  180. package/database/server/authorityStoreTypes.ts +0 -31
  181. package/database/server/legacyServerDb.ts +0 -58
  182. package/database/server/levelAuthorityStore.ts +0 -75
  183. package/database/server/memoryAuthorityStore.ts +0 -133
  184. package/database/server/serverStoreFactory.ts +0 -124
  185. package/database/tombstones.ts +0 -52
  186. package/database/utils/ulid.ts +0 -1
  187. package/dialogDataAccess.ts +0 -186
  188. package/dialogInternalCommandEntries.ts +0 -11
  189. package/dialogReadCommands.ts +0 -180
  190. package/dialogReadHelpers.ts +0 -226
  191. package/dialogStatusCommands.ts +0 -123
  192. package/docInternalCommandEntries.ts +0 -20
  193. package/hybridReadHelpers.ts +0 -109
  194. package/machineCommandPrompts.ts +0 -79
  195. package/machineCommandResolution.ts +0 -43
  196. package/noloReadBridgePrompt.ts +0 -16
  197. package/pageCreateCommands.ts +0 -219
  198. package/pageDeleteCommands.ts +0 -167
  199. package/pageReadCommands.ts +0 -151
  200. package/pageUpdateCommands.ts +0 -249
  201. package/pageWriteHelpers.ts +0 -209
  202. package/publishPackage.ts +0 -36
  203. package/runtimeInternalCommandEntries.ts +0 -15
  204. package/runtimePassthroughCommands.ts +0 -22
  205. package/scriptPassthroughHelpers.ts +0 -28
  206. package/secretScanHelpers.ts +0 -31
  207. package/share/helpers.ts +0 -302
  208. package/share/keys.ts +0 -243
  209. package/share/types.ts +0 -100
  210. package/spaceAttachCommands.ts +0 -134
  211. package/spaceCategoryCommands.ts +0 -263
  212. package/spaceCommands.ts +0 -295
  213. package/spaceDeleteCommands.ts +0 -312
  214. package/spaceInternalCommandEntries.ts +0 -21
  215. package/spaceMutationHelpers.ts +0 -135
  216. package/spaceReadCommands.ts +0 -323
  217. package/tableDataOutput.ts +0 -41
  218. package/tableDataSafety.ts +0 -26
  219. package/tableMetaCommands.ts +0 -307
  220. package/tableMutationCommands.ts +0 -266
  221. package/tableQueryParsing.ts +0 -90
  222. package/tableQueryRequest.ts +0 -53
  223. package/taskRunActions.ts +0 -122
  224. package/taskRunParsing.ts +0 -86
  225. package/taskRunPromptShared.ts +0 -55
  226. package/tui/tuiCatalog.ts +0 -22
  227. package/tui/tuiCommandInterpreter.test.ts +0 -169
  228. package/tui/tuiCommandInterpreter.ts +0 -253
  229. package/tui/tuiPresentation.test.ts +0 -154
  230. package/tui/tuiPresentation.ts +0 -146
@@ -9,7 +9,6 @@ import {
9
9
  loadProfileConfig,
10
10
  saveDefaultProfile,
11
11
  } from "./client/profileConfig";
12
- import { parseUserIdFromAuthToken } from "./cliEnvHelpers";
13
12
  import { DEFAULT_NOLO_SERVER_URL } from "./defaultServer";
14
13
 
15
14
  function getArg(args: string[], flag: string) {
@@ -68,47 +67,17 @@ async function saveTokenLogin(args: {
68
67
  configPath: string;
69
68
  serverUrl: string;
70
69
  authToken: string;
71
- fetchImpl: typeof fetch;
72
70
  output: Pick<Console, "log">;
73
71
  error: Pick<Console, "error">;
74
72
  }) {
75
- const authToken = args.authToken.trim();
76
- if (!authToken) {
73
+ if (!args.authToken.trim()) {
77
74
  args.error.error("No auth token provided.");
78
75
  return 1;
79
76
  }
80
77
 
81
- const userId = parseUserIdFromAuthToken(authToken);
82
- if (!userId) {
83
- args.error.error("Auth token payload is missing userId.");
84
- return 1;
85
- }
86
-
87
- try {
88
- const res = await args.fetchImpl(
89
- `${args.serverUrl}/api/v1/db/query/${encodeURIComponent(userId)}?limit=1`,
90
- {
91
- method: "POST",
92
- headers: {
93
- Authorization: `Bearer ${authToken}`,
94
- "Content-Type": "application/json",
95
- },
96
- body: JSON.stringify({ type: "agent" }),
97
- }
98
- );
99
- if (res.status === 401 || res.status === 403) {
100
- args.error.error(
101
- `Auth token is not valid for ${args.serverUrl}. Log in against the matching server or use a token issued by that server.`
102
- );
103
- return 1;
104
- }
105
- } catch {
106
- // Allow saving when the server is temporarily unreachable.
107
- }
108
-
109
78
  saveDefaultProfile(args.configPath, {
110
79
  serverUrl: args.serverUrl,
111
- authToken,
80
+ authToken: args.authToken.trim(),
112
81
  });
113
82
  args.output.log(`Saved profile default -> ${args.serverUrl}`);
114
83
  return 0;
@@ -175,7 +144,6 @@ async function runWebLogin(args: {
175
144
  configPath: args.configPath,
176
145
  serverUrl: approvedServer,
177
146
  authToken: poll.token,
178
- fetchImpl: args.fetchImpl,
179
147
  output: args.output,
180
148
  error: args.error,
181
149
  });
@@ -205,7 +173,6 @@ export async function runLoginCommand(args: string[], deps: LoginCommandDeps = {
205
173
  configPath,
206
174
  serverUrl,
207
175
  authToken: tokenArg,
208
- fetchImpl: deps.fetchImpl ?? fetch,
209
176
  output: outputTarget,
210
177
  error: errorTarget,
211
178
  });
@@ -220,7 +187,6 @@ export async function runLoginCommand(args: string[], deps: LoginCommandDeps = {
220
187
  configPath,
221
188
  serverUrl,
222
189
  authToken,
223
- fetchImpl: deps.fetchImpl ?? fetch,
224
190
  output: outputTarget,
225
191
  error: errorTarget,
226
192
  });
@@ -3,183 +3,42 @@ import { NOLO_CLUSTER_SERVERS } from "../database/config";
3
3
 
4
4
  export type EnvLike = Record<string, string | undefined>;
5
5
 
6
- function trimTrailingSlashes(value: string) {
7
- return value.trim().replace(/\/+$/, "");
6
+ export function resolveServerUrl(env: EnvLike) {
7
+ return (env.NOLO_SERVER || env.BASE_URL || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
8
8
  }
9
9
 
10
- function firstDefinedEnvValue(env: EnvLike, keys: string[]) {
11
- for (const key of keys) {
12
- const value = env[key];
13
- if (typeof value === "string" && value.length > 0) return value;
14
- }
15
- return "";
16
- }
17
-
18
- export function hasFlag(args: string[], flag: string) {
19
- return args.includes(flag);
20
- }
21
-
22
- export function readCliOptionValue(args: string[], flag: string): string {
23
- for (let i = 0; i < args.length; i += 1) {
24
- const arg = args[i];
25
- if (arg === flag) {
26
- const next = args[i + 1];
27
- if (typeof next === "string" && !next.startsWith("-")) return next;
28
- return "";
29
- }
30
- if (arg.startsWith(`${flag}=`)) return arg.slice(flag.length + 1);
31
- }
32
- return "";
33
- }
34
-
35
- export function hasExplicitServerOverride(args: string[]) {
36
- return Boolean(
37
- readCliOptionValue(args, "--server-url") ||
38
- readCliOptionValue(args, "--server") ||
39
- readCliOptionValue(args, "--base-url")
40
- );
41
- }
42
-
43
- export function resolveServerUrlFromEnv(env: EnvLike) {
44
- return trimTrailingSlashes(
45
- firstDefinedEnvValue(env, ["NOLO_SERVER_URL", "NOLO_SERVER", "BASE_URL"]) ||
46
- DEFAULT_NOLO_SERVER_URL,
47
- );
48
- }
49
-
50
- export function resolveServerUrlFromArgs(args: string[], env: EnvLike) {
51
- return trimTrailingSlashes(
52
- readCliOptionValue(args, "--server-url") ||
53
- readCliOptionValue(args, "--server") ||
54
- readCliOptionValue(args, "--base-url") ||
55
- firstDefinedEnvValue(env, ["NOLO_SERVER_URL", "NOLO_SERVER", "BASE_URL"]) ||
56
- DEFAULT_NOLO_SERVER_URL,
57
- );
58
- }
59
-
60
- type ServerResolverInput = string[] | EnvLike;
61
-
62
- function isCliArgs(value: ServerResolverInput): value is string[] {
63
- return Array.isArray(value);
64
- }
65
-
66
- function buildServerCandidates(values: Array<string | null | undefined>) {
67
- return [...new Set(
68
- values
69
- .filter((value): value is string => typeof value === "string" && value.trim().length > 0)
70
- .map((value) => value.replace(/\/+$/, ""))
71
- )];
72
- }
73
-
74
- export function resolveServerUrl(env: EnvLike): string;
75
- export function resolveServerUrl(args: string[], env: EnvLike): string;
76
- export function resolveServerUrl(input: ServerResolverInput, env?: EnvLike) {
77
- if (isCliArgs(input)) {
78
- return resolveServerUrlFromArgs(input, env ?? {});
79
- }
80
- return resolveServerUrlFromEnv(input);
81
- }
82
-
83
- export function resolveServerCandidates(env: EnvLike, preferred?: string | null): string[];
84
- export function resolveServerCandidates(
85
- args: string[],
86
- env: EnvLike,
87
- preferred?: string | null,
88
- ): string[];
89
- export function resolveServerCandidates(
90
- input: ServerResolverInput,
91
- envOrPreferred?: EnvLike | string | null,
92
- preferred?: string | null,
93
- ) {
94
- if (isCliArgs(input)) {
95
- const env = (envOrPreferred ?? {}) as EnvLike;
96
- const explicitServer = resolveServerUrlFromArgs(input, env);
97
- return buildServerCandidates([
98
- explicitServer,
99
- preferred?.trim(),
100
- env.NOLO_SERVER,
101
- env.BASE_URL,
102
- env.NOLO_SERVER_URL,
103
- DEFAULT_NOLO_SERVER_URL,
104
- ...NOLO_CLUSTER_SERVERS,
105
- ]);
106
- }
107
- const env = input;
108
- return buildServerCandidates([
109
- typeof envOrPreferred === "string" ? envOrPreferred.trim() : undefined,
10
+ export function resolveServerCandidates(env: EnvLike, preferred?: string | null) {
11
+ const values = [
12
+ preferred?.trim(),
110
13
  env.NOLO_SERVER,
111
14
  env.BASE_URL,
112
15
  env.NOLO_SERVER_URL,
113
16
  DEFAULT_NOLO_SERVER_URL,
114
17
  ...NOLO_CLUSTER_SERVERS,
115
- ]);
116
- }
117
-
118
- export function resolveAuthToken(env: EnvLike, extraEnvKeys?: string[]): string;
119
- export function resolveAuthToken(args: string[], env: EnvLike, extraEnvKeys?: string[]): string;
120
- export function resolveAuthToken(
121
- input: ServerResolverInput,
122
- envOrExtraEnvKeys?: EnvLike | string[],
123
- extraEnvKeys: string[] = [],
124
- ) {
125
- if (isCliArgs(input)) {
126
- return resolveAuthTokenFromArgs(input, (envOrExtraEnvKeys ?? {}) as EnvLike, extraEnvKeys);
127
- }
128
- return resolveAuthTokenFromEnv(input, (envOrExtraEnvKeys as string[] | undefined) ?? []);
129
- }
130
-
131
- export function resolveAuthTokenFromEnv(env: EnvLike, extraEnvKeys: string[] = []) {
132
- return (
133
- firstDefinedEnvValue(env, [...extraEnvKeys, "BENCHMARK_AUTH_TOKEN", "AUTH_TOKEN", "AUTH"]) ||
134
- ""
135
- );
136
- }
137
-
138
- export function resolveAuthTokenFromArgs(
139
- args: string[],
140
- env: EnvLike,
141
- extraEnvKeys: string[] = [],
142
- ) {
143
- return (
144
- readCliOptionValue(args, "--api-key") ||
145
- readCliOptionValue(args, "--token") ||
146
- firstDefinedEnvValue(env, [
147
- ...extraEnvKeys,
148
- "BENCHMARK_AUTH_TOKEN",
149
- "NOLO_TASK_RUN_TOKEN",
150
- "NOLO_MACHINE_API_KEY",
151
- "AUTH_TOKEN",
152
- "AUTH",
153
- ]) ||
154
- ""
155
- );
18
+ ];
19
+ return [...new Set(
20
+ values
21
+ .filter((value): value is string => typeof value === "string" && value.trim().length > 0)
22
+ .map((value) => value.replace(/\/+$/, ""))
23
+ )];
156
24
  }
157
25
 
158
- export function decodeJwtPayload(token: string): Record<string, unknown> | null {
159
- const trimmed = token.trim();
160
- if (!trimmed) return null;
161
- const parts = trimmed.split(".").filter(Boolean);
162
- const payloadCandidates = parts.length >= 3 ? [parts[1], parts[0]] : [parts[0]];
163
- for (const payload of payloadCandidates) {
164
- try {
165
- return JSON.parse(Buffer.from(payload, "base64").toString("utf8"));
166
- } catch {
167
- continue;
168
- }
169
- }
170
- return null;
26
+ export function resolveAuthToken(env: EnvLike) {
27
+ return env.AUTH_TOKEN || env.AUTH || "";
171
28
  }
172
29
 
173
30
  export function parseUserIdFromAuthToken(token: string) {
174
- const parsed = decodeJwtPayload(token);
175
- return typeof parsed?.userId === "string" ? parsed.userId : "";
31
+ const payload = token.trim().split(".")[0];
32
+ if (!payload) return "";
33
+ try {
34
+ const parsed = JSON.parse(Buffer.from(payload, "base64").toString("utf8"));
35
+ return typeof parsed?.userId === "string" ? parsed.userId : "";
36
+ } catch {
37
+ return "";
38
+ }
176
39
  }
177
40
 
178
41
  export function readOption(args: string[], flag: string) {
179
42
  const index = args.indexOf(flag);
180
43
  return index >= 0 ? args[index + 1] : undefined;
181
44
  }
182
-
183
- export function readOptionValue(args: string[], flag: string) {
184
- return readCliOptionValue(args, flag);
185
- }