@open-everywhere/adapters 0.1.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 (156) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +43 -0
  4. package/agent/aws/cli.ts +121 -0
  5. package/agent/aws/config.ts +71 -0
  6. package/agent/aws/register.ts +65 -0
  7. package/agent/aws/sso.ts +567 -0
  8. package/agent/aws/sts.ts +191 -0
  9. package/agent/blob/hosting.ts +24 -0
  10. package/agent/browser/config.ts +62 -0
  11. package/agent/browser/register.ts +66 -0
  12. package/agent/browser/sandbox.ts +39 -0
  13. package/agent/contributions.ts +12 -0
  14. package/agent/directory/config.ts +138 -0
  15. package/agent/directory/okta.ts +226 -0
  16. package/agent/directory/register.ts +16 -0
  17. package/agent/instrumentation.ts +42 -0
  18. package/agent/model/approval-judge.ts +57 -0
  19. package/agent/model/dream-judge.ts +105 -0
  20. package/agent/model/gateway-vision.ts +162 -0
  21. package/agent/model/gateway.ts +85 -0
  22. package/agent/oe-oauth/config.ts +246 -0
  23. package/agent/oe-oauth/errors.ts +77 -0
  24. package/agent/oe-oauth/oauth-client.ts +376 -0
  25. package/agent/oe-oauth/pkce.ts +21 -0
  26. package/agent/oe-oauth/register.ts +32 -0
  27. package/agent/oe-oauth/token-vault.ts +652 -0
  28. package/agent/oe-oauth/user-auth-flow.ts +76 -0
  29. package/agent/postgres/neon.ts +108 -0
  30. package/agent/sandbox/backend-stop.ts +259 -0
  31. package/agent/sandbox/created-sandbox-registry.ts +27 -0
  32. package/agent/sandbox/extend-workspace-time.ts +77 -0
  33. package/agent/sandbox/vercel-lifecycle.ts +252 -0
  34. package/dist/agent/aws/cli.d.ts +24 -0
  35. package/dist/agent/aws/cli.d.ts.map +1 -0
  36. package/dist/agent/aws/cli.js +89 -0
  37. package/dist/agent/aws/cli.js.map +1 -0
  38. package/dist/agent/aws/config.d.ts +27 -0
  39. package/dist/agent/aws/config.d.ts.map +1 -0
  40. package/dist/agent/aws/config.js +46 -0
  41. package/dist/agent/aws/config.js.map +1 -0
  42. package/dist/agent/aws/register.d.ts +23 -0
  43. package/dist/agent/aws/register.d.ts.map +1 -0
  44. package/dist/agent/aws/register.js +39 -0
  45. package/dist/agent/aws/register.js.map +1 -0
  46. package/dist/agent/aws/sso.d.ts +109 -0
  47. package/dist/agent/aws/sso.d.ts.map +1 -0
  48. package/dist/agent/aws/sso.js +421 -0
  49. package/dist/agent/aws/sso.js.map +1 -0
  50. package/dist/agent/aws/sts.d.ts +27 -0
  51. package/dist/agent/aws/sts.d.ts.map +1 -0
  52. package/dist/agent/aws/sts.js +135 -0
  53. package/dist/agent/aws/sts.js.map +1 -0
  54. package/dist/agent/blob/hosting.d.ts +4 -0
  55. package/dist/agent/blob/hosting.d.ts.map +1 -0
  56. package/dist/agent/blob/hosting.js +20 -0
  57. package/dist/agent/blob/hosting.js.map +1 -0
  58. package/dist/agent/browser/config.d.ts +24 -0
  59. package/dist/agent/browser/config.d.ts.map +1 -0
  60. package/dist/agent/browser/config.js +50 -0
  61. package/dist/agent/browser/config.js.map +1 -0
  62. package/dist/agent/browser/register.d.ts +7 -0
  63. package/dist/agent/browser/register.d.ts.map +1 -0
  64. package/dist/agent/browser/register.js +47 -0
  65. package/dist/agent/browser/register.js.map +1 -0
  66. package/dist/agent/browser/sandbox.d.ts +23 -0
  67. package/dist/agent/browser/sandbox.d.ts.map +1 -0
  68. package/dist/agent/browser/sandbox.js +27 -0
  69. package/dist/agent/browser/sandbox.js.map +1 -0
  70. package/dist/agent/contributions.d.ts +16 -0
  71. package/dist/agent/contributions.d.ts.map +1 -0
  72. package/dist/agent/contributions.js +11 -0
  73. package/dist/agent/contributions.js.map +1 -0
  74. package/dist/agent/directory/config.d.ts +39 -0
  75. package/dist/agent/directory/config.d.ts.map +1 -0
  76. package/dist/agent/directory/config.js +101 -0
  77. package/dist/agent/directory/config.js.map +1 -0
  78. package/dist/agent/directory/okta.d.ts +19 -0
  79. package/dist/agent/directory/okta.d.ts.map +1 -0
  80. package/dist/agent/directory/okta.js +178 -0
  81. package/dist/agent/directory/okta.js.map +1 -0
  82. package/dist/agent/directory/register.d.ts +6 -0
  83. package/dist/agent/directory/register.d.ts.map +1 -0
  84. package/dist/agent/directory/register.js +16 -0
  85. package/dist/agent/directory/register.js.map +1 -0
  86. package/dist/agent/instrumentation.d.ts +5 -0
  87. package/dist/agent/instrumentation.d.ts.map +1 -0
  88. package/dist/agent/instrumentation.js +39 -0
  89. package/dist/agent/instrumentation.js.map +1 -0
  90. package/dist/agent/model/approval-judge.d.ts +15 -0
  91. package/dist/agent/model/approval-judge.d.ts.map +1 -0
  92. package/dist/agent/model/approval-judge.js +46 -0
  93. package/dist/agent/model/approval-judge.js.map +1 -0
  94. package/dist/agent/model/dream-judge.d.ts +40 -0
  95. package/dist/agent/model/dream-judge.d.ts.map +1 -0
  96. package/dist/agent/model/dream-judge.js +80 -0
  97. package/dist/agent/model/dream-judge.js.map +1 -0
  98. package/dist/agent/model/gateway-vision.d.ts +53 -0
  99. package/dist/agent/model/gateway-vision.d.ts.map +1 -0
  100. package/dist/agent/model/gateway-vision.js +129 -0
  101. package/dist/agent/model/gateway-vision.js.map +1 -0
  102. package/dist/agent/model/gateway.d.ts +30 -0
  103. package/dist/agent/model/gateway.d.ts.map +1 -0
  104. package/dist/agent/model/gateway.js +55 -0
  105. package/dist/agent/model/gateway.js.map +1 -0
  106. package/dist/agent/oe-oauth/config.d.ts +69 -0
  107. package/dist/agent/oe-oauth/config.d.ts.map +1 -0
  108. package/dist/agent/oe-oauth/config.js +182 -0
  109. package/dist/agent/oe-oauth/config.js.map +1 -0
  110. package/dist/agent/oe-oauth/errors.d.ts +63 -0
  111. package/dist/agent/oe-oauth/errors.d.ts.map +1 -0
  112. package/dist/agent/oe-oauth/errors.js +73 -0
  113. package/dist/agent/oe-oauth/errors.js.map +1 -0
  114. package/dist/agent/oe-oauth/oauth-client.d.ts +124 -0
  115. package/dist/agent/oe-oauth/oauth-client.d.ts.map +1 -0
  116. package/dist/agent/oe-oauth/oauth-client.js +262 -0
  117. package/dist/agent/oe-oauth/oauth-client.js.map +1 -0
  118. package/dist/agent/oe-oauth/pkce.d.ts +8 -0
  119. package/dist/agent/oe-oauth/pkce.d.ts.map +1 -0
  120. package/dist/agent/oe-oauth/pkce.js +18 -0
  121. package/dist/agent/oe-oauth/pkce.js.map +1 -0
  122. package/dist/agent/oe-oauth/register.d.ts +17 -0
  123. package/dist/agent/oe-oauth/register.d.ts.map +1 -0
  124. package/dist/agent/oe-oauth/register.js +24 -0
  125. package/dist/agent/oe-oauth/register.js.map +1 -0
  126. package/dist/agent/oe-oauth/token-vault.d.ts +107 -0
  127. package/dist/agent/oe-oauth/token-vault.d.ts.map +1 -0
  128. package/dist/agent/oe-oauth/token-vault.js +498 -0
  129. package/dist/agent/oe-oauth/token-vault.js.map +1 -0
  130. package/dist/agent/oe-oauth/user-auth-flow.d.ts +10 -0
  131. package/dist/agent/oe-oauth/user-auth-flow.d.ts.map +1 -0
  132. package/dist/agent/oe-oauth/user-auth-flow.js +66 -0
  133. package/dist/agent/oe-oauth/user-auth-flow.js.map +1 -0
  134. package/dist/agent/postgres/neon.d.ts +29 -0
  135. package/dist/agent/postgres/neon.d.ts.map +1 -0
  136. package/dist/agent/postgres/neon.js +76 -0
  137. package/dist/agent/postgres/neon.js.map +1 -0
  138. package/dist/agent/sandbox/backend-stop.d.ts +98 -0
  139. package/dist/agent/sandbox/backend-stop.d.ts.map +1 -0
  140. package/dist/agent/sandbox/backend-stop.js +188 -0
  141. package/dist/agent/sandbox/backend-stop.js.map +1 -0
  142. package/dist/agent/sandbox/created-sandbox-registry.d.ts +15 -0
  143. package/dist/agent/sandbox/created-sandbox-registry.d.ts.map +1 -0
  144. package/dist/agent/sandbox/created-sandbox-registry.js +26 -0
  145. package/dist/agent/sandbox/created-sandbox-registry.js.map +1 -0
  146. package/dist/agent/sandbox/extend-workspace-time.d.ts +31 -0
  147. package/dist/agent/sandbox/extend-workspace-time.d.ts.map +1 -0
  148. package/dist/agent/sandbox/extend-workspace-time.js +63 -0
  149. package/dist/agent/sandbox/extend-workspace-time.js.map +1 -0
  150. package/dist/agent/sandbox/vercel-lifecycle.d.ts +38 -0
  151. package/dist/agent/sandbox/vercel-lifecycle.d.ts.map +1 -0
  152. package/dist/agent/sandbox/vercel-lifecycle.js +244 -0
  153. package/dist/agent/sandbox/vercel-lifecycle.js.map +1 -0
  154. package/package.json +204 -0
  155. package/tsconfig.build.json +22 -0
  156. package/tsconfig.json +22 -0
