@brantrusnak/openclaw-omadeus 1.0.1 → 1.0.3
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/README.md +5 -2
- package/dist/_virtual/_rolldown/runtime.js +4 -0
- package/dist/api.js +5 -0
- package/dist/index.js +14 -0
- package/dist/runtime-api.js +15 -0
- package/dist/setup-entry.js +7 -0
- package/dist/src/allowed-reaction-emojis.js +21 -0
- package/dist/src/api/auth.api.js +115 -0
- package/dist/src/api/channel.api.js +23 -0
- package/dist/src/api/message.api.js +76 -0
- package/dist/src/api/nugget.api.js +127 -0
- package/dist/src/auth.js +30 -0
- package/dist/src/channel.js +626 -0
- package/dist/src/config.js +52 -0
- package/dist/src/defaults.js +5 -0
- package/dist/src/inbound-policy.js +205 -0
- package/dist/src/inbound.js +97 -0
- package/dist/src/member-resolve.js +53 -0
- package/dist/src/message-handler.js +262 -0
- package/dist/src/nugget-lookup.js +140 -0
- package/dist/src/onboarding.js +363 -0
- package/dist/src/outbound.js +17 -0
- package/dist/src/reply-dispatcher.js +46 -0
- package/dist/src/runtime.js +5 -0
- package/dist/src/setup-core.js +46 -0
- package/dist/src/setup-surface.js +2 -0
- package/dist/src/socket/dolphin.socket.js +18 -0
- package/dist/src/socket/jaguar.socket.js +22 -0
- package/dist/src/socket/socket.js +153 -0
- package/dist/src/store.js +13 -0
- package/dist/src/token.js +84 -0
- package/dist/src/types.js +15 -0
- package/dist/src/utils/http.util.js +43 -0
- package/dist/src/utils/jwt.util.js +15 -0
- package/openclaw.plugin.json +144 -28
- package/package.json +12 -7
- package/src/api/auth.api.ts +0 -29
- package/src/api/channel.api.ts +29 -0
- package/src/api/nugget.api.ts +81 -10
- package/src/channel.ts +136 -247
- package/src/inbound-policy.ts +250 -0
- package/src/inbound.ts +20 -0
- package/src/member-resolve.ts +84 -0
- package/src/message-handler.ts +99 -53
- package/src/nugget-lookup.ts +67 -4
- package/src/onboarding.ts +283 -200
- package/src/setup-core.ts +10 -1
- package/src/socket/socket.ts +24 -11
- package/src/types.ts +77 -7
package/src/nugget-lookup.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { readNuggetNumber } from "./api/nugget.api.js";
|
|
2
|
+
import { mergePeopleIntoNuggetAgentPayload } from "./member-resolve.js";
|
|
3
|
+
import type { OmadeusApiOptions } from "./utils/http.util.js";
|
|
4
|
+
|
|
1
5
|
export type NuggetLookupIntent = {
|
|
2
6
|
/** Display nugget number from `N###` (maps to API `number`, not internal `id`). */
|
|
3
7
|
nuggetNumber: number;
|
|
@@ -150,6 +154,13 @@ const NUGGET_FIELDS_FOR_AGENT = [
|
|
|
150
154
|
"releaseNumber",
|
|
151
155
|
"publicRoomId",
|
|
152
156
|
"privateRoomId",
|
|
157
|
+
"memberReferenceId",
|
|
158
|
+
"assigneeReferenceId",
|
|
159
|
+
"ownerReferenceId",
|
|
160
|
+
"memberFirstName",
|
|
161
|
+
"memberLastName",
|
|
162
|
+
"assigneeFirstName",
|
|
163
|
+
"assigneeLastName",
|
|
153
164
|
] as const;
|
|
154
165
|
|
|
155
166
|
export function pickNuggetFieldsForAgent(record: Record<string, unknown>): Record<string, unknown> {
|
|
@@ -162,16 +173,31 @@ export function pickNuggetFieldsForAgent(record: Record<string, unknown>): Recor
|
|
|
162
173
|
return out;
|
|
163
174
|
}
|
|
164
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Picked Dolphin fields + `people` map (referenceId → display name) for the organization.
|
|
178
|
+
*/
|
|
179
|
+
export async function buildNuggetAgentDataPayload(
|
|
180
|
+
apiOpts: OmadeusApiOptions,
|
|
181
|
+
fullRecord: Record<string, unknown> | null,
|
|
182
|
+
): Promise<Record<string, unknown> | null> {
|
|
183
|
+
if (!fullRecord) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
const base = pickNuggetFieldsForAgent(fullRecord);
|
|
187
|
+
return mergePeopleIntoNuggetAgentPayload(apiOpts, fullRecord, base);
|
|
188
|
+
}
|
|
189
|
+
|
|
165
190
|
/**
|
|
166
191
|
* Augments the user message so the agent receives Dolphin nugget/task data and can reply with a summary.
|
|
167
192
|
* On miss or API error, the agent still gets instructions to respond helpfully.
|
|
168
193
|
*/
|
|
169
|
-
export function appendNuggetLookupContextForAgent(
|
|
194
|
+
export async function appendNuggetLookupContextForAgent(
|
|
170
195
|
rawBody: string,
|
|
171
196
|
nuggetNumber: number,
|
|
172
197
|
record: Record<string, unknown> | null,
|
|
198
|
+
apiOpts: OmadeusApiOptions,
|
|
173
199
|
fetchError?: string,
|
|
174
|
-
): string {
|
|
200
|
+
): Promise<string> {
|
|
175
201
|
const header = `[Omadeus nugget/task N${nuggetNumber}]`;
|
|
176
202
|
|
|
177
203
|
if (fetchError) {
|
|
@@ -188,9 +214,46 @@ export function appendNuggetLookupContextForAgent(
|
|
|
188
214
|
);
|
|
189
215
|
}
|
|
190
216
|
|
|
191
|
-
const payload = pickNuggetFieldsForAgent(record);
|
|
217
|
+
const payload = (await buildNuggetAgentDataPayload(apiOpts, record)) ?? pickNuggetFieldsForAgent(record);
|
|
218
|
+
return (
|
|
219
|
+
`${rawBody}\n\n${header} Data from Omadeus (summarize for someone tracking this work — status, ownership, timeline, project; plain language. **For assignees and anyone in \`people\` / \`*FirstName\` fields, use those names; never read raw *ReferenceId numbers to the user as a person.**):\n` +
|
|
220
|
+
`${JSON.stringify(payload, null, 2)}`
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Enriches a Task or Nugget **Jaguar room** with Dolphin data matched by this chat's `roomId`, so the
|
|
226
|
+
* agent can answer "status" without a bare `N###` in the message.
|
|
227
|
+
*/
|
|
228
|
+
export async function appendNuggetContextForTaskOrNuggetRoom(
|
|
229
|
+
rawBody: string,
|
|
230
|
+
roomId: number,
|
|
231
|
+
roomName: string | null,
|
|
232
|
+
record: Record<string, unknown> | null,
|
|
233
|
+
apiOpts: OmadeusApiOptions,
|
|
234
|
+
fetchError?: string,
|
|
235
|
+
): Promise<string> {
|
|
236
|
+
const roomLabel = roomName?.trim() ? `room ${roomId} ("${roomName.trim()}")` : `room ${roomId}`;
|
|
237
|
+
|
|
238
|
+
if (fetchError) {
|
|
239
|
+
return (
|
|
240
|
+
`${rawBody}\n\n[Omadeus, this task/nugget ${roomLabel}] Lookup failed: ${fetchError}.\n` +
|
|
241
|
+
`Answer from this thread. Do not tell the user to "use the Omadeus platform" or similar — give a direct reply or a concrete next step.`
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (!record) {
|
|
246
|
+
return (
|
|
247
|
+
`${rawBody}\n\n[Omadeus, this task/nugget ${roomLabel}] No Dolphin row matched this room id in search yet.\n` +
|
|
248
|
+
`Answer from the conversation; be honest if you cannot see live fields. Do not hand-wave to "the platform".`
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const n = readNuggetNumber(record);
|
|
253
|
+
const nLabel = n !== undefined ? `N${n}` : "nugget";
|
|
254
|
+
const payload = (await buildNuggetAgentDataPayload(apiOpts, record)) ?? pickNuggetFieldsForAgent(record);
|
|
192
255
|
return (
|
|
193
|
-
`${rawBody}\n\n${
|
|
256
|
+
`${rawBody}\n\n[Omadeus ${nLabel} for this chat room] The following is live task/nugget data — **answer the user with this** (stage, status, title, who, due date; plain language. **For assignee/owner, use \`people\` and name fields; never recite *ReferenceId numbers (e.g. 210) as a person's name.**). \`task/...\` in the UI is not an OpenClaw session key.\n` +
|
|
194
257
|
`${JSON.stringify(payload, null, 2)}`
|
|
195
258
|
);
|
|
196
259
|
}
|