@qilin-agent/acp 0.0.0-stage → 3.1.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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Pure translation between the harness lifecycle and the automation-only ACP wire.
3
+ * @module @qilin-agent/acp/codec
4
+ */
5
+ import type { StopReason } from '@agentclientprotocol/sdk';
6
+ import type { TurnEndReason } from '@qilin-agent/session';
7
+ /**
8
+ * Map a harness turn ending to ACP's terminal reason vocabulary.
9
+ * @param reason - harness turn outcome.
10
+ * @returns the closest legal ACP stop reason.
11
+ */
12
+ export declare function turnEndToStopReason(reason: TurnEndReason): StopReason;
13
+ //# sourceMappingURL=codec.d.ts.map
@@ -0,0 +1,50 @@
1
+ /** ACP wire-content admission and projection owned by the ACP adapter. @module */
2
+ import type { ContentBlock as AcpContentBlock } from '@agentclientprotocol/sdk';
3
+ import type { Context } from '@qilin-agent/kylin';
4
+ import type { ModelSelection } from '@qilin-agent/agent';
5
+ import type { ContentBlock } from '@qilin-agent/llm';
6
+ /** Content-admission failure category used by the protocol handler. */
7
+ export type AcpContentFailureKind = 'invalid' | 'internal';
8
+ /** Error with a stable ACP request-failure category and no raw binary payload. */
9
+ export declare class AcpContentError extends Error {
10
+ /** Whether the bridge should report invalid params or an internal failure. */
11
+ readonly kind: AcpContentFailureKind;
12
+ /**
13
+ * @param message - safe protocol-facing detail without inline binary data.
14
+ * @param kind - request-failure category.
15
+ * @param options - optional causal chain for diagnostics.
16
+ */
17
+ constructor(message: string, kind: AcpContentFailureKind, options?: ErrorOptions);
18
+ }
19
+ /**
20
+ * Determine whether initialization may truthfully advertise inline image prompts.
21
+ * Unknown service, route, capability, or deployment media support is negative.
22
+ * @param ctx - bridge context carrying optional attachment and model services.
23
+ * @param provider - configured provider route used for newly created sessions.
24
+ * @param model - configured exact model id used for newly created sessions.
25
+ * @returns whether this bridge can admit images at initialization time.
26
+ */
27
+ export declare function supportsAcpImagePrompts(ctx: Context, provider: string | undefined, model: string | undefined): Promise<boolean>;
28
+ /**
29
+ * Admit one ACP prompt into ordered durable core content.
30
+ * Every wire block and image is validated before the ordered image batch starts
31
+ * writing; cancellation after a successful content-addressed write may leave an
32
+ * unreachable object but never queues a late user message.
33
+ * @param ctx - bridge context carrying attachment and model services.
34
+ * @param route - selection pinned to the accepted prompt.
35
+ * @param prompt - untrusted ACP prompt blocks in wire order.
36
+ * @param imageEnabled - capability result advertised during initialization.
37
+ * @param signal - admission cancellation signal.
38
+ * @returns core content with durable image references in wire order.
39
+ */
40
+ export declare function admitAcpPrompt(ctx: Context, route: ModelSelection | undefined, prompt: readonly AcpContentBlock[], imageEnabled: boolean, signal: AbortSignal): Promise<ContentBlock[]>;
41
+ /**
42
+ * Translate one committed assistant block to ACP wire content.
43
+ * Images are re-read and integrity-verified before inline base64 delivery;
44
+ * unsupported core output blocks stay off the automation wire.
45
+ * @param ctx - bridge context carrying the authoritative attachment store.
46
+ * @param block - committed core assistant block.
47
+ * @returns ACP text/image content, or undefined for non-output blocks.
48
+ */
49
+ export declare function assistantBlockToAcp(ctx: Context, block: ContentBlock): Promise<AcpContentBlock | undefined>;
50
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Automation-only Agent Client Protocol server over JSON-RPC stdio.
3
+ *
4
+ * The bridge exposes persistent harness sessions to trusted programmatic
5
+ * clients. It carries standard configuration, MCP mounts, prompt content,
6
+ * committed semantic updates, cancellation, and one-shot permission decisions;
7
+ * presentation and human-interaction features stay with the harness's UI modules.
8
+ *
9
+ * @module @qilin-agent/acp
10
+ */
11
+ import type { Context } from '@qilin-agent/kylin';
12
+ import Schema from '@qilin-agent/schemastery';
13
+ import { type Stream } from '@agentclientprotocol/sdk';
14
+ export declare const name = "acp";
15
+ /** Core services required by the standard automation controls. */
16
+ export declare const inject: string[];
17
+ /** Plugin config: the provider/model selection used for each ACP-created agent. */
18
+ export interface AcpConfig {
19
+ /** Provider route for created agents. */
20
+ provider?: string;
21
+ /** Model name for created agents. */
22
+ model?: string;
23
+ /** Maximum summaries returned by one session/list page. */
24
+ sessionListPageSize?: number;
25
+ /** Runtime-only transport override; production uses stdio. */
26
+ stream?: Stream;
27
+ }
28
+ export declare const Config: Schema<AcpConfig>;
29
+ /**
30
+ * Mount the automation-only ACP server.
31
+ * @param ctx - Cordis context carrying the agent factory and session events.
32
+ * @param config - Initial provider/model selection and optional test transport.
33
+ */
34
+ export declare function apply(ctx: Context, config: AcpConfig): void;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ /** Standard ACP MCP-server declarations translated into Agent-scoped QILIN MCP clients. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { McpServer } from '@agentclientprotocol/sdk';
4
+ /** Caller-correctable MCP declaration failure. */
5
+ export declare class AcpMcpConfigError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ /**
9
+ * Validate and mount one session's complete standard MCP server list before Agent publication.
10
+ * @param agentCtx - unpublished Agent scope that owns the MCP clients and tools.
11
+ * @param servers - stable ACP stdio or HTTP server declarations.
12
+ * @param sessionCwd - canonical primary workspace used by stdio servers.
13
+ */
14
+ export declare function mountAcpMcpServers(agentCtx: Context, servers: readonly McpServer[], sessionCwd: string): Promise<void>;
15
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1,62 @@
1
+ /** Standard ACP session configuration over one Agent's model selection. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { SessionConfigOption } from '@agentclientprotocol/sdk';
4
+ import { type ModelSelection, type ModelSelectionRef } from '@qilin-agent/agent';
5
+ import { type LlmRuntime } from '@qilin-agent/llm';
6
+ /** Caller-correctable session configuration failure. */
7
+ export declare class AcpModelConfigError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ /** Project and mutate one Agent's provider/model/reasoning selection through ACP config options. */
11
+ export declare class AcpModelControl {
12
+ private readonly llm;
13
+ /** Scoped selection reference consumed by Agent request assembly. */
14
+ readonly selection: ModelSelectionRef;
15
+ private tail;
16
+ private selected;
17
+ private turnSelection;
18
+ private hasResolvedState;
19
+ constructor(llm: LlmRuntime, initial: ModelSelection | undefined);
20
+ /**
21
+ * Install request/prompt consistency listeners in the unpublished Agent scope.
22
+ * @param agentCtx - Agent scope that consumes this selection.
23
+ */
24
+ install(agentCtx: Context): void;
25
+ /**
26
+ * Snapshot the selection attached to the next accepted ACP prompt.
27
+ * @returns a detached future selection, or undefined when listeners supply the route.
28
+ */
29
+ snapshot(): ModelSelection | undefined;
30
+ /**
31
+ * Pin one admitted ACP message's selection for every step in its turn.
32
+ * @param turn - admitted Agent turn.
33
+ * @param selection - exact prompt-admission selection.
34
+ */
35
+ pinTurn(turn: number, selection: ModelSelection): void;
36
+ /**
37
+ * Release only the exact completed turn's routing override.
38
+ * @param turn - completed Agent turn.
39
+ */
40
+ releaseTurn(turn: number): void;
41
+ /**
42
+ * Return the complete standard config-option state after prior mutations settle.
43
+ * @param signal - optional catalog and exact-model cancellation.
44
+ * @returns all current standard configuration options.
45
+ */
46
+ options(signal?: AbortSignal): Promise<SessionConfigOption[]>;
47
+ /**
48
+ * Set one advertised option and return the complete resulting option state.
49
+ * @param configId - standard option id.
50
+ * @param value - opaque selected value returned by a previous option state.
51
+ * @param signal - optional catalog and exact-model cancellation.
52
+ * @returns all standard options after the serialized mutation.
53
+ */
54
+ set(configId: string, value: unknown, signal?: AbortSignal): Promise<SessionConfigOption[]>;
55
+ /** Keep concurrent client mutations in receive order without wedging after rejection. */
56
+ private serialize;
57
+ /** Build detached model choices and the dependent reasoning option. */
58
+ private state;
59
+ /** Validate an exact route and retain only Agent-owned selection fields. */
60
+ private resolveSelection;
61
+ }
62
+ //# sourceMappingURL=model-control.d.ts.map
@@ -0,0 +1,128 @@
1
+ /** One standard ACP session's Agent, configuration, prompt, update, and teardown lifecycle. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import { type McpServer, type PromptRequest, type PromptResponse, type SessionConfigOption, type SessionNotification } from '@agentclientprotocol/sdk';
4
+ import type { Agent, AgentOptions, AgentStatus, ModelSelection } from '@qilin-agent/agent';
5
+ import { type UserMessage } from '@qilin-agent/llm';
6
+ import { type Session, type SessionEvent, type SessionId } from '@qilin-agent/session';
7
+ /** Inputs shared by fresh and resumed ACP session construction. */
8
+ interface AcpSessionBuildOptions {
9
+ cwd: string;
10
+ mcpServers: readonly McpServer[];
11
+ agentOptions: AgentOptions;
12
+ fallbackSelection: ModelSelection | undefined;
13
+ signal: AbortSignal;
14
+ notify: (notification: SessionNotification) => Promise<void>;
15
+ }
16
+ /** Fresh ACP session construction inputs. */
17
+ export interface CreateAcpSessionOptions extends AcpSessionBuildOptions {
18
+ sessionId: SessionId;
19
+ }
20
+ /** Persisted ACP session construction inputs. */
21
+ export interface ResumeAcpSessionOptions extends AcpSessionBuildOptions {
22
+ sessionId: SessionId;
23
+ }
24
+ /**
25
+ * Per-session ACP module. It owns the unpublished Agent composition, selected
26
+ * route, one-prompt admission slot, ordered standard updates, and memoized
27
+ * quiescent teardown.
28
+ */
29
+ export declare class AcpSession {
30
+ private readonly ctx;
31
+ private readonly notify;
32
+ /** The exact top-level Agent owned by this ACP session. */
33
+ readonly agent: Agent;
34
+ private readonly modelControl;
35
+ private outputTail;
36
+ private inflight;
37
+ private closing;
38
+ private readonly pendingSelections;
39
+ private constructor();
40
+ private readonly disposeAgent;
41
+ /**
42
+ * Compose a fresh Agent and all requested MCP clients before publication.
43
+ * @param ctx - ACP plugin context with Agent, LLM, and persistence services.
44
+ * @param options - fresh session identity, workspace, route, MCP, and notifier.
45
+ * @returns the fully composed per-session module.
46
+ */
47
+ static create(ctx: Context, options: CreateAcpSessionOptions): Promise<AcpSession>;
48
+ /**
49
+ * Restore a persisted Agent and compose the request's fresh MCP connections.
50
+ * @param ctx - ACP plugin context with Agent, LLM, and persistence services.
51
+ * @param options - persisted identity, workspace, fallback route, MCP, and notifier.
52
+ * @returns the restored per-session module.
53
+ */
54
+ static resume(ctx: Context, options: ResumeAcpSessionOptions): Promise<AcpSession>;
55
+ /**
56
+ * Whether this module owns an exact Agent reference.
57
+ * @param agent - Agent observed on a scoped runtime event.
58
+ * @returns true only for this session's owned Agent.
59
+ */
60
+ owns(agent: Agent): boolean;
61
+ /**
62
+ * Whether this module owns an exact Session reference.
63
+ * @param session - Session observed on a durable event.
64
+ * @returns true only for this session's owned Session.
65
+ */
66
+ ownsSession(session: Session): boolean;
67
+ /**
68
+ * Return the complete standard model configuration state.
69
+ * @param signal - optional request cancellation.
70
+ * @returns provider-grouped model and exact-model reasoning options.
71
+ */
72
+ configOptions(signal?: AbortSignal): Promise<SessionConfigOption[]>;
73
+ /**
74
+ * Apply one standard configuration option to later ACP turns.
75
+ * @param configId - advertised standard option id.
76
+ * @param value - selected standard option value.
77
+ * @param signal - optional request cancellation.
78
+ * @returns the complete resulting option state.
79
+ */
80
+ setConfig(configId: string, value: unknown, signal?: AbortSignal): Promise<SessionConfigOption[]>;
81
+ /** Resolve topology state off-chain, then serialize its notification without blocking execution updates. */
82
+ topologyChanged(): void;
83
+ /**
84
+ * Admit one prompt and settle after the root, descendants, and updates finish.
85
+ * @param params - standard ACP prompt request for this session.
86
+ * @param imageEnabled - connection capability advertised at initialization.
87
+ * @param requestSignal - JSON-RPC request cancellation signal.
88
+ * @returns the correlated standard stop reason after ordered updates drain.
89
+ */
90
+ prompt(params: PromptRequest, imageEnabled: boolean, requestSignal?: AbortSignal): Promise<PromptResponse>;
91
+ /** Cancel the active prompt, or autonomous work when no ACP prompt exists. */
92
+ cancel(): void;
93
+ /**
94
+ * Process one durable event and enqueue its standard ACP projections.
95
+ * @param session - exact event-owning Session.
96
+ * @param event - committed durable event.
97
+ */
98
+ onSessionEvent(session: Session, event: SessionEvent): void;
99
+ /**
100
+ * Correlate an accepted user message with its Agent turn and pinned route.
101
+ * @param message - claimed durable inbox message.
102
+ * @param turn - allocated Agent turn.
103
+ */
104
+ onInboxClaimed(message: UserMessage, turn: number): void;
105
+ /**
106
+ * Correlate an Agent interval failure with the active ACP prompt.
107
+ * @param error - original same-process failure.
108
+ */
109
+ onAgentError(error: unknown): void;
110
+ /**
111
+ * Complete cancelled activity without following a later root driver.
112
+ * @param status - the emitted transition, which may precede a reentrant wake.
113
+ */
114
+ onAgentStatus(status: AgentStatus): void;
115
+ /** Await every update queued before this call. */
116
+ drainUpdates(): Promise<void>;
117
+ /**
118
+ * Cancel, drain, flush, and dispose this session once.
119
+ * @param detail - cancellation detail for any prompt still in admission.
120
+ * @returns the shared quiescent teardown promise.
121
+ */
122
+ close(detail: string): Promise<void>;
123
+ private assertActive;
124
+ private cancelPrompt;
125
+ private settleAfterQuiescence;
126
+ }
127
+ export {};
128
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1,26 @@
1
+ /** Standard ACP updates derived from committed QILIN session events. */
2
+ import type { Context } from '@qilin-agent/kylin';
3
+ import type { SessionUpdate } from '@agentclientprotocol/sdk';
4
+ import type { Session, SessionEvent } from '@qilin-agent/session';
5
+ /**
6
+ * Convert one committed assistant message and its context usage in block order.
7
+ * @param ctx - bridge context carrying attachment and token-meter services.
8
+ * @param session - durable session used for context pressure.
9
+ * @param event - committed assistant message event.
10
+ * @returns ordered standard thought, message, and optional usage updates.
11
+ */
12
+ export declare function assistantUpdates(ctx: Context, session: Session, event: SessionEvent<'assistant/message'>): Promise<SessionUpdate[]>;
13
+ /**
14
+ * Start one generic ACP tool lifecycle from the durable call fact.
15
+ * @param event - committed QILIN tool-call event.
16
+ * @returns the standard generic tool-call update.
17
+ */
18
+ export declare function toolCallUpdate(event: SessionEvent<'tool/call'>): SessionUpdate;
19
+ /**
20
+ * Finish one generic ACP tool lifecycle from its committed model-facing result.
21
+ * @param ctx - bridge context carrying the attachment store.
22
+ * @param event - committed QILIN tool-result event.
23
+ * @returns the standard completed or failed tool-call update.
24
+ */
25
+ export declare function toolResultUpdate(ctx: Context, event: SessionEvent<'tool/result'>): Promise<SessionUpdate>;
26
+ //# sourceMappingURL=updates.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@qilin-agent/acp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "Automation-only Agent Client Protocol server for driving QiLin agents over JSON-RPC stdio",
4
+ "version": "3.1.4",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/kkutysllb/QiLin.git",
11
+ "directory": "packages/acp/acp"
12
+ },
13
+ "engines": {
14
+ "node": "^22.19.0 || >=24.0.0"
15
+ },
16
+ "type": "module",
17
+ "main": "lib/index.js",
18
+ "types": "lib/types/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./lib/types/index.d.ts",
22
+ "default": "./lib/index.js"
23
+ },
24
+ "./src/*": "./src/*",
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "lib/index.js",
29
+ "lib/types/**/*.d.ts"
30
+ ],
31
+ "license": "MIT",
32
+ "dependencies": {
33
+ "@agentclientprotocol/sdk": "1.4.0",
34
+ "@qilin-agent/brand": "3.1.4",
35
+ "@qilin-agent/schemastery": "~3.18.3"
36
+ },
37
+ "peerDependencies": {
38
+ "@qilin-agent/kylin": "~4.0.3",
39
+ "@qilin-agent/agent": "3.1.4",
40
+ "@qilin-agent/llm": "3.1.4",
41
+ "@qilin-agent/attachment": "3.1.4",
42
+ "@qilin-agent/session": "3.1.4",
43
+ "@qilin-agent/session-persistence": "3.1.4",
44
+ "@qilin-agent/mcp-client": "3.1.4",
45
+ "@qilin-agent/token-meter": "3.1.4",
46
+ "@qilin-agent/user-approval": "3.1.4"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@qilin-agent/token-meter": {
50
+ "optional": true
51
+ }
52
+ },
53
+ "devDependencies": {
54
+ "@qilin-agent/kylin": "~4.0.3",
55
+ "@qilin-agent/agent-loop": "3.1.4",
56
+ "@qilin-agent/agent": "3.1.4",
57
+ "@qilin-agent/agent-loop-testkit": "3.1.4",
58
+ "@qilin-agent/attachment": "3.1.4",
59
+ "@qilin-agent/llm": "3.1.4",
60
+ "@qilin-agent/mcp-client": "3.1.4",
61
+ "@qilin-agent/session": "3.1.4",
62
+ "@qilin-agent/session-persistence": "3.1.4",
63
+ "@qilin-agent/session-projection": "3.1.4",
64
+ "@qilin-agent/tools": "3.1.4",
65
+ "@qilin-agent/user-approval": "3.1.4",
66
+ "@qilin-agent/session-persistence-jsonl": "3.1.4",
67
+ "@qilin-agent/token-meter": "3.1.4"
68
+ }
6
69
  }