@anhlp/alp-runtime 0.0.0-stage → 0.0.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +6 -2
- package/dist/acp-transport.d.ts +130 -0
- package/dist/acp-transport.js +511 -0
- package/dist/antigravity-transport.d.ts +82 -0
- package/dist/antigravity-transport.js +619 -0
- package/dist/assignment-results.d.ts +18 -0
- package/dist/assignment-results.js +77 -0
- package/dist/attachments.d.ts +84 -0
- package/dist/attachments.js +213 -0
- package/dist/board-domain.d.ts +56 -0
- package/dist/board-domain.js +157 -0
- package/dist/board.d.ts +21 -0
- package/dist/board.js +69 -0
- package/dist/catalog.d.ts +31 -0
- package/dist/catalog.js +38 -0
- package/dist/claude-transport.d.ts +202 -0
- package/dist/claude-transport.js +817 -0
- package/dist/configure.d.ts +44 -0
- package/dist/configure.js +64 -0
- package/dist/contracts.d.ts +327 -0
- package/dist/contracts.js +16 -0
- package/dist/conversation.d.ts +45 -0
- package/dist/conversation.js +62 -0
- package/dist/events.d.ts +1 -0
- package/dist/events.js +0 -0
- package/dist/github.d.ts +10 -0
- package/dist/github.js +39 -0
- package/dist/handoff.d.ts +36 -0
- package/dist/handoff.js +73 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +87 -0
- package/dist/language.d.ts +41 -0
- package/dist/language.js +68 -0
- package/dist/live.d.ts +48 -0
- package/dist/live.js +45 -0
- package/dist/mailbox.d.ts +26 -0
- package/dist/mailbox.js +38 -0
- package/dist/mcp-tools.d.ts +115 -0
- package/dist/mcp-tools.js +71 -0
- package/dist/permission-path.d.ts +2 -0
- package/dist/permission-path.js +44 -0
- package/dist/process-info.d.ts +14 -0
- package/dist/process-info.js +32 -0
- package/dist/providers.d.ts +28 -0
- package/dist/providers.js +71 -0
- package/dist/recall.d.ts +42 -0
- package/dist/recall.js +60 -0
- package/dist/resolve.d.ts +121 -0
- package/dist/resolve.js +238 -0
- package/dist/runtime-context.d.ts +43 -0
- package/dist/runtime-context.js +61 -0
- package/dist/runtime.d.ts +11 -0
- package/dist/runtime.js +3976 -0
- package/dist/session-config.d.ts +2102 -0
- package/dist/session-config.js +205 -0
- package/dist/session-state.d.ts +166 -0
- package/dist/session-state.js +0 -0
- package/dist/tool-detail.d.ts +81 -0
- package/dist/tool-detail.js +332 -0
- package/dist/tool-results.d.ts +12 -0
- package/dist/tool-results.js +25 -0
- package/dist/tools.d.ts +719 -0
- package/dist/tools.js +396 -0
- package/dist/transport.d.ts +47 -0
- package/dist/transport.js +169 -0
- package/dist/usage.d.ts +25 -0
- package/dist/usage.js +60 -0
- package/dist/workspace.d.ts +101 -0
- package/dist/workspace.js +259 -0
- package/dist/worktree-domain.d.ts +89 -0
- package/dist/worktree-domain.js +199 -0
- package/package.json +262 -4
- package/src/acp-transport.ts +508 -0
- package/src/antigravity-transport.ts +667 -0
- package/src/assignment-results.ts +64 -0
- package/src/attachments.ts +254 -0
- package/src/board-domain.ts +185 -0
- package/src/board.ts +80 -0
- package/src/catalog.ts +32 -0
- package/src/claude-transport.ts +938 -0
- package/src/configure.ts +93 -0
- package/src/contracts.ts +318 -0
- package/src/conversation.ts +81 -0
- package/src/events.ts +1 -0
- package/src/github.ts +37 -0
- package/src/handoff.ts +86 -0
- package/src/index.ts +32 -0
- package/src/language.ts +102 -0
- package/src/live.ts +86 -0
- package/src/mailbox.ts +49 -0
- package/src/mcp-tools.ts +73 -0
- package/src/permission-path.ts +37 -0
- package/src/process-info.ts +40 -0
- package/src/providers.ts +84 -0
- package/src/recall.ts +85 -0
- package/src/resolve.ts +230 -0
- package/src/runtime-context.ts +49 -0
- package/src/runtime.ts +4691 -0
- package/src/session-config.ts +304 -0
- package/src/session-state.ts +164 -0
- package/src/tool-detail.ts +397 -0
- package/src/tool-results.ts +26 -0
- package/src/tools.ts +397 -0
- package/src/transport.ts +116 -0
- package/src/usage.ts +79 -0
- package/src/workspace.ts +318 -0
- package/src/worktree-domain.ts +220 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const COMPACT_SHARE = 0.9;
|
|
2
|
+
/** Bounded optional reads. Never expose account identifiers or credentials. */
|
|
3
|
+
export declare function optionalRead<T>(read: () => Promise<T>, timeout?: number): Promise<T | undefined>;
|
|
4
|
+
export declare function codexUsage(result: any): {
|
|
5
|
+
available: boolean;
|
|
6
|
+
ordinaryUsageAllowed?: undefined;
|
|
7
|
+
limits?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
available: boolean;
|
|
10
|
+
ordinaryUsageAllowed: any;
|
|
11
|
+
limits: {
|
|
12
|
+
name: any;
|
|
13
|
+
model: any;
|
|
14
|
+
plan: any;
|
|
15
|
+
windows: {
|
|
16
|
+
usedPercent: any;
|
|
17
|
+
remainingPercent: number | null;
|
|
18
|
+
windowMinutes: any;
|
|
19
|
+
resetsAt: any;
|
|
20
|
+
}[];
|
|
21
|
+
spendControlReached: any;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
export declare function claudeUsage(result: any): {
|
|
25
|
+
available: boolean;
|
|
26
|
+
plan?: undefined;
|
|
27
|
+
windows?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
available: boolean;
|
|
30
|
+
plan: any;
|
|
31
|
+
windows: {
|
|
32
|
+
name: string;
|
|
33
|
+
usedPercent: any;
|
|
34
|
+
remainingPercent: number | null;
|
|
35
|
+
resetsAt: any;
|
|
36
|
+
}[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Whether a runtime's usage report (codexUsage or claudeUsage) lets it work again (ALPD §58):
|
|
40
|
+
* true when every window has room, false on explicit provider denial, a used-up window or spending cap, and
|
|
41
|
+
* undefined when the report says nothing either way.
|
|
42
|
+
*/
|
|
43
|
+
export declare function usageAllows(usage: any): boolean | undefined;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// packages/runtime/src/runtime-context.ts
|
|
2
|
+
var COMPACT_SHARE = 0.9;
|
|
3
|
+
async function optionalRead(read, timeout = 1500) {
|
|
4
|
+
let timer;
|
|
5
|
+
try {
|
|
6
|
+
return await Promise.race([Promise.resolve().then(read).catch(() => void 0), new Promise((resolve) => {
|
|
7
|
+
timer = setTimeout(() => resolve(void 0), timeout);
|
|
8
|
+
})]);
|
|
9
|
+
} finally {
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function codexUsage(result) {
|
|
14
|
+
if (!result?.rateLimits) return { available: false };
|
|
15
|
+
const clean = (limit) => ({
|
|
16
|
+
name: limit?.limitName ?? null,
|
|
17
|
+
model: limit?.normalModelSlug ?? null,
|
|
18
|
+
plan: limit?.planType ?? null,
|
|
19
|
+
windows: [limit?.primary, limit?.secondary].filter(Boolean).map((window) => ({
|
|
20
|
+
usedPercent: window.usedPercent,
|
|
21
|
+
remainingPercent: typeof window.usedPercent === "number" ? Math.max(0, 100 - window.usedPercent) : null,
|
|
22
|
+
windowMinutes: window.windowDurationMins,
|
|
23
|
+
resetsAt: window.resetsAt
|
|
24
|
+
})),
|
|
25
|
+
spendControlReached: limit?.spendControlReached ?? null
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
available: true,
|
|
29
|
+
ordinaryUsageAllowed: result.ordinaryUsageAllowed ?? null,
|
|
30
|
+
limits: Object.values(result.rateLimitsByLimitId ?? { default: result.rateLimits }).map(clean)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function claudeUsage(result) {
|
|
34
|
+
if (!result) return { available: false };
|
|
35
|
+
return {
|
|
36
|
+
available: result.rate_limits_available === true,
|
|
37
|
+
plan: result.subscription_type ?? null,
|
|
38
|
+
windows: Object.entries(result.rate_limits ?? {}).flatMap(([name, window]) => window && "utilization" in window ? [{
|
|
39
|
+
name,
|
|
40
|
+
usedPercent: window.utilization,
|
|
41
|
+
remainingPercent: typeof window.utilization === "number" ? Math.max(0, 100 - window.utilization) : null,
|
|
42
|
+
resetsAt: window.resets_at
|
|
43
|
+
}] : [])
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function usageAllows(usage) {
|
|
47
|
+
if (!usage?.available) return void 0;
|
|
48
|
+
const limits = Array.isArray(usage.limits) ? usage.limits : [];
|
|
49
|
+
if (usage.ordinaryUsageAllowed === false || limits.some((limit) => limit?.spendControlReached === true)) return false;
|
|
50
|
+
const windows = limits.length ? limits.flatMap((limit) => limit?.windows ?? []) : usage.windows ?? [];
|
|
51
|
+
const known = windows.filter((window) => typeof window?.usedPercent === "number");
|
|
52
|
+
if (!known.length) return void 0;
|
|
53
|
+
return known.every((window) => window.usedPercent < 100);
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
COMPACT_SHARE,
|
|
57
|
+
claudeUsage,
|
|
58
|
+
codexUsage,
|
|
59
|
+
optionalRead,
|
|
60
|
+
usageAllows
|
|
61
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type RuntimeOptions, type AlpRuntime } from './contracts.js';
|
|
2
|
+
export type { RuntimeTransport, RuntimeOptions, OpenOptions, PromptContent, PromptInput, AlpRuntime, SessionPreview, RecoveryOutcome, Pause, PauseState, RecallAnswer } from './contracts.js';
|
|
3
|
+
export { DEFAULT_TEAM } from './contracts.js';
|
|
4
|
+
export type WorkspaceMutationReason = 'workspace_busy' | 'workspace_claimed' | 'workspace_leased' | 'workspace_assignment_result';
|
|
5
|
+
export declare class WorkspaceMutationError extends Error {
|
|
6
|
+
readonly data: {
|
|
7
|
+
reason: WorkspaceMutationReason;
|
|
8
|
+
};
|
|
9
|
+
constructor(reason: WorkspaceMutationReason, message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare function createAlpRuntime(options?: RuntimeOptions): AlpRuntime;
|