@alpacakit/agents 0.1.0-beta.19

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 (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +224 -0
  3. package/dist/agents/builtin.d.ts +19 -0
  4. package/dist/agents/builtin.d.ts.map +1 -0
  5. package/dist/agents/builtin.js +14 -0
  6. package/dist/agents/claude.d.ts +20 -0
  7. package/dist/agents/claude.d.ts.map +1 -0
  8. package/dist/agents/claude.js +480 -0
  9. package/dist/agents/codex.d.ts +19 -0
  10. package/dist/agents/codex.d.ts.map +1 -0
  11. package/dist/agents/codex.js +355 -0
  12. package/dist/agents/openai-compatible/config.d.ts +16 -0
  13. package/dist/agents/openai-compatible/config.d.ts.map +1 -0
  14. package/dist/agents/openai-compatible/config.js +160 -0
  15. package/dist/agents/openai-compatible/engine.d.ts +18 -0
  16. package/dist/agents/openai-compatible/engine.d.ts.map +1 -0
  17. package/dist/agents/openai-compatible/engine.js +10 -0
  18. package/dist/agents/openai-compatible/fetch-engine.d.ts +38 -0
  19. package/dist/agents/openai-compatible/fetch-engine.d.ts.map +1 -0
  20. package/dist/agents/openai-compatible/fetch-engine.js +216 -0
  21. package/dist/agents/openai-compatible/pi/engine.d.ts +32 -0
  22. package/dist/agents/openai-compatible/pi/engine.d.ts.map +1 -0
  23. package/dist/agents/openai-compatible/pi/engine.js +98 -0
  24. package/dist/agents/openai-compatible/pi/module.d.ts +87 -0
  25. package/dist/agents/openai-compatible/pi/module.d.ts.map +1 -0
  26. package/dist/agents/openai-compatible/pi/module.js +43 -0
  27. package/dist/agents/openai-compatible/pi/sandbox.d.ts +25 -0
  28. package/dist/agents/openai-compatible/pi/sandbox.d.ts.map +1 -0
  29. package/dist/agents/openai-compatible/pi/sandbox.js +69 -0
  30. package/dist/agents/openai-compatible/pi/session.d.ts +17 -0
  31. package/dist/agents/openai-compatible/pi/session.d.ts.map +1 -0
  32. package/dist/agents/openai-compatible/pi/session.js +354 -0
  33. package/dist/agents/openai-compatible/response.d.ts +19 -0
  34. package/dist/agents/openai-compatible/response.d.ts.map +1 -0
  35. package/dist/agents/openai-compatible/response.js +203 -0
  36. package/dist/agents/openai-compatible/types.d.ts +34 -0
  37. package/dist/agents/openai-compatible/types.d.ts.map +1 -0
  38. package/dist/agents/openai-compatible/types.js +1 -0
  39. package/dist/agents/openai-compatible.d.ts +12 -0
  40. package/dist/agents/openai-compatible.d.ts.map +1 -0
  41. package/dist/agents/openai-compatible.js +45 -0
  42. package/dist/auth/login-probe.d.ts +21 -0
  43. package/dist/auth/login-probe.d.ts.map +1 -0
  44. package/dist/auth/login-probe.js +47 -0
  45. package/dist/auth/login.d.ts +79 -0
  46. package/dist/auth/login.d.ts.map +1 -0
  47. package/dist/auth/login.js +9 -0
  48. package/dist/auth/material.d.ts +87 -0
  49. package/dist/auth/material.d.ts.map +1 -0
  50. package/dist/auth/material.js +59 -0
  51. package/dist/auth/profile-store.d.ts +14 -0
  52. package/dist/auth/profile-store.d.ts.map +1 -0
  53. package/dist/auth/profile-store.js +101 -0
  54. package/dist/auth/secrets.d.ts +14 -0
  55. package/dist/auth/secrets.d.ts.map +1 -0
  56. package/dist/auth/secrets.js +40 -0
  57. package/dist/codex/app-server.d.ts +30 -0
  58. package/dist/codex/app-server.d.ts.map +1 -0
  59. package/dist/codex/app-server.js +322 -0
  60. package/dist/codex/index.d.ts +3 -0
  61. package/dist/codex/index.d.ts.map +1 -0
  62. package/dist/codex/index.js +1 -0
  63. package/dist/codex/protocol.d.ts +124 -0
  64. package/dist/codex/protocol.d.ts.map +1 -0
  65. package/dist/codex/protocol.js +283 -0
  66. package/dist/config/agent-config-validation.d.ts +22 -0
  67. package/dist/config/agent-config-validation.d.ts.map +1 -0
  68. package/dist/config/agent-config-validation.js +31 -0
  69. package/dist/config/agent-configs.d.ts +37 -0
  70. package/dist/config/agent-configs.d.ts.map +1 -0
  71. package/dist/config/agent-configs.js +214 -0
  72. package/dist/config/compose.d.ts +10 -0
  73. package/dist/config/compose.d.ts.map +1 -0
  74. package/dist/config/compose.js +89 -0
  75. package/dist/config/config.d.ts +21 -0
  76. package/dist/config/config.d.ts.map +1 -0
  77. package/dist/config/config.js +33 -0
  78. package/dist/config/errors.d.ts +45 -0
  79. package/dist/config/errors.d.ts.map +1 -0
  80. package/dist/config/errors.js +37 -0
  81. package/dist/config/extension.d.ts +3 -0
  82. package/dist/config/extension.d.ts.map +1 -0
  83. package/dist/config/extension.js +1 -0
  84. package/dist/config/ids.d.ts +8 -0
  85. package/dist/config/ids.d.ts.map +1 -0
  86. package/dist/config/ids.js +4 -0
  87. package/dist/config/index.d.ts +12 -0
  88. package/dist/config/index.d.ts.map +1 -0
  89. package/dist/config/index.js +6 -0
  90. package/dist/config/model.d.ts +105 -0
  91. package/dist/config/model.d.ts.map +1 -0
  92. package/dist/config/model.js +1 -0
  93. package/dist/config/paths.d.ts +7 -0
  94. package/dist/config/paths.d.ts.map +1 -0
  95. package/dist/config/paths.js +10 -0
  96. package/dist/config/schema.d.ts +59 -0
  97. package/dist/config/schema.d.ts.map +1 -0
  98. package/dist/config/schema.js +83 -0
  99. package/dist/config/store.d.ts +34 -0
  100. package/dist/config/store.d.ts.map +1 -0
  101. package/dist/config/store.js +420 -0
  102. package/dist/config/support.d.ts +14 -0
  103. package/dist/config/support.d.ts.map +1 -0
  104. package/dist/config/support.js +32 -0
  105. package/dist/config/values.d.ts +21 -0
  106. package/dist/config/values.d.ts.map +1 -0
  107. package/dist/config/values.js +22 -0
  108. package/dist/config/xdg.d.ts +20 -0
  109. package/dist/config/xdg.d.ts.map +1 -0
  110. package/dist/config/xdg.js +23 -0
  111. package/dist/core/async-queue.d.ts +14 -0
  112. package/dist/core/async-queue.d.ts.map +1 -0
  113. package/dist/core/async-queue.js +46 -0
  114. package/dist/core/env.d.ts +19 -0
  115. package/dist/core/env.d.ts.map +1 -0
  116. package/dist/core/env.js +39 -0
  117. package/dist/core/error.d.ts +121 -0
  118. package/dist/core/error.d.ts.map +1 -0
  119. package/dist/core/error.js +88 -0
  120. package/dist/core/fs.d.ts +16 -0
  121. package/dist/core/fs.d.ts.map +1 -0
  122. package/dist/core/fs.js +30 -0
  123. package/dist/core/json.d.ts +20 -0
  124. package/dist/core/json.d.ts.map +1 -0
  125. package/dist/core/json.js +42 -0
  126. package/dist/core/node-ports.d.ts +9 -0
  127. package/dist/core/node-ports.d.ts.map +1 -0
  128. package/dist/core/node-ports.js +135 -0
  129. package/dist/core/ports.d.ts +71 -0
  130. package/dist/core/ports.d.ts.map +1 -0
  131. package/dist/core/ports.js +19 -0
  132. package/dist/core/redact.d.ts +8 -0
  133. package/dist/core/redact.d.ts.map +1 -0
  134. package/dist/core/redact.js +66 -0
  135. package/dist/core/run.d.ts +125 -0
  136. package/dist/core/run.d.ts.map +1 -0
  137. package/dist/core/run.js +27 -0
  138. package/dist/core/values.d.ts +12 -0
  139. package/dist/core/values.d.ts.map +1 -0
  140. package/dist/core/values.js +9 -0
  141. package/dist/corpus/failure-corpus.d.ts +21 -0
  142. package/dist/corpus/failure-corpus.d.ts.map +1 -0
  143. package/dist/corpus/failure-corpus.js +89 -0
  144. package/dist/fleet/fleet.d.ts +120 -0
  145. package/dist/fleet/fleet.d.ts.map +1 -0
  146. package/dist/fleet/fleet.js +409 -0
  147. package/dist/fleet/policy.d.ts +45 -0
  148. package/dist/fleet/policy.d.ts.map +1 -0
  149. package/dist/fleet/policy.js +50 -0
  150. package/dist/fleet/store.d.ts +28 -0
  151. package/dist/fleet/store.d.ts.map +1 -0
  152. package/dist/fleet/store.js +225 -0
  153. package/dist/host/capabilities.d.ts +146 -0
  154. package/dist/host/capabilities.d.ts.map +1 -0
  155. package/dist/host/capabilities.js +59 -0
  156. package/dist/host/context.d.ts +29 -0
  157. package/dist/host/context.d.ts.map +1 -0
  158. package/dist/host/context.js +11 -0
  159. package/dist/host/github-dir.d.ts +16 -0
  160. package/dist/host/github-dir.d.ts.map +1 -0
  161. package/dist/host/github-dir.js +164 -0
  162. package/dist/host/mcp-list.d.ts +12 -0
  163. package/dist/host/mcp-list.d.ts.map +1 -0
  164. package/dist/host/mcp-list.js +122 -0
  165. package/dist/host/requirement-ref.d.ts +12 -0
  166. package/dist/host/requirement-ref.d.ts.map +1 -0
  167. package/dist/host/requirement-ref.js +40 -0
  168. package/dist/host/run-command.d.ts +27 -0
  169. package/dist/host/run-command.d.ts.map +1 -0
  170. package/dist/host/run-command.js +66 -0
  171. package/dist/host/validate-spec.d.ts +10 -0
  172. package/dist/host/validate-spec.d.ts.map +1 -0
  173. package/dist/host/validate-spec.js +69 -0
  174. package/dist/index.d.ts +69 -0
  175. package/dist/index.d.ts.map +1 -0
  176. package/dist/index.js +41 -0
  177. package/dist/kernel/classify.d.ts +44 -0
  178. package/dist/kernel/classify.d.ts.map +1 -0
  179. package/dist/kernel/classify.js +136 -0
  180. package/dist/kernel/cli-agent.d.ts +62 -0
  181. package/dist/kernel/cli-agent.d.ts.map +1 -0
  182. package/dist/kernel/cli-agent.js +281 -0
  183. package/dist/kernel/cli-login.d.ts +13 -0
  184. package/dist/kernel/cli-login.d.ts.map +1 -0
  185. package/dist/kernel/cli-login.js +199 -0
  186. package/dist/kernel/definition.d.ts +41 -0
  187. package/dist/kernel/definition.d.ts.map +1 -0
  188. package/dist/kernel/definition.js +13 -0
  189. package/dist/kernel/env-template.d.ts +17 -0
  190. package/dist/kernel/env-template.d.ts.map +1 -0
  191. package/dist/kernel/env-template.js +78 -0
  192. package/dist/kernel/facets.d.ts +58 -0
  193. package/dist/kernel/facets.d.ts.map +1 -0
  194. package/dist/kernel/facets.js +102 -0
  195. package/dist/kernel/guard.d.ts +24 -0
  196. package/dist/kernel/guard.d.ts.map +1 -0
  197. package/dist/kernel/guard.js +69 -0
  198. package/dist/kernel/handle.d.ts +29 -0
  199. package/dist/kernel/handle.d.ts.map +1 -0
  200. package/dist/kernel/handle.js +97 -0
  201. package/dist/kernel/keyed.d.ts +19 -0
  202. package/dist/kernel/keyed.d.ts.map +1 -0
  203. package/dist/kernel/keyed.js +35 -0
  204. package/dist/kernel/login.d.ts +20 -0
  205. package/dist/kernel/login.d.ts.map +1 -0
  206. package/dist/kernel/login.js +74 -0
  207. package/dist/kernel/options.d.ts +73 -0
  208. package/dist/kernel/options.d.ts.map +1 -0
  209. package/dist/kernel/options.js +41 -0
  210. package/dist/kernel/run.d.ts +20 -0
  211. package/dist/kernel/run.d.ts.map +1 -0
  212. package/dist/kernel/run.js +245 -0
  213. package/dist/kernel/runtime.d.ts +48 -0
  214. package/dist/kernel/runtime.d.ts.map +1 -0
  215. package/dist/kernel/runtime.js +108 -0
  216. package/dist/keyring/index.d.ts +2 -0
  217. package/dist/keyring/index.d.ts.map +1 -0
  218. package/dist/keyring/index.js +1 -0
  219. package/dist/keyring/resolver.d.ts +9 -0
  220. package/dist/keyring/resolver.d.ts.map +1 -0
  221. package/dist/keyring/resolver.js +62 -0
  222. package/dist/run-agent.d.ts +19 -0
  223. package/dist/run-agent.d.ts.map +1 -0
  224. package/dist/run-agent.js +25 -0
  225. package/dist/structured/extract.d.ts +27 -0
  226. package/dist/structured/extract.d.ts.map +1 -0
  227. package/dist/structured/extract.js +188 -0
  228. package/dist/structured/run-structured.d.ts +83 -0
  229. package/dist/structured/run-structured.d.ts.map +1 -0
  230. package/dist/structured/run-structured.js +202 -0
  231. package/dist/structured/standard-schema.d.ts +34 -0
  232. package/dist/structured/standard-schema.d.ts.map +1 -0
  233. package/dist/structured/standard-schema.js +6 -0
  234. package/dist/testing/fake-agent.d.ts +32 -0
  235. package/dist/testing/fake-agent.d.ts.map +1 -0
  236. package/dist/testing/fake-agent.js +43 -0
  237. package/dist/testing/fake-clock.d.ts +8 -0
  238. package/dist/testing/fake-clock.d.ts.map +1 -0
  239. package/dist/testing/fake-clock.js +44 -0
  240. package/dist/testing/fake-exec.d.ts +26 -0
  241. package/dist/testing/fake-exec.d.ts.map +1 -0
  242. package/dist/testing/fake-exec.js +69 -0
  243. package/dist/testing/fake-secrets.d.ts +3 -0
  244. package/dist/testing/fake-secrets.d.ts.map +1 -0
  245. package/dist/testing/fake-secrets.js +5 -0
  246. package/dist/testing/index.d.ts +10 -0
  247. package/dist/testing/index.d.ts.map +1 -0
  248. package/dist/testing/index.js +9 -0
  249. package/package.json +75 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Env mutation as data (design A8): activating one auth mechanism must be
3
+ * able to clear competing variables, so a patch carries both directions.
4
+ */
5
+ // Shared default: frozen at both levels so no caller can mutate it in place.
6
+ export const EMPTY_ENV_PATCH = Object.freeze({ set: {}, unset: [] });
7
+ Object.freeze(EMPTY_ENV_PATCH.set);
8
+ Object.freeze(EMPTY_ENV_PATCH.unset);
9
+ export function applyEnvPatch(env, patch) {
10
+ const next = { ...env };
11
+ for (const name of patch.unset) {
12
+ delete next[name];
13
+ }
14
+ for (const [name, value] of Object.entries(patch.set)) {
15
+ next[name] = value;
16
+ }
17
+ return next;
18
+ }
19
+ export function mergeEnvPatches(first, second) {
20
+ return {
21
+ set: { ...first.set, ...second.set },
22
+ unset: [...first.unset, ...second.unset],
23
+ };
24
+ }
25
+ /**
26
+ * Snapshot `process.env` as a defined-only `Record<string, string>` — the
27
+ * `baseEnv` shape `createAgentRuntime` and `runAgent` expect. Exposed so
28
+ * callers stop reaching for `process.env as Record<string, string>`, which
29
+ * lies about the `undefined` values Node keeps on the object.
30
+ */
31
+ export function processEnv() {
32
+ const env = {};
33
+ for (const [name, value] of Object.entries(process.env)) {
34
+ if (value !== undefined) {
35
+ env[name] = value;
36
+ }
37
+ }
38
+ return env;
39
+ }
@@ -0,0 +1,121 @@
1
+ /**
2
+ * One throwable type crosses the library boundary (design: "Errors are
3
+ * data"). Error data is typed per code through the `AgentErrorData` map;
4
+ * a `Record<string, unknown>` grab-bag is banned.
5
+ */
6
+ export declare const AGENT_ERROR_CODE: {
7
+ readonly invalidInput: "invalid_input";
8
+ readonly notAvailable: "not_available";
9
+ readonly capacity: "capacity";
10
+ readonly quota: "quota";
11
+ readonly auth: "auth";
12
+ readonly timeout: "timeout";
13
+ readonly limit: "limit";
14
+ readonly cancelled: "cancelled";
15
+ readonly outputRejected: "output_rejected";
16
+ readonly failed: "failed";
17
+ };
18
+ export type AgentErrorCode = (typeof AGENT_ERROR_CODE)[keyof typeof AGENT_ERROR_CODE];
19
+ export declare const AUTH_FAILURE_REASON: {
20
+ readonly notLoggedIn: "not_logged_in";
21
+ readonly invalidApiKey: "invalid_api_key";
22
+ readonly invalidToken: "invalid_token";
23
+ readonly invalidCredentials: "invalid_credentials";
24
+ readonly refreshTokenReused: "refresh_token_reused";
25
+ readonly tokenInvalidated: "token_invalidated";
26
+ readonly authenticationFailed: "authentication_failed";
27
+ readonly unauthorized: "unauthorized";
28
+ readonly forbidden: "forbidden";
29
+ readonly unknown: "unknown";
30
+ };
31
+ export type AuthFailureReason = (typeof AUTH_FAILURE_REASON)[keyof typeof AUTH_FAILURE_REASON];
32
+ export declare const NOT_AVAILABLE_CAUSE: {
33
+ readonly notInstalled: "not_installed";
34
+ readonly engineMissing: "engine_missing";
35
+ readonly badConfig: "bad_config";
36
+ readonly unreachable: "unreachable";
37
+ };
38
+ export type NotAvailableCause = (typeof NOT_AVAILABLE_CAUSE)[keyof typeof NOT_AVAILABLE_CAUSE];
39
+ export declare const TIMEOUT_KIND: {
40
+ readonly total: "total";
41
+ readonly idle: "idle";
42
+ };
43
+ export type TimeoutKind = (typeof TIMEOUT_KIND)[keyof typeof TIMEOUT_KIND];
44
+ export type GuardViolation = {
45
+ guardId: string;
46
+ reason: string;
47
+ };
48
+ export type Issue = {
49
+ path: Array<string | number>;
50
+ code: string;
51
+ message: string;
52
+ };
53
+ export type AgentErrorData = {
54
+ [AGENT_ERROR_CODE.invalidInput]: {
55
+ reason: string;
56
+ };
57
+ [AGENT_ERROR_CODE.notAvailable]: {
58
+ cause: NotAvailableCause;
59
+ };
60
+ [AGENT_ERROR_CODE.capacity]: {
61
+ cooldownUntil: string | null;
62
+ };
63
+ [AGENT_ERROR_CODE.quota]: {
64
+ cooldownUntil: string | null;
65
+ };
66
+ [AGENT_ERROR_CODE.auth]: {
67
+ reason: AuthFailureReason;
68
+ detail: string | null;
69
+ };
70
+ [AGENT_ERROR_CODE.timeout]: {
71
+ kind: TimeoutKind;
72
+ limitMs: number;
73
+ };
74
+ [AGENT_ERROR_CODE.limit]: {
75
+ violation: GuardViolation;
76
+ };
77
+ [AGENT_ERROR_CODE.cancelled]: {
78
+ reason: string | null;
79
+ };
80
+ [AGENT_ERROR_CODE.outputRejected]: {
81
+ issues: Issue[];
82
+ attempts: number;
83
+ };
84
+ [AGENT_ERROR_CODE.failed]: {
85
+ exitCode: number | null;
86
+ stdoutTail: string | null;
87
+ stderrTail: string | null;
88
+ };
89
+ };
90
+ export type AgentErrorOptions<C extends AgentErrorCode> = {
91
+ code: C;
92
+ message: string;
93
+ data: AgentErrorData[C];
94
+ runId?: string;
95
+ agentId?: string;
96
+ started?: boolean;
97
+ durationMs?: number;
98
+ cause?: unknown;
99
+ };
100
+ export declare class AgentError<C extends AgentErrorCode = AgentErrorCode> extends Error {
101
+ readonly code: C;
102
+ readonly data: AgentErrorData[C];
103
+ readonly runId: string | null;
104
+ readonly agentId: string | null;
105
+ readonly started: boolean;
106
+ readonly durationMs: number;
107
+ constructor(options: AgentErrorOptions<C>);
108
+ }
109
+ /**
110
+ * Brand-based guard, not `instanceof`: survives duplicated package copies
111
+ * in one dependency tree.
112
+ */
113
+ export declare function isAgentError<C extends AgentErrorCode>(value: unknown, code?: C): value is AgentError<C>;
114
+ /** Rebuild an AgentError with run identity the thrower could not know. */
115
+ export declare function withRunIdentity<C extends AgentErrorCode>(error: AgentError<C>, identity: {
116
+ runId: string;
117
+ agentId: string;
118
+ started: boolean;
119
+ durationMs: number;
120
+ }): AgentError<C>;
121
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/core/error.ts"],"names":[],"mappings":"AAAA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AI,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC;CAiB1C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,cAAc,EACnD,KAAK,EAAE,OAAO,EACd,IAAI,CAAC,EAAE,CAAC,GACP,KAAK,IAAI,UAAU,CAAC,CAAC,CAAC,CAQxB;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,CAAC,CAAC,SAAS,cAAc,EACtD,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EACpB,QAAQ,EAAE;IACR,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB,GACA,UAAU,CAAC,CAAC,CAAC,CAWf"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * One throwable type crosses the library boundary (design: "Errors are
3
+ * data"). Error data is typed per code through the `AgentErrorData` map;
4
+ * a `Record<string, unknown>` grab-bag is banned.
5
+ */
6
+ export const AGENT_ERROR_CODE = {
7
+ invalidInput: "invalid_input",
8
+ notAvailable: "not_available",
9
+ capacity: "capacity",
10
+ quota: "quota",
11
+ auth: "auth",
12
+ timeout: "timeout",
13
+ limit: "limit",
14
+ cancelled: "cancelled",
15
+ outputRejected: "output_rejected",
16
+ failed: "failed",
17
+ };
18
+ export const AUTH_FAILURE_REASON = {
19
+ notLoggedIn: "not_logged_in",
20
+ invalidApiKey: "invalid_api_key",
21
+ invalidToken: "invalid_token",
22
+ invalidCredentials: "invalid_credentials",
23
+ refreshTokenReused: "refresh_token_reused",
24
+ tokenInvalidated: "token_invalidated",
25
+ authenticationFailed: "authentication_failed",
26
+ unauthorized: "unauthorized",
27
+ forbidden: "forbidden",
28
+ unknown: "unknown",
29
+ };
30
+ export const NOT_AVAILABLE_CAUSE = {
31
+ notInstalled: "not_installed",
32
+ engineMissing: "engine_missing",
33
+ badConfig: "bad_config",
34
+ unreachable: "unreachable",
35
+ };
36
+ export const TIMEOUT_KIND = {
37
+ total: "total",
38
+ idle: "idle",
39
+ };
40
+ const AGENT_ERROR_BRAND = Symbol.for("@alpacakit/agents.AgentError");
41
+ export class AgentError extends Error {
42
+ code;
43
+ data;
44
+ runId;
45
+ agentId;
46
+ started;
47
+ durationMs;
48
+ constructor(options) {
49
+ super(options.message, options.cause === undefined ? undefined : { cause: options.cause });
50
+ this.name = "AgentError";
51
+ this.code = options.code;
52
+ this.data = options.data;
53
+ this.runId = options.runId ?? null;
54
+ this.agentId = options.agentId ?? null;
55
+ this.started = options.started ?? false;
56
+ this.durationMs = options.durationMs ?? 0;
57
+ Object.defineProperty(this, AGENT_ERROR_BRAND, {
58
+ value: true,
59
+ enumerable: false,
60
+ });
61
+ }
62
+ }
63
+ /**
64
+ * Brand-based guard, not `instanceof`: survives duplicated package copies
65
+ * in one dependency tree.
66
+ */
67
+ export function isAgentError(value, code) {
68
+ if (typeof value !== "object" || value === null) {
69
+ return false;
70
+ }
71
+ if (Reflect.get(value, AGENT_ERROR_BRAND) !== true) {
72
+ return false;
73
+ }
74
+ return code === undefined || Reflect.get(value, "code") === code;
75
+ }
76
+ /** Rebuild an AgentError with run identity the thrower could not know. */
77
+ export function withRunIdentity(error, identity) {
78
+ return new AgentError({
79
+ code: error.code,
80
+ message: error.message,
81
+ data: error.data,
82
+ runId: error.runId ?? identity.runId,
83
+ agentId: error.agentId ?? identity.agentId,
84
+ started: error.started || identity.started,
85
+ durationMs: error.durationMs > 0 ? error.durationMs : identity.durationMs,
86
+ cause: error.cause,
87
+ });
88
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared filesystem discipline for the package's private state files:
3
+ * errno narrowing without `instanceof` on Node internals, and the
4
+ * 0700-directory / 0600-file atomic write ritual (temp + rename) every
5
+ * store uses.
6
+ */
7
+ export declare const PRIVATE_DIRECTORY_MODE = 448;
8
+ export declare const PRIVATE_FILE_MODE = 384;
9
+ /** Narrowing over Node fs errors without `instanceof` on internals. */
10
+ export declare function isErrnoCode(error: unknown, code: string): boolean;
11
+ /**
12
+ * Write a private (0600) file atomically: create the 0700 parent, write
13
+ * a pid-suffixed temp file, then rename over the destination.
14
+ */
15
+ export declare function writeFileAtomically(filePath: string, content: string): Promise<void>;
16
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/core/fs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,eAAO,MAAM,sBAAsB,MAAQ,CAAC;AAC5C,eAAO,MAAM,iBAAiB,MAAQ,CAAC;AAGvC,uEAAuE;AACvE,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMjE;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAQf"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared filesystem discipline for the package's private state files:
3
+ * errno narrowing without `instanceof` on Node internals, and the
4
+ * 0700-directory / 0600-file atomic write ritual (temp + rename) every
5
+ * store uses.
6
+ */
7
+ import { mkdir, rename, writeFile } from "node:fs/promises";
8
+ import path from "node:path";
9
+ export const PRIVATE_DIRECTORY_MODE = 0o700;
10
+ export const PRIVATE_FILE_MODE = 0o600;
11
+ const TEMP_FILE_SUFFIX = "tmp";
12
+ /** Narrowing over Node fs errors without `instanceof` on internals. */
13
+ export function isErrnoCode(error, code) {
14
+ return (typeof error === "object" &&
15
+ error !== null &&
16
+ error.code === code);
17
+ }
18
+ /**
19
+ * Write a private (0600) file atomically: create the 0700 parent, write
20
+ * a pid-suffixed temp file, then rename over the destination.
21
+ */
22
+ export async function writeFileAtomically(filePath, content) {
23
+ await mkdir(path.dirname(filePath), {
24
+ recursive: true,
25
+ mode: PRIVATE_DIRECTORY_MODE,
26
+ });
27
+ const tempPath = [filePath, String(process.pid), TEMP_FILE_SUFFIX].join(".");
28
+ await writeFile(tempPath, content, { mode: PRIVATE_FILE_MODE });
29
+ await rename(tempPath, filePath);
30
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Narrowing readers over parsed JSON (rule: no `any`, no throwing on
3
+ * shape mismatch — `null` is "not there"). Shared by NDJSON line parsing
4
+ * in the built-in agents and host-plane CLI output parsing.
5
+ */
6
+ /**
7
+ * Foreign JSON before field-level narrowing. This alias is the ONE place
8
+ * the broad record shape is spelled (biome.json exempts this module from
9
+ * the no-broad-record plugin); every reader boundary references it so
10
+ * contract types elsewhere stay explicitly modeled.
11
+ */
12
+ export type UnknownRecord = Record<string, unknown>;
13
+ export declare function readUnknownRecord(value: unknown): UnknownRecord | null;
14
+ export declare function readJsonRecord(line: string): UnknownRecord | null;
15
+ export declare function readString(record: UnknownRecord, key: string): string | null;
16
+ export declare function readNumber(record: UnknownRecord, key: string): number | null;
17
+ export declare function readRecord(record: UnknownRecord, key: string): UnknownRecord | null;
18
+ export declare function readBoolean(record: UnknownRecord, key: string): boolean | null;
19
+ export declare function readArray(record: UnknownRecord, key: string): readonly unknown[] | null;
20
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/core/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI,CAKtE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAUjE;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG5E;AAED,wBAAgB,UAAU,CACxB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACV,aAAa,GAAG,IAAI,CAEtB;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACV,OAAO,GAAG,IAAI,CAGhB;AAED,wBAAgB,SAAS,CACvB,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACV,SAAS,OAAO,EAAE,GAAG,IAAI,CAG3B"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Narrowing readers over parsed JSON (rule: no `any`, no throwing on
3
+ * shape mismatch — `null` is "not there"). Shared by NDJSON line parsing
4
+ * in the built-in agents and host-plane CLI output parsing.
5
+ */
6
+ export function readUnknownRecord(value) {
7
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
8
+ return null;
9
+ }
10
+ return value;
11
+ }
12
+ export function readJsonRecord(line) {
13
+ if (!line.startsWith("{") || !line.endsWith("}")) {
14
+ return null;
15
+ }
16
+ try {
17
+ const parsed = JSON.parse(line);
18
+ return readUnknownRecord(parsed);
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ export function readString(record, key) {
25
+ const value = record[key];
26
+ return typeof value === "string" ? value : null;
27
+ }
28
+ export function readNumber(record, key) {
29
+ const value = record[key];
30
+ return typeof value === "number" ? value : null;
31
+ }
32
+ export function readRecord(record, key) {
33
+ return readUnknownRecord(record[key]);
34
+ }
35
+ export function readBoolean(record, key) {
36
+ const value = record[key];
37
+ return typeof value === "boolean" ? value : null;
38
+ }
39
+ export function readArray(record, key) {
40
+ const value = record[key];
41
+ return Array.isArray(value) ? value : null;
42
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Production port defaults. This is the only module (besides the "env"
3
+ * secret resolver) that touches Node process APIs directly.
4
+ */
5
+ import type { Clock, Exec, HttpClient } from "./ports.js";
6
+ export declare const systemClock: Clock;
7
+ export declare const fetchHttp: HttpClient;
8
+ export declare const nodeExec: Exec;
9
+ //# sourceMappingURL=node-ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-ports.d.ts","sourceRoot":"","sources":["../../src/core/node-ports.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EACV,KAAK,EACL,IAAI,EAIJ,UAAU,EAGX,MAAM,YAAY,CAAC;AAOpB,eAAO,MAAM,WAAW,EAAE,KAOzB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,UAEvB,CAAC;AA+HF,eAAO,MAAM,QAAQ,EAAE,IAGtB,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Production port defaults. This is the only module (besides the "env"
3
+ * secret resolver) that touches Node process APIs directly.
4
+ */
5
+ import { spawn } from "node:child_process";
6
+ import { access, constants } from "node:fs";
7
+ import path from "node:path";
8
+ import { AsyncQueue } from "./async-queue.js";
9
+ import { OUTPUT_CHANNEL, TEXT_ENCODING } from "./values.js";
10
+ const PATH_ENV_VAR = "PATH";
11
+ const PATHEXT_ENV_VAR = "PATHEXT";
12
+ const DEFAULT_WINDOWS_EXECUTABLE_EXTENSIONS = ".COM;.EXE;.BAT;.CMD";
13
+ export const systemClock = {
14
+ now: () => Date.now(),
15
+ setTimeout: (callback, delayMs) => {
16
+ const timer = setTimeout(callback, delayMs);
17
+ timer.unref();
18
+ return () => clearTimeout(timer);
19
+ },
20
+ };
21
+ export const fetchHttp = {
22
+ fetch: (url, init) => fetch(url, init),
23
+ };
24
+ /**
25
+ * Node-bin-first PATH (E5): the wrapped CLIs are node scripts, so both
26
+ * resolving them and letting them find `node` needs the running node's
27
+ * bin directory first on PATH. Reading `process.execPath` is this
28
+ * production adapter's boundary job, like `process.env` is the env
29
+ * resolver's.
30
+ */
31
+ const nodeBinDir = path.dirname(process.execPath);
32
+ function pathKeyOf(env) {
33
+ for (const key of Object.keys(env)) {
34
+ if (key.toUpperCase() === PATH_ENV_VAR) {
35
+ return key;
36
+ }
37
+ }
38
+ return PATH_ENV_VAR;
39
+ }
40
+ function withNodeBinFirst(env) {
41
+ const key = pathKeyOf(env);
42
+ const entries = (env[key] ?? "")
43
+ .split(path.delimiter)
44
+ .filter((entry) => entry !== "");
45
+ if (entries[0] === nodeBinDir) {
46
+ return env;
47
+ }
48
+ const rest = entries.filter((entry) => entry !== nodeBinDir);
49
+ return { ...env, [key]: [nodeBinDir, ...rest].join(path.delimiter) };
50
+ }
51
+ function spawnProcess(options) {
52
+ const child = spawn(options.command, options.args, {
53
+ cwd: options.cwd,
54
+ env: withNodeBinFirst(options.env),
55
+ stdio: ["pipe", "pipe", "pipe"],
56
+ });
57
+ const chunks = new AsyncQueue();
58
+ let settleExit = () => { };
59
+ let failExit = () => { };
60
+ const exit = new Promise((resolve, reject) => {
61
+ settleExit = resolve;
62
+ failExit = reject;
63
+ });
64
+ child.stdout.setEncoding(TEXT_ENCODING);
65
+ child.stderr.setEncoding(TEXT_ENCODING);
66
+ child.stdout.on("data", (text) => {
67
+ chunks.push({ channel: OUTPUT_CHANNEL.stdout, text });
68
+ });
69
+ child.stderr.on("data", (text) => {
70
+ chunks.push({ channel: OUTPUT_CHANNEL.stderr, text });
71
+ });
72
+ child.on("error", (error) => {
73
+ chunks.end();
74
+ failExit(error);
75
+ });
76
+ child.on("close", (code, signal) => {
77
+ chunks.end();
78
+ settleExit({ code, signal });
79
+ });
80
+ // A child that exits without reading stdin emits EPIPE here; without a
81
+ // listener that unhandled 'error' event would crash the host process.
82
+ child.stdin.on("error", () => { });
83
+ if (options.stdin !== null) {
84
+ child.stdin.write(options.stdin);
85
+ }
86
+ if (!("keepStdinOpen" in options)) {
87
+ child.stdin.end();
88
+ }
89
+ return {
90
+ chunks,
91
+ exit,
92
+ writeStdin: (text) => {
93
+ child.stdin.write(text);
94
+ },
95
+ endStdin: () => {
96
+ child.stdin.end();
97
+ },
98
+ kill: (signal) => {
99
+ child.kill(signal);
100
+ },
101
+ };
102
+ }
103
+ function isExecutable(candidate) {
104
+ return new Promise((resolve) => {
105
+ access(candidate, constants.X_OK, (error) => {
106
+ resolve(error === null);
107
+ });
108
+ });
109
+ }
110
+ async function whichOnPath(command, env) {
111
+ if (command.includes(path.sep)) {
112
+ return (await isExecutable(command)) ? command : null;
113
+ }
114
+ const layered = withNodeBinFirst(env);
115
+ const pathValue = layered[pathKeyOf(layered)] ?? "";
116
+ const extensions = process.platform === "win32"
117
+ ? (env[PATHEXT_ENV_VAR] ?? DEFAULT_WINDOWS_EXECUTABLE_EXTENSIONS).split(";")
118
+ : [""];
119
+ for (const directory of pathValue.split(path.delimiter)) {
120
+ if (directory === "") {
121
+ continue;
122
+ }
123
+ for (const extension of extensions) {
124
+ const candidate = path.join(directory, command + extension);
125
+ if (await isExecutable(candidate)) {
126
+ return candidate;
127
+ }
128
+ }
129
+ }
130
+ return null;
131
+ }
132
+ export const nodeExec = {
133
+ spawn: spawnProcess,
134
+ which: whichOnPath,
135
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Ports for every effect (design principle 4): subprocess spawn, clock,
3
+ * secrets, HTTP, and telemetry are injected interfaces with production
4
+ * defaults. No library module reads `process.env` or spawns directly —
5
+ * the sole exception is the built-in "env" secret resolver, whose entire
6
+ * job is that boundary.
7
+ */
8
+ import type { Clock, HttpClient, SecretResolvers } from "@alpacakit/core";
9
+ import type { RunTelemetry } from "./run.js";
10
+ import type { OutputChannel, ProcessSignal } from "./values.js";
11
+ export type { Clock, HttpClient, SecretResolver, SecretResolvers, } from "@alpacakit/core";
12
+ export type ExecChunk = {
13
+ channel: OutputChannel;
14
+ text: string;
15
+ };
16
+ export type ExecExit = {
17
+ code: number | null;
18
+ signal: string | null;
19
+ };
20
+ export type ExecSpawnOptions = {
21
+ command: string;
22
+ args: string[];
23
+ cwd: string;
24
+ env: Record<string, string>;
25
+ stdin: string | null;
26
+ };
27
+ /** Interactive spawn: stdin stays open for incremental writes. */
28
+ export type InteractiveExecSpawnOptions = ExecSpawnOptions & {
29
+ keepStdinOpen: true;
30
+ };
31
+ export interface ExecProcess {
32
+ readonly chunks: AsyncIterable<ExecChunk>;
33
+ readonly exit: Promise<ExecExit>;
34
+ kill(signal: ProcessSignal): void;
35
+ }
36
+ /** Returned by interactive spawns; stdin capability is carried by the type. */
37
+ export interface InteractiveExecProcess extends ExecProcess {
38
+ writeStdin(text: string): void;
39
+ endStdin(): void;
40
+ }
41
+ export interface Exec {
42
+ spawn(options: InteractiveExecSpawnOptions): InteractiveExecProcess;
43
+ spawn(options: ExecSpawnOptions): ExecProcess;
44
+ /** Resolve a command against the given env's PATH; null when absent. */
45
+ which(command: string, env: Record<string, string>): Promise<string | null>;
46
+ }
47
+ export interface TelemetrySink {
48
+ emit(telemetry: RunTelemetry): void;
49
+ }
50
+ export declare const LOG_LEVEL: {
51
+ readonly debug: "debug";
52
+ readonly info: "info";
53
+ readonly warn: "warn";
54
+ readonly error: "error";
55
+ };
56
+ export type LogLevel = (typeof LOG_LEVEL)[keyof typeof LOG_LEVEL];
57
+ export interface Logger {
58
+ log(level: LogLevel, message: string, data?: unknown): void;
59
+ }
60
+ /** The RESOLVED shape (rule 2): every port present. */
61
+ export type Ports = {
62
+ exec: Exec;
63
+ clock: Clock;
64
+ secrets: SecretResolvers;
65
+ http: HttpClient;
66
+ telemetry: TelemetrySink;
67
+ logger: Logger;
68
+ };
69
+ export declare const noopTelemetry: TelemetrySink;
70
+ export declare const noopLogger: Logger;
71
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
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CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,CAAC,OAAO,EAAE,2BAA2B,GAAG,sBAAsB,CAAC;IACpE,KAAK,CAAC,OAAO,EAAE,gBAAgB,GAAG,WAAW,CAAC;IAC9C,wEAAwE;IACxE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC7E;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI,CAAC;CACrC;AAED,eAAO,MAAM,SAAS;;;;;CAKZ,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAElE,MAAM,WAAW,MAAM;IACrB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7D;AAED,uDAAuD;AACvD,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,eAAe,CAAC;IACzB,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAE3B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAExB,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Ports for every effect (design principle 4): subprocess spawn, clock,
3
+ * secrets, HTTP, and telemetry are injected interfaces with production
4
+ * defaults. No library module reads `process.env` or spawns directly —
5
+ * the sole exception is the built-in "env" secret resolver, whose entire
6
+ * job is that boundary.
7
+ */
8
+ export const LOG_LEVEL = {
9
+ debug: "debug",
10
+ info: "info",
11
+ warn: "warn",
12
+ error: "error",
13
+ };
14
+ export const noopTelemetry = {
15
+ emit: () => { },
16
+ };
17
+ export const noopLogger = {
18
+ log: () => { },
19
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Library-wide rule (design F7): every surfaced diagnostic passes secret
3
+ * redaction before it can appear in an error message or telemetry event.
4
+ */
5
+ import type { JsonValue } from "@alpacakit/core";
6
+ export declare function redactSecrets(text: string): string;
7
+ export declare function redactJsonSecrets(value: JsonValue): JsonValue;
8
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/core/redact.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAuCjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASlD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAgB7D"}