@s-gw/s-gw 0.1.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.
Files changed (123) hide show
  1. package/.codex-plugin/plugin.json +35 -0
  2. package/.mcp.json +16 -0
  3. package/LICENSE +201 -0
  4. package/NOTICE +7 -0
  5. package/README.md +197 -0
  6. package/TRADEMARKS.md +9 -0
  7. package/assets/icons/aws-ec2.png +0 -0
  8. package/assets/icons/lucide/bot.svg +8 -0
  9. package/assets/icons/lucide/monitor.svg +5 -0
  10. package/assets/icons/lucide/server.svg +6 -0
  11. package/assets/icons/lucide/terminal.svg +4 -0
  12. package/assets/icons/s-gw-128.png +0 -0
  13. package/assets/icons/s-gw-16.png +0 -0
  14. package/assets/icons/s-gw-180.png +0 -0
  15. package/assets/icons/s-gw-192.png +0 -0
  16. package/assets/icons/s-gw-32.png +0 -0
  17. package/assets/icons/s-gw-64.png +0 -0
  18. package/assets/icons/s-gw-menu-bar-template.png +0 -0
  19. package/dist/agent-context.d.ts +17 -0
  20. package/dist/agent-context.js +207 -0
  21. package/dist/agents.d.ts +64 -0
  22. package/dist/agents.js +763 -0
  23. package/dist/cli.d.ts +2 -0
  24. package/dist/cli.js +1385 -0
  25. package/dist/command-suggest.d.ts +3 -0
  26. package/dist/command-suggest.js +131 -0
  27. package/dist/console-server.d.ts +16 -0
  28. package/dist/console-server.js +978 -0
  29. package/dist/console-ui/assets/codex-DYTPdPxi.png +0 -0
  30. package/dist/console-ui/assets/cursor-CBrUTJD-.png +0 -0
  31. package/dist/console-ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  32. package/dist/console-ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  33. package/dist/console-ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  34. package/dist/console-ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  35. package/dist/console-ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  36. package/dist/console-ui/assets/hermes-B8hNbJPm.png +0 -0
  37. package/dist/console-ui/assets/index-BxUf0Sye.js +96 -0
  38. package/dist/console-ui/assets/index-CmTiBR_w.css +2 -0
  39. package/dist/console-ui/assets/omnigent-Cxa4p2Mq.png +0 -0
  40. package/dist/console-ui/assets/openclaw-C5wL4ZVW.png +0 -0
  41. package/dist/console-ui/assets/opencode-D_wFATSC.png +0 -0
  42. package/dist/console-ui/assets/openhands-DnrlGgev.svg +9 -0
  43. package/dist/console-ui/assets/s-gw-64-ByMUGQ3K.png +0 -0
  44. package/dist/console-ui/assets/vscode-Bdtr9eyf.png +0 -0
  45. package/dist/console-ui/assets/zeptoclaw-DztQW8Sw.png +0 -0
  46. package/dist/console-ui/index.html +13 -0
  47. package/dist/crypto.d.ts +6 -0
  48. package/dist/crypto.js +53 -0
  49. package/dist/executor.d.ts +7 -0
  50. package/dist/executor.js +297 -0
  51. package/dist/gateway.d.ts +31 -0
  52. package/dist/gateway.js +114 -0
  53. package/dist/guard.d.ts +61 -0
  54. package/dist/guard.js +247 -0
  55. package/dist/install.d.ts +146 -0
  56. package/dist/install.js +629 -0
  57. package/dist/mcp-server.d.ts +2 -0
  58. package/dist/mcp-server.js +119 -0
  59. package/dist/native/s-gw-core +0 -0
  60. package/dist/native/s-gw-keychain-helper +0 -0
  61. package/dist/onepassword.d.ts +48 -0
  62. package/dist/onepassword.js +412 -0
  63. package/dist/paths.d.ts +4 -0
  64. package/dist/paths.js +22 -0
  65. package/dist/s-gw Menu Bar.app/Contents/Info.plist +28 -0
  66. package/dist/s-gw Menu Bar.app/Contents/MacOS/s-gw-menu-bar-helper +0 -0
  67. package/dist/s-gw Menu Bar.app/Contents/Resources/AppIcon.icns +0 -0
  68. package/dist/s-gw Menu Bar.app/Contents/Resources/AwsEc2.png +0 -0
  69. package/dist/s-gw Menu Bar.app/Contents/Resources/Lucide-bot.svg +8 -0
  70. package/dist/s-gw Menu Bar.app/Contents/Resources/Lucide-monitor.svg +5 -0
  71. package/dist/s-gw Menu Bar.app/Contents/Resources/Lucide-server.svg +6 -0
  72. package/dist/s-gw Menu Bar.app/Contents/Resources/Lucide-terminal.svg +4 -0
  73. package/dist/s-gw Menu Bar.app/Contents/Resources/MenuBarTemplate.png +0 -0
  74. package/dist/s-gw Menu Bar.app/Contents/_CodeSignature/CodeResources +194 -0
  75. package/dist/s-gw.app/Contents/Info.plist +28 -0
  76. package/dist/s-gw.app/Contents/MacOS/s-gw +0 -0
  77. package/dist/s-gw.app/Contents/Resources/AppIcon.icns +0 -0
  78. package/dist/s-gw.app/Contents/Resources/MenuBarTemplate.png +0 -0
  79. package/dist/s-gw.app/Contents/_CodeSignature/CodeResources +139 -0
  80. package/dist/scanner.d.ts +9 -0
  81. package/dist/scanner.js +437 -0
  82. package/dist/ssh.d.ts +31 -0
  83. package/dist/ssh.js +286 -0
  84. package/dist/store.d.ts +131 -0
  85. package/dist/store.js +1611 -0
  86. package/dist/types.d.ts +196 -0
  87. package/dist/types.js +2 -0
  88. package/dist/unlock.d.ts +29 -0
  89. package/dist/unlock.js +274 -0
  90. package/dist/windows/VERSION.txt +1 -0
  91. package/dist/windows/s-gw-client.cmd +4 -0
  92. package/dist/windows/s-gw-client.ps1 +106 -0
  93. package/dist/windows/s-gw-credential.cmd +4 -0
  94. package/dist/windows/s-gw-credential.ps1 +167 -0
  95. package/dist/windows/s-gw-helper.cmd +4 -0
  96. package/dist/windows/s-gw-helper.ps1 +180 -0
  97. package/docs/README.md +23 -0
  98. package/docs/agents.md +160 -0
  99. package/docs/architecture.md +72 -0
  100. package/docs/deployment.md +447 -0
  101. package/docs/detection.md +44 -0
  102. package/docs/images/s-gw-overview.png +0 -0
  103. package/docs/integrations.md +195 -0
  104. package/docs/keychain.md +39 -0
  105. package/docs/onepassword.md +84 -0
  106. package/docs/quickstart.md +104 -0
  107. package/docs/threat-model.md +100 -0
  108. package/docs/ui/THIRD_PARTY_NOTICES.md +111 -0
  109. package/docs/ui/apple-touch-icon.png +0 -0
  110. package/docs/ui/favicon-32.png +0 -0
  111. package/docs/ui/local-console.html +4477 -0
  112. package/docs/ui/vendor/d3-sankey/d3-array.LICENSE.txt +27 -0
  113. package/docs/ui/vendor/d3-sankey/d3-array.min.js +2 -0
  114. package/docs/ui/vendor/d3-sankey/d3-path.LICENSE.txt +27 -0
  115. package/docs/ui/vendor/d3-sankey/d3-path.min.js +2 -0
  116. package/docs/ui/vendor/d3-sankey/d3-sankey.LICENSE.txt +27 -0
  117. package/docs/ui/vendor/d3-sankey/d3-sankey.min.js +2 -0
  118. package/docs/ui/vendor/d3-sankey/d3-shape.LICENSE.txt +27 -0
  119. package/docs/ui/vendor/d3-sankey/d3-shape.min.js +2 -0
  120. package/docs/ui/vendor/sankeymatic/LICENSE.txt +17 -0
  121. package/docs/ui/vendor/sankeymatic/sankey.js +897 -0
  122. package/package.json +117 -0
  123. package/skills/s-gw/SKILL.md +19 -0
