kifaru 1.0.179 → 1.0.180

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.
Files changed (3) hide show
  1. package/kifaru-gateway.js +169 -495
  2. package/kifaru-pi.js +43943 -119036
  3. package/package.json +2 -2
package/kifaru-gateway.js CHANGED
@@ -6024,7 +6024,7 @@ var require_src = __commonJS((exports) => {
6024
6024
  });
6025
6025
 
6026
6026
  // src/index.ts
6027
- import fs8 from "fs";
6027
+ import fs9 from "fs";
6028
6028
 
6029
6029
  // src/config.ts
6030
6030
  import crypto2 from "crypto";
@@ -33163,6 +33163,7 @@ import {
33163
33163
  getAgentDir
33164
33164
  } from "@earendil-works/pi-coding-agent";
33165
33165
  import path6 from "path";
33166
+ import fs8 from "fs";
33166
33167
  // ../core/src/model/model-family.ts
33167
33168
  function getModelFamily(model) {
33168
33169
  const ref = typeof model === "string" ? model : `${model.providerID}/${model.modelID}`;
@@ -34452,389 +34453,17 @@ function createKifaruModels(options) {
34452
34453
  }
34453
34454
  return registry2;
34454
34455
  }
34455
- // ../core/src/headless/stage-policy.ts
34456
- function evaluateToolPolicy(stageInput, tool, params) {
34457
- if (stageInput.prohibitedActions?.includes(tool.actionCategory)) {
34458
- return {
34459
- allowed: false,
34460
- reason: `Action category "${tool.actionCategory}" is explicitly prohibited for stage "${stageInput.stageKey}".`
34461
- };
34462
- }
34463
- if (!stageInput.allowedActions.includes(tool.actionCategory)) {
34464
- return {
34465
- allowed: false,
34466
- reason: `Action category "${tool.actionCategory}" is not allowed for stage "${stageInput.stageKey}".`
34467
- };
34468
- }
34469
- if (tool.actionCategory === "skill_load") {
34470
- const name = typeof params.name === "string" ? params.name.trim() : "";
34471
- if (!stageInput.allowedSkills?.includes(name)) {
34472
- return {
34473
- allowed: false,
34474
- reason: `Skill "${name}" is not bound to stage "${stageInput.stageKey}".`
34475
- };
34476
- }
34477
- }
34478
- const allowedOrigins = stageInput.target.origins.map((o) => o.toLowerCase());
34479
- const allowedHosts = new Set(allowedOrigins.map((o) => {
34480
- try {
34481
- return new URL(o).host.toLowerCase();
34482
- } catch {
34483
- return o;
34484
- }
34485
- }).filter(Boolean));
34486
- for (const key of ["url", "target", "host", "endpoint"]) {
34487
- const raw2 = params[key];
34488
- if (typeof raw2 !== "string" || raw2.trim() === "")
34489
- continue;
34490
- if (allowedOrigins.length === 0) {
34491
- return {
34492
- allowed: false,
34493
- reason: `Target "${raw2}" (param "${key}") rejected: stage "${stageInput.stageKey}" declares no allowed origins.`
34494
- };
34495
- }
34496
- let matched = false;
34497
- let parsed;
34498
- try {
34499
- parsed = new URL(raw2);
34500
- } catch {
34501
- parsed = undefined;
34502
- }
34503
- if (parsed) {
34504
- matched = allowedOrigins.some((originStr) => {
34505
- try {
34506
- const originUrl = new URL(originStr);
34507
- return parsed.protocol.toLowerCase() === originUrl.protocol.toLowerCase() && parsed.host.toLowerCase() === originUrl.host.toLowerCase();
34508
- } catch {
34509
- return false;
34510
- }
34511
- });
34512
- } else {
34513
- const host = raw2.toLowerCase().replace(/^\/+/, "").split("/")[0] ?? raw2.toLowerCase();
34514
- matched = allowedHosts.has(host);
34515
- }
34516
- if (!matched) {
34517
- return {
34518
- allowed: false,
34519
- reason: `Target "${raw2}" (param "${key}") violates stage scope bounds: not in allowed origins [${allowedOrigins.join(", ")}].`
34520
- };
34521
- }
34522
- }
34523
- return { allowed: true };
34524
- }
34525
- // ../core/src/headless/stage-harness.ts
34526
- class StageGovernanceHarness {
34527
- catalog;
34528
- invoker;
34529
- tools = new Map;
34530
- constructor(catalog, invoker) {
34531
- this.catalog = catalog;
34532
- this.invoker = invoker;
34533
- }
34534
- registerTool(tool) {
34535
- this.tools.set(tool.name, tool);
34536
- }
34537
- getRegisteredTools() {
34538
- return Array.from(this.tools.values());
34539
- }
34540
- async dispatchTool(stageInput, toolName, params, signal) {
34541
- if (signal?.aborted) {
34542
- return {
34543
- allowed: false,
34544
- error: "Execution was aborted prior to tool dispatch."
34545
- };
34546
- }
34547
- const tool = this.tools.get(toolName);
34548
- if (!tool) {
34549
- return {
34550
- allowed: false,
34551
- error: `Tool "${toolName}" is not registered with the governance harness.`
34552
- };
34553
- }
34554
- const decision = evaluateToolPolicy(stageInput, tool, params);
34555
- if (!decision.allowed) {
34556
- return { allowed: false, error: decision.reason };
34557
- }
34558
- try {
34559
- const result = await tool.execute(params, signal);
34560
- return {
34561
- allowed: true,
34562
- output: result.output,
34563
- evidence: result.evidence
34564
- };
34565
- } catch (err) {
34566
- const errorMsg = err instanceof Error ? err.message : String(err);
34567
- return {
34568
- allowed: true,
34569
- error: `Tool execution failed: ${errorMsg}`
34570
- };
34571
- }
34572
- }
34573
- async runStage(stageInput, signal) {
34574
- if (stageInput.budget && (stageInput.budget.maxTokens <= 0 || stageInput.budget.maxCostUsd <= 0 || stageInput.budget.timeoutMs <= 0)) {
34575
- return {
34576
- agentSessionId: stageInput.agentSessionId,
34577
- stageKey: stageInput.stageKey,
34578
- status: "blocked",
34579
- summary: `Stage budget limits reached (maxTokens: ${stageInput.budget.maxTokens}, maxCostUsd: ${stageInput.budget.maxCostUsd}, timeoutMs: ${stageInput.budget.timeoutMs}).`,
34580
- findings: [],
34581
- evidence: [],
34582
- costUsd: 0,
34583
- toolAttemptsThisTurn: 0,
34584
- toolsExecutedThisTurn: 0,
34585
- toolsErroredThisTurn: 0,
34586
- tokenUsage: { inputTokens: 0, outputTokens: 0, reasoningTokens: 0 }
34587
- };
34588
- }
34589
- const resolution = this.catalog.resolve(stageInput.modelPattern);
34590
- if (!resolution) {
34591
- return {
34592
- agentSessionId: stageInput.agentSessionId,
34593
- stageKey: stageInput.stageKey,
34594
- status: "failed",
34595
- summary: `Could not resolve model reference "${stageInput.modelPattern}".`,
34596
- findings: [],
34597
- evidence: [],
34598
- costUsd: 0,
34599
- toolAttemptsThisTurn: 0,
34600
- toolsExecutedThisTurn: 0,
34601
- toolsErroredThisTurn: 0,
34602
- tokenUsage: { inputTokens: 0, outputTokens: 0, reasoningTokens: 0 }
34603
- };
34604
- }
34605
- const { model, thinkingLevel } = resolution;
34606
- const systemPrompt = [
34607
- `You are executing stage "${stageInput.stageKey}" for workflow "${stageInput.workflowKey}".`,
34608
- `Target URL: ${stageInput.target.url}`,
34609
- `Allowed Origins: ${stageInput.target.origins.join(", ") || "none"}`,
34610
- `Allowed Actions: ${stageInput.allowedActions.join(", ")}`,
34611
- `Prohibited Actions: ${stageInput.prohibitedActions?.join(", ") || "none"}`,
34612
- `Perform only the assigned stage. Do not attempt out-of-scope actions.`
34613
- ].join(`
34614
- `);
34615
- const userPrompt = [
34616
- `Dossier: ${stageInput.dossierKey}`,
34617
- `Parameters: ${JSON.stringify(stageInput.params ?? {})}`,
34618
- `Execute stage analysis and provide findings with evidence.`
34619
- ].join(`
34620
- `);
34621
- try {
34622
- const result = await this.invoker.invoke({
34623
- model,
34624
- messages: [
34625
- { role: "system", content: systemPrompt },
34626
- { role: "user", content: userPrompt }
34627
- ],
34628
- thinkingLevel,
34629
- signal
34630
- });
34631
- let status = "inconclusive";
34632
- if (result.finishReason === "error" || result.finishReason === "length" || result.finishReason === "content-filter") {
34633
- status = "failed";
34634
- } else if (result.finishReason === "aborted") {
34635
- status = "blocked";
34636
- }
34637
- const summaryPrefix = status === "inconclusive" ? "[inconclusive: analysis-only, no governed tools executed] " : "";
34638
- return {
34639
- agentSessionId: stageInput.agentSessionId,
34640
- stageKey: stageInput.stageKey,
34641
- status,
34642
- summary: `${summaryPrefix}${result.text.slice(0, 500)}`,
34643
- findings: [],
34644
- evidence: [],
34645
- costUsd: result.usage.costUsd,
34646
- toolAttemptsThisTurn: 0,
34647
- toolsExecutedThisTurn: 0,
34648
- toolsErroredThisTurn: 0,
34649
- tokenUsage: {
34650
- inputTokens: result.usage.inputTokens,
34651
- outputTokens: result.usage.outputTokens,
34652
- reasoningTokens: result.usage.reasoningTokens ?? 0,
34653
- cacheReadTokens: result.usage.cacheReadTokens,
34654
- cacheWriteTokens: result.usage.cacheWriteTokens
34655
- }
34656
- };
34657
- } catch (error45) {
34658
- const isAborted = signal?.aborted || error45 instanceof Error && error45.name === "AbortError";
34659
- return {
34660
- agentSessionId: stageInput.agentSessionId,
34661
- stageKey: stageInput.stageKey,
34662
- status: isAborted ? "blocked" : "failed",
34663
- summary: `Stage execution failed: ${error45 instanceof Error ? error45.message : String(error45)}`,
34664
- findings: [],
34665
- evidence: [],
34666
- costUsd: 0,
34667
- toolAttemptsThisTurn: 0,
34668
- toolsExecutedThisTurn: 0,
34669
- toolsErroredThisTurn: 0,
34670
- tokenUsage: { inputTokens: 0, outputTokens: 0, reasoningTokens: 0 }
34671
- };
34672
- }
34673
- }
34674
- }
34675
- // ../core/src/headless/agent-stage-runner.ts
34676
- import { Agent } from "@earendil-works/pi-agent-core";
34677
- import { Type } from "@earendil-works/pi-ai";
34678
- // ../core/src/headless/stage-session-store.ts
34679
- class StageCheckpointConflictError extends Error {
34680
- constructor(message2 = "Agent Session conversation changed during Stage execution.") {
34681
- super(message2);
34682
- this.name = "StageCheckpointConflictError";
34683
- }
34684
- }
34685
-
34686
- class InMemoryStageSessionStore {
34687
- conversations = new Map;
34688
- executions = new Map;
34689
- async load(identity2) {
34690
- const conversation = this.conversations.get(identity2.conversationKey);
34691
- const execution = [identity2.executionKey, ...identity2.legacyExecutionKeys ?? []].map((key) => this.executions.get(key)).find((candidate) => candidate !== undefined);
34692
- if (!conversation && !execution)
34693
- return;
34694
- return structuredClone({ revision: conversation?.revision ?? 0, messages: conversation?.messages ?? [], execution });
34695
- }
34696
- async commit(identity2, expectedRevision, state) {
34697
- const actualRevision = this.conversations.get(identity2.conversationKey)?.revision ?? 0;
34698
- if (actualRevision !== expectedRevision)
34699
- throw new StageCheckpointConflictError;
34700
- const revision = actualRevision + 1;
34701
- const { messages, ...execution } = structuredClone(state);
34702
- this.conversations.set(identity2.conversationKey, { revision, messages });
34703
- this.executions.set(identity2.executionKey, execution);
34704
- for (const legacyKey of identity2.legacyExecutionKeys ?? []) {
34705
- if (legacyKey !== identity2.executionKey)
34706
- this.executions.delete(legacyKey);
34707
- }
34708
- return revision;
34709
- }
34710
- async delete(identity2) {
34711
- for (const key of [identity2.executionKey, ...identity2.legacyExecutionKeys ?? []])
34712
- this.executions.delete(key);
34713
- }
34714
- }
34715
- // ../core/src/headless/sandboxed-tools.ts
34716
- import { Type as Type2 } from "@earendil-works/pi-ai";
34717
-
34718
- class SandboxedBashTool {
34719
- sandbox;
34720
- name = "sandboxed_bash";
34721
- actionCategory = "command_execution";
34722
- description = "Execute a shell command inside the isolated sandbox runtime.";
34723
- parameters = Type2.Object({
34724
- command: Type2.String({ minLength: 1, description: "Shell command to execute." }),
34725
- timeoutMs: Type2.Optional(Type2.Number({ minimum: 1, maximum: 120000, description: "Optional execution timeout in milliseconds." }))
34726
- }, { additionalProperties: false });
34727
- constructor(sandbox) {
34728
- this.sandbox = sandbox;
34729
- }
34730
- async execute(params, signal) {
34731
- const command = typeof params.command === "string" ? params.command : "";
34732
- if (!command.trim()) {
34733
- throw new Error("Missing or empty 'command' parameter for sandboxed_bash.");
34734
- }
34735
- const timeoutMs = typeof params.timeoutMs === "number" ? params.timeoutMs : 30000;
34736
- const result = await this.sandbox.exec(command, { signal, timeoutMs });
34737
- const taskFailed = result.exitCode !== 0;
34738
- const evidence = {
34739
- description: `Executed command in microVM: ${command.slice(0, 120)}`,
34740
- artifactType: "sandbox_command_execution",
34741
- data: {
34742
- command,
34743
- exitCode: result.exitCode,
34744
- durationMs: result.durationMs,
34745
- stdoutSnippet: result.stdout.slice(0, 500),
34746
- stderrSnippet: result.stderr.slice(0, 500)
34747
- },
34748
- timestamp: Date.now()
34749
- };
34750
- return {
34751
- output: {
34752
- exitCode: result.exitCode,
34753
- stdout: result.stdout,
34754
- stderr: result.stderr
34755
- },
34756
- evidence,
34757
- taskFailed
34758
- };
34759
- }
34760
- }
34761
-
34762
- class SandboxedFileReadTool {
34763
- sandbox;
34764
- name = "sandboxed_read_file";
34765
- actionCategory = "read_files";
34766
- description = "Read a UTF-8 text file from the isolated sandbox filesystem.";
34767
- parameters = Type2.Object({ path: Type2.String({ minLength: 1, description: "Absolute sandbox path or path beneath /workspace." }) }, { additionalProperties: false });
34768
- constructor(sandbox) {
34769
- this.sandbox = sandbox;
34770
- }
34771
- async execute(params, signal) {
34772
- const path5 = typeof params.path === "string" ? params.path : "";
34773
- if (!path5.trim()) {
34774
- throw new Error("Missing or empty 'path' parameter for sandboxed_read_file.");
34775
- }
34776
- const content = await this.sandbox.readFile(path5, signal);
34777
- const evidence = {
34778
- description: `Read file from microVM sandbox: ${path5}`,
34779
- artifactType: "sandbox_file_content",
34780
- data: {
34781
- path: path5,
34782
- bytes: content.length
34783
- },
34784
- timestamp: Date.now()
34785
- };
34786
- return {
34787
- output: { path: path5, content },
34788
- evidence
34789
- };
34790
- }
34791
- }
34792
-
34793
- class SandboxedFileWriteTool {
34794
- sandbox;
34795
- name = "sandboxed_write_file";
34796
- actionCategory = "write_files";
34797
- description = "Write UTF-8 text content to a file in the isolated sandbox filesystem.";
34798
- parameters = Type2.Object({
34799
- path: Type2.String({ minLength: 1, description: "Absolute sandbox path or path beneath /workspace." }),
34800
- content: Type2.String({ description: "Complete UTF-8 content to write." })
34801
- }, { additionalProperties: false });
34802
- constructor(sandbox) {
34803
- this.sandbox = sandbox;
34804
- }
34805
- async execute(params, signal) {
34806
- const path5 = typeof params.path === "string" ? params.path : "";
34807
- const content = typeof params.content === "string" ? params.content : "";
34808
- if (!path5.trim()) {
34809
- throw new Error("Missing or empty 'path' parameter for sandboxed_write_file.");
34810
- }
34811
- await this.sandbox.writeFile(path5, content, signal);
34812
- const evidence = {
34813
- description: `Wrote file inside microVM sandbox: ${path5}`,
34814
- artifactType: "sandbox_file_write",
34815
- data: {
34816
- path: path5,
34817
- bytesWritten: content.length
34818
- },
34819
- timestamp: Date.now()
34820
- };
34821
- return {
34822
- output: { path: path5, written: true, bytes: content.length },
34823
- evidence
34824
- };
34825
- }
34826
- }
34827
34456
  // ../core/src/headless/skill-loader.ts
