@anhlp/alp-runtime 0.0.1-beta.4 → 0.0.1-beta.5

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 (67) hide show
  1. package/dist/acp-transport.js +5 -36
  2. package/dist/antigravity-transport.d.ts +17 -0
  3. package/dist/antigravity-transport.js +82 -58
  4. package/dist/assignment-results.d.ts +34 -0
  5. package/dist/assignment-results.js +94 -2
  6. package/dist/board-domain.js +2 -2
  7. package/dist/board.d.ts +6 -0
  8. package/dist/board.js +7 -0
  9. package/dist/catalog.d.ts +13 -0
  10. package/dist/catalog.js +9 -1
  11. package/dist/claude-transport.d.ts +7 -0
  12. package/dist/claude-transport.js +65 -6
  13. package/dist/compact.d.ts +29 -0
  14. package/dist/compact.js +49 -0
  15. package/dist/configure.d.ts +1 -1
  16. package/dist/configure.js +2 -2
  17. package/dist/contracts.d.ts +25 -1
  18. package/dist/index.d.ts +9 -2
  19. package/dist/index.js +30 -2
  20. package/dist/input-limits.d.ts +25 -0
  21. package/dist/input-limits.js +48 -0
  22. package/dist/language.d.ts +8 -0
  23. package/dist/language.js +20 -0
  24. package/dist/mcp-tools.d.ts +8 -0
  25. package/dist/mcp-tools.js +26 -0
  26. package/dist/model-catalog.d.ts +76 -0
  27. package/dist/model-catalog.js +193 -0
  28. package/dist/model-probes.d.ts +7 -0
  29. package/dist/model-probes.js +69 -0
  30. package/dist/providers.js +2 -0
  31. package/dist/resolve.d.ts +1 -0
  32. package/dist/resolve.js +3 -1
  33. package/dist/runtime.d.ts +3 -1
  34. package/dist/runtime.js +605 -45
  35. package/dist/session-config.d.ts +174 -0
  36. package/dist/session-config.js +9 -9
  37. package/dist/session-state.d.ts +23 -1
  38. package/dist/tools.d.ts +82 -0
  39. package/dist/tools.js +53 -5
  40. package/dist/transport.js +3 -1
  41. package/dist/workspace.d.ts +11 -4
  42. package/dist/workspace.js +29 -11
  43. package/package.json +3 -3
  44. package/src/acp-transport.ts +7 -37
  45. package/src/antigravity-transport.ts +95 -53
  46. package/src/assignment-results.ts +85 -3
  47. package/src/board-domain.ts +2 -2
  48. package/src/board.ts +7 -0
  49. package/src/catalog.ts +10 -1
  50. package/src/claude-transport.ts +71 -6
  51. package/src/compact.ts +62 -0
  52. package/src/configure.ts +3 -3
  53. package/src/contracts.ts +22 -1
  54. package/src/index.ts +9 -2
  55. package/src/input-limits.ts +65 -0
  56. package/src/language.ts +18 -0
  57. package/src/mcp-tools.ts +33 -0
  58. package/src/model-catalog.ts +166 -0
  59. package/src/model-probes.ts +58 -0
  60. package/src/providers.ts +3 -0
  61. package/src/resolve.ts +4 -2
  62. package/src/runtime.ts +650 -46
  63. package/src/session-config.ts +8 -8
  64. package/src/session-state.ts +15 -1
  65. package/src/tools.ts +53 -5
  66. package/src/transport.ts +3 -1
  67. package/src/workspace.ts +42 -15
package/dist/mcp-tools.js CHANGED
@@ -3,6 +3,25 @@ import { createHash } from "node:crypto";
3
3
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
4
  import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
