@opentag/dispatcher 0.1.0 → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Amplift
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -15,6 +15,7 @@ pnpm add @opentag/dispatcher
15
15
  - `createDispatcherApp`: creates the Hono app that exposes the OpenTag dispatcher API.
16
16
  - `createGitHubCallbackSink`: posts callback messages to GitHub issue or PR comments.
17
17
  - `createSlackCallbackSink`: posts callback messages to Slack threads through `chat.postMessage`.
18
+ - `createTelegramCallbackSink`: posts callback messages to Telegram chats through the Bot API `sendMessage` method.
18
19
  - `createCompositeCallbackSink`: fans callback delivery out to multiple sinks.
19
20
  - `CallbackMessage`, `CallbackSink`: callback delivery contracts.
20
21
 
@@ -25,7 +26,8 @@ import {
25
26
  createCompositeCallbackSink,
26
27
  createDispatcherApp,
27
28
  createGitHubCallbackSink,
28
- createSlackCallbackSink
29
+ createSlackCallbackSink,
30
+ createTelegramCallbackSink
29
31
  } from "@opentag/dispatcher";
30
32
 
31
33
  export const dispatcher = createDispatcherApp({
@@ -33,14 +35,15 @@ export const dispatcher = createDispatcherApp({
33
35
  pairingToken: process.env.OPENTAG_PAIRING_TOKEN,
34
36
  callbackSink: createCompositeCallbackSink([
35
37
  createGitHubCallbackSink({ token: process.env.OPENTAG_GITHUB_TOKEN }),
36
- createSlackCallbackSink({ botToken: process.env.OPENTAG_SLACK_BOT_TOKEN })
38
+ createSlackCallbackSink({ botToken: process.env.OPENTAG_SLACK_BOT_TOKEN }),
39
+ createTelegramCallbackSink({ botToken: process.env.OPENTAG_TELEGRAM_BOT_TOKEN })
37
40
  ])
38
41
  });
39
42
  ```
40
43
 
41
44
  ## API Shape
42
45
 
43
- The app exposes `/healthz` and `/v1/*` dispatcher endpoints for runners, repository bindings, Slack channel bindings, runs, progress, heartbeats, completion, and audit event lookup.
46
+ The app exposes `/healthz` and `/v1/*` dispatcher endpoints for runners, Project Target bindings, generic channel bindings, Slack compatibility bindings, runs, progress, heartbeats, completion, and audit event lookup.
44
47
 
45
48
  When `pairingToken` is set, every `/v1/*` endpoint requires:
46
49
 
@@ -0,0 +1,44 @@
1
+ import { type OpenTagEvent, type OpenTagRun, type RunAdmissionDecision, type RunAdmissionReasonCode } from "@opentag/core";
2
+ import { type FollowUpRequest, type RepoBinding, type createOpenTagRepository } from "@opentag/store";
3
+ type Repository = ReturnType<typeof createOpenTagRepository>;
4
+ export type AgentAccessProfileCheckInput = {
5
+ event: OpenTagEvent;
6
+ binding: RepoBinding;
7
+ };
8
+ export type AgentAccessProfileCheckResult = {
9
+ allowed: true;
10
+ } | {
11
+ allowed: false;
12
+ reason: string;
13
+ reasonCode?: Extract<RunAdmissionReasonCode, "agent_access_profile_denied" | "policy_rejected">;
14
+ };
15
+ export type AgentAccessProfileCheck = (input: AgentAccessProfileCheckInput) => Promise<AgentAccessProfileCheckResult>;
16
+ export type AdmitRunInput = {
17
+ requestId: string;
18
+ event: OpenTagEvent;
19
+ };
20
+ export type AdmitRunResult = {
21
+ outcome: "start";
22
+ decision: RunAdmissionDecision;
23
+ binding: RepoBinding;
24
+ } | {
25
+ outcome: "drop_duplicate";
26
+ decision: RunAdmissionDecision;
27
+ run: OpenTagRun;
28
+ idempotentReplay: true;
29
+ } | {
30
+ outcome: "follow_up_queued";
31
+ decision: RunAdmissionDecision;
32
+ followUpRequest: FollowUpRequest;
33
+ } | {
34
+ outcome: "needs_human_decision";
35
+ decision: RunAdmissionDecision;
36
+ };
37
+ export declare function createAdmissionRuntime(input: {
38
+ repo: Repository;
39
+ agentAccessProfileCheck?: AgentAccessProfileCheck;
40
+ }): {
41
+ admitRun(request: AdmitRunInput): Promise<AdmitRunResult>;
42
+ };
43
+ export {};
44
+ //# sourceMappingURL=admission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admission.d.ts","sourceRoot":"","sources":["../src/admission.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,WAAW,EAAE,KAAK,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEtG,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAE7D,MAAM,MAAM,4BAA4B,GAAG;IACzC,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GACrC;IAAE,OAAO,EAAE,IAAI,CAAA;CAAE,GACjB;IACE,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC,sBAAsB,EAAE,6BAA6B,GAAG,iBAAiB,CAAC,CAAC;CACjG,CAAC;AAEN,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,4BAA4B,KAAK,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAEtH,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB;IACE,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB,GACD;IACE,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,GAAG,EAAE,UAAU,CAAC;IAChB,gBAAgB,EAAE,IAAI,CAAC;CACxB,GACD;IACE,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,eAAe,EAAE,eAAe,CAAC;CAClC,GACD;IACE,OAAO,EAAE,sBAAsB,CAAC;IAChC,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAgCN,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,UAAU,CAAC;IACjB,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;sBAI2B,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;EAoHlE"}
@@ -1,3 +1,4 @@
1
+ import { type LarkReplyClient } from "@opentag/lark";
1
2
  import type { CallbackSink } from "./server.js";
2
3
  export type FetchLike = typeof fetch;
3
4
  export declare function createGitHubCallbackSink(input: {
@@ -6,6 +7,18 @@ export declare function createGitHubCallbackSink(input: {
6
7
  }): CallbackSink;
7
8
  export declare function createSlackCallbackSink(input: {
8
9
  botToken?: string;
10
+ botTokensByAgentId?: Record<string, string>;
11
+ fetchImpl?: FetchLike;
12
+ }): CallbackSink;
13
+ export declare function createLarkCallbackSink(input: {
14
+ appId?: string;
15
+ appSecret?: string;
16
+ domain?: "lark" | "feishu";
17
+ client?: LarkReplyClient;
18
+ }): CallbackSink;
19
+ export declare function createTelegramCallbackSink(input: {
20
+ botToken?: string;
21
+ botTokensByAgentId?: Record<string, string>;
9
22
  fetchImpl?: FetchLike;
10
23
  }): CallbackSink;
11
24
  export declare function createCompositeCallbackSink(sinks: CallbackSink[]): CallbackSink;
@@ -1 +1 @@
1
- {"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../src/callbacks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AAErC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAwBvG;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CA+BzG;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,YAAY,CAQ/E"}
1
+ {"version":3,"file":"callbacks.d.ts","sourceRoot":"","sources":["../src/callbacks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,eAAe,EAAwC,MAAM,eAAe,CAAC;AAGlH,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,aAAa,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC;AA8BrC,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CA+CvG;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,YAAY,CA0Df;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,GAAG,YAAY,CA0Bf;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,GAAG,YAAY,CAyDf;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,YAAY,CAQ/E"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./callbacks.js";
2
+ export * from "./presentation.js";
2
3
  export * from "./server.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}