@ai-development-environment/control-agent 0.0.81 → 0.0.82

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.
@@ -5031,6 +5031,26 @@ var AgentGraphQLClient = class {
5031
5031
  })
5032
5032
  };
5033
5033
  }
5034
+ async ready() {
5035
+ const response = await fetch(`${this.server}/api/auth/config`, {
5036
+ headers: { ...this.headers },
5037
+ signal: AbortSignal.timeout(this.requestTimeoutMs)
5038
+ });
5039
+ const raw = await response.text();
5040
+ let body;
5041
+ try {
5042
+ body = raw ? JSON.parse(raw) : void 0;
5043
+ } catch {
5044
+ body = void 0;
5045
+ }
5046
+ if (!response.ok || typeof body?.mode !== "string") {
5047
+ const detail = `HTTP ${response.status} ${response.statusText}`.trim();
5048
+ throw new Error(
5049
+ !body && raw ? `${detail}: ${raw.slice(0, 500)}` : detail
5050
+ );
5051
+ }
5052
+ return { mode: body.mode };
5053
+ }
5034
5054
  async request(query, variables) {
5035
5055
  const response = await fetch(`${this.server}/api/graphql`, {
5036
5056
  method: "POST",
@@ -51405,7 +51425,7 @@ async function waitForServer(client2, timeoutMs, signal, dependencies) {
51405
51425
  let lastError;
51406
51426
  while (!signal.aborted && Date.now() < deadline) {
51407
51427
  try {
51408
- await client2.health();
51428
+ await client2.ready();
51409
51429
  return;
51410
51430
  } catch (error) {
51411
51431
  lastError = error;
@@ -51447,10 +51467,15 @@ async function prepareDevelopmentAgent(options, signal, dependencies = defaultDe
51447
51467
  }
51448
51468
  } catch {
51449
51469
  }
51450
- const enrollment2 = await anonymousClient.createEnrollmentToken();
51470
+ const enrollmentToken = options.enrollmentToken?.trim();
51471
+ if (!enrollmentToken) {
51472
+ throw new Error(
51473
+ "The development agent needs a one-time enrollment token. Create one on the Agents page and set CONTROL_AGENT_DEV_ENROLLMENT_TOKEN."
51474
+ );
51475
+ }
51451
51476
  const response = await anonymousClient.enroll({
51452
51477
  ...inventory,
51453
- enrollmentToken: enrollment2.createAgentEnrollmentToken.token,
51478
+ enrollmentToken,
51454
51479
  name
51455
51480
  });
51456
51481
  const config = {
@@ -51684,10 +51709,10 @@ async function doctor() {
51684
51709
  null,
51685
51710
  1e4,
51686
51711
  config?.headers
51687
- ).health();
51712
+ ).ready();
51688
51713
  return {
51689
- ok: health.health === "ok",
51690
- detail: `${endpoint.kind} ${endpoint.server}: ${health.health}`
51714
+ ok: true,
51715
+ detail: `${endpoint.kind} ${endpoint.server}: ready (${health.mode})`
51691
51716
  };
51692
51717
  } catch (error) {
51693
51718
  return {
@@ -51734,7 +51759,8 @@ async function main() {
51734
51759
  {
51735
51760
  server,
51736
51761
  websocketServer: options["websocket-server"] ?? process.env.CONTROL_AGENT_DEV_WEBSOCKET_SERVER ?? process.env.NEXT_PUBLIC_AGENT_WS_URL,
51737
- name: options.name
51762
+ name: options.name,
51763
+ enrollmentToken: options["enrollment-token"] ?? process.env.CONTROL_AGENT_DEV_ENROLLMENT_TOKEN
51738
51764
  },
51739
51765
  controller.signal
51740
51766
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-development-environment/control-agent",
3
- "version": "0.0.81",
3
+ "version": "0.0.82",
4
4
  "description": "Control agent for the AI Development Environment",
5
5
  "license": "MIT",
6
6
  "repository": {