@cotal-ai/connector-jcode 0.170.0 → 0.171.0

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.
Binary file
Binary file
@@ -0,0 +1,78 @@
1
+ import { type Server } from "node:net";
2
+ import { HarnessError } from "@1jehuang/jcode-sdk";
3
+ import { type PresenceCondition } from "@cotal-ai/core";
4
+ import { MeshAgent, type AgentConfig } from "@cotal-ai/connector-core";
5
+ /** How long a stop waits for the TUI to exit after SIGTERM, and again after SIGKILL. A TUI exits in
6
+ * milliseconds; the bound keeps a wedged one from eating the grace the private tree needs. */
7
+ export declare const TUI_STOP_GRACE_MS = 1000;
8
+ /** How long a run may hold the dispatch gate waiting for its own acknowledgement (#1233).
9
+ *
10
+ * Matches the SDK's `acceptTimeoutMs` default, because that is the point past which `sendMessage`
11
+ * stops waiting anyway (jcode-sdk client.js:317), so a longer value here could only hold the gate
12
+ * after the thing it is waiting for has already given up. It is a CEILING, not a delay: the gate is
13
+ * released the moment the acknowledgement arrives, which is single-digit milliseconds on a healthy
14
+ * seat. A Harness that never acknowledges therefore costs one bounded wait, not a wedged gate. */
15
+ export declare const RUN_ACCEPT_WINDOW_MS = 10000;
16
+ /** One bridge recovery remains bounded, but it is bounded by time rather than one launch/attach
17
+ * outcome. A loaded host can lose a transient replacement race without turning that into a
18
+ * second provider close or an unbounded relaunch loop. The window opens at the close, so tearing
19
+ * down the broken tree spends it too. Exported so a test waiting on a recovery step allows the
20
+ * host the same window instead of a shorter guess. */
21
+ export declare const BRIDGE_RECOVERY_WINDOW_MS = 60000;
22
+ export declare function readinessTurnTimeoutMs(): number;
23
+ /**
24
+ * Override for the SDK's per-request reply timeout, which defaults to 30000ms.
25
+ *
26
+ * Exists so a fixture can make a soft-interrupt timeout happen in seconds instead of half a minute.
27
+ * It is NOT a remedy for #1233 and must never be used as one: lengthening this bound only makes the
28
+ * stall take longer to appear, and shortening it makes it appear sooner. What the fix changes is
29
+ * what happens AFTER the timeout, which is why this knob is validated the same way as the readiness
30
+ * bound and otherwise left alone.
31
+ */
32
+ export declare function requestTimeoutOverrideMs(): number | undefined;
33
+ export declare const PERMANENT_BRIDGE_RECOVERY_CODES: Set<string>;
34
+ export declare const PERMANENT_BRIDGE_CONNECT_CAUSE_CODES: Set<string>;
35
+ /** Recovery retries availability races, not a refusal that another attempt cannot change. */
36
+ export declare function permanentBridgeRecoveryFailure(error: unknown): error is HarnessError;
37
+ interface RelayEndpoint {
38
+ /** The owner-only directory that holds {@link path}. Empty on Windows, which uses a named pipe. */
39
+ dir: string;
40
+ path: string;
41
+ token: string;
42
+ }
43
+ /** A failed turn's condition, relayed from the Harness's own error code. Only a `HarnessError` is
44
+ * relayed: it is what the Harness reported. A code outside the closed set reads `failed`, with
45
+ * the native code kept as `source`. Without this the seat read `waiting` with the error only in
46
+ * its private log (#618). */
47
+ export declare function jcodeTurnCondition(error: unknown, since?: number): PresenceCondition | undefined;
48
+ /** Jcode acknowledges a plain send with `message_accepted` before it checks whether this connection
49
+ * is still processing a message, and then refuses the send with this error. The acknowledgement is
50
+ * therefore no proof that the model received the text. */
51
+ export declare function isJcodeBusyRefusal(error: unknown): boolean;
52
+ export declare function privateAgentHome(space: string, name: string): string;
53
+ /** Jcode deliberately overlays project `.jcode/mcp.json`, `.mcp.json`, and `.claude/mcp.json`
54
+ * over its private home. A same-name project entry could replace the connector's cotal bridge, or
55
+ * add a server the operator never opted to share. The Harness API has no isolation switch for this
56
+ * source set, so refuse the whole launch instead of claiming our private home is sufficient. A home
57
+ * directory counts too: its `.jcode/mcp.json` is Jcode's own global file, read here as a project's. */
58
+ export declare function assertNoProjectMcpConfig(cwd: string): void;
59
+ export declare function writeMcpConfig(home: string, relay: RelayEndpoint, config: AgentConfig): void;
60
+ /**
61
+ * Where this launch keeps its tool relay socket.
62
+ *
63
+ * The socket used to sit at the top level of the shared temp directory. Anything that empties that
64
+ * directory — a distribution's periodic cleaner, or a self-test whose recursive cleanup escaped its
65
+ * own root — unlinked the control path of every live seat at once. The host kept listening on the
66
+ * now-nameless inode, so every `cotal_*` call failed with `connect ENOENT` and the only recovery was
67
+ * a respawn, which discards the session's context (#1625). One private per-launch directory keeps
68
+ * the socket out of a top-level sweep, and `startRelay` re-binds the path if it disappears anyway.
69
+ */
70
+ export declare function relayEndpoint(space: string, name: string): RelayEndpoint;
71
+ export declare function instructions(config: AgentConfig, persona: string | undefined): string;
72
+ export declare function startRelay(agent: MeshAgent, config: AgentConfig, endpoint: RelayEndpoint): Promise<Server>;
73
+ /** Close the relay and take its private directory with it, so a retired launch leaves nothing. */
74
+ export declare function retireRelay(server: Server | undefined, endpoint: RelayEndpoint): Promise<void>;
75
+ export declare const SEAT_ATTRIBUTION_ENV: ReadonlySet<string>;
76
+ export declare function noCotalEnv(): NodeJS.ProcessEnv;
77
+ export {};
78
+ //# sourceMappingURL=host-support.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-support.d.ts","sourceRoot":"","sources":["../src/host-support.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAGrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAiB,KAAK,iBAAiB,EAA8B,MAAM,gBAAgB,CAAC;AAInG,OAAO,EAAE,SAAS,EAA2C,KAAK,WAAW,EAAmB,MAAM,0BAA0B,CAAC;AAKjI;+FAC+F;AAC/F,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AACvC;;;;;;mGAMmG;AACnG,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAC3C;;;;uDAIuD;AACvD,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,wBAAgB,sBAAsB,IAAI,MAAM,CAO/C;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,SAAS,CAO7D;AAED,eAAO,MAAM,+BAA+B,aAQ1C,CAAC;AACH,eAAO,MAAM,oCAAoC,aAAsB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,CAQnD,CAAC;AAEH,wBAAgB,UAAU,IAAI,MAAM,CAAC,UAAU,CAI9C"}
package/dist/host.d.ts CHANGED
@@ -1,17 +1,3 @@
1
- import { HarnessError } from "@1jehuang/jcode-sdk";
2
- /** One bridge recovery remains bounded, but it is bounded by time rather than one launch/attach
3
- * outcome. A loaded host can lose a transient replacement race without turning that into a
4
- * second provider close or an unbounded relaunch loop. The window opens at the close, so tearing
5
- * down the broken tree spends it too. Exported so a test waiting on a recovery step allows the
6
- * host the same window instead of a shorter guess. */
7
- export declare const BRIDGE_RECOVERY_WINDOW_MS = 60000;
8
- export declare const PERMANENT_BRIDGE_RECOVERY_CODES: Set<string>;
9
- export declare const PERMANENT_BRIDGE_CONNECT_CAUSE_CODES: Set<string>;
10
- /** Recovery retries availability races, not a refusal that another attempt cannot change. */
11
- export declare function permanentBridgeRecoveryFailure(error: unknown): error is HarnessError;
12
- /** Jcode acknowledges a plain send with `message_accepted` before it checks whether this connection
13
- * is still processing a message, and then refuses the send with this error. The acknowledgement is
14
- * therefore no proof that the model received the text. */
15
- export declare function isJcodeBusyRefusal(error: unknown): boolean;
1
+ export { BRIDGE_RECOVERY_WINDOW_MS, PERMANENT_BRIDGE_RECOVERY_CODES, PERMANENT_BRIDGE_CONNECT_CAUSE_CODES, permanentBridgeRecoveryFailure, isJcodeBusyRefusal, } from "./host-support.js";
16
2
  export declare function runJcodeHost(): Promise<void>;
17
3
  //# sourceMappingURL=host.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAqE,MAAM,qBAAqB,CAAC;AAmFtH;;;;uDAIuD;AACvD,eAAO,MAAM,yBAAyB,QAAS,CAAC;AA6BhD,eAAO,MAAM,+BAA+B,aAQ1C,CAAC;AACH,eAAO,MAAM,oCAAoC,aAAsB,CAAC;AAExE,6FAA6F;AAC7F,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAMpF;AAwBD;;2DAE2D;AAC3D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE1D;AA+OD,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CA86DlD"}
1
+ {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAqFA,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,oCAAoC,EACpC,8BAA8B,EAC9B,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAE3B,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAq8DlD"}