5
5
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
6
+ import { inputLimitError } from "./input-limits.js";
7
+ var MCP_TOOLS = { pages: 20, tools: 500 };
8
+ var MCP_TOOLS_PAGE = { bytes: 4 * 1024 * 1024, items: 1e5, depth: 32, string: 64 * 1024 };
9
+ function limitToolPages(transport) {
10
+ const listing = /* @__PURE__ */ new Set();
11
+ const send = transport.send.bind(transport);
12
+ transport.send = (message, ...rest) => {
13
+ if ("method" in message && message.method === "tools/list" && "id" in message) listing.add(message.id);
14
+ return send(message, ...rest);
15
+ };
16
+ const deliver = transport.onmessage;
17
+ transport.onmessage = (message, ...rest) => {
18
+ if ("id" in message && "result" in message && listing.delete(message.id)) {
19
+ const error = inputLimitError(message.result, MCP_TOOLS_PAGE, "A tools/list page");
20
+ if (error) return deliver?.({ jsonrpc: "2.0", id: message.id, error: { code: -32600, message: error } }, ...rest);
21
+ }
22
+ deliver?.(message, ...rest);
23
+ };
24
+ }
6
25
  var SessionClient = class extends Client {
7
26
  stopping;
8
27
  close() {
@@ -31,10 +50,15 @@ async function openMcpTools(servers, cwd, env, signal) {
31
50
  try {
32
51
  await client.connect(transport, { timeout: 2e4, signal });
33
52
  if (!client.getServerCapabilities()?.tools) continue;
53
+ limitToolPages(transport);
34
54
  let cursor;
35
55
  const seen = /* @__PURE__ */ new Set();
56
+ let listed = 0;
36
57
  do {
58
+ if (seen.size >= MCP_TOOLS.pages) throw new Error(`More than ${MCP_TOOLS.pages} pages of MCP tools`);
37
59
  const page = await client.listTools(cursor ? { cursor } : {}, { timeout: 2e4, signal });
60
+ listed += page.tools.length;
61
+ if (listed > MCP_TOOLS.tools) throw new Error(`More than ${MCP_TOOLS.tools} MCP tools`);
38
62
  for (const tool of page.tools) {
39
63
  const hash = createHash("sha256").update(JSON.stringify([name, tool.name])).digest("hex").slice(0, 10);
40
64
  const clean = (value, length) => value.replace(/[^\w-]/g, "_").slice(0, length);
@@ -67,5 +91,7 @@ async function openMcpTools(servers, cwd, env, signal) {
67
91
  }
68
92
  }
69
93
  export {
94
+ MCP_TOOLS,
95
+ MCP_TOOLS_PAGE,
70
96
  openMcpTools
71
97
  };
@@ -0,0 +1,76 @@
1
+ import { type CatalogEntry } from './catalog.js';
2
+ export type CatalogRuntime = 'codex' | 'claude' | 'antigravity';
3
+ /** A model as a provider reports it. */
4
+ export type LiveModel = {
5
+ id: string;
6
+ label?: string;
7
+ description?: string;
8
+ efforts?: string[];
9
+ effort?: string;
10
+ };
11
+ export type ProviderState = {
12
+ status: 'ok' | 'failed' | 'static';
13
+ fetchedAt?: string;
14
+ error?: string;
15
+ models: LiveModel[];
16
+ };
17
+ export type CatalogSnapshot = {
18
+ fetchedAt?: string;
19
+ providers: Partial<Record<CatalogRuntime, ProviderState>>;
20
+ };
21
+ export type Probe = (signal: AbortSignal) => Promise<LiveModel[]>;
22
+ export declare const REFRESH_MS: number;
23
+ export declare const PROBE_TIMEOUT_MS = 15000;
24
+ export declare const POLICY: {
25
+ 'codex:gpt-6-astra': {
26
+ efforts: string[];
27
+ effort: string;
28
+ };
29
+ };
30
+ export declare const mergeCatalog: (base: CatalogEntry[], live: Partial<Record<CatalogRuntime, LiveModel[] | undefined>>) => CatalogEntry[];
31
+ /** Only well-formed rows: a string id, string label/description/effort, string efforts. */
32
+ export declare function sanitizeModels(value: unknown): LiveModel[];
33
+ type Listener = (snapshot: CatalogSnapshot, entries: CatalogEntry[]) => void;
34
+ export declare class ModelCatalog {
35
+ private readonly options;
36
+ private snapshot;
37
+ private current;
38
+ private listeners;
39
+ private timer?;
40
+ private running?;
41
+ private readonly file?;
42
+ constructor(options: {
43
+ home?: string;
44
+ probes: Partial<Record<CatalogRuntime, Probe>>;
45
+ timeoutMs?: number;
46
+ refreshMs?: number;
47
+ now?: () => Date;
48
+ apply?: boolean;
49
+ });
50
+ entries(): CatalogEntry[];
51
+ state(): CatalogSnapshot;
52
+ onUpdated(listener: Listener): () => boolean;
53
+ /** Loads the cache, then refreshes in the background and every refreshMs. Never blocks on a provider. */
54
+ start(): Promise<void>;
55
+ stop(): void;
56
+ load(): Promise<void>;
57
+ /** Asks every provider (or the named ones; a refresh already running answers instead) at once; each answer is bounded, and a failure keeps that provider's previous list. */
58
+ refresh(runtimes?: CatalogRuntime[]): Promise<CatalogSnapshot>;
59
+ /**
60
+ * A list a session reported on its own (each turn's orchestration context). Additive: it only adds
61
+ * models the catalog does not list yet, after the ones it has, so it never narrows or reshapes what a
62
+ * probe answered; a list with nothing new changes nothing.
63
+ */
64
+ ingest(runtime: CatalogRuntime, models: LiveModel[]): Promise<boolean>;
65
+ private publish;
66
+ }
67
+ /** Reads a session's orchestration context models (`runtime:id`, label, description, thinking) as live models. */
68
+ export declare function liveFromContext(context: any): {
69
+ runtime: CatalogRuntime;
70
+ models: LiveModel[];
71
+ } | undefined;
72
+ /** The daemon's catalog, which sessions feed opportunistically. */
73
+ export declare function setActiveCatalog(catalog: ModelCatalog | undefined): void;
74
+ export declare function activeCatalog(): ModelCatalog | undefined;
75
+ export declare function feedCatalog(context: unknown): void;
76
+ export {};
@@ -0,0 +1,193 @@
1
+ // packages/runtime/src/model-catalog.ts
2
+ import { mkdir, readFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { MODELS, MODEL_POLICY, catalogCacheFile, mergeCatalog as mergeCatalogRows } from "@anhlp/alp-core/models";
5
+ import { writeAtomic } from "@anhlp/alp-core/atomic";
6
+ import { applyCatalog } from "./catalog.js";
7
+ var RUNTIMES = ["codex", "claude", "antigravity"];
8
+ var REFRESH_MS = 6 * 60 * 60 * 1e3;
9
+ var PROBE_TIMEOUT_MS = 15e3;
10
+ var POLICY = MODEL_POLICY;
11
+ var mergeCatalog = mergeCatalogRows;
12
+ var staticRows = () => MODELS.map((entry) => ({ ...entry, source: "static" }));
13
+ var bounded = (work, ms) => {
14
+ const controller = new AbortController();
15
+ let timer;
16
+ return Promise.race([
17
+ work(controller.signal),
18
+ new Promise((_, reject) => {
19
+ timer = setTimeout(() => {
20
+ controller.abort();
21
+ reject(new Error(`timed out after ${ms} ms`));
22
+ }, ms);
23
+ })
24
+ ]).finally(() => clearTimeout(timer));
25
+ };
26
+ var strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : void 0;
27
+ function sanitizeModels(value) {
28
+ if (!Array.isArray(value)) return [];
29
+ return value.filter((model) => model && typeof model === "object" && typeof model.id === "string" && model.id.trim()).map((model) => ({
30
+ id: model.id,
31
+ ...typeof model.label === "string" ? { label: model.label } : {},
32
+ ...typeof model.description === "string" ? { description: model.description } : {},
33
+ ...strings(model.efforts) ? { efforts: strings(model.efforts) } : {},
34
+ ...typeof model.effort === "string" ? { effort: model.effort } : {}
35
+ }));
36
+ }
37
+ function sanitize(value) {
38
+ const providers = {};
39
+ for (const runtime of RUNTIMES) {
40
+ const state = value?.providers?.[runtime];
41
+ if (!state || typeof state !== "object") continue;
42
+ providers[runtime] = { status: state.status === "ok" ? "ok" : "failed", ...typeof state.fetchedAt === "string" ? { fetchedAt: state.fetchedAt } : {}, models: sanitizeModels(state.models) };
43
+ }
44
+ return { ...typeof value?.fetchedAt === "string" ? { fetchedAt: value.fetchedAt } : {}, providers };
45
+ }
46
+ var ModelCatalog = class {
47
+ constructor(options) {
48
+ this.options = options;
49
+ this.file = options.home ? catalogCacheFile(options.home) : void 0;
50
+ }
51
+ snapshot = { providers: {} };
52
+ current = staticRows();
53
+ listeners = /* @__PURE__ */ new Set();
54
+ timer;
55
+ running;
56
+ file;
57
+ entries() {
58
+ return this.current;
59
+ }
60
+ state() {
61
+ return this.snapshot;
62
+ }
63
+ onUpdated(listener) {
64
+ this.listeners.add(listener);
65
+ return () => this.listeners.delete(listener);
66
+ }
67
+ /** Loads the cache, then refreshes in the background and every refreshMs. Never blocks on a provider. */
68
+ async start() {
69
+ await this.load();
70
+ void this.refresh().catch(() => {
71
+ });
72
+ const every = this.options.refreshMs ?? REFRESH_MS;
73
+ if (every > 0) {
74
+ this.timer = setInterval(() => {
75
+ void this.refresh().catch(() => {
76
+ });
77
+ }, every);
78
+ this.timer.unref?.();
79
+ }
80
+ }
81
+ stop() {
82
+ if (this.timer) clearInterval(this.timer);
83
+ this.timer = void 0;
84
+ this.listeners.clear();
85
+ }
86
+ async load() {
87
+ if (!this.file) return;
88
+ try {
89
+ this.snapshot = sanitize(JSON.parse(await readFile(this.file, "utf8")));
90
+ await this.publish(false);
91
+ } catch {
92
+ this.snapshot = { providers: {} };
93
+ }
94
+ }
95
+ /** Asks every provider (or the named ones; a refresh already running answers instead) at once; each answer is bounded, and a failure keeps that provider's previous list. */
96
+ refresh(runtimes = RUNTIMES) {
97
+ if (this.running) return this.running;
98
+ this.running = (async () => {
99
+ const now = () => (this.options.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
100
+ const results = await Promise.all(runtimes.filter((runtime) => this.options.probes[runtime]).map(async (runtime) => {
101
+ try {
102
+ return [runtime, { status: "ok", fetchedAt: now(), models: sanitizeModels(await bounded(this.options.probes[runtime], this.options.timeoutMs ?? PROBE_TIMEOUT_MS)) }];
103
+ } catch (error) {
104
+ const prior = this.snapshot.providers[runtime];
105
+ return [runtime, { status: "failed", fetchedAt: prior?.fetchedAt, error: error instanceof Error ? error.message : String(error), models: prior?.models ?? [] }];
106
+ }
107
+ }));
108
+ for (const [runtime, state] of results) {
109
+ if (state.status === "ok" && !state.models.length) {
110
+ this.snapshot.providers[runtime] = { ...this.snapshot.providers[runtime] ?? { models: [] }, status: "failed", error: "provider reported no models" };
111
+ continue;
112
+ }
113
+ this.snapshot.providers[runtime] = state;
114
+ }
115
+ this.snapshot.fetchedAt = now();
116
+ await this.publish(true);
117
+ return this.snapshot;
118
+ })().finally(() => {
119
+ this.running = void 0;
120
+ });
121
+ return this.running;
122
+ }
123
+ /**
124
+ * A list a session reported on its own (each turn's orchestration context). Additive: it only adds
125
+ * models the catalog does not list yet, after the ones it has, so it never narrows or reshapes what a
126
+ * probe answered; a list with nothing new changes nothing.
127
+ */
128
+ async ingest(runtime, models) {
129
+ const prior = this.snapshot.providers[runtime];
130
+ const known = new Set((prior?.models ?? []).map((model) => model.id));
131
+ const added = sanitizeModels(models).filter((model) => !known.has(model.id));
132
+ if (!added.length) return false;
133
+ this.snapshot.providers[runtime] = { ...prior ?? { status: "ok" }, status: prior?.status ?? "ok", fetchedAt: prior?.fetchedAt ?? (this.options.now?.() ?? /* @__PURE__ */ new Date()).toISOString(), models: [...prior?.models ?? [], ...added] };
134
+ await this.publish(true);
135
+ return true;
136
+ }
137
+ async publish(save) {
138
+ const next = mergeCatalog(staticRows(), Object.fromEntries(Object.entries(this.snapshot.providers).map(([runtime, state]) => [runtime, state?.models])));
139
+ const changed = JSON.stringify(next) !== JSON.stringify(this.current);
140
+ this.current = next;
141
+ if (this.options.apply !== false) applyCatalog(next);
142
+ if (save && this.file) {
143
+ try {
144
+ await mkdir(path.dirname(this.file), { recursive: true });
145
+ await writeAtomic(this.file, JSON.stringify(this.snapshot, null, 2));
146
+ } catch {
147
+ }
148
+ }
149
+ if (save) for (const listener of this.listeners) {
150
+ try {
151
+ listener(this.snapshot, next);
152
+ } catch {
153
+ }
154
+ }
155
+ return changed;
156
+ }
157
+ };
158
+ function liveFromContext(context) {
159
+ if (!context?.catalogAvailable || !RUNTIMES.includes(context.runtime) || !Array.isArray(context.models)) return void 0;
160
+ if (context.catalogComplete === false) return void 0;
161
+ const prefix = `${context.runtime}:`;
162
+ const models = context.models.filter((model) => typeof model?.id === "string" && model.id.startsWith(prefix)).map((model) => ({
163
+ id: model.id.slice(prefix.length),
164
+ label: model.label,
165
+ description: model.description,
166
+ efforts: Array.isArray(model.thinking) ? model.thinking.map((effort) => typeof effort === "string" ? effort : effort?.reasoningEffort ?? effort?.id).filter((effort) => typeof effort === "string") : void 0
167
+ }));
168
+ return { runtime: context.runtime, models };
169
+ }
170
+ var active;
171
+ function setActiveCatalog(catalog) {
172
+ active = catalog;
173
+ }
174
+ function activeCatalog() {
175
+ return active;
176
+ }
177
+ function feedCatalog(context) {
178
+ const live = liveFromContext(context);
179
+ if (live && active) void active.ingest(live.runtime, live.models).catch(() => {
180
+ });
181
+ }
182
+ export {
183
+ ModelCatalog,
184
+ POLICY,
185
+ PROBE_TIMEOUT_MS,
186
+ REFRESH_MS,
187
+ activeCatalog,
188
+ feedCatalog,
189
+ liveFromContext,
190
+ mergeCatalog,
191
+ sanitizeModels,
192
+ setActiveCatalog
193
+ };
@@ -0,0 +1,7 @@
1
+ import type { CatalogRuntime, LiveModel, Probe } from './model-catalog.js';
2
+ export declare function codexProbe(command?: string, env?: NodeJS.ProcessEnv): Probe;
3
+ export declare function claudeProbe(command?: string, env?: NodeJS.ProcessEnv): Probe;
4
+ /** `agy models` prints one model per line, `id<TAB>label`. */
5
+ export declare function parseAgyModels(stdout: string): LiveModel[];
6
+ export declare function antigravityProbe(command?: string, env?: NodeJS.ProcessEnv): Probe;
7
+ export declare function liveProbes(env?: NodeJS.ProcessEnv): Record<CatalogRuntime, Probe>;
@@ -0,0 +1,69 @@
1
+ // packages/runtime/src/model-probes.ts
2
+ import { spawn } from "node:child_process";
3
+ import os from "node:os";
4
+ import { CodexTransport } from "./transport.js";
5
+ import { ClaudeTransport } from "./claude-transport.js";
6
+ function codexProbe(command = process.env.ALP_CODEX_BIN ?? "codex", env = process.env) {
7
+ return async (signal) => {
8
+ const transport = new CodexTransport(command, os.tmpdir(), env);
9
+ const stop = () => {
10
+ void transport.close();
11
+ };
12
+ signal.addEventListener("abort", stop);
13
+ try {
14
+ await transport.initialize();
15
+ const models = [];
16
+ let cursor;
17
+ for (let page = 0; page < 10; page++) {
18
+ const result = await transport.request("model/list", { limit: 100, includeHidden: false, ...cursor ? { cursor } : {} }, 1e4, false);
19
+ for (const model of result?.data ?? []) {
20
+ if (typeof model?.model !== "string" || model.hidden) continue;
21
+ models.push({
22
+ id: model.model,
23
+ label: model.displayName,
24
+ description: model.description,
25
+ efforts: (model.supportedReasoningEfforts ?? []).map((effort) => typeof effort === "string" ? effort : effort?.reasoningEffort).filter((effort) => typeof effort === "string"),
26
+ effort: model.defaultReasoningEffort
27
+ });
28
+ }
29
+ cursor = result?.nextCursor ?? void 0;
30
+ if (!cursor) break;
31
+ }
32
+ return models;
33
+ } finally {
34
+ signal.removeEventListener("abort", stop);
35
+ await transport.close();
36
+ }
37
+ };
38
+ }
39
+ function claudeProbe(command = process.env.ALP_CLAUDE_BIN ?? "claude", env = process.env) {
40
+ return async (signal) => new ClaudeTransport(command, os.tmpdir(), env).probeModels(signal);
41
+ }
42
+ function parseAgyModels(stdout) {
43
+ return stdout.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((line) => {
44
+ const [id, label] = line.split(" ").map((part) => part.trim());
45
+ return { id, label: label || id };
46
+ }).filter((model) => model.id && /^[A-Za-z0-9][\w.:\-\[\]/]*$/.test(model.id));
47
+ }
48
+ function antigravityProbe(command = process.env.ALP_ANTIGRAVITY_BIN ?? "agy", env = process.env) {
49
+ return (signal) => new Promise((resolve, reject) => {
50
+ const child = spawn(command, ["models"], { cwd: os.tmpdir(), env, stdio: ["ignore", "pipe", "ignore"], windowsHide: true, signal });
51
+ let stdout = "";
52
+ child.stdout.on("data", (chunk) => {
53
+ stdout += chunk;
54
+ if (stdout.length > 256 * 1024) child.kill("SIGKILL");
55
+ });
56
+ child.on("error", reject);
57
+ child.on("close", (code) => code === 0 ? resolve(parseAgyModels(stdout)) : reject(new Error(`${command} models exited with ${code}`)));
58
+ });
59
+ }
60
+ function liveProbes(env = process.env) {
61
+ return { codex: codexProbe(void 0, env), claude: claudeProbe(void 0, env), antigravity: antigravityProbe(void 0, env) };
62
+ }
63
+ export {
64
+ antigravityProbe,
65
+ claudeProbe,
66
+ codexProbe,
67
+ liveProbes,
68
+ parseAgyModels
69
+ };
package/dist/providers.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // packages/runtime/src/providers.ts
2
+ import { AGENT_MARKER } from "@anhlp/alp-core/tasks";
2
3
  import { CodexTransport } from "./transport.js";
3
4
  import { ClaudeTransport } from "./claude-transport.js";
4
5
  import { AcpTransport } from "./acp-transport.js";
@@ -8,6 +9,7 @@ function nativeEnvironment(options, extra = {}) {
8
9
  for (const key of Object.keys(environment)) {
9
10
  if (/^(PASEO_|CODEX_THREAD_ID$|CODEX_INTERNAL_|CODEX_PARENT_|CLAUDECODE$|CLAUDE_CODE_|ANTHROPIC_AGENT_)/.test(key)) delete environment[key];
10
11
  }
12
+ environment[AGENT_MARKER] = "1";
11
13
  return environment;
12
14
  }
13
15
  var ProviderRegistry = class {
package/dist/resolve.d.ts CHANGED
@@ -53,6 +53,7 @@ export declare function resolveSession(spec: SessionSpec, options?: {
53
53
  initialize?: boolean;
54
54
  }): Promise<{
55
55
  autocompact: number | undefined;
56
+ compact: import("./compact.js").CompactSettings;
56
57
  language: string;
57
58
  context?: number | undefined;
58
59
  instructions: string;
package/dist/resolve.js CHANGED
@@ -11,6 +11,7 @@ import { acpModel, loadProvider } from "@anhlp/alp-core/providers";
11
11
  import { ensureLibrary } from "@anhlp/alp-core/library";
12
12
  import { compileAgent } from "@anhlp/alp-core/adapter";
13
13
  import { capMode, profileFor } from "@anhlp/alp-core/permissions";
14
+ import { compactSettings } from "./compact.js";
14
15
  import { userLanguage } from "@anhlp/alp-core/user-settings";
15
16
  import { claudeSandboxAvailable } from "./claude-transport.js";
16
17
  import { DEFAULT_ANTIGRAVITY_MODEL, DEFAULT_CLAUDE_MODEL, DEFAULT_MODEL, ORACLE_MODELS, ORACLE_THINKING, models, modes, thinkingOptions, thinkingOptionsFor } from "./catalog.js";
@@ -156,7 +157,6 @@ async function resolveSession(spec, options = {}) {
156
157
  const requested = spec.mode ?? agent.mode ?? (agent.name === main ? "full-access" : "read-only");
157
158
  const mode = permissions ? capMode(requested, permissions.base) : requested;
158
159
  if (runtimeKind === "antigravity") {
159
- if (mode !== "full-access" && !(mode === "read-only" && antigravity?.readOnlyMode === "instructions")) throw new Error('Antigravity currently supports only full-access; read-only requires explicit readOnlyMode: "instructions" and is not sandboxed');
160
160
  if (spec.copy || permissions?.workdir === "copy") throw new Error("Antigravity cannot enforce isolation for a review copy");
161
161
  if (permissions && (permissions.deny.length || permissions.ask.length || permissions.allow.length || permissions.beyondMode === "ask")) {
162
162
  throw new Error("Antigravity cannot enforce custom permission rules");
@@ -225,6 +225,8 @@ ${project}` : "");
225
225
  // ALPD §57: the window the agent works in before its runtime compacts; absent, the model's.
226
226
  ...agent.context ? { context: agent.context } : {},
227
227
  autocompact: typeof profile?.autocompact === "number" ? profile.autocompact : typeof agent.autocompact === "number" ? agent.autocompact : void 0,
228
+ // t-0e56: when main's context is compacted at a turn boundary.
229
+ compact: compactSettings(projectSettings.compact),
228
230
  // ALPD §54: the language everything the user reads is written in.
229
231
  language: options.language ?? await userLanguage(options.library)
230
232
  };
package/dist/runtime.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { type RuntimeOptions, type AlpRuntime } from './contracts.js';
2
2
  export type { RuntimeTransport, RuntimeOptions, OpenOptions, PromptContent, PromptInput, AlpRuntime, SessionPreview, RecoveryOutcome, Pause, PauseState, RecallAnswer } from './contracts.js';
3
3
  export { DEFAULT_TEAM } from './contracts.js';
4
- export type WorkspaceMutationReason = 'workspace_busy' | 'workspace_claimed' | 'workspace_leased' | 'workspace_assignment_result';
4
+ /** The monthly curate job's prompt starts with this marker, so main and ALP recognize it. */
5
+ export declare const CURATE_MARKER = "[alp-curate]";
6
+ export type WorkspaceMutationReason = 'workspace_busy' | 'workspace_claimed' | 'workspace_leased' | 'workspace_assignment_result' | 'workspace_identity';
5
7
  export declare class WorkspaceMutationError extends Error {
6
8
  readonly data: {
7
9
  reason: WorkspaceMutationReason;