@serviceme/devtools-cli 0.1.7 → 0.1.9

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.
@@ -8751,7 +8751,7 @@ var require_yauzl = __commonJS({
8751
8751
  var Transform = require("stream").Transform;
8752
8752
  var PassThrough = require("stream").PassThrough;
8753
8753
  var Writable = require("stream").Writable;
8754
- exports2.open = open2;
8754
+ exports2.open = open;
8755
8755
  exports2.fromFd = fromFd;
8756
8756
  exports2.fromBuffer = fromBuffer;
8757
8757
  exports2.fromRandomAccessReader = fromRandomAccessReader;
@@ -8763,7 +8763,7 @@ var require_yauzl = __commonJS({
8763
8763
  exports2.Entry = Entry;
8764
8764
  exports2.LocalFileHeader = LocalFileHeader;
8765
8765
  exports2.RandomAccessReader = RandomAccessReader;
8766
- function open2(path12, options2, callback) {
8766
+ function open(path12, options2, callback) {
8767
8767
  if (typeof options2 === "function") {
8768
8768
  callback = options2;
8769
8769
  options2 = null;
@@ -9638,7 +9638,7 @@ function normalizeServicemeError(error, fallbackCode = "internal_error") {
9638
9638
  }
9639
9639
 
9640
9640
  // src/version.ts
9641
- var SERVICEME_CLI_VERSION = "0.1.7";
9641
+ var SERVICEME_CLI_VERSION = "0.1.9";
9642
9642
 
9643
9643
  // src/bridge/AgentBridgeHandler.ts
9644
9644
  var fs12 = __toESM(require("fs/promises"));
@@ -9653,10 +9653,10 @@ var AgentCatalogClient = class {
9653
9653
  }
9654
9654
  async getCatalog() {
9655
9655
  if (!this.baseUrl) {
9656
- return {
9657
- agents: [],
9658
- fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
9659
- };
9656
+ throw createServicemeError(
9657
+ "workspace_not_found",
9658
+ "Agent catalog baseUrl is not configured."
9659
+ );
9660
9660
  }
9661
9661
  const response = await this.fetchImpl(
9662
9662
  `${this.baseUrl}/api/v1/marketplace/agents`
@@ -10211,10 +10211,8 @@ var GithubCopilotCliExecutor = class {
10211
10211
  windowsHide: true
10212
10212
  });
10213
10213
  if (child.pid) {
10214
- writeDiagnostic(
10215
- `[GithubCopilotCliExecutor] spawned child PID=${child.pid}
10216
- `
10217
- );
10214
+ writeDiagnostic(`[GithubCopilotCliExecutor] spawned child PID=${child.pid}
10215
+ `);
10218
10216
  }
10219
10217
  const timeoutMs = execution.timeoutMs;
10220
10218
  const timer = timeoutMs != null ? setTimeout(() => {
@@ -10232,15 +10230,13 @@ var GithubCopilotCliExecutor = class {
10232
10230
  child.stdout.on("data", (chunk) => {
10233
10231
  const data = chunk.toString();
10234
10232
  stdoutBuf += data;
10235
- if (stdoutBuf.length > MAX_OUTPUT_BYTES)
10236
- stdoutBuf = stdoutBuf.slice(-MAX_OUTPUT_BYTES);
10233
+ if (stdoutBuf.length > MAX_OUTPUT_BYTES) stdoutBuf = stdoutBuf.slice(-MAX_OUTPUT_BYTES);
10237
10234
  onOutput("stdout", data);
10238
10235
  });
10239
10236
  child.stderr.on("data", (chunk) => {
10240
10237
  const data = chunk.toString();
10241
10238
  stderrBuf += data;
10242
- if (stderrBuf.length > MAX_OUTPUT_BYTES)
10243
- stderrBuf = stderrBuf.slice(-MAX_OUTPUT_BYTES);
10239
+ if (stderrBuf.length > MAX_OUTPUT_BYTES) stderrBuf = stderrBuf.slice(-MAX_OUTPUT_BYTES);
10244
10240
  onOutput("stderr", data);
10245
10241
  });
10246
10242
  child.on("close", (code) => {
@@ -10563,10 +10559,7 @@ function isRecord3(value) {
10563
10559
  }
10564
10560
  function requireNonEmptyString(payload, field, taskType) {
10565
10561
  if (!isRecord3(payload) || typeof payload[field] !== "string" || !payload[field].trim()) {
10566
- throw createServicemeError(
10567
- "invalid_payload",
10568
- `${taskType} payload ${field} is required`
10569
- );
10562
+ throw createServicemeError("invalid_payload", `${taskType} payload ${field} is required`);
10570
10563
  }
10571
10564
  }
10572
10565
  function validateTaskPayload(taskType, payload) {
@@ -10626,9 +10619,7 @@ var TaskExecutionEngine = class {
10626
10619
  if (policy === "reject") {
10627
10620
  const existingIds = this.taskExecutions.get(snapshot.taskId);
10628
10621
  if (existingIds && existingIds.size > 0) {
10629
- throw new Error(
10630
- `TASK_ALREADY_RUNNING: Task ${snapshot.taskId} is already running`
10631
- );
10622
+ throw new Error(`TASK_ALREADY_RUNNING: Task ${snapshot.taskId} is already running`);
10632
10623
  }
10633
10624
  }
10634
10625
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -10787,10 +10778,10 @@ var SkillCatalogClient = class {
10787
10778
  }
10788
10779
  async getCatalog() {
10789
10780
  if (!this.baseUrl) {
10790
- return {
10791
- skills: [],
10792
- fetchedAt: (/* @__PURE__ */ new Date()).toISOString()
10793
- };
10781
+ throw createServicemeError(
10782
+ "workspace_not_found",
10783
+ "Skill catalog baseUrl is not configured."
10784
+ );
10794
10785
  }
10795
10786
  const response = await this.fetchImpl(
10796
10787
  `${this.baseUrl}/api/v1/marketplace/skills`
@@ -10982,6 +10973,16 @@ var SkillStore = class {
10982
10973
  }
10983
10974
  };
10984
10975
 
10976
+ // src/bridge/marketplaceEnv.ts
10977
+ var SERVICEME_MARKETPLACE_BASE_URL_ENV = "SERVICEME_MARKETPLACE_BASE_URL";
10978
+ function readMarketplaceBaseUrl() {
10979
+ const raw = process.env[SERVICEME_MARKETPLACE_BASE_URL_ENV];
10980
+ if (typeof raw !== "string" || raw.length === 0) {
10981
+ return void 0;
10982
+ }
10983
+ return raw;
10984
+ }
10985
+
10985
10986
  // src/bridge/AgentBridgeHandler.ts
10986
10987
  function normalizeAgentIdOrThrow(store, remoteId) {
10987
10988
  try {
@@ -11025,10 +11026,7 @@ var AgentBridgeHandler = class {
11025
11026
  context.workspacePath,
11026
11027
  context.store.getWorkspaceAgentsRootPath(),
11027
11028
  `${agentId}.agent.md`
11028
- ) : path10.join(
11029
- context.store.getUserAgentsRootPath(),
11030
- `${agentId}.agent.md`
11031
- ) : void 0,
11029
+ ) : path10.join(context.store.getUserAgentsRootPath(), `${agentId}.agent.md`) : void 0,
11032
11030
  canPublish: agent.canPublish,
11033
11031
  workspaceState: this.makeScopeState(
11034
11032
  "workspace",
@@ -11042,10 +11040,7 @@ var AgentBridgeHandler = class {
11042
11040
  userState: this.makeScopeState(
11043
11041
  "user",
11044
11042
  userInstalled,
11045
- path10.join(
11046
- context.store.getUserAgentsRootPath(),
11047
- `${agentId}.agent.md`
11048
- )
11043
+ path10.join(context.store.getUserAgentsRootPath(), `${agentId}.agent.md`)
11049
11044
  )
11050
11045
  });
11051
11046
  }
@@ -11082,10 +11077,7 @@ var AgentBridgeHandler = class {
11082
11077
  userState: this.makeScopeState(
11083
11078
  "user",
11084
11079
  userSet.has(agentId),
11085
- path10.join(
11086
- context.store.getUserAgentsRootPath(),
11087
- `${agentId}.agent.md`
11088
- )
11080
+ path10.join(context.store.getUserAgentsRootPath(), `${agentId}.agent.md`)
11089
11081
  )
11090
11082
  });
11091
11083
  }
@@ -11105,10 +11097,7 @@ var AgentBridgeHandler = class {
11105
11097
  hasConflict: false,
11106
11098
  tools: [],
11107
11099
  source: "local",
11108
- localAgentPath: path10.join(
11109
- context.store.getUserAgentsRootPath(),
11110
- `${agentId}.agent.md`
11111
- ),
11100
+ localAgentPath: path10.join(context.store.getUserAgentsRootPath(), `${agentId}.agent.md`),
11112
11101
  workspaceState: this.makeScopeState(
11113
11102
  "workspace",
11114
11103
  workspaceSet.has(agentId),
@@ -11121,18 +11110,12 @@ var AgentBridgeHandler = class {
11121
11110
  userState: this.makeScopeState(
11122
11111
  "user",
11123
11112
  true,
11124
- path10.join(
11125
- context.store.getUserAgentsRootPath(),
11126
- `${agentId}.agent.md`
11127
- )
11113
+ path10.join(context.store.getUserAgentsRootPath(), `${agentId}.agent.md`)
11128
11114
  )
11129
11115
  });
11130
11116
  }
11131
11117
  return {
11132
- configPath: path10.join(
11133
- context.workspacePath,
11134
- context.store.getWorkspaceStateFilePath()
11135
- ),
11118
+ configPath: path10.join(context.workspacePath, context.store.getWorkspaceStateFilePath()),
11136
11119
  userAgentsPath: context.userAgentsRoot,
11137
11120
  agents: [...byId.values()].sort((a, b) => a.id.localeCompare(b.id)),
11138
11121
  installedAgentIds: [.../* @__PURE__ */ new Set([...workspaceAgentIds, ...userAgentIds])],
@@ -11179,7 +11162,10 @@ var AgentBridgeHandler = class {
11179
11162
  workspacePath: resolvedWorkspacePath,
11180
11163
  userAgentsRoot
11181
11164
  });
11182
- const catalogClient = new AgentCatalogClient();
11165
+ const marketplaceBaseUrl = readMarketplaceBaseUrl();
11166
+ const catalogClient = new AgentCatalogClient(
11167
+ marketplaceBaseUrl ? { baseUrl: marketplaceBaseUrl } : {}
11168
+ );
11183
11169
  const reconciler = new AgentReconciler({
11184
11170
  agentStore: store,
11185
11171
  catalogClient
@@ -11277,10 +11263,7 @@ tools:
11277
11263
  );
11278
11264
  }
11279
11265
  async readAgentContent(context, agentId, scope) {
11280
- const root = scope === "workspace" ? path10.join(
11281
- context.workspacePath,
11282
- context.store.getWorkspaceAgentsRootPath()
11283
- ) : context.store.getUserAgentsRootPath();
11266
+ const root = scope === "workspace" ? path10.join(context.workspacePath, context.store.getWorkspaceAgentsRootPath()) : context.store.getUserAgentsRootPath();
11284
11267
  const candidates = [
11285
11268
  path10.join(root, `${agentId}.agent.md`),
11286
11269
  path10.join(root, agentId, `${agentId}.agent.md`)
@@ -11351,18 +11334,12 @@ var SkillBridgeHandler = class {
11351
11334
  hasScripts: skill.hasScripts,
11352
11335
  hasHooks: skill.hasHooks,
11353
11336
  source: skill.source,
11354
- localSkillPath: workspaceInstalled || userInstalled ? workspaceInstalled ? path11.join(
11355
- context.workspacePath,
11356
- context.store.getWorkspaceSkillPath(skillId)
11357
- ) : context.store.getUserSkillPath(skillId) : void 0,
11337
+ localSkillPath: workspaceInstalled || userInstalled ? workspaceInstalled ? path11.join(context.workspacePath, context.store.getWorkspaceSkillPath(skillId)) : context.store.getUserSkillPath(skillId) : void 0,
11358
11338
  canPublish: skill.canPublish,
11359
11339
  workspaceState: this.makeScopeState(
11360
11340
  "workspace",
11361
11341
  workspaceInstalled,
11362
- path11.join(
11363
- context.workspacePath,
11364
- context.store.getWorkspaceSkillPath(skillId)
11365
- )
11342
+ path11.join(context.workspacePath, context.store.getWorkspaceSkillPath(skillId))
11366
11343
  ),
11367
11344
  userState: this.makeScopeState(
11368
11345
  "user",
@@ -11393,10 +11370,7 @@ var SkillBridgeHandler = class {
11393
11370
  workspaceState: this.makeScopeState(
11394
11371
  "workspace",
11395
11372
  true,
11396
- path11.join(
11397
- context.workspacePath,
11398
- context.store.getWorkspaceSkillPath(skillId)
11399
- )
11373
+ path11.join(context.workspacePath, context.store.getWorkspaceSkillPath(skillId))
11400
11374
  ),
11401
11375
  userState: this.makeScopeState(
11402
11376
  "user",
@@ -11424,23 +11398,13 @@ var SkillBridgeHandler = class {
11424
11398
  workspaceState: this.makeScopeState(
11425
11399
  "workspace",
11426
11400
  workspaceSet.has(skillId),
11427
- path11.join(
11428
- context.workspacePath,
11429
- context.store.getWorkspaceSkillPath(skillId)
11430
- )
11401
+ path11.join(context.workspacePath, context.store.getWorkspaceSkillPath(skillId))
11431
11402
  ),
11432
- userState: this.makeScopeState(
11433
- "user",
11434
- true,
11435
- context.store.getUserSkillPath(skillId)
11436
- )
11403
+ userState: this.makeScopeState("user", true, context.store.getUserSkillPath(skillId))
11437
11404
  });
11438
11405
  }
11439
11406
  return {
11440
- configPath: path11.join(
11441
- context.workspacePath,
11442
- context.store.getWorkspaceMarkerPath()
11443
- ),
11407
+ configPath: path11.join(context.workspacePath, context.store.getWorkspaceMarkerPath()),
11444
11408
  userSkillsPath: context.userSkillsRoot,
11445
11409
  skills: [...byId.values()].sort((a, b) => a.id.localeCompare(b.id)),
11446
11410
  enabledSkillIds: [],
@@ -11494,10 +11458,7 @@ var SkillBridgeHandler = class {
11494
11458
  skills: workspaceSkillIds.map((skillId) => ({
11495
11459
  id: skillId,
11496
11460
  displayName: skillId,
11497
- path: path11.join(
11498
- context.workspacePath,
11499
- context.store.getWorkspaceSkillPath(skillId)
11500
- )
11461
+ path: path11.join(context.workspacePath, context.store.getWorkspaceSkillPath(skillId))
11501
11462
  }))
11502
11463
  };
11503
11464
  }
@@ -11508,7 +11469,10 @@ var SkillBridgeHandler = class {
11508
11469
  workspacePath: resolvedWorkspacePath,
11509
11470
  userSkillsRoot
11510
11471
  });
11511
- const catalogClient = new SkillCatalogClient();
11472
+ const marketplaceBaseUrl = readMarketplaceBaseUrl();
11473
+ const catalogClient = new SkillCatalogClient(
11474
+ marketplaceBaseUrl ? { baseUrl: marketplaceBaseUrl } : {}
11475
+ );
11512
11476
  const reconciler = new SkillReconciler({
11513
11477
  skillStore: store,
11514
11478
  catalogClient
@@ -11594,9 +11558,7 @@ var TaskBridgeHandler = class {
11594
11558
  constructor(logger, emitEvent) {
11595
11559
  this.logger = logger;
11596
11560
  this.emitEvent = emitEvent;
11597
- this.engine = new TaskExecutionEngine(
11598
- (taskType) => getExecutor(taskType)
11599
- );
11561
+ this.engine = new TaskExecutionEngine((taskType) => getExecutor(taskType));
11600
11562
  this.engine.setListener({
11601
11563
  onStarted: (params) => this.emitEvent("task.started", params),
11602
11564
  onOutput: (params) => this.emitEvent("task.output", params),
@@ -11733,10 +11695,7 @@ var BridgeServer = class {
11733
11695
  } catch (err) {
11734
11696
  const message = err instanceof Error ? err.message : String(err);
11735
11697
  if (message.includes("TASK_ALREADY_RUNNING")) {
11736
- this.writeError(
11737
- request.id,
11738
- createServicemeError("task_already_running", message)
11739
- );
11698
+ this.writeError(request.id, createServicemeError("task_already_running", message));
11740
11699
  } else {
11741
11700
  this.writeError(request.id, err);
11742
11701
  }
@@ -11756,9 +11715,7 @@ var BridgeServer = class {
11756
11715
  }
11757
11716
  case "skill.marketplace-state": {
11758
11717
  const skillRequest = request;
11759
- const result = await this.skillHandler.getMarketplaceState(
11760
- skillRequest.params
11761
- );
11718
+ const result = await this.skillHandler.getMarketplaceState(skillRequest.params);
11762
11719
  this.writeSuccess(request.id, result);
11763
11720
  return;
11764
11721
  }
@@ -11776,17 +11733,13 @@ var BridgeServer = class {
11776
11733
  }
11777
11734
  case "skill.publishable": {
11778
11735
  const skillRequest = request;
11779
- const result = await this.skillHandler.publishable(
11780
- skillRequest.params
11781
- );
11736
+ const result = await this.skillHandler.publishable(skillRequest.params);
11782
11737
  this.writeSuccess(request.id, result);
11783
11738
  return;
11784
11739
  }
11785
11740
  case "agent.marketplace-state": {
11786
11741
  const agentRequest = request;
11787
- const result = await this.agentHandler.getMarketplaceState(
11788
- agentRequest.params
11789
- );
11742
+ const result = await this.agentHandler.getMarketplaceState(agentRequest.params);
11790
11743
  this.writeSuccess(request.id, result);
11791
11744
  return;
11792
11745
  }
@@ -11798,19 +11751,14 @@ var BridgeServer = class {
11798
11751
  }
11799
11752
  case "agent.permissions": {
11800
11753
  const agentRequest = request;
11801
- const result = await this.agentHandler.permissions(
11802
- agentRequest.params
11803
- );
11754
+ const result = await this.agentHandler.permissions(agentRequest.params);
11804
11755
  this.writeSuccess(request.id, result);
11805
11756
  return;
11806
11757
  }
11807
11758
  default:
11808
11759
  this.writeError(
11809
11760
  request.id,
11810
- createServicemeError(
11811
- "invalid_params",
11812
- "Unsupported bridge method."
11813
- )
11761
+ createServicemeError("invalid_params", "Unsupported bridge method.")
11814
11762
  );
11815
11763
  }
11816
11764
  } catch (error) {