34828
34457
  var MAX_SKILL_BODY_BYTES = 32 * 1024;
34829
34458
  // ../core/src/headless/governed-skill-tool.ts
34830
- import { Type as Type3 } from "@earendil-works/pi-ai";
34459
+ import { Type } from "@earendil-works/pi-ai";
34831
34460
 
34832
34461
  class GovernedSkillTool {
34833
34462
  catalog;
34834
34463
  name = "load_skill";
34835
34464
  actionCategory = "skill_load";
34836
34465
  description = "Load the instructions for a skill explicitly bound to this stage.";
34837
- parameters = Type3.Object({ name: Type3.String({ minLength: 1, description: "Exact bound skill name." }) }, { additionalProperties: false });
34466
+ parameters = Type.Object({ name: Type.String({ minLength: 1, description: "Exact bound skill name." }) }, { additionalProperties: false });
34838
34467
  constructor(catalog) {
34839
34468
  this.catalog = catalog;
34840
34469
  }
@@ -35435,62 +35064,6 @@ function materializeKifaruSkills(root = kifaruSkillsRoot(), skills = EMBEDDED_KI
35435
35064
  }
35436
35065
  return anyPresent ? root : null;
35437
35066
  }
35438
- // ../core/src/sandbox/mock-sandbox.ts
35439
- class MockSandboxSession {
35440
- options;
35441
- id = `mock-sandbox-${crypto.randomUUID().slice(0, 8)}`;
35442
- files = new Map;
35443
- isClosed = false;
35444
- executedCommands = [];
35445
- constructor(options = {}) {
35446
- this.options = options;
35447
- }
35448
- async exec(command, options) {
35449
- if (this.isClosed) {
35450
- throw new Error("Sandbox session is closed");
35451
- }
35452
- if (options?.signal?.aborted) {
35453
- throw new DOMException("Aborted", "AbortError");
35454
- }
35455
- this.executedCommands.push({ command, env: options?.env });
35456
- const started = Date.now();
35457
- if (command.includes("curl") || command.includes("wget")) {
35458
- const match = command.match(/https?:\/\/([^/\s"']+)/);
35459
- const targetHost = match ? match[1] : undefined;
35460
- if (targetHost && this.options.allowedHosts && !this.options.allowedHosts.some((allowed) => targetHost.includes(allowed))) {
35461
- return {
35462
- exitCode: 7,
35463
- stdout: "",
35464
- stderr: `curl: (7) Failed to connect to ${targetHost}: Connection refused (blocked by sandbox egress policy)`,
35465
- durationMs: Date.now() - started
35466
- };
35467
- }
35468
- }
35469
- return {
35470
- exitCode: 0,
35471
- stdout: `[mock-sandbox] Executed: ${command}`,
35472
- stderr: "",
35473
- durationMs: Date.now() - started
35474
- };
35475
- }
35476
- async readFile(path6) {
35477
- if (this.isClosed)
35478
- throw new Error("Sandbox session is closed");
35479
- const content = this.files.get(path6);
35480
- if (content === undefined) {
35481
- throw new Error(`File not found: ${path6}`);
35482
- }
35483
- return content;
35484
- }
35485
- async writeFile(path6, content) {
35486
- if (this.isClosed)
35487
- throw new Error("Sandbox session is closed");
35488
- this.files.set(path6, content);
35489
- }
35490
- async close() {
35491
- this.isClosed = true;
35492
- }
35493
- }
35494
35067
  // ../core/src/model/router-deps.ts
35495
35068
  function makeLogger(base) {
35496
35069
  const format = (message2, extra) => {
@@ -66126,11 +65699,11 @@ function BaseMapping(input2) {
66126
65699
  function WithMapping(input2) {
66127
65700
  return exports_guard.IsEqual(input2.length, 2) ? input2[1] : [];
66128
65701
  }
66129
- function FactorIndexArray(Type4, indexArray) {
65702
+ function FactorIndexArray(Type2, indexArray) {
66130
65703
  return indexArray.reduce((result, left) => {
66131
65704
  const _left = left;
66132
65705
  return exports_guard.IsEqual(_left.length, 1) ? IndexDeferred(result, _left[0]) : exports_guard.IsEqual(_left.length, 0) ? _Array_(result) : Unreachable2();
66133
- }, Type4);
65706
+ }, Type2);
66134
65707
  }
66135
65708
  function FactorExtends(type, extend3) {
66136
65709
  return exports_guard.IsEqual(extend3.length, 3) ? ConditionalDeferred(type, extend3[0], extend3[1], extend3[2]) : type;
@@ -66631,16 +66204,16 @@ function Until_1(end, input2) {
66631
66204
  }
66632
66205
  // ../../node_modules/.bun/typebox@1.3.7/node_modules/typebox/build/type/script/parser.mjs
66633
66206
  var If = (result, left, right = () => []) => result.length === 2 ? left(result) : right();
66634
- var GenericParameterExtendsEquals = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("extends", input3), ([_1, input4]) => If(Type4(input4), ([_2, input5]) => If(Const("=", input5), ([_3, input6]) => If(Type4(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [GenericParameterExtendsEqualsMapping(_0), input3]);
66635
- var GenericParameterExtends = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("extends", input3), ([_1, input4]) => If(Type4(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericParameterExtendsMapping(_0), input3]);
66636
- var GenericParameterEquals = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("=", input3), ([_1, input4]) => If(Type4(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericParameterEqualsMapping(_0), input3]);
66207
+ var GenericParameterExtendsEquals = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("extends", input3), ([_1, input4]) => If(Type2(input4), ([_2, input5]) => If(Const("=", input5), ([_3, input6]) => If(Type2(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [GenericParameterExtendsEqualsMapping(_0), input3]);
66208
+ var GenericParameterExtends = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("extends", input3), ([_1, input4]) => If(Type2(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericParameterExtendsMapping(_0), input3]);
66209
+ var GenericParameterEquals = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("=", input3), ([_1, input4]) => If(Type2(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericParameterEqualsMapping(_0), input3]);
66637
66210
  var GenericParameterIdentifier = (input2) => If(Ident(input2), ([_0, input3]) => [GenericParameterIdentifierMapping(_0), input3]);
66638
66211
  var GenericParameter = (input2) => If(If(GenericParameterExtendsEquals(input2), ([_0, input3]) => [_0, input3], () => If(GenericParameterExtends(input2), ([_0, input3]) => [_0, input3], () => If(GenericParameterEquals(input2), ([_0, input3]) => [_0, input3], () => If(GenericParameterIdentifier(input2), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [GenericParameterMapping(_0), input3]);
66639
66212
  var GenericParameterList_0 = (input2, result = []) => If(If(GenericParameter(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => GenericParameterList_0(input3, [...result, _0]), () => [result, input2]);
66640
66213
  var GenericParameterList = (input2) => If(If(GenericParameterList_0(input2), ([_0, input3]) => If(If(If(GenericParameter(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [GenericParameterListMapping(_0), input3]);
66641
66214
  var GenericParameters = (input2) => If(If(Const("<", input2), ([_0, input3]) => If(GenericParameterList(input3), ([_1, input4]) => If(Const(">", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericParametersMapping(_0), input3]);
66642
- var GenericCallArgumentList_0 = (input2, result = []) => If(If(Type4(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => GenericCallArgumentList_0(input3, [...result, _0]), () => [result, input2]);
66643
- var GenericCallArgumentList = (input2) => If(If(GenericCallArgumentList_0(input2), ([_0, input3]) => If(If(If(Type4(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [GenericCallArgumentListMapping(_0), input3]);
66215
+ var GenericCallArgumentList_0 = (input2, result = []) => If(If(Type2(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => GenericCallArgumentList_0(input3, [...result, _0]), () => [result, input2]);
66216
+ var GenericCallArgumentList = (input2) => If(If(GenericCallArgumentList_0(input2), ([_0, input3]) => If(If(If(Type2(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [GenericCallArgumentListMapping(_0), input3]);
66644
66217
  var GenericCallArguments = (input2) => If(If(Const("<", input2), ([_0, input3]) => If(GenericCallArgumentList(input3), ([_1, input4]) => If(Const(">", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericCallArgumentsMapping(_0), input3]);
66645
66218
  var GenericCall = (input2) => If(If(Ident(input2), ([_0, input3]) => If(GenericCallArguments(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [GenericCallMapping(_0), input3]);
66646
66219
  var OptionalSemiColon = (input2) => If(If(If(Const(";", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [OptionalSemiColonMapping(_0), input3]);
@@ -66658,21 +66231,21 @@ var KeywordNever = (input2) => If(Const("never", input2), ([_0, input3]) => [Key
66658
66231
  var KeywordSymbol = (input2) => If(Const("symbol", input2), ([_0, input3]) => [KeywordSymbolMapping(_0), input3]);
66659
66232
  var KeywordVoid = (input2) => If(Const("void", input2), ([_0, input3]) => [KeywordVoidMapping(_0), input3]);
66660
66233
  var KeywordThis = (input2) => If(Const("this", input2), ([_0, input3]) => [KeywordThisMapping(_0), input3]);
66661
- var TemplateInterpolate = (input2) => If(If(Const("${", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const("}", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [TemplateInterpolateMapping(_0), input3]);
66234
+ var TemplateInterpolate = (input2) => If(If(Const("${", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const("}", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [TemplateInterpolateMapping(_0), input3]);
66662
66235
  var TemplateSpan = (input2) => If(Until(["${", "`"], input2), ([_0, input3]) => [TemplateSpanMapping(_0), input3]);
66663
66236
  var TemplateBody = (input2) => If(If(If(TemplateSpan(input2), ([_0, input3]) => If(TemplateInterpolate(input3), ([_1, input4]) => If(TemplateBody(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => If(If(TemplateSpan(input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If(If(TemplateSpan(input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => []))), ([_0, input3]) => [TemplateBodyMapping(_0), input3]);
66664
66237
  var TemplateLiteralTypes = (input2) => If(If(Const("`", input2), ([_0, input3]) => If(TemplateBody(input3), ([_1, input4]) => If(Const("`", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [TemplateLiteralTypesMapping(_0), input3]);
66665
66238
  var TemplateLiteral = (input2) => If(TemplateLiteralTypes(input2), ([_0, input3]) => [TemplateLiteralMapping(_0), input3]);
66666
- var Dependent2 = (input2) => If(If(If(Const("if", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const("then", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => If(Const("else", input6), ([_4, input7]) => If(Type4(input7), ([_5, input8]) => [[_0, _1, _2, _3, _4, _5], input8])))))), ([_0, input3]) => [_0, input3], () => If(If(Const("if", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const("then", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [DependentMapping(_0), input3]);
66239
+ var Dependent2 = (input2) => If(If(If(Const("if", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const("then", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => If(Const("else", input6), ([_4, input7]) => If(Type2(input7), ([_5, input8]) => [[_0, _1, _2, _3, _4, _5], input8])))))), ([_0, input3]) => [_0, input3], () => If(If(Const("if", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const("then", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [DependentMapping(_0), input3]);
66667
66240
  var LiteralBigInt = (input2) => If(BigInt3(input2), ([_0, input3]) => [LiteralBigIntMapping(_0), input3]);
66668
66241
  var LiteralBoolean = (input2) => If(If(Const("true", input2), ([_0, input3]) => [_0, input3], () => If(Const("false", input2), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [LiteralBooleanMapping(_0), input3]);
66669
66242
  var LiteralNumber = (input2) => If(Number3(input2), ([_0, input3]) => [LiteralNumberMapping(_0), input3]);
66670
66243
  var LiteralString = (input2) => If(String3(["'", '"'], input2), ([_0, input3]) => [LiteralStringMapping(_0), input3]);
66671
66244
  var KeyOf = (input2) => If(If(If(Const("keyof", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [KeyOfMapping(_0), input3]);
66672
- var IndexArray_0 = (input2, result = []) => If(If(If(Const("[", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const("]", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => If(If(Const("[", input2), ([_0, input3]) => If(Const("]", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => IndexArray_0(input3, [...result, _0]), () => [result, input2]);
66245
+ var IndexArray_0 = (input2, result = []) => If(If(If(Const("[", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const("]", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => If(If(Const("[", input2), ([_0, input3]) => If(Const("]", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => IndexArray_0(input3, [...result, _0]), () => [result, input2]);
66673
66246
  var IndexArray = (input2) => If(IndexArray_0(input2), ([_0, input3]) => [IndexArrayMapping(_0), input3]);
66674
- var Extends2 = (input2) => If(If(If(Const("extends", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const("?", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => If(Const(":", input6), ([_4, input7]) => If(Type4(input7), ([_5, input8]) => [[_0, _1, _2, _3, _4, _5], input8])))))), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ExtendsMapping(_0), input3]);
66675
- var Base = (input2) => If(If(If(Const("(", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const(")", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => If(KeywordString(input2), ([_0, input3]) => [_0, input3], () => If(KeywordNumber(input2), ([_0, input3]) => [_0, input3], () => If(KeywordBoolean(input2), ([_0, input3]) => [_0, input3], () => If(KeywordUndefined(input2), ([_0, input3]) => [_0, input3], () => If(KeywordNull(input2), ([_0, input3]) => [_0, input3], () => If(KeywordInteger(input2), ([_0, input3]) => [_0, input3], () => If(KeywordBigInt(input2), ([_0, input3]) => [_0, input3], () => If(KeywordUnknown(input2), ([_0, input3]) => [_0, input3], () => If(KeywordAny(input2), ([_0, input3]) => [_0, input3], () => If(KeywordObject(input2), ([_0, input3]) => [_0, input3], () => If(KeywordNever(input2), ([_0, input3]) => [_0, input3], () => If(KeywordSymbol(input2), ([_0, input3]) => [_0, input3], () => If(KeywordVoid(input2), ([_0, input3]) => [_0, input3], () => If(KeywordThis(input2), ([_0, input3]) => [_0, input3], () => If(LiteralBigInt(input2), ([_0, input3]) => [_0, input3], () => If(LiteralBoolean(input2), ([_0, input3]) => [_0, input3], () => If(LiteralNumber(input2), ([_0, input3]) => [_0, input3], () => If(LiteralString(input2), ([_0, input3]) => [_0, input3], () => If(TemplateLiteral(input2), ([_0, input3]) => [_0, input3], () => If(Dependent2(input2), ([_0, input3]) => [_0, input3], () => If(_Object_2(input2), ([_0, input3]) => [_0, input3], () => If(_Tuple_(input2), ([_0, input3]) => [_0, input3], () => If(_Constructor_(input2), ([_0, input3]) => [_0, input3], () => If(_Function_2(input2), ([_0, input3]) => [_0, input3], () => If(_Mapped_(input2), ([_0, input3]) => [_0, input3], () => If(GenericCall(input2), ([_0, input3]) => [_0, input3], () => If(Reference(input2), ([_0, input3]) => [_0, input3], () => [])))))))))))))))))))))))))))), ([_0, input3]) => [BaseMapping(_0), input3]);
66247
+ var Extends2 = (input2) => If(If(If(Const("extends", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const("?", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => If(Const(":", input6), ([_4, input7]) => If(Type2(input7), ([_5, input8]) => [[_0, _1, _2, _3, _4, _5], input8])))))), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ExtendsMapping(_0), input3]);
66248
+ var Base = (input2) => If(If(If(Const("(", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const(")", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => If(KeywordString(input2), ([_0, input3]) => [_0, input3], () => If(KeywordNumber(input2), ([_0, input3]) => [_0, input3], () => If(KeywordBoolean(input2), ([_0, input3]) => [_0, input3], () => If(KeywordUndefined(input2), ([_0, input3]) => [_0, input3], () => If(KeywordNull(input2), ([_0, input3]) => [_0, input3], () => If(KeywordInteger(input2), ([_0, input3]) => [_0, input3], () => If(KeywordBigInt(input2), ([_0, input3]) => [_0, input3], () => If(KeywordUnknown(input2), ([_0, input3]) => [_0, input3], () => If(KeywordAny(input2), ([_0, input3]) => [_0, input3], () => If(KeywordObject(input2), ([_0, input3]) => [_0, input3], () => If(KeywordNever(input2), ([_0, input3]) => [_0, input3], () => If(KeywordSymbol(input2), ([_0, input3]) => [_0, input3], () => If(KeywordVoid(input2), ([_0, input3]) => [_0, input3], () => If(KeywordThis(input2), ([_0, input3]) => [_0, input3], () => If(LiteralBigInt(input2), ([_0, input3]) => [_0, input3], () => If(LiteralBoolean(input2), ([_0, input3]) => [_0, input3], () => If(LiteralNumber(input2), ([_0, input3]) => [_0, input3], () => If(LiteralString(input2), ([_0, input3]) => [_0, input3], () => If(TemplateLiteral(input2), ([_0, input3]) => [_0, input3], () => If(Dependent2(input2), ([_0, input3]) => [_0, input3], () => If(_Object_2(input2), ([_0, input3]) => [_0, input3], () => If(_Tuple_(input2), ([_0, input3]) => [_0, input3], () => If(_Constructor_(input2), ([_0, input3]) => [_0, input3], () => If(_Function_2(input2), ([_0, input3]) => [_0, input3], () => If(_Mapped_(input2), ([_0, input3]) => [_0, input3], () => If(GenericCall(input2), ([_0, input3]) => [_0, input3], () => If(Reference(input2), ([_0, input3]) => [_0, input3], () => [])))))))))))))))))))))))))))), ([_0, input3]) => [BaseMapping(_0), input3]);
66676
66249
  var With = (input2) => If(If(If(Const("with", input2), ([_0, input3]) => If(WithObject(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [WithMapping(_0), input3]);
66677
66250
  var Factor = (input2) => If(If(KeyOf(input2), ([_0, input3]) => If(Base(input3), ([_1, input4]) => If(IndexArray(input4), ([_2, input5]) => If(Extends2(input5), ([_3, input6]) => If(With(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [FactorMapping(_0), input3]);
66678
66251
  var ExprTermTail = (input2) => If(If(If(Const("&", input2), ([_0, input3]) => If(Factor(input3), ([_1, input4]) => If(ExprTermTail(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ExprTermTailMapping(_0), input3]);
@@ -66681,9 +66254,9 @@ var ExprTail = (input2) => If(If(If(Const("|", input2), ([_0, input3]) => If(Exp
66681
66254
  var Expr = (input2) => If(If(ExprTerm(input2), ([_0, input3]) => If(ExprTail(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ExprMapping(_0), input3]);
66682
66255
  var ExprReadonly = (input2) => If(If(Const("readonly", input2), ([_0, input3]) => If(Expr(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ExprReadonlyMapping(_0), input3]);
66683
66256
  var ExprPipe = (input2) => If(If(Const("|", input2), ([_0, input3]) => If(Expr(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ExprPipeMapping(_0), input3]);
66684
- var GenericType = (input2) => If(If(GenericParameters(input2), ([_0, input3]) => If(Const("=", input3), ([_1, input4]) => If(Type4(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericTypeMapping(_0), input3]);
66257
+ var GenericType = (input2) => If(If(GenericParameters(input2), ([_0, input3]) => If(Const("=", input3), ([_1, input4]) => If(Type2(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [GenericTypeMapping(_0), input3]);
66685
66258
  var InferType = (input2) => If(If(If(Const("infer", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(Const("extends", input4), ([_2, input5]) => If(Expr(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => If(If(Const("infer", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [InferTypeMapping(_0), input3]);
66686
- var Type4 = (input2) => If(If(InferType(input2), ([_0, input3]) => [_0, input3], () => If(ExprPipe(input2), ([_0, input3]) => [_0, input3], () => If(ExprReadonly(input2), ([_0, input3]) => [_0, input3], () => If(Expr(input2), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [TypeMapping(_0), input3]);
66259
+ var Type2 = (input2) => If(If(InferType(input2), ([_0, input3]) => [_0, input3], () => If(ExprPipe(input2), ([_0, input3]) => [_0, input3], () => If(ExprReadonly(input2), ([_0, input3]) => [_0, input3], () => If(Expr(input2), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [TypeMapping(_0), input3]);
66687
66260
  var PropertyKeyNumber = (input2) => If(Number3(input2), ([_0, input3]) => [PropertyKeyNumberMapping(_0), input3]);
66688
66261
  var PropertyKeyIdent = (input2) => If(Ident(input2), ([_0, input3]) => [PropertyKeyIdentMapping(_0), input3]);
66689
66262
  var PropertyKeyQuoted = (input2) => If(String3(["'", '"'], input2), ([_0, input3]) => [PropertyKeyQuotedMapping(_0), input3]);
@@ -66691,7 +66264,7 @@ var PropertyKeyIndex = (input2) => If(If(Const("[", input2), ([_0, input3]) => I
66691
66264
  var PropertyKey = (input2) => If(If(PropertyKeyNumber(input2), ([_0, input3]) => [_0, input3], () => If(PropertyKeyIdent(input2), ([_0, input3]) => [_0, input3], () => If(PropertyKeyQuoted(input2), ([_0, input3]) => [_0, input3], () => If(PropertyKeyIndex(input2), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [PropertyKeyMapping(_0), input3]);
66692
66265
  var Readonly2 = (input2) => If(If(If(Const("readonly", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ReadonlyMapping(_0), input3]);
66693
66266
  var Optional3 = (input2) => If(If(If(Const("?", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [OptionalMapping(_0), input3]);
66694
- var Property = (input2) => If(If(Readonly2(input2), ([_0, input3]) => If(PropertyKey(input3), ([_1, input4]) => If(Optional3(input4), ([_2, input5]) => If(Const(":", input5), ([_3, input6]) => If(Type4(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [PropertyMapping(_0), input3]);
66267
+ var Property = (input2) => If(If(Readonly2(input2), ([_0, input3]) => If(PropertyKey(input3), ([_1, input4]) => If(Optional3(input4), ([_2, input5]) => If(Const(":", input5), ([_3, input6]) => If(Type2(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [PropertyMapping(_0), input3]);
66695
66268
  var PropertyDelimiter = (input2) => If(If(If(Const(",", input2), ([_0, input3]) => If(Const(`
66696
66269
  `, input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const(";", input2), ([_0, input3]) => If(Const(`
66697
66270
  `, input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const(",", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If(If(Const(";", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If(If(Const(`
@@ -66700,29 +66273,29 @@ var PropertyList_0 = (input2, result = []) => If(If(Property(input2), ([_0, inpu
66700
66273
  var PropertyList = (input2) => If(If(PropertyList_0(input2), ([_0, input3]) => If(If(If(Property(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [PropertyListMapping(_0), input3]);
66701
66274
  var Properties = (input2) => If(If(Const("{", input2), ([_0, input3]) => If(PropertyList(input3), ([_1, input4]) => If(Const("}", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [PropertiesMapping(_0), input3]);
66702
66275
  var _Object_2 = (input2) => If(Properties(input2), ([_0, input3]) => [_Object_Mapping(_0), input3]);
66703
- var ElementNamed = (input2) => If(If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Const("readonly", input5), ([_3, input6]) => If(Type4(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [_0, input3], () => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Const("readonly", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Type4(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [ElementNamedMapping(_0), input3]);
66704
- var ElementReadonlyOptional = (input2) => If(If(Const("readonly", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => If(Const("?", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [ElementReadonlyOptionalMapping(_0), input3]);
66705
- var ElementReadonly = (input2) => If(If(Const("readonly", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ElementReadonlyMapping(_0), input3]);
66706
- var ElementOptional = (input2) => If(If(Type4(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ElementOptionalMapping(_0), input3]);
66707
- var ElementBase = (input2) => If(If(ElementNamed(input2), ([_0, input3]) => [_0, input3], () => If(ElementReadonlyOptional(input2), ([_0, input3]) => [_0, input3], () => If(ElementReadonly(input2), ([_0, input3]) => [_0, input3], () => If(ElementOptional(input2), ([_0, input3]) => [_0, input3], () => If(Type4(input2), ([_0, input3]) => [_0, input3], () => []))))), ([_0, input3]) => [ElementBaseMapping(_0), input3]);
66276
+ var ElementNamed = (input2) => If(If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Const("readonly", input5), ([_3, input6]) => If(Type2(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [_0, input3], () => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Const("readonly", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [_0, input3], () => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Type2(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [ElementNamedMapping(_0), input3]);
66277
+ var ElementReadonlyOptional = (input2) => If(If(Const("readonly", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => If(Const("?", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [ElementReadonlyOptionalMapping(_0), input3]);
66278
+ var ElementReadonly = (input2) => If(If(Const("readonly", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ElementReadonlyMapping(_0), input3]);
66279
+ var ElementOptional = (input2) => If(If(Type2(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ElementOptionalMapping(_0), input3]);
66280
+ var ElementBase = (input2) => If(If(ElementNamed(input2), ([_0, input3]) => [_0, input3], () => If(ElementReadonlyOptional(input2), ([_0, input3]) => [_0, input3], () => If(ElementReadonly(input2), ([_0, input3]) => [_0, input3], () => If(ElementOptional(input2), ([_0, input3]) => [_0, input3], () => If(Type2(input2), ([_0, input3]) => [_0, input3], () => []))))), ([_0, input3]) => [ElementBaseMapping(_0), input3]);
66708
66281
  var Element = (input2) => If(If(If(Const("...", input2), ([_0, input3]) => If(ElementBase(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(ElementBase(input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ElementMapping(_0), input3]);
66709
66282
  var ElementList_0 = (input2, result = []) => If(If(Element(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => ElementList_0(input3, [...result, _0]), () => [result, input2]);
66710
66283
  var ElementList = (input2) => If(If(ElementList_0(input2), ([_0, input3]) => If(If(If(Element(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ElementListMapping(_0), input3]);
66711
66284
  var _Tuple_ = (input2) => If(If(Const("[", input2), ([_0, input3]) => If(ElementList(input3), ([_1, input4]) => If(Const("]", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [_Tuple_Mapping(_0), input3]);
66712
- var ParameterReadonlyOptional = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Const("readonly", input5), ([_3, input6]) => If(Type4(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [ParameterReadonlyOptionalMapping(_0), input3]);
66713
- var ParameterReadonly = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Const("readonly", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [ParameterReadonlyMapping(_0), input3]);
66714
- var ParameterOptional = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [ParameterOptionalMapping(_0), input3]);
66715
- var ParameterType = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Type4(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [ParameterTypeMapping(_0), input3]);
66285
+ var ParameterReadonlyOptional = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Const("readonly", input5), ([_3, input6]) => If(Type2(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [ParameterReadonlyOptionalMapping(_0), input3]);
66286
+ var ParameterReadonly = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Const("readonly", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [ParameterReadonlyMapping(_0), input3]);
66287
+ var ParameterOptional = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => If(Const(":", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [ParameterOptionalMapping(_0), input3]);
66288
+ var ParameterType = (input2) => If(If(Ident(input2), ([_0, input3]) => If(Const(":", input3), ([_1, input4]) => If(Type2(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [ParameterTypeMapping(_0), input3]);
66716
66289
  var ParameterBase = (input2) => If(If(ParameterReadonlyOptional(input2), ([_0, input3]) => [_0, input3], () => If(ParameterReadonly(input2), ([_0, input3]) => [_0, input3], () => If(ParameterOptional(input2), ([_0, input3]) => [_0, input3], () => If(ParameterType(input2), ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [ParameterBaseMapping(_0), input3]);
66717
66290
  var Parameter2 = (input2) => If(If(If(Const("...", input2), ([_0, input3]) => If(ParameterBase(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(ParameterBase(input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ParameterMapping(_0), input3]);
66718
66291
  var ParameterList_0 = (input2, result = []) => If(If(Parameter2(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => ParameterList_0(input3, [...result, _0]), () => [result, input2]);
66719
66292
  var ParameterList = (input2) => If(If(ParameterList_0(input2), ([_0, input3]) => If(If(If(Parameter2(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ParameterListMapping(_0), input3]);
66720
- var _Function_2 = (input2) => If(If(Const("(", input2), ([_0, input3]) => If(ParameterList(input3), ([_1, input4]) => If(Const(")", input4), ([_2, input5]) => If(Const("=>", input5), ([_3, input6]) => If(Type4(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [_Function_Mapping(_0), input3]);
66721
- var _Constructor_ = (input2) => If(If(Const("new", input2), ([_0, input3]) => If(Const("(", input3), ([_1, input4]) => If(ParameterList(input4), ([_2, input5]) => If(Const(")", input5), ([_3, input6]) => If(Const("=>", input6), ([_4, input7]) => If(Type4(input7), ([_5, input8]) => [[_0, _1, _2, _3, _4, _5], input8])))))), ([_0, input3]) => [_Constructor_Mapping(_0), input3]);
66293
+ var _Function_2 = (input2) => If(If(Const("(", input2), ([_0, input3]) => If(ParameterList(input3), ([_1, input4]) => If(Const(")", input4), ([_2, input5]) => If(Const("=>", input5), ([_3, input6]) => If(Type2(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [_Function_Mapping(_0), input3]);
66294
+ var _Constructor_ = (input2) => If(If(Const("new", input2), ([_0, input3]) => If(Const("(", input3), ([_1, input4]) => If(ParameterList(input4), ([_2, input5]) => If(Const(")", input5), ([_3, input6]) => If(Const("=>", input6), ([_4, input7]) => If(Type2(input7), ([_5, input8]) => [[_0, _1, _2, _3, _4, _5], input8])))))), ([_0, input3]) => [_Constructor_Mapping(_0), input3]);
66722
66295
  var MappedReadonly = (input2) => If(If(If(Const("+", input2), ([_0, input3]) => If(Const("readonly", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const("-", input2), ([_0, input3]) => If(Const("readonly", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const("readonly", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [MappedReadonlyMapping(_0), input3]);
66723
66296
  var MappedOptional = (input2) => If(If(If(Const("+", input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const("-", input2), ([_0, input3]) => If(Const("?", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const("?", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])))), ([_0, input3]) => [MappedOptionalMapping(_0), input3]);
66724
- var MappedAs = (input2) => If(If(If(Const("as", input2), ([_0, input3]) => If(Type4(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [MappedAsMapping(_0), input3]);
66725
- var _Mapped_ = (input2) => If(If(Const("{", input2), ([_0, input3]) => If(MappedReadonly(input3), ([_1, input4]) => If(Const("[", input4), ([_2, input5]) => If(Ident(input5), ([_3, input6]) => If(Const("in", input6), ([_4, input7]) => If(Type4(input7), ([_5, input8]) => If(MappedAs(input8), ([_6, input9]) => If(Const("]", input9), ([_7, input10]) => If(MappedOptional(input10), ([_8, input11]) => If(Const(":", input11), ([_9, input12]) => If(Type4(input12), ([_10, input13]) => If(OptionalSemiColon(input13), ([_11, input14]) => If(Const("}", input14), ([_12, input15]) => [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], input15]))))))))))))), ([_0, input3]) => [_Mapped_Mapping(_0), input3]);
66297
+ var MappedAs = (input2) => If(If(If(Const("as", input2), ([_0, input3]) => If(Type2(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [MappedAsMapping(_0), input3]);
66298
+ var _Mapped_ = (input2) => If(If(Const("{", input2), ([_0, input3]) => If(MappedReadonly(input3), ([_1, input4]) => If(Const("[", input4), ([_2, input5]) => If(Ident(input5), ([_3, input6]) => If(Const("in", input6), ([_4, input7]) => If(Type2(input7), ([_5, input8]) => If(MappedAs(input8), ([_6, input9]) => If(Const("]", input9), ([_7, input10]) => If(MappedOptional(input10), ([_8, input11]) => If(Const(":", input11), ([_9, input12]) => If(Type2(input12), ([_10, input13]) => If(OptionalSemiColon(input13), ([_11, input14]) => If(Const("}", input14), ([_12, input15]) => [[_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12], input15]))))))))))))), ([_0, input3]) => [_Mapped_Mapping(_0), input3]);
66726
66299
  var Reference = (input2) => If(Ident(input2), ([_0, input3]) => [ReferenceMapping(_0), input3]);
66727
66300
  var WithBigInt = (input2) => If(BigInt3(input2), ([_0, input3]) => [WithBigIntMapping(_0), input3]);
66728
66301
  var WithNumber = (input2) => If(Number3(input2), ([_0, input3]) => [WithNumberMapping(_0), input3]);
@@ -66750,13 +66323,13 @@ var PatternUnion = (input2) => If(If(If(PatternTerm(input2), ([_0, input3]) => I
66750
66323
  var PatternTerm = (input2) => If(If(PatternBase(input2), ([_0, input3]) => If(PatternBody(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [PatternTermMapping(_0), input3]);
66751
66324
  var PatternBody = (input2) => If(If(PatternUnion(input2), ([_0, input3]) => [_0, input3], () => If(PatternTerm(input2), ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [PatternBodyMapping(_0), input3]);
66752
66325
  var Pattern = (input2) => If(If(Const("^", input2), ([_0, input3]) => If(PatternBody(input3), ([_1, input4]) => If(Const("$", input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [PatternMapping(_0), input3]);
66753
- var InterfaceDeclarationHeritageList_0 = (input2, result = []) => If(If(Type4(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => InterfaceDeclarationHeritageList_0(input3, [...result, _0]), () => [result, input2]);
66754
- var InterfaceDeclarationHeritageList = (input2) => If(If(InterfaceDeclarationHeritageList_0(input2), ([_0, input3]) => If(If(If(Type4(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [InterfaceDeclarationHeritageListMapping(_0), input3]);
66326
+ var InterfaceDeclarationHeritageList_0 = (input2, result = []) => If(If(Type2(input2), ([_0, input3]) => If(Const(",", input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => InterfaceDeclarationHeritageList_0(input3, [...result, _0]), () => [result, input2]);
66327
+ var InterfaceDeclarationHeritageList = (input2) => If(If(InterfaceDeclarationHeritageList_0(input2), ([_0, input3]) => If(If(If(Type2(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [InterfaceDeclarationHeritageListMapping(_0), input3]);
66755
66328
  var InterfaceDeclarationHeritage = (input2) => If(If(If(Const("extends", input2), ([_0, input3]) => If(InterfaceDeclarationHeritageList(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [InterfaceDeclarationHeritageMapping(_0), input3]);
66756
66329
  var InterfaceDeclarationGeneric = (input2) => If(If(Const("interface", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(GenericParameters(input4), ([_2, input5]) => If(InterfaceDeclarationHeritage(input5), ([_3, input6]) => If(Properties(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [InterfaceDeclarationGenericMapping(_0), input3]);
66757
66330
  var InterfaceDeclaration = (input2) => If(If(Const("interface", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(InterfaceDeclarationHeritage(input4), ([_2, input5]) => If(Properties(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [InterfaceDeclarationMapping(_0), input3]);
66758
- var TypeAliasDeclarationGeneric = (input2) => If(If(Const("type", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(GenericParameters(input4), ([_2, input5]) => If(Const("=", input5), ([_3, input6]) => If(Type4(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [TypeAliasDeclarationGenericMapping(_0), input3]);
66759
- var TypeAliasDeclaration = (input2) => If(If(Const("type", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(Const("=", input4), ([_2, input5]) => If(Type4(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [TypeAliasDeclarationMapping(_0), input3]);
66331
+ var TypeAliasDeclarationGeneric = (input2) => If(If(Const("type", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(GenericParameters(input4), ([_2, input5]) => If(Const("=", input5), ([_3, input6]) => If(Type2(input6), ([_4, input7]) => [[_0, _1, _2, _3, _4], input7]))))), ([_0, input3]) => [TypeAliasDeclarationGenericMapping(_0), input3]);
66332
+ var TypeAliasDeclaration = (input2) => If(If(Const("type", input2), ([_0, input3]) => If(Ident(input3), ([_1, input4]) => If(Const("=", input4), ([_2, input5]) => If(Type2(input5), ([_3, input6]) => [[_0, _1, _2, _3], input6])))), ([_0, input3]) => [TypeAliasDeclarationMapping(_0), input3]);
66760
66333
  var ExportKeyword = (input2) => If(If(If(Const("export", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If([[], input2], ([_0, input3]) => [_0, input3], () => [])), ([_0, input3]) => [ExportKeywordMapping(_0), input3]);
66761
66334
  var ModuleDeclarationDelimiter = (input2) => If(If(If(Const(";", input2), ([_0, input3]) => If(Const(`
66762
66335
  `, input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [_0, input3], () => If(If(Const(";", input2), ([_0, input3]) => [[_0], input3]), ([_0, input3]) => [_0, input3], () => If(If(Const(`
@@ -66765,7 +66338,7 @@ var ModuleDeclarationList_0 = (input2, result = []) => If(If(ModuleDeclaration(i
66765
66338
  var ModuleDeclarationList = (input2) => If(If(ModuleDeclarationList_0(input2), ([_0, input3]) => If(If(If(ModuleDeclaration(input3), ([_02, input4]) => [[_02], input4]), ([_02, input4]) => [_02, input4], () => If([[], input3], ([_02, input4]) => [_02, input4], () => [])), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ModuleDeclarationListMapping(_0), input3]);
66766
66339
  var ModuleDeclaration = (input2) => If(If(ExportKeyword(input2), ([_0, input3]) => If(If(InterfaceDeclarationGeneric(input3), ([_02, input4]) => [_02, input4], () => If(InterfaceDeclaration(input3), ([_02, input4]) => [_02, input4], () => If(TypeAliasDeclarationGeneric(input3), ([_02, input4]) => [_02, input4], () => If(TypeAliasDeclaration(input3), ([_02, input4]) => [_02, input4], () => [])))), ([_1, input4]) => If(OptionalSemiColon(input4), ([_2, input5]) => [[_0, _1, _2], input5]))), ([_0, input3]) => [ModuleDeclarationMapping(_0), input3]);
66767
66340
  var Module = (input2) => If(If(ModuleDeclaration(input2), ([_0, input3]) => If(ModuleDeclarationList(input3), ([_1, input4]) => [[_0, _1], input4])), ([_0, input3]) => [ModuleMapping(_0), input3]);
66768
- var Script = (input2) => If(If(Module(input2), ([_0, input3]) => [_0, input3], () => If(GenericType(input2), ([_0, input3]) => [_0, input3], () => If(Type4(input2), ([_0, input3]) => [_0, input3], () => []))), ([_0, input3]) => [ScriptMapping(_0), input3]);
66341
+ var Script = (input2) => If(If(Module(input2), ([_0, input3]) => [_0, input3], () => If(GenericType(input2), ([_0, input3]) => [_0, input3], () => If(Type2(input2), ([_0, input3]) => [_0, input3], () => []))), ([_0, input3]) => [ScriptMapping(_0), input3]);
66769
66342
 
66770
66343
  // ../../node_modules/.bun/typebox@1.3.7/node_modules/typebox/build/type/engine/patterns/template.mjs
66771
66344
  function ParseTemplateIntoTypes(template) {
@@ -68822,14 +68395,35 @@ class WorkbenchAgentService {
68822
68395
  modelRefs = [];
68823
68396
  cwd;
68824
68397
  skillsPath;
68398
+ registryPath;
68399
+ saved;
68400
+ opening = new Map;
68401
+ runEpoch = crypto.randomUUID();
68825
68402
  constructor(config3, catalog, platform, modelRuntime, modelRefs) {
68826
68403
  this.config = config3;
68827
68404
  this.catalog = catalog;
68828
68405
  this.platform = platform;
68829
68406
  this.modelRuntime = modelRuntime;
68830
68407
  this.modelRefs = modelRefs;
68831
- this.cwd = config3.workbenchCwd;
68408
+ fs8.mkdirSync(config3.workbenchCwd, { recursive: true });
68409
+ this.cwd = fs8.realpathSync(config3.workbenchCwd);
68832
68410
  this.skillsPath = materializeKifaruSkills();
68411
+ this.registryPath = path6.join(getAgentDir(), "workbench-conversations.json");
68412
+ this.saved = fs8.existsSync(this.registryPath) ? JSON.parse(fs8.readFileSync(this.registryPath, "utf8")) : [];
68413
+ for (const saved of this.saved) {
68414
+ for (const status of ["queued", "running"]) {
68415
+ while (true) {
68416
+ const { runs: runs2 } = this.platform.listRuns(saved.actor.workspaceID, { sessionId: saved.id, status });
68417
+ if (!runs2.length)
68418
+ break;
68419
+ for (const run of runs2) {
68420
+ this.platform.transitionRun(saved.actor.workspaceID, run.id, "cancelled", {
68421
+ error: { reason: "workbench_process_interrupted" }
68422
+ });
68423
+ }
68424
+ }
68425
+ }
68426
+ }
68833
68427
  }
68834
68428
  static async create(config3, catalog, platform) {
68835
68429
  const openaiDescriptorIDs = [];
@@ -68897,9 +68491,14 @@ class WorkbenchAgentService {
68897
68491
  const selected = chosen ?? this.modelRefs[0];
68898
68492
  return `${selected.provider}/${selected.model}`;
68899
68493
  }
68900
- async listSessions() {
68494
+ async listSessions(actor) {
68901
68495
  const infos = await SessionManager.list(this.cwd);
68902
- return infos.map((info) => ({
68496
+ return infos.filter((info) => {
68497
+ if (!isSharedSessionPath(info.path))
68498
+ return false;
68499
+ const saved = this.saved.find((item) => item.sessionPath === fs8.realpathSync(info.path));
68500
+ return saved ? saved.cwd === this.cwd && saved.actor.workspaceID === actor.workspaceID : actor.workspaceID === this.config.defaultWorkspaceId;
68501
+ }).map((info) => ({
68903
68502
  id: info.id,
68904
68503
  path: info.path,
68905
68504
  title: info.name || info.firstMessage.slice(0, 80) || "Untitled session",
@@ -68922,12 +68521,14 @@ class WorkbenchAgentService {
68922
68521
  appendSystemPrompt: [WORKBENCH_SYSTEM_PROMPT]
68923
68522
  }
68924
68523
  });
68925
- const hasExistingMessages = sessionManager.buildSessionContext().messages.length > 0;
68524
+ const context2 = sessionManager.buildSessionContext();
68525
+ const recordedModel = context2.model ? this.modelRuntime.getModel(context2.model.provider, context2.model.modelId) : undefined;
68926
68526
  const session = await createAgentSessionFromServices({
68927
68527
  services,
68928
68528
  sessionManager,
68929
68529
  sessionStartEvent,
68930
- ...hasExistingMessages ? {} : { model: this.resolveModel(modelRef), thinkingLevel: "off" },
68530
+ model: recordedModel ?? this.resolveModel(modelRef),
68531
+ ...context2.messages.length ? {} : { thinkingLevel: "off" },
68931
68532
  scopedModels: this.modelRefs.map((ref3) => this.modelRuntime.getModel(ref3.provider, ref3.model)).filter((model) => Boolean(model)).map((model) => ({ model })),
68932
68533
  tools: FULL_PI_TOOLSET,
68933
68534
  customTools: [this.reportFindingTool(conversationId)]
@@ -68936,26 +68537,93 @@ class WorkbenchAgentService {
68936
68537
  };
68937
68538
  }
68938
68539
  async createConversation(actor, modelRef) {
68939
- const id = `wb-${crypto.randomUUID().slice(0, 8)}`;
68940
- const runtime = await createAgentSessionRuntime(this.makeRuntimeFactory(id, modelRef ?? ""), {
68540
+ const manager = SessionManager.create(this.cwd);
68541
+ const sessionPath = manager.getSessionFile();
68542
+ fs8.writeFileSync(sessionPath, `${JSON.stringify(manager.getHeader())}
68543
+ `, { flag: "wx", mode: 384 });
68544
+ this.remember({
68545
+ id: `wb-${crypto.randomUUID()}`,
68546
+ sessionID: manager.getSessionId(),
68547
+ sessionPath: fs8.realpathSync(sessionPath),
68941
68548
  cwd: this.cwd,
68942
- agentDir: getAgentDir(),
68943
- sessionManager: SessionManager.create(this.cwd)
68549
+ actor
68944
68550
  });
68945
- return this.adoptRuntime(id, runtime, actor, modelRef ?? null);
68551
+ return this.resumeConversation(actor, sessionPath, modelRef);
68946
68552
  }
68947
68553
  async resumeConversation(actor, sessionPath, modelRef) {
68948
68554
  if (!isSharedSessionPath(sessionPath)) {
68949
68555
  throw new Error("Session path is outside the shared session store.");
68950
68556
  }
68951
- const id = `wb-${crypto.randomUUID().slice(0, 8)}`;
68952
- const sessionManager = SessionManager.open(sessionPath, undefined, this.cwd);
68953
- const runtime = await createAgentSessionRuntime(this.makeRuntimeFactory(id, modelRef ?? ""), {
68954
- cwd: this.cwd,
68955
- agentDir: getAgentDir(),
68956
- sessionManager
68957
- });
68958
- return this.adoptRuntime(id, runtime, actor, modelRef ?? null);
68557
+ const canonical = fs8.realpathSync(sessionPath);
68558
+ let saved = this.saved.find((item) => item.sessionPath === canonical);
68559
+ if (!saved && actor.workspaceID !== this.config.defaultWorkspaceId) {
68560
+ throw new Error("This conversation belongs to another workspace.");
68561
+ }
68562
+ if (saved) {
68563
+ this.checkSavedAccess(saved, actor);
68564
+ const existing = this.conversations.get(saved.id);
68565
+ if (existing)
68566
+ return existing;
68567
+ const pending = this.opening.get(canonical);
68568
+ if (pending)
68569
+ return pending;
68570
+ }
68571
+ const sessionManager = SessionManager.open(canonical);
68572
+ if (fs8.realpathSync(sessionManager.getCwd()) !== this.cwd) {
68573
+ throw new Error("Session belongs to another working directory.");
68574
+ }
68575
+ if (!saved) {
68576
+ saved = {
68577
+ id: `wb-${crypto.randomUUID()}`,
68578
+ sessionID: sessionManager.getSessionId(),
68579
+ sessionPath: canonical,
68580
+ cwd: this.cwd,
68581
+ actor
68582
+ };
68583
+ this.remember(saved);
68584
+ }
68585
+ if (saved.sessionID !== sessionManager.getSessionId())
68586
+ throw new Error("Session identity has changed.");
68587
+ const owner = saved;
68588
+ const operation = (async () => {
68589
+ const runtime = await createAgentSessionRuntime(this.makeRuntimeFactory(owner.id, modelRef ?? ""), {
68590
+ cwd: this.cwd,
68591
+ agentDir: getAgentDir(),
68592
+ sessionManager
68593
+ });
68594
+ return this.adoptRuntime(owner.id, runtime, owner.actor, modelRef ?? null);
68595
+ })();
68596
+ this.opening.set(canonical, operation);
68597
+ try {
68598
+ return await operation;
68599
+ } finally {
68600
+ this.opening.delete(canonical);
68601
+ }
68602
+ }
68603
+ remember(saved) {
68604
+ fs8.mkdirSync(path6.dirname(this.registryPath), { recursive: true });
68605
+ const temporary = `${this.registryPath}.tmp`;
68606
+ fs8.writeFileSync(temporary, JSON.stringify([...this.saved, saved]), { mode: 384 });
68607
+ fs8.renameSync(temporary, this.registryPath);
68608
+ this.saved.push(saved);
68609
+ }
68610
+ checkSavedAccess(saved, actor) {
68611
+ if (saved.actor.workspaceID !== actor.workspaceID || saved.cwd !== this.cwd) {
68612
+ throw new Error("This conversation belongs to another workspace.");
68613
+ }
68614
+ }
68615
+ async reconnectConversation(actor, id) {
68616
+ const existing = this.conversations.get(id);
68617
+ if (existing) {
68618
+ if (!this.canAccess(existing, actor))
68619
+ throw new Error("This conversation belongs to another workspace.");
68620
+ return existing;
68621
+ }
68622
+ const saved = this.saved.find((item) => item.id === id);
68623
+ if (!saved)
68624
+ return;
68625
+ this.checkSavedAccess(saved, actor);
68626
+ return this.resumeConversation(actor, saved.sessionPath);
68959
68627
  }
68960
68628
  adoptRuntime(id, runtime, actor, modelRef) {
68961
68629
  const conversation = {
@@ -68964,7 +68632,7 @@ class WorkbenchAgentService {
68964
68632
  session: runtime.session,
68965
68633
  unsubscribe: () => {},
68966
68634
  title: "New conversation",
68967
- modelRef: this.modelRefOf(modelRef),
68635
+ modelRef: runtime.session.model ? `${runtime.session.model.provider}/${runtime.session.model.id}` : this.modelRefOf(modelRef),
68968
68636
  tools: new Map,
68969
68637
  findingCount: 0,
68970
68638
  revision: 0,
@@ -69056,10 +68724,12 @@ class WorkbenchAgentService {
69056
68724
  const chosen = this.modelRefs.find((candidate) => `${candidate.provider}/${candidate.model}` === modelRef);
69057
68725
  if (!chosen)
69058
68726
  return;
69059
- conversation.modelRef = modelRef;
68727
+ if (conversation.session.isStreaming)
68728
+ throw new Error("Cannot change models while streaming.");
69060
68729
  const model = this.resolveModel(modelRef);
69061
- if (model && !conversation.session.isStreaming) {
69062
- await conversation.session.setModel?.(model);
68730
+ if (model) {
68731
+ await conversation.session.setModel(model);
68732
+ conversation.modelRef = `${conversation.session.model.provider}/${conversation.session.model.id}`;
69063
68733
  }
69064
68734
  conversation.revision += 1;
69065
68735
  }
@@ -69075,7 +68745,7 @@ class WorkbenchAgentService {
69075
68745
  kind: "hunt",
69076
68746
  title: `Live workspace \xB7 ${conversation.title}`.slice(0, 240),
69077
68747
  configuration: { surface: "workbench", cwd: this.cwd },
69078
- idempotencyKey: `workbench-${conversation.id}-${conversation.runCycle}`
68748
+ idempotencyKey: `workbench-${conversation.id}-${this.runEpoch}-${conversation.runCycle}`
69079
68749
  });
69080
68750
  conversation.runID = run.id;
69081
68751
  this.platform.transitionRun(conversation.actor.workspaceID, run.id, "running");
@@ -69164,9 +68834,13 @@ class WorkbenchAgentService {
69164
68834
  }
69165
68835
  }
69166
68836
  function isSharedSessionPath(sessionPath) {
69167
- const resolved = path6.resolve(sessionPath);
69168
- const root = path6.resolve(getAgentDir(), "sessions");
69169
- return resolved.endsWith(".jsonl") && resolved.startsWith(root + path6.sep);
68837
+ try {
68838
+ const resolved = fs8.realpathSync(sessionPath);
68839
+ const root = fs8.realpathSync(path6.join(getAgentDir(), "sessions"));
68840
+ return resolved.endsWith(".jsonl") && resolved.startsWith(root + path6.sep) && fs8.statSync(resolved).isFile();
68841
+ } catch {
68842
+ return false;
68843
+ }
69170
68844
  }
69171
68845
  function slugify2(value) {
69172
68846
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
@@ -69253,7 +68927,7 @@ function workbenchSocketHandlers(service) {
69253
68927
  switch (message2.type) {
69254
68928
  case "attach": {
69255
68929
  const requested = message2.conversationId;
69256
- const existing = requested ? service.getConversation(requested) : undefined;
68930
+ const existing = requested ? await service.reconnectConversation(data.actor, requested) : undefined;
69257
68931
  if (requested && existing && !service.canAccess(existing, data.actor)) {
69258
68932
  send(socket, { type: "notice", level: "error", text: FOREIGN_WORKSPACE_NOTICE });
69259
68933
  return;
@@ -69261,7 +68935,7 @@ function workbenchSocketHandlers(service) {
69261
68935
  const conversation = existing ?? await service.createConversation(data.actor);
69262
68936
  attach(socket, data, conversation);
69263
68937
  send(socket, { type: "models", models: service.listModels() });
69264
- send(socket, { type: "sessions", items: await service.listSessions() });
68938
+ send(socket, { type: "sessions", items: await service.listSessions(data.actor) });
69265
68939
  if (requested && !existing) {
69266
68940
  send(socket, {
69267
68941
  type: "notice",
@@ -69273,7 +68947,7 @@ function workbenchSocketHandlers(service) {
69273
68947
  }
69274
68948
  case "new_conversation": {
69275
68949
  attach(socket, data, await service.createConversation(data.actor));
69276
- send(socket, { type: "sessions", items: await service.listSessions() });
68950
+ send(socket, { type: "sessions", items: await service.listSessions(data.actor) });
69277
68951
  break;
69278
68952
  }
69279
68953
  case "resume_session": {
@@ -69281,7 +68955,7 @@ function workbenchSocketHandlers(service) {
69281
68955
  break;
69282
68956
  }
69283
68957
  case "list_sessions": {
69284
- send(socket, { type: "sessions", items: await service.listSessions() });
68958
+ send(socket, { type: "sessions", items: await service.listSessions(data.actor) });
69285
68959
  break;
69286
68960
  }
69287
68961
  case "prompt":
@@ -69318,7 +68992,7 @@ var catalog = loadModelCatalog(config3);
69318
68992
  var storage = createSqliteStorage(config3.sessionDbPath);
69319
68993
  var workbench = config3.workbenchCwd ? await createWorkbench() : undefined;
69320
68994
  async function createWorkbench() {
69321
- fs8.mkdirSync(config3.workbenchCwd, { recursive: true });
68995
+ fs9.mkdirSync(config3.workbenchCwd, { recursive: true });
69322
68996
  try {
69323
68997
  const service = await WorkbenchAgentService.create(config3, catalog, createPlatformRepository(storage.db));
69324
68998
  console.log(`[session-gateway] live workspace enabled at ${config3.workbenchCwd}`);