@pragma-sh/opencode-plugin 1.0.2 → 1.0.3

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/index.mjs CHANGED
@@ -506,6 +506,7 @@ function createPragmaOpencodeHooks(reporter) {
506
506
  const messageText = new Map;
507
507
  const childSessions = new Map;
508
508
  const activeChildSessions = new Set;
509
+ const activeShellCalls = new Set;
509
510
  let pendingLegacyQuestion = null;
510
511
  let activeCanonicalQuestionId = null;
511
512
  const EVENT_HANDLERS = {
@@ -513,6 +514,8 @@ function createPragmaOpencodeHooks(reporter) {
513
514
  "session.idle": applySessionIdleEvent,
514
515
  "session.error": applySessionErrorEvent,
515
516
  "session.deleted": applySessionDeletedEvent,
517
+ "session.next.shell.started": applyShellStartedEvent,
518
+ "session.next.shell.ended": applyShellEndedEvent,
516
519
  "server.instance.disposed": () => "clear",
517
520
  "permission.replied": applyPermissionRepliedEvent,
518
521
  "question.replied": applyQuestionRepliedEvent,
@@ -703,6 +706,7 @@ function createPragmaOpencodeHooks(reporter) {
703
706
  attention = false;
704
707
  childSessions.clear();
705
708
  activeChildSessions.clear();
709
+ activeShellCalls.clear();
706
710
  if (lastReported === "cleared") {
707
711
  return;
708
712
  }
@@ -713,7 +717,7 @@ function createPragmaOpencodeHooks(reporter) {
713
717
  if (attention) {
714
718
  return `attention:${attentionKind}`;
715
719
  }
716
- if (busy) {
720
+ if (busy || activeShellCalls.size > 0) {
717
721
  return "started";
718
722
  }
719
723
  return "stopped";
@@ -761,15 +765,38 @@ function createPragmaOpencodeHooks(reporter) {
761
765
  }
762
766
  busy = false;
763
767
  attention = false;
768
+ removeShellCalls(sessionIdFromEvent(event));
764
769
  removeChildren(sessionIdFromEvent(event));
765
770
  return "sync";
766
771
  }
767
772
  function applySessionDeletedEvent(event) {
768
773
  busy = false;
769
774
  attention = false;
775
+ removeShellCalls(sessionIdFromEvent(event));
770
776
  removeChildren(sessionIdFromEvent(event));
771
777
  return "sync";
772
778
  }
779
+ function applyShellStartedEvent(event) {
780
+ const key = shellCallKey(event);
781
+ if (!key)
782
+ return "none";
783
+ activeShellCalls.add(key);
784
+ return "sync";
785
+ }
786
+ function applyShellEndedEvent(event) {
787
+ const key = shellCallKey(event);
788
+ if (!key || !activeShellCalls.delete(key))
789
+ return "none";
790
+ return "sync";
791
+ }
792
+ function removeShellCalls(sessionId) {
793
+ if (!sessionId)
794
+ return;
795
+ for (const key of activeShellCalls) {
796
+ if (key.startsWith(`${sessionId}:`))
797
+ activeShellCalls.delete(key);
798
+ }
799
+ }
773
800
  function hasActiveChildren(parentId) {
774
801
  for (const childId of activeChildSessions) {
775
802
  if (!parentId || childSessions.get(childId) === parentId) {
@@ -985,6 +1012,10 @@ function sessionIdFromEvent(event) {
985
1012
  }
986
1013
  return;
987
1014
  }
1015
+ function shellCallKey(event) {
1016
+ const properties = event.properties;
1017
+ return isRecord(properties) && typeof properties.sessionID === "string" && typeof properties.callID === "string" ? `${properties.sessionID}:${properties.callID}` : undefined;
1018
+ }
988
1019
  function assistantTextPart(part) {
989
1020
  const partType = typeof part.type === "string" ? part.type : undefined;
990
1021
  if (partType !== "text" && partType !== "reasoning")
@@ -1,7 +1,7 @@
1
- // ../plugin/dist/shared/chunk-e222xk1w.js
2
- var PLUGIN_API_VERSION = "1.0.1";
1
+ // ../plugin/dist/shared/chunk-092xbtcy.js
2
+ var PLUGIN_API_VERSION = "1.1.0";
3
3
 
4
- // ../plugin/dist/shared/chunk-6qx2xj9p.js
4
+ // ../plugin/dist/shared/chunk-966j85v7.js
5
5
  function defineAgent(input) {
6
6
  return input;
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pragma-sh/opencode-plugin",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "opencode plugin that reports agent status to Pragma automatically.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {