eas-cli 23.1.0 → 24.0.0

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 (126) hide show
  1. package/README.md +424 -226
  2. package/build/api.d.ts +1 -0
  3. package/build/api.js +12 -0
  4. package/build/build/utils/url.d.ts +1 -0
  5. package/build/build/utils/url.js +4 -0
  6. package/build/channel/protection.d.ts +4 -0
  7. package/build/channel/protection.js +49 -0
  8. package/build/channel/queries.d.ts +6 -0
  9. package/build/channel/queries.js +5 -1
  10. package/build/commandUtils/workflow/logs/fetchLogs.d.ts +5 -0
  11. package/build/commandUtils/workflow/logs/fetchLogs.js +24 -0
  12. package/build/commandUtils/workflow/logs/parseLogs.d.ts +14 -0
  13. package/build/commandUtils/workflow/logs/parseLogs.js +69 -0
  14. package/build/commandUtils/workflow/logs/watcher.d.ts +32 -0
  15. package/build/commandUtils/workflow/logs/watcher.js +162 -0
  16. package/build/commandUtils/workflow/stateMachine.js +2 -1
  17. package/build/commandUtils/workflow/types.d.ts +12 -5
  18. package/build/commandUtils/workflow/utils.d.ts +9 -5
  19. package/build/commandUtils/workflow/utils.js +144 -146
  20. package/build/commands/channel/protect.d.ts +16 -0
  21. package/build/commands/channel/protect.js +68 -0
  22. package/build/commands/channel/unprotect.d.ts +16 -0
  23. package/build/commands/channel/unprotect.js +78 -0
  24. package/build/commands/observe/errors.d.ts +27 -0
  25. package/build/commands/observe/errors.js +122 -0
  26. package/build/commands/observe/event.d.ts +18 -0
  27. package/build/commands/observe/event.js +149 -0
  28. package/build/commands/observe/events.d.ts +2 -0
  29. package/build/commands/observe/events.js +10 -4
  30. package/build/commands/observe/metrics-summary.d.ts +1 -0
  31. package/build/commands/observe/metrics-summary.js +3 -2
  32. package/build/commands/observe/metrics.d.ts +2 -0
  33. package/build/commands/observe/metrics.js +8 -4
  34. package/build/commands/observe/routes.d.ts +2 -1
  35. package/build/commands/observe/routes.js +5 -5
  36. package/build/commands/observe/session.d.ts +1 -0
  37. package/build/commands/observe/session.js +14 -8
  38. package/build/commands/observe/versions.d.ts +1 -0
  39. package/build/commands/observe/versions.js +3 -2
  40. package/build/commands/project/status.d.ts +16 -0
  41. package/build/commands/project/status.js +47 -0
  42. package/build/commands/simulator/get.js +5 -1
  43. package/build/commands/simulator/index.d.ts +1 -0
  44. package/build/commands/simulator/index.js +16 -2
  45. package/build/commands/simulator/list.d.ts +1 -0
  46. package/build/commands/simulator/list.js +9 -0
  47. package/build/commands/workflow/run.d.ts +8 -0
  48. package/build/commands/workflow/run.js +27 -0
  49. package/build/commands/workflow/ssh.d.ts +31 -0
  50. package/build/commands/workflow/ssh.js +190 -0
  51. package/build/credentials/ios/credentials.d.ts +5 -3
  52. package/build/credentials/ios/utils/printCredentials.js +6 -1
  53. package/build/graphql/generated.d.ts +2474 -1079
  54. package/build/graphql/generated.js +71 -16
  55. package/build/graphql/mutations/RealtimeLogsMutation.d.ts +6 -0
  56. package/build/graphql/mutations/RealtimeLogsMutation.js +40 -0
  57. package/build/graphql/mutations/WorkflowRunMutation.d.ts +3 -2
  58. package/build/graphql/mutations/WorkflowRunMutation.js +4 -1
  59. package/build/graphql/queries/AppStoreConnectApiKeyQuery.d.ts +1 -1
  60. package/build/graphql/queries/AppStoreConnectApiKeyQuery.js +1 -1
  61. package/build/graphql/queries/ChannelQuery.js +2 -0
  62. package/build/graphql/queries/DeviceRunSessionQuery.js +10 -0
  63. package/build/graphql/queries/ObserveQuery.d.ts +62 -30
  64. package/build/graphql/queries/ObserveQuery.js +276 -121
  65. package/build/graphql/queries/SubmissionQuery.d.ts +6 -1
  66. package/build/graphql/queries/SubmissionQuery.js +41 -0
  67. package/build/graphql/queries/WorkflowJobSshQuery.d.ts +20 -0
  68. package/build/graphql/queries/WorkflowJobSshQuery.js +133 -0
  69. package/build/graphql/types/Observe.d.ts +5 -3
  70. package/build/graphql/types/Observe.js +80 -21
  71. package/build/graphql/types/UpdateChannelBasicInfo.js +1 -0
  72. package/build/observe/fetchCustomEvents.d.ts +6 -4
  73. package/build/observe/fetchCustomEvents.js +4 -2
  74. package/build/observe/fetchErrors.d.ts +32 -0
  75. package/build/observe/fetchErrors.js +42 -0
  76. package/build/observe/fetchEvents.d.ts +9 -6
  77. package/build/observe/fetchEvents.js +16 -17
  78. package/build/observe/fetchMetrics.d.ts +2 -2
  79. package/build/observe/fetchMetrics.js +9 -9
  80. package/build/observe/fetchNavigationRoutes.d.ts +7 -5
  81. package/build/observe/fetchNavigationRoutes.js +8 -8
  82. package/build/observe/fetchSessions.d.ts +13 -11
  83. package/build/observe/fetchSessions.js +59 -30
  84. package/build/observe/fetchVersions.d.ts +4 -3
  85. package/build/observe/fetchVersions.js +7 -11
  86. package/build/observe/flags.d.ts +6 -0
  87. package/build/observe/flags.js +12 -2
  88. package/build/observe/formatCustomEvents.d.ts +16 -10
  89. package/build/observe/formatCustomEvents.js +61 -28
  90. package/build/observe/formatErrors.d.ts +97 -0
  91. package/build/observe/formatErrors.js +203 -0
  92. package/build/observe/formatEvents.d.ts +11 -5
  93. package/build/observe/formatEvents.js +46 -18
  94. package/build/observe/formatMetrics.d.ts +4 -4
  95. package/build/observe/formatMetrics.js +2 -2
  96. package/build/observe/formatNavigationRoutes.d.ts +4 -4
  97. package/build/observe/formatNavigationRoutes.js +3 -3
  98. package/build/observe/formatSessions.d.ts +3 -3
  99. package/build/observe/formatSessions.js +8 -8
  100. package/build/observe/formatVersions.js +2 -2
  101. package/build/observe/platforms.d.ts +10 -19
  102. package/build/observe/platforms.js +42 -40
  103. package/build/ora.d.ts +7 -0
  104. package/build/ora.js +12 -0
  105. package/build/project/projectStatus.d.ts +96 -0
  106. package/build/project/projectStatus.js +314 -0
  107. package/build/simulator/utils.d.ts +11 -0
  108. package/build/simulator/utils.js +51 -4
  109. package/build/submit/utils/urls.js +2 -3
  110. package/build/utils/centrifuge.d.ts +10 -0
  111. package/build/utils/centrifuge.js +89 -0
  112. package/build/utils/expodash/uniqBy.js +3 -2
  113. package/oclif.manifest.json +2947 -2328
  114. package/package.json +10 -7
  115. package/build/chat/chatClient.d.ts +0 -37
  116. package/build/chat/chatClient.js +0 -359
  117. package/build/chat/detectProject.d.ts +0 -5
  118. package/build/chat/detectProject.js +0 -41
  119. package/build/chat/renderMarkdown.d.ts +0 -7
  120. package/build/chat/renderMarkdown.js +0 -47
  121. package/build/chat/replInput.d.ts +0 -10
  122. package/build/chat/replInput.js +0 -52
  123. package/build/commandUtils/workflow/fetchLogs.d.ts +0 -6
  124. package/build/commandUtils/workflow/fetchLogs.js +0 -44
  125. package/build/commands/chat.d.ts +0 -18
  126. package/build/commands/chat.js +0 -221
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eas-cli",
3
- "version": "23.1.0",
3
+ "version": "24.0.0",
4
4
  "description": "EAS command line tool",
