@pinet/slack-bridge 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 (179) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +570 -0
  3. package/dist/activity-log.d.ts +62 -0
  4. package/dist/activity-log.js +293 -0
  5. package/dist/agent-completion-runtime.d.ts +17 -0
  6. package/dist/agent-completion-runtime.js +26 -0
  7. package/dist/agent-event-runtime.d.ts +13 -0
  8. package/dist/agent-event-runtime.js +27 -0
  9. package/dist/agent-prompt-guidance.d.ts +22 -0
  10. package/dist/agent-prompt-guidance.js +46 -0
  11. package/dist/broker/adapters/slack.d.ts +74 -0
  12. package/dist/broker/adapters/slack.js +563 -0
  13. package/dist/broker/adapters/types.d.ts +1 -0
  14. package/dist/broker/adapters/types.js +1 -0
  15. package/dist/broker/agent-messaging.d.ts +1 -0
  16. package/dist/broker/agent-messaging.js +1 -0
  17. package/dist/broker/auth.d.ts +1 -0
  18. package/dist/broker/auth.js +1 -0
  19. package/dist/broker/client.d.ts +167 -0
  20. package/dist/broker/client.js +624 -0
  21. package/dist/broker/control-plane-dashboard.d.ts +98 -0
  22. package/dist/broker/control-plane-dashboard.js +213 -0
  23. package/dist/broker/ghost-reaper.d.ts +49 -0
  24. package/dist/broker/ghost-reaper.js +209 -0
  25. package/dist/broker/index.d.ts +36 -0
  26. package/dist/broker/index.js +90 -0
  27. package/dist/broker/leader.d.ts +1 -0
  28. package/dist/broker/leader.js +1 -0
  29. package/dist/broker/maintenance.d.ts +1 -0
  30. package/dist/broker/maintenance.js +1 -0
  31. package/dist/broker/message-send.d.ts +1 -0
  32. package/dist/broker/message-send.js +1 -0
  33. package/dist/broker/paths.d.ts +1 -0
  34. package/dist/broker/paths.js +1 -0
  35. package/dist/broker/raw-tcp-loopback.d.ts +1 -0
  36. package/dist/broker/raw-tcp-loopback.js +1 -0
  37. package/dist/broker/router.d.ts +1 -0
  38. package/dist/broker/router.js +1 -0
  39. package/dist/broker/schema.d.ts +9 -0
  40. package/dist/broker/schema.js +63 -0
  41. package/dist/broker/socket-server.d.ts +120 -0
  42. package/dist/broker/socket-server.js +1087 -0
  43. package/dist/broker/types.d.ts +1 -0
  44. package/dist/broker/types.js +1 -0
  45. package/dist/broker-delivery.d.ts +10 -0
  46. package/dist/broker-delivery.js +26 -0
  47. package/dist/broker-inbound-persistence.d.ts +11 -0
  48. package/dist/broker-inbound-persistence.js +22 -0
  49. package/dist/broker-prompt-loader.d.ts +34 -0
  50. package/dist/broker-prompt-loader.js +185 -0
  51. package/dist/broker-runtime-access.d.ts +14 -0
  52. package/dist/broker-runtime-access.js +20 -0
  53. package/dist/broker-runtime.d.ts +100 -0
  54. package/dist/broker-runtime.js +533 -0
  55. package/dist/broker-thread-owner-hints.d.ts +10 -0
  56. package/dist/broker-thread-owner-hints.js +14 -0
  57. package/dist/canvases.d.ts +80 -0
  58. package/dist/canvases.js +221 -0
  59. package/dist/command-registration-runtime.d.ts +9 -0
  60. package/dist/command-registration-runtime.js +9 -0
  61. package/dist/core-tool-guardrails.d.ts +24 -0
  62. package/dist/core-tool-guardrails.js +66 -0
  63. package/dist/deploy-manifest.d.ts +27 -0
  64. package/dist/deploy-manifest.js +197 -0
  65. package/dist/follower-delivery.d.ts +16 -0
  66. package/dist/follower-delivery.js +70 -0
  67. package/dist/follower-runtime.d.ts +61 -0
  68. package/dist/follower-runtime.js +350 -0
  69. package/dist/git-metadata.d.ts +35 -0
  70. package/dist/git-metadata.js +88 -0
  71. package/dist/guardrails.d.ts +69 -0
  72. package/dist/guardrails.js +283 -0
  73. package/dist/helpers.d.ts +550 -0
  74. package/dist/helpers.js +2711 -0
  75. package/dist/home-tab.d.ts +27 -0
  76. package/dist/home-tab.js +242 -0
  77. package/dist/imessage-tools.d.ts +33 -0
  78. package/dist/imessage-tools.js +96 -0
  79. package/dist/inbox-drain-runtime.d.ts +30 -0
  80. package/dist/inbox-drain-runtime.js +71 -0
  81. package/dist/index.d.ts +2 -0
  82. package/dist/index.js +1330 -0
  83. package/dist/persisted-runtime-state.d.ts +52 -0
  84. package/dist/persisted-runtime-state.js +98 -0
  85. package/dist/pinet-activity-formatting.d.ts +20 -0
  86. package/dist/pinet-activity-formatting.js +43 -0
  87. package/dist/pinet-agent-status.d.ts +36 -0
  88. package/dist/pinet-agent-status.js +48 -0
  89. package/dist/pinet-commands.d.ts +70 -0
  90. package/dist/pinet-commands.js +402 -0
  91. package/dist/pinet-confirmation-replies.d.ts +7 -0
  92. package/dist/pinet-confirmation-replies.js +30 -0
  93. package/dist/pinet-control-plane-dashboard.d.ts +34 -0
  94. package/dist/pinet-control-plane-dashboard.js +86 -0
  95. package/dist/pinet-home-tabs.d.ts +36 -0
  96. package/dist/pinet-home-tabs.js +101 -0
  97. package/dist/pinet-maintenance-delivery.d.ts +22 -0
  98. package/dist/pinet-maintenance-delivery.js +45 -0
  99. package/dist/pinet-mesh-ops.d.ts +97 -0
  100. package/dist/pinet-mesh-ops.js +266 -0
  101. package/dist/pinet-registration-gate.d.ts +14 -0
  102. package/dist/pinet-registration-gate.js +42 -0
  103. package/dist/pinet-remote-control-acks.d.ts +16 -0
  104. package/dist/pinet-remote-control-acks.js +46 -0
  105. package/dist/pinet-remote-control.d.ts +17 -0
  106. package/dist/pinet-remote-control.js +74 -0
  107. package/dist/pinet-runtime-composition.d.ts +27 -0
  108. package/dist/pinet-runtime-composition.js +20 -0
  109. package/dist/pinet-tools.d.ts +67 -0
  110. package/dist/pinet-tools.js +1211 -0
  111. package/dist/prompts/broker/default.md +41 -0
  112. package/dist/prompts/broker/tmux.md +49 -0
  113. package/dist/ralph-loop.d.ts +76 -0
  114. package/dist/ralph-loop.js +524 -0
  115. package/dist/reaction-triggers.d.ts +25 -0
  116. package/dist/reaction-triggers.js +171 -0
  117. package/dist/repo-tool-guardrails.d.ts +20 -0
  118. package/dist/repo-tool-guardrails.js +81 -0
  119. package/dist/runtime-agent-context.d.ts +93 -0
  120. package/dist/runtime-agent-context.js +302 -0
  121. package/dist/runtime-mode.d.ts +10 -0
  122. package/dist/runtime-mode.js +39 -0
  123. package/dist/scheduled-wakeups.d.ts +1 -0
  124. package/dist/scheduled-wakeups.js +1 -0
  125. package/dist/session-ui-runtime.d.ts +20 -0
  126. package/dist/session-ui-runtime.js +163 -0
  127. package/dist/single-player-runtime.d.ts +71 -0
  128. package/dist/single-player-runtime.js +436 -0
  129. package/dist/skins/cosmere.json +1571 -0
  130. package/dist/skins/foundation.json +1304 -0
  131. package/dist/slack-access.d.ts +186 -0
  132. package/dist/slack-access.js +462 -0
  133. package/dist/slack-api.d.ts +2 -0
  134. package/dist/slack-api.js +1 -0
  135. package/dist/slack-block-kit.d.ts +36 -0
  136. package/dist/slack-block-kit.js +242 -0
  137. package/dist/slack-export.d.ts +31 -0
  138. package/dist/slack-export.js +206 -0
  139. package/dist/slack-message-context.d.ts +15 -0
  140. package/dist/slack-message-context.js +207 -0
  141. package/dist/slack-modals.d.ts +13 -0
  142. package/dist/slack-modals.js +79 -0
  143. package/dist/slack-pinet-runtime-adapter.d.ts +16 -0
  144. package/dist/slack-pinet-runtime-adapter.js +72 -0
  145. package/dist/slack-presence.d.ts +36 -0
  146. package/dist/slack-presence.js +89 -0
  147. package/dist/slack-request-runtime.d.ts +8 -0
  148. package/dist/slack-request-runtime.js +19 -0
  149. package/dist/slack-runtime-access.d.ts +28 -0
  150. package/dist/slack-runtime-access.js +107 -0
  151. package/dist/slack-scope-diagnostics.d.ts +31 -0
  152. package/dist/slack-scope-diagnostics.js +235 -0
  153. package/dist/slack-socket-dedup.d.ts +7 -0
  154. package/dist/slack-socket-dedup.js +135 -0
  155. package/dist/slack-thread-status.d.ts +41 -0
  156. package/dist/slack-thread-status.js +156 -0
  157. package/dist/slack-tool-policy-runtime.d.ts +36 -0
  158. package/dist/slack-tool-policy-runtime.js +96 -0
  159. package/dist/slack-tools.d.ts +52 -0
  160. package/dist/slack-tools.js +2688 -0
  161. package/dist/slack-turn-guardrails.d.ts +19 -0
  162. package/dist/slack-turn-guardrails.js +36 -0
  163. package/dist/slack-upload.d.ts +49 -0
  164. package/dist/slack-upload.js +224 -0
  165. package/dist/task-assignments.d.ts +45 -0
  166. package/dist/task-assignments.js +527 -0
  167. package/dist/thread-confirmations.d.ts +22 -0
  168. package/dist/thread-confirmations.js +139 -0
  169. package/dist/tool-registration-runtime.d.ts +13 -0
  170. package/dist/tool-registration-runtime.js +13 -0
  171. package/dist/ttl-cache.d.ts +47 -0
  172. package/dist/ttl-cache.js +105 -0
  173. package/manifest.yaml +57 -0
  174. package/package.json +60 -0
  175. package/skills/pinet-skin-creator/SKILL.md +109 -0
  176. package/skills/pinet-skin-creator/references/descriptor-format.md +99 -0
  177. package/skills/pinet-skin-creator/references/safety-checklist.md +56 -0
  178. package/skills/pinet-skin-creator/templates/pinet-skin-descriptor.json +77 -0
  179. package/skills/slack-bridge/SKILL.md +360 -0
