tamash-playwright 0.7.0 → 0.8.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.
Potentially problematic release.
This version of tamash-playwright might be problematic. Click here for more details.
- package/.env.example +22 -6
- package/README.md +495 -431
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +3 -10
- package/dist/cli/doctor.js.map +1 -1
- package/dist/healer/providers/claude-cli.d.ts +3 -0
- package/dist/healer/providers/claude-cli.d.ts.map +1 -0
- package/dist/healer/providers/claude-cli.js +122 -0
- package/dist/healer/providers/claude-cli.js.map +1 -0
- package/dist/healer/providers/claude-subscription.d.ts +3 -0
- package/dist/healer/providers/claude-subscription.d.ts.map +1 -0
- package/dist/healer/providers/claude-subscription.js +122 -0
- package/dist/healer/providers/claude-subscription.js.map +1 -0
- package/dist/healer/providers/copilot-cli.d.ts +3 -0
- package/dist/healer/providers/copilot-cli.d.ts.map +1 -0
- package/dist/healer/providers/copilot-cli.js +115 -0
- package/dist/healer/providers/copilot-cli.js.map +1 -0
- package/dist/healer/providers/copilot-subscription.d.ts +3 -0
- package/dist/healer/providers/copilot-subscription.d.ts.map +1 -0
- package/dist/healer/providers/copilot-subscription.js +118 -0
- package/dist/healer/providers/copilot-subscription.js.map +1 -0
- package/dist/healer/providers/index.d.ts.map +1 -1
- package/dist/healer/providers/index.js +12 -1
- package/dist/healer/providers/index.js.map +1 -1
- package/package.json +17 -3
- package/usage.md +4 -16
package/dist/cli/doctor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":"AA8IA,wBAAsB,SAAS,CAAC,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBlE"}
|
package/dist/cli/doctor.js
CHANGED
|
@@ -19,20 +19,13 @@ async function checkProviderConnectivity() {
|
|
|
19
19
|
console.log(' Healing is currently OFF. Set HEALER_ENABLED=true (or remove the line) to turn it back on.');
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
console.log(`HEALER_ACTION_RECOVERY_ENABLED: ${process.env.HEALER_ACTION_RECOVERY_ENABLED ?? '(unset — defaults to false)'}`);
|
|
23
|
-
if ((0, healer_1.isActionRecoveryEnabled)()) {
|
|
24
|
-
console.log(' Action recovery is ON — if a locator heals but the action on it still fails, the AI may retry');
|
|
25
|
-
console.log(' it (scroll into view, force, wait, or dispatch the DOM event directly) before giving up.');
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.log(' Action recovery is OFF (opt-in, off by default). Set HEALER_ACTION_RECOVERY_ENABLED=true to turn it on.');
|
|
29
|
-
}
|
|
30
|
-
console.log('');
|
|
31
22
|
const providerName = process.env.HEALER_PROVIDER;
|
|
32
23
|
if (!providerName) {
|
|
33
24
|
console.log('[WARN] HEALER_PROVIDER is not set. No AI provider is configured, so self-healing will never');
|
|
34
25
|
console.log(' recover a failed action — it will just fail normally.');
|
|
35
|
-
console.log(' Set HEALER_PROVIDER (ollama | openai | anthropic | gemini
|
|
26
|
+
console.log(' Set HEALER_PROVIDER (ollama | openai | anthropic | gemini | claude-subscription |');
|
|
27
|
+
console.log(' copilot-subscription) plus its API key/model (or, for claude-subscription/');
|
|
28
|
+
console.log(' copilot-subscription, a subscription login) in .env.');
|
|
36
29
|
return;
|
|
37
30
|
}
|
|
38
31
|
const provider = (0, providers_1.getHealProvider)();
|
package/dist/cli/doctor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/cli/doctor.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oDAA4B;AAC5B,mDAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"doctor.js","source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0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-cli.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/claude-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,YAAY,EAAsH,MAAM,SAAS,CAAC;AAqFpL,wBAAgB,uBAAuB,IAAI,YAAY,CAmDtD"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createClaudeCliProvider = createClaudeCliProvider;
|
|
4
|
+
const prompt_1 = require("./prompt");
|
|
5
|
+
// Fallback only — normally overridden by SuggestSelectorInput.timeoutMs, same as the other providers.
|
|
6
|
+
const REQUEST_TIMEOUT_MS = 15000;
|
|
7
|
+
// @anthropic-ai/claude-agent-sdk is a peer dependency (optional — see package.json), not installed
|
|
8
|
+
// by default, so it's only ever loaded lazily inside a try/catch. It's also ESM-only ("type":
|
|
9
|
+
// "module", no "require" export condition) — but this project compiles to CommonJS (tsconfig
|
|
10
|
+
// "module": "commonjs"), and under that setting tsc silently downlevels a plain `await
|
|
11
|
+
// import(...)` into a deferred `require(...)`, which throws ERR_REQUIRE_ESM against an ESM-only
|
|
12
|
+
// package at runtime (confirmed by inspecting the compiled dist/ output). Loading it through
|
|
13
|
+
// `new Function(...)` hides the import() call from tsc's static rewrite — it stays a real,
|
|
14
|
+
// unmodified dynamic import at runtime, which is the only way to load an ESM-only package from a
|
|
15
|
+
// CommonJS module in Node.
|
|
16
|
+
const importClaudeAgentSdk = new Function('specifier', 'return import(specifier)');
|
|
17
|
+
function warnUnavailable(reason, error) {
|
|
18
|
+
const err = error;
|
|
19
|
+
const notInstalled = err?.code === 'ERR_MODULE_NOT_FOUND' || err?.code === 'MODULE_NOT_FOUND';
|
|
20
|
+
if (notInstalled) {
|
|
21
|
+
console.warn(`[self-healer] claude-cli: @anthropic-ai/claude-agent-sdk is not installed — run \`npm install @anthropic-ai/claude-agent-sdk\` to use it, or use HEALER_PROVIDER=anthropic + ANTHROPIC_API_KEY instead.`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.warn(`[self-healer] claude-cli: ${reason} — not authenticated? Run \`claude login\`, or for CI set CLAUDE_CODE_OAUTH_TOKEN (see \`claude setup-token\`), or use HEALER_PROVIDER=anthropic + ANTHROPIC_API_KEY instead.`);
|
|
25
|
+
}
|
|
26
|
+
// A fresh query() call per invocation (own AbortController, no shared session) — the provider is a
|
|
27
|
+
// module-level singleton (see providers/index.ts) that can be called concurrently, so nothing here
|
|
28
|
+
// may hold state across calls.
|
|
29
|
+
async function runQuery(model, systemPrompt, prompt, timeoutMs) {
|
|
30
|
+
const { query } = await importClaudeAgentSdk('@anthropic-ai/claude-agent-sdk');
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
33
|
+
try {
|
|
34
|
+
for await (const message of query({
|
|
35
|
+
prompt,
|
|
36
|
+
options: {
|
|
37
|
+
model,
|
|
38
|
+
maxTurns: 1,
|
|
39
|
+
tools: [],
|
|
40
|
+
permissionMode: 'bypassPermissions',
|
|
41
|
+
systemPrompt,
|
|
42
|
+
abortController: controller,
|
|
43
|
+
},
|
|
44
|
+
})) {
|
|
45
|
+
if (message.type === 'result') {
|
|
46
|
+
if (message.subtype !== 'success') {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
text: message.result,
|
|
51
|
+
inputTokens: message.usage?.input_tokens,
|
|
52
|
+
outputTokens: message.usage?.output_tokens,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function toUsage(result) {
|
|
63
|
+
const { inputTokens, outputTokens } = result;
|
|
64
|
+
if (inputTokens === undefined || outputTokens === undefined) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return { inputTokens, outputTokens, totalTokens: inputTokens + outputTokens };
|
|
68
|
+
}
|
|
69
|
+
// Unlike the API-key providers (anthropic.ts, etc.), this one always returns a provider object —
|
|
70
|
+
// there's no env var to check synchronously, since auth is either an existing `claude login`
|
|
71
|
+
// session or CLAUDE_CODE_OAUTH_TOKEN, both of which can only be verified by actually trying a call.
|
|
72
|
+
// Failure is deferred to each method call below, matching the existing swallow-and-return-null
|
|
73
|
+
// contract every other provider already follows.
|
|
74
|
+
function createClaudeCliProvider() {
|
|
75
|
+
const model = process.env.CLAUDE_CLI_MODEL ?? 'haiku';
|
|
76
|
+
return {
|
|
77
|
+
name: `claude-cli:${model}`,
|
|
78
|
+
// Neither SDK's one-shot `prompt: string` path has a confirmed image-input shape suited to
|
|
79
|
+
// this package's "return pixel coordinates" vision task — safer not to attempt it than guess.
|
|
80
|
+
supportsVision: false,
|
|
81
|
+
async suggestSelector(input) {
|
|
82
|
+
try {
|
|
83
|
+
const result = await runQuery(model, prompt_1.SYSTEM_PROMPT, (0, prompt_1.buildUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
84
|
+
if (!result) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const suggestion = (0, prompt_1.parseSuggestion)(result.text);
|
|
88
|
+
if (!suggestion) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return { suggestion, usage: toUsage(result) };
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
95
|
+
warnUnavailable(reason, error);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
async suggestSelectorFromImage(_input) {
|
|
100
|
+
return null;
|
|
101
|
+
},
|
|
102
|
+
async suggestActionTactic(input) {
|
|
103
|
+
try {
|
|
104
|
+
const result = await runQuery(model, prompt_1.ACTION_RECOVERY_SYSTEM_PROMPT, (0, prompt_1.buildActionRecoveryUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
105
|
+
if (!result) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const tactic = (0, prompt_1.parseActionTacticSuggestion)(result.text);
|
|
109
|
+
if (!tactic) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return { tactic, usage: toUsage(result) };
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
116
|
+
warnUnavailable(reason, error);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=claude-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-cli.js","sourceRoot":"","sources":["../../../src/healer/providers/claude-cli.ts"],"names":[],"mappings":";;;AACA,qCAAsK;AAEtK,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,mGAAmG;AACnG,8FAA8F;AAC9F,6FAA6F;AAC7F,uFAAuF;AACvF,gGAAgG;AAChG,6FAA6F;AAC7F,2FAA2F;AAC3F,iGAAiG;AACjG,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEpB,CAAC;AAE9D,SAAS,eAAe,CAAC,MAAc,EAAE,KAAc;IACrD,MAAM,GAAG,GAAG,KAA8B,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,EAAE,IAAI,KAAK,sBAAsB,IAAI,GAAG,EAAE,IAAI,KAAK,kBAAkB,CAAC;IAC9F,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,yMAAyM,CAC1M,CAAC;QACF,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CACV,6BAA6B,MAAM,+KAA+K,CACnN,CAAC;AACJ,CAAC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AAC,KAA+B;YACvD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,QAAQ,CAC3B,KAAK,EACL,sCAA6B,EAC7B,IAAA,sCAA6B,EAAC,KAAK,CAAC,EACpC,KAAK,CAAC,SAAS,IAAI,kBAAkB,CACtC,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM,MAAM,GAAG,IAAA,oCAA2B,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;gBACxD,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtE,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-subscription.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/claude-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,YAAY,EAAsH,MAAM,SAAS,CAAC;AAqFpL,wBAAgB,gCAAgC,IAAI,YAAY,CAmD/D"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createClaudeSubscriptionProvider = createClaudeSubscriptionProvider;
|
|
4
|
+
const prompt_1 = require("./prompt");
|
|
5
|
+
// Fallback only — normally overridden by SuggestSelectorInput.timeoutMs, same as the other providers.
|
|
6
|
+
const REQUEST_TIMEOUT_MS = 15000;
|
|
7
|
+
// @anthropic-ai/claude-agent-sdk is a peer dependency (optional — see package.json), not installed
|
|
8
|
+
// by default, so it's only ever loaded lazily inside a try/catch. It's also ESM-only ("type":
|
|
9
|
+
// "module", no "require" export condition) — but this project compiles to CommonJS (tsconfig
|
|
10
|
+
// "module": "commonjs"), and under that setting tsc silently downlevels a plain `await
|
|
11
|
+
// import(...)` into a deferred `require(...)`, which throws ERR_REQUIRE_ESM against an ESM-only
|
|
12
|
+
// package at runtime (confirmed by inspecting the compiled dist/ output). Loading it through
|
|
13
|
+
// `new Function(...)` hides the import() call from tsc's static rewrite — it stays a real,
|
|
14
|
+
// unmodified dynamic import at runtime, which is the only way to load an ESM-only package from a
|
|
15
|
+
// CommonJS module in Node.
|
|
16
|
+
const importClaudeAgentSdk = new Function('specifier', 'return import(specifier)');
|
|
17
|
+
function warnUnavailable(reason, error) {
|
|
18
|
+
const err = error;
|
|
19
|
+
const notInstalled = err?.code === 'ERR_MODULE_NOT_FOUND' || err?.code === 'MODULE_NOT_FOUND';
|
|
20
|
+
if (notInstalled) {
|
|
21
|
+
console.warn(`[self-healer] claude-subscription: @anthropic-ai/claude-agent-sdk is not installed — run \`npm install @anthropic-ai/claude-agent-sdk\` to use it, or use HEALER_PROVIDER=anthropic + ANTHROPIC_API_KEY instead.`);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
console.warn(`[self-healer] claude-subscription: ${reason} — not authenticated? Run \`claude login\`, or for CI set CLAUDE_CODE_OAUTH_TOKEN (see \`claude setup-token\`), or use HEALER_PROVIDER=anthropic + ANTHROPIC_API_KEY instead.`);
|
|
25
|
+
}
|
|
26
|
+
// A fresh query() call per invocation (own AbortController, no shared session) — the provider is a
|
|
27
|
+
// module-level singleton (see providers/index.ts) that can be called concurrently, so nothing here
|
|
28
|
+
// may hold state across calls.
|
|
29
|
+
async function runQuery(model, systemPrompt, prompt, timeoutMs) {
|
|
30
|
+
const { query } = await importClaudeAgentSdk('@anthropic-ai/claude-agent-sdk');
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
33
|
+
try {
|
|
34
|
+
for await (const message of query({
|
|
35
|
+
prompt,
|
|
36
|
+
options: {
|
|
37
|
+
model,
|
|
38
|
+
maxTurns: 1,
|
|
39
|
+
tools: [],
|
|
40
|
+
permissionMode: 'bypassPermissions',
|
|
41
|
+
systemPrompt,
|
|
42
|
+
abortController: controller,
|
|
43
|
+
},
|
|
44
|
+
})) {
|
|
45
|
+
if (message.type === 'result') {
|
|
46
|
+
if (message.subtype !== 'success') {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
text: message.result,
|
|
51
|
+
inputTokens: message.usage?.input_tokens,
|
|
52
|
+
outputTokens: message.usage?.output_tokens,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
clearTimeout(timer);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function toUsage(result) {
|
|
63
|
+
const { inputTokens, outputTokens } = result;
|
|
64
|
+
if (inputTokens === undefined || outputTokens === undefined) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
return { inputTokens, outputTokens, totalTokens: inputTokens + outputTokens };
|
|
68
|
+
}
|
|
69
|
+
// Unlike the API-key providers (anthropic.ts, etc.), this one always returns a provider object —
|
|
70
|
+
// there's no env var to check synchronously, since auth is either an existing `claude login`
|
|
71
|
+
// session or CLAUDE_CODE_OAUTH_TOKEN, both of which can only be verified by actually trying a call.
|
|
72
|
+
// Failure is deferred to each method call below, matching the existing swallow-and-return-null
|
|
73
|
+
// contract every other provider already follows.
|
|
74
|
+
function createClaudeSubscriptionProvider() {
|
|
75
|
+
const model = process.env.CLAUDE_SUBSCRIPTION_MODEL ?? 'haiku';
|
|
76
|
+
return {
|
|
77
|
+
name: `claude-subscription:${model}`,
|
|
78
|
+
// Neither SDK's one-shot `prompt: string` path has a confirmed image-input shape suited to
|
|
79
|
+
// this package's "return pixel coordinates" vision task — safer not to attempt it than guess.
|
|
80
|
+
supportsVision: false,
|
|
81
|
+
async suggestSelector(input) {
|
|
82
|
+
try {
|
|
83
|
+
const result = await runQuery(model, prompt_1.SYSTEM_PROMPT, (0, prompt_1.buildUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
84
|
+
if (!result) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const suggestion = (0, prompt_1.parseSuggestion)(result.text);
|
|
88
|
+
if (!suggestion) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
return { suggestion, usage: toUsage(result) };
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
95
|
+
warnUnavailable(reason, error);
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
async suggestSelectorFromImage(_input) {
|
|
100
|
+
return null;
|
|
101
|
+
},
|
|
102
|
+
async suggestActionTactic(input) {
|
|
103
|
+
try {
|
|
104
|
+
const result = await runQuery(model, prompt_1.ACTION_RECOVERY_SYSTEM_PROMPT, (0, prompt_1.buildActionRecoveryUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
105
|
+
if (!result) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const tactic = (0, prompt_1.parseActionTacticSuggestion)(result.text);
|
|
109
|
+
if (!tactic) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return { tactic, usage: toUsage(result) };
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
116
|
+
warnUnavailable(reason, error);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=claude-subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-subscription.js","sourceRoot":"","sources":["../../../src/healer/providers/claude-subscription.ts"],"names":[],"mappings":";;;AACA,qCAAsK;AAEtK,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,mGAAmG;AACnG,8FAA8F;AAC9F,6FAA6F;AAC7F,uFAAuF;AACvF,gGAAgG;AAChG,6FAA6F;AAC7F,2FAA2F;AAC3F,iGAAiG;AACjG,2BAA2B;AAC3B,MAAM,oBAAoB,GAAG,IAAI,QAAQ,CAAC,WAAW,EAAE,0BAA0B,CAEpB,CAAC;AAE9D,SAAS,eAAe,CAAC,MAAc,EAAE,KAAc;IACrD,MAAM,GAAG,GAAG,KAA8B,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,EAAE,IAAI,KAAK,sBAAsB,IAAI,GAAG,EAAE,IAAI,KAAK,kBAAkB,CAAC;IAC9F,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,kNAAkN,CACnN,CAAC;QACF,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CACV,sCAAsC,MAAM,+KAA+K,CAC5N,CAAC;AACJ,CAAC;AAID,mGAAmG;AACnG,mGAAmG;AACnG,+BAA+B;AAC/B,KAAK,UAAU,QAAQ,CAAC,KAAa,EAAE,YAAoB,EAAE,MAAc,EAAE,SAAiB;IAC5F,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,oBAAoB,CAAC,gCAAgC,CAAC,CAAC;IAC/E,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;IAE9D,IAAI,CAAC;QACH,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,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ACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtE,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-cli.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/copilot-cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,YAAY,EAAsH,MAAM,SAAS,CAAC;AAsEpL,wBAAgB,wBAAwB,IAAI,YAAY,CAuDvD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCopilotCliProvider = createCopilotCliProvider;
|
|
4
|
+
const prompt_1 = require("./prompt");
|
|
5
|
+
// Fallback only — normally overridden by SuggestSelectorInput.timeoutMs, same as the other providers.
|
|
6
|
+
const REQUEST_TIMEOUT_MS = 15000;
|
|
7
|
+
// @github/copilot-sdk is a peer dependency (optional — see package.json), not installed by default,
|
|
8
|
+
// so it's only ever loaded lazily inside a try/catch. Unlike the Claude Agent SDK, this package
|
|
9
|
+
// ships both CJS and ESM builds, so a plain require() resolves correctly from this CJS package.
|
|
10
|
+
function warnUnavailable(reason, error) {
|
|
11
|
+
const err = error;
|
|
12
|
+
const notInstalled = err?.code === 'MODULE_NOT_FOUND';
|
|
13
|
+
if (notInstalled) {
|
|
14
|
+
console.warn(`[self-healer] copilot-cli: @github/copilot-sdk is not installed — run \`npm install @github/copilot-sdk\` to use it, or use HEALER_PROVIDER=openai/anthropic/gemini + an API key instead.`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.warn(`[self-healer] copilot-cli: ${reason} — not authenticated? Install and sign in with the \`copilot\` CLI locally, or for CI set GITHUB_TOKEN (with a "copilot-requests: write" workflow permission on GitHub Actions, or a PAT with "Copilot Requests" scope elsewhere), or use HEALER_PROVIDER=openai/anthropic/gemini + an API key instead.`);
|
|
18
|
+
}
|
|
19
|
+
// A fresh CopilotClient (and its underlying `copilot` CLI subprocess) is started and stopped per
|
|
20
|
+
// call, matching the "no shared state across concurrent calls" requirement — the provider is a
|
|
21
|
+
// module-level singleton (see providers/index.ts) that can be invoked concurrently. A shared,
|
|
22
|
+
// lazily-started client reusing sessions per call would avoid the repeated subprocess-spawn cost
|
|
23
|
+
// and is architecturally supported by the SDK, but isn't implemented here to avoid taking on
|
|
24
|
+
// subprocess-lifecycle management (leftover child processes, retry-after-failure semantics)
|
|
25
|
+
// without a concrete need yet.
|
|
26
|
+
async function sendMessage(model, systemPrompt, prompt, timeoutMs) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
28
|
+
const { CopilotClient } = require('@github/copilot-sdk');
|
|
29
|
+
const client = new CopilotClient();
|
|
30
|
+
try {
|
|
31
|
+
await client.start();
|
|
32
|
+
// availableTools: [] keeps this a pure text completion — no tool/file access during a heal
|
|
33
|
+
// call. Deliberately not wiring up onPermissionRequest (e.g. approveAll): with no tools
|
|
34
|
+
// available, none should ever fire, and auto-approving tool calls would be a real security
|
|
35
|
+
// regression for something that can run unattended in CI.
|
|
36
|
+
const session = await client.createSession({ model, availableTools: [] });
|
|
37
|
+
const response = await session.sendAndWait({ prompt: `${systemPrompt}\n\n${prompt}` }, timeoutMs);
|
|
38
|
+
const content = response?.data.content;
|
|
39
|
+
if (!content) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return { content, outputTokens: response?.data.outputTokens };
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
await client.stop();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Best-effort cleanup — nothing useful to do if the client can't be stopped cleanly.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function toUsage(result) {
|
|
54
|
+
// The Copilot SDK's assistant.message event only exposes an output-token count, no input/prompt
|
|
55
|
+
// tokens — inputTokens/totalTokens stay undefined, which TokenUsage already allows.
|
|
56
|
+
return result.outputTokens === undefined ? undefined : { outputTokens: result.outputTokens };
|
|
57
|
+
}
|
|
58
|
+
// Unlike the API-key providers (openai.ts, etc.), this one always returns a provider object —
|
|
59
|
+
// there's no env var to check synchronously, since auth is either an existing `copilot` CLI login
|
|
60
|
+
// or an ambient GITHUB_TOKEN, both of which can only be verified by actually trying a call. Failure
|
|
61
|
+
// is deferred to each method call below, matching the existing swallow-and-return-null contract
|
|
62
|
+
// every other provider already follows.
|
|
63
|
+
function createCopilotCliProvider() {
|
|
64
|
+
// MAI-Code-1-Flash (Microsoft's own coding model, available on every Copilot tier including
|
|
65
|
+
// free) by default — cheap and fast, which fits this package's narrow selector-suggestion task
|
|
66
|
+
// well, and matches defaulting claude-cli to Haiku for the same reason. Override with
|
|
67
|
+
// COPILOT_CLI_MODEL for a different model (e.g. the newer MAI-Code-1.1-Flash).
|
|
68
|
+
const model = process.env.COPILOT_CLI_MODEL ?? 'MAI-Code-1-Flash';
|
|
69
|
+
return {
|
|
70
|
+
name: `copilot-cli:${model}`,
|
|
71
|
+
// Neither SDK's one-shot completion path has a confirmed image-input shape suited to this
|
|
72
|
+
// package's "return pixel coordinates" vision task — safer not to attempt it than guess.
|
|
73
|
+
supportsVision: false,
|
|
74
|
+
async suggestSelector(input) {
|
|
75
|
+
try {
|
|
76
|
+
const result = await sendMessage(model, prompt_1.SYSTEM_PROMPT, (0, prompt_1.buildUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
77
|
+
if (!result) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
const suggestion = (0, prompt_1.parseSuggestion)(result.content);
|
|
81
|
+
if (!suggestion) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
return { suggestion, usage: toUsage(result) };
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
88
|
+
warnUnavailable(reason, error);
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
async suggestSelectorFromImage(_input) {
|
|
93
|
+
return null;
|
|
94
|
+
},
|
|
95
|
+
async suggestActionTactic(input) {
|
|
96
|
+
try {
|
|
97
|
+
const result = await sendMessage(model, prompt_1.ACTION_RECOVERY_SYSTEM_PROMPT, (0, prompt_1.buildActionRecoveryUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
98
|
+
if (!result) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const tactic = (0, prompt_1.parseActionTacticSuggestion)(result.content);
|
|
102
|
+
if (!tactic) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
return { tactic, usage: toUsage(result) };
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
109
|
+
warnUnavailable(reason, error);
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=copilot-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-cli.js","sourceRoot":"","sources":["../../../src/healer/providers/copilot-cli.ts"],"names":[],"mappings":";;;AACA,qCAAsK;AAEtK,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,oGAAoG;AACpG,gGAAgG;AAChG,gGAAgG;AAChG,SAAS,eAAe,CAAC,MAAc,EAAE,KAAc;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KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtE,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,KAAK,CAAC,wBAAwB,CAAC,MAAoC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,mBAAmB,CAAC,KAA+B;YACvD,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,WAAW,CAC9B,KAAK,EACL,sCAA6B,EAC7B,IAAA,sCAA6B,EAAC,KAAK,CAAC,EACpC,KAAK,CAAC,SAAS,IAAI,kBAAkB,CACtC,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM,MAAM,GAAG,IAAA,oCAA2B,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtE,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-subscription.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/copilot-subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,YAAY,EAAsH,MAAM,SAAS,CAAC;AAsEpL,wBAAgB,iCAAiC,IAAI,YAAY,CA0DhE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCopilotSubscriptionProvider = createCopilotSubscriptionProvider;
|
|
4
|
+
const prompt_1 = require("./prompt");
|
|
5
|
+
// Fallback only — normally overridden by SuggestSelectorInput.timeoutMs, same as the other providers.
|
|
6
|
+
const REQUEST_TIMEOUT_MS = 15000;
|
|
7
|
+
// @github/copilot-sdk is a peer dependency (optional — see package.json), not installed by default,
|
|
8
|
+
// so it's only ever loaded lazily inside a try/catch. Unlike the Claude Agent SDK, this package
|
|
9
|
+
// ships both CJS and ESM builds, so a plain require() resolves correctly from this CJS package.
|
|
10
|
+
function warnUnavailable(reason, error) {
|
|
11
|
+
const err = error;
|
|
12
|
+
const notInstalled = err?.code === 'MODULE_NOT_FOUND';
|
|
13
|
+
if (notInstalled) {
|
|
14
|
+
console.warn(`[self-healer] copilot-subscription: @github/copilot-sdk is not installed — run \`npm install @github/copilot-sdk\` to use it, or use HEALER_PROVIDER=openai/anthropic/gemini + an API key instead.`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.warn(`[self-healer] copilot-subscription: ${reason} — not authenticated? Install and sign in with the \`copilot\` CLI locally, or for CI set GITHUB_TOKEN (with a "copilot-requests: write" workflow permission on GitHub Actions, or a PAT with "Copilot Requests" scope elsewhere), or use HEALER_PROVIDER=openai/anthropic/gemini + an API key instead.`);
|
|
18
|
+
}
|
|
19
|
+
// A fresh CopilotClient (and its underlying `copilot` CLI subprocess) is started and stopped per
|
|
20
|
+
// call, matching the "no shared state across concurrent calls" requirement — the provider is a
|
|
21
|
+
// module-level singleton (see providers/index.ts) that can be invoked concurrently. A shared,
|
|
22
|
+
// lazily-started client reusing sessions per call would avoid the repeated subprocess-spawn cost
|
|
23
|
+
// and is architecturally supported by the SDK, but isn't implemented here to avoid taking on
|
|
24
|
+
// subprocess-lifecycle management (leftover child processes, retry-after-failure semantics)
|
|
25
|
+
// without a concrete need yet.
|
|
26
|
+
async function sendMessage(model, systemPrompt, prompt, timeoutMs) {
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
28
|
+
const { CopilotClient } = require('@github/copilot-sdk');
|
|
29
|
+
const client = new CopilotClient();
|
|
30
|
+
try {
|
|
31
|
+
await client.start();
|
|
32
|
+
// availableTools: [] keeps this a pure text completion — no tool/file access during a heal
|
|
33
|
+
// call. Deliberately not wiring up onPermissionRequest (e.g. approveAll): with no tools
|
|
34
|
+
// available, none should ever fire, and auto-approving tool calls would be a real security
|
|
35
|
+
// regression for something that can run unattended in CI.
|
|
36
|
+
const session = await client.createSession({ model, availableTools: [] });
|
|
37
|
+
const response = await session.sendAndWait({ prompt: `${systemPrompt}\n\n${prompt}` }, timeoutMs);
|
|
38
|
+
const content = response?.data.content;
|
|
39
|
+
if (!content) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return { content, outputTokens: response?.data.outputTokens };
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
await client.stop();
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Best-effort cleanup — nothing useful to do if the client can't be stopped cleanly.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function toUsage(result) {
|
|
54
|
+
// The Copilot SDK's assistant.message event only exposes an output-token count, no input/prompt
|
|
55
|
+
// tokens — inputTokens/totalTokens stay undefined, which TokenUsage already allows.
|
|
56
|
+
return result.outputTokens === undefined ? undefined : { outputTokens: result.outputTokens };
|
|
57
|
+
}
|
|
58
|
+
// Unlike the API-key providers (openai.ts, etc.), this one always returns a provider object —
|
|
59
|
+
// there's no env var to check synchronously, since auth is either an existing `copilot` CLI login
|
|
60
|
+
// or an ambient GITHUB_TOKEN, both of which can only be verified by actually trying a call. Failure
|
|
61
|
+
// is deferred to each method call below, matching the existing swallow-and-return-null contract
|
|
62
|
+
// every other provider already follows.
|
|
63
|
+
function createCopilotSubscriptionProvider() {
|
|
64
|
+
// MAI-Code-1-Flash (Microsoft's own coding model, available on every Copilot tier including
|
|
65
|
+
// free) by default — cheap and fast, which fits this package's narrow selector-suggestion task
|
|
66
|
+
// well, and matches defaulting claude-subscription to Haiku for the same reason. The display
|
|
67
|
+
// name "MAI-Code-1-Flash" is NOT the selectable model id — confirmed live against
|
|
68
|
+
// client.listModels() and a real session — the actual id is "mai-code-1-flash-picker". Override
|
|
69
|
+
// with COPILOT_SUBSCRIPTION_MODEL for a different model (e.g. "mai-code-1.1-flash", the newer
|
|
70
|
+
// version with vision support — also confirmed working live).
|
|
71
|
+
const model = process.env.COPILOT_SUBSCRIPTION_MODEL ?? 'mai-code-1-flash-picker';
|
|
72
|
+
return {
|
|
73
|
+
name: `copilot-subscription:${model}`,
|
|
74
|
+
// Neither SDK's one-shot completion path has a confirmed image-input shape suited to this
|
|
75
|
+
// package's "return pixel coordinates" vision task — safer not to attempt it than guess.
|
|
76
|
+
supportsVision: false,
|
|
77
|
+
async suggestSelector(input) {
|
|
78
|
+
try {
|
|
79
|
+
const result = await sendMessage(model, prompt_1.SYSTEM_PROMPT, (0, prompt_1.buildUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
80
|
+
if (!result) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const suggestion = (0, prompt_1.parseSuggestion)(result.content);
|
|
84
|
+
if (!suggestion) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
return { suggestion, usage: toUsage(result) };
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
91
|
+
warnUnavailable(reason, error);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async suggestSelectorFromImage(_input) {
|
|
96
|
+
return null;
|
|
97
|
+
},
|
|
98
|
+
async suggestActionTactic(input) {
|
|
99
|
+
try {
|
|
100
|
+
const result = await sendMessage(model, prompt_1.ACTION_RECOVERY_SYSTEM_PROMPT, (0, prompt_1.buildActionRecoveryUserPrompt)(input), input.timeoutMs ?? REQUEST_TIMEOUT_MS);
|
|
101
|
+
if (!result) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const tactic = (0, prompt_1.parseActionTacticSuggestion)(result.content);
|
|
105
|
+
if (!tactic) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
return { tactic, usage: toUsage(result) };
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
112
|
+
warnUnavailable(reason, error);
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=copilot-subscription.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copilot-subscription.js","sourceRoot":"","sources":["../../../src/healer/providers/copilot-subscription.ts"],"names":[],"mappings":";;;AACA,qCAAsK;AAEtK,sGAAsG;AACtG,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC,oGAAoG;AACpG,gGAAgG;AAChG,gGAAgG;AAChG,SAAS,eAAe,CAAC,MAAc,EAAE,KAAc;IACrD,MAAM,GAAG,GAAG,KAA8B,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,EAAE,IAAI,KAAK,kBAAkB,CAAC;IACtD,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,oMAAoM,CACrM,CAAC;QACF,OAAO;IACT,CAAC;IACD,OAAO,CAAC,IAAI,CACV,uCAAuC,MAAM,ySAAyS,CACvV,CAAC;AACJ,CAAC;AAID,iGAAiG;AACjG,+FAA+F;AAC/F,8FAA8F;AAC9F,iGAAiG;AACjG,6FAA6F;AAC7F,4FAA4F;AAC5F,+BAA+B;A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AAK,EACL,sCAA6B,EAC7B,IAAA,sCAA6B,EAAC,KAAK,CAAC,EACpC,KAAK,CAAC,SAAS,IAAI,kBAAkB,CACtC,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,MAAM,MAAM,GAAG,IAAA,oCAA2B,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;gBAC3D,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACtE,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC/B,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/healer/providers/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAUlH,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CA6BrD"}
|