instar 0.24.22 → 0.24.24

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/dist/cli.js CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAimCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAinGtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAimCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuqGtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -3057,6 +3057,19 @@ export async function startServer(options) {
3057
3057
  console.log(pc.green(' Commitment sentinel enabled (LLM-powered)'));
3058
3058
  }
3059
3059
  // Presence Proxy — Intelligent Response Standby (tiered status updates)
3060
+ // Slack bridge: PresenceProxy uses numeric topicIds internally. For Slack channels,
3061
+ // we assign stable negative synthetic IDs and route sendMessage to the correct platform.
3062
+ const slackProxyChannelMap = new Map(); // syntheticId -> Slack channelId
3063
+ function slackChannelToSyntheticId(channelId) {
3064
+ // Stable hash: sum of char codes, negated to avoid Telegram topic ID collisions
3065
+ let hash = 0;
3066
+ for (let i = 0; i < channelId.length; i++) {
3067
+ hash = ((hash << 5) - hash + channelId.charCodeAt(i)) | 0;
3068
+ }
3069
+ const syntheticId = -(Math.abs(hash) + 1); // Always negative, never 0
3070
+ slackProxyChannelMap.set(syntheticId, channelId);
3071
+ return syntheticId;
3072
+ }
3060
3073
  let presenceProxy;
3061
3074
  if (sharedIntelligence && telegram) {
3062
3075
  try {
@@ -3097,9 +3110,23 @@ export async function startServer(options) {
3097
3110
  }
3098
3111
  },
3099
3112
  captureSessionOutput: (name, lines) => sessionManager.captureOutput(name, lines),
3100
- getSessionForTopic: (topicId) => telegram.getSessionForTopic(topicId),
3113
+ getSessionForTopic: (topicId) => {
3114
+ // Check if this is a Slack synthetic ID
3115
+ const slackChId = slackProxyChannelMap.get(topicId);
3116
+ if (slackChId && _slackAdapter) {
3117
+ return _slackAdapter.getSessionForChannel(slackChId) ?? null;
3118
+ }
3119
+ return telegram.getSessionForTopic(topicId);
3120
+ },
3101
3121
  isSessionAlive: (name) => sessionManager.isSessionAlive(name),
3102
3122
  sendMessage: async (topicId, text, metadata) => {
3123
+ // Check if this is a Slack synthetic ID (negative = Slack channel)
3124
+ const slackChannelId = slackProxyChannelMap.get(topicId);
3125
+ if (slackChannelId && _slackAdapter) {
3126
+ // Route directly to Slack channel
3127
+ await _slackAdapter.sendToChannel(slackChannelId, text);
3128
+ return;
3129
+ }
3103
3130
  // Send to Telegram
3104
3131
  const url = `http://localhost:${config.port}/telegram/reply/${topicId}`;
3105
3132
  const response = await fetch(url, {
@@ -3121,9 +3148,9 @@ export async function startServer(options) {
3121
3148
  const sessionName = telegram?.getSessionForTopic?.(topicId);
3122
3149
  if (sessionName) {
3123
3150
  // Find the Slack channel bound to that session
3124
- const slackChannelId = _slackAdapter.getChannelForSession(sessionName);
3125
- if (slackChannelId) {
3126
- _slackAdapter.sendToChannel(slackChannelId, text).catch(() => { });
3151
+ const mirrorChannelId = _slackAdapter.getChannelForSession(sessionName);
3152
+ if (mirrorChannelId) {
3153
+ _slackAdapter.sendToChannel(mirrorChannelId, text).catch(() => { });
3127
3154
  }
3128
3155
  }
3129
3156
  }
@@ -3183,6 +3210,30 @@ export async function startServer(options) {
3183
3210
  });
3184
3211
  };
3185
3212
  presenceProxy.start();
3213
+ // Wire Slack's onMessageLogged into PresenceProxy (if Slack is active)
3214
+ if (_slackAdapter) {
3215
+ const existingSlackCallback = _slackAdapter.onMessageLogged;
3216
+ _slackAdapter.onMessageLogged = (entry) => {
3217
+ if (existingSlackCallback) {
3218
+ existingSlackCallback(entry);
3219
+ }
3220
+ // Convert Slack channelId to synthetic numeric ID for PresenceProxy
3221
+ if (!entry.channelId)
3222
+ return;
3223
+ const syntheticId = slackChannelToSyntheticId(String(entry.channelId));
3224
+ presenceProxy.onMessageLogged({
3225
+ messageId: typeof entry.messageId === 'number' ? entry.messageId : parseInt(String(entry.messageId), 10) || 0,
3226
+ channelId: syntheticId.toString(),
3227
+ text: entry.text,
3228
+ fromUser: entry.fromUser,
3229
+ timestamp: entry.timestamp,
3230
+ sessionName: entry.sessionName,
3231
+ senderName: entry.senderName,
3232
+ platformUserId: entry.platformUserId != null ? String(entry.platformUserId) : undefined,
3233
+ });
3234
+ };
3235
+ console.log(pc.green(' Presence Proxy wired to Slack'));
3236
+ }
3186
3237
  console.log(pc.green(' Presence Proxy enabled (🔭 [Standby])'));
3187
3238
  }
3188
3239
  catch (err) {