@ziggs-ai/agent-sdk 0.1.5 → 0.1.7
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 +4 -4
- package/package.json +12 -3
- package/src/context/batch.ts +3 -1
- package/src/index.ts +2 -0
- package/src/pricing/fleetDefaults.ts +1 -1
- package/src/pricing/fleetTierByAgentId.gen.ts +1 -300
- package/src/runtime/PromptBuilder.ts +2 -1
- package/src/server/agreements/AgreementService.ts +11 -5
- package/src/server/tools/index.ts +2 -1
- package/src/server/tools/tier1/protocolTools.ts +1 -1
- package/src/server/tools/tier2/marketplaceTools.ts +4 -2
- package/src/tools/index.ts +2 -0
- package/src/tools/recordReport.ts +82 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ It is **not** a generic chat wrapper: the core idea is a **lightweight state mac
|
|
|
13
13
|
| **`defineAgent` / workflow** | Declarative agent: `initial`, `states`, optional `id`, `description`, `specialization`, merged `tools` / `services`. |
|
|
14
14
|
| **`AgentMachine`** | Interprets the workflow: parked states wait for events; thinking states run `runTurn`; `transitions` picks the next state from context. |
|
|
15
15
|
| **`runTurn`** | Builds prompts, calls the LLM (with tools), parses the model output, and returns effects for the machine. |
|
|
16
|
-
| **`
|
|
16
|
+
| **`AgentHost`** | Batteries-included process: OpenAI adapter, tool manager, task service, context clients, **WebSocket** to Ziggs, and an **`Agent`** that dispatches incoming messages into the machine. |
|
|
17
17
|
| **`Agent`** | Orchestrates message handling, machine lifecycle, and integration with platform APIs (without requiring you to use WebSockets if you construct it yourself). |
|
|
18
18
|
|
|
19
19
|
There is **no** separate compile step: the workflow object is used **directly** by the runtime.
|
|
@@ -50,7 +50,7 @@ The `wait` action is built-in: `defineAgent` automatically injects it into every
|
|
|
50
50
|
## How you usually run an agent
|
|
51
51
|
|
|
52
52
|
1. **`defineAgent({ ... })`** → options object including `workflow`.
|
|
53
|
-
2. Pass **`openaiKey`**, **`operatorKey`** (Ziggs operator token), **`agentId`**, **`wsUrl`**, etc., and **`
|
|
53
|
+
2. Pass **`openaiKey`**, **`operatorKey`** (Ziggs operator token), **`agentId`**, **`wsUrl`**, etc., and **`createAgent(config)`** (returns an **`AgentHost`**).
|
|
54
54
|
3. **`connect()`** to open the WebSocket; the SDK routes platform messages into **`handleMessage`**.
|
|
55
55
|
|
|
56
56
|
Examples in the repo: `examples/agents/*.js` (e.g. coffee, expense, delivery agents).
|
|
@@ -59,14 +59,14 @@ Examples in the repo: `examples/agents/*.js` (e.g. coffee, expense, delivery age
|
|
|
59
59
|
|
|
60
60
|
## Main exports (entry: `src/index.js`)
|
|
61
61
|
|
|
62
|
-
- **`
|
|
62
|
+
- **`AgentHost`**, **`createAgent`**, **`createAgentPool`**, **`defineAgent`**
|
|
63
63
|
- **`Agent`**, **`AgentMachine`**, **`runTurn`**
|
|
64
64
|
- **Prompt / tools:** `PromptBuilder`, `ToolManager`, `defineTool`
|
|
65
65
|
- **Tools come in two tiers — single home: `server/tools/`:**
|
|
66
66
|
- **Tier 1 — protocol grammar (`server/tools/tier1/`, `PROTOCOL_TOOLS`).** The verbs every agent speaks to participate in the agreement/task system: `agreementProposeTool`, `agreementSubcontractTool`, `agreementRespondTool`, `agreementCounterProposalTool`, `taskSpawnTool`, `taskUpdateTool`, `taskUpdatePlanStepTool`. **Framework-managed**: attached via the `taskTools` config (default `'all'`), dispatched to in-process services — *not* passed in the user `tools:` array. Publishing open work is part of this grammar: `agreement_propose({ proposedTo: "everyone" })` (there is no separate publish tool).
|
|
67
67
|
- **Tier 2 — capability bundles (`server/tools/tier2/`, opt-in, HTTP-backed).** Discrete capability domains an agent chooses to have. **Off by default**; an agent gains a capability by spreading the bundle into its `tools:` array. Each tool reads `operatorKey`/`agentId` from tool context and wraps a backend HTTP client. Bundles: `DISCOVERY_TOOLS` (`agentSearchTool`, `agentGetTool`), `MARKETPLACE_TOOLS` (`marketplaceViewTool` — read-only), `PAYMENT_TOOLS` (`paymentBalanceTool`, `paymentTransferTool`, …).
|
|
68
68
|
- **Adapters / utils:** `OpenAIAdapter`, JSON helpers, formatters
|
|
69
|
-
- **Re-exported** from `@ziggs-ai/api-client`: `WebSocketClient`, `
|
|
69
|
+
- **Re-exported** from `@ziggs-ai/api-client`: `WebSocketClient`, `ContextReadClient`, `ContextDiscoveryClient`, `ContextGrantsClient`, `ArtifactsClient`, `MessagesClient`, `ScopeClient`, `AgentSearchClient`, `getBackendUrl`, `getWebSocketUrl`, etc. (There is no `ContextReader` / `ContextWriter` — use the clients above from `@ziggs-ai/api-client` directly.)
|
|
70
70
|
|
|
71
71
|
Package export: `"."` → `src/index.js` (see `package.json`).
|
|
72
72
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/agent-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Agent framework SDK for building autonomous agents on the Ziggs platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -21,9 +21,18 @@
|
|
|
21
21
|
"dotenv": "^17.2.3",
|
|
22
22
|
"openai": "^4.0.0"
|
|
23
23
|
},
|
|
24
|
-
"keywords": [
|
|
24
|
+
"keywords": [
|
|
25
|
+
"ziggs",
|
|
26
|
+
"agent",
|
|
27
|
+
"sdk",
|
|
28
|
+
"ai",
|
|
29
|
+
"autonomous"
|
|
30
|
+
],
|
|
25
31
|
"license": "MIT",
|
|
26
|
-
"files": [
|
|
32
|
+
"files": [
|
|
33
|
+
"src",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
27
36
|
"publishConfig": {
|
|
28
37
|
"access": "public",
|
|
29
38
|
"registry": "https://registry.npmjs.org/"
|
package/src/context/batch.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isBroadcastTarget } from '@ziggs-ai/api-client';
|
|
2
|
+
|
|
1
3
|
export function getBatchEvents(rawEvent: unknown): unknown[] {
|
|
2
4
|
if (!rawEvent) return [];
|
|
3
5
|
const e = rawEvent as Record<string, unknown>;
|
|
@@ -12,6 +14,6 @@ export function isTaskResultRelevantToAgent(result: Record<string, unknown>, own
|
|
|
12
14
|
result['creatorIsYou'] || result['providerIsYou'] || result['payerIsYou'] || result['proposedToIsYou'] ||
|
|
13
15
|
parties['creator'] === ownAgentId || parties['provider'] === ownAgentId ||
|
|
14
16
|
parties['payer'] === ownAgentId || parties['proposedTo'] === ownAgentId ||
|
|
15
|
-
parties['proposedTo']
|
|
17
|
+
isBroadcastTarget(parties['proposedTo'] as string | undefined)
|
|
16
18
|
);
|
|
17
19
|
}
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,8 @@ export { AgreementService } from './server/agreements/AgreementService.js';
|
|
|
54
54
|
export { ToolManager } from './tools/ToolManager.js';
|
|
55
55
|
export { ToolProvider } from './tools/ToolProvider.js';
|
|
56
56
|
export { defineTool } from './tools/defineTool.js';
|
|
57
|
+
export { recordReport } from './tools/recordReport.js';
|
|
58
|
+
export type { RecordReportInput, RecordReportResult, TaskReport } from './tools/recordReport.js';
|
|
57
59
|
export { OpenAIAdapter } from './adapters/OpenAIAdapter.js';
|
|
58
60
|
export { extractJSON, safeParseJSON } from './utils/jsonExtractor.js';
|
|
59
61
|
export { HistoryFormatter, historyFormatter, AgreementFormatter, agreementFormatter } from './formatters/index.js';
|
|
@@ -12,7 +12,7 @@ export const TIER_PRICE_CENTS: Record<FleetPricingTier, number> = {
|
|
|
12
12
|
A: 200, // 2 ZIG / call
|
|
13
13
|
B: 500, // 5 ZIG / call
|
|
14
14
|
C: 1500, // 15 ZIG / job (orchestrator, charged once at top)
|
|
15
|
-
D: 100, // 1 ZIG / call (
|
|
15
|
+
D: 100, // 1 ZIG / call (hand-written demo agents)
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
const ZIGGS_ORCHESTRATOR_IDS = new Set(['ziggs-agent']);
|
|
@@ -270,305 +270,6 @@ export const FLEET_TIER_BY_AGENT_ID: Record<string, FleetPricingTier> = {
|
|
|
270
270
|
"feature-prioritizer": "C",
|
|
271
271
|
"threat-model-committee": "C",
|
|
272
272
|
"negotiation-simulator": "C",
|
|
273
|
-
"pizza-ordering-agent": "D",
|
|
274
|
-
"sushi-ordering-agent": "D",
|
|
275
|
-
"burger-ordering-agent": "D",
|
|
276
|
-
"salad-ordering-agent": "D",
|
|
277
|
-
"coffee-ordering-agent": "D",
|
|
278
|
-
"restaurant-finder": "D",
|
|
279
|
-
"reservation-maker": "D",
|
|
280
|
-
"menu-browser": "D",
|
|
281
|
-
"dietary-filter": "D",
|
|
282
|
-
"review-aggregator": "D",
|
|
283
|
-
"meal-planner": "D",
|
|
284
|
-
"recipe-finder": "D",
|
|
285
|
-
"grocery-list-builder": "D",
|
|
286
|
-
"calorie-counter": "D",
|
|
287
|
-
"wine-pairer": "D",
|
|
288
|
-
"food-delivery-tracker": "D",
|
|
289
|
-
"tip-calculator": "D",
|
|
290
|
-
"split-bill-calculator": "D",
|
|
291
|
-
"allergen-checker": "D",
|
|
292
|
-
"catering-coordinator": "D",
|
|
293
|
-
"party-food-planner": "D",
|
|
294
|
-
"food-truck-finder": "D",
|
|
295
|
-
"brunch-recommender": "D",
|
|
296
|
-
"dessert-advisor": "D",
|
|
297
|
-
"happy-hour-finder": "D",
|
|
298
|
-
"breakfast-planner": "D",
|
|
299
|
-
"late-night-eats-finder": "D",
|
|
300
|
-
"food-allergy-restaurant-finder": "D",
|
|
301
|
-
"kids-menu-finder": "D",
|
|
302
|
-
"flight-searcher": "D",
|
|
303
|
-
"hotel-booker": "D",
|
|
304
|
-
"car-rental": "D",
|
|
305
|
-
"airport-transfer": "D",
|
|
306
|
-
"visa-checker": "D",
|
|
307
|
-
"trip-planner": "D",
|
|
308
|
-
"itinerary-builder": "D",
|
|
309
|
-
"packing-list-maker": "D",
|
|
310
|
-
"currency-advisor": "D",
|
|
311
|
-
"travel-insurance": "D",
|
|
312
|
-
"train-booker": "D",
|
|
313
|
-
"bus-route-finder": "D",
|
|
314
|
-
"ferry-scheduler": "D",
|
|
315
|
-
"road-trip-planner": "D",
|
|
316
|
-
"toll-calculator": "D",
|
|
317
|
-
"rideshare-booker": "D",
|
|
318
|
-
"bike-share": "D",
|
|
319
|
-
"scooter-rental": "D",
|
|
320
|
-
"parking-finder": "D",
|
|
321
|
-
"traffic-checker": "D",
|
|
322
|
-
"travel-photo-finder": "D",
|
|
323
|
-
"local-guide": "D",
|
|
324
|
-
"phrase-book": "D",
|
|
325
|
-
"embassy-locator": "D",
|
|
326
|
-
"timezone-advisor": "D",
|
|
327
|
-
"cruise-finder": "D",
|
|
328
|
-
"camping-booker": "D",
|
|
329
|
-
"hostel-searcher": "D",
|
|
330
|
-
"vacation-rental": "D",
|
|
331
|
-
"loyalty-tracker": "D",
|
|
332
|
-
"electronics-shopper": "D",
|
|
333
|
-
"fashion-advisor": "D",
|
|
334
|
-
"book-recommender": "D",
|
|
335
|
-
"gift-finder": "D",
|
|
336
|
-
"price-comparator": "D",
|
|
337
|
-
"grocery-shopper": "D",
|
|
338
|
-
"furniture-browser": "D",
|
|
339
|
-
"auto-parts-finder": "D",
|
|
340
|
-
"pet-supplies": "D",
|
|
341
|
-
"sports-gear": "D",
|
|
342
|
-
"deal-hunter": "D",
|
|
343
|
-
"coupon-finder": "D",
|
|
344
|
-
"wishlist-manager": "D",
|
|
345
|
-
"return-tracker": "D",
|
|
346
|
-
"warranty-checker": "D",
|
|
347
|
-
"subscription-manager": "D",
|
|
348
|
-
"auction-bidder": "D",
|
|
349
|
-
"local-store-finder": "D",
|
|
350
|
-
"size-converter": "D",
|
|
351
|
-
"product-reviewer": "D",
|
|
352
|
-
"comparison-builder": "D",
|
|
353
|
-
"inventory-checker": "D",
|
|
354
|
-
"price-drop-monitor": "D",
|
|
355
|
-
"flash-sale-alerter": "D",
|
|
356
|
-
"barcode-scanner": "D",
|
|
357
|
-
"doctor-appointment-booker": "D",
|
|
358
|
-
"dentist-scheduler": "D",
|
|
359
|
-
"optometrist-finder": "D",
|
|
360
|
-
"symptom-checker": "D",
|
|
361
|
-
"medication-reminder": "D",
|
|
362
|
-
"prescription-tracker": "D",
|
|
363
|
-
"pharmacy-finder": "D",
|
|
364
|
-
"fitness-trainer": "D",
|
|
365
|
-
"workout-planner": "D",
|
|
366
|
-
"yoga-instructor": "D",
|
|
367
|
-
"meditation-guide": "D",
|
|
368
|
-
"step-counter": "D",
|
|
369
|
-
"nutrition-advisor": "D",
|
|
370
|
-
"diet-planner": "D",
|
|
371
|
-
"water-tracker": "D",
|
|
372
|
-
"sleep-tracker": "D",
|
|
373
|
-
"mood-logger": "D",
|
|
374
|
-
"mental-health-checkin": "D",
|
|
375
|
-
"stress-advisor": "D",
|
|
376
|
-
"breathing-guide": "D",
|
|
377
|
-
"first-aid-advisor": "D",
|
|
378
|
-
"vaccine-tracker": "D",
|
|
379
|
-
"insurance-claim-helper": "D",
|
|
380
|
-
"lab-result-explainer": "D",
|
|
381
|
-
"pet-vet-booker": "D",
|
|
382
|
-
"smart-light-controller": "D",
|
|
383
|
-
"thermostat-manager": "D",
|
|
384
|
-
"smart-lock-controller": "D",
|
|
385
|
-
"camera-monitor": "D",
|
|
386
|
-
"smart-speaker": "D",
|
|
387
|
-
"plumber-finder": "D",
|
|
388
|
-
"electrician-booker": "D",
|
|
389
|
-
"cleaner-scheduler": "D",
|
|
390
|
-
"gardener-finder": "D",
|
|
391
|
-
"pest-control": "D",
|
|
392
|
-
"interior-designer": "D",
|
|
393
|
-
"paint-matcher": "D",
|
|
394
|
-
"furniture-arranger": "D",
|
|
395
|
-
"lighting-planner": "D",
|
|
396
|
-
"utility-tracker": "D",
|
|
397
|
-
"energy-monitor": "D",
|
|
398
|
-
"water-advisor": "D",
|
|
399
|
-
"moving-coordinator": "D",
|
|
400
|
-
"storage-finder": "D",
|
|
401
|
-
"furniture-assembly-helper": "D",
|
|
402
|
-
"home-warranty-manager": "D",
|
|
403
|
-
"renovation-planner": "D",
|
|
404
|
-
"contractor-reviewer": "D",
|
|
405
|
-
"package-tracker": "D",
|
|
406
|
-
"handyman-finder": "D",
|
|
407
|
-
"bank-account-viewer": "D",
|
|
408
|
-
"transaction-categorizer": "D",
|
|
409
|
-
"budget-planner": "D",
|
|
410
|
-
"savings-tracker": "D",
|
|
411
|
-
"credit-card-advisor": "D",
|
|
412
|
-
"loan-calculator": "D",
|
|
413
|
-
"mortgage-estimator": "D",
|
|
414
|
-
"refinance-checker": "D",
|
|
415
|
-
"portfolio-tracker": "D",
|
|
416
|
-
"stock-trader-sim": "D",
|
|
417
|
-
"crypto-trader-sim": "D",
|
|
418
|
-
"robo-advisor": "D",
|
|
419
|
-
"tax-estimator": "D",
|
|
420
|
-
"deduction-finder": "D",
|
|
421
|
-
"tax-filing-assistant": "D",
|
|
422
|
-
"receipt-organizer": "D",
|
|
423
|
-
"auto-insurance-quoter": "D",
|
|
424
|
-
"home-insurance-quoter": "D",
|
|
425
|
-
"life-insurance-quoter": "D",
|
|
426
|
-
"health-insurance-quoter": "D",
|
|
427
|
-
"claim-filer": "D",
|
|
428
|
-
"bill-pay-scheduler": "D",
|
|
429
|
-
"subscription-auditor": "D",
|
|
430
|
-
"retirement-calculator": "D",
|
|
431
|
-
"college-savings-planner": "D",
|
|
432
|
-
"uber-sim": "D",
|
|
433
|
-
"lyft-sim": "D",
|
|
434
|
-
"taxi-booker": "D",
|
|
435
|
-
"shuttle-service": "D",
|
|
436
|
-
"limo-booker": "D",
|
|
437
|
-
"subway-navigator": "D",
|
|
438
|
-
"bus-tracker": "D",
|
|
439
|
-
"commuter-rail": "D",
|
|
440
|
-
"light-rail": "D",
|
|
441
|
-
"ferry-booker": "D",
|
|
442
|
-
"bike-rental": "D",
|
|
443
|
-
"scooter-rental-sim": "D",
|
|
444
|
-
"e-bike-finder": "D",
|
|
445
|
-
"skateboard-rental": "D",
|
|
446
|
-
"segway-tour": "D",
|
|
447
|
-
"parking-meter": "D",
|
|
448
|
-
"garage-finder": "D",
|
|
449
|
-
"valet-service": "D",
|
|
450
|
-
"airport-parking": "D",
|
|
451
|
-
"street-parking": "D",
|
|
452
|
-
"car-wash-finder": "D",
|
|
453
|
-
"oil-change-scheduler": "D",
|
|
454
|
-
"tire-shop": "D",
|
|
455
|
-
"mechanic-finder": "D",
|
|
456
|
-
"roadside-assistance": "D",
|
|
457
|
-
"course-finder": "D",
|
|
458
|
-
"university-searcher": "D",
|
|
459
|
-
"scholarship-finder": "D",
|
|
460
|
-
"admission-advisor": "D",
|
|
461
|
-
"resume-reviewer": "D",
|
|
462
|
-
"job-searcher": "D",
|
|
463
|
-
"interview-prepper": "D",
|
|
464
|
-
"salary-negotiator": "D",
|
|
465
|
-
"career-coach": "D",
|
|
466
|
-
"online-class-enrollor": "D",
|
|
467
|
-
"certificate-tracker": "D",
|
|
468
|
-
"skill-assessor": "D",
|
|
469
|
-
"mentor-matcher": "D",
|
|
470
|
-
"language-lesson-booker": "D",
|
|
471
|
-
"music-lesson-scheduler": "D",
|
|
472
|
-
"tutoring-booker": "D",
|
|
473
|
-
"internship-finder": "D",
|
|
474
|
-
"networking-advisor": "D",
|
|
475
|
-
"linkedin-optimizer": "D",
|
|
476
|
-
"conference-finder": "D",
|
|
477
|
-
"workshop-registrar": "D",
|
|
478
|
-
"webinar-scheduler": "D",
|
|
479
|
-
"library-manager": "D",
|
|
480
|
-
"study-group-coordinator": "D",
|
|
481
|
-
"campus-navigator": "D",
|
|
482
|
-
"concert-ticket-buyer": "D",
|
|
483
|
-
"movie-ticket-booker": "D",
|
|
484
|
-
"theater-booker": "D",
|
|
485
|
-
"party-organizer": "D",
|
|
486
|
-
"wedding-planner": "D",
|
|
487
|
-
"birthday-coordinator": "D",
|
|
488
|
-
"sports-ticket-buyer": "D",
|
|
489
|
-
"gym-membership-manager": "D",
|
|
490
|
-
"spa-booker": "D",
|
|
491
|
-
"streaming-manager": "D",
|
|
492
|
-
"playlist-curator": "D",
|
|
493
|
-
"podcast-recommender": "D",
|
|
494
|
-
"board-game-organizer": "D",
|
|
495
|
-
"trivia-host": "D",
|
|
496
|
-
"karaoke-picker": "D",
|
|
497
|
-
"museum-ticket-buyer": "D",
|
|
498
|
-
"zoo-pass-manager": "D",
|
|
499
|
-
"amusement-park-planner": "D",
|
|
500
|
-
"festival-finder": "D",
|
|
501
|
-
"book-club-organizer": "D",
|
|
502
|
-
"art-class-booker": "D",
|
|
503
|
-
"cooking-class-finder": "D",
|
|
504
|
-
"photography-booker": "D",
|
|
505
|
-
"escape-room-booker": "D",
|
|
506
|
-
"dmv-appointment": "D",
|
|
507
|
-
"passport-renewal": "D",
|
|
508
|
-
"visa-tracker": "D",
|
|
509
|
-
"voter-registration": "D",
|
|
510
|
-
"polling-finder": "D",
|
|
511
|
-
"official-lookup": "D",
|
|
512
|
-
"building-permit-tracker": "D",
|
|
513
|
-
"zoning-info": "D",
|
|
514
|
-
"noise-complaint-filer": "D",
|
|
515
|
-
"jury-duty-manager": "D",
|
|
516
|
-
"court-date-tracker": "D",
|
|
517
|
-
"public-record-searcher": "D",
|
|
518
|
-
"tax-authority-contact": "D",
|
|
519
|
-
"benefits-checker": "D",
|
|
520
|
-
"park-permit": "D",
|
|
521
|
-
"recycling-guide": "D",
|
|
522
|
-
"carbon-calculator": "D",
|
|
523
|
-
"eco-product-finder": "D",
|
|
524
|
-
"volunteer-finder": "D",
|
|
525
|
-
"donation-tracker": "D",
|
|
526
|
-
"charity-evaluator": "D",
|
|
527
|
-
"community-board": "D",
|
|
528
|
-
"neighborhood-alert": "D",
|
|
529
|
-
"lost-and-found": "D",
|
|
530
|
-
"carpool-matcher": "D",
|
|
531
|
-
"bike-route-planner": "D",
|
|
532
|
-
"transit-optimizer": "D",
|
|
533
|
-
"solar-estimator": "D",
|
|
534
|
-
"ev-charger-finder": "D",
|
|
535
|
-
"green-energy-advisor": "D",
|
|
536
|
-
"pet-adoption": "D",
|
|
537
|
-
"breeder-finder": "D",
|
|
538
|
-
"pet-sitter-booker": "D",
|
|
539
|
-
"dog-walker": "D",
|
|
540
|
-
"pet-groomer": "D",
|
|
541
|
-
"pet-boarding": "D",
|
|
542
|
-
"pet-food-delivery": "D",
|
|
543
|
-
"pet-toy-recommender": "D",
|
|
544
|
-
"pet-training-class": "D",
|
|
545
|
-
"pet-insurance-comparer": "D",
|
|
546
|
-
"dry-cleaner": "D",
|
|
547
|
-
"tailor-finder": "D",
|
|
548
|
-
"shoe-repair": "D",
|
|
549
|
-
"watch-repair": "D",
|
|
550
|
-
"phone-repair": "D",
|
|
551
|
-
"car-detailer": "D",
|
|
552
|
-
"car-wash-booker": "D",
|
|
553
|
-
"auto-detailing": "D",
|
|
554
|
-
"mechanic-scheduler": "D",
|
|
555
|
-
"tire-rotator": "D",
|
|
556
|
-
"photo-printer": "D",
|
|
557
|
-
"custom-framer": "D",
|
|
558
|
-
"engraver": "D",
|
|
559
|
-
"embroiderer": "D",
|
|
560
|
-
"storage-unit-finder": "D",
|
|
561
|
-
"junk-removal": "D",
|
|
562
|
-
"donation-pickup": "D",
|
|
563
|
-
"hauler": "D",
|
|
564
|
-
"painter-finder": "D",
|
|
565
|
-
"roofer-finder": "D",
|
|
566
|
-
"window-washer": "D",
|
|
567
|
-
"chimney-sweep": "D",
|
|
568
|
-
"snow-remover": "D",
|
|
569
|
-
"lawn-care": "D",
|
|
570
|
-
"tree-trimmer": "D",
|
|
571
|
-
"power-washer": "D",
|
|
572
273
|
"aristotle": "B",
|
|
573
274
|
"plato": "B",
|
|
574
275
|
"confucius": "B",
|
|
@@ -1019,4 +720,4 @@ export const FLEET_TIER_BY_AGENT_ID: Record<string, FleetPricingTier> = {
|
|
|
1019
720
|
"death-studies-scholar": "B"
|
|
1020
721
|
} as Record<string, FleetPricingTier>;
|
|
1021
722
|
|
|
1022
|
-
export const FLEET_TIER_MAP_SIZE =
|
|
723
|
+
export const FLEET_TIER_MAP_SIZE = 713;
|
|
@@ -2,6 +2,7 @@ import type { Action, Ctx, PromptDef } from '../types.js';
|
|
|
2
2
|
import { HistoryFormatter, AgreementFormatter } from '../formatters/index.js';
|
|
3
3
|
import { validateContext } from '../cognition/validateContext.js';
|
|
4
4
|
import type { RawEvent } from './buildOutcome.js';
|
|
5
|
+
import { isBroadcastTarget } from '@ziggs-ai/api-client';
|
|
5
6
|
|
|
6
7
|
type AnyObj = Record<string, unknown>;
|
|
7
8
|
|
|
@@ -370,7 +371,7 @@ ${this._renderDecisionSchemaFromActions(actions, senderMeta, ctxObj, omitMessage
|
|
|
370
371
|
|
|
371
372
|
const replyTo = (senderMeta.defaultReplyReceiverId as string) || '<receiverId>';
|
|
372
373
|
const pendingProposals = (ctxObj.agreements || []).filter(
|
|
373
|
-
(a) => (a.proposal as Record<string, unknown> | undefined)?.status === 'pending' && (a.proposedToIsYou || (a.parties as Record<string, unknown> | undefined)?.proposedTo
|
|
374
|
+
(a) => (a.proposal as Record<string, unknown> | undefined)?.status === 'pending' && (a.proposedToIsYou || isBroadcastTarget((a.parties as Record<string, unknown> | undefined)?.proposedTo as string | undefined)),
|
|
374
375
|
);
|
|
375
376
|
|
|
376
377
|
if (pendingProposals.length > 0) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
proposeAgreement, delegateAgreement, respondToAgreement, counterAgreement,
|
|
2
|
+
proposeAgreement, proposeBroadcast as proposeBroadcastApi, delegateAgreement, respondToAgreement, counterAgreement,
|
|
3
3
|
getAgreementStatus, listAgreements, getMyAgreements, getAgreement,
|
|
4
4
|
publishOffer as publishOfferApi, createAgreement, revokeAgreement, getAgreementsByChat, linkAgreementToChat,
|
|
5
5
|
getChatsForAgreement, joinAgreement, linkArtifactToAgreement, getArtifactsForAgreement,
|
|
6
6
|
linkUserToAgreement, getUsersForAgreement, createContract,
|
|
7
|
-
OPEN_AGREEMENT_TARGET,
|
|
8
7
|
type Creds, type Agreement,
|
|
9
8
|
type ProposeAgreementData, type ProposeDirectInput, type ProposeBroadcastInput,
|
|
10
9
|
type PublishOfferPayload,
|
|
@@ -32,9 +31,13 @@ export class AgreementService {
|
|
|
32
31
|
return proposeAgreement(payload, this.creds);
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Open buyer-broadcast. `payload.audience` selects who may see/claim it:
|
|
36
|
+
* 'everyone' (default, fully public) or 'org' (members of your active org).
|
|
37
|
+
* Server defaults engagementKind to `service`.
|
|
38
|
+
*/
|
|
36
39
|
proposeBroadcast(payload: ProposeBroadcastInput): Promise<Agreement> {
|
|
37
|
-
return
|
|
40
|
+
return proposeBroadcastApi(payload, this.creds);
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
/** @deprecated Alias for {@link proposeDirect}. */
|
|
@@ -42,7 +45,10 @@ export class AgreementService {
|
|
|
42
45
|
return proposeAgreement(payload, this.creds);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Seller-broadcast marketplace offer. `payload.audience` sets the `payer`
|
|
50
|
+
* sentinel: 'everyone' (default, public) or 'org' (your active org only).
|
|
51
|
+
*/
|
|
46
52
|
publishOffer(payload: PublishOfferPayload): Promise<Agreement> {
|
|
47
53
|
return publishOfferApi(payload, this.creds);
|
|
48
54
|
}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* config (default 'all'), dispatched to in-process services (taskService /
|
|
8
8
|
* agreementService) injected into tool context — NOT passed in the user `tools:`
|
|
9
9
|
* array. Publishing open work is part of this grammar:
|
|
10
|
-
* agreement_propose({ proposedTo: "everyone" })
|
|
10
|
+
* agreement_propose({ proposedTo: "everyone" }) for a public broadcast, or
|
|
11
|
+
* proposedTo: "org" to scope it to your org — there is no separate publish tool.
|
|
11
12
|
*
|
|
12
13
|
* Tier 2 — capability bundles (tier2/). Opt-in, HTTP-backed tool bundles an agent
|
|
13
14
|
* chooses to have. Off by default; an agent gains a bundle by spreading it into
|
|
@@ -33,7 +33,7 @@ export const agreementProposeTool: ToolDefinition = defineTool(
|
|
|
33
33
|
'agreement_propose',
|
|
34
34
|
{ description: { type: 'string', required: true }, proposedTo: { type: 'string', required: true }, engagementKind: { type: 'string', enum: ['hire', 'service'], description: 'Contract type. Defaults to service when omitted.' }, parentAgreementId: 'string', parentTaskId: 'string', payerId: 'string', providerId: 'string', price: 'number', lifecycle: 'string', expiresAt: 'string', maxExecutions: 'number', agreementDescription: 'string', plan: { type: 'object' }, planReviewTiming: 'string', requireMidWorkPlanAck: 'boolean' },
|
|
35
35
|
handlerFor('agreement-propose'),
|
|
36
|
-
{ description: 'Propose a contract to a user, agent, or everyone (proposedTo="
|
|
36
|
+
{ description: 'Propose a contract to a user, agent, or as an open broadcast. For a broadcast set proposedTo="everyone" (fully public — any agent may claim) or proposedTo="org" (scoped to your org — only members of your org see and claim it). engagementKind defaults to service.', isAgreementCreation: true },
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
export const agreementSubcontractTool: ToolDefinition = defineTool(
|
|
@@ -4,7 +4,9 @@ import { pullFromLedger } from '@ziggs-ai/api-client';
|
|
|
4
4
|
type Ctx = Record<string, unknown>;
|
|
5
5
|
|
|
6
6
|
// Read-only marketplace access. Publishing an open quest is NOT here: it is the
|
|
7
|
-
// tier-1 protocol verb agreement_propose({ proposedTo: "everyone" }).
|
|
7
|
+
// tier-1 protocol verb agreement_propose({ proposedTo: "everyone" | "org" }).
|
|
8
|
+
// This feed already returns only quests the caller may see — org-scoped quests
|
|
9
|
+
// appear here only for members of the quest's org (filtered server-side).
|
|
8
10
|
export const marketplaceViewTool: ToolDefinition = defineTool('marketplace_view',
|
|
9
11
|
{ limit: 'number', since: 'string' },
|
|
10
12
|
async (args, ctx) => {
|
|
@@ -19,7 +21,7 @@ export const marketplaceViewTool: ToolDefinition = defineTool('marketplace_view'
|
|
|
19
21
|
const quests = await pullFromLedger(options, { operatorKey, agentId });
|
|
20
22
|
return { quests, count: quests.length };
|
|
21
23
|
},
|
|
22
|
-
{ description: 'Browse open quests on the marketplace — work
|
|
24
|
+
{ description: 'Browse open quests on the marketplace — work buyers have broadcast to willing agents. Returns public quests plus any org-scoped quests in your org. To claim a quest, use agreement_respond on the returned agreementId. To publish your own, use agreement_propose({ proposedTo: "everyone" }) for a public quest or proposedTo: "org" to keep it inside your org.' },
|
|
23
25
|
);
|
|
24
26
|
|
|
25
27
|
export const MARKETPLACE_TOOLS: ToolDefinition[] = [marketplaceViewTool];
|
package/src/tools/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { ToolManager } from './ToolManager.js';
|
|
2
2
|
export { ToolProvider } from './ToolProvider.js';
|
|
3
3
|
export { defineTool } from './defineTool.js';
|
|
4
|
+
export { recordReport } from './recordReport.js';
|
|
5
|
+
export type { RecordReportInput, RecordReportResult, TaskReport } from './recordReport.js';
|
|
4
6
|
// Pure protocol-tool name registry (no handlers, no services).
|
|
5
7
|
export { PROTOCOL_TOOL_NAMES, PROTOCOL_TOOL_TO_OPERATION, mapProtocolToolToOperation, isProtocolToolName } from '../tasks/protocolRegistry.js';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArtifactsClient,
|
|
3
|
+
updateTaskState,
|
|
4
|
+
type Creds,
|
|
5
|
+
} from '@ziggs-ai/api-client';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The canonical report shape (B1 convention — ZIG-561).
|
|
9
|
+
* Matches Task.result as set by ziggs_set_task_result.
|
|
10
|
+
*/
|
|
11
|
+
export interface TaskReport {
|
|
12
|
+
summary: string;
|
|
13
|
+
status?: string;
|
|
14
|
+
links?: string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface RecordReportInput {
|
|
18
|
+
creds: Creds;
|
|
19
|
+
taskId: string;
|
|
20
|
+
report: TaskReport;
|
|
21
|
+
/**
|
|
22
|
+
* Primary artifact scope — required when `deliverable` is provided.
|
|
23
|
+
* Pass exactly one of chatId or agreementId.
|
|
24
|
+
*/
|
|
25
|
+
chatId?: string;
|
|
26
|
+
agreementId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Heavy deliverable text (document, diff, data).
|
|
29
|
+
* When present, writes a `content_type=result` artifact bound to the task
|
|
30
|
+
* alongside setting Task.result.
|
|
31
|
+
*/
|
|
32
|
+
deliverable?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface RecordReportResult {
|
|
36
|
+
taskId: string;
|
|
37
|
+
artifactId?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Record a conformant report for a completed task (B2 — ZIG-562).
|
|
42
|
+
*
|
|
43
|
+
* Always sets Task.result via updateTaskState (the canonical done payload).
|
|
44
|
+
* When `deliverable` is provided, also writes a task-bound result artifact
|
|
45
|
+
* via ArtifactsClient so it is retrievable as `via=task:<taskId>`.
|
|
46
|
+
*
|
|
47
|
+
* Implements the B1 convention (Agents/REPORTING.md).
|
|
48
|
+
*/
|
|
49
|
+
export async function recordReport(
|
|
50
|
+
input: RecordReportInput,
|
|
51
|
+
): Promise<RecordReportResult> {
|
|
52
|
+
const { creds, taskId, report, chatId, agreementId, deliverable } = input;
|
|
53
|
+
|
|
54
|
+
if (deliverable && !chatId && !agreementId) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
'recordReport: chatId or agreementId is required when deliverable is provided',
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
await updateTaskState(
|
|
61
|
+
taskId,
|
|
62
|
+
'completed',
|
|
63
|
+
{ result: { summary: report.summary, status: report.status ?? 'ok', links: report.links ?? [] } },
|
|
64
|
+
creds,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (!deliverable) {
|
|
68
|
+
return { taskId };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const artifactsClient = new ArtifactsClient(creds.operatorKey, creds.agentId);
|
|
72
|
+
await artifactsClient.write({
|
|
73
|
+
text: deliverable,
|
|
74
|
+
content_type: 'result',
|
|
75
|
+
taskId,
|
|
76
|
+
chatId,
|
|
77
|
+
agreementId,
|
|
78
|
+
visibility: 'chat',
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return { taskId };
|
|
82
|
+
}
|