@@ -0,0 +1,3 @@
1
+ export declare const KNOWN_COMMANDS: string[];
2
+ export declare function unknownCommandMessage(command: string[]): string;
3
+ export declare function suggestCommands(command: string[], limit?: number): string[];
@@ -0,0 +1,131 @@
1
+ // Suggest a fix when someone fat-fingers a command on first run (`s-gw statu`,
2
+ // `s-gw secrets list`). Kept out of cli.ts so it can be unit-tested without importing
3
+ // the CLI entry point, which runs main() on import.
4
+ // The full vocabulary of top-level + two-word commands.
5
+ export const KNOWN_COMMANDS = [
6
+ "init",
7
+ "setup",
8
+ "status",
9
+ "start",
10
+ "stop",
11
+ "doctor",
12
+ "console",
13
+ "help",
14
+ "app open",
15
+ "app app-path",
16
+ "guard status",
17
+ "guard run",
18
+ "run",
19
+ "service install",
20
+ "service start",
21
+ "service stop",
22
+ "service status",
23
+ "service uninstall",
24
+ "menubar open",
25
+ "menubar install",
26
+ "menubar start",
27
+ "menubar stop",
28
+ "menubar status",
29
+ "menubar uninstall",
30
+ "menubar app-path",
31
+ "helper open",
32
+ "helper app-path",
33
+ "unlock status",
34
+ "unlock keychain set",
35
+ "unlock keychain delete",
36
+ "secret add",
37
+ "secret add-1password",
38
+ "secret list",
39
+ "secret delete",
40
+ "onepassword status",
41
+ "onepassword import",
42
+ "onepassword capture",
43
+ "aws plan",
44
+ "aws request",
45
+ "aws run",
46
+ "approval settings",
47
+ "approval set",
48
+ "approval grants",
49
+ "approval revoke",
50
+ "approval clear",
51
+ "scan-file",
52
+ "agent list",
53
+ "agent show",
54
+ "agent mcp-snippet",
55
+ "agent codeguard-plan",
56
+ "request env-command",
57
+ "requests",
58
+ "requests cleanup",
59
+ "store backups",
60
+ "approve",
61
+ "deny",
62
+ "execute",
63
+ "execute-next"
64
+ ];
65
+ export function unknownCommandMessage(command) {
66
+ const typed = command.join(" ");
67
+ const suggestions = suggestCommands(command);
68
+ const tail = suggestions.length
69
+ ? ` Did you mean: ${suggestions.map((s) => `s-gw ${s}`).join(", ")}? Run \`s-gw help\` for all commands.`
70
+ : " Run `s-gw help` to see all commands.";
71
+ return `Unknown command: ${typed}.${tail}`;
72
+ }
73
+ // Suggest the closest known commands to what was typed. We match on the whole phrase
74
+ // and on the first word (so a trailing positional arg the user typed can't drown out
75
+ // the verb match), then fall back to listing a known noun's subcommands.
76
+ export function suggestCommands(command, limit = 3) {
77
+ const typed = command.join(" ").trim().toLowerCase();
78
+ if (!typed) {
79
+ return [];
80
+ }
81
+ const first = (command[0] || "").toLowerCase();
82
+ // Score each candidate by the better of: full-phrase distance, or first-word distance
83
+ // against the candidate's own first word. The latter means `aproove <id>` still maps to
84
+ // `approve` even though the trailing arg inflates the phrase distance.
85
+ const scored = KNOWN_COMMANDS.map((candidate) => {
86
+ const phraseDistance = editDistance(typed, candidate);
87
+ const wordDistance = first ? editDistance(first, candidate.split(" ")[0]) : phraseDistance;
88
+ return { candidate, distance: Math.min(phraseDistance, wordDistance) };
89
+ }).sort((a, b) => a.distance - b.distance);
90
+ // Threshold tracks the shorter of the typed verb / full phrase so short typos
91
+ // (`statu`) still match without a one-word verb matching everything.
92
+ const threshold = Math.max(2, Math.ceil(Math.min(typed.length, Math.max(first.length, 1)) / 3) + 1);
93
+ const best = scored[0]?.distance ?? Infinity;
94
+ if (best <= threshold) {
95
+ // Keep only suggestions within 1 edit of the best match so a clear winner
96
+ // (`deny` for `deni`) isn't diluted by weaker, coincidental matches.
97
+ return scored
98
+ .filter((entry) => entry.distance <= Math.min(threshold, best + 1))
99
+ .map((entry) => entry.candidate)
100
+ .slice(0, limit);
101
+ }
102
+ // No close match — if the noun is real, list its subcommands so a user who typed
103
+ // `s-gw secret` (forgetting `add`/`list`) still gets pointed the right way.
104
+ if (first) {
105
+ const sameNoun = KNOWN_COMMANDS.filter((candidate) => candidate.split(" ")[0] === first && candidate !== first);
106
+ if (sameNoun.length) {
107
+ return sameNoun.slice(0, limit);
108
+ }
109
+ }
110
+ return [];
111
+ }
112
+ // Plain Levenshtein. Small command set, runs once on an error path — clarity over cleverness.
113
+ function editDistance(a, b) {
114
+ const rows = a.length + 1;
115
+ const cols = b.length + 1;
116
+ const dist = Array.from({ length: rows }, () => new Array(cols).fill(0));
117
+ for (let i = 0; i < rows; i += 1) {
118
+ dist[i][0] = i;
119
+ }
120
+ for (let j = 0; j < cols; j += 1) {
121
+ dist[0][j] = j;
122
+ }
123
+ for (let i = 1; i < rows; i += 1) {
124
+ for (let j = 1; j < cols; j += 1) {
125
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
126
+ dist[i][j] = Math.min(dist[i - 1][j] + 1, dist[i][j - 1] + 1, dist[i - 1][j - 1] + cost);
127
+ }
128
+ }
129
+ return dist[rows - 1][cols - 1];
130
+ }
131
+ //# sourceMappingURL=command-suggest.js.map
@@ -0,0 +1,16 @@
1
+ import { type Server } from "node:http";
2
+ import { SecretStore } from "./store.js";
3
+ export interface ConsoleServerOptions {
4
+ host?: string;
5
+ port?: number;
6
+ store?: SecretStore;
7
+ token?: string;
8
+ uiDir?: string;
9
+ }
10
+ export interface RunningConsoleServer {
11
+ url: string;
12
+ token: string;
13
+ server: Server;
14
+ close: () => Promise<void>;
15
+ }
16
+ export declare function startConsoleServer(options?: ConsoleServerOptions): Promise<RunningConsoleServer>;