@farazirfan/costar-server-executor 1.7.37 → 1.7.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.d.ts +90 -0
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +606 -0
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/pi-embedded-runner/run.d.ts.map +1 -1
- package/dist/agent/pi-embedded-runner/run.js +2 -1
- package/dist/agent/pi-embedded-runner/run.js.map +1 -1
- package/dist/agent/pi-embedded-runner/system-prompt.d.ts.map +1 -1
- package/dist/agent/pi-embedded-runner/system-prompt.js +16 -37
- package/dist/agent/pi-embedded-runner/system-prompt.js.map +1 -1
- package/dist/agent/pi-embedded-runner/tools.d.ts +4 -1
- package/dist/agent/pi-embedded-runner/tools.d.ts.map +1 -1
- package/dist/agent/pi-embedded-runner/tools.js +3 -1
- package/dist/agent/pi-embedded-runner/tools.js.map +1 -1
- package/dist/agent/pi-embedded-runner/types.d.ts +4 -0
- package/dist/agent/pi-embedded-runner/types.d.ts.map +1 -1
- package/dist/cli/env-loader.d.ts.map +1 -1
- package/dist/cli/env-loader.js +1 -0
- package/dist/cli/env-loader.js.map +1 -1
- package/dist/cli/setup.js +2 -2
- package/dist/cli/setup.js.map +1 -1
- package/dist/cron/normalize.d.ts +31 -0
- package/dist/cron/normalize.d.ts.map +1 -0
- package/dist/cron/normalize.js +211 -0
- package/dist/cron/normalize.js.map +1 -0
- package/dist/cron/scheduler.d.ts +33 -3
- package/dist/cron/scheduler.d.ts.map +1 -1
- package/dist/cron/scheduler.js +253 -48
- package/dist/cron/scheduler.js.map +1 -1
- package/dist/heartbeat/runner.d.ts +27 -12
- package/dist/heartbeat/runner.d.ts.map +1 -1
- package/dist/heartbeat/runner.js +82 -104
- package/dist/heartbeat/runner.js.map +1 -1
- package/dist/infra/heartbeat-events-filter.d.ts +29 -0
- package/dist/infra/heartbeat-events-filter.d.ts.map +1 -0
- package/dist/infra/heartbeat-events-filter.js +80 -0
- package/dist/infra/heartbeat-events-filter.js.map +1 -0
- package/dist/infra/index.d.ts +9 -0
- package/dist/infra/index.d.ts.map +1 -0
- package/dist/infra/index.js +9 -0
- package/dist/infra/index.js.map +1 -0
- package/dist/infra/system-events.d.ts +58 -2
- package/dist/infra/system-events.d.ts.map +1 -1
- package/dist/infra/system-events.js +80 -14
- package/dist/infra/system-events.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.js.map +1 -1
- package/dist/services/platform-keys.d.ts +19 -0
- package/dist/services/platform-keys.d.ts.map +1 -0
- package/dist/services/platform-keys.js +74 -0
- package/dist/services/platform-keys.js.map +1 -0
- package/dist/subagent/registry.d.ts +96 -0
- package/dist/subagent/registry.d.ts.map +1 -0
- package/dist/subagent/registry.js +180 -0
- package/dist/subagent/registry.js.map +1 -0
- package/dist/tools/complete-turn.d.ts +2 -2
- package/dist/tools/complete-turn.js +10 -10
- package/dist/tools/complete-turn.js.map +1 -1
- package/dist/tools/contacts.d.ts +13 -0
- package/dist/tools/contacts.d.ts.map +1 -0
- package/dist/tools/contacts.js +80 -0
- package/dist/tools/contacts.js.map +1 -0
- package/dist/tools/cron.d.ts +17 -2
- package/dist/tools/cron.d.ts.map +1 -1
- package/dist/tools/cron.js +117 -35
- package/dist/tools/cron.js.map +1 -1
- package/dist/tools/google-maps.d.ts +6 -6
- package/dist/tools/google-maps.d.ts.map +1 -1
- package/dist/tools/google-maps.js +207 -262
- package/dist/tools/google-maps.js.map +1 -1
- package/dist/tools/index.d.ts +17 -7
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +40 -9
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/phone-call.d.ts +11 -0
- package/dist/tools/phone-call.d.ts.map +1 -0
- package/dist/tools/phone-call.js +151 -0
- package/dist/tools/phone-call.js.map +1 -0
- package/dist/tools/sessions-spawn.d.ts +33 -0
- package/dist/tools/sessions-spawn.d.ts.map +1 -0
- package/dist/tools/sessions-spawn.js +164 -0
- package/dist/tools/sessions-spawn.js.map +1 -0
- package/dist/tools/spotify.d.ts +12 -0
- package/dist/tools/spotify.d.ts.map +1 -0
- package/dist/tools/spotify.js +251 -0
- package/dist/tools/spotify.js.map +1 -0
- package/dist/tools/subagents.d.ts +23 -0
- package/dist/tools/subagents.d.ts.map +1 -0
- package/dist/tools/subagents.js +209 -0
- package/dist/tools/subagents.js.map +1 -0
- package/dist/tools/whatsapp.d.ts +13 -0
- package/dist/tools/whatsapp.d.ts.map +1 -0
- package/dist/tools/whatsapp.js +215 -0
- package/dist/tools/whatsapp.js.map +1 -0
- package/dist/tools/youtube.d.ts +12 -0
- package/dist/tools/youtube.d.ts.map +1 -0
- package/dist/tools/youtube.js +218 -0
- package/dist/tools/youtube.js.map +1 -0
- package/dist/utils/asterizk-auth.d.ts +43 -0
- package/dist/utils/asterizk-auth.d.ts.map +1 -0
- package/dist/utils/asterizk-auth.js +125 -0
- package/dist/utils/asterizk-auth.js.map +1 -0
- package/dist/web-server.d.ts.map +1 -1
- package/dist/web-server.js +132 -0
- package/dist/web-server.js.map +1 -1
- package/dist/workspace/index.d.ts +3 -4
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +3 -4
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/templates.d.ts +8 -7
- package/dist/workspace/templates.d.ts.map +1 -1
- package/dist/workspace/templates.js +18 -127
- package/dist/workspace/templates.js.map +1 -1
- package/dist/workspace/workspace.d.ts +2 -4
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/dist/workspace/workspace.js +7 -16
- package/dist/workspace/workspace.js.map +1 -1
- package/package.json +1 -1
- package/public/index.html +231 -0
- package/skills/docx/SKILL.md +468 -0
- package/skills/docx/scripts/__init__.py +1 -0
- package/skills/docx/scripts/accept_changes.py +181 -0
- package/skills/docx/scripts/comment.py +347 -0
- package/skills/docx/scripts/helpers/__init__.py +0 -0
- package/skills/docx/scripts/helpers/merge_runs.py +231 -0
- package/skills/docx/scripts/helpers/simplify_redlines.py +240 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/docx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/docx/scripts/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/docx/scripts/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/docx/scripts/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/docx/scripts/ooxml/scripts/pack.py +159 -0
- package/skills/docx/scripts/ooxml/scripts/unpack.py +29 -0
- package/skills/docx/scripts/ooxml/scripts/validate.py +106 -0
- package/skills/docx/scripts/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/docx/scripts/ooxml/scripts/validation/base.py +1023 -0
- package/skills/docx/scripts/ooxml/scripts/validation/docx.py +519 -0
- package/skills/docx/scripts/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/docx/scripts/ooxml/scripts/validation/redlining.py +284 -0
- package/skills/docx/scripts/pack.py +166 -0
- package/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/docx/scripts/unpack.py +134 -0
- package/skills/longform-video-generation/SKILL.md +298 -0
- package/skills/longform-video-generation/references/advanced_techniques.md +474 -0
- package/skills/longform-video-generation/references/google_api_guide.md +288 -0
- package/skills/longform-video-generation/scripts/video_generator.py +579 -0
- package/skills/pdf/FORMS.md +305 -0
- package/skills/pdf/REFERENCE.md +612 -0
- package/skills/pdf/SKILL.md +293 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +70 -0
- package/skills/pdf/scripts/check_fillable_fields.py +12 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/skills/pdf/scripts/create_validation_image.py +41 -0
- package/skills/pdf/scripts/extract_form_field_info.py +152 -0
- package/skills/pdf/scripts/extract_form_structure.py +124 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +116 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +136 -0
- package/skills/pptx/SKILL.md +171 -0
- package/skills/pptx/editing.md +205 -0
- package/skills/pptx/pptxgenjs.md +377 -0
- package/skills/pptx/scripts/add_slide.py +225 -0
- package/skills/pptx/scripts/clean.py +309 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/pptx/scripts/ooxml/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/pptx/scripts/ooxml/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/pptx/scripts/ooxml/schemas/mce/mc.xsd +75 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/pptx/scripts/ooxml/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/pptx/scripts/ooxml/scripts/pack.py +159 -0
- package/skills/pptx/scripts/ooxml/scripts/unpack.py +29 -0
- package/skills/pptx/scripts/ooxml/scripts/validate.py +106 -0
- package/skills/pptx/scripts/ooxml/scripts/validation/__init__.py +15 -0
- package/skills/pptx/scripts/ooxml/scripts/validation/base.py +1023 -0
- package/skills/pptx/scripts/ooxml/scripts/validation/docx.py +519 -0
- package/skills/pptx/scripts/ooxml/scripts/validation/pptx.py +315 -0
- package/skills/pptx/scripts/ooxml/scripts/validation/redlining.py +284 -0
- package/skills/pptx/scripts/pack.py +168 -0
- package/skills/pptx/scripts/thumbnail.py +318 -0
- package/skills/pptx/scripts/unpack.py +86 -0
- package/skills/xlsx/SKILL.md +291 -0
- package/skills/xlsx/recalc.py +247 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoStar Server Executor - Subagent Registry
|
|
3
|
+
* Ported from OpenClaw's agents/subagent-registry.ts
|
|
4
|
+
*
|
|
5
|
+
* Differences from OpenClaw:
|
|
6
|
+
* - In-memory only (no disk persistence, no Supabase) — subagent runs are ephemeral
|
|
7
|
+
* - No gateway event listener (uses Promise completion instead)
|
|
8
|
+
* - No announce retry queue (single injectIsolatedResult call)
|
|
9
|
+
* - AbortController stored on each record for kill support
|
|
10
|
+
* - No multi-agent routing (single agent per user)
|
|
11
|
+
*
|
|
12
|
+
* Matched with OpenClaw:
|
|
13
|
+
* - Same SubagentRunRecord concept (simplified fields)
|
|
14
|
+
* - Same query functions (listRunsForRequester, countActiveRunsForSession)
|
|
15
|
+
* - Same target resolution (index, runId prefix, label)
|
|
16
|
+
* - Same archive cleanup (60 min default)
|
|
17
|
+
* - Same markTerminated pattern
|
|
18
|
+
*/
|
|
19
|
+
// ---------- constants (from OpenClaw subagent-registry.ts:46-59) ----------
|
|
20
|
+
/** Archive window — clean up completed records older than this */
|
|
21
|
+
const ARCHIVE_AFTER_MS = 60 * 60 * 1000; // 60 minutes
|
|
22
|
+
// ---------- module-level state ----------
|
|
23
|
+
const subagentRuns = new Map();
|
|
24
|
+
// ---------- registry functions ----------
|
|
25
|
+
/**
|
|
26
|
+
* Register a new subagent run in the registry.
|
|
27
|
+
* (OpenClaw: subagent-registry.ts:507-552)
|
|
28
|
+
*/
|
|
29
|
+
export function registerSubagentRun(record) {
|
|
30
|
+
subagentRuns.set(record.runId, record);
|
|
31
|
+
console.log(`[SUBAGENT-REGISTRY] Registered run ${record.runId}${record.label ? ` (${record.label})` : ""} — task: ${record.task.slice(0, 80)}`);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Mark a run as completed/failed/timeout with outcome details.
|
|
35
|
+
*/
|
|
36
|
+
export function completeRun(runId, result) {
|
|
37
|
+
const entry = subagentRuns.get(runId);
|
|
38
|
+
if (!entry) {
|
|
39
|
+
console.warn(`[SUBAGENT-REGISTRY] completeRun: run not found: ${runId}`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
entry.status = result.status;
|
|
43
|
+
entry.completedAt = Date.now();
|
|
44
|
+
entry.outcome = result.outcome;
|
|
45
|
+
entry.error = result.error;
|
|
46
|
+
entry.durationMs = result.durationMs;
|
|
47
|
+
entry.inputTokens = result.inputTokens;
|
|
48
|
+
entry.outputTokens = result.outputTokens;
|
|
49
|
+
console.log(`[SUBAGENT-REGISTRY] Run ${runId} ${result.status}${result.error ? `: ${result.error.slice(0, 100)}` : ""}`);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Count active (status === "running") runs for a requester session.
|
|
53
|
+
* (OpenClaw: subagent-registry.ts:766-782)
|
|
54
|
+
*/
|
|
55
|
+
export function countActiveRunsForSession(requesterSessionKey) {
|
|
56
|
+
const key = requesterSessionKey.trim();
|
|
57
|
+
if (!key)
|
|
58
|
+
return 0;
|
|
59
|
+
let count = 0;
|
|
60
|
+
for (const entry of subagentRuns.values()) {
|
|
61
|
+
if (entry.requesterSessionKey !== key)
|
|
62
|
+
continue;
|
|
63
|
+
if (entry.status === "running") {
|
|
64
|
+
count += 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return count;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* List all runs (active + recent) for a requester, sorted by startedAt desc.
|
|
71
|
+
* (OpenClaw: subagent-registry.ts:758-764)
|
|
72
|
+
*/
|
|
73
|
+
export function listRunsForRequester(requesterSessionKey) {
|
|
74
|
+
const key = requesterSessionKey.trim();
|
|
75
|
+
if (!key)
|
|
76
|
+
return [];
|
|
77
|
+
// Opportunistic cleanup
|
|
78
|
+
cleanupArchive();
|
|
79
|
+
return [...subagentRuns.values()]
|
|
80
|
+
.filter((entry) => entry.requesterSessionKey === key)
|
|
81
|
+
.sort((a, b) => b.startedAt - a.startedAt);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get a run by ID.
|
|
85
|
+
*/
|
|
86
|
+
export function getRunById(runId) {
|
|
87
|
+
return subagentRuns.get(runId);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve a target to a SubagentRunRecord.
|
|
91
|
+
* Accepts: 1-based index (from active list), runId prefix, or label.
|
|
92
|
+
* (Ported from OpenClaw subagents-tool.ts:130-150)
|
|
93
|
+
*/
|
|
94
|
+
export function resolveTarget(requesterSessionKey, target) {
|
|
95
|
+
const runs = listRunsForRequester(requesterSessionKey);
|
|
96
|
+
const activeRuns = runs.filter((r) => r.status === "running");
|
|
97
|
+
// Try "all" — special case handled by caller
|
|
98
|
+
if (target === "all" || target === "*") {
|
|
99
|
+
return undefined; // Caller handles "all"
|
|
100
|
+
}
|
|
101
|
+
// Try as 1-based index into active list
|
|
102
|
+
const index = Number(target);
|
|
103
|
+
if (Number.isInteger(index) && index >= 1 && index <= activeRuns.length) {
|
|
104
|
+
return activeRuns[index - 1];
|
|
105
|
+
}
|
|
106
|
+
// Try as runId prefix
|
|
107
|
+
const byRunId = runs.find((r) => r.runId.startsWith(target));
|
|
108
|
+
if (byRunId)
|
|
109
|
+
return byRunId;
|
|
110
|
+
// Try as label (case-insensitive, most recent first — already sorted)
|
|
111
|
+
const lowerTarget = target.toLowerCase();
|
|
112
|
+
const byLabel = runs.find((r) => r.label?.toLowerCase() === lowerTarget ||
|
|
113
|
+
r.label?.toLowerCase().startsWith(lowerTarget));
|
|
114
|
+
if (byLabel)
|
|
115
|
+
return byLabel;
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Kill a running subagent by aborting its AbortController.
|
|
120
|
+
* (OpenClaw: subagent-registry.ts:716-756 markSubagentRunTerminated)
|
|
121
|
+
*/
|
|
122
|
+
export function killRun(runId) {
|
|
123
|
+
const entry = subagentRuns.get(runId);
|
|
124
|
+
if (!entry)
|
|
125
|
+
return false;
|
|
126
|
+
if (entry.status !== "running")
|
|
127
|
+
return false;
|
|
128
|
+
entry.abortController.abort();
|
|
129
|
+
entry.status = "killed";
|
|
130
|
+
entry.completedAt = Date.now();
|
|
131
|
+
entry.durationMs = entry.completedAt - entry.startedAt;
|
|
132
|
+
entry.error = "killed";
|
|
133
|
+
console.log(`[SUBAGENT-REGISTRY] Killed run ${runId}${entry.label ? ` (${entry.label})` : ""}`);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Kill all active runs for a requester session.
|
|
138
|
+
* Returns count of killed runs and their labels.
|
|
139
|
+
*/
|
|
140
|
+
export function killAllForSession(requesterSessionKey) {
|
|
141
|
+
const runs = listRunsForRequester(requesterSessionKey);
|
|
142
|
+
const activeRuns = runs.filter((r) => r.status === "running");
|
|
143
|
+
const labels = [];
|
|
144
|
+
for (const run of activeRuns) {
|
|
145
|
+
killRun(run.runId);
|
|
146
|
+
labels.push(run.label || run.runId.slice(0, 8));
|
|
147
|
+
}
|
|
148
|
+
return { killed: activeRuns.length, labels };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Remove completed/failed/killed records older than ARCHIVE_AFTER_MS.
|
|
152
|
+
* Called opportunistically on list/spawn operations.
|
|
153
|
+
* (OpenClaw: sweeper pattern from subagent-registry.ts)
|
|
154
|
+
*/
|
|
155
|
+
export function cleanupArchive() {
|
|
156
|
+
const cutoff = Date.now() - ARCHIVE_AFTER_MS;
|
|
157
|
+
for (const [runId, entry] of subagentRuns) {
|
|
158
|
+
if (entry.status !== "running" && entry.completedAt && entry.completedAt < cutoff) {
|
|
159
|
+
subagentRuns.delete(runId);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Format duration in short human-readable form.
|
|
165
|
+
* (OpenClaw: subagent-announce.ts formatDurationShort)
|
|
166
|
+
*/
|
|
167
|
+
export function formatRunDuration(startedAt, completedAt) {
|
|
168
|
+
const endMs = completedAt ?? Date.now();
|
|
169
|
+
const ms = Math.max(0, endMs - startedAt);
|
|
170
|
+
const totalSeconds = Math.round(ms / 1000);
|
|
171
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
172
|
+
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
173
|
+
const seconds = totalSeconds % 60;
|
|
174
|
+
if (hours > 0)
|
|
175
|
+
return `${hours}h${minutes}m`;
|
|
176
|
+
if (minutes > 0)
|
|
177
|
+
return `${minutes}m${seconds}s`;
|
|
178
|
+
return `${seconds}s`;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/subagent/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAuBH,6EAA6E;AAE7E,kEAAkE;AAClE,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAA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GAAG,EAAE,GAAG,gBAAgB,CAAC;IAC7C,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,YAAY,EAAE,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,CAAC;YAClF,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAiB,EAAE,WAAoB;IACvE,MAAM,KAAK,GAAG,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IACxC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,YAAY,GAAG,EAAE,CAAC;IAClC,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,GAAG,KAAK,IAAI,OAAO,GAAG,CAAC;IAC7C,IAAI,OAAO,GAAG,CAAC;QAAE,OAAO,GAAG,OAAO,IAAI,OAAO,GAAG,CAAC;IACjD,OAAO,GAAG,OAAO,GAAG,CAAC;AACvB,CAAC"}
|
|
@@ -15,12 +15,12 @@ export type TurnSummary = {
|
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Get the last turn summary (called by heartbeat runner after the turn).
|
|
18
|
-
* Returns null if the LLM never called
|
|
18
|
+
* Returns null if the LLM never called complete_task.
|
|
19
19
|
*/
|
|
20
20
|
export declare function getLastTurnSummary(): TurnSummary | null;
|
|
21
21
|
/**
|
|
22
22
|
* Clear the turn summary (called before each new turn to reset state).
|
|
23
23
|
*/
|
|
24
24
|
export declare function clearTurnSummary(): void;
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function createCompleteTaskTool(): AnyAgentTool;
|
|
26
26
|
//# sourceMappingURL=complete-turn.d.ts.map
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { Type } from "@sinclair/typebox";
|
|
12
12
|
import { jsonResult } from "../utils/tool-helpers.js";
|
|
13
|
-
/** Stores the most recent
|
|
13
|
+
/** Stores the most recent complete_task call data */
|
|
14
14
|
let _lastTurnSummary = null;
|
|
15
15
|
/**
|
|
16
16
|
* Get the last turn summary (called by heartbeat runner after the turn).
|
|
17
|
-
* Returns null if the LLM never called
|
|
17
|
+
* Returns null if the LLM never called complete_task.
|
|
18
18
|
*/
|
|
19
19
|
export function getLastTurnSummary() {
|
|
20
20
|
return _lastTurnSummary;
|
|
@@ -28,7 +28,7 @@ export function clearTurnSummary() {
|
|
|
28
28
|
// ═══════════════════════════════════════════════════
|
|
29
29
|
// TOOL DEFINITION
|
|
30
30
|
// ═══════════════════════════════════════════════════
|
|
31
|
-
const
|
|
31
|
+
const CompleteTaskSchema = Type.Object({
|
|
32
32
|
title: Type.String({
|
|
33
33
|
description: "Short title (5-10 words) describing what you did. Example: 'Email check and Bitcoin price monitoring'",
|
|
34
34
|
}),
|
|
@@ -36,19 +36,19 @@ const CompleteTurnSchema = Type.Object({
|
|
|
36
36
|
description: "Thorough account of what happened — write naturally, like telling a colleague what happened while they were away. This is the only record of your work.",
|
|
37
37
|
}),
|
|
38
38
|
});
|
|
39
|
-
export function
|
|
39
|
+
export function createCompleteTaskTool() {
|
|
40
40
|
return {
|
|
41
|
-
label: "Complete
|
|
42
|
-
name: "
|
|
43
|
-
description: "Call this as your LAST tool call in every turn to log what you did. Provide a short title and a thorough summary. This is the only record of your work — stored for future recall
|
|
44
|
-
parameters:
|
|
41
|
+
label: "Complete Task",
|
|
42
|
+
name: "complete_task",
|
|
43
|
+
description: "Call this as your LAST tool call in every turn to log what you did. Provide a short title and a thorough summary. This is the only record of your work — stored for future recall. Write naturally, no technical terms.",
|
|
44
|
+
parameters: CompleteTaskSchema,
|
|
45
45
|
execute: async (_toolCallId, params) => {
|
|
46
46
|
const title = params.title?.trim() || "Untitled turn";
|
|
47
47
|
const summary = params.summary?.trim() || "No summary provided.";
|
|
48
48
|
// Store for the runner to pick up
|
|
49
49
|
_lastTurnSummary = { title, summary };
|
|
50
|
-
console.log(`[
|
|
51
|
-
console.log(`[
|
|
50
|
+
console.log(`[COMPLETE_TASK] Title: ${title}`);
|
|
51
|
+
console.log(`[COMPLETE_TASK] Summary: ${summary.slice(0, 200)}`);
|
|
52
52
|
return jsonResult({
|
|
53
53
|
status: "logged",
|
|
54
54
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"complete-turn.js","sourceRoot":"","sources":["../../src/tools/complete-turn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAWtD,qDAAqD;AACrD,IAAI,gBAAgB,GAAuB,IAAI,CAAC;AAEhD;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,sDAAsD;AACtD,kBAAkB;AAClB,sDAAsD;AAEtD,MAAM,kBAAkB,GAAG,IAAI,CAAC,MAAM,CAAC;IACrC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QACjB,WAAW,EACT,uGAAuG;KAC1G,CAAC;IACF,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC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AAkC;YAClC,gBAAgB,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;YAEtC,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,4BAA4B,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAEjE,OAAO,UAAU,CAAC;gBAChB,MAAM,EAAE,QAAQ;gBAChB,KAAK;gBACL,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,OAAO;aACxE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoStar Server Executor - Contacts Search Tool
|
|
3
|
+
*
|
|
4
|
+
* Search user's contacts via Asterizk API.
|
|
5
|
+
* Endpoint: POST /samantha/api/v1/contacts/search/{userEmail}
|
|
6
|
+
*
|
|
7
|
+
* Returns contacts with name, email, phone, WhatsApp JID.
|
|
8
|
+
* Use this tool BEFORE making phone calls or sending WhatsApp messages
|
|
9
|
+
* to get the correct phone number or JID.
|
|
10
|
+
*/
|
|
11
|
+
import type { AnyAgentTool } from "../types/tool.js";
|
|
12
|
+
export declare function createContactsSearchTool(): AnyAgentTool;
|
|
13
|
+
//# sourceMappingURL=contacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA6BrD,wBAAgB,wBAAwB,IAAI,YAAY,CA4DvD"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CoStar Server Executor - Contacts Search Tool
|
|
3
|
+
*
|
|
4
|
+
* Search user's contacts via Asterizk API.
|
|
5
|
+
* Endpoint: POST /samantha/api/v1/contacts/search/{userEmail}
|
|
6
|
+
*
|
|
7
|
+
* Returns contacts with name, email, phone, WhatsApp JID.
|
|
8
|
+
* Use this tool BEFORE making phone calls or sending WhatsApp messages
|
|
9
|
+
* to get the correct phone number or JID.
|
|
10
|
+
*/
|
|
11
|
+
import { Type } from "@sinclair/typebox";
|
|
12
|
+
import { jsonResult, readStringParam } from "../utils/tool-helpers.js";
|
|
13
|
+
import { getUserEmail, asterizkFetch, handleAsterizkApiError } from "../utils/asterizk-auth.js";
|
|
14
|
+
const ContactsSearchSchema = Type.Object({
|
|
15
|
+
q: Type.Optional(Type.String({ description: "General search query (searches across name, email, phone)." })),
|
|
16
|
+
name: Type.Optional(Type.String({ description: "Filter by contact name." })),
|
|
17
|
+
email: Type.Optional(Type.String({ description: "Filter by email address." })),
|
|
18
|
+
phone: Type.Optional(Type.String({ description: "Filter by phone number." })),
|
|
19
|
+
contact_type: Type.Optional(Type.Union([
|
|
20
|
+
Type.Literal("email"),
|
|
21
|
+
Type.Literal("whatsapp"),
|
|
22
|
+
Type.Literal("phonebook"),
|
|
23
|
+
], { description: "Filter by contact type. Optional." })),
|
|
24
|
+
});
|
|
25
|
+
export function createContactsSearchTool() {
|
|
26
|
+
return {
|
|
27
|
+
name: "contacts_search",
|
|
28
|
+
label: "Search Contacts",
|
|
29
|
+
description: "Search the user's contacts by name, email, phone number, or general query. Returns contact details including WhatsApp JID and phone numbers. Always search contacts before making calls or sending WhatsApp messages to get the correct number.",
|
|
30
|
+
parameters: ContactsSearchSchema,
|
|
31
|
+
execute: async (_toolCallId, params) => {
|
|
32
|
+
const q = readStringParam(params, "q");
|
|
33
|
+
const name = readStringParam(params, "name");
|
|
34
|
+
const email = readStringParam(params, "email");
|
|
35
|
+
const phone = readStringParam(params, "phone");
|
|
36
|
+
const contactType = readStringParam(params, "contact_type");
|
|
37
|
+
try {
|
|
38
|
+
const userEmail = getUserEmail();
|
|
39
|
+
console.log(`[CONTACTS] Searching contacts for ${userEmail} (q: "${q || name || email || phone}")`);
|
|
40
|
+
const body = {};
|
|
41
|
+
if (q)
|
|
42
|
+
body.q = q;
|
|
43
|
+
if (name)
|
|
44
|
+
body.name = name;
|
|
45
|
+
if (email)
|
|
46
|
+
body.email = email;
|
|
47
|
+
if (phone)
|
|
48
|
+
body.phone = phone;
|
|
49
|
+
if (contactType)
|
|
50
|
+
body.contact_type = contactType;
|
|
51
|
+
const response = await asterizkFetch(`/samantha/api/v1/contacts/search/${encodeURIComponent(userEmail)}`, { body });
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const errText = await response.text();
|
|
54
|
+
throw new Error(`Contacts search failed (${response.status}): ${errText}`);
|
|
55
|
+
}
|
|
56
|
+
const data = await response.json();
|
|
57
|
+
// Flatten grouped contacts for easier consumption
|
|
58
|
+
const contacts = Array.isArray(data) ? data : (data.contacts || data.results || []);
|
|
59
|
+
const flattened = contacts.map((c) => ({
|
|
60
|
+
name: c.name,
|
|
61
|
+
email: c.email || null,
|
|
62
|
+
phone: c.phone_number || c.phone || null,
|
|
63
|
+
whatsapp_jid: c.whatsapp_jid || null,
|
|
64
|
+
contact_type: c.contact_type || null,
|
|
65
|
+
}));
|
|
66
|
+
console.log(`[CONTACTS] Found ${flattened.length} contacts`);
|
|
67
|
+
return jsonResult({
|
|
68
|
+
query: q || name || email || phone || "(all)",
|
|
69
|
+
count: flattened.length,
|
|
70
|
+
contacts: flattened,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error(`[CONTACTS] Error:`, error);
|
|
75
|
+
return jsonResult(handleAsterizkApiError(error, "contacts_search"));
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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|
|
3
|
+
* Ported from OpenClaw's agents/tools/cron-tool.ts
|
|
4
|
+
*
|
|
5
|
+
* Differences from OpenClaw:
|
|
6
|
+
* - Uses Supabase-backed storage instead of gateway RPC
|
|
7
|
+
* - Flat schema (snake_case fields) instead of nested job/payload/schedule objects
|
|
8
|
+
* - No delivery system (CoStar uses agent.injectIsolatedResult instead)
|
|
9
|
+
* - No agentId/sessionKey per job (CoStar uses user_id with single agent)
|
|
10
|
+
* - No contextMessages (no gateway chat.history endpoint)
|
|
11
|
+
*
|
|
12
|
+
* Matched with OpenClaw:
|
|
13
|
+
* - Same actions: status, list, add, update, remove, run, runs, wake
|
|
14
|
+
* - Same schedule types: at, every, cron
|
|
15
|
+
* - Same session targets: main, isolated
|
|
16
|
+
* - Same wake modes: now, next-heartbeat
|
|
17
|
+
* - Same normalization (schedule coercion, field inference, defaults)
|
|
18
|
+
* - Same runMode (due/force) for manual triggers
|
|
19
|
+
* - Flat-params recovery for non-frontier models
|
|
5
20
|
*/
|
|
6
21
|
import type { AnyAgentTool } from "../types/tool.js";
|
|
7
22
|
export type CronToolDeps = {
|
package/dist/tools/cron.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/tools/cron.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"cron.d.ts","sourceRoot":"","sources":["../../src/tools/cron.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkDrD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,CAAC,EAAE,MAAM;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACxH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,GAAG,gBAAgB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACjF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnD,CAAC;AA2BF,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,CAgT/D"}
|