alaska-ai 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 (74) hide show
  1. package/README.md +56 -0
  2. package/dist/adapters/slack.d.ts +130 -0
  3. package/dist/adapters/slack.js +1484 -0
  4. package/dist/adapters/slack.js.map +1 -0
  5. package/dist/backends/claude.d.ts +78 -0
  6. package/dist/backends/claude.js +452 -0
  7. package/dist/backends/claude.js.map +1 -0
  8. package/dist/backends/codex.d.ts +53 -0
  9. package/dist/backends/codex.js +324 -0
  10. package/dist/backends/codex.js.map +1 -0
  11. package/dist/cli/init.d.ts +50 -0
  12. package/dist/cli/init.js +386 -0
  13. package/dist/cli/init.js.map +1 -0
  14. package/dist/cli/prompt.d.ts +31 -0
  15. package/dist/cli/prompt.js +145 -0
  16. package/dist/cli/prompt.js.map +1 -0
  17. package/dist/cli/start.d.ts +28 -0
  18. package/dist/cli/start.js +522 -0
  19. package/dist/cli/start.js.map +1 -0
  20. package/dist/cli.d.ts +2 -0
  21. package/dist/cli.js +65 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +8 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/mcp/callbacks.d.ts +32 -0
  27. package/dist/mcp/callbacks.js +181 -0
  28. package/dist/mcp/callbacks.js.map +1 -0
  29. package/dist/mcp/config.d.ts +15 -0
  30. package/dist/mcp/config.js +22 -0
  31. package/dist/mcp/config.js.map +1 -0
  32. package/dist/mcp/entry.d.ts +13 -0
  33. package/dist/mcp/entry.js +119 -0
  34. package/dist/mcp/entry.js.map +1 -0
  35. package/dist/mcp/file-browser.d.ts +15 -0
  36. package/dist/mcp/file-browser.js +135 -0
  37. package/dist/mcp/file-browser.js.map +1 -0
  38. package/dist/mcp/ipc-server.d.ts +64 -0
  39. package/dist/mcp/ipc-server.js +380 -0
  40. package/dist/mcp/ipc-server.js.map +1 -0
  41. package/dist/mcp/preview-server.d.ts +33 -0
  42. package/dist/mcp/preview-server.js +254 -0
  43. package/dist/mcp/preview-server.js.map +1 -0
  44. package/dist/mcp/server.d.ts +51 -0
  45. package/dist/mcp/server.js +257 -0
  46. package/dist/mcp/server.js.map +1 -0
  47. package/dist/mcp/tunnel.d.ts +17 -0
  48. package/dist/mcp/tunnel.js +154 -0
  49. package/dist/mcp/tunnel.js.map +1 -0
  50. package/dist/router.d.ts +113 -0
  51. package/dist/router.js +511 -0
  52. package/dist/router.js.map +1 -0
  53. package/dist/sandbox-policy.d.ts +6 -0
  54. package/dist/sandbox-policy.js +46 -0
  55. package/dist/sandbox-policy.js.map +1 -0
  56. package/dist/scheduler.d.ts +42 -0
  57. package/dist/scheduler.js +169 -0
  58. package/dist/scheduler.js.map +1 -0
  59. package/dist/store.d.ts +95 -0
  60. package/dist/store.js +353 -0
  61. package/dist/store.js.map +1 -0
  62. package/dist/types/adapter.d.ts +50 -0
  63. package/dist/types/adapter.js +9 -0
  64. package/dist/types/adapter.js.map +1 -0
  65. package/dist/types/backend.d.ts +73 -0
  66. package/dist/types/backend.js +8 -0
  67. package/dist/types/backend.js.map +1 -0
  68. package/dist/types/events.d.ts +47 -0
  69. package/dist/types/events.js +9 -0
  70. package/dist/types/events.js.map +1 -0
  71. package/dist/utils.d.ts +59 -0
  72. package/dist/utils.js +272 -0
  73. package/dist/utils.js.map +1 -0
  74. package/package.json +50 -0
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # alaska-ai
2
+
3
+ `alaska-ai` is a Node.js CLI package that starts the AI bridge service.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g alaska-ai
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ alaska-ai start
15
+ ```
16
+
17
+ On first start, the setup wizard runs and requires a sandbox root directory (`projects_root`).
18
+ All project directories must stay under that root.
19
+
20
+ or run without global install:
21
+
22
+ ```bash
23
+ npx alaska-ai start
24
+ ```
25
+
26
+ Available commands:
27
+
28
+ - `alaska-ai start` start the bridge (default command)
29
+ - `alaska-ai configure` open settings menu
30
+ - `alaska-ai init` run setup wizard
31
+ - `alaska-ai --help` show help
32
+
33
+ ## Development
34
+
35
+ ```bash
36
+ npm install
37
+ npm run build
38
+ node dist/cli.js --help
39
+ npm start
40
+ ```
41
+
42
+ Database setup for fresh deployments:
43
+
44
+ ```bash
45
+ # Apply base schema first, then sandbox hardening constraints
46
+ psql "$SUPABASE_DB_URL" -f supabase/schema.sql
47
+ psql "$SUPABASE_DB_URL" -f supabase/init_sandbox.sql
48
+ ```
49
+
50
+ ## Publish to npm
51
+
52
+ ```bash
53
+ npm login
54
+ npm run prepublishOnly
55
+ npm publish --access public
56
+ ```
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Slack adapter for Alaska.
3
+ *
4
+ * Connects to Slack via Socket Mode using @slack/bolt.
5
+ * Listens for messages and slash commands, routes them through the router,
6
+ * and posts responses back to the appropriate threads.
7
+ */
8
+ import { App } from '@slack/bolt';
9
+ import type { Router } from '../router.js';
10
+ import type { Store } from '../store.js';
11
+ export interface SlackAdapterOptions {
12
+ botToken: string;
13
+ appToken: string;
14
+ router: Router;
15
+ store: Store;
16
+ /** Optional pre-created App instance (for testing). */
17
+ app?: App;
18
+ }
19
+ export declare function createBoltApp(botToken: string, appToken: string): App;
20
+ export declare class SlackAdapter {
21
+ private app;
22
+ private router;
23
+ private store;
24
+ private botUserId;
25
+ /** Message refs for pending AskUserQuestion prompts, for updating on resolution. */
26
+ private questionMessages;
27
+ /** Message refs for todo checklist messages, keyed by threadId (one per thread). */
28
+ private todoMessages;
29
+ /** Tracked permission/question ack messages per thread, for :eyes: cleanup after backend responds. */
30
+ private permissionAckMessages;
31
+ constructor(options: SlackAdapterOptions);
32
+ /** Start the Slack adapter - connects via Socket Mode. */
33
+ start(): Promise<void>;
34
+ /** Stop the Slack adapter - disconnect. */
35
+ stop(): Promise<void>;
36
+ /** Get the underlying Bolt app (for testing). */
37
+ getApp(): App;
38
+ /** Register all Slack event handlers. */
39
+ private registerHandlers;
40
+ /**
41
+ * Auto-join a channel if the bot isn't already in it.
42
+ * Returns true if the bot is in the channel, false if it can't join.
43
+ */
44
+ private ensureInChannel;
45
+ /** React with :eyes: to acknowledge a user's message. */
46
+ private reactSeen;
47
+ /** Remove the :eyes: reaction after the backend has responded. */
48
+ private removeReactSeen;
49
+ /** Swap :eyes: to checkmarkto confirm a schedule was created (no text reply needed). */
50
+ private reactScheduleConfirm;
51
+ /** Track a permission/question ack message for later :eyes: cleanup. */
52
+ private trackPermissionAck;
53
+ /** Remove :eyes: from all tracked permission ack messages for a thread. */
54
+ private cleanupPermissionAcks;
55
+ /** Handle an incoming Slack message. */
56
+ private handleMessage;
57
+ /** Handle freeform text when session is waiting_for_input. */
58
+ private handleFreeformResponse;
59
+ /** Handle permission Allow/Deny/Always Allow button clicks.
60
+ * Button value is "toolName|requestId" (hook flow) or "toolName" (legacy). */
61
+ private handlePermissionAction;
62
+ /** Render normalized events as Slack messages in a thread. */
63
+ private renderEvents;
64
+ /** Post text response, splitting if it exceeds Slack's limit. */
65
+ postText(channelId: string, threadTs: string, text: string, client: any): Promise<void>;
66
+ /** Post a permission denial prompt with Allow/Deny buttons.
67
+ * When event.requestId is set (hook-based flow), it's embedded in button values
68
+ * so the action handler can resolve the permission in-process. */
69
+ postPermissionPrompt(channelId: string, threadTs: string, event: {
70
+ toolName: string;
71
+ toolInput: Record<string, unknown>;
72
+ context?: string;
73
+ requestId?: string;
74
+ }, client: any): Promise<void>;
75
+ /** Post an interactive question with dynamic option buttons.
76
+ * Renders the first question from AskUserQuestion as Slack blocks with buttons. */
77
+ postUserQuestion(channelId: string, threadTs: string, questions: Array<{
78
+ question: string;
79
+ header: string;
80
+ options: Array<{
81
+ label: string;
82
+ description: string;
83
+ }>;
84
+ multiSelect: boolean;
85
+ }>, requestId: string, client: any): Promise<void>;
86
+ /** Handle AskUserQuestion option button clicks.
87
+ * Resolves the pending question via IPC and updates the message. */
88
+ private handleQuestionAnswer;
89
+ /** Post an error message. */
90
+ postError(channelId: string, threadTs: string, message: string, client: any): Promise<void>;
91
+ /** Build the list of /project subcommand descriptions. */
92
+ private getProjectCommandLines;
93
+ /** Handle /project slash command. */
94
+ private handleProjectCommand;
95
+ /** Handle project connect flow - bind a directory to a channel. */
96
+ private handleProjectConnect;
97
+ /** Post a project picker with pagination support. */
98
+ private postProjectPicker;
99
+ /** Get the default backend, or throw if not configured. */
100
+ private getDefaultBackend;
101
+ /** Handle permission mode button action. */
102
+ private handlePermModeAction;
103
+ /** Post a sandbox denial notice (no upgrade path). */
104
+ private postSandboxDeniedNotice;
105
+ /** Post permission mode selection prompt after project creation. */
106
+ private postPermissionModePrompt;
107
+ /** Bind a project to a channel and post confirmation. */
108
+ private bindProjectToChannel;
109
+ /** Create a new Slack channel, bind a project to it, and invite the user. */
110
+ private createChannelAndBind;
111
+ /** Handle name_taken error when creating a channel - offer to bind existing. */
112
+ private handleNameTaken;
113
+ /** Handle /settings slash command. */
114
+ private handleSettingsCommand;
115
+ /** Handle file uploads in messages - downloads all file types for backend passthrough. */
116
+ handleFileUpload(channelId: string, threadTs: string, files: any[], text: string, client: any, messageTs?: string): Promise<void>;
117
+ /** Upload a file to a Slack thread. Called by MCP callback handler. */
118
+ uploadFile(channelId: string, threadId: string, filePath: string): Promise<void>;
119
+ /** Post a plain text message to a Slack thread. Called by MCP callback handler. */
120
+ sendMessage(channelId: string, threadId: string, text: string): Promise<void>;
121
+ createThread(channelId: string, title: string): Promise<string>;
122
+ /** Format todos as Slack mrkdwn checklist. */
123
+ private formatTodosSlack;
124
+ renderTodoList(channelId: string, threadId: string, todos: Array<{
125
+ content: string;
126
+ status: string;
127
+ activeForm: string;
128
+ }>): Promise<void>;
129
+ }
130
+ export { splitText } from '../utils.js';