@@ -0,0 +1,74 @@
1
+ import { finishPinetRemoteControl, queuePinetRemoteControl, } from "./helpers.js";
2
+ function createInitialRemoteControlState() {
3
+ return {
4
+ currentCommand: null,
5
+ queuedCommand: null,
6
+ };
7
+ }
8
+ export function createPinetRemoteControl(deps) {
9
+ let remoteControlState = createInitialRemoteControlState();
10
+ function resetRemoteControlState() {
11
+ remoteControlState = createInitialRemoteControlState();
12
+ }
13
+ function runRemoteControl(command, ctx) {
14
+ deps.flushDeferredRemoteControlAcks(command);
15
+ const controlCtx = ctx;
16
+ if (!(ctx.isIdle?.() ?? true)) {
17
+ try {
18
+ controlCtx.abort?.();
19
+ }
20
+ catch {
21
+ /* best effort */
22
+ }
23
+ }
24
+ ctx.ui.notify(`Pinet remote control requested: /${command}`, "warning");
25
+ void (async () => {
26
+ try {
27
+ if (command === "interrupt") {
28
+ return;
29
+ }
30
+ if (command === "reload") {
31
+ await deps.reloadPinetRuntime(ctx);
32
+ return;
33
+ }
34
+ if (typeof controlCtx.shutdown !== "function") {
35
+ throw new Error("Shutdown is not available in this extension context.");
36
+ }
37
+ controlCtx.shutdown();
38
+ }
39
+ catch (err) {
40
+ ctx.ui.notify(`Pinet remote control failed: ${deps.formatError(err)}`, "error");
41
+ }
42
+ finally {
43
+ const next = finishPinetRemoteControl(remoteControlState);
44
+ remoteControlState = {
45
+ currentCommand: next.currentCommand,
46
+ queuedCommand: next.queuedCommand,
47
+ };
48
+ if (next.nextCommand) {
49
+ ctx.ui.notify(`Pinet remote control continuing with queued /${next.nextCommand}`, "warning");
50
+ runRemoteControl(next.nextCommand, ctx);
51
+ }
52
+ }
53
+ })();
54
+ }
55
+ function requestRemoteControl(command, ctx) {
56
+ const queued = queuePinetRemoteControl(remoteControlState, command);
57
+ remoteControlState = {
58
+ currentCommand: queued.currentCommand,
59
+ queuedCommand: queued.queuedCommand,
60
+ };
61
+ if (queued.status === "queued") {
62
+ ctx.ui.notify(`Pinet remote control queued: /${queued.queuedCommand ?? command}`, "warning");
63
+ }
64
+ else if (!queued.shouldStartNow) {
65
+ ctx.ui.notify(`Pinet remote control already scheduled — keeping /${queued.scheduledCommand}`, "warning");
66
+ }
67
+ return queued;
68
+ }
69
+ return {
70
+ requestRemoteControl,
71
+ runRemoteControl,
72
+ resetRemoteControlState,
73
+ };
74
+ }
@@ -0,0 +1,27 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { Broker } from "./broker/index.js";
3
+ import type { MessageRouter } from "./broker/router.js";
4
+ import type { InboundMessage, MessageAdapter } from "./broker/types.js";
5
+ export interface PinetRuntimeAdapterBinding {
6
+ /** Transport adapter to attach to the broker runtime. */
7
+ adapter: MessageAdapter;
8
+ /** Optional compatibility status used by Slack bridge startup/status surfaces. */
9
+ getBotUserId?: () => string | null;
10
+ }
11
+ export interface PinetRuntimeAdapterFactoryContext {
12
+ broker: Broker;
13
+ router: MessageRouter;
14
+ selfId: string;
15
+ ctx: ExtensionContext;
16
+ }
17
+ export type PinetRuntimeAdapterFactory = (context: PinetRuntimeAdapterFactoryContext) => PinetRuntimeAdapterBinding | PinetRuntimeAdapterBinding[] | Promise<PinetRuntimeAdapterBinding | PinetRuntimeAdapterBinding[]>;
18
+ export interface ConnectPinetRuntimeAdaptersOptions {
19
+ broker: Pick<Broker, "addAdapter">;
20
+ bindings: PinetRuntimeAdapterBinding[];
21
+ onInbound: (message: InboundMessage) => void;
22
+ }
23
+ export interface ConnectPinetRuntimeAdaptersResult {
24
+ botUserId: string | null;
25
+ }
26
+ export declare function buildPinetRuntimeAdapterBindings(factories: readonly PinetRuntimeAdapterFactory[], context: PinetRuntimeAdapterFactoryContext): Promise<PinetRuntimeAdapterBinding[]>;
27
+ export declare function connectPinetRuntimeAdapters({ broker, bindings, onInbound, }: ConnectPinetRuntimeAdaptersOptions): Promise<ConnectPinetRuntimeAdaptersResult>;
@@ -0,0 +1,20 @@
1
+ function normalizeAdapterBindings(value) {
2
+ return Array.isArray(value) ? value : [value];
3
+ }
4
+ export async function buildPinetRuntimeAdapterBindings(factories, context) {
5
+ const bindings = [];
6
+ for (const factory of factories) {
7
+ bindings.push(...normalizeAdapterBindings(await factory(context)));
8
+ }
9
+ return bindings;
10
+ }
11
+ export async function connectPinetRuntimeAdapters({ broker, bindings, onInbound, }) {
12
+ let botUserId = null;
13
+ for (const binding of bindings) {
14
+ binding.adapter.onInbound(onInbound);
15
+ broker.addAdapter(binding.adapter);
16
+ await binding.adapter.connect();
17
+ botUserId ??= binding.getBotUserId?.() ?? null;
18
+ }
19
+ return { botUserId };
20
+ }
@@ -0,0 +1,67 @@
1
+ import { type PinetReadOptions, type PinetReadResult } from "@pinet/pinet-core/pinet-read-formatting";
2
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
3
+ import type { RalphSnoozeStatus } from "./ralph-loop.js";
4
+ import type { PortLeaseAcquireInput, PortLeaseInfo, PortLeaseListOptions, PortLeaseReleaseInput, PortLeaseRenewInput, PinetLaneInfo, PinetLaneListOptions, PinetLaneParticipantInfo, PinetLaneParticipantUpsertInput, PinetLaneUpsertInput } from "./broker/types.js";
5
+ export interface PinetToolsAgentRecord {
6
+ emoji: string;
7
+ name: string;
8
+ id: string;
9
+ pid?: number;
10
+ status: "working" | "idle";
11
+ metadata: Record<string, unknown> | null;
12
+ lastHeartbeat: string;
13
+ lastSeen?: string;
14
+ disconnectedAt?: string | null;
15
+ resumableUntil?: string | null;
16
+ outboundCount?: number;
17
+ pendingInboxCount?: number;
18
+ }
19
+ export interface RegisterPinetToolsDeps {
20
+ pinetEnabled: () => boolean;
21
+ brokerRole: () => "broker" | "follower" | null;
22
+ requireToolPolicy: (toolName: string, threadTs: string | undefined, action: string) => void;
23
+ sendPinetAgentMessage: (target: string, body: string, metadata?: Record<string, unknown>) => Promise<{
24
+ messageId: number;
25
+ target: string;
26
+ transferredThreadId?: string;
27
+ transferredThreadChannel?: string;
28
+ }>;
29
+ sendPinetBroadcastMessage: (channel: string, body: string) => {
30
+ channel: string;
31
+ messageIds: number[];
32
+ recipients: string[];
33
+ };
34
+ signalAgentFree: (ctx: ExtensionContext | undefined, options: {
35
+ requirePinet?: boolean;
36
+ }) => Promise<{
37
+ queuedInboxCount: number;
38
+ drainedQueuedInbox: boolean;
39
+ }>;
40
+ scheduleBrokerWakeup: (fireAt: string, message: string) => Promise<{
41
+ id: number;
42
+ fireAt: string;
43
+ }>;
44
+ scheduleFollowerWakeup: (fireAt: string, message: string) => Promise<{
45
+ id: number;
46
+ fireAt: string;
47
+ }>;
48
+ readPinetInbox: (options: PinetReadOptions) => Promise<PinetReadResult>;
49
+ listBrokerAgents: () => PinetToolsAgentRecord[];
50
+ listFollowerAgents: (includeGhosts: boolean) => Promise<PinetToolsAgentRecord[]>;
51
+ listPinetLanes: (options: PinetLaneListOptions) => Promise<PinetLaneInfo[]>;
52
+ upsertPinetLane: (input: PinetLaneUpsertInput) => Promise<PinetLaneInfo>;
53
+ setPinetLaneParticipant: (input: PinetLaneParticipantUpsertInput) => Promise<PinetLaneParticipantInfo>;
54
+ acquirePortLease: (input: PortLeaseAcquireInput) => Promise<PortLeaseInfo>;
55
+ renewPortLease: (input: PortLeaseRenewInput) => Promise<PortLeaseInfo>;
56
+ releasePortLease: (input: PortLeaseReleaseInput) => Promise<PortLeaseInfo>;
57
+ getPortLease: (leaseId: string) => Promise<PortLeaseInfo | null>;
58
+ listPortLeases: (options: PortLeaseListOptions) => Promise<PortLeaseInfo[]>;
59
+ expirePortLeases: () => Promise<PortLeaseInfo[]>;
60
+ ralphSnoozeStatus?: () => RalphSnoozeStatus | null;
61
+ snoozeRalphLoop?: (input: {
62
+ durationMs: number;
63
+ reason?: string | null;
64
+ }) => RalphSnoozeStatus;
65
+ clearRalphSnooze?: () => RalphSnoozeStatus;
66
+ }
67
+ export declare function registerPinetTools(pi: ExtensionAPI, deps: RegisterPinetToolsDeps): void;