@canonmsg/codex-plugin 0.20.0 → 0.22.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/README.md +4 -4
- package/dist/adapter.d.ts +96 -0
- package/dist/adapter.js +310 -0
- package/dist/app-server-adapter.d.ts +3 -64
- package/dist/app-server-adapter.js +7 -54
- package/dist/app-server-approval.d.ts +1 -1
- package/dist/app-server-approval.js +1 -1
- package/dist/cli-entry.d.ts +2 -2
- package/dist/cli-entry.js +1 -1
- package/dist/control-channel.d.ts +46 -26
- package/dist/control-channel.js +50 -37
- package/dist/host-lifecycle.d.ts +4 -0
- package/dist/host-lifecycle.js +3 -0
- package/dist/host.d.ts +1 -1
- package/dist/host.js +1019 -995
- package/dist/inbound-policy.d.ts +22 -0
- package/dist/inbound-policy.js +46 -0
- package/dist/permission-mode.d.ts +1 -1
- package/dist/register.js +25 -73
- package/dist/session-store.d.ts +1 -1
- package/dist/session-store.js +1 -1
- package/dist/startup-recovery.d.ts +46 -0
- package/dist/startup-recovery.js +59 -0
- package/dist/turn-activity.d.ts +8 -23
- package/dist/turn-activity.js +40 -24
- package/package.json +7 -10
- package/dist/bridge-bin.d.ts +0 -14
- package/dist/bridge-bin.js +0 -27
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApprovalNativeRequestMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalResult, ApprovalRisk, CanonUnifiedDiff } from '@canonmsg/core
|
|
1
|
+
import type { ApprovalNativeRequestMetadata, ApprovalRequestCategory, ApprovalRequestDetail, ApprovalResult, ApprovalRisk, CanonUnifiedDiff } from '@canonmsg/core';
|
|
2
2
|
/**
|
|
3
3
|
* Mapping for Codex app-server native approval requests.
|
|
4
4
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sanitizeUnifiedDiffForSharing, truncateUnifiedDiff } from '@canonmsg/core
|
|
1
|
+
import { sanitizeUnifiedDiffForSharing, truncateUnifiedDiff } from '@canonmsg/core';
|
|
2
2
|
function isRecord(value) {
|
|
3
3
|
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
4
4
|
}
|
package/dist/cli-entry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { handleCliMetadataRequest, isDirectExecution, readCliPackageVersion, runCli, } from '@canonmsg/core
|
|
2
|
-
export type { CliMetadata, RunCliMetadataOptions, } from '@canonmsg/core
|
|
1
|
+
export { handleCliMetadataRequest, isDirectExecution, readCliPackageVersion, runCli, } from '@canonmsg/core';
|
|
2
|
+
export type { CliMetadata, RunCliMetadataOptions, } from '@canonmsg/core';
|
package/dist/cli-entry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { handleCliMetadataRequest, isDirectExecution, readCliPackageVersion, runCli, } from '@canonmsg/core
|
|
1
|
+
export { handleCliMetadataRequest, isDirectExecution, readCliPackageVersion, runCli, } from '@canonmsg/core';
|
|
@@ -1,32 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex host control
|
|
2
|
+
* Codex host RTDB `/control/{conversationId}/{agentId}` channel wiring.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* and pushes `onSessionControl` / `onControlSignal` / `onControlPrimitive`
|
|
8
|
-
* notifications instead. This module keeps the codex-shaped handler wiring:
|
|
9
|
-
* session + signal ride the shared agent-host router; the primitive channel
|
|
10
|
-
* (context.compact) subscribes alongside them.
|
|
4
|
+
* Configures the shared `ControlChannelPoller` from `@canonmsg/core` to the
|
|
5
|
+
* codex host characterization profile (the "codex host profile" describe
|
|
6
|
+
* block in core's control-poller.test.ts is the contract):
|
|
11
7
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* - Keys: `session` + `signal`, plus `primitive` when a primitive handler is
|
|
9
|
+
* configured; read sequentially per conversation, conversations polled one
|
|
10
|
+
* at a time.
|
|
11
|
+
* - Cadence: immediate first cycle, then active/idle delays + jitter with
|
|
12
|
+
* the activity probe sampled BEFORE the cycle runs.
|
|
13
|
+
* - Session controls are always consumed once newer (default consume), even
|
|
14
|
+
* when no live session applied them; signals are NOT consumed when the
|
|
15
|
+
* handler throws (consumeOnError stays false).
|
|
16
|
+
* - Dedupe is primed eagerly via `poller.baseline([conversationId])` at
|
|
17
|
+
* session creation — the second legacy poll site.
|
|
16
18
|
*/
|
|
17
|
-
import type
|
|
18
|
-
|
|
19
|
+
import { ControlChannelPoller, type ControlChannelRTDB, type ControlHandlerResult, type ControlPollerError, type ControlPrimitiveEvent, type ControlSessionEvent, type ControlSignalEvent } from '@canonmsg/core';
|
|
20
|
+
export declare const CONTROL_POLL_MS = 2000;
|
|
21
|
+
export declare const IDLE_CONTROL_POLL_MS = 10000;
|
|
22
|
+
export declare const CONTROL_POLL_JITTER_MS = 1000;
|
|
19
23
|
export interface CodexControlChannelInput {
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
/** Scoped RTDB handle from `initRTDBAuth` — never the module-global default. */
|
|
25
|
+
rtdb: ControlChannelRTDB;
|
|
26
|
+
agentId: string;
|
|
27
|
+
/** Live session conversation ids, snapshotted at the start of every cycle. */
|
|
28
|
+
conversationIds: () => Iterable<string>;
|
|
29
|
+
/** Sampled before each cycle to choose the active vs idle delay. */
|
|
30
|
+
hasActiveWork: () => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Applies a newer `/session` control node. The node is always consumed
|
|
33
|
+
* after the handler resolves; a thrown error leaves it in place (with
|
|
34
|
+
* dedupe already advanced, so it is never retried).
|
|
35
|
+
*/
|
|
36
|
+
onSessionControl: (event: ControlSessionEvent) => Promise<ControlHandlerResult> | ControlHandlerResult;
|
|
37
|
+
/**
|
|
38
|
+
* Handles a newer `/signal` node. Return `{ consume: false }` to leave the
|
|
39
|
+
* node in place; thrown errors also leave it (consumeOnError stays false).
|
|
40
|
+
*/
|
|
41
|
+
onSignal: (event: ControlSignalEvent) => Promise<ControlHandlerResult> | ControlHandlerResult;
|
|
42
|
+
/**
|
|
43
|
+
* Handles a newer `/primitive` node. Primitive commands are consumed by
|
|
44
|
+
* default after the handler resolves or throws, matching core's command
|
|
45
|
+
* semantics so one failed command cannot replay forever.
|
|
46
|
+
*/
|
|
47
|
+
onPrimitive?: (event: ControlPrimitiveEvent) => Promise<ControlHandlerResult> | ControlHandlerResult;
|
|
48
|
+
onError?: (error: ControlPollerError) => void;
|
|
49
|
+
/** Injectable jitter source (tests). */
|
|
50
|
+
random?: () => number;
|
|
30
51
|
}
|
|
31
|
-
|
|
32
|
-
export declare function attachCodexControlNotifications(input: CodexControlChannelInput): () => void;
|
|
52
|
+
export declare function createCodexControlPoller(input: CodexControlChannelInput): ControlChannelPoller;
|
package/dist/control-channel.js
CHANGED
|
@@ -1,43 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Codex host control
|
|
2
|
+
* Codex host RTDB `/control/{conversationId}/{agentId}` channel wiring.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* and pushes `onSessionControl` / `onControlSignal` / `onControlPrimitive`
|
|
8
|
-
* notifications instead. This module keeps the codex-shaped handler wiring:
|
|
9
|
-
* session + signal ride the shared agent-host router; the primitive channel
|
|
10
|
-
* (context.compact) subscribes alongside them.
|
|
4
|
+
* Configures the shared `ControlChannelPoller` from `@canonmsg/core` to the
|
|
5
|
+
* codex host characterization profile (the "codex host profile" describe
|
|
6
|
+
* block in core's control-poller.test.ts is the contract):
|
|
11
7
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* - Keys: `session` + `signal`, plus `primitive` when a primitive handler is
|
|
9
|
+
* configured; read sequentially per conversation, conversations polled one
|
|
10
|
+
* at a time.
|
|
11
|
+
* - Cadence: immediate first cycle, then active/idle delays + jitter with
|
|
12
|
+
* the activity probe sampled BEFORE the cycle runs.
|
|
13
|
+
* - Session controls are always consumed once newer (default consume), even
|
|
14
|
+
* when no live session applied them; signals are NOT consumed when the
|
|
15
|
+
* handler throws (consumeOnError stays false).
|
|
16
|
+
* - Dedupe is primed eagerly via `poller.baseline([conversationId])` at
|
|
17
|
+
* session creation — the second legacy poll site.
|
|
16
18
|
*/
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
import { ControlChannelPoller, } from '@canonmsg/core';
|
|
20
|
+
export const CONTROL_POLL_MS = 2_000;
|
|
21
|
+
export const IDLE_CONTROL_POLL_MS = 10_000;
|
|
22
|
+
export const CONTROL_POLL_JITTER_MS = 1_000;
|
|
23
|
+
export function createCodexControlPoller(input) {
|
|
24
|
+
return new ControlChannelPoller({
|
|
25
|
+
rtdb: input.rtdb,
|
|
26
|
+
agentId: input.agentId,
|
|
27
|
+
conversationIds: input.conversationIds,
|
|
28
|
+
cadence: {
|
|
29
|
+
kind: 'adaptive',
|
|
30
|
+
activeMs: CONTROL_POLL_MS,
|
|
31
|
+
idleMs: IDLE_CONTROL_POLL_MS,
|
|
32
|
+
jitterMs: CONTROL_POLL_JITTER_MS,
|
|
33
|
+
hasActiveWork: input.hasActiveWork,
|
|
34
|
+
activitySample: 'cycle-start',
|
|
35
|
+
},
|
|
36
|
+
pollOnStart: true,
|
|
37
|
+
conversationConcurrency: 'sequential',
|
|
38
|
+
handlers: {
|
|
39
|
+
session: {
|
|
40
|
+
handle: input.onSessionControl,
|
|
41
|
+
},
|
|
42
|
+
signal: {
|
|
43
|
+
handle: input.onSignal,
|
|
44
|
+
},
|
|
45
|
+
...(input.onPrimitive
|
|
46
|
+
? {
|
|
47
|
+
primitive: {
|
|
48
|
+
handle: input.onPrimitive,
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
: {}),
|
|
52
|
+
},
|
|
53
|
+
...(input.onError ? { onError: input.onError } : {}),
|
|
54
|
+
...(input.random ? { random: input.random } : {}),
|
|
23
55
|
});
|
|
24
|
-
const detachShared = attachHostControlNotifications(input.source, { logPrefix: '[canon-codex]' }, {
|
|
25
|
-
onSessionControl: input.onSessionControl,
|
|
26
|
-
onControlSignal: input.onSignal,
|
|
27
|
-
onError: (error, kind, conversationId) => report(error, kind, conversationId),
|
|
28
|
-
});
|
|
29
|
-
let detachPrimitive = null;
|
|
30
|
-
if (input.onPrimitive) {
|
|
31
|
-
const onPrimitive = input.onPrimitive;
|
|
32
|
-
detachPrimitive = input.source.onNotification('onControlPrimitive', (params) => {
|
|
33
|
-
const event = params;
|
|
34
|
-
void Promise.resolve(onPrimitive(event)).catch((error) => {
|
|
35
|
-
report(error, 'primitive', event?.conversationId ?? null);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return () => {
|
|
40
|
-
detachShared();
|
|
41
|
-
detachPrimitive?.();
|
|
42
|
-
};
|
|
43
56
|
}
|
package/dist/host.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { type CanonRuntimeCommandDescriptor, type CanonRuntimeDescriptor, type CanonRuntimePresentationPolicy, type ExecutionEnvironmentMode, type WorkspaceOption, type CanonWorkspaceRootMetadata } from '@canonmsg/core
|
|
2
|
+
import { type CanonRuntimeCommandDescriptor, type CanonRuntimeDescriptor, type CanonRuntimePresentationPolicy, type ExecutionEnvironmentMode, type WorkspaceOption, type CanonWorkspaceRootMetadata } from '@canonmsg/core';
|
|
3
3
|
import { type CodexSkillMetadata } from './app-server-adapter.js';
|
|
4
4
|
interface HostSessionState {
|
|
5
5
|
lastError?: string;
|