agent-relay-codex 0.4.18 → 0.4.23
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/bin/agent-relay-codex.ts +32 -11
- package/package.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/relay.ts +1 -0
package/bin/agent-relay-codex.ts
CHANGED
|
@@ -118,7 +118,15 @@ function isAgentRelaySessionStartCommand(command: string): boolean {
|
|
|
118
118
|
return /agent-relay.*hooks\/session-start\.ts/.test(command);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
function
|
|
121
|
+
function isSessionStartGroupHeader(header: string | null | undefined): boolean {
|
|
122
|
+
return header?.trim() === "[[hooks.SessionStart]]";
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isSessionStartHookHeader(header: string | null | undefined): boolean {
|
|
126
|
+
return header?.trim() === "[[hooks.SessionStart.hooks]]";
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function removeAgentRelaySessionStartToml(input: string): string {
|
|
122
130
|
const lines = input.split(/\r?\n/);
|
|
123
131
|
const blocks: Array<{ header: string | null; text: string }> = [];
|
|
124
132
|
|
|
@@ -136,15 +144,26 @@ function removeAgentRelaySessionStartToml(input: string): string {
|
|
|
136
144
|
let output = "";
|
|
137
145
|
for (let index = 0; index < blocks.length; ) {
|
|
138
146
|
const block = blocks[index];
|
|
139
|
-
if (block?.header
|
|
140
|
-
const group
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
if (isSessionStartGroupHeader(block?.header)) {
|
|
148
|
+
const group = block!;
|
|
149
|
+
const hooks: typeof blocks = [];
|
|
150
|
+
index += 1;
|
|
151
|
+
while (index < blocks.length && isSessionStartHookHeader(blocks[index]?.header)) {
|
|
152
|
+
hooks.push(blocks[index]!);
|
|
143
153
|
index += 1;
|
|
144
154
|
}
|
|
145
155
|
|
|
146
|
-
const
|
|
147
|
-
|
|
156
|
+
const keptHooks = hooks.filter((hook) => !isAgentRelaySessionStartCommand(hook.text));
|
|
157
|
+
const groupIsAgentRelay = isAgentRelaySessionStartCommand(group.text) || (hooks.length > 0 && keptHooks.length === 0);
|
|
158
|
+
if (!groupIsAgentRelay || keptHooks.length > 0) {
|
|
159
|
+
output += `${group.text}\n`;
|
|
160
|
+
for (const hook of keptHooks) output += `${hook.text}\n`;
|
|
161
|
+
}
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (isSessionStartHookHeader(block?.header) && isAgentRelaySessionStartCommand(block?.text ?? "")) {
|
|
166
|
+
index += 1;
|
|
148
167
|
continue;
|
|
149
168
|
}
|
|
150
169
|
|
|
@@ -987,7 +1006,9 @@ async function main(): Promise<void> {
|
|
|
987
1006
|
return start(command ? [command, ...args] : []);
|
|
988
1007
|
}
|
|
989
1008
|
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1009
|
+
if (import.meta.main) {
|
|
1010
|
+
main().catch((error) => {
|
|
1011
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1012
|
+
process.exit(1);
|
|
1013
|
+
});
|
|
1014
|
+
}
|
package/package.json
CHANGED