@arnilo/prism-hosts 0.13.0 → 0.14.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/CHANGELOG.md +2 -0
- package/a2a/README.md +195 -0
- package/a2a/src/card.ts +208 -0
- package/a2a/src/codec.ts +523 -0
- package/a2a/src/connect.ts +415 -0
- package/a2a/src/errors.ts +87 -0
- package/a2a/src/index.ts +40 -0
- package/a2a/src/limits.ts +43 -0
- package/a2a/src/pending.ts +28 -0
- package/a2a/src/proxy.ts +526 -0
- package/a2a/src/serve.ts +886 -0
- package/acp/README.md +3 -1
- package/acp/src/limits.ts +3 -16
- package/acp/src/mapper.ts +26 -5
- package/acp/src/serve.ts +6 -5
- package/ag-ui/README.md +2 -1
- package/ag-ui/src/a2ui.ts +8 -31
- package/ag-ui/src/ag-ui-mapper.ts +27 -1
- package/ag-ui/src/encrypted-value.ts +3 -3
- package/ag-ui/src/handler.ts +4 -4
- package/ag-ui/src/index.ts +0 -33
- package/ag-ui/src/limits.ts +5 -88
- package/ag-ui/src/projectors.ts +8 -6
- package/ag-ui/src/renderer/bind.ts +2 -1
- package/channels/README.md +61 -5
- package/channels/src/discord-gateway.ts +354 -0
- package/channels/src/discord.ts +873 -0
- package/channels/src/index.ts +4 -2
- package/channels/src/limits.ts +3 -19
- package/channels/src/pairing.ts +1 -2
- package/channels/src/runtime-turn.ts +10 -2
- package/channels/src/signal.ts +11 -19
- package/channels/src/slack.ts +854 -0
- package/channels/src/telegram.ts +22 -44
- package/channels/src/types.ts +5 -2
- package/devtools/README.md +1 -1
- package/driver-process/src/driver.ts +3 -1
- package/driver-process/src/testing.ts +1 -1
- package/driver-process/src/turn.ts +5 -1
- package/evals/README.md +11 -7
- package/evals/src/calibration.ts +5 -13
- package/evals/src/compare-experiments.ts +1 -2
- package/evals/src/comparison.ts +7 -25
- package/evals/src/curate.ts +3 -9
- package/evals/src/dataset.ts +0 -2
- package/evals/src/index.ts +3 -20
- package/evals/src/injection.ts +33 -6
- package/evals/src/judge.ts +9 -13
- package/evals/src/limits.ts +0 -17
- package/evals/src/rubric-judge.ts +5 -10
- package/evals/src/scenario-runner.ts +8 -4
- package/evals/src/scenarios.ts +5 -5
- package/evals/src/score.ts +3 -5
- package/evals/src/stats.ts +0 -2
- package/evals/src/threshold.ts +3 -3
- package/evals/src/toolless-session.ts +7 -3
- package/evals/src/trace.ts +8 -14
- package/evals/src/trajectory.ts +45 -11
- package/evals/src/types.ts +2 -2
- package/evals/src/user-simulator.ts +1 -7
- package/evals/src/util.ts +3 -9
- package/headless/README.md +20 -1
- package/headless/src/authority.ts +14 -1
- package/headless/src/errors.ts +3 -1
- package/headless/src/index.ts +10 -1
- package/headless/src/limits.ts +2 -2
- package/headless/src/pending.ts +4 -3
- package/headless/src/recover.ts +126 -0
- package/headless/src/resume.ts +1 -1
- package/host-builder/data/api.json +1308 -1367
- package/host-builder/data/errors.json +207 -181
- package/host-builder/data/examples/a2a-client.ts +125 -0
- package/host-builder/data/examples/a2a-server.ts +133 -0
- package/host-builder/data/examples/autonomous-coding-loop.ts +1 -1
- package/host-builder/data/examples/build-workflow.ts +2 -2
- package/host-builder/data/examples/caveman-ponytail.ts +1 -1
- package/host-builder/data/examples/channel-discord.ts +176 -0
- package/host-builder/data/examples/channel-slack.ts +146 -0
- package/host-builder/data/examples/continue-after-failure.ts +80 -0
- package/host-builder/data/examples/custom-adapter.ts +1 -1
- package/host-builder/data/examples/decision-models.ts +1 -1
- package/host-builder/data/examples/define-package.ts +1 -1
- package/host-builder/data/examples/delegate.ts +74 -9
- package/host-builder/data/examples/durable-loops-and-approvals.ts +11 -10
- package/host-builder/data/examples/governance-deny.ts +1 -1
- package/host-builder/data/examples/guardrail-content.ts +126 -0
- package/host-builder/data/examples/headless-host.ts +1 -1
- package/host-builder/data/examples/long-running-job.ts +129 -0
- package/host-builder/data/examples/long-term-memory.ts +1 -1
- package/host-builder/data/examples/mcp-oauth.ts +197 -0
- package/host-builder/data/examples/mcp-trust.ts +1 -1
- package/host-builder/data/examples/memory-and-wiki.ts +3 -3
- package/host-builder/data/examples/memory-system.ts +31 -18
- package/host-builder/data/examples/model-router-aggregate-budgets.ts +1 -1
- package/host-builder/data/examples/parallel-tools.ts +70 -0
- package/host-builder/data/examples/remote-agent.ts +1 -1
- package/host-builder/data/examples/serve-tools.ts +1 -1
- package/host-builder/data/examples/session-memory.ts +29 -26
- package/host-builder/data/examples/side-call.ts +9 -5
- package/host-builder/data/examples/sqlite-resume.ts +1 -1
- package/host-builder/data/examples/structured-output.ts +57 -0
- package/host-builder/data/examples.json +15 -5
- package/host-builder/skills/prism-host-builder/SKILL.md +1 -1
- package/host-builder/skills/prism-host-builder/references/choosing.md +14 -10
- package/host-builder/skills/prism-host-builder/references/pitfalls.md +5 -3
- package/host-builder/skills/prism-host-builder/references/recipes.md +5 -5
- package/host-builder/skills/prism-host-builder/references/verification.md +1 -1
- package/host-builder/src/check/runner.ts +2 -3
- package/host-builder/src/server.ts +2 -2
- package/mcp-server/README.md +3 -3
- package/mcp-server/src/bounds.ts +3 -3
- package/mcp-server/src/serve-tools.ts +2 -9
- package/mcp-server/src/serve.ts +2 -4
- package/mcp-server/src/server.ts +10 -20
- package/package.json +12 -6
- package/remote/README.md +7 -4
- package/remote/src/channel.ts +6 -2
- package/remote/src/connect.ts +9 -3
- package/remote/src/errors.ts +3 -1
- package/remote/src/limits.ts +3 -13
- package/remote/src/mirror.ts +2 -1
- package/remote/src/pending.ts +4 -3
- package/remote/src/protocol.ts +3 -0
- package/remote/src/serve.ts +43 -5
- package/remote/src/session-proxy.ts +28 -5
- package/remote/src/testing.ts +3 -1
- package/remote/src/wire.ts +74 -14
package/channels/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { ChannelDeliveryJournal, ChannelDeliveryJournalOptions, ChannelReplyKeyInput } from "./delivery.js";
|
|
2
2
|
export { createChannelDeliveryJournal, emptyPruneResult, isSettledReply } from "./delivery.js";
|
|
3
|
-
export { DEFAULT_CHANNEL_LIMITS,
|
|
3
|
+
export { DEFAULT_CHANNEL_LIMITS, resolveChannelLimits } from "./limits.js";
|
|
4
4
|
export type {
|
|
5
5
|
ChannelPairingConsumption,
|
|
6
6
|
ChannelPairingGrant,
|
|
@@ -10,7 +10,7 @@ export type {
|
|
|
10
10
|
ConsumeChannelPairingInput,
|
|
11
11
|
CreateChannelPairingInput,
|
|
12
12
|
} from "./pairing.js";
|
|
13
|
-
export { createChannelPairingStore, DEFAULT_PAIRING_TTL_MS
|
|
13
|
+
export { createChannelPairingStore, DEFAULT_PAIRING_TTL_MS } from "./pairing.js";
|
|
14
14
|
export type { ChannelApprovalStore } from "./approvals.js";
|
|
15
15
|
export { createChannelApprovalStore } from "./approvals.js";
|
|
16
16
|
export { createMemoryCheckpointStore, createMemoryLeaseStore } from "./memory-stores.js";
|
|
@@ -78,5 +78,7 @@ export type {
|
|
|
78
78
|
} from "./types.js";
|
|
79
79
|
export { connectTelegram, type TelegramConnectOptions } from "./telegram.js";
|
|
80
80
|
export { connectSignal, type SignalConnectOptions } from "./signal.js";
|
|
81
|
+
export { connectSlack, type SlackConnectOptions } from "./slack.js";
|
|
82
|
+
export { connectDiscord, type DiscordConnectOptions } from "./discord.js";
|
|
81
83
|
|
|
82
84
|
export { channelHostUi, type ChannelHostUiOptions } from "./host-ui.js";
|
package/channels/src/limits.ts
CHANGED
|
@@ -19,29 +19,13 @@ export const DEFAULT_CHANNEL_LIMITS: ResolvedChannelLimits = {
|
|
|
19
19
|
maxAttachmentBytes: 1024 * 1024,
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
export const HARD_CHANNEL_LIMITS: ResolvedChannelLimits = {
|
|
23
|
-
maxInputBytes: 64 * 1024,
|
|
24
|
-
maxResponseBytes: 128 * 1024,
|
|
25
|
-
maxPendingPerBinding: 32,
|
|
26
|
-
maxPendingPerProcess: 500,
|
|
27
|
-
maxActiveSessions: 16,
|
|
28
|
-
maxRoutes: 10_000,
|
|
29
|
-
maxSeenEventsPerConnection: 10_000,
|
|
30
|
-
stopDeadlineMs: 5 * 60_000,
|
|
31
|
-
retentionDays: 90,
|
|
32
|
-
maxJournalPage: 500,
|
|
33
|
-
maxJournalRecordBytes: 512 * 1024,
|
|
34
|
-
leaseTtlMs: 5 * 60_000,
|
|
35
|
-
approvalTtlMs: 5 * 60_000,
|
|
36
|
-
maxAttachmentBytes: 4 * 1024 * 1024,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
22
|
export function resolveChannelLimits(input: ChannelLimits = {}): ResolvedChannelLimits {
|
|
40
23
|
const out = {} as Record<keyof ResolvedChannelLimits, number>;
|
|
41
24
|
for (const key of Object.keys(DEFAULT_CHANNEL_LIMITS) as (keyof ResolvedChannelLimits)[]) {
|
|
42
25
|
const value = input[key] ?? DEFAULT_CHANNEL_LIMITS[key];
|
|
43
|
-
|
|
44
|
-
|
|
26
|
+
// Host-set: the host's value is the cap (plan 239 Task 5).
|
|
27
|
+
if (!Number.isFinite(value) || value < 1) {
|
|
28
|
+
throw new TypeError(`Channel limit ${key} must be a positive number`);
|
|
45
29
|
}
|
|
46
30
|
out[key] = value;
|
|
47
31
|
}
|
package/channels/src/pairing.ts
CHANGED
|
@@ -9,7 +9,6 @@ import { CHANNEL_JOURNAL_NAMESPACES } from "./state.js";
|
|
|
9
9
|
|
|
10
10
|
/** Review section 6: 5 minutes, host-tightenable, never longer. */
|
|
11
11
|
export const DEFAULT_PAIRING_TTL_MS = 5 * 60_000;
|
|
12
|
-
export const HARD_PAIRING_TTL_MS = 5 * 60_000;
|
|
13
12
|
const TOKEN_BYTES = 32;
|
|
14
13
|
|
|
15
14
|
export interface ChannelPairingRecord {
|
|
@@ -121,7 +120,7 @@ export function createChannelPairingStore(options: ChannelPairingStoreOptions):
|
|
|
121
120
|
return r;
|
|
122
121
|
},
|
|
123
122
|
async create(input) {
|
|
124
|
-
const ttl = Math.
|
|
123
|
+
const ttl = Math.max(1_000, input.ttlMs ?? DEFAULT_PAIRING_TTL_MS);
|
|
125
124
|
const now = input.now ?? new Date().toISOString();
|
|
126
125
|
const token = randomBytes(TOKEN_BYTES).toString("base64url");
|
|
127
126
|
const record: ChannelPairingRecord = {
|
|
@@ -389,19 +389,27 @@ export function createRuntimeTurn(ctx: RuntimeContext, core: RuntimeCore) {
|
|
|
389
389
|
|
|
390
390
|
/**
|
|
391
391
|
* Assistant-text preview accumulator for one turn: cumulative, redacted, never journaled and
|
|
392
|
-
* never allowed to fail the turn. Resets on each new
|
|
393
|
-
*
|
|
392
|
+
* never allowed to fail the turn. Resets on each new run. A provider attempt that ends with
|
|
393
|
+
* `error` drops its text (plan 227 Task 4: the run may retry it), so the next delta's cumulative
|
|
394
|
+
* preview replaces the failed attempt's.
|
|
394
395
|
*/
|
|
395
396
|
function createPreview(route: RouteState, isLive: () => boolean): (event: AgentEvent) => void {
|
|
396
397
|
const onDelta = options.onAssistantDelta;
|
|
397
398
|
if (onDelta === undefined) return () => undefined;
|
|
398
399
|
let runId: string | undefined;
|
|
399
400
|
let text = "";
|
|
401
|
+
let attemptStart = "";
|
|
400
402
|
return (event) => {
|
|
401
403
|
// A new run resets the preview: `run.started` replaces the retired message-start event.
|
|
402
404
|
if (event.type === "run.started") {
|
|
403
405
|
runId = event.runId;
|
|
404
406
|
text = "";
|
|
407
|
+
attemptStart = "";
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if ((event.type === "turn.started" || event.type === "turn.completed") && (runId === undefined || event.runId === runId)) {
|
|
411
|
+
if (event.type === "turn.started") attemptStart = text;
|
|
412
|
+
else if (event.error) text = attemptStart;
|
|
405
413
|
return;
|
|
406
414
|
}
|
|
407
415
|
if (event.type !== "message.delta" || event.content.type !== "text") return;
|
package/channels/src/signal.ts
CHANGED
|
@@ -26,11 +26,8 @@ export type { ChannelConnectionHandle };
|
|
|
26
26
|
export const SIGNAL_CLI_VERSION = "0.14.8";
|
|
27
27
|
|
|
28
28
|
const DEFAULT_FRAME_BYTES = 128 * 1024;
|
|
29
|
-
const HARD_FRAME_BYTES = 512 * 1024;
|
|
30
29
|
const DEFAULT_PENDING_REQUESTS = 16;
|
|
31
|
-
const HARD_PENDING_REQUESTS = 64;
|
|
32
30
|
const DEFAULT_PENDING_EVENTS = 32;
|
|
33
|
-
const HARD_PENDING_EVENTS = 128;
|
|
34
31
|
const DEFAULT_REQUEST_TIMEOUT_MS = 10_000;
|
|
35
32
|
const DEFAULT_RECONNECT_DELAY_MS = 1_000;
|
|
36
33
|
const DEFAULT_MAX_RECONNECT_DELAY_MS = 30_000;
|
|
@@ -146,10 +143,11 @@ function asRecord(value: unknown): Record<string, unknown> | undefined {
|
|
|
146
143
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? (value as Record<string, unknown>) : undefined;
|
|
147
144
|
}
|
|
148
145
|
|
|
149
|
-
|
|
146
|
+
/** A host-set Signal limit, at least `min`. The host's value is the cap (plan 239 Task 5). */
|
|
147
|
+
function bounded(value: number | undefined, fallback: number, min: number, name: string): number {
|
|
150
148
|
const resolved = value ?? fallback;
|
|
151
|
-
if (!Number.isSafeInteger(resolved) || resolved < min
|
|
152
|
-
throw new TypeError(`Signal ${name} must be an integer
|
|
149
|
+
if (!Number.isSafeInteger(resolved) || resolved < min) {
|
|
150
|
+
throw new TypeError(`Signal ${name} must be an integer of at least ${min}`);
|
|
153
151
|
}
|
|
154
152
|
return resolved;
|
|
155
153
|
}
|
|
@@ -318,19 +316,13 @@ function validateOptions(options: SignalAdapterOptions): void {
|
|
|
318
316
|
*/
|
|
319
317
|
export function createSignalAdapter(options: SignalAdapterOptions): SignalAdapter {
|
|
320
318
|
validateOptions(options);
|
|
321
|
-
const maxFrameBytes = bounded(options.maxFrameBytes, DEFAULT_FRAME_BYTES, 1024,
|
|
322
|
-
const maxPendingRequests = bounded(options.maxPendingRequests, DEFAULT_PENDING_REQUESTS, 1,
|
|
323
|
-
const maxPendingEvents = bounded(options.maxPendingEvents, DEFAULT_PENDING_EVENTS, 1,
|
|
324
|
-
const requestTimeoutMs = bounded(options.requestTimeoutMs, DEFAULT_REQUEST_TIMEOUT_MS, 100,
|
|
325
|
-
const reconnectDelayMs = bounded(options.reconnectDelayMs, DEFAULT_RECONNECT_DELAY_MS, 1,
|
|
326
|
-
const maxReconnectDelayMs = bounded(
|
|
327
|
-
|
|
328
|
-
DEFAULT_MAX_RECONNECT_DELAY_MS,
|
|
329
|
-
reconnectDelayMs,
|
|
330
|
-
60_000,
|
|
331
|
-
"maxReconnectDelayMs",
|
|
332
|
-
);
|
|
333
|
-
const leaseTtlMs = bounded(options.leaseTtlMs, DEFAULT_LEASE_TTL_MS, 5_000, 300_000, "leaseTtlMs");
|
|
319
|
+
const maxFrameBytes = bounded(options.maxFrameBytes, DEFAULT_FRAME_BYTES, 1024, "maxFrameBytes");
|
|
320
|
+
const maxPendingRequests = bounded(options.maxPendingRequests, DEFAULT_PENDING_REQUESTS, 1, "maxPendingRequests");
|
|
321
|
+
const maxPendingEvents = bounded(options.maxPendingEvents, DEFAULT_PENDING_EVENTS, 1, "maxPendingEvents");
|
|
322
|
+
const requestTimeoutMs = bounded(options.requestTimeoutMs, DEFAULT_REQUEST_TIMEOUT_MS, 100, "requestTimeoutMs");
|
|
323
|
+
const reconnectDelayMs = bounded(options.reconnectDelayMs, DEFAULT_RECONNECT_DELAY_MS, 1, "reconnectDelayMs");
|
|
324
|
+
const maxReconnectDelayMs = bounded(options.maxReconnectDelayMs, DEFAULT_MAX_RECONNECT_DELAY_MS, reconnectDelayMs, "maxReconnectDelayMs");
|
|
325
|
+
const leaseTtlMs = bounded(options.leaseTtlMs, DEFAULT_LEASE_TTL_MS, 5_000, "leaseTtlMs");
|
|
334
326
|
const ownerId = `signal-receiver-${randomUUID()}`;
|
|
335
327
|
const connect = options.connect ?? ((socketPath: string) => createConnection(socketPath));
|
|
336
328
|
const pending = new Map<string, Pending>();
|