@signetai/connector-opencode 0.198.1 → 0.198.2

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.js CHANGED
@@ -12677,7 +12677,10 @@ ${content}`);
12677
12677
  function isSignetGeneratedFile(raw) {
12678
12678
  const lines = raw.split(`
12679
12679
  `).slice(0, 6);
12680
- return lines.some((line, i) => /^#\s+AUTO-GENERATED\s+from\s+.*\s+by\s+Signet/i.test(line) || /^#\s+Auto-generated\s+from\s+/.test(line) && i + 1 < lines.length && /^#\s+Source:\s+/.test(lines[i + 1]));
12680
+ return lines.some((line, i) => {
12681
+ const nextLine = lines[i + 1];
12682
+ return /^#\s+AUTO-GENERATED\s+from\s+.*\s+by\s+Signet/i.test(line) || /^#\s+Auto-generated\s+from\s+/.test(line) && /^#\s+Source:\s+/.test(nextLine ?? "");
12683
+ });
12681
12684
  }
12682
12685
  function atomicWriteText(path, content, mode) {
12683
12686
  const tmp = join3(dirname5(path), `.${randomBytes(6).toString("hex")}.tmp`);
@@ -14736,6 +14739,8 @@ function parseLenientJsonObject(raw, options) {
14736
14739
  parsed = import_json5.parse(source);
14737
14740
  } catch {
14738
14741
  const first = errors[0];
14742
+ if (!first)
14743
+ throw new Error(`Invalid ${options.label}`);
14739
14744
  throw new Error(`Invalid ${options.label} at offset ${first.offset} (${printParseErrorCode(first.error)})`);
14740
14745
  }
14741
14746
  }
@@ -31447,7 +31452,7 @@ Set the \\\`cycles\\\` parameter to \\\`"ref"\\\` to resolve cyclical schemas wi
31447
31452
  \${I}\`:I}function h5($){let z=J$($.dynamicContext)||J$($.inject),I=J$($.notifications?.inject);if(!I||!z.endsWith(I))return z;return z.slice(0,-I.length).trim()}function C$($){let z=Reflect.get(globalThis,"process");if(!z||typeof z!=="object")return;let I=Reflect.get(z,"env");if(!I||typeof I!=="object")return;let _=Reflect.get(I,$);return typeof _==="string"?_:void 0}function b5(){let $=C$("SIGNET_PATH")??IX(zX(),".agents");return x4($)??""}function f5($){let z=C$("SIGNET_PATH")??IX(zX(),".agents");if($==="timeout")return x4(z,K0)??"";return x4(z)??""}function UX(){return B0(C$(Z0)??C$(F0))}function y5(){return S0(C$(q0))}function Ij($){if(!$)return;if(typeof $.id==="string")return $.id;if(typeof $.sessionID==="string")return $.sessionID;if(typeof $.sessionId==="string")return $.sessionId;let z=$.info;if(typeof z!=="object"||z===null)return;let I=Reflect.get(z,"id");if(typeof I==="string")return I;let _=Reflect.get(z,"sessionID");if(typeof _==="string")return _;let U=Reflect.get(z,"sessionId");if(typeof U==="string")return U;return}function u5($){if(!$)return;if(typeof $.parentID==="string")return $.parentID;if(typeof $.parentId==="string")return $.parentId;let z=$.info;if(typeof z!=="object"||z===null)return;let I=Reflect.get(z,"parentID");if(typeof I==="string")return I;let _=Reflect.get(z,"parentId");return typeof _==="string"?_:void 0}async function m5($,z){let I=await $.session.messages({path:{id:z},throwOnError:!1});if(!I.data)return"";let _=[];for(let U of I.data){let O=U.info.role==="user"?"User":"Assistant";for(let j of U.parts){if(j.type!=="text")continue;let W=U6(j.text??"").trim().replace(/\\s*\\r?\\n\\s*/g," ");if(W)_.push(\`\${O}: \${W}\`)}}return _.join(\`
31448
31453
  \`)}function c5($){if(typeof $!=="object"||$===null)return null;if(Reflect.get($,"type")!=="text")return null;let I=Reflect.get($,"text");return typeof I==="string"?I:null}var l5=async({directory:$,client:z})=>{if(!(C$("SIGNET_ENABLED")!=="false"&&C$("SIGNET_NO_HOOKS")!=="1"))return{};let _=C$("SIGNET_DAEMON_URL")??D0,U=C$("SIGNET_AGENT_ID"),O=P0(_),j="",W=new Map,N=new Map,X=new Set,H=new Map,Q=new Map,G=await O.postResult("/api/hooks/session-start",{harness:K$,project:$,agentId:U,runtimePath:S$},UX());if(G.ok)j=J$(G.data.stableSystemPrompt)||J$(G.data.inject)||J$(G.data.recentContext);else if(G.reason==="timeout")j=f5("timeout");else j=b5();async function J(Y){if(X.has(Y))return N.get(Y)??"";let L=H.get(Y);if(L)return await L;let K=O.post("/api/hooks/session-start",{harness:K$,project:$,agentId:U,sessionKey:Y,parentSessionKey:Q.get(Y),runtimePath:S$},UX()).then((B)=>{X.add(Y);let S=J$(B?.dynamicContext);if(B){if(W.set(Y,J$(B.stableSystemPrompt)||J$(B.inject)||J$(B.recentContext)),S)N.set(Y,S)}return S});H.set(Y,K);try{return await K}finally{H.delete(Y)}}async function V(Y,L){let K=V$.get(Y)??eJ(Y,void 0,"");try{let B=await O.post("/api/hooks/notifications",{harness:K$,hook:L,agentId:U,sessionKey:Y,project:$},B$);if(V$.get(Y)===K)K.notificationInject=J$(B?.inject)}catch{}}return{"tool.execute.before":async(Y)=>{await V(Y.sessionID,"tool.execute.before")},"tool.execute.after":async(Y,L)=>{if(Y.tool!=="skill")return;let K=typeof Y.args?.name==="string"?Y.args.name:"";if(!K)return;let B=L?.metadata,S=!(B&&typeof B==="object"&&("error"in B));O.post("/api/hooks/skill-invocation",{harness:K$,skillName:K,agentId:U,sessionId:Y.sessionID,toolUseId:Y.callID,cwd:$,args:JSON.stringify(Y.args),success:S,origin:"plugin",runtimePath:S$}).catch(()=>{})},"chat.message":async(Y,L)=>{V$.delete(Y.sessionID);let K=L.parts.map((S)=>c5(S)).filter((S)=>S!==null).join(\`
31449
31454
  \`).trim(),B=eJ(Y.sessionID,Y.messageID??L.message?.id,K);if(!K)return;try{try{let F=await J(Y.sessionID);if(F)$X(Y.sessionID,B,F);N.delete(Y.sessionID)}catch{}let S=await O.post("/api/hooks/user-prompt-submit",{harness:K$,project:$,agentId:U,sessionKey:Y.sessionID,userMessage:K,runtimePath:S$},y5());if(S){let F=h5(S);if(F)$X(Y.sessionID,B,F);B.notificationInject=J$(S.notifications?.dynamicContext)||J$(S.notifications?.inject)}}catch{}},"experimental.chat.system.transform":async(Y,L)=>{if(!Y.sessionID)return;let K="";try{K=await J(Y.sessionID)}catch{}await V(Y.sessionID,"experimental.chat.system.transform");let B=W.get(Y.sessionID)??j,S=V$.get(Y.sessionID),F=S?.notificationInject??"";if(!K&&!S?.userText&&!F)return;let D=[B,F].filter((q)=>q.trim().length>0);if(D.length>0)L.system.push(D.join(\`
31450
- \`))},"experimental.text.complete":async(Y,L)=>{L.text=U6(Q0(L.text))},"experimental.chat.messages.transform":async(Y,L)=>{for(let K=L.messages.length-1;K>=0;K--){let B=L.messages[K];if(B.info.role!=="user")continue;let S=V$.get(B.info.sessionID);if(!S||!S.dynamicContext.trim())continue;if(S.messageID&&B.info.id!==S.messageID)continue;if(!S.messageID&&S.userText){let q=B.parts.filter((R)=>R.type==="text").map((R)=>R.text).join(\`
31455
+ \`))},"experimental.text.complete":async(Y,L)=>{L.text=U6(Q0(L.text))},"experimental.chat.messages.transform":async(Y,L)=>{for(let K=L.messages.length-1;K>=0;K--){let B=L.messages[K];if(B==null||B.info.role!=="user")continue;let S=V$.get(B.info.sessionID);if(!S||!S.dynamicContext.trim())continue;if(S.messageID&&B.info.id!==S.messageID)continue;if(!S.messageID&&S.userText){let q=B.parts.filter((R)=>R.type==="text").map((R)=>R.text).join(\`
31451
31456
  \`).trim();if(U6(q)!==U6(S.userText))continue}let F=S.dynamicContext.trim();if(!F)return;let D=[...B.parts].reverse().find((q)=>q.type==="text");if(!D||D.type!=="text")return;D.text=W0(D.text,F);return}},"experimental.session.compacting":async(Y,L)=>{try{let K=await O.post("/api/hooks/pre-compaction",{harness:K$,agentId:U,sessionKey:Y.sessionID,runtimePath:S$},B$);if(K?.guidelines)L.context.push(K.guidelines);else if(j)L.context.push(j)}catch{}},event:async({event:Y})=>{try{if(Y.type==="session.created"){let L=Ij(Y.properties),K=u5(Y.properties);if(L&&K)Q.set(L,K)}if(Y.type==="session.idle"||Y.type==="session.deleted"){let L=Ij(Y.properties),K="";if(L)try{K=await m5(z,L)}catch{}if(O.post("/api/hooks/session-end",{harness:K$,agentId:U,runtimePath:S$,reason:Y.type,sessionKey:L,...K?{transcript:K}:{}},G$).catch((B)=>{console.warn("[signet] session-end fire-and-forget failed:",B)}),L)X.delete(L),W.delete(L),N.delete(L),Q.delete(L),V$.delete(L)}if(Y.type==="session.compacted"&&Y.summary){let L=Ij(Y.properties);if(L)V$.delete(L),N.delete(L);await O.post("/api/hooks/compaction-complete",{harness:K$,summary:Y.summary,project:$,sessionKey:L||void 0,runtimePath:S$},G$)}}catch{}},tool:sJ(O)}},KY=l5;export{KY as default,l5 as SignetPlugin};
31452
31457
  `;
31453
31458