@voicethere/agent 0.5.2 → 0.5.3
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/package.json +1 -1
- package/templates/game-sync-smoke.ts +34 -0
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* - On join/leave: broadcast `{ type: "state", tick, players }` to every session.
|
|
6
6
|
* - On `{ type: "tick" }`: increment tick and rebroadcast.
|
|
7
7
|
* - On `{ type: "agent_log_probe", id }`: `agentLog` the id (agent-logs-smoke) and ack.
|
|
8
|
+
* - On `{ type: "env_probe", key }`: ack allowlisted `AGENT_E2E_*` keys from `process.env`.
|
|
8
9
|
*
|
|
9
10
|
* Load-staging uses the full `game-sync` product template (object-sync).
|
|
10
11
|
*/
|
|
@@ -13,6 +14,21 @@ import { agentLog, defineAgent, sendToClient } from "@voicethere/agent";
|
|
|
13
14
|
/** E2E deploy-smoke — rewritten before each fixture upload. */
|
|
14
15
|
export const FIXTURE_MARKER = "deploy-smoke-fixture-b";
|
|
15
16
|
|
|
17
|
+
/** Only keys matching this pattern may be read via env_probe (no webhook/OpenAI secrets). */
|
|
18
|
+
export const AGENT_E2E_ENV_PROBE_KEY_PATTERN = /^AGENT_E2E_[A-Z0-9_]+$/;
|
|
19
|
+
|
|
20
|
+
export function isAllowlistedEnvProbeKey(key: string): boolean {
|
|
21
|
+
return AGENT_E2E_ENV_PROBE_KEY_PATTERN.test(key.trim());
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function resolveEnvProbeValue(key: string): string | null {
|
|
25
|
+
const trimmed = key.trim();
|
|
26
|
+
if (!isAllowlistedEnvProbeKey(trimmed)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return process.env[trimmed] ?? null;
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
const connectedSessions = new Set<string>();
|
|
17
33
|
let tick = 0;
|
|
18
34
|
|
|
@@ -48,6 +64,14 @@ function isAgentLogProbe(
|
|
|
48
64
|
);
|
|
49
65
|
}
|
|
50
66
|
|
|
67
|
+
function isEnvProbeMessage(
|
|
68
|
+
message: unknown,
|
|
69
|
+
): message is { type: "env_probe"; key: string } {
|
|
70
|
+
if (!message || typeof message !== "object") return false;
|
|
71
|
+
const record = message as { type?: unknown; key?: unknown };
|
|
72
|
+
return record.type === "env_probe" && typeof record.key === "string";
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
defineAgent({
|
|
52
76
|
onClientJoin({ sessionId }) {
|
|
53
77
|
connectedSessions.add(sessionId);
|
|
@@ -72,6 +96,16 @@ defineAgent({
|
|
|
72
96
|
return;
|
|
73
97
|
}
|
|
74
98
|
|
|
99
|
+
if (isEnvProbeMessage(ctx.message)) {
|
|
100
|
+
const key = ctx.message.key.trim();
|
|
101
|
+
sendToClient(ctx.sessionId, {
|
|
102
|
+
type: "env_probe_ack",
|
|
103
|
+
key,
|
|
104
|
+
value: resolveEnvProbeValue(key),
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
75
109
|
if (!isTickMessage(ctx.message)) {
|
|
76
110
|
return;
|
|
77
111
|
}
|