@maincode-ai/matilda-code 0.22.2 → 0.22.3-nightly.20261109.f08200276
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/README.md +1 -1
- package/chunks/agent-B3ZDDRG6.js +3 -0
- package/chunks/agent-headless-SGYTO6WW.js +3 -0
- package/chunks/{askUserQuestion-DHYKAZWH.js → askUserQuestion-Y66GA5LV.js} +1 -1
- package/chunks/ca-KKKDEIJT.js +23 -0
- package/chunks/chunk-6SPPO7RK.js +62 -0
- package/chunks/chunk-6X3HPMAU.js +56 -0
- package/chunks/{chunk-FY3LL4OC.js → chunk-7SPPCSW2.js} +1 -1
- package/chunks/{chunk-BQDEPKIG.js → chunk-ADMI5U2X.js} +2 -2
- package/chunks/chunk-AXPU2T2O.js +10 -0
- package/chunks/{chunk-DZKI2CAC.js → chunk-C2AKSF3S.js} +1 -1
- package/chunks/{chunk-HRD7WD3P.js → chunk-GFKFHWDN.js} +1 -1
- package/chunks/chunk-HAM3C2JN.js +2586 -0
- package/chunks/{chunk-OF7ORAN6.js → chunk-HSSKS2BO.js} +30 -30
- package/chunks/{chunk-VWM3GUBH.js → chunk-I4KER2VG.js} +1 -1
- package/chunks/{chunk-PFXCFIHY.js → chunk-JRGQUM3K.js} +1 -1
- package/chunks/chunk-PZF4OFAZ.js +12 -0
- package/chunks/{chunk-MZ73LBEY.js → chunk-RDTF45AP.js} +1 -1
- package/chunks/{chunk-HJK3NKAR.js → chunk-SHISTILE.js} +1 -1
- package/chunks/{chunk-OWEBLTAN.js → chunk-TGRZ364D.js} +1 -1
- package/chunks/chunk-TVTJEK4V.js +12 -0
- package/chunks/{chunk-BS7Q7KA6.js → chunk-U6ATDQUV.js} +1 -1
- package/chunks/{chunk-E2KMVG7F.js → chunk-UJWYKBZM.js} +1 -1
- package/chunks/{chunk-REUZDMLM.js → chunk-W3ZB63AP.js} +25 -25
- package/chunks/chunk-YTKDUEUJ.js +8 -0
- package/chunks/{chunk-ZUQRP3N6.js → chunk-YZ33K24S.js} +1 -1
- package/chunks/chunk-ZRUOQBYQ.js +207 -0
- package/chunks/{computer-use-5T3ZH24D.js → computer-use-ZUTEIFET.js} +5 -17
- package/chunks/{cron-create-5RRFCP36.js → cron-create-4AQ43RPW.js} +1 -1
- package/chunks/cron-delete-HB7V5CZ5.js +3 -0
- package/chunks/cron-list-DIZZQW44.js +5 -0
- package/chunks/{de-MJBGC47E.js → de-2Z3VYN7K.js} +1 -1
- package/chunks/{edit-Y7YSDGLT.js → edit-ESBQCHHP.js} +1 -1
- package/chunks/en-WPNO63RZ.js +23 -0
- package/chunks/{enter-worktree-5ZGIYDUE.js → enter-worktree-3DNEZJHH.js} +1 -1
- package/chunks/{enterPlanMode-TWD4MXCW.js → enterPlanMode-AVYWCGBL.js} +1 -1
- package/chunks/{exit-worktree-3F5UY76U.js → exit-worktree-JRQ6Z7AB.js} +1 -1
- package/chunks/{exitPlanMode-HWK5EUVS.js → exitPlanMode-DRWHFT3R.js} +10 -10
- package/chunks/fr-S2YBRXGB.js +23 -0
- package/chunks/{glob-H7DNNPJ4.js → glob-ZJ2IBSBL.js} +1 -1
- package/chunks/{goal-tools-CJINJJ3Y.js → goal-tools-APHZOFAF.js} +1 -1
- package/chunks/{grep-5MCMGW6A.js → grep-7SKE6UM4.js} +1 -1
- package/chunks/{ja-OEXP6Z3S.js → ja-NOFHSWYP.js} +1 -1
- package/chunks/ls-I6JUFOTE.js +15 -0
- package/chunks/{lsp-Y46R5DO5.js → lsp-JMVZE3IL.js} +1 -1
- package/chunks/mcp-client-WGLA6WFP.js +3 -0
- package/chunks/monitor-24WFRG6D.js +32 -0
- package/chunks/notebook-edit-75IBMHFG.js +17 -0
- package/chunks/openaiContentGenerator-SK6CIVEM.js +52 -0
- package/chunks/{pt-PCVIFK7H.js → pt-PF7EEIOB.js} +1 -1
- package/chunks/read-file-PLW5HG6G.js +3 -0
- package/chunks/ripGrep-5I2QHVHA.js +3 -0
- package/chunks/{ru-CB5SIZZM.js → ru-X7QWJTM4.js} +1 -1
- package/chunks/scheduler-V6VOAQ5Q.js +8 -0
- package/chunks/send-message-F2OT25N7.js +8 -0
- package/chunks/shell-3HCOYZFM.js +3 -0
- package/chunks/{skill-5EMGSWRM.js → skill-WUXCNHR2.js} +1 -1
- package/chunks/symbol-search-R7VDY7D2.js +19 -0
- package/chunks/syntheticOutput-ULZO4GEC.js +3 -0
- package/chunks/task-create-ARA6A3IM.js +3 -0
- package/chunks/task-detach-4JGQ6IFW.js +9 -0
- package/chunks/task-list-MUF5W3YQ.js +9 -0
- package/chunks/{task-stop-OEAEE5R7.js → task-stop-JDLVQ7YB.js} +1 -1
- package/chunks/{task-update-4ANRU74G.js → task-update-Z6PWEP2K.js} +1 -1
- package/chunks/{team-create-G4N2NCFN.js → team-create-MERVIMYO.js} +1 -1
- package/chunks/team-delete-7YXVWNUC.js +8 -0
- package/chunks/todoWrite-RJABGUPD.js +3 -0
- package/chunks/tool-call-O4FMFOGR.js +3 -0
- package/chunks/tool-search-UQPAGXZY.js +26 -0
- package/chunks/{web-fetch-VA2BZ4VR.js → web-fetch-3LOJYO2U.js} +1 -1
- package/chunks/{web-search-OVFXJQDS.js → web-search-MPPPKAJ7.js} +1 -1
- package/chunks/{workflow-6VMVM5BG.js → workflow-JA2PZCN3.js} +2 -2
- package/chunks/write-file-R7UW3VKA.js +15 -0
- package/cli.js +449 -465
- package/locales/ca.js +2 -3
- package/locales/de.js +2 -3
- package/locales/en.js +11 -22
- package/locales/fr.js +2 -3
- package/locales/ja.js +2 -3
- package/locales/pt.js +2 -3
- package/locales/ru.js +2 -3
- package/npm-postinstall.js +2 -2
- package/package.json +2 -2
- package/chunks/agent-IJOGVY62.js +0 -3
- package/chunks/agent-headless-FZGKJCVK.js +0 -3
- package/chunks/ca-HHQCT6S2.js +0 -23
- package/chunks/chunk-225CZWD7.js +0 -89
- package/chunks/chunk-3BT7ZYAM.js +0 -121
- package/chunks/chunk-3IG6LNQ3.js +0 -2581
- package/chunks/chunk-46FFWNRO.js +0 -12
- package/chunks/chunk-55YW6EUC.js +0 -8
- package/chunks/chunk-FPGKJJJY.js +0 -13
- package/chunks/chunk-L2FKLLEC.js +0 -12
- package/chunks/chunk-N2BE647T.js +0 -10
- package/chunks/chunk-P24OL22U.js +0 -31
- package/chunks/chunk-VWE5BSHV.js +0 -56
- package/chunks/chunk-WL27X35X.js +0 -44
- package/chunks/cron-delete-7DTRWCSV.js +0 -3
- package/chunks/cron-list-HY6XJD7D.js +0 -5
- package/chunks/en-JITX7JKV.js +0 -23
- package/chunks/fr-WT3R2JCR.js +0 -23
- package/chunks/keychain-token-storage-BCODB632.js +0 -3
- package/chunks/ls-JORGCXES.js +0 -15
- package/chunks/mcp-client-54J5M542.js +0 -3
- package/chunks/monitor-BRJR6PR3.js +0 -32
- package/chunks/notebook-edit-UCCVQ4JP.js +0 -17
- package/chunks/openaiContentGenerator-H6JOS3XU.js +0 -52
- package/chunks/read-file-LVMBCRCT.js +0 -3
- package/chunks/ripGrep-F6AJSDKU.js +0 -3
- package/chunks/scheduler-XAOD6LG6.js +0 -8
- package/chunks/send-message-VY4DP63A.js +0 -8
- package/chunks/shell-QUDC6MJK.js +0 -3
- package/chunks/symbol-search-YNGX4Z5T.js +0 -19
- package/chunks/syntheticOutput-4JANVS4D.js +0 -3
- package/chunks/task-create-NRBVXURQ.js +0 -3
- package/chunks/task-detach-VHDDAO2K.js +0 -9
- package/chunks/task-list-T2IET466.js +0 -9
- package/chunks/team-delete-M4ORNSTT.js +0 -8
- package/chunks/todoWrite-RN2OP46T.js +0 -3
- package/chunks/tool-search-WEUURHFZ.js +0 -28
- package/chunks/write-file-5ZAZVXBB.js +0 -15
package/chunks/chunk-46FFWNRO.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{f as o,g as a,m as u,n}from"./chunk-P24OL22U.js";import{b as s}from"./chunk-GZPNIYVZ.js";s();var i=`Submit your final answer as structured JSON that conforms to the provided schema.
|
|
4
|
-
|
|
5
|
-
CRITICAL: In structured-output mode, this is the ONLY way to deliver the final result. Call this tool to deliver the final result; the first call with valid arguments ends the session. Do not emit the final answer as plain text \u2014 it will be discarded. Use other tools (Read, Grep, etc.) to gather the information you need before calling this tool.
|
|
6
|
-
|
|
7
|
-
The arguments you pass MUST validate against the tool's parameter schema. If validation fails you will receive the error and may retry with corrected fields.`,p={__redacted:"structured_output payload (see stdout result)"},l=class r extends a{static Name=u.STRUCTURED_OUTPUT;constructor(t){super(r.Name,n.STRUCTURED_OUTPUT,i,"think",t,!1,!1,!1,!0,"structured output json schema final result submit")}createInvocation(t){return new e(t)}},e=class extends o{getDescription(){return"Submit structured result"}async execute(t){return{llmContent:"Structured output accepted. The session will end now \u2014 do not send further content.",returnDisplay:"Structured output accepted."}}};export{p as a,l as b};
|
|
8
|
-
/**
|
|
9
|
-
* @license
|
|
10
|
-
* Copyright 2025 Matilda
|
|
11
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
*/
|
package/chunks/chunk-55YW6EUC.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{ea as d}from"./chunk-WL27X35X.js";import{b as n}from"./chunk-GZPNIYVZ.js";n();import*as w from"node:crypto";n();var l=class{serviceName;constructor(e){this.serviceName=e}validateCredentials(e){if(!e.serverName)throw new Error("Server name is required");if(!e.token)throw new Error("Token is required");if(!e.token.accessToken)throw new Error("Access token is required");if(!e.token.tokenType)throw new Error("Token type is required")}isTokenExpired(e){if(!e.token.expiresAt)return!1;let t=5*60*1e3;return Date.now()>e.token.expiresAt-t}sanitizeServerName(e){return e.replace(/[^a-zA-Z0-9-_.]/g,"_")}};var o=d("MCP_KEYCHAIN"),c="__keychain_test__",s="__secret__",y=class extends l{keychainAvailable=null;keytarModule=null;keytarLoadAttempted=!1;async getKeytar(){if(this.keytarLoadAttempted)return this.keytarModule;this.keytarLoadAttempted=!0;try{let t=await import("keytar");this.keytarModule=t.default||t}catch(e){o.error(`Failed to load keytar module: ${e}`)}return this.keytarModule}async getCredentials(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");try{let r=this.sanitizeServerName(e),a=await t.getPassword(this.serviceName,r);if(!a)return null;let i=JSON.parse(a);return this.isTokenExpired(i)?null:i}catch(r){throw r instanceof SyntaxError?new Error(`Failed to parse stored credentials for ${e}`):r}}async setCredentials(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");this.validateCredentials(e);let r=this.sanitizeServerName(e.serverName),a={...e,updatedAt:Date.now()},i=JSON.stringify(a);await t.setPassword(this.serviceName,r,i)}async deleteCredentials(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");let r=this.sanitizeServerName(e);if(!await t.deletePassword(this.serviceName,r))throw new Error(`No credentials found for ${e}`)}async listServers(){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let e=await this.getKeytar();if(!e)throw new Error("Keytar module not available");try{return(await e.findCredentials(this.serviceName)).filter(r=>!r.account.startsWith(c)).filter(r=>!r.account.startsWith(s)).map(r=>r.account)}catch(t){return o.error(`Failed to list servers from keychain: ${t}`),[]}}async getAllCredentials(){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let e=await this.getKeytar();if(!e)throw new Error("Keytar module not available");let t=new Map;try{let r=(await e.findCredentials(this.serviceName)).filter(a=>!a.account.startsWith(c)).filter(a=>!a.account.startsWith(s));for(let a of r)try{let i=JSON.parse(a.password);this.isTokenExpired(i)||t.set(a.account,i)}catch(i){o.error(`Failed to parse credentials for ${a.account}: ${i}`)}}catch(r){o.error(`Failed to get all credentials from keychain: ${r}`)}return t}async clearAll(){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let e=this.keytarModule?await this.keytarModule.findCredentials(this.serviceName).then(r=>r.map(a=>a.account)).catch(r=>{throw new Error(`Failed to list servers for clearing: ${r.message}`)}):[],t=[];for(let r of e)try{await this.deleteCredentials(r)}catch(a){t.push(a)}if(t.length>0)throw new Error(`Failed to clear some credentials: ${t.map(r=>r.message).join(", ")}`)}async checkKeychainAvailability(){if(this.keychainAvailable!==null)return this.keychainAvailable;try{let e=await this.getKeytar();if(!e)return this.keychainAvailable=!1,!1;let t=`${c}${w.randomBytes(8).toString("hex")}`,r="test";await e.setPassword(this.serviceName,t,r);let a=await e.getPassword(this.serviceName,t),h=await e.deletePassword(this.serviceName,t)&&a===r;return this.keychainAvailable=h,h}catch{return this.keychainAvailable=!1,!1}}async isAvailable(){return this.checkKeychainAvailability()}async setSecret(e,t){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let r=await this.getKeytar();if(!r)throw new Error("Keytar module not available");await r.setPassword(this.serviceName,`${s}${e}`,t)}async getSecret(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");return t.getPassword(this.serviceName,`${s}${e}`)}async deleteSecret(e){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let t=await this.getKeytar();if(!t)throw new Error("Keytar module not available");if(!await t.deletePassword(this.serviceName,`${s}${e}`))throw new Error(`No secret found for key: ${e}`)}async listSecrets(){if(!await this.checkKeychainAvailability())throw new Error("Keychain is not available");let e=await this.getKeytar();if(!e)throw new Error("Keytar module not available");try{return(await e.findCredentials(this.serviceName)).filter(r=>r.account.startsWith(s)).map(r=>r.account.substring(s.length))}catch(t){return o.error(`Failed to list secrets from keychain: ${t}`),[]}}};export{l as a,y as b};
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright 2025 Google LLC
|
|
7
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
*/
|
package/chunks/chunk-FPGKJJJY.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{b as n}from"./chunk-GZPNIYVZ.js";n();n();var x="MATILDA_API_KEY";var d="matilda-code-1.0",l="Matilda",O="https://matilda.maincode.com/api/v1/code",g={id:"matilda",label:"Matilda",description:"Connect to the Matilda Core code API endpoint",protocol:"openai",baseUrl:O,envKey:x,models:[{id:d,displayName:l,contextWindowSize:1048576,description:"Matilda Code model",generationConfig:{openAIRequestProfile:"matilda-code",timeout:6e5,samplingParams:{max_tokens:65536,chat_template_kwargs:{enable_thinking:!0}},schemaCompliance:"openapi_30",splitToolMedia:!0,customHeaders:{"User-Agent":"MatildaCode/0.1"}}}],documentationUrl:"https://help.maincode.com/products/matilda/v1/en/authentication/manage-api-keys"};var b=d,v="text-embedding-v4";n();import{AsyncLocalStorage as D}from"node:async_hooks";import{randomUUID as f}from"node:crypto";n();import{AsyncLocalStorage as P}from"node:async_hooks";var m=new P;var A="x-matilda-reported-operation-id",E="x-matilda-reported-attempt-purpose",y=[A,E],I=new Set(y),C=["answer","tool_followup","continuation","retry","compaction","unknown"],M=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,L=new Set(C),c=new D,_=new WeakSet;function T(){return f()}function a(t,e){let o=Object.freeze({operationId:t,attemptPurpose:e});return _.add(o),o}function q(t){return I.has(t.toLowerCase())}function s(){let t=c.getStore();return t&&_.has(t)?t:void 0}var R=class{activeOperationId;begin(e){return this.activeOperationId=T(),a(this.activeOperationId,e)}continue(e){let o=s()?.operationId??this.activeOperationId??T();return this.activeOperationId=o,a(o,e)}};function p(t,e){return c.run(t,e)}function z(t){c.enterWith(t)}function B(t,e){let o=s();return o?p(a(o.operationId,t),e):e()}function h(t,e){let o={next:(...r)=>p(t,()=>e.next(...r)),return:r=>p(t,()=>e.return(r)),throw:r=>p(t,()=>e.throw(r)),[Symbol.asyncIterator]:()=>o},i=Symbol.asyncDispose,u=i&&e[i];return i&&typeof u=="function"&&(o[i]=()=>p(t,()=>u.call(e))),o}function F(t,e){let o=s();return o?h(a(o.operationId,t),e):e}function V(){let t=s();if(!t||!M.test(t.operationId))return{};let e=m.getStore()?.attempt,o=e!==void 0&&e>1?"retry":t.attemptPurpose;return L.has(o)?{[A]:t.operationId,[E]:o}:{}}export{m as a,A as b,E as c,y as d,q as e,s as f,R as g,p as h,z as i,B as j,h as k,F as l,V as m,x as n,d as o,l as p,O as q,g as r,b as s,v as t};
|
|
4
|
-
/**
|
|
5
|
-
* @license
|
|
6
|
-
* Copyright 2026 Matilda Team
|
|
7
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* @license
|
|
11
|
-
* Copyright 2025 Google LLC
|
|
12
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
13
|
-
*/
|
package/chunks/chunk-L2FKLLEC.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{j as i,s as c}from"./chunk-FPGKJJJY.js";import{d as l}from"./chunk-P24OL22U.js";import{b as g}from"./chunk-GZPNIYVZ.js";g();import{readFile as y}from"node:fs/promises";function S(t){return t?`side-query:${t}`:"side-query"}function T(t,e){return e??t.getFastModel?.()??t.getModel()??c}function x(t){let e=t?.thinkingConfig;return{...t??{},thinkingConfig:e?{includeThoughts:!1,...e}:{includeThoughts:!1}}}async function h(t){let e=t.getOutputLanguageFilePath?.();if(e)try{let n=(await y(e,"utf8")).trim();return n?["Follow the user-visible output language preference below for this side query.",n].join(`
|
|
4
|
-
|
|
5
|
-
`):void 0}catch{return}}function C(t,e){return e?t===void 0?e:typeof t=="string"?`${t}
|
|
6
|
-
|
|
7
|
-
${e}`:Array.isArray(t)?[...t,{text:e}]:typeof t=="object"&&"parts"in t&&Array.isArray(t.parts)?{...t,parts:[...t.parts,{text:e}]}:[t,{text:e}]:t}function R(t){return t.schema!==void 0&&t.schema!==null}async function A(t,e){let n=T(t,e.model),o=e.promptId??S(e.purpose),s=x(e.config),a=C(e.systemInstruction,await h(t)),u=e.purpose==="chat-compression"?"compaction":"unknown";if(R(e)){let r=await i(u,()=>t.getBaseLlmClient().generateJson({contents:e.contents,schema:e.schema,abortSignal:e.abortSignal,model:n,systemInstruction:a,promptId:o,config:s,...e.maxAttempts!==void 0&&{maxAttempts:e.maxAttempts}})),f=l.validate(e.schema,r);if(f)throw new Error(`Invalid side query response: ${f}`);let m=e.validate?.(r);if(m)throw new Error(m);return r}let p=await i(u,()=>t.getBaseLlmClient().generateText({contents:e.contents,model:n,systemInstruction:a,abortSignal:e.abortSignal,promptId:o,config:s,...e.maxAttempts!==void 0&&{maxAttempts:e.maxAttempts},...e.stream&&{stream:!0}})),d=e.validate?.(p.text);if(d)throw new Error(d);return p}export{A as a};
|
|
8
|
-
/**
|
|
9
|
-
* @license
|
|
10
|
-
* Copyright 2025 Google LLC
|
|
11
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
*/
|
package/chunks/chunk-N2BE647T.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Force strict mode and setup for ESM
|
|
2
|
-
"use strict";
|
|
3
|
-
import{a as c}from"./chunk-V6UPUMP3.js";import{m as u}from"./chunk-P24OL22U.js";import{b as m}from"./chunk-GZPNIYVZ.js";m();import{AsyncLocalStorage as k}from"node:async_hooks";var a=new k,r=new WeakMap,p={turns:"max_turn_requests",session_turns:"max_turn_requests",loop_detected:"max_turn_requests",continuations:"max_turn_requests",session_tokens:"max_tokens"},h=class{jobs=new Map;joinsJobs;wake;closed=!1;keepsFinished=!1;revision=0;task;lastResponse;stop;ended;finished;constructor(e={}){this.joinsJobs=e.joinsJobs??!0}begin(e,t,s=e){this.task||(this.task={startUuid:e,rootUuid:s,recorder:t},this.ended&&this.finish(this.ended).catch(()=>{}))}get taskStartUuid(){return this.task?.startUuid}get taskRef(){return this.task?{startUuid:this.task.startUuid,rootUuid:this.task.rootUuid}:void 0}noteResponse(e){this.lastResponse=e}noteStop(e){this.stop=e}finish(e){let t=this.task;return t?(this.finished??=this.recordOutcome(t,e),this.finished):(this.ended??=e,Promise.resolve(void 0))}async recordOutcome(e,t){let s=this.stop&&(t.outcome==="completed"||t.outcome==="error")?p[this.stop]:t.outcome,i=s==="completed"&&this.lastResponse?.finalAnswer?this.lastResponse:void 0,n=t.limitKind??(s==="max_tokens"||s==="max_turn_requests"?this.stop:void 0);return await e.recorder.recordTaskOutcome({taskStartUuid:e.startUuid,outcome:s,...n?{limitKind:n}:{},...s==="completed"?{finalAnswerUuid:i?i.recordId??i.id:null}:{}}),{outcome:s,...i&&{finalAnswerId:i.id}}}static get current(){return a.getStore()}run(e){return a.run(this,e)}static detached(e){return a.run(void 0,e)}static register(e,t,s){let i=a.getStore();e.originTask??=s?.originTask??i?.taskRef;let n=s?.status==="running"?r.get(s):void 0,o=n??(i?.joinsJobs?i:void 0);if(o){if(n&&s&&n.consume(s),e.completion==="detached"||!n&&e.status!=="running"){o.changed();return}if(r.set(e,o),o.closed){t();return}o.jobs.set(e,t),o.changed()}}static changed(e){e&&r.get(e)?.changed()}static abandoned(e){return r.get(e)?.closed===!0}static detach(e){let t=r.get(e);return!t||t.closed||!t.owns(e)||e.status!=="running"?!1:(e.completion="detached",t.consume(e),t.changed(),!0)}owns(e){return this.jobs.has(e)}consume(e){r.delete(e),this.jobs.delete(e)}get pending(){return this.jobs.size>0}get position(){return this.revision}get paused(){return[...this.jobs.keys()].some(e=>e.status==="paused")}get running(){return[...this.jobs.keys()].filter(e=>e.status==="running")}changed(){this.revision++,this.wake?.()}async wait(e,t,s){this.closed||t.aborted||e!==this.revision||await new Promise(i=>{let n,o=()=>{clearTimeout(n),t.removeEventListener("abort",o),this.wake=void 0,i()};this.wake=o,t.addEventListener("abort",o,{once:!0}),s!==void 0&&(n=setTimeout(o,s))})}keepFinishedJobs(){this.keepsFinished=!0}close(){this.closed=!0;for(let[e,t]of this.jobs)e.status==="running"?t():this.keepsFinished&&e.status!=="paused"&&this.consume(e);this.changed()}};function g(d,e){let t=s=>{let i=s.description.replace(/[\p{Cc}\s]+/gu," ").trim(),n=Math.max(1,Math.round((e-s.startTime)/6e4));return`background ${s.kind} "${i.length>80?`${i.slice(0,77)}...`:i}" (running ${n} min)`};return{displayText:`Still waiting on ${d.map(t).join(", ")}.`,modelText:d.map(s=>["<task-notification>",`<task-id>${c(s.id)}</task-id>`,`<kind>${s.kind}</kind>`,"<status>running</status>",`<summary>${c(`The ${t(s)} is still running, and this request cannot finish until it does. If the request needs its result, keep waiting. If it should keep running after the request, such as a server or watcher, call ${u.TASK_DETACH}. If it is no longer needed, call ${u.TASK_STOP}.`)}</summary>`,"</task-notification>"].join(`
|
|
4
|
-
`)).join(`
|
|
5
|
-
`)}}export{h as a,g as b};
|
|
6
|
-
/**
|
|
7
|
-
* @license
|
|
8
|
-
* Copyright 2026 Matilda
|
|
9
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
*/
|