@agentclientprotocol/claude-agent-acp 0.81.1-preview.2 → 0.81.1-preview.3

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
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { resolveSettings } from "@anthropic-ai/claude-agent-sdk";
3
2
  import { claudeCliPath, runAcp } from "./acp-agent.js";
3
+ import { applyManagedPolicyEnv } from "./managed-policy.js";
4
4
  import packageJson from "../package.json" with { type: "json" };
5
5
  import { appendFileSync, mkdirSync } from "node:fs";
6
6
  import { join } from "node:path";
@@ -43,13 +43,10 @@ else if (process.argv.includes("--version") || process.argv.includes("-v")) {
43
43
  }
44
44
  else {
45
45
  // Apply env vars from the managed-policy tier before any SDK call so the
46
- // SDK subprocess inherits them. Going through resolveSettings (vs. a raw
47
- // read of managed-settings.json) also picks up MDM sources on macOS and
48
- // HKLM/HKCU on Windows.
49
- const policy = await resolveSettings({ settingSources: [] });
50
- for (const [key, value] of Object.entries(policy.effective.env ?? {})) {
51
- process.env[key] = value;
52
- }
46
+ // SDK subprocess inherits them. Reading the tier is best-effort: a transient
47
+ // failure leaves the agent running with no policy env instead of aborting
48
+ // module evaluation here, before any ACP traffic.
49
+ await applyManagedPolicyEnv();
53
50
  // stdout is used to send messages to the client
54
51
  // we redirect everything else to stderr to make sure it doesn't interfere with ACP
55
52
  console.log = console.error;
@@ -0,0 +1,19 @@
1
+ import { resolveSettings } from "@anthropic-ai/claude-agent-sdk";
2
+ /**
3
+ * Applies the managed-policy tier's env vars to `process.env` before any SDK
4
+ * call, so the SDK subprocess inherits them. Going through `resolveSettings`
5
+ * rather than a raw read of `managed-settings.json` also picks up MDM sources on
6
+ * macOS and `HKLM`/`HKCU` on Windows.
7
+ *
8
+ * Reading the tier is best-effort by nature: on a host with no MDM and no
9
+ * managed policy the result is empty and the agent behaves identically. So a
10
+ * transient failure to read it — `EINTR`, `EMFILE`, `EAGAIN` — must leave the
11
+ * agent running with no policy env rather than stop it from starting.
12
+ *
13
+ * That guard matters because the caller awaits this at module scope in an ESM
14
+ * entry point, where a rejection aborts module evaluation and the process exits
15
+ * before serving any ACP traffic. `SettingsManager.loadAllSettings` wraps the
16
+ * same SDK call for the same reason.
17
+ */
18
+ export declare function applyManagedPolicyEnv(resolve?: typeof resolveSettings, env?: Record<string, string | undefined>): Promise<void>;
19
+ //# sourceMappingURL=managed-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-policy.d.ts","sourceRoot":"","sources":["../src/managed-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,GAAE,OAAO,eAAiC,EACjD,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAAC,IAAI,CAAC,CAYf"}
@@ -0,0 +1,31 @@
1
+ import { resolveSettings } from "@anthropic-ai/claude-agent-sdk";
2
+ /**
3
+ * Applies the managed-policy tier's env vars to `process.env` before any SDK
4
+ * call, so the SDK subprocess inherits them. Going through `resolveSettings`
5
+ * rather than a raw read of `managed-settings.json` also picks up MDM sources on
6
+ * macOS and `HKLM`/`HKCU` on Windows.
7
+ *
8
+ * Reading the tier is best-effort by nature: on a host with no MDM and no
9
+ * managed policy the result is empty and the agent behaves identically. So a
10
+ * transient failure to read it — `EINTR`, `EMFILE`, `EAGAIN` — must leave the
11
+ * agent running with no policy env rather than stop it from starting.
12
+ *
13
+ * That guard matters because the caller awaits this at module scope in an ESM
14
+ * entry point, where a rejection aborts module evaluation and the process exits
15
+ * before serving any ACP traffic. `SettingsManager.loadAllSettings` wraps the
16
+ * same SDK call for the same reason.
17
+ */
18
+ export async function applyManagedPolicyEnv(resolve = resolveSettings, env = process.env) {
19
+ let policy;
20
+ try {
21
+ policy = await resolve({ settingSources: [] });
22
+ }
23
+ catch (error) {
24
+ // stderr, so the ACP stream on stdout stays clean.
25
+ console.error("Failed to resolve managed policy settings:", error);
26
+ return;
27
+ }
28
+ for (const [key, value] of Object.entries(policy.effective.env ?? {})) {
29
+ env[key] = value;
30
+ }
31
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.81.1-preview.2",
6
+ "version": "0.81.1-preview.3",
7
7
  "description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
8
8
  "main": "dist/lib.js",
9
9
  "types": "dist/lib.d.ts",