@bragi-gmbh/codebus 1.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/bin/codebus.js +2 -0
- package/dist/binding-guard.js +97 -0
- package/dist/binding-guard.js.map +1 -0
- package/dist/client.js +94 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/ack.js +47 -0
- package/dist/commands/ack.js.map +1 -0
- package/dist/commands/archive.js +21 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/as.js +299 -0
- package/dist/commands/as.js.map +1 -0
- package/dist/commands/ask.js +189 -0
- package/dist/commands/ask.js.map +1 -0
- package/dist/commands/auth.js +33 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/checkin.js +235 -0
- package/dist/commands/checkin.js.map +1 -0
- package/dist/commands/decision.js +52 -0
- package/dist/commands/decision.js.map +1 -0
- package/dist/commands/digest.js +117 -0
- package/dist/commands/digest.js.map +1 -0
- package/dist/commands/doctor.js +106 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/factory.js +191 -0
- package/dist/commands/factory.js.map +1 -0
- package/dist/commands/github-login.js +205 -0
- package/dist/commands/github-login.js.map +1 -0
- package/dist/commands/graph.js +88 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/health.js +34 -0
- package/dist/commands/health.js.map +1 -0
- package/dist/commands/inbox.js +83 -0
- package/dist/commands/inbox.js.map +1 -0
- package/dist/commands/ingest.js +553 -0
- package/dist/commands/ingest.js.map +1 -0
- package/dist/commands/init.js +97 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install.js +520 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/invite.js +152 -0
- package/dist/commands/invite.js.map +1 -0
- package/dist/commands/jira.js +237 -0
- package/dist/commands/jira.js.map +1 -0
- package/dist/commands/join.js +96 -0
- package/dist/commands/join.js.map +1 -0
- package/dist/commands/links.js +66 -0
- package/dist/commands/links.js.map +1 -0
- package/dist/commands/login.js +84 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/morning.js +121 -0
- package/dist/commands/morning.js.map +1 -0
- package/dist/commands/next.js +66 -0
- package/dist/commands/next.js.map +1 -0
- package/dist/commands/onboarding.js +109 -0
- package/dist/commands/onboarding.js.map +1 -0
- package/dist/commands/pack.js +276 -0
- package/dist/commands/pack.js.map +1 -0
- package/dist/commands/plan-gh.js +425 -0
- package/dist/commands/plan-gh.js.map +1 -0
- package/dist/commands/plan.js +465 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/pr.js +88 -0
- package/dist/commands/pr.js.map +1 -0
- package/dist/commands/question.js +142 -0
- package/dist/commands/question.js.map +1 -0
- package/dist/commands/read.js +84 -0
- package/dist/commands/read.js.map +1 -0
- package/dist/commands/refs.js +357 -0
- package/dist/commands/refs.js.map +1 -0
- package/dist/commands/reply.js +38 -0
- package/dist/commands/reply.js.map +1 -0
- package/dist/commands/repo.js +1198 -0
- package/dist/commands/repo.js.map +1 -0
- package/dist/commands/report.js +41 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/resolve-refs.js +21 -0
- package/dist/commands/resolve-refs.js.map +1 -0
- package/dist/commands/resolve.js +93 -0
- package/dist/commands/resolve.js.map +1 -0
- package/dist/commands/send.js +168 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/sent.js +22 -0
- package/dist/commands/sent.js.map +1 -0
- package/dist/commands/session.js +426 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/statusline.js +43 -0
- package/dist/commands/statusline.js.map +1 -0
- package/dist/commands/task.js +140 -0
- package/dist/commands/task.js.map +1 -0
- package/dist/commands/tick.js +233 -0
- package/dist/commands/tick.js.map +1 -0
- package/dist/commands/upgrade.js +76 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/watch.js +169 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/whoami.js +27 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.js +103 -0
- package/dist/config.js.map +1 -0
- package/dist/directives.js +102 -0
- package/dist/directives.js.map +1 -0
- package/dist/errors.js +110 -0
- package/dist/errors.js.map +1 -0
- package/dist/git-hooks.js +116 -0
- package/dist/git-hooks.js.map +1 -0
- package/dist/graph-bootstrap.js +95 -0
- package/dist/graph-bootstrap.js.map +1 -0
- package/dist/graph-remote.js +889 -0
- package/dist/graph-remote.js.map +1 -0
- package/dist/graph.js +335 -0
- package/dist/graph.js.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/dist/kit/graph-publish.mjs +400 -0
- package/dist/mail-latency.js +120 -0
- package/dist/mail-latency.js.map +1 -0
- package/dist/mcp-registry.js +859 -0
- package/dist/mcp-registry.js.map +1 -0
- package/dist/mcp.js +193 -0
- package/dist/mcp.js.map +1 -0
- package/dist/output.js +12 -0
- package/dist/output.js.map +1 -0
- package/dist/positioning.js +21 -0
- package/dist/positioning.js.map +1 -0
- package/dist/rolestore.js +89 -0
- package/dist/rolestore.js.map +1 -0
- package/dist/session.js +49 -0
- package/dist/session.js.map +1 -0
- package/dist/sessionstore.js +736 -0
- package/dist/sessionstore.js.map +1 -0
- package/dist/version-check.js +97 -0
- package/dist/version-check.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task.js","sourceRoot":"","sources":["../../src/commands/task.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAa,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAO,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;;GAKG;AACH,KAAK,UAAU,aAAa,CAAC,GAAQ,EAAE,WAAmB;IACxD,IAAI,YAAY,CA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AAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5I,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5I,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC9I,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { resolveConfig, configDir } from "../config.js";
|
|
4
|
+
import { makeCtx, workspaceId } from "../client.js";
|
|
5
|
+
import { DeadSessionError, SessionStoreError } from "../errors.js";
|
|
6
|
+
import { isActionableMessage } from "../directives.js";
|
|
7
|
+
// Workspace-scoped: an agent that participates in more than one workspace
|
|
8
|
+
// (review MAJOR finding #3) must not have workspace A's watermark silently
|
|
9
|
+
// gate mail arriving in workspace B (or vice versa) — the state file, like
|
|
10
|
+
// the mail query below, is keyed on agent slug AND workspace.
|
|
11
|
+
const stateFile = (slug, workspace) => join(configDir(), `tick-${slug}-${workspace}.json`);
|
|
12
|
+
function loadState(slug, workspace) {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(readFileSync(stateFile(slug, workspace), "utf8"));
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function saveState(slug, workspace, s) {
|
|
21
|
+
mkdirSync(configDir(), { recursive: true });
|
|
22
|
+
writeFileSync(stateFile(slug, workspace), JSON.stringify(s) + "\n", { mode: 0o600 });
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Resolve THIS command's identity via the SAME path as every other command
|
|
26
|
+
* (resolveConfig → sessionstore/rolestore), then apply tick's own "explicit or
|
|
27
|
+
* silent" gate on top: identitySource "file"/"none" means nothing distinctive
|
|
28
|
+
* matched, so stay quiet rather than nag as the author — resolveConfig's
|
|
29
|
+
* ordinary "no token"/"no server URL" throws (nothing at all is configured)
|
|
30
|
+
* are swallowed to the same null here, matching tick's original contract of
|
|
31
|
+
* quietly doing nothing rather than erroring.
|
|
32
|
+
*
|
|
33
|
+
* DeadSessionError and SessionStoreError are the two exceptions: the session
|
|
34
|
+
* tier EXISTED for this session and either died (§2.4 precedent 3) or
|
|
35
|
+
* couldn't be trusted (a corrupt/unreadable session-roles.json — sessionstore
|
|
36
|
+
* fails closed rather than guess), which is categorically different from
|
|
37
|
+
* "nothing configured" and must NOT be swallowed — both propagate so the
|
|
38
|
+
* caller can decide whether to surface them loudly (plain mode) or let them
|
|
39
|
+
* join the rest of hook mode's swallowed errors (--hook, which wraps this
|
|
40
|
+
* whole call in its own try/catch already, and swallows to SILENCE — never
|
|
41
|
+
* to an inferred fallback identity, since the throw already stopped
|
|
42
|
+
* resolveConfig before it reached the cwd-binding tier).
|
|
43
|
+
*
|
|
44
|
+
* Exported for the regression suite (rank-1/FM-3/FM-4 tests: must NEVER fall
|
|
45
|
+
* back to the author's config.json file token).
|
|
46
|
+
*/
|
|
47
|
+
export function tickIdentity(o, env = process.env) {
|
|
48
|
+
let cfg;
|
|
49
|
+
try {
|
|
50
|
+
cfg = resolveConfig(o, env);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
if (e instanceof DeadSessionError || e instanceof SessionStoreError)
|
|
54
|
+
throw e;
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return cfg.identitySource === "file" || cfg.identitySource === "none" ? null : cfg;
|
|
58
|
+
}
|
|
59
|
+
/** Read the Stop-hook input JSON from stdin (best-effort; {} when not piped). */
|
|
60
|
+
async function readHookInput() {
|
|
61
|
+
if (process.stdin.isTTY)
|
|
62
|
+
return {};
|
|
63
|
+
try {
|
|
64
|
+
let data = "";
|
|
65
|
+
process.stdin.setEncoding("utf8");
|
|
66
|
+
for await (const chunk of process.stdin)
|
|
67
|
+
data += chunk;
|
|
68
|
+
return data.trim() ? JSON.parse(data) : {};
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Exported for the regression suite (workspace-scoping + watermark-contract
|
|
76
|
+
* tests pass a raw token + overrides); internal callers pass the Config that
|
|
77
|
+
* tickIdentity() already resolved — no second resolve, no gate bypass.
|
|
78
|
+
*/
|
|
79
|
+
export async function checkNewMail(cfgOrToken, o = {}) {
|
|
80
|
+
const cfg = typeof cfgOrToken === "string" ? resolveConfig({ ...o, token: cfgOrToken }) : cfgOrToken;
|
|
81
|
+
const ctx = await makeCtx(cfg);
|
|
82
|
+
const slug = ctx.agentSlug;
|
|
83
|
+
const ws = await workspaceId(ctx);
|
|
84
|
+
const state = loadState(slug, ctx.workspaceSlug);
|
|
85
|
+
// First tick for this agent+workspace on this machine: baseline to now,
|
|
86
|
+
// report nothing. Checkin/session-start orientation already showed the
|
|
87
|
+
// existing inbox; the tick's job is strictly NEW arrivals from here on.
|
|
88
|
+
if (!state) {
|
|
89
|
+
saveState(slug, ctx.workspaceSlug, { watermark: new Date().toISOString() });
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
// Fetch EVERY recipient row past the watermark IN THIS WORKSPACE, engaged
|
|
93
|
+
// or not (review MAJOR finding #3: the old query had no workspace filter at
|
|
94
|
+
// all, so an agent in >1 workspace got every workspace's mail lumped
|
|
95
|
+
// together here). Engagement state (read_at/handled_at), not "has it been
|
|
96
|
+
// reported yet", is what decides whether the watermark may advance past it.
|
|
97
|
+
const { data, error } = await ctx.supabase
|
|
98
|
+
.from("message_recipients")
|
|
99
|
+
.select("read_at, handled_at, messages!inner(subject, created_at, urgency, workspace_id, type, required_action)")
|
|
100
|
+
.is("archived_at", null)
|
|
101
|
+
.eq("messages.workspace_id", ws)
|
|
102
|
+
.gt("messages.created_at", state.watermark);
|
|
103
|
+
if (error)
|
|
104
|
+
throw new Error(error.message);
|
|
105
|
+
const rows = (data ?? []).map((r) => ({ read: !!r.read_at, handled: !!r.handled_at, ...r.messages }));
|
|
106
|
+
if (!rows.length)
|
|
107
|
+
return null;
|
|
108
|
+
// CONTRACT RULING (see header comment): the watermark advances past mail
|
|
109
|
+
// that was read OR handled — only NEVER-ENGAGED mail keeps it from moving
|
|
110
|
+
// and gets re-reported. "handled" implies engaged, but check both — a
|
|
111
|
+
// message can be handled (e.g. via a reply that never opened it first)
|
|
112
|
+
// without read_at ever being set.
|
|
113
|
+
const unengaged = rows.filter((r) => !r.read && !r.handled);
|
|
114
|
+
if (!unengaged.length) {
|
|
115
|
+
// Everything new since the watermark has been read or handled (e.g. the
|
|
116
|
+
// agent replied/acked/read out of band before this tick ran) — safe to
|
|
117
|
+
// advance past all of it; nothing left for TICK to report. Unhandled-but-
|
|
118
|
+
// read mail stays visible via inbox/digest (handled_at-gated), untouched
|
|
119
|
+
// by this watermark.
|
|
120
|
+
rows.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
121
|
+
saveState(slug, ctx.workspaceSlug, { watermark: rows[0].created_at });
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
// Still-unengaged mail past the watermark: report it. The watermark is
|
|
125
|
+
// deliberately left untouched — it must NOT skip past mail that was never
|
|
126
|
+
// even opened, so this same mail resurfaces on the next tick until it's
|
|
127
|
+
// read or handled.
|
|
128
|
+
unengaged.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
129
|
+
return {
|
|
130
|
+
count: unengaged.length,
|
|
131
|
+
urgent: unengaged.filter((r) => r.urgency === "speak_now").length,
|
|
132
|
+
newestSubject: unengaged[0].subject ?? null,
|
|
133
|
+
slug,
|
|
134
|
+
actionable: unengaged.filter((r) => isActionableMessage(r)).length,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export function reasonLine(m) {
|
|
138
|
+
const urgent = m.urgent > 0 ? ` (${m.urgent} URGENT)` : "";
|
|
139
|
+
const newest = m.newestSubject ? ` — newest: "${m.newestSubject}"` : "";
|
|
140
|
+
// RC2 review finding: tick used to call EVERY new-mail set "a work order,
|
|
141
|
+
// not a notification" regardless of what it actually was — a class-8 FYI
|
|
142
|
+
// note (bus_digest's non-actionable class, 0061_actionable_messages.sql)
|
|
143
|
+
// got the identical "ACT on each message... do the work it asks" framing
|
|
144
|
+
// as a genuine ask/handoff. When NONE of the reported mail is actionable,
|
|
145
|
+
// still report it (mail must never go silently unseen — that's tick's
|
|
146
|
+
// whole reliability property, unrelated to whether it's a work order), but
|
|
147
|
+
// with honest wording instead of a false work-order claim.
|
|
148
|
+
// Identity caveat shared by ALL branches. The Stop hook uses the FYI branch
|
|
149
|
+
// too, so it must carry the SAME stand-down as the actionable branches (ai-
|
|
150
|
+
// review: an unrelated session bound to this directory must be told not to
|
|
151
|
+
// read or answer another agent's mail — FYI or not).
|
|
152
|
+
const identityCaveat = `IMPORTANT: only act if you actually are '${m.slug}'. If you are some other session that merely runs in ` +
|
|
153
|
+
`this directory (a scheduled task, an unrelated chat), do NOT read or answer this mail — leave it for the ` +
|
|
154
|
+
`real agent and finish normally. (Field incident: a scheduled sync task inherited a directory binding and ` +
|
|
155
|
+
`answered another agent's liveness check with wrong information.)`;
|
|
156
|
+
if (m.actionable === 0) {
|
|
157
|
+
// A speak_now note is urgent-to-READ, not urgent-to-act — don't tack the
|
|
158
|
+
// bare "(N URGENT)" marker onto "No action required" (ai-review: that reads
|
|
159
|
+
// as a contradiction and could make automation prioritize non-actionable
|
|
160
|
+
// mail). Fold the urgency into read-promptness instead.
|
|
161
|
+
const readSoon = m.urgent > 0
|
|
162
|
+
? ` ${m.urgent} ${m.urgent === 1 ? "is" : "are"} marked urgent to READ — skim promptly, but still no reply is needed.`
|
|
163
|
+
: "";
|
|
164
|
+
return `CodeBus: ${m.count} new FYI note${m.count === 1 ? "" : "s"} for '${m.slug}'${newest}. ` +
|
|
165
|
+
`No action required — this is plain note/plan mail, not a work order.${readSoon} Skim it via ` +
|
|
166
|
+
`\`codebus inbox --unread\` when convenient, or \`codebus ack <id>\` to clear it. ` + identityCaveat;
|
|
167
|
+
}
|
|
168
|
+
// RC2 review finding: a MIXED batch (some actionable, some FYI) must not frame
|
|
169
|
+
// the whole set as a work order — that re-introduces the class-7/class-8
|
|
170
|
+
// confusion this change removes. Count the two classes honestly so the FYI
|
|
171
|
+
// items aren't presented as mandatory work.
|
|
172
|
+
if (m.actionable < m.count) {
|
|
173
|
+
const fyi = m.count - m.actionable;
|
|
174
|
+
return `CodeBus: ${m.count} new messages${urgent} for '${m.slug}'${newest}. ` +
|
|
175
|
+
`${m.actionable} need action (work order${m.actionable === 1 ? "" : "s"} — do the work or answer with ` +
|
|
176
|
+
`substance, then reply with the outcome; a bare acknowledgement does not count), and ${fyi} ` +
|
|
177
|
+
`${fyi === 1 ? "is a plain FYI note" : "are plain FYI notes"} (no reply needed — skim, or ` +
|
|
178
|
+
`\`codebus ack <id>\` to clear). Run \`codebus inbox --unread\` to tell them apart and act on the ` +
|
|
179
|
+
`${m.actionable} that need it. ` + identityCaveat;
|
|
180
|
+
}
|
|
181
|
+
return `CodeBus: ${m.count} new message${m.count === 1 ? "" : "s"}${urgent} for '${m.slug}'${newest}. ` +
|
|
182
|
+
`Before finishing, run \`codebus inbox --unread\` and ACT on each message — it is a work order, not a ` +
|
|
183
|
+
`notification: do the work it asks or answer with substance, then reply with the outcome. A bare ` +
|
|
184
|
+
`acknowledgement does not count. ` + identityCaveat;
|
|
185
|
+
}
|
|
186
|
+
async function tickCmd(o) {
|
|
187
|
+
if (o.hook) {
|
|
188
|
+
// Hook contract: silent exit 0 = allow stop; {"decision":"block","reason":…}
|
|
189
|
+
// on stdout = keep the turn alive with the reason fed back to the model.
|
|
190
|
+
// Everything — a bus outage, a bad token, a dead session tier — is
|
|
191
|
+
// swallowed to silence: coding must never stall on this.
|
|
192
|
+
try {
|
|
193
|
+
const input = await readHookInput();
|
|
194
|
+
if (input.stop_hook_active)
|
|
195
|
+
return; // hard loop guard
|
|
196
|
+
const cfg = tickIdentity(o);
|
|
197
|
+
if (!cfg)
|
|
198
|
+
return; // unbound session: stay silent
|
|
199
|
+
const mail = await checkNewMail(cfg);
|
|
200
|
+
if (mail)
|
|
201
|
+
console.log(JSON.stringify({ decision: "block", reason: reasonLine(mail) }));
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
/* bus outage must never block coding */
|
|
205
|
+
}
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
// tickIdentity() only ever throws DeadSessionError (everything else is
|
|
209
|
+
// already folded into null) — let it propagate here, loud, never silent
|
|
210
|
+
// (§2.4 precedent 3). Plain mode has no swallow-all wrapper, so it surfaces
|
|
211
|
+
// through the CLI's top-level error handler like any other command's error.
|
|
212
|
+
const cfg = tickIdentity(o);
|
|
213
|
+
if (!cfg) {
|
|
214
|
+
console.log("tick: no explicit identity here (no CODEBUS_TOKEN, no session checkin, no cwd binding) — nothing to do");
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const mail = await checkNewMail(cfg);
|
|
218
|
+
if (!mail) {
|
|
219
|
+
if (!o.json)
|
|
220
|
+
console.log("tick: no new mail");
|
|
221
|
+
else
|
|
222
|
+
console.log(JSON.stringify({ new: 0 }));
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
console.log(o.json ? JSON.stringify({ new: mail.count, urgent: mail.urgent, agent: mail.slug }) : reasonLine(mail));
|
|
226
|
+
}
|
|
227
|
+
export function registerTick(program, g) {
|
|
228
|
+
g(program.command("tick"))
|
|
229
|
+
.description("report NEW mail since the last tick (Stop-hook mode: --hook)")
|
|
230
|
+
.option("--hook", "Claude Code Stop-hook mode: read hook JSON on stdin, emit block-decision JSON only when there is new mail, never fail")
|
|
231
|
+
.action(tickCmd);
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=tick.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tick.js","sourceRoot":"","sources":["../../src/commands/tick.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAqB,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AA+DvD,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,8DAA8D;AAC9D,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,SAAiB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,QAAQ,IAAI,IAAI,SAAS,OAAO,CAAC,CAAC;AAE3G,SAAS,SAAS,CAAC,IAAY,EAA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IAAI,CAAC,IAAI,EAAE,CAAC;QACV,IAAI,CAAC,CAAC,CAAC,IAAI;YAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;;YACzC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7C,OAAO;IACT,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AACtH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,CAA0B;IACvE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;SACvB,WAAW,CAAC,8DAA8D,CAAC;SAC3E,MAAM,CAAC,QAAQ,EAAE,uHAAuH,CAAC;SACzI,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { resolveConfig } from "../config.js";
|
|
4
|
+
import { makeCtx } from "../client.js";
|
|
5
|
+
import { OK, WARN } from "./login.js";
|
|
6
|
+
import { localVersion, isDevLinkedInstall, fetchAdvertisedRelease, isOlder } from "../version-check.js";
|
|
7
|
+
const exec = promisify(execFile);
|
|
8
|
+
const PKG = "@bragi-gmbh/codebus";
|
|
9
|
+
// `codebus upgrade` — the one update path everyone uses. It reads the current
|
|
10
|
+
// released version the bus advertises (0062 cli_release), compares it to the
|
|
11
|
+
// running build, and either updates from the registry or — for a linked dev
|
|
12
|
+
// build — explains how to switch onto the published CLI. Full flow:
|
|
13
|
+
// docs/CLI-DISTRIBUTION.md.
|
|
14
|
+
async function upgradeCmd(o) {
|
|
15
|
+
const local = localVersion();
|
|
16
|
+
let current = null;
|
|
17
|
+
let notes = null;
|
|
18
|
+
try {
|
|
19
|
+
const ctx = await makeCtx(resolveConfig(o));
|
|
20
|
+
const rel = await fetchAdvertisedRelease(ctx);
|
|
21
|
+
current = rel?.current_version ?? null;
|
|
22
|
+
notes = rel?.notes ?? null;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* offline / no identity — still show the local version + instructions */
|
|
26
|
+
}
|
|
27
|
+
const dev = isDevLinkedInstall();
|
|
28
|
+
const behind = !!current && isOlder(local, current);
|
|
29
|
+
if (o.json) {
|
|
30
|
+
console.log(JSON.stringify({ package: PKG, local, current, dev_linked: dev, behind, notes }, null, 2));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
console.log(`codebus ${local}${current ? ` · latest: ${current}` : ""}${notes ? ` (${notes})` : ""}`);
|
|
34
|
+
if (dev) {
|
|
35
|
+
console.log(`${WARN} You're running a LINKED DEV build (a source checkout), not the published CLI.`);
|
|
36
|
+
console.log(` A linked build's version tells you nothing about how current its code is. Switch to the`);
|
|
37
|
+
console.log(` released CLI so you get updates like everyone else (one-time, public npm registry — no auth):`);
|
|
38
|
+
console.log(` npm rm -g ${PKG} && npm install -g ${PKG}@latest`);
|
|
39
|
+
console.log(` Full walkthrough: docs/CLI-DISTRIBUTION.md`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!behind) {
|
|
43
|
+
console.log(current ? `${OK} You're on the latest published CLI.` : `(could not reach the bus to check for a newer release)`);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const cmd = `npm install -g ${PKG}@latest`;
|
|
47
|
+
if (!o.run) {
|
|
48
|
+
console.log(`A newer release is available. Update with:`);
|
|
49
|
+
console.log(` ${cmd}`);
|
|
50
|
+
console.log(` or re-run: codebus upgrade --run`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
console.log(`Updating: ${cmd}`);
|
|
54
|
+
try {
|
|
55
|
+
const { stdout, stderr } = await exec("npm", ["install", "-g", `${PKG}@latest`]);
|
|
56
|
+
if (stdout)
|
|
57
|
+
process.stdout.write(stdout);
|
|
58
|
+
if (stderr)
|
|
59
|
+
process.stderr.write(stderr);
|
|
60
|
+
console.log(`${OK} Updated. Run 'codebus --version' to confirm.`);
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log(`${WARN} Update failed: ${e?.message ?? e}`);
|
|
64
|
+
console.log(` Run it yourself: ${cmd}`);
|
|
65
|
+
console.log(` If npm asked for auth or hit npm.pkg.github.com: a stale ~/.npmrc still routes @bragi-gmbh`);
|
|
66
|
+
console.log(` to the old private registry. Remove the override and retry:`);
|
|
67
|
+
console.log(` npm config delete @bragi-gmbh:registry`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function registerUpgrade(program, g) {
|
|
71
|
+
g(program.command("upgrade"))
|
|
72
|
+
.description("check for and install the latest published codebus CLI (bus-advertised)")
|
|
73
|
+
.option("--run", "actually run the npm update (default: just print the command)")
|
|
74
|
+
.action(upgradeCmd);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAa,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,OAA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ACzC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,+CAA+C,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,mBAAoB,CAAW,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,8FAA8F,CAAC,CAAC;QAC5G,OAAO,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAgB,EAAE,CAA0B;IAC1E,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SAC1B,WAAW,CAAC,yEAAyE,CAAC;SACtF,MAAM,CAAC,OAAO,EAAE,+DAA+D,CAAC;SAChF,MAAM,CAAC,UAAU,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { resolveConfig } from "../config.js";
|
|
3
|
+
import { makeCtx, workspaceId, projectId } from "../client.js";
|
|
4
|
+
import { fetchInbox } from "./inbox.js";
|
|
5
|
+
import { ACT_DIRECTIVE, TASK_ACT_DIRECTIVE, FYI_DIRECTIVE, isActionableMessage } from "../directives.js";
|
|
6
|
+
// Blocks and streams new messages/tasks in the workspace. Realtime authorization is
|
|
7
|
+
// governed by RLS on the publication; v1 prints inserts the agent is allowed to see.
|
|
8
|
+
//
|
|
9
|
+
// --mine / --first turn watch into the cheap participation primitive for
|
|
10
|
+
// polling automations: a blocking realtime wait DECOUPLES LATENCY FROM POLL
|
|
11
|
+
// FREQUENCY. An automation that fires every N minutes and runs
|
|
12
|
+
// `watch --mine --first --timeout <N-ish>` reacts to mail within seconds of
|
|
13
|
+
// arrival (the event wakes the wait) while costing one invocation per window
|
|
14
|
+
// instead of one per short poll. Field motivation: four Codex automations
|
|
15
|
+
// polling every 2 minutes backed 21 identical ticks into one thread, while a
|
|
16
|
+
// cron-shaped one spawned a new session per fire.
|
|
17
|
+
export async function watchCmd(o) {
|
|
18
|
+
const ctx = await makeCtx(resolveConfig(o));
|
|
19
|
+
const ws = await workspaceId(ctx);
|
|
20
|
+
const projId = await projectId(ctx, ws, o.project);
|
|
21
|
+
const suffix = projId ? ` (project=${o.project})` : "";
|
|
22
|
+
const timeoutMs = o.timeout ? parseInt(o.timeout, 10) : undefined;
|
|
23
|
+
const timeoutLabel = timeoutMs ? ` (timeout ${timeoutMs}ms)` : " (ctrl-c to stop)";
|
|
24
|
+
const modeLabel = `${o.mine ? " [mine]" : ""}${o.first ? " [first]" : ""}`;
|
|
25
|
+
console.error(`watching workspace=${ctx.workspaceSlug} as ${ctx.agentSlug}${suffix}${modeLabel}${timeoutLabel}`);
|
|
26
|
+
// Best-effort arm signal (delivery gap #8): checkin/doctor read this back to
|
|
27
|
+
// tell "a watch window is/was recently live" apart from "nothing is armed at
|
|
28
|
+
// all". Never let a logging hiccup block the actual watch.
|
|
29
|
+
void ctx.supabase.from("session_log").insert({ workspace_id: ws, kind: "watch" }).then(() => undefined, () => undefined);
|
|
30
|
+
// --mine needs my agent id to test recipient rows / task ownership.
|
|
31
|
+
let myId = null;
|
|
32
|
+
if (o.mine) {
|
|
33
|
+
const { data } = await ctx.supabase.from("agents").select("id").eq("slug", ctx.agentSlug).single();
|
|
34
|
+
myId = data?.id ?? null;
|
|
35
|
+
if (!myId)
|
|
36
|
+
throw new Error(`cannot resolve own agent id for ${ctx.agentSlug}`);
|
|
37
|
+
}
|
|
38
|
+
const msgFilter = projId ? `workspace_id=eq.${ws},project_id=eq.${projId}` : `workspace_id=eq.${ws}`;
|
|
39
|
+
const taskFilter = projId ? `workspace_id=eq.${ws},project_id=eq.${projId}` : `workspace_id=eq.${ws}`;
|
|
40
|
+
let done;
|
|
41
|
+
const finished = new Promise((resolve) => { done = resolve; });
|
|
42
|
+
let hit = false;
|
|
43
|
+
// Dedup: a row inserted between the subscription ack and the catch-up query
|
|
44
|
+
// can surface through both paths; emit each item once.
|
|
45
|
+
const seen = new Set();
|
|
46
|
+
// The reader here is an agent in (or entering) the standing loop, and a bare
|
|
47
|
+
// event line reads as a notification — agents acknowledged mail without
|
|
48
|
+
// acting on it (field incident). Deliver the work-order directive WITH the
|
|
49
|
+
// event on EVERY emit, not only under --first (AI-review finding: plain
|
|
50
|
+
// `watch --mine` streamed bare lines forever with no instruction at all);
|
|
51
|
+
// json mode stays pure data for parsers. `directive` is item-appropriate —
|
|
52
|
+
// a task's follow-up is `codebus task claim/done`, not `codebus read`
|
|
53
|
+
// (AI-review finding: one shared message-flavored directive had been
|
|
54
|
+
// applied to task events too).
|
|
55
|
+
const emit = (key, line, directive) => {
|
|
56
|
+
if (seen.has(key))
|
|
57
|
+
return;
|
|
58
|
+
seen.add(key);
|
|
59
|
+
console.log(o.json ? line : `${line}\n${directive}`);
|
|
60
|
+
if (o.first && !hit) {
|
|
61
|
+
hit = true;
|
|
62
|
+
// Resolve on the next tick so the line above is flushed before exit.
|
|
63
|
+
setImmediate(() => done());
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// Catch-up on arm (--mine --first): anything already unread — or already
|
|
67
|
+
// claimable/mine and untouched — is emitted immediately instead of waiting
|
|
68
|
+
// for a live event. Realtime has no replay, so without this, mail arriving
|
|
69
|
+
// between an automation's windows (or during checkin's orientation,
|
|
70
|
+
// observed live in the wake test) would sit until someone polled; and
|
|
71
|
+
// pre-existing tasks (AI-review finding on this PR: the original drain only
|
|
72
|
+
// ever checked messages, so an already-unclaimed task never surfaced until
|
|
73
|
+
// some UNRELATED new row triggered a live event) would sit unseen
|
|
74
|
+
// indefinitely, since a task nobody touches never fires an INSERT.
|
|
75
|
+
// ORDER MATTERS: the drain runs only after the subscription acks. Draining
|
|
76
|
+
// first looked gapless and wasn't (an earlier AI-review finding on this same
|
|
77
|
+
// PR): a message landing between the drain query and subscribe() vanished.
|
|
78
|
+
// Subscribe -> ack -> drain closes the window; `seen` dedups the overlap.
|
|
79
|
+
let drained = false;
|
|
80
|
+
const drainBacklog = async () => {
|
|
81
|
+
if (drained || !(o.mine && o.first))
|
|
82
|
+
return;
|
|
83
|
+
drained = true;
|
|
84
|
+
// fetchInbox returns oldest-first (delivery gap #2): draining backlog[0]
|
|
85
|
+
// surfaces the OLDEST unhandled message, not the newest — a newest-first
|
|
86
|
+
// drain starved old mail indefinitely under a standing watch loop.
|
|
87
|
+
const backlog = await fetchInbox(ctx, { unread: true, projId, ws });
|
|
88
|
+
if (backlog.length) {
|
|
89
|
+
// RC2 review finding: backlog is oldest-first, and FYI mail requires no
|
|
90
|
+
// reply/ack — so an older class-8 FYI note sitting ahead of a newer
|
|
91
|
+
// class-7 ask/handoff would end EVERY `--first` window on the FYI and
|
|
92
|
+
// never surface the work order (starvation under a standing watch loop).
|
|
93
|
+
// Surface the OLDEST ACTIONABLE item first; fall back to the oldest FYI
|
|
94
|
+
// only when there is no actionable mail — then the FYI is the only thing
|
|
95
|
+
// left, so nothing is starved in the other direction either.
|
|
96
|
+
const actionable = backlog.filter((x) => isActionableMessage(x));
|
|
97
|
+
const m = (actionable.length ? actionable[0] : backlog[0]);
|
|
98
|
+
const more = backlog.length - 1;
|
|
99
|
+
const pendingLine = more > 0
|
|
100
|
+
? (o.json ? "" : `\n${more} more pending — run codebus inbox --unread`)
|
|
101
|
+
: "";
|
|
102
|
+
const line = o.json ? JSON.stringify(m) : `msg ${m.display_id}: ${m.subject ?? m.body}${pendingLine}`;
|
|
103
|
+
// RC2 review finding: this used to hand out ACT_DIRECTIVE unconditionally
|
|
104
|
+
// — a class-8 FYI note (bus_digest's non-actionable class, 0061) got the
|
|
105
|
+
// same "ACT NOW — this is a work order" instruction as a real ask/handoff.
|
|
106
|
+
// isActionableMessage() mirrors bus_digest's own class-7/8 split; fetchInbox
|
|
107
|
+
// already selects type/required_action on every row, so `m` carries both.
|
|
108
|
+
emit(`msg:${m.display_id}`, line, isActionableMessage(m) ? ACT_DIRECTIVE : FYI_DIRECTIVE);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// No unread mail — check for a pre-existing task that's mine or claimable.
|
|
112
|
+
let tq = ctx.supabase.from("tasks").select("display_id, title, owner_agent_id")
|
|
113
|
+
.eq("workspace_id", ws).in("status", ["todo", "in_progress"]);
|
|
114
|
+
tq = projId ? tq.eq("project_id", projId) : tq;
|
|
115
|
+
tq = tq.or(`owner_agent_id.is.null,owner_agent_id.eq.${myId}`);
|
|
116
|
+
const { data: tasks } = await tq.order("created_at", { ascending: false }).limit(1);
|
|
117
|
+
if (tasks?.length) {
|
|
118
|
+
const t = tasks[0];
|
|
119
|
+
emit(`task:${t.display_id}`, o.json ? JSON.stringify(t) : `task ${t.display_id}: ${t.title}`, TASK_ACT_DIRECTIVE);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
// Topic must be unique per invocation: Realtime hands each decoded change
|
|
123
|
+
// to whoever is on the topic when it finishes processing, not who was
|
|
124
|
+
// subscribed at commit time — a fixed shared topic lets one call's message
|
|
125
|
+
// leak into the next call's subscription (reproduced outside vitest).
|
|
126
|
+
const channel = ctx.supabase
|
|
127
|
+
.channel(`codebus:${ctx.agentSlug}:${randomUUID()}`)
|
|
128
|
+
.on("postgres_changes", { event: "INSERT", schema: "public", table: "messages", filter: msgFilter }, async (p) => {
|
|
129
|
+
const row = p.new;
|
|
130
|
+
if (o.mine) {
|
|
131
|
+
// message_recipients is not in the realtime publication, so filter by
|
|
132
|
+
// lookup: am I a recipient of this message? RLS scopes the query to my
|
|
133
|
+
// own recipient rows, so a non-empty result IS the answer. Broadcast
|
|
134
|
+
// messages create a recipient row per member (send.ts), so they match.
|
|
135
|
+
const { data } = await ctx.supabase.from("message_recipients")
|
|
136
|
+
.select("message_id").eq("message_id", row.id).limit(1);
|
|
137
|
+
if (!data?.length)
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Realtime's payload IS the raw messages row, so row.type/row.required_action
|
|
141
|
+
// are present — same isActionableMessage() gate as the backlog drain above.
|
|
142
|
+
emit(`msg:${row.display_id}`, o.json ? JSON.stringify(row) : `msg ${row.display_id}: ${row.subject ?? row.body}`, isActionableMessage(row) ? ACT_DIRECTIVE : FYI_DIRECTIVE);
|
|
143
|
+
})
|
|
144
|
+
.on("postgres_changes", { event: "INSERT", schema: "public", table: "tasks", filter: taskFilter }, (p) => {
|
|
145
|
+
const row = p.new;
|
|
146
|
+
// --mine for tasks: only ones assigned to me, or unclaimed (claimable).
|
|
147
|
+
if (o.mine && row.owner_agent_id && row.owner_agent_id !== myId)
|
|
148
|
+
return;
|
|
149
|
+
emit(`task:${row.display_id}`, o.json ? JSON.stringify(row) : `task ${row.display_id}: ${row.title}`, TASK_ACT_DIRECTIVE);
|
|
150
|
+
})
|
|
151
|
+
.subscribe((status) => {
|
|
152
|
+
// A failed catch-up must not crash the watcher (a bus hiccup shouldn't
|
|
153
|
+
// kill a standing loop) or leak an unhandled rejection (AI-review
|
|
154
|
+
// finding: `void drainBacklog()` had no rejection handler) — the live
|
|
155
|
+
// subscription still works independently of this one-shot drain.
|
|
156
|
+
if (status === "SUBSCRIBED")
|
|
157
|
+
drainBacklog().catch((err) => console.error(`watch: catch-up drain failed (continuing live-only): ${err.message ?? err}`));
|
|
158
|
+
});
|
|
159
|
+
if (timeoutMs) {
|
|
160
|
+
const timer = setTimeout(() => done(), timeoutMs);
|
|
161
|
+
await finished;
|
|
162
|
+
clearTimeout(timer);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
await finished; // --first without timeout: block until the first event
|
|
166
|
+
}
|
|
167
|
+
await channel.unsubscribe();
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js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C,IAAI,IAAI,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,cAAc,KAAK,IAAI;YAAE,OAAO;QACxE,IAAI,CAAC,QAAQ,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,UAAU,KAAK,GAAG,CAAC,KAAK,EAAE,EAAE,kBAAkB,CAAC,CAAC;IAC5H,CAAC,CAAC;SACH,SAAS,CAAC,CAAC,MAAM,EAAE,EAAE;QACpB,uEAAuE;QACvE,kEAAkE;QAClE,sEAAsE;QACtE,iEAAiE;QACjE,IAAI,MAAM,KAAK,YAAY;YAAE,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,wDAAwD,GAAG,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;IAC1J,CAAC,CAAC,CAAC;IAEL,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;QAClD,MAAM,QAAQ,CAAC;QACf,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,CAAC,CAAC,uDAAuD;IACzE,CAAC;IACD,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { resolveConfig } from "../config.js";
|
|
2
|
+
import { makeCtx, workspaceId } from "../client.js";
|
|
3
|
+
import { render } from "../output.js";
|
|
4
|
+
export async function whoamiCmd(o) {
|
|
5
|
+
const ctx = await makeCtx(resolveConfig(o));
|
|
6
|
+
// Person is derived server-side via agents.person_id; null = service agent.
|
|
7
|
+
const { data } = await ctx.supabase
|
|
8
|
+
.from("agents").select("people!person_id(id,slug)").eq("slug", ctx.agentSlug).single();
|
|
9
|
+
const me = data?.people ?? null;
|
|
10
|
+
const person = me?.slug ?? null;
|
|
11
|
+
let conn = null;
|
|
12
|
+
if (me) {
|
|
13
|
+
const ws = await workspaceId(ctx);
|
|
14
|
+
const { data: connData } = await ctx.supabase.from("connections")
|
|
15
|
+
.select("kind, expires_at, other:other_person_id(slug)")
|
|
16
|
+
.eq("workspace_id", ws)
|
|
17
|
+
.eq("person_id", me.id);
|
|
18
|
+
conn = connData;
|
|
19
|
+
}
|
|
20
|
+
const invitedBy = conn?.find((c) => c.kind === "invited_by")?.other?.slug ?? null;
|
|
21
|
+
const mentor = conn?.find((c) => c.kind === "mentor" && new Date(c.expires_at) > new Date())?.other?.slug ?? null;
|
|
22
|
+
console.log(render([{
|
|
23
|
+
agent: ctx.agentSlug, person, workspace: ctx.workspaceSlug,
|
|
24
|
+
invited_by: invitedBy, mentor,
|
|
25
|
+
}], { json: !!o.json }));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,CAAiC;IAC/D,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,4EAA4E;IAC5E,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,CAAC,QAAQ;SAChC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,SAAS,CA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