@agentuity/coder-tui 3.0.0-alpha.2 → 3.0.0-alpha.6
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/auth.d.ts +5 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +62 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -6
- package/dist/client.js.map +1 -1
- package/dist/hub-overlay.d.ts.map +1 -1
- package/dist/hub-overlay.js +6 -9
- package/dist/hub-overlay.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -10
- package/dist/index.js.map +1 -1
- package/dist/remote-session.d.ts.map +1 -1
- package/dist/remote-session.js +5 -3
- package/dist/remote-session.js.map +1 -1
- package/package.json +1 -1
- package/src/auth.ts +75 -0
- package/src/client.ts +6 -6
- package/src/hub-overlay.ts +14 -11
- package/src/index.ts +6 -8
- package/src/remote-session.ts +5 -3
package/src/index.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { OutputViewerOverlay, type StoredResult } from './output-viewer.ts';
|
|
|
21
21
|
import { setNativeRemoteExtensionContext } from './native-remote-ui-context.ts';
|
|
22
22
|
import { handleRemoteUiRequest } from './remote-ui-handler.ts';
|
|
23
23
|
import { buildInboundRpcPromptText, getInboundRpcDeliverAs } from './inbound-rpc.ts';
|
|
24
|
+
import { applyCoderAuthHeaders, getCoderAuthCurlArgs } from './auth.ts';
|
|
24
25
|
import type {
|
|
25
26
|
HubAction,
|
|
26
27
|
HubResponse,
|
|
@@ -43,9 +44,8 @@ const HUB_URL_ENV = 'AGENTUITY_CODER_HUB_URL';
|
|
|
43
44
|
const AGENT_ENV = 'AGENTUITY_CODER_AGENT';
|
|
44
45
|
const REMOTE_SESSION_ENV = 'AGENTUITY_CODER_REMOTE_SESSION';
|
|
45
46
|
const NATIVE_REMOTE_ENV = 'AGENTUITY_CODER_NATIVE_REMOTE';
|
|
46
|
-
//
|
|
47
|
+
// Populated by `agentuity coder start` for hub bootstrap and runtime auth.
|
|
47
48
|
const API_KEY_ENV = 'AGENTUITY_CODER_API_KEY';
|
|
48
|
-
const API_KEY_HEADER = 'x-agentuity-auth-api-key';
|
|
49
49
|
const RECONNECT_WAIT_TIMEOUT_MS = 120_000;
|
|
50
50
|
|
|
51
51
|
type HubUiStatus = 'connected' | 'reconnecting' | 'offline';
|
|
@@ -117,12 +117,11 @@ function log(msg: string): void {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/** Build headers object with API key if available. Merges with any existing headers. */
|
|
120
|
-
// TODO: Remove/Change when we get Agentuity service level auth enabled, this is just temporary
|
|
121
120
|
function authHeaders(extra?: Record<string, string>): Record<string, string> {
|
|
122
121
|
const apiKey = process.env[API_KEY_ENV];
|
|
122
|
+
const orgId = process.env.AGENTUITY_ORGID;
|
|
123
123
|
const headers: Record<string, string> = { ...extra };
|
|
124
|
-
|
|
125
|
-
return headers;
|
|
124
|
+
return applyCoderAuthHeaders(headers, apiKey, orgId);
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
// ══════════════════════════════════════════════
|
|
@@ -173,9 +172,9 @@ function fetchInitMessageSync(hubUrl: string, agentRole?: string): InitMessage |
|
|
|
173
172
|
'node:child_process'
|
|
174
173
|
) as typeof import('node:child_process');
|
|
175
174
|
const apiKey = process.env[API_KEY_ENV];
|
|
175
|
+
const orgId = process.env.AGENTUITY_ORGID;
|
|
176
176
|
const curlArgs = ['-s', '--connect-timeout', '3', '--max-time', '5'];
|
|
177
|
-
|
|
178
|
-
if (apiKey) curlArgs.push('-H', `${API_KEY_HEADER}: ${apiKey}`);
|
|
177
|
+
curlArgs.push(...getCoderAuthCurlArgs(apiKey, orgId));
|
|
179
178
|
curlArgs.push(httpUrl);
|
|
180
179
|
const result = execFileSync('curl', curlArgs, { encoding: 'utf-8' });
|
|
181
180
|
|
|
@@ -417,7 +416,6 @@ export function agentuityCoderHub(pi: ExtensionAPI) {
|
|
|
417
416
|
// ══════════════════════════════════════════════
|
|
418
417
|
|
|
419
418
|
const client = new HubClient();
|
|
420
|
-
// TODO: Remove/Change when we get Agentuity service level auth enabled, this is just temporary
|
|
421
419
|
client.apiKey = process.env[API_KEY_ENV] || null;
|
|
422
420
|
let cachedInitMessage: InitMessage | null = initMsg;
|
|
423
421
|
let currentSessionId: string | null = initMsg.sessionId ?? null;
|
package/src/remote-session.ts
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
syncRemoteLifecycleWorkingMessage,
|
|
23
23
|
type RemoteLifecycleState,
|
|
24
24
|
} from './remote-lifecycle.ts';
|
|
25
|
+
import { resolveCoderOrgId } from './auth.ts';
|
|
25
26
|
|
|
26
27
|
const DEBUG = !!process.env['AGENTUITY_DEBUG'];
|
|
27
28
|
|
|
@@ -267,9 +268,10 @@ export class RemoteSession {
|
|
|
267
268
|
wsHeaders['Authorization'] = `Bearer ${this.apiKey}`;
|
|
268
269
|
}
|
|
269
270
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
const orgId = resolveCoderOrgId(this.orgId);
|
|
272
|
+
if (orgId) {
|
|
273
|
+
url.searchParams.set('orgId', orgId);
|
|
274
|
+
wsHeaders['x-agentuity-orgid'] = orgId;
|
|
273
275
|
}
|
|
274
276
|
|
|
275
277
|
log(`${isReconnect ? 'Reconnecting' : 'Connecting'} to ${url.toString()}`);
|