@markus-global/cli 0.11.3-rc.0 → 0.12.0-rc.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/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +5 -1
- package/dist/backend.js.map +1 -1
- package/dist/commands/approval-card.d.ts +53 -0
- package/dist/commands/approval-card.d.ts.map +1 -0
- package/dist/commands/approval-card.js +43 -0
- package/dist/commands/approval-card.js.map +1 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +11 -5
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +7 -5
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/model.d.ts.map +1 -1
- package/dist/commands/model.js +6 -4
- package/dist/commands/model.js.map +1 -1
- package/dist/commands/outbound.d.ts +76 -0
- package/dist/commands/outbound.d.ts.map +1 -0
- package/dist/commands/outbound.js +80 -0
- package/dist/commands/outbound.js.map +1 -0
- package/dist/commands/start.d.ts +124 -2
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +718 -82
- package/dist/commands/start.js.map +1 -1
- package/dist/index.js +5 -20
- package/dist/index.js.map +1 -1
- package/dist/markus.mjs +112615 -103125
- package/dist/web-ui/assets/AsyncState-BebkDWbq.js +1 -0
- package/dist/web-ui/assets/{CommentInput-C-niUbUY.js → CommentInput-BRZWIC3U.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DxsnJJRX.js → ContentRenderer-PGP8H_Zz.js} +2 -2
- package/dist/web-ui/assets/DeliverableShareModal-CcigVYGz.js +1 -0
- package/dist/web-ui/assets/Deliverables-CQwXaCA4.js +3 -0
- package/dist/web-ui/assets/{Notifications-4KXYRdkr.js → Notifications-BvHJCIRG.js} +1 -1
- package/dist/web-ui/assets/Search-BA-aXh7i.js +1 -0
- package/dist/web-ui/assets/SendToChat-CAfyKhpq.js +1 -0
- package/dist/web-ui/assets/Settings-icFp6tNI.js +8 -0
- package/dist/web-ui/assets/{Store-JWjwXfTU.js → Store-DKwOcmMu.js} +1 -1
- package/dist/web-ui/assets/Switch-C7lFnHA7.js +1 -0
- package/dist/web-ui/assets/Team-DyqXLZ-X.js +84 -0
- package/dist/web-ui/assets/Work-BXGrda4S.js +12 -0
- package/dist/web-ui/assets/{arc-DPZmpo1U.js → arc-Dnk6N-Zc.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-DlOs02JO.js → architectureDiagram-3BPJPVTR-CV8JIXXD.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-C7qsXNUe.js → blockDiagram-GPEHLZMM-D9pKmrXH.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-Drwp-rtM.js → c4Diagram-AAUBKEIU-Q26HvIpY.js} +1 -1
- package/dist/web-ui/assets/channel-BZs6ereM.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-VgR09Mqk.js → chunk-2J33WTMH-BSjFVwnx.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-CuwDpBRL.js → chunk-4BX2VUAB-BZXv4MQp.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-nC7YWJ_i.js → chunk-55IACEB6-CeKd3oeJ.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-Dw6mBsRE.js → chunk-727SXJPM-DP1tSQo5.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CPhNJbHl.js → chunk-AQP2D5EJ-DqEncn7j.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-AyhQakG8.js → chunk-FMBD7UC4-tuDUJ9Xx.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-DgYemv8I.js → chunk-ND2GUHAM-DoC8aLWB.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-CLdqxrFB.js → chunk-QZHKN3VN-74zpvcgs.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-C9JIxJeJ.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-C9JIxJeJ.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DrOgwDIH.js → cose-bilkent-S5V4N54A-DjYUalC1.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-DhoJiA83.js → dagre-BM42HDAG-oSewacE8.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-BDILSgqK.js → diagram-2AECGRRQ-C1fiWe46.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-CeXywd1i.js → diagram-5GNKFQAL-9G_q6hCa.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-Bi4RlMT0.js → diagram-KO2AKTUF-CSm-lJp-.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-Cw1yxk8b.js → diagram-LMA3HP47-BTAORcHx.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-Bl857da2.js → diagram-OG6HWLK6-DbcCkDfo.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-CjoUhrMq.js → docx-preview-DjqdA44x.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DEiaMhuV.js → erDiagram-TEJ5UH35-DFa-B8-u.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BgKZhO0h.js → flowDiagram-I6XJVG4X-WCTnaK9M.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-Dkx-EaS8.js → ganttDiagram-6RSMTGT7-DbW1CoJJ.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DXaQwA0y.js → gitGraphDiagram-PVQCEYII-1faDfO29.js} +1 -1
- package/dist/web-ui/assets/index-B8h1PPzP.js +883 -0
- package/dist/web-ui/assets/index-DD3NMntN.css +1 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-Dpx9IOkx.js → infoDiagram-5YYISTIA-DfXKP4tQ.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-BWqWgitQ.js → ishikawaDiagram-YF4QCWOH-D6FOsFQ5.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-BBwIZ4k9.js → journeyDiagram-JHISSGLW-DXpxntIF.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-C_MRWV8R.js → kanban-definition-UN3LZRKU-Dt7FBCF3.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BMAh3nnq.js → mermaid.core-sTcSUoRD.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-B6vJQcat.js → mindmap-definition-RKZ34NQL-CvOU23ga.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BxdEttqt.js → pieDiagram-4H26LBE5-DUedtXVj.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-gsNs2VfP.js → quadrantDiagram-W4KKPZXB-CqpHHRca.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BSC9KvC2.js → requirementDiagram-4Y6WPE33-CKZYvVDJ.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-DktAZfe_.js → sankeyDiagram-5OEKKPKP-gZ0nzDfs.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-BIPt8kGU.js → sequenceDiagram-3UESZ5HK-DN3XdBkW.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DiXmJWB0.js → stateDiagram-AJRCARHV-BvtafGxO.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-B2nWDV5R.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-LRi7H35g.js → timeline-definition-PNZ67QCA-BrR919lp.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-DWQ1I022.js → vennDiagram-CIIHVFJN-B7CTm4yM.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BUb6dYqN.js → wardley-L42UT6IY-CyqFngx_.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-BYE1B3xT.js → wardleyDiagram-YWT4CUSO-BCqEPBJ5.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-D-pS2-Sa.js → xychartDiagram-2RQKCTM6-BmT6Cmz-.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/docs/README.md +1 -0
- package/docs/architecture/architecture.md +1 -1
- package/docs/architecture/configuration-model.md +156 -0
- package/docs/architecture/messaging-gateway.md +1043 -0
- package/docs/architecture/notification-delivery.md +273 -0
- package/docs/design/remote-access-contract.md +445 -0
- package/docs/guides/development.md +1 -1
- package/docs/guides/guide.md +4 -2
- package/docs/guides/remote-access.md +147 -214
- package/docs/handoff/approval-tri-state-handoff.md +69 -0
- package/docs/handoff/remote-access-handoff.md +160 -0
- package/docs/records/agent-platform-friction-2026-10.md +102 -2
- package/package.json +1 -1
- package/dist/web-ui/assets/DeliverableShareModal-DV3TiZx0.js +0 -1
- package/dist/web-ui/assets/Deliverables-tlLsJnxZ.js +0 -3
- package/dist/web-ui/assets/Search-CPFwZv1U.js +0 -1
- package/dist/web-ui/assets/Settings-DIa-_qre.js +0 -8
- package/dist/web-ui/assets/Team-COBxn96h.js +0 -84
- package/dist/web-ui/assets/Work-BScJUqWL.js +0 -12
- package/dist/web-ui/assets/channel-DCChB-1T.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CrNiYfSI.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CrNiYfSI.js +0 -1
- package/dist/web-ui/assets/index-C_QhfMcC.js +0 -882
- package/dist/web-ui/assets/index-DEN_qReg.css +0 -1
- package/dist/web-ui/assets/modelCapabilities-DDtCBZ6o.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-COOgTXIX.js +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire the outbound dispatcher into a running backend (design §7, slice G4).
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `start.ts` so the assembly is small, testable and obvious: bind the
|
|
5
|
+
* two ports (a `channel_bindings`-backed lookup, a router-backed sink), subscribe
|
|
6
|
+
* to HITL notifications and EventBus task events, hand back a detacher.
|
|
7
|
+
*
|
|
8
|
+
* Before this, "approval reached a chat app" existed only inside the Feishu
|
|
9
|
+
* notifier, which is why no other platform could carry one. Nothing here is
|
|
10
|
+
* platform-specific: a new platform becomes reachable by having an instance row.
|
|
11
|
+
*/
|
|
12
|
+
import { OutboundDispatcher, type BindingRowLike, type InstanceSource, type NotificationSource, type SendOptions, type PlatformField } from '@markus/comms';
|
|
13
|
+
export interface OutboundWiringOptions {
|
|
14
|
+
router: {
|
|
15
|
+
sendToChannel(platform: string, channelId: string, content: string, instanceId?: string, options?: SendOptions): Promise<string | undefined>;
|
|
16
|
+
};
|
|
17
|
+
/** `channel_bindings` reader. Absent ⇒ dispatch is not wired. */
|
|
18
|
+
bindingRepo?: {
|
|
19
|
+
listByOrg(orgId: string): BindingRowLike[];
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* `platform_instances` reader — resolves a binding's instance to its platform,
|
|
23
|
+
* and (via `listByOrg`) finds a **declared** destination without any binding
|
|
24
|
+
* (the reliable terminus, design §3 step 2).
|
|
25
|
+
*/
|
|
26
|
+
instanceRepo?: InstanceSource;
|
|
27
|
+
/** Who is the org Secretary — the owner of the global (level-3) default. */
|
|
28
|
+
orgSecretaryId?: () => string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Manifest field definitions per platform — the `notifyTarget` annotation
|
|
31
|
+
* source for a **declared** destination. Defaults to the platform registry;
|
|
32
|
+
* injectable so the DB→outbound path is testable without the real manifest.
|
|
33
|
+
*/
|
|
34
|
+
fieldDefs?: (platform: string) => PlatformField[];
|
|
35
|
+
/** HITL notification source (`HITLService`). */
|
|
36
|
+
notificationSource?: NotificationSource;
|
|
37
|
+
/** EventBus — task events are forwarded when present. */
|
|
38
|
+
eventBus?: {
|
|
39
|
+
on(event: string, fn: (payload: unknown) => void): () => void;
|
|
40
|
+
};
|
|
41
|
+
orgId?: string;
|
|
42
|
+
/** Buffer `info` messages into a periodic digest instead of sending each. */
|
|
43
|
+
digestInfo?: boolean;
|
|
44
|
+
/** Secret for signing approval action refs. */
|
|
45
|
+
actionSecret?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve an agent's display name from its id — lets a delivered notification
|
|
48
|
+
* name the agent that sent it (`agentId` → "来自 Agent 名"). Optional; without
|
|
49
|
+
* it, notifications are delivered unattributed rather than with a raw id.
|
|
50
|
+
*/
|
|
51
|
+
agentName?: (agentId: string) => string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the team an agent belongs to — shown alongside the agent so a
|
|
54
|
+
* notification says which team it came from. Optional and independent of
|
|
55
|
+
* `agentName`: a missing team never blocks a delivery.
|
|
56
|
+
*/
|
|
57
|
+
agentTeamName?: (agentId: string) => string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve the language outbound approval buttons are written in — the
|
|
60
|
+
* recipient's locale. Optional; absent means English defaults, so the wiring
|
|
61
|
+
* stays usable in a context that knows nothing about users.
|
|
62
|
+
*/
|
|
63
|
+
locale?: () => string | undefined;
|
|
64
|
+
}
|
|
65
|
+
export interface OutboundWiring {
|
|
66
|
+
dispatcher: OutboundDispatcher;
|
|
67
|
+
/** Unsubscribe every source this wiring attached. */
|
|
68
|
+
detach: () => void;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Build and attach the outbound dispatcher. Returns `undefined` when there is no
|
|
72
|
+
* binding store to resolve targets from — in that case the legacy notifier path
|
|
73
|
+
* still runs, and we say so rather than pretending dispatch is active.
|
|
74
|
+
*/
|
|
75
|
+
export declare function setupOutboundDispatch(opts: OutboundWiringOptions): OutboundWiring | undefined;
|
|
76
|
+
//# sourceMappingURL=outbound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound.d.ts","sourceRoot":"","sources":["../../src/commands/outbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,kBAAkB,EAMlB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAKvB,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE;QACN,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;KAChC,CAAC;IACF,iEAAiE;IACjE,WAAW,CAAC,EAAE;QAAE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE,CAAA;KAAE,CAAC;IAC7D;;;;OAIG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC;IAC9B,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IAC1C;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,aAAa,EAAE,CAAC;IAClD,gDAAgD;IAChD,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,yDAAyD;IACzD,QAAQ,CAAC,EAAE;QAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;KAAE,CAAC;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACpD;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACxD;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,kBAAkB,CAAC;IAC/B,qDAAqD;IACrD,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,qBAAqB,GAAG,cAAc,GAAG,SAAS,CAgE7F"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire the outbound dispatcher into a running backend (design §7, slice G4).
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `start.ts` so the assembly is small, testable and obvious: bind the
|
|
5
|
+
* two ports (a `channel_bindings`-backed lookup, a router-backed sink), subscribe
|
|
6
|
+
* to HITL notifications and EventBus task events, hand back a detacher.
|
|
7
|
+
*
|
|
8
|
+
* Before this, "approval reached a chat app" existed only inside the Feishu
|
|
9
|
+
* notifier, which is why no other platform could carry one. Nothing here is
|
|
10
|
+
* platform-specific: a new platform becomes reachable by having an instance row.
|
|
11
|
+
*/
|
|
12
|
+
import { OutboundDispatcher, RepoNotifyPreferenceSource, RepoNotifyTargetLookup, RouterOutboundSink, renderCapabilitiesOf, getManifest, } from '@markus/comms';
|
|
13
|
+
import { createLogger } from '@markus/shared';
|
|
14
|
+
const log = createLogger('outbound-setup');
|
|
15
|
+
/**
|
|
16
|
+
* Build and attach the outbound dispatcher. Returns `undefined` when there is no
|
|
17
|
+
* binding store to resolve targets from — in that case the legacy notifier path
|
|
18
|
+
* still runs, and we say so rather than pretending dispatch is active.
|
|
19
|
+
*/
|
|
20
|
+
export function setupOutboundDispatch(opts) {
|
|
21
|
+
if (!opts.bindingRepo) {
|
|
22
|
+
log.warn('Outbound dispatch not wired — no channel-binding store available');
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const orgId = opts.orgId ?? 'default';
|
|
26
|
+
// Every destination is resolved from the DB — `channel_bindings` plus the
|
|
27
|
+
// `platform_instances.config` that Settings writes. No `markus.json` reader
|
|
28
|
+
// here (design §3 "Single source of truth").
|
|
29
|
+
const lookup = new RepoNotifyTargetLookup({
|
|
30
|
+
bindingRepo: opts.bindingRepo,
|
|
31
|
+
instanceRepo: opts.instanceRepo,
|
|
32
|
+
orgSecretaryId: opts.orgSecretaryId,
|
|
33
|
+
fieldDefs: opts.fieldDefs,
|
|
34
|
+
});
|
|
35
|
+
const sink = new RouterOutboundSink({
|
|
36
|
+
router: opts.router,
|
|
37
|
+
// Capabilities come from the platform manifest — a new platform teaches the
|
|
38
|
+
// gateway what it can render, with no code here.
|
|
39
|
+
capabilitiesOf: (platform) => renderCapabilitiesOf(getManifest(platform)?.capabilities),
|
|
40
|
+
});
|
|
41
|
+
// Preference enforcement reads the *same* `platform_instances` source the
|
|
42
|
+
// lookup resolves destinations from — one config source for both (design §3).
|
|
43
|
+
const preferences = new RepoNotifyPreferenceSource({ instanceRepo: opts.instanceRepo });
|
|
44
|
+
const dispatcher = new OutboundDispatcher({
|
|
45
|
+
lookup,
|
|
46
|
+
sink,
|
|
47
|
+
preferences,
|
|
48
|
+
orgId,
|
|
49
|
+
digestInfo: opts.digestInfo,
|
|
50
|
+
actionSecret: opts.actionSecret,
|
|
51
|
+
agentName: opts.agentName,
|
|
52
|
+
agentTeamName: opts.agentTeamName,
|
|
53
|
+
locale: opts.locale,
|
|
54
|
+
});
|
|
55
|
+
const detachers = [];
|
|
56
|
+
if (opts.notificationSource) {
|
|
57
|
+
detachers.push(dispatcher.attachNotifications(opts.notificationSource));
|
|
58
|
+
}
|
|
59
|
+
if (opts.eventBus)
|
|
60
|
+
detachers.push(dispatcher.attachEventBus(opts.eventBus));
|
|
61
|
+
log.info('Outbound dispatcher wired', {
|
|
62
|
+
orgId,
|
|
63
|
+
sources: detachers.length,
|
|
64
|
+
digest: Boolean(opts.digestInfo),
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
dispatcher,
|
|
68
|
+
detach: () => {
|
|
69
|
+
for (const d of detachers) {
|
|
70
|
+
try {
|
|
71
|
+
d();
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
/* ignore */
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=outbound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outbound.js","sourceRoot":"","sources":["../../src/commands/outbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,GAMZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,GAAG,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC;AA+D3C;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA2B;IAC/D,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACtB,GAAG,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;QAC7E,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,SAAS,CAAC;IAEtC,0EAA0E;IAC1E,4EAA4E;IAC5E,6CAA6C;IAC7C,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC;QACxC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,cAAc,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AU;QACV,MAAM,EAAE,GAAG,EAAE;YACX,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;gBAC1B,IAAI,CAAC;oBACH,CAAC,EAAE,CAAC;gBACN,CAAC;gBAAC,MAAM,CAAC;oBACP,YAAY;gBACd,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/commands/start.d.ts
CHANGED
|
@@ -1,8 +1,130 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
2
|
import type { BackendInstance } from '../backend.js';
|
|
3
|
-
import { loadConfig } from '@markus/shared';
|
|
3
|
+
import { loadConfig, type MarkusConfig } from '@markus/shared';
|
|
4
4
|
import { AgentManager, LLMRouter, RoleLoader } from '@markus/core';
|
|
5
|
-
import { OrganizationService, TaskService, HITLService, BillingService, LicenseService, TelemetryService, AuditService } from '@markus/org-manager';
|
|
5
|
+
import { OrganizationService, TaskService, HITLService, BillingService, LicenseService, TelemetryService, AuditService, type PlatformStoreDeps, type StoredPlatformConfig } from '@markus/org-manager';
|
|
6
|
+
import { MessageRouter, type PlatformManifest } from '@markus/comms';
|
|
7
|
+
/** One platform's connection outcome — drives startup logs and the progress text. */
|
|
8
|
+
export interface PlatformStartupResult {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
connected: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ConnectPlatformsOptions {
|
|
15
|
+
router: MessageRouter;
|
|
16
|
+
manifests: readonly PlatformManifest[];
|
|
17
|
+
config: MarkusConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Config values computed at runtime, keyed by platform id. Only platforms whose
|
|
20
|
+
* config cannot be static need an entry; a newly added platform needs none.
|
|
21
|
+
*/
|
|
22
|
+
runtimeConfig?: Record<string, Record<string, unknown>>;
|
|
23
|
+
/**
|
|
24
|
+
* Persisted bot instances for this org (`platform_instances` rows). When a
|
|
25
|
+
* platform has any, **they** define its connections — one adapter per row, each
|
|
26
|
+
* on its own credentials; the legacy path below is skipped for that platform.
|
|
27
|
+
* This is the "iterate instances, not platforms" traversal (G2, design §4.2).
|
|
28
|
+
*/
|
|
29
|
+
instances?: readonly PersistedBotInstance[];
|
|
30
|
+
/**
|
|
31
|
+
* Persisted (Settings-API) config per platform, keyed by platform id — the
|
|
32
|
+
* **legacy** `integrations` fallback, consulted only for a platform that has no
|
|
33
|
+
* instance row. When a value is present here the platform was configured
|
|
34
|
+
* through the UI, and it must win over the read-only `markus.json` bootstrap —
|
|
35
|
+
* otherwise "saved in Settings" and "running" would drift apart. `enabled` is
|
|
36
|
+
* the row's toggle; `undefined` means "no stored row", i.e. fall back to
|
|
37
|
+
* field-based enablement.
|
|
38
|
+
*/
|
|
39
|
+
storedConfig?: (platformId: string) => StoredPlatformConfig | undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Minimal shape of a persisted bot instance (`platform_instances` row) as startup
|
|
43
|
+
* needs it. Structural, so a storage row is assignable without a cast.
|
|
44
|
+
*/
|
|
45
|
+
export interface PersistedBotInstance {
|
|
46
|
+
id: string;
|
|
47
|
+
platform: string;
|
|
48
|
+
label: string;
|
|
49
|
+
/** Raw stored config (credentials); merged with file/env/runtime at resolution. */
|
|
50
|
+
config?: unknown;
|
|
51
|
+
enabled?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Structural view of the persisted bot rows the reconciler needs (`platform_instances`).
|
|
55
|
+
* Narrow on purpose: a storage row is assignable without a cast, and tests can
|
|
56
|
+
* pass a literal.
|
|
57
|
+
*/
|
|
58
|
+
export interface ReconcilableInstanceRepo {
|
|
59
|
+
findById(id: string): PersistedBotInstance | undefined;
|
|
60
|
+
listByPlatform(orgId: string, platform: string): PersistedBotInstance[];
|
|
61
|
+
}
|
|
62
|
+
export interface CreateInstanceReconcilerOptions {
|
|
63
|
+
router: MessageRouter;
|
|
64
|
+
/**
|
|
65
|
+
* The manifests to reconcile against — the **same list** startup is given, so
|
|
66
|
+
* the two paths can never disagree about a platform's fields. Falls back to the
|
|
67
|
+
* global registry only when omitted.
|
|
68
|
+
*/
|
|
69
|
+
manifests?: readonly PlatformManifest[];
|
|
70
|
+
/** Desired state: the persisted bot rows. Absent ⇒ nothing can be reconciled. */
|
|
71
|
+
instanceRepo?: ReconcilableInstanceRepo;
|
|
72
|
+
orgId: string;
|
|
73
|
+
/** `markus.json` `integrations` section — the read-only bootstrap fallback. */
|
|
74
|
+
sections?: Record<string, unknown>;
|
|
75
|
+
/** Persisted platform-level (legacy) values, when the caller has just saved some. */
|
|
76
|
+
storedPlatformValues?: (platformId: string) => Record<string, unknown> | undefined;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Runtime reconciliation of a bot's live adapter against its persisted config.
|
|
80
|
+
*
|
|
81
|
+
* The adapter set is *derived* state — it must equal what the instance rows say.
|
|
82
|
+
* Startup derives it once; these two entry points re-derive it after a change, so
|
|
83
|
+
* saving Settings takes effect immediately instead of at the next restart. Keep
|
|
84
|
+
* the mapping 1:1 — one method per way the desired state can change.
|
|
85
|
+
*/
|
|
86
|
+
export interface InstanceReconciler {
|
|
87
|
+
/** Re-derive one bot from its row (or drop it when the row is gone/disabled). */
|
|
88
|
+
syncInstance(instanceId: string): Promise<void>;
|
|
89
|
+
/** Re-derive a platform: every instance of it, or the legacy implicit bot. */
|
|
90
|
+
syncPlatform(platform: string, overrides?: Record<string, unknown>): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Build the runtime reconciler. It reads the same inputs startup does
|
|
94
|
+
* (`sections` = markus.json bootstrap, row config = stored credentials), so the
|
|
95
|
+
* two can never disagree about what a bot's config *is*.
|
|
96
|
+
*/
|
|
97
|
+
export declare function createInstanceReconciler(opts: CreateInstanceReconcilerOptions): InstanceReconciler;
|
|
98
|
+
/**
|
|
99
|
+
* Build, register and connect every enabled bot in `manifests`.
|
|
100
|
+
*
|
|
101
|
+
* A **platform** is a manifest; a **bot** is one instance of it. This walks the
|
|
102
|
+
* persisted instances first — one adapter per row, each on its own credentials —
|
|
103
|
+
* and only falls back to the legacy platform path (the `integrations` row +
|
|
104
|
+
* `markus.json` + env) for a platform that has no instance row. The legacy
|
|
105
|
+
* fallback registers a single implicit instance whose id is the platform id,
|
|
106
|
+
* which is byte-for-byte the pre-instance behaviour (design §4.2, §5.2 step 4).
|
|
107
|
+
*
|
|
108
|
+
* One bot failing never blocks the rest (issue #340 degradation rules).
|
|
109
|
+
*/
|
|
110
|
+
export declare function connectConfiguredPlatforms(opts: ConnectPlatformsOptions): Promise<PlatformStartupResult[]>;
|
|
111
|
+
export interface ApplyBindingsOptions {
|
|
112
|
+
router: MessageRouter;
|
|
113
|
+
/** Persisted integrations repo. Structural typing keeps this storage-agnostic. */
|
|
114
|
+
repo?: PlatformStoreDeps['repo'];
|
|
115
|
+
orgId: string;
|
|
116
|
+
/** Read-only legacy fallback, forwarded to `loadPlatformBindings`. */
|
|
117
|
+
bootstrap?: (platform: string) => Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Apply the persisted platform→agent bindings to the router at startup.
|
|
121
|
+
*
|
|
122
|
+
* Runs right after {@link connectConfiguredPlatforms} so the router is bound in
|
|
123
|
+
* the same window the adapters come up — before the first inbound message can be
|
|
124
|
+
* routed. Returns the number of bindings applied (0 is a valid, quiet outcome:
|
|
125
|
+
* a fresh install binds nothing and inbound stays a loud no-op until configured).
|
|
126
|
+
*/
|
|
127
|
+
export declare function applyPersistedPlatformBindings(opts: ApplyBindingsOptions): number;
|
|
6
128
|
export declare function registerStartCommand(program: Command): void;
|
|
7
129
|
export declare function createServices(config: ReturnType<typeof loadConfig>): Promise<{
|
|
8
130
|
agentManager: AgentManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAA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