agentix-cli 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/{agent-LS4CZPJ6.js → agent-SPE7Q7MD.js} +2 -2
  2. package/dist/{board-dashboard-6QQCKFB3.js → board-dashboard-K4DM32SO.js} +2 -2
  3. package/dist/{chunk-LNWX4MPX.js → chunk-42DCRKUD.js} +130 -129
  4. package/dist/chunk-42DCRKUD.js.map +1 -0
  5. package/dist/chunk-45BLFNDG.js +170 -0
  6. package/dist/chunk-45BLFNDG.js.map +1 -0
  7. package/dist/{chunk-SBCZLZG3.js → chunk-AUNDQPDR.js} +2 -2
  8. package/dist/chunk-DWADWDMU.js +96 -0
  9. package/dist/chunk-DWADWDMU.js.map +1 -0
  10. package/dist/{chunk-3QVOWDHZ.js → chunk-EL3J74N2.js} +2 -2
  11. package/dist/{chunk-AE2LDMZU.js → chunk-GK7XAM3D.js} +2 -2
  12. package/dist/chunk-GK7XAM3D.js.map +1 -0
  13. package/dist/{chunk-OTXDKKEU.js → chunk-GUBMLV34.js} +134 -122
  14. package/dist/chunk-GUBMLV34.js.map +1 -0
  15. package/dist/{chunk-Z2Y24ETP.js → chunk-IVQO43U2.js} +2 -2
  16. package/dist/{chunk-F5AEXRPR.js → chunk-MGNJWBVP.js} +2 -2
  17. package/dist/{chunk-6F2IKJ2F.js → chunk-Q7CZIRBB.js} +2 -2
  18. package/dist/{chunk-UYSNGBDT.js → chunk-UU4WOZNR.js} +2 -2
  19. package/dist/{chunk-JIOLJIBM.js → chunk-V4HURNMX.js} +2 -2
  20. package/dist/cli.js +1 -1
  21. package/dist/cli.js.map +1 -1
  22. package/dist/index.d.ts +161 -155
  23. package/dist/index.js +1 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/program-DWZAI4GY.js +2 -0
  26. package/dist/query-3HXGBKGM.js +2 -0
  27. package/dist/registry-EJRWAJYG.js +2 -0
  28. package/dist/{request-planner-BKT6RZKX.js → request-planner-BCOXUAPA.js} +2 -2
  29. package/dist/{review-candidates-F3OFYTCZ.js → review-candidates-O2PS7L3B.js} +2 -2
  30. package/dist/routing-5K7PGHPL.js +2 -0
  31. package/dist/{seat-ZVHXNAEN.js → seat-FZRNRAHQ.js} +2 -2
  32. package/dist/{select-L7C52URW.js → select-SOJYFAMI.js} +2 -2
  33. package/dist/wiki-34XVI32N.js +2 -0
  34. package/dist/workspace-setup-G6KGWPHY.js +2 -0
  35. package/package.json +1 -1
  36. package/dist/chunk-67Q4DCPS.js +0 -54
  37. package/dist/chunk-67Q4DCPS.js.map +0 -1
  38. package/dist/chunk-AE2LDMZU.js.map +0 -1
  39. package/dist/chunk-I3SIXTJO.js +0 -44
  40. package/dist/chunk-I3SIXTJO.js.map +0 -1
  41. package/dist/chunk-LNWX4MPX.js.map +0 -1
  42. package/dist/chunk-OTXDKKEU.js.map +0 -1
  43. package/dist/chunk-XPXO5K4L.js +0 -164
  44. package/dist/chunk-XPXO5K4L.js.map +0 -1
  45. package/dist/program-I4J63BQ7.js +0 -2
  46. package/dist/query-R7EI3VGX.js +0 -2
  47. package/dist/registry-UJIJBLUR.js +0 -2
  48. package/dist/routing-S5WSFIAD.js +0 -2
  49. package/dist/wiki-5YQI4YKM.js +0 -2
  50. package/dist/workspace-setup-B3F3TUDE.js +0 -2
  51. /package/dist/{agent-LS4CZPJ6.js.map → agent-SPE7Q7MD.js.map} +0 -0
  52. /package/dist/{board-dashboard-6QQCKFB3.js.map → board-dashboard-K4DM32SO.js.map} +0 -0
  53. /package/dist/{chunk-SBCZLZG3.js.map → chunk-AUNDQPDR.js.map} +0 -0
  54. /package/dist/{chunk-3QVOWDHZ.js.map → chunk-EL3J74N2.js.map} +0 -0
  55. /package/dist/{chunk-Z2Y24ETP.js.map → chunk-IVQO43U2.js.map} +0 -0
  56. /package/dist/{chunk-F5AEXRPR.js.map → chunk-MGNJWBVP.js.map} +0 -0
  57. /package/dist/{chunk-6F2IKJ2F.js.map → chunk-Q7CZIRBB.js.map} +0 -0
  58. /package/dist/{chunk-UYSNGBDT.js.map → chunk-UU4WOZNR.js.map} +0 -0
  59. /package/dist/{chunk-JIOLJIBM.js.map → chunk-V4HURNMX.js.map} +0 -0
  60. /package/dist/{program-I4J63BQ7.js.map → program-DWZAI4GY.js.map} +0 -0
  61. /package/dist/{query-R7EI3VGX.js.map → query-3HXGBKGM.js.map} +0 -0
  62. /package/dist/{registry-UJIJBLUR.js.map → registry-EJRWAJYG.js.map} +0 -0
  63. /package/dist/{request-planner-BKT6RZKX.js.map → request-planner-BCOXUAPA.js.map} +0 -0
  64. /package/dist/{review-candidates-F3OFYTCZ.js.map → review-candidates-O2PS7L3B.js.map} +0 -0
  65. /package/dist/{routing-S5WSFIAD.js.map → routing-5K7PGHPL.js.map} +0 -0
  66. /package/dist/{seat-ZVHXNAEN.js.map → seat-FZRNRAHQ.js.map} +0 -0
  67. /package/dist/{select-L7C52URW.js.map → select-SOJYFAMI.js.map} +0 -0
  68. /package/dist/{wiki-5YQI4YKM.js.map → wiki-34XVI32N.js.map} +0 -0
  69. /package/dist/{workspace-setup-B3F3TUDE.js.map → workspace-setup-G6KGWPHY.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -6375,6 +6375,159 @@ interface FriendlyError {
6375
6375
  raw?: string;
6376
6376
  }
6377
6377
 
6378
+ /**
6379
+ * Verified channel context — facts the channel adapter knows for certain.
6380
+ * Prevents agents from hallucinating about their environment.
6381
+ */
6382
+ interface ChannelMeta {
6383
+ /** Channel name */
6384
+ channel: string;
6385
+ /** Verified agents/bots present in this chat/group/project */
6386
+ agents?: Array<{
6387
+ id: string;
6388
+ name: string;
6389
+ handle?: string;
6390
+ }>;
6391
+ /** Project path (GitLab) or group topic */
6392
+ project?: string;
6393
+ /** Issue/MR context (GitLab) */
6394
+ issue?: {
6395
+ type: string;
6396
+ iid: string;
6397
+ title: string;
6398
+ };
6399
+ /** Channel-specific facts (e.g., pipeline status, group description) */
6400
+ facts?: string[];
6401
+ }
6402
+ interface IncomingMessage {
6403
+ id: string;
6404
+ channel: string;
6405
+ accountId: string;
6406
+ sender: {
6407
+ id: string;
6408
+ name: string;
6409
+ username?: string;
6410
+ /** True when the origin is another bot account (Telegram `from.is_bot`).
6411
+ * Used by the router to apply strict @-mention-only routing — prevents
6412
+ * cross-daemon cascades from bare-word matches in bot replies. */
6413
+ isBot?: boolean;
6414
+ };
6415
+ group?: {
6416
+ id: string;
6417
+ name: string;
6418
+ };
6419
+ text: string;
6420
+ replyTo?: string;
6421
+ replyToText?: string;
6422
+ timestamp: Date;
6423
+ media?: {
6424
+ path: string;
6425
+ type: string;
6426
+ fileName?: string;
6427
+ };
6428
+ raw?: unknown;
6429
+ resolvedAgent?: string;
6430
+ preferNode?: string;
6431
+ channelMeta?: ChannelMeta;
6432
+ /** Correlator threaded by the workflow engine. When a workflow dispatches
6433
+ * an agent, this carries the run id through the pipeline so post:response
6434
+ * can re-enter the engine with `kind: agentResult` transitions. Opaque
6435
+ * everywhere outside src/workflows/. */
6436
+ workflowRunId?: string;
6437
+ /** Phase 1 / 6 — when set, identifies the intent-ledger decision row
6438
+ * this message corresponds to. The agent registry calls
6439
+ * `ledger.recordResolution(...)` when the dispatched task completes,
6440
+ * so Inv-ActiveTaskSafety's "decision in flight" check can clear.
6441
+ * Set by the channel adapter (gitlab, router) right after
6442
+ * recordGitLabTargetDispatch / recordRouterDispatch returns the
6443
+ * decision row. Undefined when the dispatch was deduped/halted by
6444
+ * the ledger (no resolution to write) or when the source is in
6445
+ * mode=off. */
6446
+ intentRef?: {
6447
+ eventId: string;
6448
+ decidedBy: string;
6449
+ };
6450
+ /** Path to the project root whose runbook (CLAUDE.md / AGENTS.md / etc.)
6451
+ * the agent should consult for this task. Set by the gitlab/github
6452
+ * adapters when a project rule resolves a `runbook:` path. The agent
6453
+ * registry reads the file set into the cacheable system prefix.
6454
+ * Undefined when no rule matched — agent uses its own workspace's
6455
+ * CLAUDE.md as before. */
6456
+ runbookPath?: string;
6457
+ /** Override list of files the registry should read from runbookPath.
6458
+ * Carried alongside the path so per-project customisation applies
6459
+ * without the registry re-reading the rule. */
6460
+ runbookFiles?: string[];
6461
+ }
6462
+ interface OutgoingMessage {
6463
+ channel: string;
6464
+ chatId: string;
6465
+ text: string;
6466
+ replyTo?: string;
6467
+ parseMode?: "markdown" | "html" | "plain";
6468
+ agentId?: string;
6469
+ poll?: {
6470
+ name: string;
6471
+ values: string[];
6472
+ selectableCount?: number;
6473
+ };
6474
+ media?: {
6475
+ type: "image" | "document" | "audio" | "video";
6476
+ url: string;
6477
+ caption?: string;
6478
+ mimetype?: string;
6479
+ fileName?: string;
6480
+ };
6481
+ /** URL inline buttons (Phase 1). Telegram renders an inline_keyboard;
6482
+ * channels without button support ignore them. */
6483
+ buttons?: Array<{
6484
+ label: string;
6485
+ url: string;
6486
+ }>;
6487
+ }
6488
+ interface ChannelAdapter {
6489
+ readonly name: string;
6490
+ /** Start polling or webhook listener */
6491
+ start(): Promise<void>;
6492
+ /** Stop the adapter gracefully */
6493
+ stop(): Promise<void>;
6494
+ /** Send a message back to a chat */
6495
+ send(msg: OutgoingMessage): Promise<string | void>;
6496
+ /** Edit an existing message (returns false if not supported) */
6497
+ editMessage?(chatId: string, messageId: string, text: string, parseMode?: string): Promise<boolean>;
6498
+ /** Send typing/action indicator */
6499
+ sendTyping?(chatId: string): Promise<void>;
6500
+ /** React to a message with an emoji (e.g., 👀 for seen) */
6501
+ react?(chatId: string, messageId: string, emoji?: string): Promise<void>;
6502
+ /** Register handler for incoming messages */
6503
+ onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
6504
+ /** Get verified context for a chat (optional — channels implement what they can) */
6505
+ getChannelMeta?(chatId: string): Promise<ChannelMeta | undefined>;
6506
+ /** Fetch the most recent messages from the live channel for cold-start
6507
+ * session seeding. Called once per (agent, channel, chatId, day) when a
6508
+ * fresh session is created — never on warm cache hits. Bounded by
6509
+ * maxMessages and maxChars (enforced by the caller). Channels return their
6510
+ * own externalId so SessionStore can dedup against re-seeds. */
6511
+ seedHistory?(chatId: string, opts: {
6512
+ sinceISO?: string;
6513
+ maxMessages: number;
6514
+ maxChars: number;
6515
+ }): Promise<Array<SeededMessage>>;
6516
+ }
6517
+ /** A message returned by seedHistory — flat, channel-agnostic. */
6518
+ interface SeededMessage {
6519
+ role: "user" | "agent";
6520
+ name: string;
6521
+ content: string;
6522
+ timestamp: string;
6523
+ externalId?: string;
6524
+ /** Optional channel-side account/bot identity that handled this message
6525
+ * (e.g., Telegram accountId "acme_cx_bot"). Captured by adapters that
6526
+ * shadow-log outbound, so seeded history preserves the audit trail of
6527
+ * which bot identity actually sent each line. Renderers may ignore it. */
6528
+ accountId?: string;
6529
+ }
6530
+
6378
6531
  interface AgentPeer {
6379
6532
  id: string;
6380
6533
  name: string;
@@ -6439,6 +6592,10 @@ interface AgentTask {
6439
6592
  * that pattern without requiring callers to invent unique
6440
6593
  * chatIds. */
6441
6594
  freshSession?: boolean;
6595
+ /** Transcript held by a client that owns the conversation (OpenCode).
6596
+ * Seeds an empty AgentX session the same way a channel adapter's
6597
+ * seedHistory does, so a new or rotated session starts with it. */
6598
+ seedHistory?: SeededMessage[];
6442
6599
  context?: {
6443
6600
  channel?: string;
6444
6601
  sender?: string;
@@ -6645,159 +6802,6 @@ declare class MemoryStore {
6645
6802
  prune(agentId: string): void;
6646
6803
  }
6647
6804
 
6648
- /**
6649
- * Verified channel context — facts the channel adapter knows for certain.
6650
- * Prevents agents from hallucinating about their environment.
6651
- */
6652
- interface ChannelMeta {
6653
- /** Channel name */
6654
- channel: string;
6655
- /** Verified agents/bots present in this chat/group/project */
6656
- agents?: Array<{
6657
- id: string;
6658
- name: string;
6659
- handle?: string;
6660
- }>;
6661
- /** Project path (GitLab) or group topic */
6662
- project?: string;
6663
- /** Issue/MR context (GitLab) */
6664
- issue?: {
6665
- type: string;
6666
- iid: string;
6667
- title: string;
6668
- };
6669
- /** Channel-specific facts (e.g., pipeline status, group description) */
6670
- facts?: string[];
6671
- }
6672
- interface IncomingMessage {
6673
- id: string;
6674
- channel: string;
6675
- accountId: string;
6676
- sender: {
6677
- id: string;
6678
- name: string;
6679
- username?: string;
6680
- /** True when the origin is another bot account (Telegram `from.is_bot`).
6681
- * Used by the router to apply strict @-mention-only routing — prevents
6682
- * cross-daemon cascades from bare-word matches in bot replies. */
6683
- isBot?: boolean;
6684
- };
6685
- group?: {
6686
- id: string;
6687
- name: string;
6688
- };
6689
- text: string;
6690
- replyTo?: string;
6691
- replyToText?: string;
6692
- timestamp: Date;
6693
- media?: {
6694
- path: string;
6695
- type: string;
6696
- fileName?: string;
6697
- };
6698
- raw?: unknown;
6699
- resolvedAgent?: string;
6700
- preferNode?: string;
6701
- channelMeta?: ChannelMeta;
6702
- /** Correlator threaded by the workflow engine. When a workflow dispatches
6703
- * an agent, this carries the run id through the pipeline so post:response
6704
- * can re-enter the engine with `kind: agentResult` transitions. Opaque
6705
- * everywhere outside src/workflows/. */
6706
- workflowRunId?: string;
6707
- /** Phase 1 / 6 — when set, identifies the intent-ledger decision row
6708
- * this message corresponds to. The agent registry calls
6709
- * `ledger.recordResolution(...)` when the dispatched task completes,
6710
- * so Inv-ActiveTaskSafety's "decision in flight" check can clear.
6711
- * Set by the channel adapter (gitlab, router) right after
6712
- * recordGitLabTargetDispatch / recordRouterDispatch returns the
6713
- * decision row. Undefined when the dispatch was deduped/halted by
6714
- * the ledger (no resolution to write) or when the source is in
6715
- * mode=off. */
6716
- intentRef?: {
6717
- eventId: string;
6718
- decidedBy: string;
6719
- };
6720
- /** Path to the project root whose runbook (CLAUDE.md / AGENTS.md / etc.)
6721
- * the agent should consult for this task. Set by the gitlab/github
6722
- * adapters when a project rule resolves a `runbook:` path. The agent
6723
- * registry reads the file set into the cacheable system prefix.
6724
- * Undefined when no rule matched — agent uses its own workspace's
6725
- * CLAUDE.md as before. */
6726
- runbookPath?: string;
6727
- /** Override list of files the registry should read from runbookPath.
6728
- * Carried alongside the path so per-project customisation applies
6729
- * without the registry re-reading the rule. */
6730
- runbookFiles?: string[];
6731
- }
6732
- interface OutgoingMessage {
6733
- channel: string;
6734
- chatId: string;
6735
- text: string;
6736
- replyTo?: string;
6737
- parseMode?: "markdown" | "html" | "plain";
6738
- agentId?: string;
6739
- poll?: {
6740
- name: string;
6741
- values: string[];
6742
- selectableCount?: number;
6743
- };
6744
- media?: {
6745
- type: "image" | "document" | "audio" | "video";
6746
- url: string;
6747
- caption?: string;
6748
- mimetype?: string;
6749
- fileName?: string;
6750
- };
6751
- /** URL inline buttons (Phase 1). Telegram renders an inline_keyboard;
6752
- * channels without button support ignore them. */
6753
- buttons?: Array<{
6754
- label: string;
6755
- url: string;
6756
- }>;
6757
- }
6758
- interface ChannelAdapter {
6759
- readonly name: string;
6760
- /** Start polling or webhook listener */
6761
- start(): Promise<void>;
6762
- /** Stop the adapter gracefully */
6763
- stop(): Promise<void>;
6764
- /** Send a message back to a chat */
6765
- send(msg: OutgoingMessage): Promise<string | void>;
6766
- /** Edit an existing message (returns false if not supported) */
6767
- editMessage?(chatId: string, messageId: string, text: string, parseMode?: string): Promise<boolean>;
6768
- /** Send typing/action indicator */
6769
- sendTyping?(chatId: string): Promise<void>;
6770
- /** React to a message with an emoji (e.g., 👀 for seen) */
6771
- react?(chatId: string, messageId: string, emoji?: string): Promise<void>;
6772
- /** Register handler for incoming messages */
6773
- onMessage(handler: (msg: IncomingMessage) => Promise<void>): void;
6774
- /** Get verified context for a chat (optional — channels implement what they can) */
6775
- getChannelMeta?(chatId: string): Promise<ChannelMeta | undefined>;
6776
- /** Fetch the most recent messages from the live channel for cold-start
6777
- * session seeding. Called once per (agent, channel, chatId, day) when a
6778
- * fresh session is created — never on warm cache hits. Bounded by
6779
- * maxMessages and maxChars (enforced by the caller). Channels return their
6780
- * own externalId so SessionStore can dedup against re-seeds. */
6781
- seedHistory?(chatId: string, opts: {
6782
- sinceISO?: string;
6783
- maxMessages: number;
6784
- maxChars: number;
6785
- }): Promise<Array<SeededMessage>>;
6786
- }
6787
- /** A message returned by seedHistory — flat, channel-agnostic. */
6788
- interface SeededMessage {
6789
- role: "user" | "agent";
6790
- name: string;
6791
- content: string;
6792
- timestamp: string;
6793
- externalId?: string;
6794
- /** Optional channel-side account/bot identity that handled this message
6795
- * (e.g., Telegram accountId "acme_cx_bot"). Captured by adapters that
6796
- * shadow-log outbound, so seeded history preserves the audit trail of
6797
- * which bot identity actually sent each line. Renderers may ignore it. */
6798
- accountId?: string;
6799
- }
6800
-
6801
6805
  interface SessionMessage {
6802
6806
  role: "user" | "agent";
6803
6807
  name?: string;
@@ -6880,10 +6884,12 @@ declare class SessionStore {
6880
6884
  * - the session already has messages (warm cache or partially loaded)
6881
6885
  * - no adapter resolver is installed
6882
6886
  * - the channel adapter has no seedHistory method
6887
+ * Caller-supplied seeds (from a client that owns the transcript, such
6888
+ * as OpenCode) take the adapter's place.
6883
6889
  * Concurrent calls against the same key share one in-flight promise so
6884
6890
  * the channel API is hit exactly once per cold create. Errors are
6885
6891
  * swallowed — a seeding failure should never block a turn. */
6886
- seedIfEmpty(agentId: string, channel: string, chatId: string): Promise<void>;
6892
+ seedIfEmpty(agentId: string, channel: string, chatId: string, callerSeeds?: SeededMessage[]): Promise<void>;
6887
6893
  /** Append seeded messages to a session in chronological order, deduping
6888
6894
  * by externalId against anything already present. Marks each entry with
6889
6895
  * `seeded: true` so observers can distinguish them; the model's prompt
@@ -8493,7 +8499,7 @@ declare class AgentRegistry {
8493
8499
  byChannel: Record<string, {
8494
8500
  tasks: number;
8495
8501
  cost: number;
8496
- }>;
8502
+ }>; /** Runtime handover store — shared with MessageRouter via file on disk. */
8497
8503
  sessionStats: Record<string, {
8498
8504
  sessions: number;
8499
8505
  avgTasksPerSession: number;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as L}from"./chunk-W5C2GDNC.js";import{B as bt,C as Tt,D as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt}from"./chunk-OTXDKKEU.js";import"./chunk-F6CNF7V3.js";import"./chunk-3QVOWDHZ.js";import"./chunk-IWMW5432.js";import"./chunk-ZVP6GB4G.js";import{H as yt,f as lt,g as ct,h as dt,i as mt,j as pt}from"./chunk-XPXO5K4L.js";import"./chunk-Z2Y24ETP.js";import"./chunk-4BR7D2OU.js";import"./chunk-M4AMWP3H.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-UYSNGBDT.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-3SCPRYJB.js";import"./chunk-I3SIXTJO.js";import"./chunk-67Q4DCPS.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import{h as ut}from"./chunk-4KXBUORV.js";import"./chunk-SC5DIKBB.js";import"./chunk-AE2LDMZU.js";import"./chunk-77OV7346.js";import"./chunk-VWTBHLMX.js";import{a as gt,b as ft,e as ht}from"./chunk-SBCZLZG3.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-JIOLJIBM.js";import"./chunk-AJ5RMU7X.js";import"./chunk-EVWEG3VD.js";import{j as it,k as rt,l as at}from"./chunk-F5AEXRPR.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-QOYAX2FT.js";import"./chunk-WPMX3VGI.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-LCIREYTD.js";import{a as m,b as G}from"./chunk-L2WSPY6S.js";import{a as Fe,b as Le,c as A,d as De}from"./chunk-VDMYBPYB.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{e as tt,g as st,h as ot,j as nt}from"./chunk-GMNKJXTR.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
1
+ import{a as L}from"./chunk-W5C2GDNC.js";import{B as bt,C as Tt,D as Mt,a as St,b as kt,c as vt,d as xt,e as $t,f as Ct,g as Pt}from"./chunk-GUBMLV34.js";import"./chunk-F6CNF7V3.js";import"./chunk-EL3J74N2.js";import"./chunk-IWMW5432.js";import"./chunk-ZVP6GB4G.js";import{J as yt,h as lt,i as ct,j as dt,k as mt,l as pt}from"./chunk-45BLFNDG.js";import"./chunk-IVQO43U2.js";import"./chunk-4BR7D2OU.js";import"./chunk-M4AMWP3H.js";import{h as ut}from"./chunk-4KXBUORV.js";import{A as D,B as z,C as V,a as ye,b as we,c as Se,d as Ae,e as Ie,f as Oe,g as Ne,h as He,i as je,j as Ue,k as _e,l as I,m as q,n as Be,o as qe,p as Ye,q as O,r as ze,s as Ve,t as Xe,u as x,v as Y,w as Qe,x as Ze,y as et,z as wt}from"./chunk-UU4WOZNR.js";import{a as B,b as M,c as F}from"./chunk-SFQUP3BP.js";import"./chunk-3SCPRYJB.js";import"./chunk-WPMX3VGI.js";import"./chunk-K33GIBSE.js";import"./chunk-76Z4VHDX.js";import"./chunk-W4YR2RO2.js";import"./chunk-AFRHKA7B.js";import"./chunk-SC5DIKBB.js";import"./chunk-GK7XAM3D.js";import"./chunk-DWADWDMU.js";import"./chunk-77OV7346.js";import"./chunk-VWTBHLMX.js";import{a as gt,b as ft,e as ht}from"./chunk-AUNDQPDR.js";import"./chunk-PNWNVOEZ.js";import"./chunk-64P4QHSZ.js";import"./chunk-V4HURNMX.js";import"./chunk-AJ5RMU7X.js";import"./chunk-EVWEG3VD.js";import{j as it,k as rt,l as at}from"./chunk-MGNJWBVP.js";import"./chunk-ZTEU5JVQ.js";import"./chunk-AJONZWLT.js";import"./chunk-F4HZTZHW.js";import"./chunk-QOYAX2FT.js";import{a as ke,b as ve,c as xe,d as $e,e as Ce,f as Pe,g as be,h as Te,i as Me,j as Re,l as Ee,m as Ge,o as T,p as W}from"./chunk-LCIREYTD.js";import{a as m,b as G}from"./chunk-L2WSPY6S.js";import{a as Fe,b as Le,c as A,d as De}from"./chunk-VDMYBPYB.js";import{a as Ke,b as Je,e as We}from"./chunk-DSYKYZMT.js";import{e as tt,g as st,h as ot,j as nt}from"./chunk-GMNKJXTR.js";import"./chunk-BH3GTCZ6.js";import"./chunk-FIOB3MEX.js";W();G();import{execa as Rt}from"execa";import{existsSync as se,promises as X}from"fs";import S from"path";import ie from"node-fetch";async function Et(o,e){let t=o.split("/");if(t.length<2)throw new Error(`Invalid skill package ID: ${o}. Expected format: owner/repo`);let s=t[0],i=t[1],n=t[2];try{let a=n?`${s}/${i}/${n}`:`${s}/${i}`;await Rt("npx",["-y","skills","add",a],{cwd:e,stdio:"pipe"}),m.success(`Installed skill package: ${o}`);let r=S.resolve(e,".skills",`${s}_${i}`);if(se(r))return await ne(r,o);let d=S.resolve(e,".skills");return se(d)?await ne(d,o):[]}catch{return m.info(`Fetching skills directly from GitHub: ${s}/${i}`),await Gt(s,i,n,e)}}async function Gt(o,e,t,s){let i=[];try{let n=`https://api.github.com/repos/${o}/${e}/git/trees/main?recursive=1`,a=await ie(n);if(!a.ok)throw new Error(`GitHub API error: ${a.status}`);let d=(await a.json()).tree.filter(p=>p.type==="blob"&&p.path.endsWith("SKILL.md"));if(t){let p=d.find(f=>f.path.includes(`/${t}/`)||f.path===`${t}/SKILL.md`);if(p){let f=await oe(o,e,p.path,s);f&&i.push(f)}}else for(let p of d){let f=await oe(o,e,p.path,s);f&&i.push(f)}}catch(n){m.error(`Failed to fetch skills from GitHub: ${n.message}`)}return i}async function oe(o,e,t,s){try{let i=`https://raw.githubusercontent.com/${o}/${e}/main/${t}`,n=await ie(i);if(!n.ok)return null;let a=await n.text(),r=A(a);if(r){r.source="remote",r.packageId=`${o}/${e}`;let d=S.dirname(t),p=S.resolve(s,".skills",`${o}_${e}`,d);await X.mkdir(p,{recursive:!0}),await X.writeFile(S.resolve(p,"SKILL.md"),a),r.path=S.resolve(p,"SKILL.md")}return r}catch{return null}}async function ne(o,e){let t=[],{default:s}=await import("fast-glob"),i=await s.glob("**/SKILL.md",{cwd:o,deep:5});for(let n of i)try{let a=S.resolve(o,n),r=await X.readFile(a,"utf8"),d=A(r);d&&(d.source="remote",d.path=a,d.packageId=e,t.push(d))}catch{}return t}async function At(o,e,t,s,i){let n=["---",`name: ${o}`,`description: ${e}`];if(s?.length){n.push("tags:");for(let a of s)n.push(` - ${a}`)}if(i?.length){n.push("globs:");for(let a of i)n.push(` - ${a}`)}return n.push("---"),`${n.join(`
2
2
  `)}
3
3
 
4
4
  ${t}`}async function It(o){let{loadLocalSkills:e}=await import("./loader-BOKE5M5S.js");return e(o)}async function Ot(o,e,t,s,i){let a=[{role:"system",content:`You are a skill author for the Agent Skills ecosystem (skills.sh).