@@ -0,0 +1,31 @@
1
+ /** Per-call cap on the extension, in minutes — the `sandbox.extendMaxMinutes` setting
2
+ * (OPE-371), with `sandbox.extendMaxMinutes` as its declared ops override. */
3
+ export declare function maxExtendMinutes(): number;
4
+ /** Injected SDK surface, so the logic is testable without Vercel credentials. */
5
+ export interface ExtendDeps {
6
+ list(sessionId: string): Promise<Array<{
7
+ name: string;
8
+ status: string;
9
+ }>>;
10
+ extend(name: string, ms: number): Promise<void>;
11
+ }
12
+ /**
13
+ * Extend every RUNNING sandbox tagged with this session by `minutes` (clamped to the
14
+ * cap). A stopped/absent sandbox needs no extension — its next boot gets a full fresh
15
+ * window — so that case reports rather than errors.
16
+ */
17
+ export declare function extendSessionSandboxes(sessionId: string, minutes: number, deps?: ExtendDeps): Promise<{
18
+ extended: string[];
19
+ clampedTo: number;
20
+ }>;
21
+ declare const _default: import("eve/tools").ToolDefinition<{
22
+ minutes: number;
23
+ reason?: string | undefined;
24
+ }, string> & {
25
+ execute(input: {
26
+ minutes: number;
27
+ reason?: string | undefined;
28
+ }, ctx: import("eve/tools").ToolContext): Promise<string>;
29
+ };
30
+ export default _default;
31
+ //# sourceMappingURL=extend-workspace-time.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extend-workspace-time.d.ts","sourceRoot":"","sources":["../../../agent/sandbox/extend-workspace-time.ts"],"names":[],"mappings":"AAUA;+EAC+E;AAC/E,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC1E,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACjD;AAWD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,IAAI,GAAE,UAAoB,GACzB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CASpD"}
@@ -0,0 +1,63 @@
1
+ // `extend_workspace_time` — lengthen the sandbox session's FIXED fuse before a long command. It extends
2
+ // BLIND (no remaining-time reading exists), is capped and audited, and plan ceilings still apply upstream.
3
+ import { defineTool } from "eve/tools";
4
+ import { z } from "zod";
5
+ import { Sandbox } from "@vercel/sandbox";
6
+ import { auditToolAction, getSettings } from "@open-everywhere/core/agent/adapter-api.js";
7
+ import { shouldStop } from "./vercel-lifecycle.js";
8
+ import { vercelStopper } from "./backend-stop.js";
9
+ /** Per-call cap on the extension, in minutes — the `sandbox.extendMaxMinutes` setting
10
+ * (OPE-371), with `sandbox.extendMaxMinutes` as its declared ops override. */
11
+ export function maxExtendMinutes() {
12
+ return getSettings().sandbox.extendMaxMinutes;
13
+ }
14
+ // The list is `vercelStopper.list` — the same tag-index-plus-id-record lookup the stop hook uses — rather
15
+ // than a second, independent `Sandbox.list({tags})` call.
16
+ const sdkDeps = {
17
+ list: vercelStopper.list,
18
+ async extend(name, ms) {
19
+ await (await Sandbox.get({ name })).extendTimeout(ms);
20
+ },
21
+ };
22
+ /**
23
+ * Extend every RUNNING sandbox tagged with this session by `minutes` (clamped to the
24
+ * cap). A stopped/absent sandbox needs no extension — its next boot gets a full fresh
25
+ * window — so that case reports rather than errors.
26
+ */
27
+ export async function extendSessionSandboxes(sessionId, minutes, deps = sdkDeps) {
28
+ const clampedTo = Math.min(Math.max(1, Math.floor(minutes)), maxExtendMinutes());
29
+ const extended = [];
30
+ for (const s of await deps.list(sessionId)) {
31
+ if (!shouldStop(s.status))
32
+ continue; // same "is the VM up" predicate as the stop hook
33
+ await deps.extend(s.name, clampedTo * 60_000);
34
+ extended.push(s.name);
35
+ }
36
+ return { extended, clampedTo };
37
+ }
38
+ export default defineTool({
39
+ description: "Extend your workspace VM's lifetime by N minutes. Call this BEFORE starting a long-running command " +
40
+ "(a big install, build, or a test run you expect to take more than ~10 minutes): the workspace has a " +
41
+ "fixed time window and a command still running when it expires is killed. There is no visible countdown, " +
42
+ "so extend by roughly the time the upcoming work needs. If no VM is currently running, nothing needs " +
43
+ "extending — your next command boots a fresh one with a full window.",
44
+ inputSchema: z.object({
45
+ minutes: z.number().int().min(1).describe("How many extra minutes the upcoming work needs."),
46
+ reason: z.string().optional().describe("What the time is for (goes to the audit log)."),
47
+ }),
48
+ async execute(input, ctx) {
49
+ const { extended, clampedTo } = await extendSessionSandboxes(ctx.session.id, input.minutes);
50
+ await auditToolAction(ctx, "sandbox.extend", {
51
+ minutes: clampedTo,
52
+ requested: input.minutes,
53
+ extended,
54
+ ...(input.reason ? { reason: input.reason } : {}),
55
+ });
56
+ if (extended.length === 0) {
57
+ return "No workspace VM is currently running — nothing to extend. Your next command boots a fresh session with a full time window, so just proceed.";
58
+ }
59
+ const clampNote = clampedTo !== input.minutes ? ` (requested ${input.minutes}, capped at ${clampedTo} by sandbox.extendMaxMinutes)` : "";
60
+ return `Extended the workspace lifetime by ${clampedTo} minutes${clampNote}. Start the long-running work now.`;
61
+ },
62
+ });
63
+ //# sourceMappingURL=extend-workspace-time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extend-workspace-time.js","s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AAC,CAAC,CAAC,eAAe,KAAK,CAAC,OAAO,eAAe,SAAS,+BAA+B,CAAC,CAAC,CAAC,EAAE,CAAC;QACzI,OAAO,sCAAsC,SAAS,WAAW,SAAS,oCAAoC,CAAC;IACjH,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { type HookContext } from "eve/hooks";
2
+ import { shouldStop, type SandboxListing, type SandboxStopper } from "./backend-stop.js";
3
+ export { shouldStop, type SandboxListing, type SandboxStopper };
4
+ /** On by default (the `sandbox.stopAfterTurn` setting, OPE-371); declare
5
+ * `sandbox: { stopAfterTurn: false }` in `agent/settings.ts`, or set the
6
+ * `sandbox.stopAfterTurn` ops override, to keep sandboxes alive between turns. */
7
+ export declare function stopAfterTurnEnabled(): boolean;
8
+ /** One sandbox this sweep actually stopped, with its honestly-observed runtime window. */
9
+ export interface StoppedSandbox {
10
+ readonly name: string;
11
+ readonly sandboxSeconds: number;
12
+ }
13
+ /**
14
+ * Stop every running sandbox tagged with this session. Fail-soft per sandbox — a straggler falls back to the
15
+ * timeout fuse. The window is measured from `createdAt`, which does NOT advance across a stop and auto-resume,
16
+ * so this reports the CUMULATIVE window and the billing below takes the delta.
17
+ */
18
+ export declare function stopSessionSandboxes(sessionId: string, stopper?: SandboxStopper, now?: () => number): Promise<StoppedSandbox[]>;
19
+ /**
20
+ * The second half of the child guard: hand the shared sandbox back to the parent, so the parent's own sweep
21
+ * finds it. A backend that never re-tags answers an empty result — a correct outcome, not a failure.
22
+ */
23
+ export declare function restoreParentSandboxTag(ctx: HookContext, stopper: SandboxStopper): Promise<string[]>;
24
+ /** Test seam: forget that the ownership line was already logged. */
25
+ export declare function resetStopOwnershipLogForTest(): void;
26
+ /**
27
+ * WHICH delegated background tasks this session believes still hold its sandbox. Non-empty ⇒ this turn end
28
+ * must not stop the VM. A read, never a write, and fail-soft to EMPTY.
29
+ */
30
+ export declare function liveDelegatedTasksHoldingSandbox(): readonly string[];
31
+ /**
32
+ * Record each stopped sandbox's runtime in BOTH spend stores, best-effort. ORDER IS LOAD-BEARING: the ledger
33
+ * row goes FIRST and the watermark only once it succeeds, so a failure re-bills instead of under-billing.
34
+ */
35
+ export declare function recordSandboxUsage(ctx: HookContext, stopped: StoppedSandbox[]): Promise<void>;
36
+ declare const _default: import("eve/hooks").HookDefinition<"session.completed" | "session.failed" | "turn.completed" | "turn.failed">;
37
+ export default _default;
38
+ //# sourceMappingURL=vercel-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-lifecycle.d.ts","sourceRoot":"","sources":["../../../agent/sandbox/vercel-lifecycle.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAyB,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKhH,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,CAAC;AAMhE;;mFAEmF;AACnF,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,0FAA0F;AAC1F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,cAAwC,EACjD,GAAG,GAAE,MAAM,MAAiB,GAC3B,OAAO,CAAC,cAAc,EAAE,CAAC,CAc3B;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAc1G;AAWD,oEAAoE;AACpE,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,IAAI,SAAS,MAAM,EAAE,CAMpE;AAwCD;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgGnG"}
@@ -0,0 +1,244 @@
1
+ // Stop-after-turn sandbox lifecycle — this file owns the DECISION, backend-stop.ts the mechanics. It exists
2
+ // because a session VM is billed for its whole idle tail; every failure is fail-soft to the `timeout` fuse.
3
+ import { defineHook } from "eve/hooks";
4
+ import { bindFrom, domainKeyOf, resolvePartition, appendUsageEvent, usageForSession, recordSpend, periodOf, estimateSandboxCostUsd, routineIdOf, turnSurfaceMode, getSettings, isSubagentChildContext, liveTaskIds, subagentParentSessionId } from "@open-everywhere/core/agent/adapter-api.js";
5
+ import { resolveSandboxStopper, shouldStop } from "./backend-stop.js";
6
+ // Re-exported so the one "is this sandbox up?" predicate and the one listing shape stay
7
+ // single-homed in backend-stop.ts while their existing import sites keep working
8
+ // (extend-workspace-time.ts, the lifecycle tests).
9
+ export { shouldStop };
10
+ function log(msg) {
11
+ console.log(`[open-everywhere:sandbox-lifecycle] ${msg}`);
12
+ }
13
+ /** On by default (the `sandbox.stopAfterTurn` setting, OPE-371); declare
14
+ * `sandbox: { stopAfterTurn: false }` in `agent/settings.ts`, or set the
15
+ * `sandbox.stopAfterTurn` ops override, to keep sandboxes alive between turns. */
16
+ export function stopAfterTurnEnabled() {
17
+ return getSettings().sandbox.stopAfterTurn;
18
+ }
19
+ /**
20
+ * Stop every running sandbox tagged with this session. Fail-soft per sandbox — a straggler falls back to the
21
+ * timeout fuse. The window is measured from `createdAt`, which does NOT advance across a stop and auto-resume,
22
+ * so this reports the CUMULATIVE window and the billing below takes the delta.
23
+ */
24
+ export async function stopSessionSandboxes(sessionId, stopper = resolveSandboxStopper(), now = Date.now) {
25
+ const stopped = [];
26
+ const sandboxes = await stopper.list(sessionId);
27
+ for (const s of sandboxes) {
28
+ if (!shouldStop(s.status))
29
+ continue;
30
+ try {
31
+ await stopper.stop(s.name);
32
+ const sandboxSeconds = Math.max(0, (now() - s.createdAt) / 1000);
33
+ stopped.push({ name: s.name, sandboxSeconds });
34
+ }
35
+ catch (err) {
36
+ log(`stop of "${s.name}" failed (falls back to the timeout fuse): ${String(err)}`);
37
+ }
38
+ }
39
+ return stopped;
40
+ }
41
+ /**
42
+ * The second half of the child guard: hand the shared sandbox back to the parent, so the parent's own sweep
43
+ * finds it. A backend that never re-tags answers an empty result — a correct outcome, not a failure.
44
+ */
45
+ export async function restoreParentSandboxTag(ctx, stopper) {
46
+ const parentSessionId = subagentParentSessionId(ctx);
47
+ // No typed linkage (eve does not expose `session.parent` in every child shape) ⇒ nothing to
48
+ // restore the tag TO. Skipping the stop is still correct and is the half that matters.
49
+ if (parentSessionId === undefined)
50
+ return [];
51
+ const restored = [];
52
+ for (const s of await stopper.list(ctx.session.id)) {
53
+ try {
54
+ if (await stopper.retag(s.name, parentSessionId))
55
+ restored.push(s.name);
56
+ }
57
+ catch (err) {
58
+ log(`re-tag of "${s.name}" back to parent session failed (the parent reclaims it on its next sandbox use): ${String(err)}`);
59
+ }
60
+ }
61
+ return restored;
62
+ }
63
+ /** Name the owning backend once per process, at the first turn end. An operator must be able to
64
+ * tell from the deployment which backend stops the sandbox — or that none does. */
65
+ let ownershipLogged = false;
66
+ function logStopOwnershipOnce(stopper) {
67
+ if (ownershipLogged)
68
+ return;
69
+ ownershipLogged = true;
70
+ log(stopper.ownership);
71
+ }
72
+ /** Test seam: forget that the ownership line was already logged. */
73
+ export function resetStopOwnershipLogForTest() {
74
+ ownershipLogged = false;
75
+ }
76
+ /**
77
+ * WHICH delegated background tasks this session believes still hold its sandbox. Non-empty ⇒ this turn end
78
+ * must not stop the VM. A read, never a write, and fail-soft to EMPTY.
79
+ */
80
+ export function liveDelegatedTasksHoldingSandbox() {
81
+ try {
82
+ return liveTaskIds();
83
+ }
84
+ catch {
85
+ return [];
86
+ }
87
+ }
88
+ async function onTurnEnd(ctx, outcome) {
89
+ if (!stopAfterTurnEnabled())
90
+ return;
91
+ try {
92
+ const stopper = resolveSandboxStopper();
93
+ logStopOwnershipOnce(stopper);
94
+ // 🔴 OPE-447 — a delegated child shares the PARENT's sandbox and must not stop it.
95
+ if (isSubagentChildContext(ctx)) {
96
+ const restored = await restoreParentSandboxTag(ctx, stopper);
97
+ log(`turn.${outcome}: SKIPPED the stop — this is an eve subagent child and the parent owns the shared sandbox` +
98
+ (restored.length > 0 ? `; handed ${restored.join(", ")} back to the parent session` : ""));
99
+ return;
100
+ }
101
+ // 🔴 OPE-595 — a live BACKGROUND child holds this session's VM after this turn ends.
102
+ // See the file header for the measurement and for why the skip cannot leak a VM.
103
+ const holding = liveDelegatedTasksHoldingSandbox();
104
+ if (holding.length > 0) {
105
+ log(`turn.${outcome}: SKIPPED the stop — ${holding.length} delegated background task(s) still hold this session's sandbox ` +
106
+ `[${holding.join(", ")}]; the next turn end that finds none sweeps it`);
107
+ return;
108
+ }
109
+ const stopped = await stopSessionSandboxes(ctx.session.id, stopper);
110
+ if (stopped.length > 0) {
111
+ log(`turn.${outcome}: stopped ${stopped.map((s) => s.name).join(", ")} (auto-snapshot; next turn auto-resumes)`);
112
+ // Only a backend that bills runtime by wall clock gets a spend row. Pricing a self-hosted
113
+ // container at Vercel's GB-hour rate would invent a charge that the USD caps then enforce.
114
+ if (stopper.metered)
115
+ await recordSandboxUsage(ctx, stopped);
116
+ }
117
+ }
118
+ catch (err) {
119
+ // Listing failed (no credentials locally, transient API error, …) — the sandbox
120
+ // just idles out its timeout fuse, exactly the pre-hook behaviour.
121
+ log(`turn.${outcome}: sandbox stop skipped: ${String(err)}`);
122
+ }
123
+ }
124
+ /**
125
+ * Record each stopped sandbox's runtime in BOTH spend stores, best-effort. ORDER IS LOAD-BEARING: the ledger
126
+ * row goes FIRST and the watermark only once it succeeds, so a failure re-bills instead of under-billing.
127
+ */
128
+ export async function recordSandboxUsage(ctx, stopped) {
129
+ try {
130
+ const p = resolvePartition(ctx);
131
+ // ATTRIBUTION (OPE-275) — the SAME derivations core's hooks/spend.ts stamps on the session's
132
+ // model rows: the ATTRIBUTED principal (a routine fire binds as its attested creator, a
133
+ // delegated child carries its parent's) and the dispatcher's routine marker. Before this the
134
+ // sandbox row wrote both as '' — so a person's delegated sandbox dollars were invisible to
135
+ // their `perUser` budget (surface/workspace caps caught them; the person axis did not), and a
136
+ // routine's reported cost excluded exactly its compute. Both reads are fail-soft: an unusual
137
+ // ctx degrades to an unattributed row, which is what the row always was.
138
+ const principalId = bindFrom(ctx).principalId;
139
+ const routineId = routineIdOf(ctx);
140
+ // OPE-1862 — the conversation's own mode, stamped on both rows below exactly as core's
141
+ // hooks/spend.ts stamps it on a model call. Without it a sandbox row is UNCLASSIFIED, and a
142
+ // report then masks the surface key it names rather than publish one it cannot classify.
143
+ const surfaceMode = turnSurfaceMode(ctx);
144
+ // The DELTA watermark (finding 4): the seconds already billed for each sandbox this session
145
+ // are the SUM of its prior "sandbox" usage_events deltas — the durable per-session stamp that
146
+ // survives a fresh serverless instance per turn. Read once; a failure leaves it empty, so the
147
+ // full cumulative is billed (today's overestimate), never dropped — the safe direction.
148
+ const priorBilled = new Map();
149
+ try {
150
+ for (const e of await usageForSession(p.org, ctx.session.id)) {
151
+ if (e.kind !== "sandbox")
152
+ continue;
153
+ const name = e.detail?.sandboxName;
154
+ if (typeof name !== "string")
155
+ continue;
156
+ const secs = typeof e.detail?.sandboxSeconds === "number" ? e.detail.sandboxSeconds : 0;
157
+ priorBilled.set(name, (priorBilled.get(name) ?? 0) + secs);
158
+ }
159
+ }
160
+ catch (err) {
161
+ log(`prior sandbox usage read skipped (billing the full window): ${String(err)}`);
162
+ }
163
+ // Dedupe by name: if `stopped` ever carries the same sandbox twice in one call (a
164
+ // list()/stop() quirk upstream), processing both entries would read the SAME
165
+ // priorBilled value for each and double-bill the delta. Keep the first occurrence.
166
+ const seenNames = new Set();
167
+ const dedupedStopped = stopped.filter((s) => {
168
+ if (seenNames.has(s.name))
169
+ return false;
170
+ seenNames.add(s.name);
171
+ return true;
172
+ });
173
+ for (const s of dedupedStopped) {
174
+ // `s.sandboxSeconds` is the CUMULATIVE window since createdAt; bill only the increment
175
+ // since this sandbox's last stop (clamped ≥ 0: a sandbox recreated mid-session, finding 5,
176
+ // resets createdAt below the prior sum → 0 for that window, never negative).
177
+ const billedSeconds = Math.max(0, Math.round(s.sandboxSeconds) - (priorBilled.get(s.name) ?? 0));
178
+ // THE LEDGER WRITE FIRST (see the doc comment above for why the order flipped).
179
+ try {
180
+ await recordSpend(p, {
181
+ period: periodOf(new Date().toISOString()),
182
+ usage: {},
183
+ principalId,
184
+ routineId,
185
+ model: "",
186
+ ...(surfaceMode !== undefined ? { surfaceMode } : {}),
187
+ // Explicit usdMicros: runtime spend has no (model, tokens) key that could
188
+ // express it — this is the case that forced write-time pricing (OPE-265/266).
189
+ usdMicros: Math.round(estimateSandboxCostUsd(billedSeconds) * 1_000_000),
190
+ });
191
+ }
192
+ catch (err) {
193
+ log(`sandbox spend-ledger record skipped for "${s.name}" (watermark NOT advanced — this window re-bills next stop): ${String(err)}`);
194
+ continue;
195
+ }
196
+ // The watermark: only reached once the ledger write above actually landed, so a
197
+ // future priorBilled sum never marks seconds "billed" that no ledger row backs.
198
+ try {
199
+ await appendUsageEvent({
200
+ org: p.org,
201
+ // SPEND grain (domainKeyOf), matching core's hooks/spend.ts: a Discord thread's
202
+ // sandbox seconds bill against its PARENT channel's scope (item 22); the domain
203
+ // key IS the surfaceKey everywhere else.
204
+ surfaceKey: domainKeyOf(p),
205
+ sessionId: ctx.session.id,
206
+ kind: "sandbox",
207
+ ...(surfaceMode !== undefined ? { surfaceMode } : {}),
208
+ principalId,
209
+ ...(routineId !== undefined ? { routineId } : {}),
210
+ inputTokens: 0,
211
+ outputTokens: 0,
212
+ cacheReadTokens: 0,
213
+ cacheWriteTokens: 0,
214
+ // The DELTA (not the cumulative) — so the next stop's watermark sum telescopes to the
215
+ // true lifetime, and a session_cost view that SUMS these rows is correct rather than
216
+ // over-counting (which the old cumulative-per-row write silently did).
217
+ detail: { sandboxSeconds: billedSeconds, sandboxName: s.name },
218
+ });
219
+ }
220
+ catch (err) {
221
+ // The ledger row above already landed — only the watermark/forensics row is missing.
222
+ // A future stop's priorBilled sum under-counts by this delta, so it re-bills this
223
+ // window too: a double-bill, but over-billing is this file's chosen safe direction.
224
+ log(`sandbox usage-event append skipped for "${s.name}" (watermark not advanced; a future stop may re-bill this window): ${String(err)}`);
225
+ }
226
+ }
227
+ }
228
+ catch (err) {
229
+ log(`sandbox usage records skipped (no resolvable partition): ${String(err)}`);
230
+ }
231
+ }
232
+ export default defineHook({
233
+ events: {
234
+ // Turn boundaries are the signal: the reply has been sent, nothing is using the VM.
235
+ "turn.completed": async (_event, ctx) => onTurnEnd(ctx, "completed"),
236
+ "turn.failed": async (_event, ctx) => onTurnEnd(ctx, "failed"),
237
+ // Completing sessions (routines, one-shots) end with session.* — a final sweep. If
238
+ // another session-end hook (memory persist) touches the sandbox after us it simply
239
+ // auto-resumes and the leftover falls back to the fuse: no correctness impact.
240
+ "session.completed": async (_event, ctx) => onTurnEnd(ctx, "session-completed"),
241
+ "session.failed": async (_event, ctx) => onTurnEnd(ctx, "session-failed"),
242
+ },
243
+ });
244
+ //# sourceMappingURL=vercel-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vercel-lifecycle.js","sourceRoot":"","sources":["../../../agent/sandbox/vercel-lifecycle.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,4GAA4G;AAE5G,OAAO,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,sBAAsB,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,sBAAsB,EAAE,WAAW,EAAE,uBAAuB,EAAwB,MAAM,4CAA4C,CAAC;AACtT,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAA4C,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AC;QACb,GAAG,CAAC,4DAA4D,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED,eAAe,UAAU,CAAC;IACxB,MAAM,EAAE;QACN,oFAAoF;QACpF,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,WAAW,CAAC;QACpE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;QAC9D,mFAAmF;QACnF,mFAAmF;QACnF,+EAA+E;QAC/E,mBAAmB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,mBAAmB,CAAC;QAC/E,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,gBAAgB,CAAC;KAC1E;CACF,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,204 @@
1
+ {
2
+ "name": "@open-everywhere/adapters",
3
+ "version": "0.1.0",
4
+ "description": "Open Everywhere adapters — the reference Vercel-hosted backends: AI Gateway models and pricing, Sandbox, Blob, Neon, OpenTelemetry, AWS and Okta.",
5
+ "keywords": [
6
+ "agent",
7
+ "eve",
8
+ "vercel",
9
+ "neon",
10
+ "postgres",
11
+ "opentelemetry",
12
+ "sandbox",
13
+ "blob",
14
+ "okta",
15
+ "aws"
16
+ ],
17
+ "license": "Apache-2.0",
18
+ "type": "module",
19
+ "homepage": "https://github.com/open-everywhere/open-everywhere/tree/main/packages/adapters",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/open-everywhere/open-everywhere.git",
23
+ "directory": "packages/adapters"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/open-everywhere/open-everywhere/issues"
27
+ },
28
+ "engines": {
29
+ "node": ">=24"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "files": [
35
+ "agent",
36
+ "dist",
37
+ "tsconfig.json",
38
+ "tsconfig.build.json",
39
+ "LICENSE",
40
+ "NOTICE"
41
+ ],
42
+ "exports": {
43
+ "./package.json": "./package.json",
44
+ "./agent/aws/cli.js": {
45
+ "types": "./dist/agent/aws/cli.d.ts",
46
+ "default": "./dist/agent/aws/cli.js"
47
+ },
48
+ "./agent/aws/config.js": {
49
+ "types": "./dist/agent/aws/config.d.ts",
50
+ "default": "./dist/agent/aws/config.js"
51
+ },
52
+ "./agent/aws/register.js": {
53
+ "types": "./dist/agent/aws/register.d.ts",
54
+ "default": "./dist/agent/aws/register.js"
55
+ },
56
+ "./agent/aws/sso.js": {
57
+ "types": "./dist/agent/aws/sso.d.ts",
58
+ "default": "./dist/agent/aws/sso.js"
59
+ },
60
+ "./agent/aws/sts.js": {
61
+ "types": "./dist/agent/aws/sts.d.ts",
62
+ "default": "./dist/agent/aws/sts.js"
63
+ },
64
+ "./agent/blob/hosting.js": {
65
+ "types": "./dist/agent/blob/hosting.d.ts",
66
+ "default": "./dist/agent/blob/hosting.js"
67
+ },
68
+ "./agent/browser/config.js": {
69
+ "types": "./dist/agent/browser/config.d.ts",
70
+ "default": "./dist/agent/browser/config.js"
71
+ },
72
+ "./agent/browser/register.js": {
73
+ "types": "./dist/agent/browser/register.d.ts",
74
+ "default": "./dist/agent/browser/register.js"
75
+ },
76
+ "./agent/browser/sandbox.js": {
77
+ "types": "./dist/agent/browser/sandbox.d.ts",
78
+ "default": "./dist/agent/browser/sandbox.js"
79
+ },
80
+ "./agent/contributions.js": {
81
+ "types": "./dist/agent/contributions.d.ts",
82
+ "default": "./dist/agent/contributions.js"
83
+ },
84
+ "./agent/directory/config.js": {
85
+ "types": "./dist/agent/directory/config.d.ts",
86
+ "default": "./dist/agent/directory/config.js"
87
+ },
88
+ "./agent/directory/okta.js": {
89
+ "types": "./dist/agent/directory/okta.d.ts",
90
+ "default": "./dist/agent/directory/okta.js"
91
+ },
92
+ "./agent/directory/register.js": {
93
+ "types": "./dist/agent/directory/register.d.ts",
94
+ "default": "./dist/agent/directory/register.js"
95
+ },
96
+ "./agent/instrumentation.js": {
97
+ "types": "./dist/agent/instrumentation.d.ts",
98
+ "default": "./dist/agent/instrumentation.js"
99
+ },
100
+ "./agent/model/approval-judge.js": {
101
+ "types": "./dist/agent/model/approval-judge.d.ts",
102
+ "default": "./dist/agent/model/approval-judge.js"
103
+ },
104
+ "./agent/model/dream-judge.js": {
105
+ "types": "./dist/agent/model/dream-judge.d.ts",
106
+ "default": "./dist/agent/model/dream-judge.js"
107
+ },
108
+ "./agent/model/gateway-vision.js": {
109
+ "types": "./dist/agent/model/gateway-vision.d.ts",
110
+ "default": "./dist/agent/model/gateway-vision.js"
111
+ },
112
+ "./agent/model/gateway.js": {
113
+ "types": "./dist/agent/model/gateway.d.ts",
114
+ "default": "./dist/agent/model/gateway.js"
115
+ },
116
+ "./agent/oe-oauth/config.js": {
117
+ "types": "./dist/agent/oe-oauth/config.d.ts",
118
+ "default": "./dist/agent/oe-oauth/config.js"
119
+ },
120
+ "./agent/oe-oauth/errors.js": {
121
+ "types": "./dist/agent/oe-oauth/errors.d.ts",
122
+ "default": "./dist/agent/oe-oauth/errors.js"
123
+ },
124
+ "./agent/oe-oauth/oauth-client.js": {
125
+ "types": "./dist/agent/oe-oauth/oauth-client.d.ts",
126
+ "default": "./dist/agent/oe-oauth/oauth-client.js"
127
+ },
128
+ "./agent/oe-oauth/pkce.js": {
129
+ "types": "./dist/agent/oe-oauth/pkce.d.ts",
130
+ "default": "./dist/agent/oe-oauth/pkce.js"
131
+ },
132
+ "./agent/oe-oauth/register.js": {
133
+ "types": "./dist/agent/oe-oauth/register.d.ts",
134
+ "default": "./dist/agent/oe-oauth/register.js"
135
+ },
136
+ "./agent/oe-oauth/token-vault.js": {
137
+ "types": "./dist/agent/oe-oauth/token-vault.d.ts",
138
+ "default": "./dist/agent/oe-oauth/token-vault.js"
139
+ },
140
+ "./agent/oe-oauth/user-auth-flow.js": {
141
+ "types": "./dist/agent/oe-oauth/user-auth-flow.d.ts",
142
+ "default": "./dist/agent/oe-oauth/user-auth-flow.js"
143
+ },
144
+ "./agent/postgres/neon.js": {
145
+ "types": "./dist/agent/postgres/neon.d.ts",
146
+ "default": "./dist/agent/postgres/neon.js"
147
+ },
148
+ "./agent/sandbox/backend-stop.js": {
149
+ "types": "./dist/agent/sandbox/backend-stop.d.ts",
150
+ "default": "./dist/agent/sandbox/backend-stop.js"
151
+ },
152
+ "./agent/sandbox/created-sandbox-registry.js": {
153
+ "types": "./dist/agent/sandbox/created-sandbox-registry.d.ts",
154
+ "default": "./dist/agent/sandbox/created-sandbox-registry.js"
155
+ },
156
+ "./agent/sandbox/extend-workspace-time.js": {
157
+ "types": "./dist/agent/sandbox/extend-workspace-time.d.ts",
158
+ "default": "./dist/agent/sandbox/extend-workspace-time.js"
159
+ },
160
+ "./agent/sandbox/vercel-lifecycle.js": {
161
+ "types": "./dist/agent/sandbox/vercel-lifecycle.d.ts",
162
+ "default": "./dist/agent/sandbox/vercel-lifecycle.js"
163
+ }
164
+ },
165
+ "scripts": {
166
+ "build": "tsc -p tsconfig.build.json",
167
+ "typecheck": "tsc --noEmit -p tsconfig.json",
168
+ "test": "npm run test:chain",
169
+ "test:chain": "npm run test:instrumentation && npm run test:sandbox-lifecycle && npm run test:sandbox-guard && npm run test:sandbox-extend && npm run test:model-gateway && npm run test:dream-judge-gateway && npm run test:approval-judge-gateway && npm run test:gateway-vision && npm run test:oe-oauth && npm run test:oe-oauth-static && npm run test:agent-browser && npm run test:neon-pool-error && npm run test:aws-adapter && npm run test:aws-sso && npm run test:okta-directory",
170
+ "test:aws-adapter": "tsx scripts/aws-adapter-test.ts",
171
+ "test:okta-directory": "tsx scripts/okta-directory-test.ts",
172
+ "test:aws-sso": "tsx scripts/aws-sso-test.ts",
173
+ "test:neon-pool-error": "tsx scripts/neon-pool-error-test.ts",
174
+ "test:agent-browser": "tsx scripts/agent-browser-test.ts",
175
+ "test:oe-oauth": "tsx scripts/oe-oauth-test.ts",
176
+ "test:oe-oauth-static": "tsx scripts/oe-oauth-static-client-test.ts",
177
+ "test:instrumentation": "tsx scripts/instrumentation-test.ts",
178
+ "test:sandbox-lifecycle": "tsx scripts/sandbox-lifecycle-test.ts",
179
+ "test:sandbox-guard": "tsx scripts/sandbox-live-guard-test.ts",
180
+ "test:sandbox-live": "tsx scripts/sandbox-live-test.ts",
181
+ "test:sandbox-extend": "tsx scripts/sandbox-extend-test.ts",
182
+ "test:model-gateway": "tsx scripts/model-gateway-test.ts",
183
+ "test:dream-judge-gateway": "tsx scripts/dream-judge-gateway-test.ts",
184
+ "test:approval-judge-gateway": "tsx scripts/approval-judge-gateway-test.ts",
185
+ "test:gateway-vision": "tsx scripts/gateway-vision-test.ts"
186
+ },
187
+ "dependencies": {
188
+ "@neondatabase/serverless": "^1.1.0",
189
+ "@open-everywhere/core": "0.1.0",
190
+ "@vercel/blob": "^2.6.1",
191
+ "@vercel/otel": "^2.1.3",
192
+ "@vercel/sandbox": "^3.2.1",
193
+ "ai": "^7.0.11"
194
+ },
195
+ "peerDependencies": {
196
+ "@agent-browser/eve": "0.32.4",
197
+ "eve": "0.54.3"
198
+ },
199
+ "devDependencies": {
200
+ "@types/node": "latest",
201
+ "tsx": "latest",
202
+ "typescript": "latest"
203
+ }
204
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ // PUBLISH BUILD (OPE-406). See packages/core/tsconfig.build.json for the full rationale: the
3
+ // sibling tsconfig.json stays noEmit (it is the typecheck gate and covers scripts/** too); this
4
+ // config emits ONLY the published surface (agent/**) into dist/, because a registry install
5
+ // cannot execute raw TypeScript and "eve build" evaluates the authored agent modules.
6
+ "extends": "./tsconfig.json",
7
+ "compilerOptions": {
8
+ "noEmit": false,
9
+ // Incremental: these run from every pre-hook (pretypecheck/pretest/prebuild), so a no-op
10
+ // rebuild has to be near-free or the gate chain pays a full tsc on every invocation.
11
+ "incremental": true,
12
+ // OUTSIDE outDir on purpose: a tsbuildinfo left in dist/ gets swept up by the files
13
+ // allowlist and PUBLISHED (caught by the tarball listing, 2026-08-12).
14
+ "tsBuildInfoFile": "./.tsbuildinfo",
15
+ "declaration": true,
16
+ "declarationMap": true,
17
+ "sourceMap": true,
18
+ "outDir": "dist",
19
+ "rootDir": "."
20
+ },
21
+ "include": ["agent/**/*.ts"]
22
+ }