@anhlp/alp-runtime 0.0.1-beta.6 → 0.0.1-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/claude-transport.d.ts +11 -0
- package/dist/claude-transport.js +16 -2
- package/dist/contracts.d.ts +11 -0
- package/dist/index.d.ts +1 -1
- package/dist/resolve.d.ts +1 -0
- package/dist/resolve.js +2 -0
- package/dist/runtime.js +16 -2
- package/package.json +3 -3
- package/src/claude-transport.ts +17 -4
- package/src/contracts.ts +7 -0
- package/src/index.ts +1 -1
- package/src/resolve.ts +2 -0
- package/src/runtime.ts +23 -2
|
@@ -168,6 +168,17 @@ export declare class ClaudeTransport {
|
|
|
168
168
|
}[];
|
|
169
169
|
};
|
|
170
170
|
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Claude's slash commands, skills included, for the composer (t-f628); none before the session starts.
|
|
173
|
+
* Not the ones whose work ALP does itself (t-efa3): /clear moves Claude to a new conversation ALP does not
|
|
174
|
+
* follow, and /compact and /rewind skip ALP's checkpoint and its rewind of the timeline.
|
|
175
|
+
*/
|
|
176
|
+
commands(): Promise<{
|
|
177
|
+
kind: "skill" | "command";
|
|
178
|
+
argumentHint?: string | undefined;
|
|
179
|
+
name: string;
|
|
180
|
+
description: string;
|
|
181
|
+
}[]>;
|
|
171
182
|
initialize(): Promise<void>;
|
|
172
183
|
/** The models Claude offers now, from a Claude process that sends no prompt and is closed after (t-e5ee). */
|
|
173
184
|
probeModels(signal?: AbortSignal): Promise<{
|
package/dist/claude-transport.js
CHANGED
|
@@ -12,9 +12,8 @@ import { inputLimitError, POUR_VARS, VAR_NAME } from "./input-limits.js";
|
|
|
12
12
|
import { claudeToolDetail, resultText } from "./tool-detail.js";
|
|
13
13
|
import { CLOSE_REASONS, GATE_KINDS, TASK_STATUSES, TASK_TYPES } from "@anhlp/alp-core/tasks";
|
|
14
14
|
import { commandDecision } from "@anhlp/alp-core/permissions";
|
|
15
|
-
import { packagedInfo } from "@anhlp/alp-core/packaged";
|
|
16
15
|
var CLAUDE_SDK = ["@anthropic-ai", "claude-agent-sdk"].join("/");
|
|
17
|
-
var claudeSdk = () =>
|
|
16
|
+
var claudeSdk = () => import(CLAUDE_SDK);
|
|
18
17
|
var bounded = (schema, limits) => z.preprocess((value, ctx) => {
|
|
19
18
|
const error = inputLimitError(value, limits);
|
|
20
19
|
if (error) ctx.addIssue({ code: "custom", message: error });
|
|
@@ -176,6 +175,7 @@ var toolShapes = {
|
|
|
176
175
|
}
|
|
177
176
|
};
|
|
178
177
|
var SKILL_PLUGIN = "alp";
|
|
178
|
+
var ALP_HANDLED_COMMANDS = /* @__PURE__ */ new Set(["clear", "compact", "rewind"]);
|
|
179
179
|
function skillPlugin(directory, skills) {
|
|
180
180
|
rmSync(directory, { recursive: true, force: true });
|
|
181
181
|
mkdirSync(path.join(directory, ".claude-plugin"), { recursive: true });
|
|
@@ -377,6 +377,20 @@ var ClaudeTransport = class {
|
|
|
377
377
|
usage: claudeUsage(usage)
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
+
/**
|
|
381
|
+
* Claude's slash commands, skills included, for the composer (t-f628); none before the session starts.
|
|
382
|
+
* Not the ones whose work ALP does itself (t-efa3): /clear moves Claude to a new conversation ALP does not
|
|
383
|
+
* follow, and /compact and /rewind skip ALP's checkpoint and its rewind of the timeline.
|
|
384
|
+
*/
|
|
385
|
+
async commands() {
|
|
386
|
+
const listed = this.query ? await optionalRead(async () => this.query.supportedCommands(), 1e4) : void 0;
|
|
387
|
+
return (Array.isArray(listed) ? listed : []).filter((command) => typeof command?.name === "string" && command.name && !ALP_HANDLED_COMMANDS.has(command.name)).map((command) => ({
|
|
388
|
+
name: command.name,
|
|
389
|
+
description: typeof command.description === "string" ? command.description : "",
|
|
390
|
+
...command.argumentHint ? { argumentHint: command.argumentHint } : {},
|
|
391
|
+
kind: command.name.startsWith(`${SKILL_PLUGIN}:`) ? "skill" : "command"
|
|
392
|
+
}));
|
|
393
|
+
}
|
|
380
394
|
async initialize() {
|
|
381
395
|
}
|
|
382
396
|
/** The models Claude offers now, from a Claude process that sends no prompt and is closed after (t-e5ee). */
|
package/dist/contracts.d.ts
CHANGED
|
@@ -8,10 +8,19 @@ import type { AcpProvider } from './acp-transport.js';
|
|
|
8
8
|
import type { AntigravityProvider } from './antigravity-transport.js';
|
|
9
9
|
import type { GitHubRunner } from './github.js';
|
|
10
10
|
import type { AttachmentReader } from './attachments.js';
|
|
11
|
+
/** A slash command or skill an agent's composer offers after "/" (t-f628). */
|
|
12
|
+
export type RuntimeCommand = {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
argumentHint?: string;
|
|
16
|
+
kind: 'command' | 'skill';
|
|
17
|
+
};
|
|
11
18
|
export type RuntimeTransport = {
|
|
12
19
|
request(method: string, params: any): Promise<any>;
|
|
13
20
|
initialize(): Promise<void>;
|
|
14
21
|
orchestrationContext?: () => Promise<unknown>;
|
|
22
|
+
/** The runtime's own slash commands and skills for the composer (t-f628); omitted, the runtime offers none. */
|
|
23
|
+
commands?: () => Promise<RuntimeCommand[]>;
|
|
15
24
|
onNotification(listener: (method: string, params: any) => void): void;
|
|
16
25
|
onFailure(listener: (error: unknown) => void): void;
|
|
17
26
|
close(): Promise<void>;
|
|
@@ -248,6 +257,8 @@ export type AlpRuntime = {
|
|
|
248
257
|
compact?(sessionId: string): {
|
|
249
258
|
status: 'started' | 'deferred' | 'running';
|
|
250
259
|
};
|
|
260
|
+
/** The slash commands and skills a live session's composer offers (t-f628): its runtime's, then its ALP skills. */
|
|
261
|
+
commands?(sessionId: string): Promise<RuntimeCommand[]>;
|
|
251
262
|
/**
|
|
252
263
|
* Holds the turns the runtime would start by itself on this session (mail wakes) while a lifecycle
|
|
253
264
|
* operation changes its conversation (a rewind, later a reload or live configure): mail stays queued
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createAlpRuntime, DEFAULT_TEAM, WorkspaceMutationError } from './runtime.js';
|
|
2
2
|
export type { WorkspaceMutationReason, AlpRuntime, RuntimeOptions, OpenOptions, RuntimeTransport, PromptInput, PromptContent, SessionPreview } from './runtime.js';
|
|
3
3
|
export { ConversationError } from './contracts.js';
|
|
4
|
-
export type { BranchRequest, ConversationErrorReason, NativeBase, NativeBinding, ConfigureChanges, ConfigureResult, ConfigurePreview, EffectiveConfig } from './contracts.js';
|
|
4
|
+
export type { RuntimeCommand, BranchRequest, ConversationErrorReason, NativeBase, NativeBinding, ConfigureChanges, ConfigureResult, ConfigurePreview, EffectiveConfig } from './contracts.js';
|
|
5
5
|
export type { AlpEvent, AlpError, Envelope, SessionSnapshot, TimelineItem, TurnOrigin, AssignmentSnapshot, UserQuestion, TreeStatus, SessionState } from './events.js';
|
|
6
6
|
export { resolveSession, InstructionsAdapter, skillDescription } from './resolve.js';
|
|
7
7
|
export type { SessionSpec, HostMcpServer, ResolvedSession, RuntimeKind } from './resolve.js';
|
package/dist/resolve.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export declare function resolveSession(spec: SessionSpec, options?: {
|
|
|
52
52
|
language?: string; /** False for a preview: it writes nothing (D31). */
|
|
53
53
|
initialize?: boolean;
|
|
54
54
|
}): Promise<{
|
|
55
|
+
commands: string[];
|
|
55
56
|
autocompact: number | undefined;
|
|
56
57
|
compact: import("./compact.js").CompactSettings;
|
|
57
58
|
language: string;
|
package/dist/resolve.js
CHANGED
|
@@ -224,6 +224,8 @@ ${project}` : "");
|
|
|
224
224
|
keepThread: spec.keepThread ?? false,
|
|
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
|
+
// t-efa3: the runtime's own commands and skills the "/" list offers; its ALP skills always.
|
|
228
|
+
commands: Array.isArray(profile?.commands) ? profile.commands.filter((name) => typeof name === "string") : [],
|
|
227
229
|
autocompact: typeof profile?.autocompact === "number" ? profile.autocompact : typeof agent.autocompact === "number" ? agent.autocompact : void 0,
|
|
228
230
|
// t-0e56: when main's context is compacted at a turn boundary.
|
|
229
231
|
compact: compactSettings(projectSettings.compact),
|
package/dist/runtime.js
CHANGED
|
@@ -32,7 +32,7 @@ import { isTrusted, trustProject } from "@anhlp/alp-core/trust";
|
|
|
32
32
|
import { listTeams, teamOf } from "@anhlp/alp-core/teams";
|
|
33
33
|
import { CONFIGURABLE, changesOf, effectiveOf, executablesOf, nativeModelOf, offered } from "./configure.js";
|
|
34
34
|
import { anyModel, offers, profileModel, selectedProfile } from "@anhlp/alp-core/profiles";
|
|
35
|
-
import { LESSONS_FILE, READ_ONLY_AGENTS, resolveSession } from "./resolve.js";
|
|
35
|
+
import { LESSONS_FILE, READ_ONLY_AGENTS, resolveSession, skillDescription } from "./resolve.js";
|
|
36
36
|
import { MAIL_BODY_CHARS, MAIL_HEADER, publicEvent, renderMail, takeBatch, USER } from "./mailbox.js";
|
|
37
37
|
import { live, normalizePaths, overlapping, renderBoard } from "./board.js";
|
|
38
38
|
import { verifyConfig } from "@anhlp/alp-core/verify";
|
|
@@ -1481,6 +1481,16 @@ Review the process against ALP.md, ${agent}'s AGENT.md and the recorded lessons.
|
|
|
1481
1481
|
compactAtBoundary(sessionId, session);
|
|
1482
1482
|
return { status: "started" };
|
|
1483
1483
|
}
|
|
1484
|
+
async function listCommands(sessionId) {
|
|
1485
|
+
const session = sessions.get(sessionId);
|
|
1486
|
+
if (!session || session.closed) throw new ConversationError("session_busy", "The session is not open");
|
|
1487
|
+
const prefix = session.runtimeKind === "claude" ? `${SKILL_PLUGIN}:` : "";
|
|
1488
|
+
const offered2 = /* @__PURE__ */ new Set([...session.mapping.commands ?? [], ...session.mapping.agent.skills.map((skill) => prefix + skill.name)]);
|
|
1489
|
+
const listed = (session.runtime.commands ? await session.runtime.commands().catch(() => []) : []).filter((command) => offered2.has(command.name));
|
|
1490
|
+
const seen = new Set(listed.map((command) => command.name));
|
|
1491
|
+
const skills = await Promise.all(session.mapping.agent.skills.filter((skill) => !seen.has(prefix + skill.name)).map(async (skill) => ({ name: prefix + skill.name, description: await skillDescription(skill.path), kind: "skill" })));
|
|
1492
|
+
return [...listed, ...skills];
|
|
1493
|
+
}
|
|
1484
1494
|
async function restoreAfterCompaction(sessionId, session, checkpoint) {
|
|
1485
1495
|
const parts = ["Your context was just compacted. In case the summary lost any of it, this is what ALP holds of your work now."];
|
|
1486
1496
|
if (session.parent && session.brief) parts.push(`Your assignment from ${session.parentAgent ?? "your requester"}, as it was given:
|
|
@@ -4100,6 +4110,7 @@ ${interrupted}`), text_elements: [] }] : []
|
|
|
4100
4110
|
const after = mail.length && !wake ? [{ type: "text", text: promptSafe(renderMail(mail, session.parentAgent)), text_elements: [] }] : [];
|
|
4101
4111
|
const inputLayout = { textParts: 1 + before.length + 1 + attached.length + after.length, prompt: 1 + before.length };
|
|
4102
4112
|
const listed = attached.map(({ attachment }) => attachmentMeta(attachment));
|
|
4113
|
+
const invoked = session.runtimeKind === "codex" && origin === "user" && prompt.delivery !== "steer" ? session.mapping.agent.skills.find((skill) => text2.match(/^\/(\S+)(?:\s|$)/)?.[1] === skill.name) : void 0;
|
|
4103
4114
|
const nativeInput = [
|
|
4104
4115
|
{ type: "text", text: promptSafe(CATALOG + JSON.stringify({ inputLayout, ...orchestration, ...listed.length ? { attachments: listed } : {} })), text_elements: [] },
|
|
4105
4116
|
...before,
|
|
@@ -4110,7 +4121,9 @@ ${interrupted}`), text_elements: [] }] : []
|
|
|
4110
4121
|
},
|
|
4111
4122
|
...attached.map(({ attachment, staged }) => ({ type: "text", text: promptSafe(attachmentPart(attachment, staged)), text_elements: [] })),
|
|
4112
4123
|
...images.map((image) => ({ type: "image", url: `data:${image.mimeType};base64,${image.data}` })),
|
|
4113
|
-
...after
|
|
4124
|
+
...after,
|
|
4125
|
+
// "/<skill> ..." from the user loads that ALP skill in Codex, as its own $<skill> does (t-efa3).
|
|
4126
|
+
...invoked ? [{ type: "skill", name: invoked.name, path: invoked.path }] : []
|
|
4114
4127
|
];
|
|
4115
4128
|
const result = prompt.delivery === "steer" ? await session.runtime.request(
|
|
4116
4129
|
"turn/steer",
|
|
@@ -4363,6 +4376,7 @@ ${interrupted}`), text_elements: [] }] : []
|
|
|
4363
4376
|
rebind: (sessionId, binding) => enqueue(() => rebindSession(sessionId, binding)),
|
|
4364
4377
|
reload: (sessionId) => enqueue(() => reloadSession(sessionId)),
|
|
4365
4378
|
compact: (sessionId) => requestCompact(sessionId),
|
|
4379
|
+
commands: (sessionId) => listCommands(sessionId),
|
|
4366
4380
|
previewConfigure: (sessionId, changes) => previewConfigureSession(sessionId, changes),
|
|
4367
4381
|
reconfigure: (sessionId, changes, options2) => enqueue(() => reconfigureSession(sessionId, changes, options2)),
|
|
4368
4382
|
starting: (sessionId) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anhlp/alp-runtime",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ALP runtime module",
|
|
6
6
|
"files": [
|
|
@@ -230,8 +230,8 @@
|
|
|
230
230
|
"node": ">=22.12"
|
|
231
231
|
},
|
|
232
232
|
"dependencies": {
|
|
233
|
-
"@anhlp/alp-core": "0.0.1-beta.
|
|
234
|
-
"@anhlp/alp-protocol": "0.0.1-beta.
|
|
233
|
+
"@anhlp/alp-core": "0.0.1-beta.7",
|
|
234
|
+
"@anhlp/alp-protocol": "0.0.1-beta.7",
|
|
235
235
|
"@anthropic-ai/claude-agent-sdk": "^0.3.292",
|
|
236
236
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
237
237
|
"@agentclientprotocol/sdk": "1.7.0",
|
package/src/claude-transport.ts
CHANGED
|
@@ -11,20 +11,18 @@ import { inputLimitError, POUR_VARS, VAR_NAME, type InputLimits } from './input-
|
|
|
11
11
|
import { claudeToolDetail, resultText } from './tool-detail.js';
|
|
12
12
|
import { CLOSE_REASONS, GATE_KINDS, TASK_STATUSES, TASK_TYPES } from '@anhlp/alp-core/tasks';
|
|
13
13
|
import { commandDecision } from '@anhlp/alp-core/permissions';
|
|
14
|
-
import { packagedInfo } from '@anhlp/alp-core/packaged';
|
|
15
14
|
|
|
16
15
|
// Keep the Claude SDK behind the runtime boundary. Paseo inspects static
|
|
17
16
|
// imports while compiling plugin entrypoints, including their declaration
|
|
18
17
|
// graph; the SDK is a daemon-only optional runtime dependency.
|
|
19
18
|
const CLAUDE_SDK = ['@anthropic-ai', 'claude-agent-sdk'].join('/');
|
|
20
|
-
|
|
21
|
-
// registers the import under the package name (scripts/build-binary.mjs).
|
|
22
|
-
const claudeSdk = (): Promise<any> => packagedInfo()?.modules?.[CLAUDE_SDK]?.() ?? import(CLAUDE_SDK);
|
|
19
|
+
const claudeSdk = (): Promise<any> => import(CLAUDE_SDK);
|
|
23
20
|
|
|
24
21
|
type SDKUserMessage = any;
|
|
25
22
|
type SDKMessage = any;
|
|
26
23
|
type ClaudeQuery = AsyncGenerator<SDKMessage, void> & {
|
|
27
24
|
supportedModels(): Promise<Array<{ value: string; displayName: string; description: string; supportedEffortLevels?: string[] }>>;
|
|
25
|
+
supportedCommands(): Promise<Array<{ name: string; description: string; argumentHint?: string }>>;
|
|
28
26
|
usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET(options: { skipBehaviors: boolean }): Promise<any>;
|
|
29
27
|
getContextUsage(options: { detail: 'summary' | 'full' }): Promise<any>;
|
|
30
28
|
interrupt(): Promise<unknown>;
|
|
@@ -225,6 +223,8 @@ type NativeConfig = {
|
|
|
225
223
|
|
|
226
224
|
/** The plugin name ALP's skills are loaded under, so Claude Code calls them alp:<name>. */
|
|
227
225
|
export const SKILL_PLUGIN = 'alp';
|
|
226
|
+
/** Claude's own commands the composer does not offer: ALP does their work its own way (t-efa3). */
|
|
227
|
+
const ALP_HANDLED_COMMANDS = new Set(['clear', 'compact', 'rewind']);
|
|
228
228
|
|
|
229
229
|
/**
|
|
230
230
|
* A Claude Code plugin in `directory` holding the given skills, linked to their own
|
|
@@ -463,6 +463,19 @@ export class ClaudeTransport {
|
|
|
463
463
|
models: (catalog ?? []).map(model => ({ id: `claude:${model.value}`, label: model.displayName,
|
|
464
464
|
description: model.description, thinking: model.supportedEffortLevels })), usage: claudeUsage(usage) };
|
|
465
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* Claude's slash commands, skills included, for the composer (t-f628); none before the session starts.
|
|
468
|
+
* Not the ones whose work ALP does itself (t-efa3): /clear moves Claude to a new conversation ALP does not
|
|
469
|
+
* follow, and /compact and /rewind skip ALP's checkpoint and its rewind of the timeline.
|
|
470
|
+
*/
|
|
471
|
+
async commands() {
|
|
472
|
+
const listed = this.query ? await optionalRead(async () => this.query!.supportedCommands(), 10_000) : undefined;
|
|
473
|
+
return (Array.isArray(listed) ? listed : []).filter(command => typeof command?.name === 'string' && command.name && !ALP_HANDLED_COMMANDS.has(command.name)).map(command => ({
|
|
474
|
+
name: command.name, description: typeof command.description === 'string' ? command.description : '',
|
|
475
|
+
...(command.argumentHint ? { argumentHint: command.argumentHint } : {}),
|
|
476
|
+
kind: command.name.startsWith(`${SKILL_PLUGIN}:`) ? 'skill' as const : 'command' as const,
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
466
479
|
async initialize() {}
|
|
467
480
|
|
|
468
481
|
/** The models Claude offers now, from a Claude process that sends no prompt and is closed after (t-e5ee). */
|
package/src/contracts.ts
CHANGED
|
@@ -9,10 +9,15 @@ import type { AntigravityProvider } from './antigravity-transport.js';
|
|
|
9
9
|
import type { GitHubRunner } from './github.js';
|
|
10
10
|
import type { AttachmentReader } from './attachments.js';
|
|
11
11
|
|
|
12
|
+
/** A slash command or skill an agent's composer offers after "/" (t-f628). */
|
|
13
|
+
export type RuntimeCommand = { name: string; description: string; argumentHint?: string; kind: 'command' | 'skill' };
|
|
14
|
+
|
|
12
15
|
export type RuntimeTransport = {
|
|
13
16
|
request(method: string, params: any): Promise<any>;
|
|
14
17
|
initialize(): Promise<void>;
|
|
15
18
|
orchestrationContext?: () => Promise<unknown>;
|
|
19
|
+
/** The runtime's own slash commands and skills for the composer (t-f628); omitted, the runtime offers none. */
|
|
20
|
+
commands?: () => Promise<RuntimeCommand[]>;
|
|
16
21
|
onNotification(listener: (method: string, params: any) => void): void;
|
|
17
22
|
onFailure(listener: (error: unknown) => void): void;
|
|
18
23
|
close(): Promise<void>;
|
|
@@ -238,6 +243,8 @@ export type AlpRuntime = {
|
|
|
238
243
|
reload?(sessionId: string): Promise<SessionSnapshot>;
|
|
239
244
|
/** Compacts a root's context at its next turn boundary, with a checkpoint main writes by skill compact (t-0e56). */
|
|
240
245
|
compact?(sessionId: string): { status: 'started' | 'deferred' | 'running' };
|
|
246
|
+
/** The slash commands and skills a live session's composer offers (t-f628): its runtime's, then its ALP skills. */
|
|
247
|
+
commands?(sessionId: string): Promise<RuntimeCommand[]>;
|
|
241
248
|
/**
|
|
242
249
|
* Holds the turns the runtime would start by itself on this session (mail wakes) while a lifecycle
|
|
243
250
|
* operation changes its conversation (a rewind, later a reload or live configure): mail stays queued
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export { createAlpRuntime, DEFAULT_TEAM, WorkspaceMutationError } from './runtime.js';
|
|
3
3
|
export type { WorkspaceMutationReason, AlpRuntime, RuntimeOptions, OpenOptions, RuntimeTransport, PromptInput, PromptContent, SessionPreview } from './runtime.js';
|
|
4
4
|
export { ConversationError } from './contracts.js';
|
|
5
|
-
export type { BranchRequest, ConversationErrorReason, NativeBase, NativeBinding, ConfigureChanges, ConfigureResult, ConfigurePreview, EffectiveConfig } from './contracts.js';
|
|
5
|
+
export type { RuntimeCommand, BranchRequest, ConversationErrorReason, NativeBase, NativeBinding, ConfigureChanges, ConfigureResult, ConfigurePreview, EffectiveConfig } from './contracts.js';
|
|
6
6
|
export type { AlpEvent, AlpError, Envelope, SessionSnapshot, TimelineItem, TurnOrigin, AssignmentSnapshot, UserQuestion, TreeStatus, SessionState } from './events.js';
|
|
7
7
|
export { resolveSession, InstructionsAdapter, skillDescription } from './resolve.js';
|
|
8
8
|
export type { SessionSpec, HostMcpServer, ResolvedSession, RuntimeKind } from './resolve.js';
|
package/src/resolve.ts
CHANGED
|
@@ -223,6 +223,8 @@ export async function resolveSession(spec: SessionSpec, options: { templates?: R
|
|
|
223
223
|
mcp, env: { ...spec.env }, persist: spec.persist ?? false, keepThread: spec.keepThread ?? false,
|
|
224
224
|
// ALPD §57: the window the agent works in before its runtime compacts; absent, the model's.
|
|
225
225
|
...(agent.context ? { context: agent.context } : {}),
|
|
226
|
+
// t-efa3: the runtime's own commands and skills the "/" list offers; its ALP skills always.
|
|
227
|
+
commands: Array.isArray(profile?.commands) ? profile.commands.filter((name: unknown): name is string => typeof name === 'string') : [] as string[],
|
|
226
228
|
autocompact: typeof profile?.autocompact === 'number' ? profile.autocompact as number : typeof agent.autocompact === 'number' ? agent.autocompact : undefined,
|
|
227
229
|
// t-0e56: when main's context is compacted at a turn boundary.
|
|
228
230
|
compact: compactSettings(projectSettings.compact),
|
package/src/runtime.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { createBoardDomain } from './board-domain.js';
|
|
|
9
9
|
import { ATTACHMENT_ROUTES, STAGED_PATH, attachmentPart, createAttachmentStager, runtimeAttachment, stagingExposure, type AttachmentReader, type AttachmentRoute } from './attachments.js';
|
|
10
10
|
import type { RuntimeAttachment } from '@anhlp/alp-protocol/session';
|
|
11
11
|
import { createWorktreeDomain } from './worktree-domain.js';
|
|
12
|
-
import { type RuntimeTransport, type RuntimeOptions, type OpenOptions, type PromptContent, type PromptInput, type AlpRuntime, type SessionPreview, type RecoveryOutcome, type Pause, type PauseState, type RecallAnswer, type ScheduleHandler, type BranchRequest, type NativeBinding, type ConfigurePreview, type ConfigureResult, type ConversationErrorReason, ConversationError } from './contracts.js';
|
|
12
|
+
import { type RuntimeTransport, type RuntimeOptions, type OpenOptions, type PromptContent, type PromptInput, type AlpRuntime, type SessionPreview, type RecoveryOutcome, type Pause, type PauseState, type RecallAnswer, type ScheduleHandler, type BranchRequest, type NativeBinding, type ConfigurePreview, type ConfigureResult, type ConversationErrorReason, type RuntimeCommand, ConversationError } from './contracts.js';
|
|
13
13
|
import { claudeCut, codexForkEnd, codexForkRefusal, pendingChain, type ChainEntry } from './conversation.js';
|
|
14
14
|
export type { RuntimeTransport, RuntimeOptions, OpenOptions, PromptContent, PromptInput, AlpRuntime, SessionPreview, RecoveryOutcome, Pause, PauseState, RecallAnswer } from './contracts.js';
|
|
15
15
|
export { DEFAULT_TEAM } from './contracts.js';
|
|
@@ -36,7 +36,7 @@ import { isTrusted, trustProject } from '@anhlp/alp-core/trust';
|
|
|
36
36
|
import { listTeams, teamOf } from '@anhlp/alp-core/teams';
|
|
37
37
|
import { CONFIGURABLE, changesOf, effectiveOf, executablesOf, nativeModelOf, offered, type ConfigureChange, type ConfigureChanges, type EffectiveConfig } from './configure.js';
|
|
38
38
|
import { anyModel, offers, profileModel, selectedProfile } from '@anhlp/alp-core/profiles';
|
|
39
|
-
import { LESSONS_FILE, READ_ONLY_AGENTS, resolveSession, type ResolvedSession, type RuntimeKind, type SessionSpec } from './resolve.js';
|
|
39
|
+
import { LESSONS_FILE, READ_ONLY_AGENTS, resolveSession, skillDescription, type ResolvedSession, type RuntimeKind, type SessionSpec } from './resolve.js';
|
|
40
40
|
import { MAIL_BODY_CHARS, MAIL_HEADER, publicEvent, renderMail, takeBatch, USER, type MailEvent } from './mailbox.js';
|
|
41
41
|
import type { AlpEvent, AssignmentSnapshot, Envelope, SessionSnapshot, TurnOrigin, UserQuestion } from './events.js';
|
|
42
42
|
import { live, normalizePaths, overlapping, renderBoard, type Pin } from './board.js';
|
|
@@ -1798,6 +1798,22 @@ export function createAlpRuntime(options: RuntimeOptions = {}): AlpRuntime {
|
|
|
1798
1798
|
return { status: 'started' as const };
|
|
1799
1799
|
}
|
|
1800
1800
|
|
|
1801
|
+
/**
|
|
1802
|
+
* The composer's "/" list for a live session (t-f628): the agent's ALP skills, as Claude names them
|
|
1803
|
+
* (`alp:<name>`), and only the runtime's own commands and skills its team settings name (t-efa3).
|
|
1804
|
+
*/
|
|
1805
|
+
async function listCommands(sessionId: string): Promise<RuntimeCommand[]> {
|
|
1806
|
+
const session = sessions.get(sessionId);
|
|
1807
|
+
if (!session || session.closed) throw new ConversationError('session_busy', 'The session is not open');
|
|
1808
|
+
const prefix = session.runtimeKind === 'claude' ? `${SKILL_PLUGIN}:` : '';
|
|
1809
|
+
const offered = new Set([...session.mapping.commands ?? [], ...session.mapping.agent.skills.map(skill => prefix + skill.name)]);
|
|
1810
|
+
const listed = (session.runtime.commands ? await session.runtime.commands().catch(() => [] as RuntimeCommand[]) : []).filter(command => offered.has(command.name));
|
|
1811
|
+
const seen = new Set(listed.map(command => command.name));
|
|
1812
|
+
const skills = await Promise.all(session.mapping.agent.skills.filter(skill => !seen.has(prefix + skill.name))
|
|
1813
|
+
.map(async skill => ({ name: prefix + skill.name, description: await skillDescription(skill.path), kind: 'skill' as const })));
|
|
1814
|
+
return [...listed, ...skills];
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1801
1817
|
/** What ALP holds of a session's work, told to it after a compaction (ALPD §57). */
|
|
1802
1818
|
async function restoreAfterCompaction(sessionId: string, session: Session, checkpoint?: string) {
|
|
1803
1819
|
const parts = ['Your context was just compacted. In case the summary lost any of it, this is what ALP holds of your work now.'];
|
|
@@ -4812,6 +4828,8 @@ export function createAlpRuntime(options: RuntimeOptions = {}): AlpRuntime {
|
|
|
4812
4828
|
const after = mail.length && !wake ? [{ type: 'text', text: promptSafe(renderMail(mail, session.parentAgent)), text_elements: [] }] : [];
|
|
4813
4829
|
const inputLayout: InputLayout = { textParts: 1 + before.length + 1 + attached.length + after.length, prompt: 1 + before.length };
|
|
4814
4830
|
const listed = attached.map(({ attachment }) => attachmentMeta(attachment));
|
|
4831
|
+
const invoked = session.runtimeKind === 'codex' && origin === 'user' && prompt.delivery !== 'steer'
|
|
4832
|
+
? session.mapping.agent.skills.find(skill => text.match(/^\/(\S+)(?:\s|$)/)?.[1] === skill.name) : undefined;
|
|
4815
4833
|
const nativeInput = [
|
|
4816
4834
|
{ type: 'text', text: promptSafe(CATALOG + JSON.stringify({ inputLayout, ...(orchestration as object), ...(listed.length ? { attachments: listed } : {}) })), text_elements: [] },
|
|
4817
4835
|
...before,
|
|
@@ -4823,6 +4841,8 @@ export function createAlpRuntime(options: RuntimeOptions = {}): AlpRuntime {
|
|
|
4823
4841
|
...attached.map(({ attachment, staged }) => ({ type: 'text', text: promptSafe(attachmentPart(attachment, staged)), text_elements: [] })),
|
|
4824
4842
|
...images.map(image => ({ type: 'image', url: `data:${image.mimeType};base64,${image.data}` })),
|
|
4825
4843
|
...after,
|
|
4844
|
+
// "/<skill> ..." from the user loads that ALP skill in Codex, as its own $<skill> does (t-efa3).
|
|
4845
|
+
...(invoked ? [{ type: 'skill', name: invoked.name, path: invoked.path }] : []),
|
|
4826
4846
|
];
|
|
4827
4847
|
|
|
4828
4848
|
const result =
|
|
@@ -5101,6 +5121,7 @@ export function createAlpRuntime(options: RuntimeOptions = {}): AlpRuntime {
|
|
|
5101
5121
|
|
|
5102
5122
|
reload: sessionId => enqueue(() => reloadSession(sessionId)),
|
|
5103
5123
|
compact: (sessionId: string) => requestCompact(sessionId),
|
|
5124
|
+
commands: (sessionId: string) => listCommands(sessionId),
|
|
5104
5125
|
|
|
5105
5126
|
previewConfigure: (sessionId, changes) => previewConfigureSession(sessionId, changes),
|
|
5106
5127
|
|