5
5
  "keywords": [
6
6
  "cli",
@@ -44,15 +44,15 @@
44
44
  "copy-new-templates": "rimraf build/commandUtils/new/templates && mkdir -p build/commandUtils/new && cp -r src/commandUtils/new/templates build/commandUtils/new"
45
45
  },
46
46
  "dependencies": {
47
- "@expo/apple-utils": "2.1.22",
47
+ "@expo/apple-utils": "2.2.0",
48
48
  "@expo/code-signing-certificates": "0.0.5",
49
49
  "@expo/config": "55.0.10",
50
50
  "@expo/config-plugins": "55.0.7",
51
- "@expo/eas-build-job": "23.1.0",
52
- "@expo/eas-json": "23.1.0",
51
+ "@expo/eas-build-job": "24.0.0",
52
+ "@expo/eas-json": "24.0.0",
53
53
  "@expo/env": "^1.0.0",
54
54
  "@expo/json-file": "8.3.3",
55
- "@expo/logger": "23.1.0",
55
+ "@expo/logger": "24.0.0",
56
56
  "@expo/multipart-body-parser": "2.0.0",
57
57
  "@expo/osascript": "2.1.4",
58
58
  "@expo/package-manager": "1.9.10",
@@ -64,7 +64,7 @@
64
64
  "@expo/results": "1.0.0",
65
65
  "@expo/rudder-sdk-node": "1.1.1",
66
66
  "@expo/spawn-async": "1.7.2",
67
- "@expo/steps": "23.1.0",
67
+ "@expo/steps": "24.0.0",
68
68
  "@expo/timeago.js": "1.0.0",
69
69
  "@oclif/core": "^4.8.3",
70
70
  "@oclif/plugin-autocomplete": "^3.2.40",
@@ -77,6 +77,7 @@
77
77
  "ajv-formats": "2.1.1",
78
78
  "better-opn": "3.0.2",
79
79
  "bplist-parser": "^0.3.0",
80
+ "centrifuge": "5.7.1",
80
81
  "chalk": "4.1.2",
81
82
  "cli-progress": "3.12.0",
82
83
  "dateformat": "4.6.3",
@@ -132,6 +133,7 @@
132
133
  "untildify": "4.0.0",
133
134
  "uuid": "11.1.1",
134
135
  "wrap-ansi": "7.0.0",
136
+ "ws": "8.21.1",
135
137
  "yaml": "2.6.0",
136
138
  "zod": "^4.1.3"
137
139
  },
