@cotal-ai/cli 0.137.0 → 0.138.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.
- package/dist/chat/chat-view.d.ts +1 -1
- package/dist/chat/chat-view.d.ts.map +1 -1
- package/dist/chat/controller.d.ts +1 -1
- package/dist/chat/controller.d.ts.map +1 -1
- package/dist/chat/frontend.d.ts +1 -1
- package/dist/chat/frontend.d.ts.map +1 -1
- package/dist/chat/picker.d.ts +1 -1
- package/dist/chat/picker.d.ts.map +1 -1
- package/dist/chat/plain.d.ts +1 -1
- package/dist/chat/plain.d.ts.map +1 -1
- package/dist/chat/stdio-io.d.ts +1 -1
- package/dist/chat/stdio-io.d.ts.map +1 -1
- package/dist/chat/stdio.d.ts +1 -1
- package/dist/chat/stdio.d.ts.map +1 -1
- package/dist/chat/view.d.ts +1 -1
- package/dist/chat/view.d.ts.map +1 -1
- package/dist/commands/agents.d.ts +7 -149
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +15 -723
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/channels.js +1 -1
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.d.ts +1 -24
- package/dist/commands/chat.d.ts.map +1 -1
- package/dist/commands/chat.js +3 -15
- package/dist/commands/chat.js.map +1 -1
- package/dist/console/app.js +1 -1
- package/dist/console/app.js.map +1 -1
- package/package.json +5 -6
- package/dist/chat/engine.d.ts +0 -111
- package/dist/chat/engine.d.ts.map +0 -1
- package/dist/chat/engine.js +0 -225
- package/dist/chat/engine.js.map +0 -1
- package/dist/chat/native-session.d.ts +0 -120
- package/dist/chat/native-session.d.ts.map +0 -1
- package/dist/chat/native-session.js +0 -487
- package/dist/chat/native-session.js.map +0 -1
- package/dist/chat/open-session.d.ts +0 -9
- package/dist/chat/open-session.d.ts.map +0 -1
- package/dist/chat/open-session.js +0 -120
- package/dist/chat/open-session.js.map +0 -1
- package/dist/chat/session.d.ts +0 -230
- package/dist/chat/session.d.ts.map +0 -1
- package/dist/chat/session.js +0 -2
- package/dist/chat/session.js.map +0 -1
- package/dist/chat/static-session.d.ts +0 -62
- package/dist/chat/static-session.d.ts.map +0 -1
- package/dist/chat/static-session.js +0 -236
- package/dist/chat/static-session.js.map +0 -1
- package/dist/chat/user-session.d.ts +0 -22
- package/dist/chat/user-session.d.ts.map +0 -1
- package/dist/chat/user-session.js +0 -180
- package/dist/chat/user-session.js.map +0 -1
- package/dist/lib/attach-client.d.ts +0 -112
- package/dist/lib/attach-client.d.ts.map +0 -1
- package/dist/lib/attach-client.js +0 -528
- package/dist/lib/attach-client.js.map +0 -1
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type MeshTarget } from "@cotal-ai/workspace";
|
|
2
|
-
import { NativeChatSession } from "./native-session.js";
|
|
3
|
-
/** Open mode supplies routing identity only. No credentials, auth rows or authority retirement. */
|
|
4
|
-
export declare function openRoutingChatSession(target: MeshTarget, options: {
|
|
5
|
-
readonly label: string;
|
|
6
|
-
readonly channels: readonly string[];
|
|
7
|
-
readonly reopen: (channel: string) => string;
|
|
8
|
-
}): Promise<NativeChatSession>;
|
|
9
|
-
//# sourceMappingURL=open-session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-session.d.ts","sourceRoot":"","sources":["../../src/chat/open-session.ts"],"names":[],"mappings":"AAeA,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAWxD,mGAAmG;AACnG,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE;IACxE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;CAC9C,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA2F7B"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { CotalEndpoint, dialerFor, dmDurable, dmStream, isConcreteChannel, isConsumerNotFound, isJetStreamMissing, mintLifecycleUid, standaloneConnectOpts, unicastRecvFilter, } from "@cotal-ai/core";
|
|
3
|
-
import { JetStreamApiCodes, jetstreamManager } from "@nats-io/jetstream";
|
|
4
|
-
import { CommandFailure } from "@cotal-ai/workspace";
|
|
5
|
-
import { NativeChatSession } from "./native-session.js";
|
|
6
|
-
const absent = (error) => isConsumerNotFound(error) || isJetStreamMissing(error, JetStreamApiCodes.StreamNotFound);
|
|
7
|
-
const BACKSTOP = "The 600-second inactive threshold is a backstop, not an erasure guarantee; retained messages and interrupted history readers are not erased.";
|
|
8
|
-
/** Open mode supplies routing identity only. No credentials, auth rows or authority retirement. */
|
|
9
|
-
export async function openRoutingChatSession(target, options) {
|
|
10
|
-
if (target.mode !== "open")
|
|
11
|
-
throw new CommandFailure("refused", "UNSUPPORTED", "the routing-only chat adapter requires a recorded open target; no authentication fallback was attempted", { target: { space: target.space } });
|
|
12
|
-
if (!options.label || options.label.length > 128 || options.channels.some((channel) => !isConcreteChannel(channel)))
|
|
13
|
-
throw new CommandFailure("refused", "USAGE_INVALID", "chat requires a label of 1 to 128 characters and concrete initial channels");
|
|
14
|
-
const actor = randomBytes(16).toString("hex");
|
|
15
|
-
const uid = mintLifecycleUid();
|
|
16
|
-
const owner = "local";
|
|
17
|
-
const stream = dmStream(target.space);
|
|
18
|
-
const durable = dmDurable(owner, actor, uid);
|
|
19
|
-
const filter = unicastRecvFilter(target.space, owner, actor);
|
|
20
|
-
let connection;
|
|
21
|
-
let pin;
|
|
22
|
-
const endpoint = new CotalEndpoint({
|
|
23
|
-
space: target.space,
|
|
24
|
-
servers: target.server,
|
|
25
|
-
tls: target.tlsRequired,
|
|
26
|
-
card: { owner, actor, name: options.label, kind: "endpoint", meta: { sessionKind: "chat" } },
|
|
27
|
-
lifecycleUid: uid,
|
|
28
|
-
channels: [...options.channels],
|
|
29
|
-
inactiveThresholdMs: 600_000,
|
|
30
|
-
onConnection: (nc) => { connection = nc; },
|
|
31
|
-
});
|
|
32
|
-
const identity = {
|
|
33
|
-
mode: "open", space: target.space, principal: `${owner}.${actor}`, lifecycleUid: uid, label: options.label,
|
|
34
|
-
// These are routing intent, not broker-enforced ceilings on an open mesh.
|
|
35
|
-
allowSubscribe: [">"], allowPublish: [">"],
|
|
36
|
-
};
|
|
37
|
-
const matches = (info) => info.name === durable && info.stream_name === stream &&
|
|
38
|
-
info.config.durable_name === durable && info.config.filter_subject === filter;
|
|
39
|
-
const retire = async () => {
|
|
40
|
-
// stop() is memoized. A rejected close cannot authorize a consumer delete, even when called
|
|
41
|
-
// after NativeChatSession already attempted that same close.
|
|
42
|
-
try {
|
|
43
|
-
await endpoint.stop();
|
|
44
|
-
}
|
|
45
|
-
catch {
|
|
46
|
-
return { retirement: "not-applicable", connectionClosed: "not-confirmed", message: `Open session connection closure was not confirmed; inbox cleanup was held. ${BACKSTOP}` };
|
|
47
|
-
}
|
|
48
|
-
if (!pin)
|
|
49
|
-
return { retirement: "not-applicable", connectionClosed: "confirmed", message: `Open session closed; inbox creation identity was not captured, so cleanup was held. ${BACKSTOP}` };
|
|
50
|
-
let cleanupConnection;
|
|
51
|
-
let message = "Open session closed; inbox cleanup was not confirmed and was not retried.";
|
|
52
|
-
let closed = true;
|
|
53
|
-
try {
|
|
54
|
-
cleanupConnection = await dialerFor(target.server)({
|
|
55
|
-
servers: target.server, ...standaloneConnectOpts({ tls: target.tlsRequired }),
|
|
56
|
-
timeout: 2_000, reconnect: false, maxReconnectAttempts: 0,
|
|
57
|
-
});
|
|
58
|
-
const jsm = await jetstreamManager(cleanupConnection, { checkAPI: false, timeout: 2_000 });
|
|
59
|
-
const streamInfo = await jsm.streams.info(stream);
|
|
60
|
-
const info = await jsm.consumers.info(stream, durable);
|
|
61
|
-
if (streamInfo.config.name !== stream || streamInfo.created !== pin.streamCreated ||
|
|
62
|
-
!matches(info) || info.created !== pin.consumerCreated) {
|
|
63
|
-
message = "Open session closed; the inbox or stream creation identity changed, so cleanup was held.";
|
|
64
|
-
}
|
|
65
|
-
else if (await jsm.consumers.delete(stream, durable)) {
|
|
66
|
-
try {
|
|
67
|
-
await jsm.consumers.info(stream, durable);
|
|
68
|
-
message = "Open session closed; a consumer is present after the delete acknowledgement, so cleanup remains unconfirmed.";
|
|
69
|
-
}
|
|
70
|
-
catch (error) {
|
|
71
|
-
if (!absent(error))
|
|
72
|
-
throw error;
|
|
73
|
-
message = "Open session closed; its own DM inbox was observed absent. Routing only: no ownership, confinement or revocation.";
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
if (absent(error))
|
|
79
|
-
message = "Open session closed; its own DM inbox was observed absent. Routing only: no ownership, confinement or revocation.";
|
|
80
|
-
// A permission denial, unreadable response or timeout is not absence. Never replay a delete.
|
|
81
|
-
}
|
|
82
|
-
finally {
|
|
83
|
-
if (cleanupConnection) {
|
|
84
|
-
try {
|
|
85
|
-
await cleanupConnection.close();
|
|
86
|
-
}
|
|
87
|
-
catch {
|
|
88
|
-
closed = false;
|
|
89
|
-
}
|
|
90
|
-
if (!cleanupConnection.isClosed())
|
|
91
|
-
closed = false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return { retirement: "not-applicable", connectionClosed: closed ? "confirmed" : "not-confirmed", message: `${message} ${BACKSTOP}${closed ? "" : " The cleanup connection closure was not confirmed."}` };
|
|
95
|
-
};
|
|
96
|
-
// Register the real participant listeners before starting the endpoint. No fabricated session or
|
|
97
|
-
// connector runtime is involved; NativeChatSession owns its endpoint listeners through close().
|
|
98
|
-
const session = new NativeChatSession({ endpoint, identity, retire, reopen: options.reopen });
|
|
99
|
-
try {
|
|
100
|
-
await endpoint.start();
|
|
101
|
-
if (!connection || connection.isClosed())
|
|
102
|
-
throw new Error("the opened transport is unavailable");
|
|
103
|
-
const jsm = await jetstreamManager(connection, { checkAPI: false, timeout: 2_000 });
|
|
104
|
-
const streamInfo = await jsm.streams.info(stream);
|
|
105
|
-
const info = await jsm.consumers.info(stream, durable);
|
|
106
|
-
if (streamInfo.config.name !== stream || !streamInfo.created || !matches(info) || !info.created)
|
|
107
|
-
throw new Error("the own inbox creation identity could not be verified");
|
|
108
|
-
pin = { streamCreated: streamInfo.created, consumerCreated: info.created };
|
|
109
|
-
return session;
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
const close = await session.close();
|
|
113
|
-
throw new CommandFailure("unknown", "OPERATION_UNKNOWN", "the routing-only chat opening did not finish; no automatic retry was made", {
|
|
114
|
-
target: { space: target.space, principal: identity.principal, lifecycleUid: uid },
|
|
115
|
-
native: { outcome: "unknown", detail: { close } },
|
|
116
|
-
remedy: "inspect the original broker before another opening; an unconfirmed inbox remains subject to its inactive backstop",
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
//# sourceMappingURL=open-session.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-session.js","sourceRoot":"","sources":["../../src/chat/open-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAqB,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAQxD,MAAM,MAAM,GAAG,CAAC,KAAc,EAAW,EAAE,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and "Program
|
|
3
|
-
* participants"). This module declares the contract a native admission adapter must satisfy. It
|
|
4
|
-
* contains no admission, no credential, no identity minting and no transport. Nothing here can
|
|
5
|
-
* produce a session: a value of this type exists only when a reviewed per-mode admission adapter
|
|
6
|
-
* (proposal.md §4, §6) returns one.
|
|
7
|
-
*
|
|
8
|
-
* Every method acts under the session's own bounded authority. The methods mirror the existing
|
|
9
|
-
* connector-core `MeshAgent` participant methods (send, dm, anycast, setStatus, setAttention,
|
|
10
|
-
* setChannelMode, joinChannel, leaveChannel, peekInbox / drainInboxDeliveries, roster, channelInfo,
|
|
11
|
-
* reconnect) and `CotalEndpoint.invokeService` / `readHistory`, so an adapter wraps that engine
|
|
12
|
-
* instead of building a second one. Results are classified HERE as data, never thrown, because only
|
|
13
|
-
* the adapter can tell a native denial from an unknown outcome.
|
|
14
|
-
*/
|
|
15
|
-
import type { AttentionMode, ChannelMode, PresenceStatus } from "@cotal-ai/core";
|
|
16
|
-
import type { RefusalCode } from "@cotal-ai/workspace";
|
|
17
|
-
/** The auth mode the opening was admitted under. It sets which security claims output may make. */
|
|
18
|
-
export type SessionMode = "user" | "static" | "open";
|
|
19
|
-
/** What the opening is, as its admission authority recorded it. Display data only: the broker-bound
|
|
20
|
-
* principal, not the label, is the authority. No credential, secret or bearer is ever carried. */
|
|
21
|
-
export interface SessionIdentity {
|
|
22
|
-
readonly mode: SessionMode;
|
|
23
|
-
/** The resolved space this opening operates in. Display context, never inferred from its label. */
|
|
24
|
-
readonly space: string;
|
|
25
|
-
/** The principal dot-form `<owner>.<actor>` the admission authority assigned. */
|
|
26
|
-
readonly principal: string;
|
|
27
|
-
/** The opening's lifecycle UID, as admitted. Shown abbreviated in human output. */
|
|
28
|
-
readonly lifecycleUid: string;
|
|
29
|
-
/** The display label. Never an authority input. */
|
|
30
|
-
readonly label: string;
|
|
31
|
-
/** Effective channel ceilings the authority accepted, for display and local pre-checks only. The
|
|
32
|
-
* broker remains the enforcement point. */
|
|
33
|
-
readonly allowSubscribe: readonly string[];
|
|
34
|
-
readonly allowPublish: readonly string[];
|
|
35
|
-
/** Absolute end of the opening in epoch ms, when the authority set one. */
|
|
36
|
-
readonly expiresAt?: number;
|
|
37
|
-
}
|
|
38
|
-
/** A refusal before any effect, with the native cause kept beside it. */
|
|
39
|
-
export interface Refused {
|
|
40
|
-
readonly outcome: "refused";
|
|
41
|
-
readonly code: RefusalCode;
|
|
42
|
-
readonly message: string;
|
|
43
|
-
readonly native?: {
|
|
44
|
-
readonly code?: string;
|
|
45
|
-
readonly detail?: unknown;
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/** The effect may or may not have happened. Never retried automatically. */
|
|
49
|
-
export interface Unknown {
|
|
50
|
-
readonly outcome: "unknown";
|
|
51
|
-
readonly message: string;
|
|
52
|
-
}
|
|
53
|
-
/** A read or local step that did not complete and had no effect. */
|
|
54
|
-
export interface Failed {
|
|
55
|
-
readonly outcome: "failed";
|
|
56
|
-
readonly message: string;
|
|
57
|
-
}
|
|
58
|
-
export type Result<T> = {
|
|
59
|
-
readonly outcome: "ok";
|
|
60
|
-
readonly value: T;
|
|
61
|
-
} | Refused | Unknown | Failed;
|
|
62
|
-
/** A publication the broker's stream acknowledged. Stored is not delivered, read or answered. */
|
|
63
|
-
export interface Stored {
|
|
64
|
-
readonly outcome: "stored";
|
|
65
|
-
readonly messageId: string;
|
|
66
|
-
/** The stream sequence from the publish ack, when the native call returns it. Native `unicastAttributed`
|
|
67
|
-
* and `anycastAttributed` do; native `multicast` awaits the ack but discards it (`publishMsg`), so a
|
|
68
|
-
* channel send has no sequence here. Absent means not returned, never zero. */
|
|
69
|
-
readonly seq?: number;
|
|
70
|
-
readonly duplicate?: boolean;
|
|
71
|
-
/** For a channel send, the channel it was stored on and whether the registry knows it. */
|
|
72
|
-
readonly channel?: string;
|
|
73
|
-
readonly registered?: boolean;
|
|
74
|
-
/** For a DM, the resolved recipient. */
|
|
75
|
-
readonly recipient?: {
|
|
76
|
-
readonly id: string;
|
|
77
|
-
readonly name: string;
|
|
78
|
-
};
|
|
79
|
-
/** For a DM, the recipient's roster status just before the publish; `unrostered` when it had no row. */
|
|
80
|
-
readonly recipientStatusAtSend?: PresenceStatus | "unrostered";
|
|
81
|
-
/** For anycast, the live holders at send, when the presence view was current. */
|
|
82
|
-
readonly holdersAtSend?: number;
|
|
83
|
-
}
|
|
84
|
-
export type PublishResult = Stored | Refused | Unknown;
|
|
85
|
-
/** One received message, as the session surfaces it. Text is untrusted. */
|
|
86
|
-
export interface SessionMessage {
|
|
87
|
-
/** The opaque per-delivery key the session acknowledges with {@link AdmittedChatSession.surfaced}. */
|
|
88
|
-
readonly deliveryKey: string;
|
|
89
|
-
readonly id: string;
|
|
90
|
-
readonly ts: number;
|
|
91
|
-
/** Derived from the delivering subject, never from the payload. */
|
|
92
|
-
readonly kind: "channel" | "dm" | "anycast";
|
|
93
|
-
readonly from: {
|
|
94
|
-
readonly id: string;
|
|
95
|
-
readonly name: string;
|
|
96
|
-
readonly role?: string;
|
|
97
|
-
};
|
|
98
|
-
readonly channel?: string;
|
|
99
|
-
readonly service?: string;
|
|
100
|
-
readonly text: string;
|
|
101
|
-
readonly replyTo?: string;
|
|
102
|
-
readonly mentionsMe: boolean;
|
|
103
|
-
readonly historical: boolean;
|
|
104
|
-
/** Broker delivery count above 1 means an earlier copy went unacknowledged and may have surfaced. */
|
|
105
|
-
readonly deliveryCount?: number;
|
|
106
|
-
}
|
|
107
|
-
export interface RosterRow {
|
|
108
|
-
readonly id: string;
|
|
109
|
-
readonly name: string;
|
|
110
|
-
readonly kind: string;
|
|
111
|
-
readonly role?: string;
|
|
112
|
-
readonly status: PresenceStatus;
|
|
113
|
-
readonly activity?: string;
|
|
114
|
-
readonly sessionKind?: string;
|
|
115
|
-
}
|
|
116
|
-
export interface RosterView {
|
|
117
|
-
readonly rows: readonly RosterRow[];
|
|
118
|
-
/** `current` only when the presence watch has a complete snapshot. Otherwise the list is partial. */
|
|
119
|
-
readonly view: "current" | "unpopulated" | "stale";
|
|
120
|
-
}
|
|
121
|
-
export type ConnectionState = "connected" | "disconnected" | "reconnecting" | "ended";
|
|
122
|
-
export interface ConnectionReport {
|
|
123
|
-
readonly state: ConnectionState;
|
|
124
|
-
readonly identity: SessionIdentity;
|
|
125
|
-
readonly bufferedInbox: number;
|
|
126
|
-
readonly joinedChannels: readonly string[];
|
|
127
|
-
readonly attention: AttentionMode;
|
|
128
|
-
readonly channelModes: Readonly<Record<string, ChannelMode>>;
|
|
129
|
-
}
|
|
130
|
-
export interface ChannelInfo {
|
|
131
|
-
readonly channel: string;
|
|
132
|
-
readonly registered: boolean;
|
|
133
|
-
readonly description?: string;
|
|
134
|
-
readonly instructions?: string;
|
|
135
|
-
readonly replay: boolean;
|
|
136
|
-
readonly readable: boolean;
|
|
137
|
-
readonly postable: boolean;
|
|
138
|
-
}
|
|
139
|
-
export interface HistoryPage {
|
|
140
|
-
readonly channel: string;
|
|
141
|
-
readonly messages: readonly SessionMessage[];
|
|
142
|
-
/** True when retention, a bound or a gap means this is not the full conversation. */
|
|
143
|
-
readonly partial: boolean;
|
|
144
|
-
readonly note?: string;
|
|
145
|
-
}
|
|
146
|
-
/** What closing the opening achieved. Only the adapter's native observation may set these. */
|
|
147
|
-
export interface CloseReport {
|
|
148
|
-
/** `retired`: the authority confirmed the terminal. `requested`: asked, not confirmed.
|
|
149
|
-
* `unknown`: the request's outcome is unknown. `not-applicable`: open mode has no lifecycle. */
|
|
150
|
-
readonly retirement: "retired" | "requested" | "unknown" | "not-applicable";
|
|
151
|
-
/** Whether the broker connection closure was confirmed (eviction verified or own close observed). */
|
|
152
|
-
readonly connectionClosed: "confirmed" | "not-confirmed";
|
|
153
|
-
/** Static mode: the credential stays broker-valid until this epoch ms unless eviction was verified. */
|
|
154
|
-
readonly credentialValidUntil?: number;
|
|
155
|
-
readonly message: string;
|
|
156
|
-
/** Set when the session ended itself because it could not continue, such as when its inbox was
|
|
157
|
-
* gone from the broker after an outage: why. */
|
|
158
|
-
readonly lost?: string;
|
|
159
|
-
}
|
|
160
|
-
export type SessionEvent = {
|
|
161
|
-
readonly type: "message";
|
|
162
|
-
readonly message: SessionMessage;
|
|
163
|
-
} | {
|
|
164
|
-
readonly type: "presence";
|
|
165
|
-
readonly row: RosterRow;
|
|
166
|
-
readonly change: "joined" | "updated" | "left";
|
|
167
|
-
} | {
|
|
168
|
-
readonly type: "connection";
|
|
169
|
-
readonly state: ConnectionState;
|
|
170
|
-
readonly reason?: string;
|
|
171
|
-
}
|
|
172
|
-
/** Messages may have been missed: a live-only channel while disconnected, a retention bound, a
|
|
173
|
-
* dropped buffer. Never presented as complete history. */
|
|
174
|
-
| {
|
|
175
|
-
readonly type: "gap";
|
|
176
|
-
readonly scope: string;
|
|
177
|
-
readonly reason: string;
|
|
178
|
-
};
|
|
179
|
-
/** A DM target. A string is a typed name or principal the session resolves. `{ principal }` is an
|
|
180
|
-
* exact principal, such as a received message's sender, sent as is with no lookup. */
|
|
181
|
-
export type DmTarget = string | {
|
|
182
|
-
readonly principal: string;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* One admitted opening. An adapter implements this over the existing participant engine; the CLI
|
|
186
|
-
* front ends (TUI, `--stdio`) consume it and nothing else.
|
|
187
|
-
*/
|
|
188
|
-
export interface AdmittedChatSession {
|
|
189
|
-
identity(): SessionIdentity;
|
|
190
|
-
/** Register for events. Returns the unsubscribe. Events start after the call; no replay. */
|
|
191
|
-
subscribe(listener: (event: SessionEvent) => void): () => void;
|
|
192
|
-
send(text: string, channel: string, mentions: readonly string[]): Promise<PublishResult>;
|
|
193
|
-
dm(to: DmTarget, text: string, replyTo?: string): Promise<PublishResult>;
|
|
194
|
-
/** Resolve a DM target as {@link dm} does, sending nothing, so a front end refuses it when it is chosen. */
|
|
195
|
-
resolveDm(to: DmTarget): Promise<Result<{
|
|
196
|
-
readonly id: string;
|
|
197
|
-
readonly name: string;
|
|
198
|
-
}>>;
|
|
199
|
-
anycast(role: string, text: string): Promise<PublishResult>;
|
|
200
|
-
setStatus(status: Exclude<PresenceStatus, "offline">, activity?: string): Promise<Result<void>>;
|
|
201
|
-
setAttention(mode: AttentionMode): Promise<Result<void>>;
|
|
202
|
-
setChannelMode(channel: string, mode: ChannelMode | "normal"): Promise<Result<void>>;
|
|
203
|
-
join(channel: string): Promise<Result<{
|
|
204
|
-
readonly joined: boolean;
|
|
205
|
-
readonly backfilled: number;
|
|
206
|
-
readonly durable: boolean;
|
|
207
|
-
readonly reason?: string;
|
|
208
|
-
}>>;
|
|
209
|
-
leave(channel: string): Promise<Result<{
|
|
210
|
-
readonly left: boolean;
|
|
211
|
-
}>>;
|
|
212
|
-
/** Buffered messages held by attention or channel mode. `peek` leaves them buffered. */
|
|
213
|
-
inbox(peek: boolean): Promise<Result<readonly SessionMessage[]>>;
|
|
214
|
-
roster(): Promise<Result<RosterView>>;
|
|
215
|
-
channelInfo(channel: string): Promise<Result<ChannelInfo>>;
|
|
216
|
-
connection(): Promise<Result<ConnectionReport>>;
|
|
217
|
-
history(channel: string, limit: number): Promise<Result<HistoryPage>>;
|
|
218
|
-
/** Endpoint invoke within the session's own grants. A seat-only or unbound command refuses natively. */
|
|
219
|
-
invoke(endpoint: string, command: string, args: Readonly<Record<string, unknown>> | undefined, timeoutMs: number): Promise<Result<unknown>>;
|
|
220
|
-
/** Reconnect THIS opening only. Never creates a new identity; refuses when it cannot keep this one. */
|
|
221
|
-
reconnect(): Promise<Result<{
|
|
222
|
-
readonly reconnected: boolean;
|
|
223
|
-
readonly message: string;
|
|
224
|
-
}>>;
|
|
225
|
-
/** Acknowledge deliveries after they were written or shown. Unacknowledged ones redeliver. */
|
|
226
|
-
surfaced(deliveryKeys: readonly string[]): void;
|
|
227
|
-
/** End listening and presence, and request this opening's retirement. Idempotent. */
|
|
228
|
-
close(): Promise<CloseReport>;
|
|
229
|
-
}
|
|
230
|
-
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.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MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACtC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3D,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAChD,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;IACtE,wGAAwG;IACxG,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5I,uGAAuG;IACvG,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;QAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAE1F,8FAA8F;IAC9F,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAChD,qFAAqF;IACrF,KAAK,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;CAC/B"}
|
package/dist/chat/session.js
DELETED
package/dist/chat/session.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/chat/session.ts"],"names":[],"mappings":""}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The static-mode chat admission adapter. On a static-auth mesh the local manager admits the
|
|
3
|
-
* session (`chat-session-open`): it draws the `chat_` alias and a fresh nkey identity and mints the
|
|
4
|
-
* session's own leaf. This adapter runs one real `CotalEndpoint` under that leaf and ends the
|
|
5
|
-
* session with `chat-session-retire` at the same manager instance that admitted it, on close or at
|
|
6
|
-
* the leaf's expiry. `cotal chat` opens it for a static-auth target.
|
|
7
|
-
*
|
|
8
|
-
* The leaf never crosses the wire in the clear. The adapter sends a one-time curve key as
|
|
9
|
-
* `sealTo`, and the manager seals the leaf to it, bound to the space, the admitting instance and
|
|
10
|
-
* every reply field; a generic invoke, an agent tool or a browser sees only that ciphertext. The
|
|
11
|
-
* adapter opens it once, checks every bound field, keeps the leaf in memory, and never writes it to
|
|
12
|
-
* a file, a receipt, a log or any output record. Its retire path never sees it.
|
|
13
|
-
*
|
|
14
|
-
* The caller resolves the mesh once, into `target`. Every manager call mints its one-shot
|
|
15
|
-
* instrument from a copy of that target's server, TLS requirement and trust material, so a later
|
|
16
|
-
* `cotal use` or registry change cannot move the retirement to another mesh.
|
|
17
|
-
*/
|
|
18
|
-
import { SealRecipient } from "@cotal-ai/core";
|
|
19
|
-
import { type MeshTarget } from "@cotal-ai/workspace";
|
|
20
|
-
import { NativeChatSession } from "./native-session.js";
|
|
21
|
-
import type { CloseReport } from "./session.js";
|
|
22
|
-
import { type ManagerReply } from "@cotal-ai/workspace/control";
|
|
23
|
-
/** The leaf's whole life. The manager caps `ttl` here and never renews it. */
|
|
24
|
-
export declare const STATIC_CHAT_TTL_SEC = 900;
|
|
25
|
-
/** What `chat-session-open` returned, checked. `actor` is the session's wire authority and
|
|
26
|
-
* `alias` its routing-only slot name. */
|
|
27
|
-
export interface StaticAdmission {
|
|
28
|
-
readonly alias: string;
|
|
29
|
-
readonly actor: string;
|
|
30
|
-
readonly lifecycleUid: string;
|
|
31
|
-
readonly creds: string;
|
|
32
|
-
readonly expiresAt: number;
|
|
33
|
-
}
|
|
34
|
-
/** Open and check one `chat-session-open` reply. The outer reply must have its contract shape;
|
|
35
|
-
* the sealed payload must open with `recipient`, which it uses up, must carry exactly the sealed
|
|
36
|
-
* keys, and must bind the expected space and responding instance, this recipient's own key and
|
|
37
|
-
* the outer alias, actor, uid and expiry; and its credential must be the identity it names.
|
|
38
|
-
* Undefined when any part does not hold; the caller never uses a reply that fails here. */
|
|
39
|
-
export declare function readAdmission(data: unknown, recipient: SealRecipient, expected: {
|
|
40
|
-
readonly space: string;
|
|
41
|
-
readonly managerInstanceId: string;
|
|
42
|
-
}): StaticAdmission | undefined;
|
|
43
|
-
/** The close report for a `chat-session-retire` reply. The adapter asks only after its own
|
|
44
|
-
* endpoint stopped, so `connectionClosed` is that observed stop, and `NativeChatSession`
|
|
45
|
-
* downgrades it when the stop failed. The retirement outcome is reported apart from it and never
|
|
46
|
-
* changes it. A static mesh has no broker-side revocation, so no outcome here ends the leaf at
|
|
47
|
-
* the broker: a copy of it still authenticates until `validUntil`. */
|
|
48
|
-
export declare function retireReport(reply: ManagerReply, managerInstanceId: string, validUntil: number): CloseReport;
|
|
49
|
-
/** Open one static chat session on `target`, which the caller resolved once. The three lists are
|
|
50
|
-
* a spawn's, under its rules: `subscribe` the initial channels, `allowSubscribe` the read ceiling
|
|
51
|
-
* (empty means `subscribe`), `allowPublish` the post list (empty means none). `instanceId`
|
|
52
|
-
* (`--on`) chooses the admitting manager; retirement always goes to the instance that answered
|
|
53
|
-
* the open. */
|
|
54
|
-
export declare function openStaticChatSession(target: MeshTarget, options: {
|
|
55
|
-
readonly label: string;
|
|
56
|
-
readonly subscribe?: readonly string[];
|
|
57
|
-
readonly allowSubscribe?: readonly string[];
|
|
58
|
-
readonly allowPublish?: readonly string[];
|
|
59
|
-
readonly instanceId?: string;
|
|
60
|
-
readonly reopen: (channel: string) => string;
|
|
61
|
-
}): Promise<NativeChatSession>;
|
|
62
|
-
//# sourceMappingURL=static-session.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-session.d.ts","sourceRoot":"","sources":["../../src/chat/static-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACoC,aAAa,EAEvD,MAAM,gBAAg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