@ai-wendao/ant 0.3.20 → 0.4.1
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 +9 -1
- package/client.js +754 -1
- package/conversation.js +658 -0
- package/cordis.patch.yml +26 -0
- package/delegation.js +1016 -0
- package/index.js +319 -2
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export const name = 'ant'
|
|
|
3
3
|
import { createHash } from 'node:crypto'
|
|
4
4
|
import { createRequire } from 'node:module'
|
|
5
5
|
import { installSkill, listSkills, uninstallSkill } from './skill-install.js'
|
|
6
|
+
import { readLocalDelegationSettings, recentDelegationStatus, startDelegationHost,
|
|
7
|
+
writeLocalDelegationSettings } from './delegation.js'
|
|
6
8
|
|
|
7
9
|
export const inject = []
|
|
8
10
|
|
|
@@ -18,6 +20,17 @@ const SKILL_ORIGINAL_PATH = '/api/ant-teams/skills/original'
|
|
|
18
20
|
const SKILL_INSTALL_PATH = '/api/ant-teams/skills/install'
|
|
19
21
|
const SKILL_UNINSTALL_PATH = '/api/ant-teams/skills/uninstall'
|
|
20
22
|
const PLUGINS_PATH = '/api/ant-teams/plugins'
|
|
23
|
+
const DELEGATION_BOTS_PATH = '/api/ant-teams/delegation/bots'
|
|
24
|
+
const DELEGATION_GRANTS_PATH = '/api/ant-teams/delegation/grants'
|
|
25
|
+
const DELEGATION_ENROLLED_BOTS_PATH = '/api/ant-teams/delegation/enrolled-bots'
|
|
26
|
+
const DELEGATION_GROUPS_PATH = '/api/ant-teams/delegation/groups'
|
|
27
|
+
const DELEGATION_OWNER_CHALLENGE_PATH = '/api/ant-teams/delegation/owner-challenge'
|
|
28
|
+
const DELEGATION_STATUS_PATH = '/api/ant-teams/delegation/status'
|
|
29
|
+
const DELEGATION_CARDS_PATH = '/api/ant-teams/delegation/cards'
|
|
30
|
+
const DELEGATION_SETTINGS_PATH = '/api/ant-teams/delegation/settings'
|
|
31
|
+
const DELEGATION_EXECUTORS_PATH = '/api/ant-teams/delegation/executors'
|
|
32
|
+
const DELEGATION_LOCAL_SETTINGS_PATH = '/api/ant-teams/delegation/local-settings'
|
|
33
|
+
const DELEGATION_CANCEL_PATH = '/api/ant-teams/delegation/cancel'
|
|
21
34
|
const ANT_NPM_PACKAGE_NAME = '@ai-wendao/ant'
|
|
22
35
|
const BUNDLE_VERSION = createRequire(import.meta.url)('./package.json').version
|
|
23
36
|
const MAX_MODEL_RESPONSE_BYTES = 1024 * 1024
|
|
@@ -117,7 +130,7 @@ async function updateModelSession(serviceUrl, token, action) {
|
|
|
117
130
|
})
|
|
118
131
|
}
|
|
119
132
|
|
|
120
|
-
async function readLimitedBody(response) {
|
|
133
|
+
async function readLimitedBody(response, maxBytes = MAX_MODEL_RESPONSE_BYTES) {
|
|
121
134
|
if (!response.body) return ''
|
|
122
135
|
const reader = response.body.getReader()
|
|
123
136
|
const chunks = []
|
|
@@ -127,7 +140,7 @@ async function readLimitedBody(response) {
|
|
|
127
140
|
const { done, value } = await reader.read()
|
|
128
141
|
if (done) break
|
|
129
142
|
size += value.byteLength
|
|
130
|
-
if (size >
|
|
143
|
+
if (size > maxBytes) {
|
|
131
144
|
await reader.cancel()
|
|
132
145
|
return null
|
|
133
146
|
}
|
|
@@ -184,6 +197,252 @@ async function fetchMemberModels(request, credentials, settings) {
|
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
|
|
200
|
+
function dshImService(ctx) {
|
|
201
|
+
try { return ctx.get?.('dshIm') ?? ctx.dshIm ?? null } catch { return null }
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async function fetchDelegationBots(request, ctx) {
|
|
205
|
+
if (request.method !== 'GET') return jsonResponse(405, { message: '只支持 GET 请求。' })
|
|
206
|
+
const service = dshImService(ctx)
|
|
207
|
+
if (!service?.listBots || !service?.describeBot) return jsonResponse(503, { message: '请先安装并启用 DSH-IM。' })
|
|
208
|
+
try {
|
|
209
|
+
const bots = (await service.listBots()).filter((bot) => bot.channel === 'feishu').slice(0, 50)
|
|
210
|
+
const result = await Promise.all(bots.map(async (bot) => {
|
|
211
|
+
try {
|
|
212
|
+
const details = await service.describeBot(bot.botId)
|
|
213
|
+
return {
|
|
214
|
+
bot_id: bot.botId, name: details.account?.name || bot.botId,
|
|
215
|
+
fingerprint: details.account?.fingerprint,
|
|
216
|
+
connected: details.connected === true,
|
|
217
|
+
available: details.capabilities?.includes('exclusive-text-consumer')
|
|
218
|
+
&& details.capabilities?.includes('reply-text-checked'),
|
|
219
|
+
history_available: details.capabilities?.includes('history-text-checked') === true,
|
|
220
|
+
}
|
|
221
|
+
} catch { return null }
|
|
222
|
+
}))
|
|
223
|
+
return jsonResponse(200, { bots: result.filter(Boolean) })
|
|
224
|
+
} catch { return jsonResponse(502, { message: '暂时无法读取 DSH-IM 机器人列表。' }) }
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
async function fetchDelegationGrants(request, ctx, credentials, settings) {
|
|
228
|
+
if (!['GET', 'POST', 'DELETE'].includes(request.method)) return jsonResponse(405, { message: '请求方式不支持。' })
|
|
229
|
+
let connection
|
|
230
|
+
try { connection = await readMemberConnection(credentials, settings) } catch {
|
|
231
|
+
return jsonResponse(500, { message: '无法读取 ANT 连接。' })
|
|
232
|
+
}
|
|
233
|
+
if (!connection) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
234
|
+
let body
|
|
235
|
+
if (request.method !== 'GET') {
|
|
236
|
+
try {
|
|
237
|
+
const raw = await request.text()
|
|
238
|
+
if (raw.length > 16_384) return jsonResponse(413, { message: '委托设置过大。' })
|
|
239
|
+
body = JSON.parse(raw)
|
|
240
|
+
} catch { return jsonResponse(400, { message: '委托设置格式无效。' }) }
|
|
241
|
+
}
|
|
242
|
+
if (request.method === 'POST') {
|
|
243
|
+
const service = dshImService(ctx)
|
|
244
|
+
if (!service?.describeBot) return jsonResponse(503, { message: '请先安装并启用 DSH-IM。' })
|
|
245
|
+
try {
|
|
246
|
+
const bot = await service.describeBot(body.bot_id)
|
|
247
|
+
if (bot.channel !== 'feishu' || !bot.connected || bot.account?.fingerprint !== body.bot_fingerprint
|
|
248
|
+
|| !bot.capabilities?.includes('exclusive-text-consumer') || !bot.capabilities?.includes('reply-text-checked')) {
|
|
249
|
+
return jsonResponse(400, { message: '请选择已连接且支持协作收件的飞书机器人。' })
|
|
250
|
+
}
|
|
251
|
+
} catch { return jsonResponse(400, { message: '机器人当前不可用。' }) }
|
|
252
|
+
}
|
|
253
|
+
if (request.method === 'DELETE' && (typeof body?.id !== 'string' || !/^[0-9a-f-]{36}$/iu.test(body.id))) {
|
|
254
|
+
return jsonResponse(400, { message: '委托授权编号无效。' })
|
|
255
|
+
}
|
|
256
|
+
const path = request.method === 'DELETE'
|
|
257
|
+
? `/api/me/im-delegations/${encodeURIComponent(body.id)}` : '/api/me/im-delegations'
|
|
258
|
+
try {
|
|
259
|
+
const response = await fetch(new URL(path, connection.serviceUrl), {
|
|
260
|
+
method: request.method,
|
|
261
|
+
headers: { authorization: `Bearer ${connection.token}`, accept: 'application/json',
|
|
262
|
+
...(request.method === 'POST' ? { 'content-type': 'application/json' } : {}) },
|
|
263
|
+
...(request.method === 'POST' ? { body: JSON.stringify(body) } : {}),
|
|
264
|
+
redirect: 'manual', signal: AbortSignal.timeout(12_000),
|
|
265
|
+
})
|
|
266
|
+
if (response.status === 404 && request.method !== 'DELETE') {
|
|
267
|
+
return jsonResponse(426, { message: '团队服务端尚未支持委托审查,请联系管理员升级 ANT 服务端。' })
|
|
268
|
+
}
|
|
269
|
+
if (response.status === 204) return new Response(null, { status: 204 })
|
|
270
|
+
const text = await readLimitedBody(response)
|
|
271
|
+
if (text === null) return jsonResponse(502, { message: '委托设置响应过大。' })
|
|
272
|
+
return new Response(text, { status: response.status,
|
|
273
|
+
headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } })
|
|
274
|
+
} catch { return jsonResponse(502, { message: '暂时无法连接 ANT 团队服务。' }) }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function fetchDelegationGroupSettings(request, ctx, credentials, settings, kind) {
|
|
278
|
+
const methods = kind === 'groups' ? ['GET'] : kind === 'challenge' ? ['POST'] : ['GET', 'POST', 'DELETE']
|
|
279
|
+
if (!methods.includes(request.method)) return jsonResponse(405, { message: '请求方式不支持。' })
|
|
280
|
+
let connection
|
|
281
|
+
try { connection = await readMemberConnection(credentials, settings) } catch {
|
|
282
|
+
return jsonResponse(500, { message: '无法读取 ANT 连接。' })
|
|
283
|
+
}
|
|
284
|
+
if (!connection) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
285
|
+
let body = null
|
|
286
|
+
if (request.method !== 'GET') {
|
|
287
|
+
try {
|
|
288
|
+
const raw = await request.text()
|
|
289
|
+
if (raw.length > 2048) return jsonResponse(413, { message: '请求内容过大。' })
|
|
290
|
+
body = JSON.parse(raw)
|
|
291
|
+
} catch { return jsonResponse(400, { message: '请求格式无效。' }) }
|
|
292
|
+
}
|
|
293
|
+
if (kind === 'bots' && request.method === 'POST') {
|
|
294
|
+
const service = dshImService(ctx)
|
|
295
|
+
if (!service?.describeBot) return jsonResponse(503, { message: '请先安装并启用 DSH-IM。' })
|
|
296
|
+
try {
|
|
297
|
+
const bot = await service.describeBot(body.bot_id)
|
|
298
|
+
if (bot.channel !== 'feishu' || !bot.connected || bot.account?.fingerprint !== body.bot_fingerprint
|
|
299
|
+
|| !bot.capabilities?.includes('exclusive-text-consumer') || !bot.capabilities?.includes('reply-text-checked')) {
|
|
300
|
+
return jsonResponse(400, { message: '请选择已连接且支持协作收件的飞书机器人。' })
|
|
301
|
+
}
|
|
302
|
+
} catch { return jsonResponse(400, { message: '机器人当前不可用。' }) }
|
|
303
|
+
}
|
|
304
|
+
if (kind === 'bots' && request.method === 'DELETE'
|
|
305
|
+
&& (typeof body?.bot_id !== 'string' || !body.bot_id || body.bot_id.length > 128)) {
|
|
306
|
+
return jsonResponse(400, { message: '机器人编号无效。' })
|
|
307
|
+
}
|
|
308
|
+
const path = kind === 'groups' ? '/api/me/im-delegations/groups'
|
|
309
|
+
: kind === 'challenge' ? '/api/me/im-delegations/owner-challenge'
|
|
310
|
+
: request.method === 'DELETE'
|
|
311
|
+
? `/api/me/im-delegations/bots/${encodeURIComponent(body.bot_id)}`
|
|
312
|
+
: '/api/me/im-delegations/bots'
|
|
313
|
+
try {
|
|
314
|
+
const response = await fetch(new URL(path, connection.serviceUrl), {
|
|
315
|
+
method: request.method,
|
|
316
|
+
headers: { authorization: `Bearer ${connection.token}`, accept: 'application/json',
|
|
317
|
+
...(request.method === 'POST' ? { 'content-type': 'application/json' } : {}) },
|
|
318
|
+
...(request.method === 'POST' ? { body: JSON.stringify(body) } : {}),
|
|
319
|
+
redirect: 'manual', signal: AbortSignal.timeout(12_000),
|
|
320
|
+
})
|
|
321
|
+
if (response.status === 404 && request.method !== 'DELETE') {
|
|
322
|
+
return jsonResponse(426, { message: '团队服务端尚未支持群聊委托,请联系管理员升级 ANT 服务端。' })
|
|
323
|
+
}
|
|
324
|
+
if (response.status === 204) return new Response(null, { status: 204 })
|
|
325
|
+
const text = await readLimitedBody(response)
|
|
326
|
+
if (text === null) return jsonResponse(502, { message: '团队服务响应过大。' })
|
|
327
|
+
return new Response(text, { status: response.status,
|
|
328
|
+
headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } })
|
|
329
|
+
} catch { return jsonResponse(502, { message: '暂时无法连接 ANT 团队服务。' }) }
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
async function fetchDelegationStatus(request, credentials, settings) {
|
|
333
|
+
if (request.method !== 'GET') return jsonResponse(405, { message: '只支持 GET 请求。' })
|
|
334
|
+
try {
|
|
335
|
+
const connection = await readMemberConnection(credentials, settings)
|
|
336
|
+
if (!connection) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
337
|
+
return jsonResponse(200, { items: await recentDelegationStatus(connection.serviceUrl) })
|
|
338
|
+
} catch { return jsonResponse(503, { message: '本机委托任务记录暂时无法读取,请联系管理员检查。' }) }
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async function fetchDelegationCards(request, ctx, credentials, settings) {
|
|
342
|
+
if (!['GET', 'POST', 'DELETE'].includes(request.method)) return jsonResponse(405, { message: '请求方式不支持。' })
|
|
343
|
+
let connection
|
|
344
|
+
try { connection = await readMemberConnection(credentials, settings) } catch {
|
|
345
|
+
return jsonResponse(500, { message: '无法读取 ANT 连接。' })
|
|
346
|
+
}
|
|
347
|
+
if (!connection) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
348
|
+
let body = null
|
|
349
|
+
if (request.method !== 'GET') {
|
|
350
|
+
try {
|
|
351
|
+
const raw = await request.text()
|
|
352
|
+
if (raw.length > 32_768) return jsonResponse(413, { message: '任务设置过大。' })
|
|
353
|
+
body = JSON.parse(raw)
|
|
354
|
+
} catch { return jsonResponse(400, { message: '任务设置格式无效。' }) }
|
|
355
|
+
}
|
|
356
|
+
if (request.method === 'POST') {
|
|
357
|
+
const service = dshImService(ctx)
|
|
358
|
+
if (!service?.describeBot) return jsonResponse(503, { message: '请先安装并启用 DSH-IM。' })
|
|
359
|
+
try {
|
|
360
|
+
const bot = await service.describeBot(body.bot_id)
|
|
361
|
+
if (bot.channel !== 'feishu' || !bot.connected || bot.account?.fingerprint !== body.bot_fingerprint
|
|
362
|
+
|| !bot.capabilities?.includes('exclusive-text-consumer') || !bot.capabilities?.includes('reply-text-checked')) {
|
|
363
|
+
return jsonResponse(400, { message: '请选择已连接且支持协作收件的飞书机器人。' })
|
|
364
|
+
}
|
|
365
|
+
} catch { return jsonResponse(400, { message: '机器人当前不可用。' }) }
|
|
366
|
+
}
|
|
367
|
+
if (request.method === 'DELETE' && (typeof body?.id !== 'string' || !/^[0-9a-f-]{36}$/iu.test(body.id))) {
|
|
368
|
+
return jsonResponse(400, { message: '任务编号无效。' })
|
|
369
|
+
}
|
|
370
|
+
const path = request.method === 'DELETE'
|
|
371
|
+
? `/api/me/im-delegations/cards/${encodeURIComponent(body.id)}` : '/api/me/im-delegations/cards'
|
|
372
|
+
try {
|
|
373
|
+
const response = await fetch(new URL(path, connection.serviceUrl), {
|
|
374
|
+
method: request.method,
|
|
375
|
+
headers: { authorization: `Bearer ${connection.token}`, accept: 'application/json',
|
|
376
|
+
...(request.method === 'POST' ? { 'content-type': 'application/json' } : {}) },
|
|
377
|
+
...(request.method === 'POST' ? { body: JSON.stringify(body) } : {}),
|
|
378
|
+
redirect: 'manual', signal: AbortSignal.timeout(12_000),
|
|
379
|
+
})
|
|
380
|
+
if (response.status === 404 && request.method !== 'DELETE') return jsonResponse(426, { message: '团队服务端尚未支持自定义任务,请联系管理员升级。' })
|
|
381
|
+
if (response.status === 204) return new Response(null, { status: 204 })
|
|
382
|
+
const text = await readLimitedBody(response, request.method === 'GET' ? 8 * 1024 * 1024 : MAX_MODEL_RESPONSE_BYTES)
|
|
383
|
+
if (text === null) return jsonResponse(502, { message: '团队服务响应过大。' })
|
|
384
|
+
return new Response(text, { status: response.status,
|
|
385
|
+
headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } })
|
|
386
|
+
} catch { return jsonResponse(502, { message: '暂时无法连接 ANT 团队服务。' }) }
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
async function fetchDelegationRuntimeSettings(request, credentials, settings) {
|
|
390
|
+
if (request.method !== 'GET') return jsonResponse(405, { message: '请求方式不支持。' })
|
|
391
|
+
try {
|
|
392
|
+
const connection = await readMemberConnection(credentials, settings)
|
|
393
|
+
if (!connection) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
394
|
+
const response = await fetch(new URL('/api/me/im-delegations/settings', connection.serviceUrl), {
|
|
395
|
+
headers: { authorization: `Bearer ${connection.token}`, accept: 'application/json' },
|
|
396
|
+
redirect: 'manual', signal: AbortSignal.timeout(12_000),
|
|
397
|
+
})
|
|
398
|
+
if (!response.ok) return jsonResponse(response.status, { message: '暂时无法读取团队协作设置。' })
|
|
399
|
+
return jsonResponse(200, await response.json())
|
|
400
|
+
} catch { return jsonResponse(502, { message: '暂时无法读取团队协作设置。' }) }
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function fetchDelegationExecutors(request, ctx) {
|
|
404
|
+
if (request.method !== 'GET') return jsonResponse(405, { message: '请求方式不支持。' })
|
|
405
|
+
let providers = []
|
|
406
|
+
try { providers = (ctx.get?.('subagents') ?? ctx.subagents)?.list?.() || [] } catch {}
|
|
407
|
+
const available = new Set(providers)
|
|
408
|
+
return jsonResponse(200, [
|
|
409
|
+
{ id: 'dsh', title: 'DSH', available: Boolean(ctx.sessionController && ctx.agents) },
|
|
410
|
+
{ id: 'codex', title: 'Codex', available: available.has('codex') },
|
|
411
|
+
{ id: 'claude-code', title: 'Claude Code', available: available.has('claude-code') },
|
|
412
|
+
{ id: 'acp', title: 'DSH ACP', available: available.has('acp') },
|
|
413
|
+
{ id: 'dsh-sdk', title: 'DSH SDK 子代理', available: available.has('dsh-sdk') },
|
|
414
|
+
])
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
async function fetchDelegationLocalSettings(request, credentials, settings) {
|
|
418
|
+
if (!['GET', 'PUT'].includes(request.method)) return jsonResponse(405, { message: '请求方式不支持。' })
|
|
419
|
+
try {
|
|
420
|
+
if (!await readMemberConnection(credentials, settings)) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
421
|
+
if (request.method === 'GET') return jsonResponse(200, await readLocalDelegationSettings())
|
|
422
|
+
const raw = await request.text()
|
|
423
|
+
if (raw.length > 256) return jsonResponse(413, { message: '设置内容过大。' })
|
|
424
|
+
const body = JSON.parse(raw)
|
|
425
|
+
return jsonResponse(200, await writeLocalDelegationSettings(body))
|
|
426
|
+
} catch (error) { return jsonResponse(400, { message: error?.message || '本机设置无法保存。' }) }
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
async function fetchDelegationCancel(request, credentials, settings, getHost) {
|
|
430
|
+
if (request.method !== 'POST') return jsonResponse(405, { message: '请求方式不支持。' })
|
|
431
|
+
try {
|
|
432
|
+
const connection = await readMemberConnection(credentials, settings)
|
|
433
|
+
if (!connection) return jsonResponse(401, { message: '请先连接 ANT 团队。' })
|
|
434
|
+
const raw = await request.text()
|
|
435
|
+
if (raw.length > 256) return jsonResponse(413, { message: '请求内容过大。' })
|
|
436
|
+
const body = JSON.parse(raw)
|
|
437
|
+
if (typeof body.task_id !== 'string' || !/^[A-F0-9]{10}$/u.test(body.task_id)) {
|
|
438
|
+
return jsonResponse(400, { message: '任务编号无效。' })
|
|
439
|
+
}
|
|
440
|
+
const host = getHost()
|
|
441
|
+
if (!host) return jsonResponse(503, { message: '协作机器人尚未就绪。' })
|
|
442
|
+
return jsonResponse(200, { canceled: await host.cancelTask(body.task_id, connection.serviceUrl) })
|
|
443
|
+
} catch { return jsonResponse(503, { message: '暂时无法取消任务,请稍后重试。' }) }
|
|
444
|
+
}
|
|
445
|
+
|
|
187
446
|
async function fetchServiceInfo(request, credentials, settings) {
|
|
188
447
|
if (request.method !== 'POST') return jsonResponse(405, { message: '只支持 POST 请求' })
|
|
189
448
|
let body
|
|
@@ -588,6 +847,7 @@ async function fetchAuthRequest(request, endpoint, credentials, settings) {
|
|
|
588
847
|
|
|
589
848
|
export function apply(ctx) {
|
|
590
849
|
ctx.inject(['connection', 'credentials', 'settings'], (connectionCtx) => {
|
|
850
|
+
let delegationHost = null
|
|
591
851
|
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
592
852
|
path: SERVICE_INFO_PATH,
|
|
593
853
|
methods: ['POST'],
|
|
@@ -632,6 +892,51 @@ export function apply(ctx) {
|
|
|
632
892
|
path: PLUGINS_PATH, methods: ['GET'], requestBody: 'buffered',
|
|
633
893
|
fetch: (request) => fetchMemberPlugins(request, connectionCtx.credentials, connectionCtx.settings),
|
|
634
894
|
}), 'ant-teams: enterprise plugin catalog')
|
|
895
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
896
|
+
path: DELEGATION_BOTS_PATH, methods: ['GET'], requestBody: 'buffered',
|
|
897
|
+
fetch: (request) => fetchDelegationBots(request, connectionCtx),
|
|
898
|
+
}), 'ant-teams: DSH-IM collaboration bots')
|
|
899
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
900
|
+
path: DELEGATION_GRANTS_PATH, methods: ['GET', 'POST', 'DELETE'], requestBody: 'buffered',
|
|
901
|
+
fetch: (request) => fetchDelegationGrants(request, connectionCtx,
|
|
902
|
+
connectionCtx.credentials, connectionCtx.settings),
|
|
903
|
+
}), 'ant-teams: member delegation settings')
|
|
904
|
+
for (const [path, methods, kind] of [
|
|
905
|
+
[DELEGATION_ENROLLED_BOTS_PATH, ['GET', 'POST', 'DELETE'], 'bots'],
|
|
906
|
+
[DELEGATION_GROUPS_PATH, ['GET'], 'groups'],
|
|
907
|
+
[DELEGATION_OWNER_CHALLENGE_PATH, ['POST'], 'challenge'],
|
|
908
|
+
]) {
|
|
909
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
910
|
+
path, methods, requestBody: 'buffered',
|
|
911
|
+
fetch: (request) => fetchDelegationGroupSettings(request, connectionCtx,
|
|
912
|
+
connectionCtx.credentials, connectionCtx.settings, kind),
|
|
913
|
+
}), `ant-teams: member delegation ${kind}`)
|
|
914
|
+
}
|
|
915
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
916
|
+
path: DELEGATION_STATUS_PATH, methods: ['GET'], requestBody: 'buffered',
|
|
917
|
+
fetch: (request) => fetchDelegationStatus(request, connectionCtx.credentials, connectionCtx.settings),
|
|
918
|
+
}), 'ant-teams: local delegated task status')
|
|
919
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
920
|
+
path: DELEGATION_CARDS_PATH, methods: ['GET', 'POST', 'DELETE'], requestBody: 'buffered',
|
|
921
|
+
fetch: (request) => fetchDelegationCards(request, connectionCtx, connectionCtx.credentials, connectionCtx.settings),
|
|
922
|
+
}), 'ant-teams: member task cards')
|
|
923
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
924
|
+
path: DELEGATION_SETTINGS_PATH, methods: ['GET'], requestBody: 'buffered',
|
|
925
|
+
fetch: (request) => fetchDelegationRuntimeSettings(request, connectionCtx.credentials, connectionCtx.settings),
|
|
926
|
+
}), 'ant-teams: collaboration defaults')
|
|
927
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
928
|
+
path: DELEGATION_EXECUTORS_PATH, methods: ['GET'], requestBody: 'buffered',
|
|
929
|
+
fetch: (request) => fetchDelegationExecutors(request, connectionCtx),
|
|
930
|
+
}), 'ant-teams: local executor availability')
|
|
931
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
932
|
+
path: DELEGATION_LOCAL_SETTINGS_PATH, methods: ['GET', 'PUT'], requestBody: 'buffered',
|
|
933
|
+
fetch: (request) => fetchDelegationLocalSettings(request, connectionCtx.credentials, connectionCtx.settings),
|
|
934
|
+
}), 'ant-teams: local delegated-task concurrency')
|
|
935
|
+
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
936
|
+
path: DELEGATION_CANCEL_PATH, methods: ['POST'], requestBody: 'buffered',
|
|
937
|
+
fetch: (request) => fetchDelegationCancel(request, connectionCtx.credentials,
|
|
938
|
+
connectionCtx.settings, () => delegationHost),
|
|
939
|
+
}), 'ant-teams: owner cancellation for delegated tasks')
|
|
635
940
|
connectionCtx.effect(() => connectionCtx.connection.fetch.register({
|
|
636
941
|
path: DISCONNECT_PATH,
|
|
637
942
|
methods: ['POST'],
|
|
@@ -676,5 +981,17 @@ export function apply(ctx) {
|
|
|
676
981
|
} catch {}
|
|
677
982
|
}
|
|
678
983
|
}, 'ant-teams: ANT model activity session')
|
|
984
|
+
connectionCtx.inject?.(['dshIm', 'sessionController', 'sessions', 'agents', 'tools'], (delegationCtx) => {
|
|
985
|
+
delegationCtx.effect(() => {
|
|
986
|
+
const host = startDelegationHost(delegationCtx,
|
|
987
|
+
() => readMemberConnection(delegationCtx.credentials, delegationCtx.settings))
|
|
988
|
+
delegationHost = host
|
|
989
|
+
return async () => {
|
|
990
|
+
if (delegationHost === host) delegationHost = null
|
|
991
|
+
await host()
|
|
992
|
+
}
|
|
993
|
+
},
|
|
994
|
+
'ant-teams: delegated IM review intake')
|
|
995
|
+
})
|
|
679
996
|
})
|
|
680
997
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-wendao/ant",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "ANT (AI-native Teams) connects a DeepSeek Harness Desktop profile to team identity and approved models.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "node --test client.test.js index.test.js skill-install.test.js tools/migrate-legacy.test.mjs"
|
|
7
|
+
"test": "node --test client.test.js delegation.test.js index.test.js skill-install.test.js tools/migrate-legacy.test.mjs"
|
|
8
8
|
},
|
|
9
9
|
"bin": {
|
|
10
10
|
"ant-migrate": "tools/migrate-legacy.mjs"
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"./client": "./client.js",
|
|
17
17
|
"./locale/*.json": "./locale/*.json"
|
|
18
18
|
},
|
|
19
|
-
"files": ["index.js", "client.js", "skill-install.js", "cordis.patch.yml", "locale/*.json", "tools/migrate-legacy.mjs", "MIGRATION.md", "README.md"],
|
|
19
|
+
"files": ["index.js", "client.js", "skill-install.js", "delegation.js", "conversation.js", "cordis.patch.yml", "locale/*.json", "tools/migrate-legacy.mjs", "MIGRATION.md", "README.md"],
|
|
20
20
|
"dsh": {
|
|
21
21
|
"bundle": {
|
|
22
22
|
"patch": "./cordis.patch.yml"
|