@wingman-ai/gateway 0.4.2 → 0.4.4
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 +14 -0
- package/dist/agent/config/mcpClientManager.cjs +104 -1
- package/dist/agent/config/mcpClientManager.d.ts +30 -0
- package/dist/agent/config/mcpClientManager.js +104 -1
- package/dist/agent/config/modelFactory.cjs +10 -0
- package/dist/agent/config/modelFactory.js +10 -0
- package/dist/agent/config/xaiImageModel.cjs +242 -0
- package/dist/agent/config/xaiImageModel.d.ts +33 -0
- package/dist/agent/config/xaiImageModel.js +202 -0
- package/dist/agent/tests/mcpClientManager.test.cjs +116 -0
- package/dist/agent/tests/mcpClientManager.test.js +117 -1
- package/dist/agent/tests/mcpResourceTools.test.cjs +101 -0
- package/dist/agent/tests/mcpResourceTools.test.d.ts +1 -0
- package/dist/agent/tests/mcpResourceTools.test.js +95 -0
- package/dist/agent/tests/modelFactory.test.cjs +16 -2
- package/dist/agent/tests/modelFactory.test.js +16 -2
- package/dist/agent/tests/xaiImageModel.test.cjs +194 -0
- package/dist/agent/tests/xaiImageModel.test.d.ts +1 -0
- package/dist/agent/tests/xaiImageModel.test.js +188 -0
- package/dist/agent/tools/mcp_resources.cjs +111 -0
- package/dist/agent/tools/mcp_resources.d.ts +3 -0
- package/dist/agent/tools/mcp_resources.js +77 -0
- package/dist/bench/adapters/commandAdapter.cjs +93 -0
- package/dist/bench/adapters/commandAdapter.d.ts +6 -0
- package/dist/bench/adapters/commandAdapter.js +59 -0
- package/dist/bench/adapters/helpers.cjs +170 -0
- package/dist/bench/adapters/helpers.d.ts +7 -0
- package/dist/bench/adapters/helpers.js +133 -0
- package/dist/bench/adapters/index.cjs +41 -0
- package/dist/bench/adapters/index.d.ts +2 -0
- package/dist/bench/adapters/index.js +7 -0
- package/dist/bench/adapters/wingmanCliAdapter.cjs +100 -0
- package/dist/bench/adapters/wingmanCliAdapter.d.ts +6 -0
- package/dist/bench/adapters/wingmanCliAdapter.js +66 -0
- package/dist/bench/cleanup.cjs +122 -0
- package/dist/bench/cleanup.d.ts +9 -0
- package/dist/bench/cleanup.js +85 -0
- package/dist/bench/config.cjs +190 -0
- package/dist/bench/config.d.ts +2 -0
- package/dist/bench/config.js +156 -0
- package/dist/bench/index.cjs +43 -0
- package/dist/bench/index.d.ts +3 -0
- package/dist/bench/index.js +3 -0
- package/dist/bench/official.cjs +616 -0
- package/dist/bench/official.d.ts +80 -0
- package/dist/bench/official.js +546 -0
- package/dist/bench/officialCli.cjs +204 -0
- package/dist/bench/officialCli.d.ts +5 -0
- package/dist/bench/officialCli.js +170 -0
- package/dist/bench/process.cjs +78 -0
- package/dist/bench/process.d.ts +14 -0
- package/dist/bench/process.js +44 -0
- package/dist/bench/runner.cjs +237 -0
- package/dist/bench/runner.d.ts +7 -0
- package/dist/bench/runner.js +197 -0
- package/dist/bench/scoring.cjs +171 -0
- package/dist/bench/scoring.d.ts +9 -0
- package/dist/bench/scoring.js +137 -0
- package/dist/bench/types.cjs +18 -0
- package/dist/bench/types.d.ts +200 -0
- package/dist/bench/types.js +0 -0
- package/dist/bench/validator.cjs +92 -0
- package/dist/bench/validator.d.ts +2 -0
- package/dist/bench/validator.js +58 -0
- package/dist/cli/config/schema.cjs +36 -1
- package/dist/cli/config/schema.d.ts +46 -0
- package/dist/cli/config/schema.js +36 -1
- package/dist/cli/config/warnings.cjs +119 -51
- package/dist/cli/config/warnings.js +119 -51
- package/dist/cli/core/agentInvoker.cjs +9 -2
- package/dist/cli/core/agentInvoker.d.ts +1 -0
- package/dist/cli/core/agentInvoker.js +9 -2
- package/dist/cli/core/imagePersistence.cjs +17 -1
- package/dist/cli/core/imagePersistence.d.ts +2 -0
- package/dist/cli/core/imagePersistence.js +13 -3
- package/dist/cli/core/sessionManager.cjs +2 -0
- package/dist/cli/core/sessionManager.js +3 -1
- package/dist/cli/types.d.ts +18 -0
- package/dist/gateway/adapters/teams.cjs +419 -0
- package/dist/gateway/adapters/teams.d.ts +47 -0
- package/dist/gateway/adapters/teams.js +361 -0
- package/dist/gateway/http/sms.cjs +286 -0
- package/dist/gateway/http/sms.d.ts +4 -0
- package/dist/gateway/http/sms.js +249 -0
- package/dist/gateway/server.cjs +54 -3
- package/dist/gateway/server.d.ts +2 -0
- package/dist/gateway/server.js +54 -3
- package/dist/gateway/sms/commands.cjs +116 -0
- package/dist/gateway/sms/commands.d.ts +15 -0
- package/dist/gateway/sms/commands.js +79 -0
- package/dist/gateway/sms/control.cjs +118 -0
- package/dist/gateway/sms/control.d.ts +18 -0
- package/dist/gateway/sms/control.js +84 -0
- package/dist/gateway/sms/policyStore.cjs +198 -0
- package/dist/gateway/sms/policyStore.d.ts +37 -0
- package/dist/gateway/sms/policyStore.js +161 -0
- package/dist/providers/registry.cjs +1 -0
- package/dist/providers/registry.js +1 -0
- package/dist/tests/cli-config-warnings.test.cjs +41 -0
- package/dist/tests/cli-config-warnings.test.js +41 -0
- package/dist/tests/cli-init.test.cjs +32 -26
- package/dist/tests/cli-init.test.js +32 -26
- package/dist/tests/gateway-http-security.test.cjs +21 -0
- package/dist/tests/gateway-http-security.test.js +21 -0
- package/dist/tests/gateway-origin-policy.test.cjs +22 -0
- package/dist/tests/gateway-origin-policy.test.js +22 -0
- package/dist/tests/gateway.test.cjs +57 -0
- package/dist/tests/gateway.test.js +57 -0
- package/dist/tests/imagePersistence.test.cjs +26 -0
- package/dist/tests/imagePersistence.test.js +27 -1
- package/dist/tests/run-terminal-bench-official-script.test.cjs +61 -0
- package/dist/tests/run-terminal-bench-official-script.test.d.ts +1 -0
- package/dist/tests/run-terminal-bench-official-script.test.js +55 -0
- package/dist/tests/sessions-api.test.cjs +69 -1
- package/dist/tests/sessions-api.test.js +70 -2
- package/dist/tests/sms-api.test.cjs +183 -0
- package/dist/tests/sms-api.test.d.ts +1 -0
- package/dist/tests/sms-api.test.js +177 -0
- package/dist/tests/sms-commands.test.cjs +90 -0
- package/dist/tests/sms-commands.test.d.ts +1 -0
- package/dist/tests/sms-commands.test.js +84 -0
- package/dist/tests/sms-policy-store.test.cjs +69 -0
- package/dist/tests/sms-policy-store.test.d.ts +1 -0
- package/dist/tests/sms-policy-store.test.js +63 -0
- package/dist/tests/teams-adapter.test.cjs +58 -0
- package/dist/tests/teams-adapter.test.d.ts +1 -0
- package/dist/tests/teams-adapter.test.js +52 -0
- package/dist/tests/terminal-bench-adapters-helpers.test.cjs +64 -0
- package/dist/tests/terminal-bench-adapters-helpers.test.d.ts +1 -0
- package/dist/tests/terminal-bench-adapters-helpers.test.js +58 -0
- package/dist/tests/terminal-bench-cleanup.test.cjs +93 -0
- package/dist/tests/terminal-bench-cleanup.test.d.ts +1 -0
- package/dist/tests/terminal-bench-cleanup.test.js +87 -0
- package/dist/tests/terminal-bench-config.test.cjs +62 -0
- package/dist/tests/terminal-bench-config.test.d.ts +1 -0
- package/dist/tests/terminal-bench-config.test.js +56 -0
- package/dist/tests/terminal-bench-official.test.cjs +194 -0
- package/dist/tests/terminal-bench-official.test.d.ts +1 -0
- package/dist/tests/terminal-bench-official.test.js +188 -0
- package/dist/tests/terminal-bench-runner.test.cjs +82 -0
- package/dist/tests/terminal-bench-runner.test.d.ts +1 -0
- package/dist/tests/terminal-bench-runner.test.js +76 -0
- package/dist/tests/terminal-bench-scoring.test.cjs +128 -0
- package/dist/tests/terminal-bench-scoring.test.d.ts +1 -0
- package/dist/tests/terminal-bench-scoring.test.js +122 -0
- package/dist/tools/mcp-fal-ai.cjs +1 -1
- package/dist/tools/mcp-fal-ai.js +1 -1
- package/dist/webui/assets/index-Cyg_Hs57.css +11 -0
- package/dist/webui/assets/{index-BMekSELC.js → index-DZXLLjaA.js} +109 -109
- package/dist/webui/index.html +2 -2
- package/package.json +11 -2
- package/templates/agents/game-dev/agent.md +110 -63
- package/templates/agents/game-dev/art-director.md +106 -0
- package/templates/agents/game-dev/game-designer.md +87 -0
- package/templates/agents/game-dev/scene-engineer.md +474 -0
- package/dist/webui/assets/index-Cwkg4DKj.css +0 -11
- package/templates/agents/game-dev/art-generation.md +0 -38
- package/templates/agents/game-dev/asset-refinement.md +0 -17
- package/templates/agents/game-dev/planning-idea.md +0 -17
- package/templates/agents/game-dev/ui-specialist.md +0 -17
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const MINUTE_MS = 60000;
|
|
2
|
+
const HOUR_MS = 60 * MINUTE_MS;
|
|
3
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
4
|
+
const MAX_PAUSE_DURATION_MS = 30 * DAY_MS;
|
|
5
|
+
function parsePauseDurationMs(raw) {
|
|
6
|
+
const trimmed = raw.trim();
|
|
7
|
+
const match = trimmed.match(/^(\d+)\s*([mhd])$/i);
|
|
8
|
+
if (!match) return null;
|
|
9
|
+
const amount = Number(match[1]);
|
|
10
|
+
if (!Number.isInteger(amount) || amount <= 0) return null;
|
|
11
|
+
const unit = match[2].toLowerCase();
|
|
12
|
+
const multiplier = "m" === unit ? MINUTE_MS : "h" === unit ? HOUR_MS : DAY_MS;
|
|
13
|
+
const durationMs = amount * multiplier;
|
|
14
|
+
if (durationMs <= 0 || durationMs > MAX_PAUSE_DURATION_MS) return null;
|
|
15
|
+
return durationMs;
|
|
16
|
+
}
|
|
17
|
+
function interpretSmsInboundMessage(raw) {
|
|
18
|
+
const trimmed = raw.trim();
|
|
19
|
+
if (!trimmed) return {
|
|
20
|
+
type: "text",
|
|
21
|
+
content: ""
|
|
22
|
+
};
|
|
23
|
+
if (trimmed.startsWith("\\")) return {
|
|
24
|
+
type: "text",
|
|
25
|
+
content: trimmed.slice(1).trimStart()
|
|
26
|
+
};
|
|
27
|
+
const normalized = trimmed.toLowerCase();
|
|
28
|
+
if ("help" === normalized) return {
|
|
29
|
+
type: "command",
|
|
30
|
+
command: {
|
|
31
|
+
name: "help"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
if ("status" === normalized) return {
|
|
35
|
+
type: "command",
|
|
36
|
+
command: {
|
|
37
|
+
name: "status"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
if ("resume" === normalized) return {
|
|
41
|
+
type: "command",
|
|
42
|
+
command: {
|
|
43
|
+
name: "resume"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
if ("stop" === normalized) return {
|
|
47
|
+
type: "command",
|
|
48
|
+
command: {
|
|
49
|
+
name: "stop"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const pauseMatch = trimmed.match(/^pause(?:\s+(.+))?$/i);
|
|
53
|
+
if (pauseMatch) {
|
|
54
|
+
const durationRaw = pauseMatch[1]?.trim();
|
|
55
|
+
if (!durationRaw) return {
|
|
56
|
+
type: "command",
|
|
57
|
+
command: {
|
|
58
|
+
name: "pause",
|
|
59
|
+
durationMs: null
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const durationMs = parsePauseDurationMs(durationRaw);
|
|
63
|
+
if (null !== durationMs) return {
|
|
64
|
+
type: "command",
|
|
65
|
+
command: {
|
|
66
|
+
name: "pause",
|
|
67
|
+
durationMs
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
type: "text",
|
|
73
|
+
content: trimmed
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function buildSmsHelpMessage() {
|
|
77
|
+
return 'Commands:\n- STATUS\n- PAUSE [15m|2h|1d]\n- RESUME\n- STOP\n- HELP\nUse "\\<command>" to send a command word as normal text.';
|
|
78
|
+
}
|
|
79
|
+
export { buildSmsHelpMessage, interpretSmsInboundMessage };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
applySmsControlCommand: ()=>applySmsControlCommand
|
|
28
|
+
});
|
|
29
|
+
const external_commands_cjs_namespaceObject = require("./commands.cjs");
|
|
30
|
+
function formatPauseRemaining(untilMs, nowMs) {
|
|
31
|
+
const remaining = Math.max(untilMs - nowMs, 0);
|
|
32
|
+
const totalMinutes = Math.ceil(remaining / 60000);
|
|
33
|
+
if (totalMinutes < 60) return `${totalMinutes}m`;
|
|
34
|
+
const hours = Math.ceil(totalMinutes / 60);
|
|
35
|
+
if (hours < 24) return `${hours}h`;
|
|
36
|
+
const days = Math.ceil(hours / 24);
|
|
37
|
+
return `${days}d`;
|
|
38
|
+
}
|
|
39
|
+
function formatPolicyStatus(policy, nowMs) {
|
|
40
|
+
const lines = [
|
|
41
|
+
`SMS status for ${policy.target}:`,
|
|
42
|
+
`- stop: ${policy.stopEnabled ? "enabled" : "disabled"}`
|
|
43
|
+
];
|
|
44
|
+
if (policy.paused) if (policy.pausedUntil) lines.push(`- proactive alerts: paused (${formatPauseRemaining(policy.pausedUntil, nowMs)} remaining)`);
|
|
45
|
+
else lines.push("- proactive alerts: paused (until RESUME)");
|
|
46
|
+
else lines.push("- proactive alerts: active");
|
|
47
|
+
lines.push(`- alert mode: ${policy.alertMode}`);
|
|
48
|
+
return lines.join("\n");
|
|
49
|
+
}
|
|
50
|
+
function applySmsControlCommand(params) {
|
|
51
|
+
const { store, target, text, nowMs = Date.now() } = params;
|
|
52
|
+
const parsed = (0, external_commands_cjs_namespaceObject.interpretSmsInboundMessage)(text);
|
|
53
|
+
if ("text" === parsed.type) return {
|
|
54
|
+
handled: false,
|
|
55
|
+
passThroughText: parsed.content,
|
|
56
|
+
policy: store.resolve(target, nowMs)
|
|
57
|
+
};
|
|
58
|
+
const command = parsed.command;
|
|
59
|
+
if ("help" === command.name) {
|
|
60
|
+
const policy = store.resolve(target, nowMs);
|
|
61
|
+
return {
|
|
62
|
+
handled: true,
|
|
63
|
+
command,
|
|
64
|
+
responseText: (0, external_commands_cjs_namespaceObject.buildSmsHelpMessage)(),
|
|
65
|
+
policy
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if ("status" === command.name) {
|
|
69
|
+
const policy = store.resolve(target, nowMs);
|
|
70
|
+
return {
|
|
71
|
+
handled: true,
|
|
72
|
+
command,
|
|
73
|
+
responseText: formatPolicyStatus(policy, nowMs),
|
|
74
|
+
policy
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if ("pause" === command.name) {
|
|
78
|
+
const pausedUntil = "number" == typeof command.durationMs ? nowMs + command.durationMs : null;
|
|
79
|
+
const policy = store.upsert(target, {
|
|
80
|
+
paused: true,
|
|
81
|
+
pausedUntil
|
|
82
|
+
}, nowMs);
|
|
83
|
+
return {
|
|
84
|
+
handled: true,
|
|
85
|
+
command,
|
|
86
|
+
responseText: pausedUntil ? `Proactive SMS alerts paused for ${formatPauseRemaining(pausedUntil, nowMs)}.` : "Proactive SMS alerts paused until you send RESUME.",
|
|
87
|
+
policy
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
if ("resume" === command.name) {
|
|
91
|
+
const policy = store.upsert(target, {
|
|
92
|
+
paused: false,
|
|
93
|
+
pausedUntil: null
|
|
94
|
+
}, nowMs);
|
|
95
|
+
return {
|
|
96
|
+
handled: true,
|
|
97
|
+
command,
|
|
98
|
+
responseText: "Proactive SMS alerts resumed.",
|
|
99
|
+
policy
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
const policy = store.upsert(target, {
|
|
103
|
+
stopEnabled: true
|
|
104
|
+
}, nowMs);
|
|
105
|
+
return {
|
|
106
|
+
handled: true,
|
|
107
|
+
command,
|
|
108
|
+
responseText: "SMS chat is now stopped for this sender. Re-enable in Wingman settings/API.",
|
|
109
|
+
policy
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
exports.applySmsControlCommand = __webpack_exports__.applySmsControlCommand;
|
|
113
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
114
|
+
"applySmsControlCommand"
|
|
115
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
116
|
+
Object.defineProperty(exports, '__esModule', {
|
|
117
|
+
value: true
|
|
118
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SmsControlCommand } from "./commands.js";
|
|
2
|
+
import type { SmsPolicyRecord, SmsPolicyStore } from "./policyStore.js";
|
|
3
|
+
export type SmsControlResolution = {
|
|
4
|
+
handled: false;
|
|
5
|
+
passThroughText: string;
|
|
6
|
+
policy: SmsPolicyRecord;
|
|
7
|
+
} | {
|
|
8
|
+
handled: true;
|
|
9
|
+
command: SmsControlCommand;
|
|
10
|
+
responseText: string;
|
|
11
|
+
policy: SmsPolicyRecord;
|
|
12
|
+
};
|
|
13
|
+
export declare function applySmsControlCommand(params: {
|
|
14
|
+
store: SmsPolicyStore;
|
|
15
|
+
target: string;
|
|
16
|
+
text: string;
|
|
17
|
+
nowMs?: number;
|
|
18
|
+
}): SmsControlResolution;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { buildSmsHelpMessage, interpretSmsInboundMessage } from "./commands.js";
|
|
2
|
+
function formatPauseRemaining(untilMs, nowMs) {
|
|
3
|
+
const remaining = Math.max(untilMs - nowMs, 0);
|
|
4
|
+
const totalMinutes = Math.ceil(remaining / 60000);
|
|
5
|
+
if (totalMinutes < 60) return `${totalMinutes}m`;
|
|
6
|
+
const hours = Math.ceil(totalMinutes / 60);
|
|
7
|
+
if (hours < 24) return `${hours}h`;
|
|
8
|
+
const days = Math.ceil(hours / 24);
|
|
9
|
+
return `${days}d`;
|
|
10
|
+
}
|
|
11
|
+
function formatPolicyStatus(policy, nowMs) {
|
|
12
|
+
const lines = [
|
|
13
|
+
`SMS status for ${policy.target}:`,
|
|
14
|
+
`- stop: ${policy.stopEnabled ? "enabled" : "disabled"}`
|
|
15
|
+
];
|
|
16
|
+
if (policy.paused) if (policy.pausedUntil) lines.push(`- proactive alerts: paused (${formatPauseRemaining(policy.pausedUntil, nowMs)} remaining)`);
|
|
17
|
+
else lines.push("- proactive alerts: paused (until RESUME)");
|
|
18
|
+
else lines.push("- proactive alerts: active");
|
|
19
|
+
lines.push(`- alert mode: ${policy.alertMode}`);
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
22
|
+
function applySmsControlCommand(params) {
|
|
23
|
+
const { store, target, text, nowMs = Date.now() } = params;
|
|
24
|
+
const parsed = interpretSmsInboundMessage(text);
|
|
25
|
+
if ("text" === parsed.type) return {
|
|
26
|
+
handled: false,
|
|
27
|
+
passThroughText: parsed.content,
|
|
28
|
+
policy: store.resolve(target, nowMs)
|
|
29
|
+
};
|
|
30
|
+
const command = parsed.command;
|
|
31
|
+
if ("help" === command.name) {
|
|
32
|
+
const policy = store.resolve(target, nowMs);
|
|
33
|
+
return {
|
|
34
|
+
handled: true,
|
|
35
|
+
command,
|
|
36
|
+
responseText: buildSmsHelpMessage(),
|
|
37
|
+
policy
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
if ("status" === command.name) {
|
|
41
|
+
const policy = store.resolve(target, nowMs);
|
|
42
|
+
return {
|
|
43
|
+
handled: true,
|
|
44
|
+
command,
|
|
45
|
+
responseText: formatPolicyStatus(policy, nowMs),
|
|
46
|
+
policy
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
if ("pause" === command.name) {
|
|
50
|
+
const pausedUntil = "number" == typeof command.durationMs ? nowMs + command.durationMs : null;
|
|
51
|
+
const policy = store.upsert(target, {
|
|
52
|
+
paused: true,
|
|
53
|
+
pausedUntil
|
|
54
|
+
}, nowMs);
|
|
55
|
+
return {
|
|
56
|
+
handled: true,
|
|
57
|
+
command,
|
|
58
|
+
responseText: pausedUntil ? `Proactive SMS alerts paused for ${formatPauseRemaining(pausedUntil, nowMs)}.` : "Proactive SMS alerts paused until you send RESUME.",
|
|
59
|
+
policy
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if ("resume" === command.name) {
|
|
63
|
+
const policy = store.upsert(target, {
|
|
64
|
+
paused: false,
|
|
65
|
+
pausedUntil: null
|
|
66
|
+
}, nowMs);
|
|
67
|
+
return {
|
|
68
|
+
handled: true,
|
|
69
|
+
command,
|
|
70
|
+
responseText: "Proactive SMS alerts resumed.",
|
|
71
|
+
policy
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const policy = store.upsert(target, {
|
|
75
|
+
stopEnabled: true
|
|
76
|
+
}, nowMs);
|
|
77
|
+
return {
|
|
78
|
+
handled: true,
|
|
79
|
+
command,
|
|
80
|
+
responseText: "SMS chat is now stopped for this sender. Re-enable in Wingman settings/API.",
|
|
81
|
+
policy
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export { applySmsControlCommand };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createSmsPolicyStore: ()=>createSmsPolicyStore,
|
|
28
|
+
normalizeSmsPolicyTarget: ()=>normalizeSmsPolicyTarget
|
|
29
|
+
});
|
|
30
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
31
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
32
|
+
const MAX_TARGET_LENGTH = 256;
|
|
33
|
+
const MINUTE_LIMIT = 1439;
|
|
34
|
+
function isAlertMode(value) {
|
|
35
|
+
return "off" === value || "important-only" === value || "all" === value;
|
|
36
|
+
}
|
|
37
|
+
function normalizeQuietHours(value) {
|
|
38
|
+
if (!value || "object" != typeof value || Array.isArray(value)) return null;
|
|
39
|
+
const candidate = value;
|
|
40
|
+
const startMinute = "number" == typeof candidate.startMinute ? candidate.startMinute : NaN;
|
|
41
|
+
const endMinute = "number" == typeof candidate.endMinute ? candidate.endMinute : NaN;
|
|
42
|
+
if (!Number.isInteger(startMinute) || startMinute < 0 || startMinute > MINUTE_LIMIT || !Number.isInteger(endMinute) || endMinute < 0 || endMinute > MINUTE_LIMIT) return null;
|
|
43
|
+
return {
|
|
44
|
+
enabled: false !== candidate.enabled,
|
|
45
|
+
startMinute,
|
|
46
|
+
endMinute,
|
|
47
|
+
timezone: "string" == typeof candidate.timezone && candidate.timezone.trim() ? candidate.timezone.trim() : void 0
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function normalizeTarget(raw) {
|
|
51
|
+
const trimmed = raw.trim();
|
|
52
|
+
if (!trimmed || trimmed.length > MAX_TARGET_LENGTH) return null;
|
|
53
|
+
return trimmed;
|
|
54
|
+
}
|
|
55
|
+
function normalizeSmsPolicyTarget(raw) {
|
|
56
|
+
return normalizeTarget(raw);
|
|
57
|
+
}
|
|
58
|
+
function createDefaultPolicy(target, nowMs) {
|
|
59
|
+
return {
|
|
60
|
+
target,
|
|
61
|
+
paused: false,
|
|
62
|
+
pausedUntil: null,
|
|
63
|
+
stopEnabled: false,
|
|
64
|
+
alertMode: "important-only",
|
|
65
|
+
quietHours: null,
|
|
66
|
+
createdAt: nowMs,
|
|
67
|
+
updatedAt: nowMs
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function parsePolicyRecord(entry) {
|
|
71
|
+
if (!entry || "object" != typeof entry || Array.isArray(entry)) return null;
|
|
72
|
+
const typed = entry;
|
|
73
|
+
const target = "string" == typeof typed.target ? normalizeTarget(typed.target) : null;
|
|
74
|
+
if (!target) return null;
|
|
75
|
+
const createdAt = "number" == typeof typed.createdAt && Number.isFinite(typed.createdAt) ? typed.createdAt : Date.now();
|
|
76
|
+
const updatedAt = "number" == typeof typed.updatedAt && Number.isFinite(typed.updatedAt) ? typed.updatedAt : createdAt;
|
|
77
|
+
const paused = true === typed.paused;
|
|
78
|
+
const pausedUntil = "number" == typeof typed.pausedUntil && Number.isFinite(typed.pausedUntil) ? Math.trunc(typed.pausedUntil) : null;
|
|
79
|
+
return {
|
|
80
|
+
target,
|
|
81
|
+
paused,
|
|
82
|
+
pausedUntil: paused ? pausedUntil : null,
|
|
83
|
+
stopEnabled: true === typed.stopEnabled,
|
|
84
|
+
alertMode: isAlertMode(typed.alertMode) ? typed.alertMode : "important-only",
|
|
85
|
+
quietHours: normalizeQuietHours(typed.quietHours),
|
|
86
|
+
createdAt,
|
|
87
|
+
updatedAt
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function resolveExpiredPause(record, nowMs) {
|
|
91
|
+
if (!record.paused || null === record.pausedUntil || record.pausedUntil > nowMs) return record;
|
|
92
|
+
return {
|
|
93
|
+
...record,
|
|
94
|
+
paused: false,
|
|
95
|
+
pausedUntil: null,
|
|
96
|
+
updatedAt: nowMs
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const createSmsPolicyStore = (resolveConfigDirPath)=>{
|
|
100
|
+
const resolvePath = ()=>{
|
|
101
|
+
const configDir = resolveConfigDirPath();
|
|
102
|
+
(0, external_node_fs_namespaceObject.mkdirSync)(configDir, {
|
|
103
|
+
recursive: true
|
|
104
|
+
});
|
|
105
|
+
return (0, external_node_path_namespaceObject.join)(configDir, "sms-policies.json");
|
|
106
|
+
};
|
|
107
|
+
const readRecords = ()=>{
|
|
108
|
+
const path = resolvePath();
|
|
109
|
+
if (!(0, external_node_fs_namespaceObject.existsSync)(path)) return [];
|
|
110
|
+
try {
|
|
111
|
+
const raw = (0, external_node_fs_namespaceObject.readFileSync)(path, "utf-8");
|
|
112
|
+
const parsed = JSON.parse(raw);
|
|
113
|
+
if (!Array.isArray(parsed)) return [];
|
|
114
|
+
const records = [];
|
|
115
|
+
for (const entry of parsed){
|
|
116
|
+
const record = parsePolicyRecord(entry);
|
|
117
|
+
if (record) records.push(record);
|
|
118
|
+
}
|
|
119
|
+
return records;
|
|
120
|
+
} catch {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const writeRecords = (records)=>{
|
|
125
|
+
const path = resolvePath();
|
|
126
|
+
(0, external_node_fs_namespaceObject.writeFileSync)(path, JSON.stringify(records, null, 2));
|
|
127
|
+
};
|
|
128
|
+
const replaceRecord = (records, nextRecord)=>{
|
|
129
|
+
const index = records.findIndex((record)=>record.target === nextRecord.target);
|
|
130
|
+
if (index >= 0) records[index] = nextRecord;
|
|
131
|
+
else records.unshift(nextRecord);
|
|
132
|
+
return records;
|
|
133
|
+
};
|
|
134
|
+
const resolveRecord = (target, nowMs = Date.now())=>{
|
|
135
|
+
const normalizedTarget = normalizeTarget(target);
|
|
136
|
+
if (!normalizedTarget) return createDefaultPolicy("unknown", nowMs);
|
|
137
|
+
const records = readRecords();
|
|
138
|
+
const existing = records.find((record)=>record.target === normalizedTarget);
|
|
139
|
+
if (!existing) return createDefaultPolicy(normalizedTarget, nowMs);
|
|
140
|
+
const resolved = resolveExpiredPause(existing, nowMs);
|
|
141
|
+
if (resolved !== existing) writeRecords(replaceRecord(records, resolved));
|
|
142
|
+
return resolved;
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
load: ()=>readRecords(),
|
|
146
|
+
save: (records)=>writeRecords(records),
|
|
147
|
+
list: ()=>readRecords(),
|
|
148
|
+
get: (target)=>{
|
|
149
|
+
const normalizedTarget = normalizeTarget(target);
|
|
150
|
+
if (!normalizedTarget) return null;
|
|
151
|
+
return readRecords().find((record)=>record.target === normalizedTarget) || null;
|
|
152
|
+
},
|
|
153
|
+
resolve: (target, nowMs = Date.now())=>resolveRecord(target, nowMs),
|
|
154
|
+
upsert: (target, patch, nowMs = Date.now())=>{
|
|
155
|
+
const normalizedTarget = normalizeTarget(target);
|
|
156
|
+
if (!normalizedTarget) throw new Error("Invalid SMS policy target");
|
|
157
|
+
const records = readRecords();
|
|
158
|
+
const existing = records.find((record)=>record.target === normalizedTarget);
|
|
159
|
+
const base = existing || createDefaultPolicy(normalizedTarget, nowMs);
|
|
160
|
+
const next = {
|
|
161
|
+
...base,
|
|
162
|
+
updatedAt: nowMs
|
|
163
|
+
};
|
|
164
|
+
if ("boolean" == typeof patch.paused) next.paused = patch.paused;
|
|
165
|
+
if (Object.hasOwn(patch, "pausedUntil")) {
|
|
166
|
+
const value = patch.pausedUntil;
|
|
167
|
+
if ("number" == typeof value && Number.isFinite(value)) next.pausedUntil = Math.trunc(value);
|
|
168
|
+
else next.pausedUntil = null;
|
|
169
|
+
}
|
|
170
|
+
if ("boolean" == typeof patch.stopEnabled) next.stopEnabled = patch.stopEnabled;
|
|
171
|
+
if (isAlertMode(patch.alertMode)) next.alertMode = patch.alertMode;
|
|
172
|
+
if (Object.hasOwn(patch, "quietHours")) next.quietHours = patch.quietHours ? normalizeQuietHours(patch.quietHours) : null;
|
|
173
|
+
if (!next.paused) next.pausedUntil = null;
|
|
174
|
+
const resolved = resolveExpiredPause(next, nowMs);
|
|
175
|
+
writeRecords(replaceRecord(records, resolved));
|
|
176
|
+
return resolved;
|
|
177
|
+
},
|
|
178
|
+
reset: (target)=>{
|
|
179
|
+
const normalizedTarget = normalizeTarget(target);
|
|
180
|
+
if (!normalizedTarget) return;
|
|
181
|
+
const records = readRecords();
|
|
182
|
+
const filtered = records.filter((record)=>record.target !== normalizedTarget);
|
|
183
|
+
if (filtered.length === records.length) return;
|
|
184
|
+
writeRecords(filtered);
|
|
185
|
+
},
|
|
186
|
+
isPaused: (target, nowMs = Date.now())=>resolveRecord(target, nowMs).paused,
|
|
187
|
+
isStopped: (target, nowMs = Date.now())=>resolveRecord(target, nowMs).stopEnabled
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
exports.createSmsPolicyStore = __webpack_exports__.createSmsPolicyStore;
|
|
191
|
+
exports.normalizeSmsPolicyTarget = __webpack_exports__.normalizeSmsPolicyTarget;
|
|
192
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
193
|
+
"createSmsPolicyStore",
|
|
194
|
+
"normalizeSmsPolicyTarget"
|
|
195
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
196
|
+
Object.defineProperty(exports, '__esModule', {
|
|
197
|
+
value: true
|
|
198
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type SmsAlertMode = "off" | "important-only" | "all";
|
|
2
|
+
export type SmsQuietHours = {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
startMinute: number;
|
|
5
|
+
endMinute: number;
|
|
6
|
+
timezone?: string;
|
|
7
|
+
};
|
|
8
|
+
export type SmsPolicyRecord = {
|
|
9
|
+
target: string;
|
|
10
|
+
paused: boolean;
|
|
11
|
+
pausedUntil: number | null;
|
|
12
|
+
stopEnabled: boolean;
|
|
13
|
+
alertMode: SmsAlertMode;
|
|
14
|
+
quietHours: SmsQuietHours | null;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
updatedAt: number;
|
|
17
|
+
};
|
|
18
|
+
export type SmsPolicyPatch = {
|
|
19
|
+
paused?: boolean;
|
|
20
|
+
pausedUntil?: number | null;
|
|
21
|
+
stopEnabled?: boolean;
|
|
22
|
+
alertMode?: SmsAlertMode;
|
|
23
|
+
quietHours?: unknown;
|
|
24
|
+
};
|
|
25
|
+
export type SmsPolicyStore = {
|
|
26
|
+
load: () => SmsPolicyRecord[];
|
|
27
|
+
save: (records: SmsPolicyRecord[]) => void;
|
|
28
|
+
list: () => SmsPolicyRecord[];
|
|
29
|
+
get: (target: string) => SmsPolicyRecord | null;
|
|
30
|
+
resolve: (target: string, nowMs?: number) => SmsPolicyRecord;
|
|
31
|
+
upsert: (target: string, patch: SmsPolicyPatch, nowMs?: number) => SmsPolicyRecord;
|
|
32
|
+
reset: (target: string) => void;
|
|
33
|
+
isPaused: (target: string, nowMs?: number) => boolean;
|
|
34
|
+
isStopped: (target: string, nowMs?: number) => boolean;
|
|
35
|
+
};
|
|
36
|
+
export declare function normalizeSmsPolicyTarget(raw: string): string | null;
|
|
37
|
+
export declare const createSmsPolicyStore: (resolveConfigDirPath: () => string) => SmsPolicyStore;
|