@wrongstack/acp 1.0.24 → 1.0.27

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/agent.js CHANGED
@@ -1691,6 +1691,16 @@ import { treeKill } from "@wrongstack/core/utils/tree-kill";
1691
1691
  var DEFAULT_MAX_FRAME_CHARS = 20 * 1024 * 1024;
1692
1692
  var DEFAULT_MAX_QUEUED_MESSAGES = 1e3;
1693
1693
  var DEFAULT_MAX_QUEUED_CHARS = 32 * 1024 * 1024;
1694
+ function takeLines(pending, chunk) {
1695
+ const lines = [];
1696
+ let start = 0;
1697
+ for (let nl = chunk.indexOf("\n"); nl !== -1; nl = chunk.indexOf("\n", start)) {
1698
+ lines.push(pending + chunk.slice(start, nl));
1699
+ pending = "";
1700
+ start = nl + 1;
1701
+ }
1702
+ return { lines, pending: pending + chunk.slice(start) };
1703
+ }
1694
1704
  function positiveLimit(value, fallback) {
1695
1705
  return value !== void 0 && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
1696
1706
  }
@@ -1778,9 +1788,8 @@ var StdioTransport = class {
1778
1788
  this.claimHandlers.clear();
1779
1789
  }
1780
1790
  onData(chunk) {
1781
- this.buffer += chunk;
1782
- const lines = this.buffer.split("\n");
1783
- this.buffer = lines.pop() ?? "";
1791
+ const { lines, pending } = takeLines(this.buffer, chunk);
1792
+ this.buffer = pending;
1784
1793
  if (this.buffer.length > this.maxFrameChars) {
1785
1794
  this.stderr.write(
1786
1795
  `[wstack-acp frame error] pending frame exceeds ${this.maxFrameChars} characters
@@ -0,0 +1,20 @@
1
+ import type { AgentCapabilities, AuthMethod, SessionId } from '../types/acp-v1.js';
2
+ import type { State } from './acp-request-state.js';
3
+ import { type ACPSessionOpContext } from './acp-session-ops.js';
4
+ import type { ACPSessionOptions } from './acp-session-types.js';
5
+ export interface AcpSessionAuthHost {
6
+ state: State;
7
+ authMethods: AuthMethod[];
8
+ allocId: () => number;
9
+ sendRequest: (id: number, method: string, params: unknown, timeoutMs?: number) => Promise<unknown>;
10
+ agentCapabilities: AgentCapabilities;
11
+ opContext: () => ACPSessionOpContext;
12
+ ensureAuthenticated: () => Promise<void>;
13
+ authenticate: (methodId: string) => Promise<void>;
14
+ opts: ACPSessionOptions;
15
+ }
16
+ export declare function authenticate(host: AcpSessionAuthHost, methodId: string): Promise<void>;
17
+ export declare function logout(host: AcpSessionAuthHost): Promise<void>;
18
+ export declare function createSessionWithAuth(host: AcpSessionAuthHost): Promise<SessionId>;
19
+ export declare function ensureAuthenticated(host: AcpSessionAuthHost): Promise<void>;
20
+ //# sourceMappingURL=acp-session-auth.d.ts.map
@@ -138,5 +138,6 @@ export declare class ACPSession {
138
138
  private progressHandler;
139
139
  private scratch;
140
140
  private resetScratch;
141
+ private acpSessionAuthHost;
141
142
  }
142
143
  //# sourceMappingURL=acp-session.d.ts.map