@gajae-code/coding-agent 0.3.1 → 0.4.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.
- package/CHANGELOG.md +46 -0
- package/README.md +1 -1
- package/dist/types/cli/args.d.ts +2 -0
- package/dist/types/commands/launch.d.ts +6 -0
- package/dist/types/config/model-profile-activation.d.ts +30 -0
- package/dist/types/config/model-profiles.d.ts +19 -0
- package/dist/types/config/model-registry.d.ts +25 -10
- package/dist/types/config/model-resolver.d.ts +1 -1
- package/dist/types/config/models-config-schema.d.ts +84 -0
- package/dist/types/config/settings-schema.d.ts +15 -0
- package/dist/types/edit/diff.d.ts +16 -0
- package/dist/types/edit/modes/replace.d.ts +7 -0
- package/dist/types/extensibility/gjc-plugins/activation.d.ts +14 -0
- package/dist/types/extensibility/gjc-plugins/index.d.ts +9 -0
- package/dist/types/extensibility/gjc-plugins/injection.d.ts +31 -0
- package/dist/types/extensibility/gjc-plugins/loader.d.ts +3 -0
- package/dist/types/extensibility/gjc-plugins/paths.d.ts +8 -0
- package/dist/types/extensibility/gjc-plugins/schema.d.ts +3 -0
- package/dist/types/extensibility/gjc-plugins/state.d.ts +9 -0
- package/dist/types/extensibility/gjc-plugins/tools.d.ts +8 -0
- package/dist/types/extensibility/gjc-plugins/types.d.ts +64 -0
- package/dist/types/extensibility/gjc-plugins/validation.d.ts +4 -0
- package/dist/types/extensibility/skills.d.ts +9 -1
- package/dist/types/gjc-runtime/state-runtime.d.ts +22 -0
- package/dist/types/harness-control-plane/storage.d.ts +7 -0
- package/dist/types/lsp/client.d.ts +1 -0
- package/dist/types/main.d.ts +10 -1
- package/dist/types/modes/bridge/bridge-mode.d.ts +2 -0
- package/dist/types/modes/components/custom-provider-wizard.d.ts +10 -0
- package/dist/types/modes/components/model-selector.d.ts +6 -1
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +1 -1
- package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +2 -2
- package/dist/types/modes/rpc/rpc-client.d.ts +9 -1
- package/dist/types/modes/rpc/rpc-types.d.ts +179 -2
- package/dist/types/modes/shared/agent-wire/approval-gate.d.ts +57 -0
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +16 -1
- package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +47 -0
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +7 -0
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +11 -1
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +3 -1
- package/dist/types/modes/shared/agent-wire/responses.d.ts +1 -1
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +27 -0
- package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +68 -0
- package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +161 -0
- package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +61 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +114 -0
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +39 -0
- package/dist/types/modes/theme/theme.d.ts +2 -1
- package/dist/types/modes/types.d.ts +1 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +0 -4
- package/dist/types/sdk.d.ts +8 -1
- package/dist/types/session/agent-session.d.ts +10 -0
- package/dist/types/session/blob-store.d.ts +17 -0
- package/dist/types/session/messages.d.ts +3 -0
- package/dist/types/session/session-storage.d.ts +6 -0
- package/dist/types/skill-state/active-state.d.ts +13 -0
- package/dist/types/task/executor.d.ts +1 -0
- package/dist/types/thinking.d.ts +3 -2
- package/dist/types/tools/hindsight-recall.d.ts +0 -2
- package/dist/types/tools/hindsight-reflect.d.ts +0 -2
- package/dist/types/tools/hindsight-retain.d.ts +0 -2
- package/dist/types/tools/index.d.ts +7 -4
- package/package.json +9 -7
- package/src/cli/args.ts +10 -0
- package/src/cli.ts +14 -0
- package/src/commands/harness.ts +192 -7
- package/src/commands/launch.ts +8 -0
- package/src/commands/ultragoal.ts +1 -21
- package/src/config/model-equivalence.ts +1 -1
- package/src/config/model-profile-activation.ts +157 -0
- package/src/config/model-profiles.ts +155 -0
- package/src/config/model-registry.ts +51 -5
- package/src/config/model-resolver.ts +3 -2
- package/src/config/models-config-schema.ts +42 -1
- package/src/config/settings-schema.ts +14 -1
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +11 -1
- package/src/defaults/gjc/skills/ultragoal/ai-slop-cleaner.md +61 -0
- package/src/defaults/gjc-defaults.ts +7 -0
- package/src/discovery/claude-plugins.ts +25 -5
- package/src/edit/diff.ts +64 -1
- package/src/edit/modes/replace.ts +60 -2
- package/src/extensibility/gjc-plugins/activation.ts +87 -0
- package/src/extensibility/gjc-plugins/index.ts +9 -0
- package/src/extensibility/gjc-plugins/injection.ts +114 -0
- package/src/extensibility/gjc-plugins/loader.ts +131 -0
- package/src/extensibility/gjc-plugins/paths.ts +66 -0
- package/src/extensibility/gjc-plugins/schema.ts +79 -0
- package/src/extensibility/gjc-plugins/state.ts +29 -0
- package/src/extensibility/gjc-plugins/tools.ts +47 -0
- package/src/extensibility/gjc-plugins/types.ts +97 -0
- package/src/extensibility/gjc-plugins/validation.ts +76 -0
- package/src/extensibility/skills.ts +39 -7
- package/src/gjc-runtime/state-runtime.ts +93 -2
- package/src/gjc-runtime/state-writer.ts +17 -1
- package/src/gjc-runtime/ultragoal-runtime.ts +62 -2
- package/src/gjc-runtime/workflow-manifest.generated.json +5 -0
- package/src/gjc-runtime/workflow-manifest.ts +2 -2
- package/src/harness-control-plane/storage.ts +144 -2
- package/src/hashline/hash.ts +23 -0
- package/src/hooks/skill-state.ts +2 -0
- package/src/internal-urls/docs-index.generated.ts +8 -11
- package/src/lsp/client.ts +7 -0
- package/src/main.ts +67 -1
- package/src/modes/acp/acp-agent.ts +25 -2
- package/src/modes/bridge/bridge-mode.ts +124 -2
- package/src/modes/components/custom-provider-wizard.ts +318 -0
- package/src/modes/components/model-selector.ts +108 -18
- package/src/modes/components/provider-onboarding-selector.ts +6 -1
- package/src/modes/controllers/input-controller.ts +14 -2
- package/src/modes/controllers/selector-controller.ts +57 -1
- package/src/modes/prompt-action-autocomplete.ts +49 -10
- package/src/modes/rpc/rpc-client.ts +57 -3
- package/src/modes/rpc/rpc-mode.ts +67 -0
- package/src/modes/rpc/rpc-types.ts +224 -2
- package/src/modes/shared/agent-wire/approval-gate.ts +151 -0
- package/src/modes/shared/agent-wire/command-dispatch.ts +97 -4
- package/src/modes/shared/agent-wire/command-validation.ts +25 -1
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +222 -0
- package/src/modes/shared/agent-wire/event-envelope.ts +13 -0
- package/src/modes/shared/agent-wire/handshake.ts +43 -3
- package/src/modes/shared/agent-wire/protocol.ts +7 -0
- package/src/modes/shared/agent-wire/responses.ts +2 -2
- package/src/modes/shared/agent-wire/scopes.ts +2 -0
- package/src/modes/shared/agent-wire/unattended-action-policy.ts +341 -0
- package/src/modes/shared/agent-wire/unattended-audit.ts +175 -0
- package/src/modes/shared/agent-wire/unattended-run-controller.ts +406 -0
- package/src/modes/shared/agent-wire/unattended-session.ts +180 -0
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +324 -0
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +331 -0
- package/src/modes/theme/theme.ts +6 -0
- package/src/modes/types.ts +1 -0
- package/src/prompts/memories/consolidation.md +1 -1
- package/src/prompts/memories/read-path.md +6 -7
- package/src/prompts/memories/unavailable.md +2 -2
- package/src/prompts/tools/bash.md +1 -1
- package/src/prompts/tools/irc.md +1 -1
- package/src/prompts/tools/read.md +2 -2
- package/src/prompts/tools/recall.md +1 -0
- package/src/prompts/tools/reflect.md +1 -0
- package/src/prompts/tools/retain.md +1 -0
- package/src/runtime-mcp/client.ts +7 -4
- package/src/runtime-mcp/manager.ts +45 -13
- package/src/runtime-mcp/transports/http.ts +40 -14
- package/src/runtime-mcp/transports/stdio.ts +11 -10
- package/src/sdk.ts +48 -1
- package/src/session/agent-session.ts +211 -2
- package/src/session/blob-store.ts +84 -0
- package/src/session/messages.ts +3 -0
- package/src/session/session-manager.ts +390 -33
- package/src/session/session-storage.ts +26 -0
- package/src/setup/provider-onboarding.ts +2 -2
- package/src/skill-state/active-state.ts +89 -1
- package/src/slash-commands/builtin-registry.ts +1 -1
- package/src/task/discovery.ts +7 -1
- package/src/task/executor.ts +18 -2
- package/src/task/index.ts +2 -0
- package/src/thinking.ts +8 -2
- package/src/tools/ask.ts +39 -9
- package/src/tools/hindsight-recall.ts +0 -2
- package/src/tools/hindsight-reflect.ts +0 -2
- package/src/tools/hindsight-retain.ts +0 -2
- package/src/tools/index.ts +7 -18
- package/src/tools/read.ts +3 -3
- package/src/tools/skill.ts +15 -3
- package/src/utils/edit-mode.ts +1 -1
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
Text,
|
|
13
13
|
type TUI,
|
|
14
14
|
} from "@gajae-code/tui";
|
|
15
|
+
import type { ModelProfileDefinition } from "../../config/model-profiles";
|
|
15
16
|
import type { GjcModelAssignmentTargetId, ModelRegistry } from "../../config/model-registry";
|
|
16
17
|
import { GJC_MODEL_ASSIGNMENT_TARGET_IDS, GJC_MODEL_ASSIGNMENT_TARGETS } from "../../config/model-registry";
|
|
17
18
|
import {
|
|
@@ -74,6 +75,12 @@ interface CanonicalModelItem {
|
|
|
74
75
|
explicitThinkingLevel?: boolean;
|
|
75
76
|
}
|
|
76
77
|
|
|
78
|
+
interface ProfileItem {
|
|
79
|
+
kind: "profile";
|
|
80
|
+
name: string;
|
|
81
|
+
profile: ModelProfileDefinition;
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
type ScopedModelItem = ScopedModelSelection;
|
|
78
85
|
|
|
79
86
|
interface RoleAssignment {
|
|
@@ -102,6 +109,11 @@ export type ModelSelectorSelection =
|
|
|
102
109
|
selector: string;
|
|
103
110
|
preset: ModelAssignmentPreset;
|
|
104
111
|
assignments: Record<GjcModelAssignmentTargetId, ThinkingLevel>;
|
|
112
|
+
}
|
|
113
|
+
| {
|
|
114
|
+
kind: "profile";
|
|
115
|
+
profileName: string;
|
|
116
|
+
setDefault: boolean;
|
|
105
117
|
};
|
|
106
118
|
|
|
107
119
|
interface PendingThinkingChoice {
|
|
@@ -110,7 +122,7 @@ interface PendingThinkingChoice {
|
|
|
110
122
|
levels: ThinkingLevel[];
|
|
111
123
|
}
|
|
112
124
|
|
|
113
|
-
type RoleSelectCallback = (selection: ModelSelectorSelection) => void
|
|
125
|
+
type RoleSelectCallback = (selection: ModelSelectorSelection) => void | Promise<void>;
|
|
114
126
|
type CancelCallback = () => void;
|
|
115
127
|
|
|
116
128
|
interface ProviderTabState {
|
|
@@ -161,6 +173,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
161
173
|
#filteredModels: ModelItem[] = [];
|
|
162
174
|
#canonicalModels: CanonicalModelItem[] = [];
|
|
163
175
|
#filteredCanonicalModels: CanonicalModelItem[] = [];
|
|
176
|
+
#profileItems: ProfileItem[] = [];
|
|
164
177
|
#selectedIndex: number = 0;
|
|
165
178
|
#roles = {} as Record<string, RoleAssignment | undefined>;
|
|
166
179
|
#settings = null as unknown as Settings;
|
|
@@ -228,7 +241,11 @@ export class ModelSelectorComponent extends Container {
|
|
|
228
241
|
this.#searchInput.onSubmit = () => {
|
|
229
242
|
const selectedItem = this.#getSelectedItem();
|
|
230
243
|
if (selectedItem) {
|
|
231
|
-
|
|
244
|
+
if (selectedItem.kind === "profile") {
|
|
245
|
+
this.#beginProfileActionMenu(selectedItem);
|
|
246
|
+
} else {
|
|
247
|
+
this.#beginActionMenuOrSelect(selectedItem);
|
|
248
|
+
}
|
|
232
249
|
}
|
|
233
250
|
};
|
|
234
251
|
this.addChild(this.#searchInput);
|
|
@@ -465,11 +482,18 @@ export class ModelSelectorComponent extends Container {
|
|
|
465
482
|
|
|
466
483
|
this.#sortModels(models);
|
|
467
484
|
this.#sortCanonicalModels(canonicalModels);
|
|
485
|
+
const profiles = this.#modelRegistry.getModelProfiles?.() ?? new Map();
|
|
486
|
+
const profileItems = this.#temporaryOnly
|
|
487
|
+
? []
|
|
488
|
+
: [...profiles.values()]
|
|
489
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
490
|
+
.map(profile => ({ kind: "profile" as const, name: profile.name, profile }));
|
|
468
491
|
|
|
469
492
|
this.#allModels = models;
|
|
470
493
|
this.#filteredModels = models;
|
|
471
494
|
this.#canonicalModels = canonicalModels;
|
|
472
495
|
this.#filteredCanonicalModels = canonicalModels;
|
|
496
|
+
this.#profileItems = profileItems;
|
|
473
497
|
this.#selectedIndex = Math.min(this.#selectedIndex, Math.max(0, models.length - 1));
|
|
474
498
|
}
|
|
475
499
|
|
|
@@ -664,20 +688,40 @@ export class ModelSelectorComponent extends Container {
|
|
|
664
688
|
}
|
|
665
689
|
}
|
|
666
690
|
|
|
691
|
+
#getVisibleProfiles(): ProfileItem[] {
|
|
692
|
+
return !this.#temporaryOnly && !this.#isCanonicalTab() && this.#getActiveTabId() === ALL_TAB
|
|
693
|
+
? this.#profileItems
|
|
694
|
+
: [];
|
|
695
|
+
}
|
|
696
|
+
|
|
667
697
|
#updateList(): void {
|
|
668
698
|
this.#listContainer.clear();
|
|
669
699
|
const isCanonicalTab = this.#isCanonicalTab();
|
|
700
|
+
const visibleProfiles = this.#getVisibleProfiles();
|
|
701
|
+
const modelSelectedIndex = Math.max(0, this.#selectedIndex - visibleProfiles.length);
|
|
670
702
|
const visibleItems = isCanonicalTab ? this.#filteredCanonicalModels : this.#filteredModels;
|
|
671
703
|
|
|
672
704
|
const maxVisible = 10;
|
|
673
705
|
const startIndex = Math.max(
|
|
674
706
|
0,
|
|
675
|
-
Math.min(
|
|
707
|
+
Math.min(modelSelectedIndex - Math.floor(maxVisible / 2), visibleItems.length - maxVisible),
|
|
676
708
|
);
|
|
677
709
|
const endIndex = Math.min(startIndex + maxVisible, visibleItems.length);
|
|
678
710
|
|
|
679
711
|
const showProvider = this.#getActiveTabId() === ALL_TAB;
|
|
680
712
|
|
|
713
|
+
if (visibleProfiles.length > 0) {
|
|
714
|
+
this.#listContainer.addChild(new Text(theme.fg("muted", "Profiles"), 0, 0));
|
|
715
|
+
for (let i = 0; i < visibleProfiles.length; i++) {
|
|
716
|
+
const profile = visibleProfiles[i];
|
|
717
|
+
if (!profile) continue;
|
|
718
|
+
const isSelected = i === this.#selectedIndex;
|
|
719
|
+
const prefix = isSelected ? theme.fg("accent", `${theme.nav.cursor} `) : " ";
|
|
720
|
+
const label = isSelected ? theme.fg("accent", profile.name) : profile.name;
|
|
721
|
+
this.#listContainer.addChild(new Text(`${prefix}${label}`, 0, 0));
|
|
722
|
+
}
|
|
723
|
+
this.#listContainer.addChild(new Spacer(1));
|
|
724
|
+
}
|
|
681
725
|
// Show visible slice of filtered models
|
|
682
726
|
for (let i = startIndex; i < endIndex; i++) {
|
|
683
727
|
const item = visibleItems[i];
|
|
@@ -685,7 +729,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
685
729
|
const canonicalItem = isCanonicalTab ? (item as CanonicalModelItem) : undefined;
|
|
686
730
|
const providerItem = isCanonicalTab ? undefined : (item as ModelItem);
|
|
687
731
|
|
|
688
|
-
const isSelected = i === this.#selectedIndex;
|
|
732
|
+
const isSelected = i + visibleProfiles.length === this.#selectedIndex;
|
|
689
733
|
|
|
690
734
|
// Build role badges (inverted: color as background, black text)
|
|
691
735
|
const roleBadgeTokens: string[] = [];
|
|
@@ -742,7 +786,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
742
786
|
for (const line of errorLines) {
|
|
743
787
|
this.#listContainer.addChild(new Text(theme.fg("error", line), 0, 0));
|
|
744
788
|
}
|
|
745
|
-
} else if (visibleItems.length === 0) {
|
|
789
|
+
} else if (visibleItems.length === 0 && visibleProfiles.length === 0) {
|
|
746
790
|
const statusMessage = this.#getProviderEmptyStateMessage();
|
|
747
791
|
this.#listContainer.addChild(
|
|
748
792
|
new Text(
|
|
@@ -751,8 +795,13 @@ export class ModelSelectorComponent extends Container {
|
|
|
751
795
|
0,
|
|
752
796
|
),
|
|
753
797
|
);
|
|
798
|
+
} else if (this.#selectedIndex < visibleProfiles.length) {
|
|
799
|
+
const selectedProfile = visibleProfiles[this.#selectedIndex];
|
|
800
|
+
if (selectedProfile && this.#pendingActionItem) {
|
|
801
|
+
this.#renderProfileActionMenu(selectedProfile);
|
|
802
|
+
}
|
|
754
803
|
} else {
|
|
755
|
-
const selected = visibleItems[
|
|
804
|
+
const selected = visibleItems[modelSelectedIndex];
|
|
756
805
|
if (!selected) {
|
|
757
806
|
return;
|
|
758
807
|
}
|
|
@@ -806,6 +855,20 @@ export class ModelSelectorComponent extends Container {
|
|
|
806
855
|
}
|
|
807
856
|
}
|
|
808
857
|
|
|
858
|
+
#renderProfileActionMenu(profile: ProfileItem): void {
|
|
859
|
+
this.#listContainer.addChild(new Spacer(1));
|
|
860
|
+
this.#listContainer.addChild(new Text(theme.fg("muted", ` Action for profile: ${profile.name}`), 0, 0));
|
|
861
|
+
this.#listContainer.addChild(new Spacer(1));
|
|
862
|
+
const labels = ["Apply for this session", "Set as default"];
|
|
863
|
+
for (let i = 0; i < labels.length; i++) {
|
|
864
|
+
const label = labels[i] ?? "";
|
|
865
|
+
const prefix = i === this.#selectedActionIndex ? theme.fg("accent", `${theme.nav.cursor} `) : " ";
|
|
866
|
+
this.#listContainer.addChild(
|
|
867
|
+
new Text(`${prefix}${i === this.#selectedActionIndex ? theme.fg("accent", label) : label}`, 0, 0),
|
|
868
|
+
);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
|
|
809
872
|
#getCurrentRoleThinkingLevel(role: string): ThinkingLevel {
|
|
810
873
|
return this.#roles[role]?.thinkingLevel ?? ThinkingLevel.Inherit;
|
|
811
874
|
}
|
|
@@ -813,10 +876,11 @@ export class ModelSelectorComponent extends Container {
|
|
|
813
876
|
return GJC_MODEL_ASSIGNMENT_TARGET_IDS.length + (supportsOpenAICodexPreset(model) ? 1 : 0);
|
|
814
877
|
}
|
|
815
878
|
|
|
816
|
-
#getSelectedItem(): ModelItem | CanonicalModelItem | undefined {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
879
|
+
#getSelectedItem(): ModelItem | CanonicalModelItem | ProfileItem | undefined {
|
|
880
|
+
const visibleProfiles = this.#getVisibleProfiles();
|
|
881
|
+
if (this.#selectedIndex < visibleProfiles.length) return visibleProfiles[this.#selectedIndex];
|
|
882
|
+
const modelIndex = this.#selectedIndex - visibleProfiles.length;
|
|
883
|
+
return this.#isCanonicalTab() ? this.#filteredCanonicalModels[modelIndex] : this.#filteredModels[modelIndex];
|
|
820
884
|
}
|
|
821
885
|
|
|
822
886
|
handleInput(keyData: string): void {
|
|
@@ -836,7 +900,9 @@ export class ModelSelectorComponent extends Container {
|
|
|
836
900
|
|
|
837
901
|
// Up arrow - navigate list (wrap to bottom when at top)
|
|
838
902
|
if (matchesKey(keyData, "up")) {
|
|
839
|
-
const itemCount =
|
|
903
|
+
const itemCount =
|
|
904
|
+
this.#getVisibleProfiles().length +
|
|
905
|
+
(this.#isCanonicalTab() ? this.#filteredCanonicalModels.length : this.#filteredModels.length);
|
|
840
906
|
if (itemCount === 0) return;
|
|
841
907
|
this.#selectedIndex = this.#selectedIndex === 0 ? itemCount - 1 : this.#selectedIndex - 1;
|
|
842
908
|
this.#updateList();
|
|
@@ -845,7 +911,9 @@ export class ModelSelectorComponent extends Container {
|
|
|
845
911
|
|
|
846
912
|
// Down arrow - navigate list (wrap to top when at bottom)
|
|
847
913
|
if (matchesKey(keyData, "down")) {
|
|
848
|
-
const itemCount =
|
|
914
|
+
const itemCount =
|
|
915
|
+
this.#getVisibleProfiles().length +
|
|
916
|
+
(this.#isCanonicalTab() ? this.#filteredCanonicalModels.length : this.#filteredModels.length);
|
|
849
917
|
if (itemCount === 0) return;
|
|
850
918
|
this.#selectedIndex = this.#selectedIndex === itemCount - 1 ? 0 : this.#selectedIndex + 1;
|
|
851
919
|
this.#updateList();
|
|
@@ -857,7 +925,11 @@ export class ModelSelectorComponent extends Container {
|
|
|
857
925
|
if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
|
|
858
926
|
const selectedItem = this.#getSelectedItem();
|
|
859
927
|
if (selectedItem) {
|
|
860
|
-
|
|
928
|
+
if (selectedItem.kind === "profile") {
|
|
929
|
+
this.#beginProfileActionMenu(selectedItem);
|
|
930
|
+
} else {
|
|
931
|
+
this.#beginActionMenuOrSelect(selectedItem);
|
|
932
|
+
}
|
|
861
933
|
}
|
|
862
934
|
return;
|
|
863
935
|
}
|
|
@@ -872,6 +944,12 @@ export class ModelSelectorComponent extends Container {
|
|
|
872
944
|
this.#searchInput.handleInput(keyData);
|
|
873
945
|
this.#filterModels(this.#searchInput.getValue());
|
|
874
946
|
}
|
|
947
|
+
#beginProfileActionMenu(profile: ProfileItem): void {
|
|
948
|
+
this.#pendingActionItem = profile as unknown as ModelItem;
|
|
949
|
+
this.#selectedActionIndex = 0;
|
|
950
|
+
this.#updateList();
|
|
951
|
+
}
|
|
952
|
+
|
|
875
953
|
#beginActionMenuOrSelect(item: ModelItem | CanonicalModelItem): void {
|
|
876
954
|
if (this.#temporaryOnly) {
|
|
877
955
|
this.#handleSelect(item, null);
|
|
@@ -885,7 +963,7 @@ export class ModelSelectorComponent extends Container {
|
|
|
885
963
|
#handleActionMenuInput(keyData: string): void {
|
|
886
964
|
const item = this.#pendingActionItem;
|
|
887
965
|
if (!item) return;
|
|
888
|
-
const actionCount = this.#getActionCount(item.model);
|
|
966
|
+
const actionCount = (item as unknown as ProfileItem).kind === "profile" ? 2 : this.#getActionCount(item.model);
|
|
889
967
|
if (matchesKey(keyData, "up")) {
|
|
890
968
|
this.#selectedActionIndex = this.#selectedActionIndex === 0 ? actionCount - 1 : this.#selectedActionIndex - 1;
|
|
891
969
|
this.#updateList();
|
|
@@ -898,11 +976,20 @@ export class ModelSelectorComponent extends Container {
|
|
|
898
976
|
}
|
|
899
977
|
if (matchesKey(keyData, "enter") || matchesKey(keyData, "return") || keyData === "\n") {
|
|
900
978
|
this.#pendingActionItem = undefined;
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
this.#
|
|
979
|
+
if ((item as unknown as ProfileItem).kind === "profile") {
|
|
980
|
+
const profile = item as unknown as ProfileItem;
|
|
981
|
+
this.#onSelectCallback({
|
|
982
|
+
kind: "profile",
|
|
983
|
+
profileName: profile.name,
|
|
984
|
+
setDefault: this.#selectedActionIndex === 1,
|
|
985
|
+
});
|
|
904
986
|
} else {
|
|
905
|
-
this.#
|
|
987
|
+
const role = GJC_MODEL_ASSIGNMENT_TARGET_IDS[this.#selectedActionIndex];
|
|
988
|
+
if (role) {
|
|
989
|
+
this.#handleSelect(item, role);
|
|
990
|
+
} else {
|
|
991
|
+
this.#handlePresetSelect(item, OPENAI_CODE_PROFILE_PRESET);
|
|
992
|
+
}
|
|
906
993
|
}
|
|
907
994
|
return;
|
|
908
995
|
}
|
|
@@ -1004,6 +1091,9 @@ export class ModelSelectorComponent extends Container {
|
|
|
1004
1091
|
getSearchInput(): Input {
|
|
1005
1092
|
return this.#searchInput;
|
|
1006
1093
|
}
|
|
1094
|
+
async __testSelectProfile(profileName: string, setDefault: boolean): Promise<void> {
|
|
1095
|
+
await this.#onSelectCallback({ kind: "profile", profileName, setDefault });
|
|
1096
|
+
}
|
|
1007
1097
|
}
|
|
1008
1098
|
|
|
1009
1099
|
function requiresExplicitThinkingChoice(model: Model): boolean {
|
|
@@ -4,7 +4,7 @@ import { matchesSelectCancel } from "../../modes/utils/keybinding-matchers";
|
|
|
4
4
|
import { formatModelOnboardingGuidance } from "../../setup/model-onboarding-guidance";
|
|
5
5
|
import { DynamicBorder } from "./dynamic-border";
|
|
6
6
|
|
|
7
|
-
export type ProviderOnboardingAction = "oauth-login" | "api-guide";
|
|
7
|
+
export type ProviderOnboardingAction = "custom-provider-wizard" | "oauth-login" | "api-guide";
|
|
8
8
|
|
|
9
9
|
interface ProviderOnboardingOption {
|
|
10
10
|
label: string;
|
|
@@ -13,6 +13,11 @@ interface ProviderOnboardingOption {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const PROVIDER_ONBOARDING_OPTIONS: ProviderOnboardingOption[] = [
|
|
16
|
+
{
|
|
17
|
+
label: "Add custom provider",
|
|
18
|
+
description: "Configure an OpenAI- or Anthropic-compatible API provider interactively.",
|
|
19
|
+
action: "custom-provider-wizard",
|
|
20
|
+
},
|
|
16
21
|
{
|
|
17
22
|
label: "Login with OAuth/subscription",
|
|
18
23
|
description: "Open the interactive OAuth provider selector.",
|
|
@@ -4,6 +4,7 @@ import { type AgentMessage, ThinkingLevel } from "@gajae-code/agent-core";
|
|
|
4
4
|
import type { AutocompleteProvider, SlashCommand } from "@gajae-code/tui";
|
|
5
5
|
import { $env, sanitizeText } from "@gajae-code/utils";
|
|
6
6
|
import { isSettingsInitialized, settings } from "../../config/settings";
|
|
7
|
+
import { resolveSubskillActivationForSkillInvocation } from "../../extensibility/gjc-plugins";
|
|
7
8
|
import { buildSkillPromptMessage, parseSkillInvocations } from "../../extensibility/skills";
|
|
8
9
|
import { expandEmoticons } from "../../modes/emoji-autocomplete";
|
|
9
10
|
import { createPromptActionAutocompleteProvider } from "../../modes/prompt-action-autocomplete";
|
|
@@ -472,9 +473,20 @@ export class InputController {
|
|
|
472
473
|
for (let index = 0; index < invocations.length; index += 1) {
|
|
473
474
|
const invocation = invocations[index];
|
|
474
475
|
if (!invocation) continue;
|
|
475
|
-
const
|
|
476
|
+
const activationResult = await resolveSubskillActivationForSkillInvocation({
|
|
477
|
+
cwd: this.ctx.sessionManager.getCwd(),
|
|
478
|
+
sessionId: this.ctx.session.sessionId,
|
|
479
|
+
skillName: invocation.skill.name,
|
|
480
|
+
args: invocation.args,
|
|
481
|
+
});
|
|
482
|
+
const built = await buildSkillPromptMessage(invocation.skill, activationResult.cleanedArgs, {
|
|
483
|
+
subskillActivation: activationResult.activation,
|
|
484
|
+
subskillActivationSet: activationResult.activeSubskillsToPersist,
|
|
485
|
+
cwd: this.ctx.sessionManager.getCwd(),
|
|
486
|
+
sessionId: this.ctx.session.sessionId,
|
|
487
|
+
});
|
|
476
488
|
const details: SkillPromptDetails = built.details;
|
|
477
|
-
const displayText = `/${invocation.commandName}${
|
|
489
|
+
const displayText = `/${invocation.commandName}${activationResult.cleanedArgs ? ` ${activationResult.cleanedArgs}` : ""}`;
|
|
478
490
|
// When the agent is streaming, register a compact slash-form text as
|
|
479
491
|
// the pending-display twin BEFORE dispatching the CustomMessage. The
|
|
480
492
|
// returned tag is embedded in details so AgentSession.#handleAgentEvent
|
|
@@ -4,6 +4,7 @@ import type { OAuthProvider } from "@gajae-code/ai/utils/oauth/types";
|
|
|
4
4
|
import type { Component, OverlayHandle } from "@gajae-code/tui";
|
|
5
5
|
import { Input, Loader, Spacer, Text } from "@gajae-code/tui";
|
|
6
6
|
import { getAgentDbPath, getProjectDir } from "@gajae-code/utils";
|
|
7
|
+
import { activateModelProfile } from "../../config/model-profile-activation";
|
|
7
8
|
import { settings } from "../../config/settings";
|
|
8
9
|
import { DebugSelectorComponent } from "../../debug";
|
|
9
10
|
import { disableProvider, enableProvider } from "../../discovery";
|
|
@@ -35,10 +36,12 @@ import {
|
|
|
35
36
|
MODEL_ONBOARDING_PROVIDER_PRESET_COMMAND,
|
|
36
37
|
MODEL_ONBOARDING_SETUP_COMMAND,
|
|
37
38
|
} from "../../setup/model-onboarding-guidance";
|
|
39
|
+
import { addApiCompatibleProvider, formatProviderSetupResult } from "../../setup/provider-onboarding";
|
|
38
40
|
import { isSearchProviderPreference, setPreferredImageProvider, setPreferredSearchProvider } from "../../tools";
|
|
39
41
|
import { setSessionTerminalTitle } from "../../utils/title-generator";
|
|
40
42
|
import { AgentDashboard } from "../components/agent-dashboard";
|
|
41
43
|
import { AssistantMessageComponent } from "../components/assistant-message";
|
|
44
|
+
import { CustomProviderWizardComponent, type CustomProviderWizardSubmit } from "../components/custom-provider-wizard";
|
|
42
45
|
import { ExtensionDashboard } from "../components/extensions";
|
|
43
46
|
import { HistorySearchComponent } from "../components/history-search";
|
|
44
47
|
import { JobsOverlayComponent } from "../components/jobs-overlay";
|
|
@@ -119,7 +122,9 @@ export class SelectorController {
|
|
|
119
122
|
const selector = new ProviderOnboardingSelectorComponent(
|
|
120
123
|
(action: ProviderOnboardingAction) => {
|
|
121
124
|
done();
|
|
122
|
-
if (action === "
|
|
125
|
+
if (action === "custom-provider-wizard") {
|
|
126
|
+
this.showCustomProviderWizard();
|
|
127
|
+
} else if (action === "oauth-login") {
|
|
123
128
|
void this.showOAuthSelector("login");
|
|
124
129
|
} else {
|
|
125
130
|
this.ctx.showStatus(formatProviderOnboardingCommandGuide());
|
|
@@ -134,6 +139,36 @@ export class SelectorController {
|
|
|
134
139
|
});
|
|
135
140
|
}
|
|
136
141
|
|
|
142
|
+
showCustomProviderWizard(): void {
|
|
143
|
+
this.showSelector(done => {
|
|
144
|
+
let wizard: CustomProviderWizardComponent;
|
|
145
|
+
const submit = async (input: CustomProviderWizardSubmit): Promise<void> => {
|
|
146
|
+
try {
|
|
147
|
+
const result = await addApiCompatibleProvider(input);
|
|
148
|
+
await this.ctx.session.modelRegistry.refresh("offline");
|
|
149
|
+
await this.ctx.notifyConfigChanged?.();
|
|
150
|
+
this.ctx.showStatus(formatProviderSetupResult(result));
|
|
151
|
+
done();
|
|
152
|
+
this.ctx.ui.requestRender();
|
|
153
|
+
} catch (err) {
|
|
154
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
155
|
+
wizard.setSubmitError(`Provider setup failed: ${message}`);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
wizard = new CustomProviderWizardComponent(
|
|
159
|
+
input => {
|
|
160
|
+
void submit(input);
|
|
161
|
+
},
|
|
162
|
+
() => {
|
|
163
|
+
done();
|
|
164
|
+
this.ctx.ui.requestRender();
|
|
165
|
+
},
|
|
166
|
+
() => this.ctx.ui.requestRender(),
|
|
167
|
+
);
|
|
168
|
+
return { component: wizard, focus: wizard };
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
137
172
|
showSettingsSelector(): void {
|
|
138
173
|
getAvailableThemes().then(availableThemes => {
|
|
139
174
|
this.showSelector(done => {
|
|
@@ -502,6 +537,27 @@ export class SelectorController {
|
|
|
502
537
|
this.ctx.ui.requestRender();
|
|
503
538
|
return;
|
|
504
539
|
}
|
|
540
|
+
if (selection.kind === "profile") {
|
|
541
|
+
await activateModelProfile(
|
|
542
|
+
{
|
|
543
|
+
session: this.ctx.session,
|
|
544
|
+
modelRegistry: this.ctx.session.modelRegistry,
|
|
545
|
+
settings: this.ctx.settings,
|
|
546
|
+
profileName: selection.profileName,
|
|
547
|
+
},
|
|
548
|
+
{ persistDefault: selection.setDefault },
|
|
549
|
+
);
|
|
550
|
+
this.ctx.statusLine.invalidate();
|
|
551
|
+
this.ctx.updateEditorBorderColor();
|
|
552
|
+
this.ctx.showStatus(
|
|
553
|
+
selection.setDefault
|
|
554
|
+
? `Default model profile: ${selection.profileName}`
|
|
555
|
+
: `Model profile: ${selection.profileName}`,
|
|
556
|
+
);
|
|
557
|
+
done();
|
|
558
|
+
this.ctx.ui.requestRender();
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
505
561
|
const { model, role, thinkingLevel, selector } = selection;
|
|
506
562
|
if (role === null) {
|
|
507
563
|
// Temporary: update agent state but don't persist to settings
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
getKeybindings,
|
|
6
|
-
type SlashCommand,
|
|
7
|
-
} from "@gajae-code/tui";
|
|
8
|
-
import { formatKeyHints, type KeybindingsManager } from "../config/keybindings";
|
|
1
|
+
import type { AutocompleteItem, AutocompleteProvider, SlashCommand } from "@gajae-code/tui";
|
|
2
|
+
import { CombinedAutocompleteProvider, getKeybindings, getSlashCommandMatchRank } from "@gajae-code/tui";
|
|
3
|
+
import type { KeybindingsManager } from "../config/keybindings";
|
|
4
|
+
import { formatKeyHints } from "../config/keybindings";
|
|
9
5
|
import { isSettingsInitialized, settings } from "../config/settings";
|
|
10
6
|
import { applyEmojiCompletion, getEmojiSuggestions, isEmojiPrefix, tryEmojiInlineReplace } from "./emoji-autocomplete";
|
|
11
7
|
|
|
@@ -104,6 +100,43 @@ function mergeAutocompleteSuggestions(
|
|
|
104
100
|
return { items, prefix: primary.prefix };
|
|
105
101
|
}
|
|
106
102
|
|
|
103
|
+
function sortSlashCommandSuggestions(
|
|
104
|
+
suggestions: { items: AutocompleteItem[]; prefix: string } | null,
|
|
105
|
+
commands: SlashCommand[],
|
|
106
|
+
): { items: AutocompleteItem[]; prefix: string } | null {
|
|
107
|
+
if (!suggestions) return null;
|
|
108
|
+
const query = suggestions.prefix.slice(1).toLowerCase();
|
|
109
|
+
const commandIndexes = new Map(commands.map((command, index) => [command.name, index]));
|
|
110
|
+
const commandByName = new Map(commands.map(command => [command.name, command]));
|
|
111
|
+
const items = suggestions.items
|
|
112
|
+
.map((item, index) => {
|
|
113
|
+
const command = commandByName.get(item.value);
|
|
114
|
+
const commandIndex = commandIndexes.get(item.value) ?? index;
|
|
115
|
+
const lowerName = item.value.toLowerCase();
|
|
116
|
+
const lowerDesc = command?.description?.toLowerCase() ?? item.description?.toLowerCase() ?? "";
|
|
117
|
+
const nameScore = fuzzyMatch(query, lowerName) ? fuzzyScore(query, lowerName) : 0;
|
|
118
|
+
const descScore = fuzzyMatch(query, lowerDesc) ? fuzzyScore(query, lowerDesc) * 0.5 : 0;
|
|
119
|
+
return {
|
|
120
|
+
item,
|
|
121
|
+
index,
|
|
122
|
+
commandIndex,
|
|
123
|
+
matchRank: getSlashCommandMatchRank(query, lowerName),
|
|
124
|
+
priority: command?.priority ?? 0,
|
|
125
|
+
score: Math.max(nameScore, descScore),
|
|
126
|
+
};
|
|
127
|
+
})
|
|
128
|
+
.sort(
|
|
129
|
+
(a, b) =>
|
|
130
|
+
a.matchRank - b.matchRank ||
|
|
131
|
+
b.priority - a.priority ||
|
|
132
|
+
b.score - a.score ||
|
|
133
|
+
a.commandIndex - b.commandIndex ||
|
|
134
|
+
a.index - b.index,
|
|
135
|
+
)
|
|
136
|
+
.map(({ item }) => item);
|
|
137
|
+
return { ...suggestions, items };
|
|
138
|
+
}
|
|
139
|
+
|
|
107
140
|
function withoutSkillCommandSuggestions(
|
|
108
141
|
suggestions: { items: AutocompleteItem[]; prefix: string } | null,
|
|
109
142
|
): { items: AutocompleteItem[]; prefix: string } | null {
|
|
@@ -182,7 +215,10 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
|
|
|
182
215
|
await this.#baseProvider.getSuggestions(lines, cursorLine, cursorCol),
|
|
183
216
|
);
|
|
184
217
|
const skillCommandSuggestions = this.#getSkillCommandSuggestions(textBeforeCursor);
|
|
185
|
-
return
|
|
218
|
+
return sortSlashCommandSuggestions(
|
|
219
|
+
mergeAutocompleteSuggestions(baseSuggestions, skillCommandSuggestions),
|
|
220
|
+
this.#commands,
|
|
221
|
+
);
|
|
186
222
|
}
|
|
187
223
|
|
|
188
224
|
if (!isSettingsInitialized() || settings.get("emojiAutocomplete")) {
|
|
@@ -253,7 +289,10 @@ export class PromptActionAutocompleteProvider implements AutocompleteProvider {
|
|
|
253
289
|
this.#baseProvider.trySyncSlashCompletion?.(textBeforeCursor) ?? null,
|
|
254
290
|
);
|
|
255
291
|
const skillCommandSuggestions = this.#getSkillCommandSuggestions(textBeforeCursor);
|
|
256
|
-
return
|
|
292
|
+
return sortSlashCommandSuggestions(
|
|
293
|
+
mergeAutocompleteSuggestions(baseSuggestions, skillCommandSuggestions),
|
|
294
|
+
this.#commands,
|
|
295
|
+
);
|
|
257
296
|
}
|
|
258
297
|
trySyncInlineReplace(textBeforeCursor: string): { replaceLen: number; insert: string } | null {
|
|
259
298
|
if (isSettingsInitialized() && !settings.get("emojiAutocomplete")) return null;
|
|
@@ -20,6 +20,9 @@ import type {
|
|
|
20
20
|
RpcHostToolUpdate,
|
|
21
21
|
RpcResponse,
|
|
22
22
|
RpcSessionState,
|
|
23
|
+
RpcWorkflowGate,
|
|
24
|
+
RpcWorkflowGateResolution,
|
|
25
|
+
RpcWorkflowGateResponse,
|
|
23
26
|
} from "./rpc-types";
|
|
24
27
|
|
|
25
28
|
/** Distributive Omit that works with union types */
|
|
@@ -97,7 +100,7 @@ function isRpcResponse(value: unknown): value is RpcResponse {
|
|
|
97
100
|
if (typeof value.success !== "boolean") return false;
|
|
98
101
|
if (value.id !== undefined && typeof value.id !== "string") return false;
|
|
99
102
|
if (value.success === false) {
|
|
100
|
-
return typeof value.error === "string";
|
|
103
|
+
return typeof value.error === "string" || isRecord(value.error);
|
|
101
104
|
}
|
|
102
105
|
return true;
|
|
103
106
|
}
|
|
@@ -130,6 +133,21 @@ function isRpcExtensionUiRequest(value: unknown): value is RpcExtensionUIRequest
|
|
|
130
133
|
return value.type === "extension_ui_request" && typeof value.id === "string" && typeof value.method === "string";
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
function isRpcWorkflowGate(value: unknown): value is RpcWorkflowGate {
|
|
137
|
+
if (!isRecord(value)) return false;
|
|
138
|
+
return (
|
|
139
|
+
value.type === "workflow_gate" &&
|
|
140
|
+
typeof value.gate_id === "string" &&
|
|
141
|
+
typeof value.stage === "string" &&
|
|
142
|
+
typeof value.kind === "string" &&
|
|
143
|
+
isRecord(value.schema) &&
|
|
144
|
+
typeof value.schema_hash === "string" &&
|
|
145
|
+
isRecord(value.context) &&
|
|
146
|
+
typeof value.created_at === "string" &&
|
|
147
|
+
value.required === true
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
133
151
|
function normalizeToolResult<TDetails>(result: RpcClientToolResult<TDetails>): AgentToolResult<TDetails> {
|
|
134
152
|
if (typeof result === "string") {
|
|
135
153
|
return {
|
|
@@ -152,6 +170,7 @@ export class RpcClient {
|
|
|
152
170
|
#pendingHostToolCalls = new Map<string, { controller: AbortController }>();
|
|
153
171
|
#requestId = 0;
|
|
154
172
|
#extensionUiListeners: Set<(req: RpcExtensionUIRequest) => void> = new Set();
|
|
173
|
+
#workflowGateListeners: Set<(gate: RpcWorkflowGate) => void> = new Set();
|
|
155
174
|
#abortController = new AbortController();
|
|
156
175
|
|
|
157
176
|
constructor(private options: RpcClientOptions = {}) {
|
|
@@ -299,6 +318,29 @@ export class RpcClient {
|
|
|
299
318
|
};
|
|
300
319
|
}
|
|
301
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Subscribe to workflow lifecycle gates emitted by RPC mode.
|
|
323
|
+
*/
|
|
324
|
+
onWorkflowGate(listener: (gate: RpcWorkflowGate) => void): () => void {
|
|
325
|
+
this.#workflowGateListeners.add(listener);
|
|
326
|
+
return () => {
|
|
327
|
+
this.#workflowGateListeners.delete(listener);
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Answer a workflow lifecycle gate and wait for the server resolution envelope.
|
|
333
|
+
*/
|
|
334
|
+
async respondGate(gateId: string, answer: unknown, idempotencyKey?: string): Promise<RpcWorkflowGateResolution> {
|
|
335
|
+
const response = await this.#send({
|
|
336
|
+
type: "workflow_gate_response",
|
|
337
|
+
gate_id: gateId,
|
|
338
|
+
answer,
|
|
339
|
+
idempotency_key: idempotencyKey,
|
|
340
|
+
});
|
|
341
|
+
return this.#getData(response);
|
|
342
|
+
}
|
|
343
|
+
|
|
302
344
|
/**
|
|
303
345
|
* Get collected stderr output (useful for debugging).
|
|
304
346
|
*/
|
|
@@ -687,6 +729,13 @@ export class RpcClient {
|
|
|
687
729
|
return;
|
|
688
730
|
}
|
|
689
731
|
|
|
732
|
+
if (isRpcWorkflowGate(data)) {
|
|
733
|
+
for (const listener of this.#workflowGateListeners) {
|
|
734
|
+
listener(data);
|
|
735
|
+
}
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
|
|
690
739
|
if (isRpcHostToolCancelRequest(data)) {
|
|
691
740
|
this.#pendingHostToolCalls.get(data.targetId)?.controller.abort();
|
|
692
741
|
return;
|
|
@@ -798,7 +847,10 @@ export class RpcClient {
|
|
|
798
847
|
}
|
|
799
848
|
}
|
|
800
849
|
|
|
801
|
-
#writeFrame(
|
|
850
|
+
#writeFrame(
|
|
851
|
+
frame: RpcCommand | RpcWorkflowGateResponse | RpcHostToolResult | RpcHostToolUpdate,
|
|
852
|
+
onError?: (error: Error) => void,
|
|
853
|
+
): void {
|
|
802
854
|
if (!this.#process?.stdin) {
|
|
803
855
|
throw new Error("Client not started");
|
|
804
856
|
}
|
|
@@ -815,7 +867,9 @@ export class RpcClient {
|
|
|
815
867
|
#getData<T>(response: RpcResponse): T {
|
|
816
868
|
if (!response.success) {
|
|
817
869
|
const errorResponse = response as Extract<RpcResponse, { success: false }>;
|
|
818
|
-
throw new Error(
|
|
870
|
+
throw new Error(
|
|
871
|
+
typeof errorResponse.error === "string" ? errorResponse.error : JSON.stringify(errorResponse.error),
|
|
872
|
+
);
|
|
819
873
|
}
|
|
820
874
|
// Type assertion: we trust response.data matches T based on the command sent.
|
|
821
875
|
// This is safe because each public method specifies the correct T for its command.
|