@@ -160,6 +162,7 @@
160
162
  "@types/tar-stream": "3.1.3",
161
163
  "@types/tough-cookie": "4.0.2",
162
164
  "@types/wrap-ansi": "3.0.0",
165
+ "@types/ws": "8.5.10",
163
166
  "axios": "1.18.1",
164
167
  "eslint-plugin-graphql": "4.0.0",
165
168
  "jest": "29.7.0",
@@ -265,5 +268,5 @@
265
268
  "engines": {
266
269
  "node": ">=20.0.0"
267
270
  },
268
- "gitHead": "0658d58efdbf614f6920e3b4142223ac198bc003"
271
+ "gitHead": "5409c03d58c50b80e4ec9d5ca40f2fbdfaba9aa0"
269
272
  }
@@ -1,37 +0,0 @@
1
- type ChatMessagePart = {
2
- type: 'text';
3
- text: string;
4
- } | {
5
- type: 'step-start';
6
- } | {
7
- type: `tool-${string}`;
8
- toolCallId: string;
9
- state: 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
10
- input: unknown;
11
- output?: unknown;
12
- errorText?: string;
13
- };
14
- export type ChatMessage = {
15
- id: string;
16
- role: 'system' | 'user' | 'assistant';
17
- parts: ChatMessagePart[];
18
- };
19
- export declare function makeUserMessage(text: string): ChatMessage;
20
- export type ChatToolCall = {
21
- toolName: string;
22
- input?: unknown;
23
- output?: unknown;
24
- errorText?: string;
25
- };
26
- export type ChatResult = {
27
- text: string;
28
- toolCalls: ChatToolCall[];
29
- assistantMessage: ChatMessage;
30
- };
31
- export declare function streamChatResponseAsync({ messages, accountName, sessionSecret, stream, }: {
32
- messages: ChatMessage[];
33
- accountName: string | undefined;
34
- sessionSecret: string;
35
- stream: boolean;
36
- }): Promise<ChatResult>;
37
- export {};
@@ -1,359 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeUserMessage = makeUserMessage;
4
- exports.streamChatResponseAsync = streamChatResponseAsync;
5
- const tslib_1 = require("tslib");
6
- const node_string_decoder_1 = require("node:string_decoder");
7
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
8
- const uuid_1 = require("uuid");
9
- const api_1 = require("../api");
10
- const fetch_1 = tslib_1.__importStar(require("../fetch"));
11
- const log_1 = tslib_1.__importDefault(require("../log"));
12
- const ora_1 = require("../ora");
13
- const renderMarkdown_1 = require("./renderMarkdown");
14
- const CHAT_SYSTEM_GUIDANCE = [
15
- 'You are being used through the EAS CLI in a terminal, not the web dashboard.',
16
- 'The user cannot see the interactive tables the dashboard renders from tool results, so include the important details directly in your text answer instead of assuming a table is shown.',
17
- 'Whenever you reference a specific artifact (a build, update, submission, deployment, workflow run, channel, or branch), include its direct https://expo.dev link so the user can open it.',
18
- 'Use only simple markdown: bold, inline code, and bullet or numbered lists.',
19
- ].join(' ');
20
- function getWebsiteAuthCookieName() {
21
- if (process.env.EXPO_STAGING) {
22
- return 'staging.expo.auth.sessionSecret';
23
- }
24
- else if (process.env.EXPO_LOCAL) {
25
- return 'local.expo.auth.sessionSecret';
26
- }
27
- else {
28
- return 'io.expo.auth.sessionSecret';
29
- }
30
- }
31
- const TOOL_LABELS = {
32
- get_projects: 'Looking up your projects',
33
- get_latest_builds: 'Looking up builds',
34
- get_build: 'Looking up a build',
35
- get_build_logs: 'Reading build logs',
36
- get_activity: 'Looking up recent activity',
37
- get_updates: 'Looking up updates',
38
- get_workflow_runs: 'Looking up workflow runs',
39
- get_workflow_run: 'Looking up a workflow run',
40
- get_workflow_run_logs: 'Reading workflow logs',
41
- get_submissions: 'Looking up submissions',
42
- get_channels: 'Looking up channels',
43
- get_branches: 'Looking up branches',
44
- get_worker_deployments: 'Looking up deployments',
45
- get_environment_variables: 'Looking up environment variables',
46
- get_account_members: 'Looking up account members',
47
- get_usage: 'Looking up usage',
48
- get_usage_history: 'Looking up usage history',
49
- get_invoices: 'Looking up invoices',
50
- search_expo_docs: 'Searching Expo docs',
51
- navigate: 'Finding the right page',
52
- };
53
- function describeTool(toolName) {
54
- return TOOL_LABELS[toolName] ?? `Using ${toolName.replace(/_/g, ' ')}`;
55
- }
56
- const ASSISTANT_LABEL_TEXT = 'Expo';
57
- const ASSISTANT_LABEL = `${chalk_1.default.bold.magenta(ASSISTANT_LABEL_TEXT)}${chalk_1.default.dim(' > ')}`;
58
- const ASSISTANT_INDENT = ' '.repeat(`${ASSISTANT_LABEL_TEXT} > `.length);
59
- const ASSISTANT_SPINNER_PREFIX = `${chalk_1.default.bold.magenta(ASSISTANT_LABEL_TEXT)}${chalk_1.default.dim(' >')}`;
60
- function makeSystemMessage(text) {
61
- return { id: (0, uuid_1.v4)(), role: 'system', parts: [{ type: 'text', text }] };
62
- }
63
- function makeUserMessage(text) {
64
- return { id: (0, uuid_1.v4)(), role: 'user', parts: [{ type: 'text', text }] };
65
- }
66
- function makeAssistantMessage(parts) {
67
- return { id: (0, uuid_1.v4)(), role: 'assistant', parts };
68
- }
69
- async function streamChatResponseAsync({ messages, accountName, sessionSecret, stream, }) {
70
- let response;
71
- try {
72
- response = await (0, fetch_1.default)(`${(0, api_1.getExpoWebsiteBaseUrl)()}/api/chat`, {
73
- method: 'POST',
74
- headers: {
75
- 'content-type': 'application/json',
76
- accept: 'text/event-stream',
77
- cookie: `${getWebsiteAuthCookieName()}=${encodeURIComponent(sessionSecret)}`,
78
- ...(accountName ? { 'x-account-name': accountName } : {}),
79
- },
80
- body: JSON.stringify({ messages: [makeSystemMessage(CHAT_SYSTEM_GUIDANCE), ...messages] }),
81
- });
82
- }
83
- catch (error) {
84
- throw toFriendlyChatError(error);
85
- }
86
- if (!response.body) {
87
- throw new Error('The chat service returned an empty response.');
88
- }
89
- const spinner = stream
90
- ? (0, ora_1.ora)({ text: 'Thinking…', discardStdin: false, prefixText: ASSISTANT_SPINNER_PREFIX }).start()
91
- : undefined;
92
- let spinnerStopped = false;
93
- const stopSpinner = () => {
94
- if (!spinner || spinnerStopped) {
95
- return;
96
- }
97
- spinnerStopped = true;
98
- spinner.stop();
99
- if (process.stdout.isTTY) {
100
- process.stdout.write('\r');
101
- }
102
- };
103
- const toolMessagePartsById = new Map();
104
- const textMessagePartsById = new Map();
105
- const assistantMessageParts = [];
106
- const announcedTools = new Set();
107
- const markdownState = (0, renderMarkdown_1.createMarkdownRenderState)();
108
- let fullText = '';
109
- let streamingText = false;
110
- let errorText;
111
- let buffer = '';
112
- let displayBuffer = '';
113
- let wroteAssistantLine = false;
114
- let currentTextMessagePart;
115
- const getOrCreateToolMessagePart = (toolCallId, toolName) => {
116
- const existing = toolMessagePartsById.get(toolCallId);
117
- if (existing) {
118
- return existing;
119
- }
120
- const part = {
121
- type: `tool-${toolName}`,
122
- toolCallId,
123
- state: 'input-streaming',
124
- input: undefined,
125
- };
126
- toolMessagePartsById.set(toolCallId, part);
127
- assistantMessageParts.push(part);
128
- return part;
129
- };
130
- const getOrCreateTextMessagePart = (id) => {
131
- const existing = id ? textMessagePartsById.get(id) : currentTextMessagePart;
132
- if (existing) {
133
- return existing;
134
- }
135
- const part = { type: 'text', text: '' };
136
- if (id) {
137
- textMessagePartsById.set(id, part);
138
- }
139
- currentTextMessagePart = part;
140
- assistantMessageParts.push(part);
141
- return part;
142
- };
143
- const writeAssistantLine = (rendered, withNewline) => {
144
- if (!streamingText) {
145
- stopSpinner();
146
- streamingText = true;
147
- }
148
- const columns = process.stdout.columns ?? 0;
149
- const width = columns > 0 ? columns - ASSISTANT_INDENT.length : 0;
150
- const segments = (0, renderMarkdown_1.wrapToWidth)(rendered, width);
151
- segments.forEach((segment, index) => {
152
- const prefix = wroteAssistantLine ? ASSISTANT_INDENT : ASSISTANT_LABEL;
153
- wroteAssistantLine = true;
154
- const isLastSegment = index === segments.length - 1;
155
- const needsNewline = !isLastSegment || withNewline;
156
- process.stdout.write(`${prefix}${segment}${needsNewline ? '\n' : ''}`);
157
- });
158
- };
159
- const flushDisplayLines = (flushRemainder) => {
160
- let newlineIndex;
161
- while ((newlineIndex = displayBuffer.indexOf('\n')) !== -1) {
162
- const rawLine = displayBuffer.slice(0, newlineIndex);
163
- displayBuffer = displayBuffer.slice(newlineIndex + 1);
164
- const rendered = (0, renderMarkdown_1.renderMarkdownLine)(rawLine, markdownState);
165
- if (rendered !== null) {
166
- writeAssistantLine(rendered, true);
167
- }
168
- }
169
- if (flushRemainder && displayBuffer.length > 0) {
170
- const rendered = (0, renderMarkdown_1.renderMarkdownLine)(displayBuffer, markdownState);
171
- displayBuffer = '';
172
- if (rendered !== null) {
173
- writeAssistantLine(rendered, false);
174
- }
175
- }
176
- };
177
- const announceTool = (toolName) => {
178
- if (!stream || announcedTools.has(toolName)) {
179
- return;
180
- }
181
- announcedTools.add(toolName);
182
- const label = describeTool(toolName);
183
- if (streamingText) {
184
- flushDisplayLines(true);
185
- process.stdout.write(chalk_1.default.dim(`\n${ASSISTANT_INDENT}(${label})\n`));
186
- }
187
- else if (spinner) {
188
- spinner.text = `${label}…`;
189
- }
190
- };
191
- const handleFrame = (frame) => {
192
- switch (frame.type) {
193
- case 'start-step': {
194
- assistantMessageParts.push({ type: 'step-start' });
195
- currentTextMessagePart = undefined;
196
- break;
197
- }
198
- case 'text-start': {
199
- currentTextMessagePart = getOrCreateTextMessagePart(frame.id);
200
- break;
201
- }
202
- case 'text-delta': {
203
- const delta = typeof frame.delta === 'string' ? frame.delta : '';
204
- if (!delta) {
205
- return;
206
- }
207
- fullText += delta;
208
- getOrCreateTextMessagePart(frame.id).text += delta;
209
- if (stream) {
210
- displayBuffer += delta;
211
- flushDisplayLines(false);
212
- }
213
- break;
214
- }
215
- case 'text-end': {
216
- currentTextMessagePart = undefined;
217
- break;
218
- }
219
- case 'tool-input-start':
220
- case 'tool-input-available': {
221
- const { toolCallId, toolName } = frame;
222
- if (!toolCallId || !toolName) {
223
- return;
224
- }
225
- const toolPart = getOrCreateToolMessagePart(toolCallId, toolName);
226
- if (frame.type === 'tool-input-available') {
227
- toolPart.state = 'input-available';
228
- toolPart.input = frame.input;
229
- delete toolPart.output;
230
- delete toolPart.errorText;
231
- }
232
- else if (frame.input !== undefined) {
233
- toolPart.input = frame.input;
234
- }
235
- announceTool(toolName);
236
- break;
237
- }
238
- case 'tool-input-error': {
239
- const { toolCallId, toolName } = frame;
240
- if (!toolCallId || !toolName || typeof frame.errorText !== 'string') {
241
- return;
242
- }
243
- const toolPart = getOrCreateToolMessagePart(toolCallId, toolName);
244
- toolPart.state = 'output-error';
245
- toolPart.input = frame.input;
246
- delete toolPart.output;
247
- toolPart.errorText = frame.errorText;
248
- announceTool(toolName);
249
- break;
250
- }
251
- case 'tool-output-available': {
252
- const { toolCallId } = frame;
253
- if (!toolCallId) {
254
- return;
255
- }
256
- const toolPart = toolMessagePartsById.get(toolCallId);
257
- if (toolPart) {
258
- toolPart.state = 'output-available';
259
- toolPart.output = frame.output;
260
- delete toolPart.errorText;
261
- }
262
- break;
263
- }
264
- case 'tool-output-error': {
265
- const { toolCallId } = frame;
266
- if (!toolCallId || typeof frame.errorText !== 'string') {
267
- return;
268
- }
269
- const toolPart = toolMessagePartsById.get(toolCallId);
270
- if (toolPart) {
271
- toolPart.state = 'output-error';
272
- delete toolPart.output;
273
- toolPart.errorText = frame.errorText;
274
- }
275
- break;
276
- }
277
- case 'error': {
278
- if (typeof frame.errorText === 'string') {
279
- errorText = frame.errorText;
280
- }
281
- break;
282
- }
283
- }
284
- };
285
- const decoder = new node_string_decoder_1.StringDecoder('utf8');
286
- try {
287
- for await (const chunk of response.body) {
288
- buffer += decoder.write(chunk);
289
- let newlineIndex;
290
- while ((newlineIndex = buffer.indexOf('\n')) !== -1) {
291
- const line = buffer.slice(0, newlineIndex).trim();
292
- buffer = buffer.slice(newlineIndex + 1);
293
- if (!line.startsWith('data:')) {
294
- continue;
295
- }
296
- const data = line.slice('data:'.length).trim();
297
- if (!data || data === '[DONE]') {
298
- continue;
299
- }
300
- let frame;
301
- try {
302
- frame = JSON.parse(data);
303
- }
304
- catch {
305
- continue;
306
- }
307
- handleFrame(frame);
308
- }
309
- }
310
- }
311
- finally {
312
- if (stream) {
313
- flushDisplayLines(true);
314
- }
315
- stopSpinner();
316
- }
317
- if (errorText) {
318
- throw new Error(errorText);
319
- }
320
- const toolCalls = assistantMessageParts
321
- .filter((part) => part.type.startsWith('tool-'))
322
- .map(part => ({
323
- toolName: part.type.slice('tool-'.length),
324
- input: part.input,
325
- output: part.output,
326
- errorText: part.errorText,
327
- }));
328
- const assistantMessage = makeAssistantMessage(assistantMessageParts.filter(part => part.type === 'text' ||
329
- part.type === 'step-start' ||
330
- part.state === 'output-available' ||
331
- part.state === 'output-error'));
332
- if (stream) {
333
- if (fullText.length > 0) {
334
- log_1.default.newLine();
335
- }
336
- else {
337
- log_1.default.log(chalk_1.default.dim(toolCalls.length > 0
338
- ? 'The assistant looked up your data but did not return a text response. Try asking a more specific question.'
339
- : 'The assistant did not return a response.'));
340
- }
341
- }
342
- return { text: fullText, toolCalls, assistantMessage };
343
- }
344
- function toFriendlyChatError(error) {
345
- if (error instanceof fetch_1.RequestError) {
346
- const status = error.response.status;
347
- if (status === 401) {
348
- return new Error('Your Expo session is not valid for chat. Run `eas login` and try again.');
349
- }
350
- if (status === 403) {
351
- return new Error('Chat is not enabled for this account yet. It is still rolling out. If you think you should have access, reach out to Expo.');
352
- }
353
- if (status === 429) {
354
- return new Error('You have reached your chat usage limit. Try again later or upgrade your plan for a larger allowance.');
355
- }
356
- return new Error(`The chat request failed (HTTP ${status}).`);
357
- }
358
- return error instanceof Error ? error : new Error(String(error));
359
- }
@@ -1,5 +0,0 @@
1
- import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
2
- export declare function detectCurrentProjectAsync(graphqlClient: ExpoGraphqlClient): Promise<{
3
- accountName: string;
4
- label: string;
5
- } | null>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.detectCurrentProjectAsync = detectCurrentProjectAsync;
4
- const config_1 = require("@expo/config");
5
- const findProjectDirAndVerifyProjectSetupAsync_1 = require("../commandUtils/context/contextUtils/findProjectDirAndVerifyProjectSetupAsync");
6
- const AppQuery_1 = require("../graphql/queries/AppQuery");
7
- const expoConfig_1 = require("../project/expoConfig");
8
- async function detectCurrentProjectAsync(graphqlClient) {
9
- let projectDir;
10
- try {
11
- projectDir = await (0, findProjectDirAndVerifyProjectSetupAsync_1.findProjectDirAndVerifyProjectSetupAsync)();
12
- }
13
- catch {
14
- return null;
15
- }
16
- if (!projectDir) {
17
- return null;
18
- }
19
- const configPaths = (0, config_1.getConfigFilePaths)(projectDir);
20
- if (!configPaths.staticConfigPath && !configPaths.dynamicConfigPath) {
21
- return null;
22
- }
23
- let projectId;
24
- try {
25
- const expoConfig = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
26
- projectId = expoConfig.extra?.eas?.projectId;
27
- }
28
- catch {
29
- return null;
30
- }
31
- if (typeof projectId !== 'string' || !projectId) {
32
- return null;
33
- }
34
- try {
35
- const app = await AppQuery_1.AppQuery.byIdAsync(graphqlClient, projectId);
36
- return { accountName: app.ownerAccount.name, label: app.fullName };
37
- }
38
- catch {
39
- return null;
40
- }
41
- }
@@ -1,7 +0,0 @@
1
- export declare function wrapToWidth(text: string, width: number): string[];
2
- export type MarkdownRenderState = {
3
- inCodeBlock: boolean;
4
- };
5
- export declare function createMarkdownRenderState(): MarkdownRenderState;
6
- export declare function renderMarkdownLine(line: string, state: MarkdownRenderState): string | null;
7
- export declare function renderInlineMarkdown(text: string): string;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapToWidth = wrapToWidth;
4
- exports.createMarkdownRenderState = createMarkdownRenderState;
5
- exports.renderMarkdownLine = renderMarkdownLine;
6
- exports.renderInlineMarkdown = renderInlineMarkdown;
7
- const tslib_1 = require("tslib");
8
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
9
- const wrap_ansi_1 = tslib_1.__importDefault(require("wrap-ansi"));
10
- function wrapToWidth(text, width) {
11
- if (width < 10) {
12
- return [text];
13
- }
14
- return (0, wrap_ansi_1.default)(text, width, { hard: true, trim: false }).split('\n');
15
- }
16
- function createMarkdownRenderState() {
17
- return { inCodeBlock: false };
18
- }
19
- const FENCE_REGEX = /^\s*```/;
20
- const BULLET_REGEX = /^(\s*)[-*+]\s+(.*)$/;
21
- const ORDERED_REGEX = /^(\s*)(\d+)\.\s+(.*)$/;
22
- const TERMINAL_CONTROL_CHARACTERS_REGEX = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]/g;
23
- function renderMarkdownLine(line, state) {
24
- const sanitizedLine = line.replace(TERMINAL_CONTROL_CHARACTERS_REGEX, '');
25
- if (FENCE_REGEX.test(sanitizedLine)) {
26
- state.inCodeBlock = !state.inCodeBlock;
27
- return null;
28
- }
29
- if (state.inCodeBlock) {
30
- return chalk_1.default.gray(sanitizedLine);
31
- }
32
- const bullet = sanitizedLine.match(BULLET_REGEX);
33
- if (bullet) {
34
- return `${bullet[1]}${chalk_1.default.dim('•')} ${renderInlineMarkdown(bullet[2])}`;
35
- }
36
- const ordered = sanitizedLine.match(ORDERED_REGEX);
37
- if (ordered) {
38
- return `${ordered[1]}${chalk_1.default.dim(`${ordered[2]}.`)} ${renderInlineMarkdown(ordered[3])}`;
39
- }
40
- return renderInlineMarkdown(sanitizedLine);
41
- }
42
- function renderInlineMarkdown(text) {
43
- return text
44
- .replace(/`([^`]+)`/g, (_match, code) => chalk_1.default.cyan(code))
45
- .replace(/\[([^\]]+)\]\(([^)]+)\)/g, (_match, label, url) => `${chalk_1.default.underline(label)} ${chalk_1.default.dim(`(${url})`)}`)
46
- .replace(/(\*\*|__)(.+?)\1/g, (_match, _marker, content) => chalk_1.default.bold(content));
47
- }
@@ -1,10 +0,0 @@
1
- export type ChatReplInput = {
2
- askAsync(prompt: string): Promise<string | null>;
3
- close(): void;
4
- };
5
- export declare function createChatReplInput(options?: {
6
- input?: NodeJS.ReadableStream;
7
- output?: NodeJS.WritableStream;
8
- terminal?: boolean;
9
- history?: string[];
10
- }): ChatReplInput;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createChatReplInput = createChatReplInput;
4
- const tslib_1 = require("tslib");
5
- const node_readline_1 = tslib_1.__importDefault(require("node:readline"));
6
- function createChatReplInput(options) {
7
- const inputStream = options?.input ?? process.stdin;
8
- const readlineInterface = node_readline_1.default.createInterface({
9
- input: inputStream,
10
- output: options?.output ?? process.stdout,
11
- terminal: options?.terminal ?? true,
12
- historySize: 100,
13
- history: options?.history,
14
- });
15
- let closed = false;
16
- readlineInterface.on('close', () => {
17
- closed = true;
18
- });
19
- readlineInterface.on('SIGINT', () => {
20
- readlineInterface.close();
21
- });
22
- return {
23
- async askAsync(prompt) {
24
- if (closed) {
25
- return null;
26
- }
27
- inputStream.resume();
28
- return await new Promise(resolve => {
29
- let settled = false;
30
- const onClose = () => {
31
- if (!settled) {
32
- settled = true;
33
- resolve(null);
34
- }
35
- };
36
- readlineInterface.once('close', onClose);
37
- readlineInterface.question(prompt, answer => {
38
- if (!settled) {
39
- settled = true;
40
- readlineInterface.removeListener('close', onClose);
41
- resolve(answer);
42
- }
43
- });
44
- });
45
- },
46
- close() {
47
- if (!closed) {
48
- readlineInterface.close();
49
- }
50
- },
51
- };
52
- }
@@ -1,6 +0,0 @@
1
- import { WorkflowJobResult } from './types';
2
- import { ExpoGraphqlClient } from '../context/contextUtils/createGraphqlClient';
3
- export declare function fetchRawLogsForCustomJobAsync(job: WorkflowJobResult): Promise<string | null>;
4
- export declare function fetchRawLogsForBuildJobAsync(state: {
5
- graphqlClient: ExpoGraphqlClient;
6
- }, job: WorkflowJobResult): Promise<string | null>;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchRawLogsForCustomJobAsync = fetchRawLogsForCustomJobAsync;
4
- exports.fetchRawLogsForBuildJobAsync = fetchRawLogsForBuildJobAsync;
5
- const BuildQuery_1 = require("../../graphql/queries/BuildQuery");
6
- // This function is in a separate module for testing purposes
7
- async function fetchRawLogsForCustomJobAsync(job) {
8
- const firstLogFileUrl = job.turtleJobRun?.logFileUrls?.[0];
9
- if (!firstLogFileUrl) {
10
- return null;
11
- }
12
- const response = await fetch(firstLogFileUrl, {
13
- method: 'GET',
14
- });
15
- const rawLogs = await response.text();
16
- return rawLogs;
17
- }
18
- async function fetchRawLogsForBuildJobAsync(state, job) {
19
- // Prefer turtleJobRun logs, which contain JSONL-formatted step logs
20
- // for both built-in and custom build steps
21
- const turtleLogFileUrl = job.turtleJobRun?.logFileUrls?.[0];
22
- if (turtleLogFileUrl) {
23
- const response = await fetch(turtleLogFileUrl, {
24
- method: 'GET',
25
- });
26
- return await response.text();
27
- }
28
- // Fall back to build logFiles
29
- const buildId = job.outputs?.build_id;
30
- if (!buildId) {
31
- return null;
32
- }
33
- const buildFragment = await BuildQuery_1.BuildQuery.byIdAsync(state.graphqlClient, buildId, {
34
- useCache: false,
35
- });
36
- const firstLogFileUrl = buildFragment.logFiles?.[0];
37
- if (!firstLogFileUrl) {
38
- return null;
39
- }
40
- const response = await fetch(firstLogFileUrl, {
41
- method: 'GET',
42
- });
43
- return await response.text();
44
- }