openhorse 0.2.15 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +128 -6
- package/dist/commands/index.js.map +1 -1
- package/dist/ink-ui/components/SelectList.d.ts.map +1 -1
- package/dist/ink-ui/components/SelectList.js +10 -4
- package/dist/ink-ui/components/SelectList.js.map +1 -1
- package/dist/ink-ui/components/StatusLine.d.ts +3 -1
- package/dist/ink-ui/components/StatusLine.d.ts.map +1 -1
- package/dist/ink-ui/components/StatusLine.js +5 -3
- package/dist/ink-ui/components/StatusLine.js.map +1 -1
- package/dist/ink-ui/components/ToolActivity.d.ts +3 -1
- package/dist/ink-ui/components/ToolActivity.d.ts.map +1 -1
- package/dist/ink-ui/components/ToolActivity.js +37 -10
- package/dist/ink-ui/components/ToolActivity.js.map +1 -1
- package/dist/ink-ui/launch.d.ts.map +1 -1
- package/dist/ink-ui/launch.js +39 -10
- package/dist/ink-ui/launch.js.map +1 -1
- package/dist/ink-ui/screens/ReplScreen.d.ts.map +1 -1
- package/dist/ink-ui/screens/ReplScreen.js +39 -0
- package/dist/ink-ui/screens/ReplScreen.js.map +1 -1
- package/dist/runtime/chat-controller.d.ts.map +1 -1
- package/dist/runtime/chat-controller.js +31 -0
- package/dist/runtime/chat-controller.js.map +1 -1
- package/dist/runtime/ui-events.d.ts +16 -0
- package/dist/runtime/ui-events.d.ts.map +1 -1
- package/dist/runtime/ui-events.js.map +1 -1
- package/dist/runtime/ui-view-model.d.ts +35 -3
- package/dist/runtime/ui-view-model.d.ts.map +1 -1
- package/dist/runtime/ui-view-model.js +5 -0
- package/dist/runtime/ui-view-model.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,SAAS,CAAC;AAuQjB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAErF;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAQrE;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,SAAS,CAAC;AAuQjB,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,MAAM,CAErF;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE,CAQrE;AA46CD,iBAAe,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAgUpF;AAoyCD,wBAAgB,WAAW,IAAI,YAAY,EAAE,CAE5C;AAED,wBAAgB,kBAAkB,IAAI,YAAY,EAAE,CAEnD;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAElE;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAED,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -623,11 +623,81 @@ function latestToolTrace(events) {
|
|
|
623
623
|
}
|
|
624
624
|
return null;
|
|
625
625
|
}
|
|
626
|
+
/** Find tool trace by 1-based sequence number across all tool events. */
|
|
627
|
+
function toolTraceBySeq(events, seq) {
|
|
628
|
+
let counter = 0;
|
|
629
|
+
const toolEvents = new Map();
|
|
630
|
+
for (const event of events) {
|
|
631
|
+
if (event.type !== 'tool_call' && event.type !== 'tool_result')
|
|
632
|
+
continue;
|
|
633
|
+
if (!event.callId)
|
|
634
|
+
continue;
|
|
635
|
+
const entry = toolEvents.get(event.callId) ?? {};
|
|
636
|
+
if (event.type === 'tool_call') {
|
|
637
|
+
counter++;
|
|
638
|
+
entry.call = event;
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
if (!entry.call)
|
|
642
|
+
counter++;
|
|
643
|
+
entry.result = event;
|
|
644
|
+
}
|
|
645
|
+
toolEvents.set(event.callId, entry);
|
|
646
|
+
if (counter === seq) {
|
|
647
|
+
return toolEvents.get(event.callId) ?? null;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
/** Find tool trace by callId prefix. */
|
|
653
|
+
function toolTraceByCallId(events, callIdPrefix) {
|
|
654
|
+
let call;
|
|
655
|
+
let result;
|
|
656
|
+
for (const event of events) {
|
|
657
|
+
if (event.type !== 'tool_call' && event.type !== 'tool_result')
|
|
658
|
+
continue;
|
|
659
|
+
if (!event.callId?.startsWith(callIdPrefix))
|
|
660
|
+
continue;
|
|
661
|
+
if (event.type === 'tool_call')
|
|
662
|
+
call = event;
|
|
663
|
+
else
|
|
664
|
+
result = event;
|
|
665
|
+
}
|
|
666
|
+
if (!call && !result)
|
|
667
|
+
return null;
|
|
668
|
+
return { call, result };
|
|
669
|
+
}
|
|
670
|
+
/** Collect all tool trace pairs ordered by appearance (1-based sequence). */
|
|
671
|
+
function collectToolTracePairs(events) {
|
|
672
|
+
const pairs = [];
|
|
673
|
+
const seen = new Map();
|
|
674
|
+
let counter = 0;
|
|
675
|
+
for (const event of events) {
|
|
676
|
+
if (event.type !== 'tool_call' && event.type !== 'tool_result')
|
|
677
|
+
continue;
|
|
678
|
+
if (!event.callId)
|
|
679
|
+
continue;
|
|
680
|
+
let entry = seen.get(event.callId);
|
|
681
|
+
if (!entry) {
|
|
682
|
+
counter++;
|
|
683
|
+
entry = { seq: counter };
|
|
684
|
+
seen.set(event.callId, entry);
|
|
685
|
+
pairs.push(entry);
|
|
686
|
+
}
|
|
687
|
+
if (event.type === 'tool_call')
|
|
688
|
+
entry.call = event;
|
|
689
|
+
else
|
|
690
|
+
entry.result = event;
|
|
691
|
+
}
|
|
692
|
+
return pairs;
|
|
693
|
+
}
|
|
626
694
|
function parseLastToolArgs(args = '') {
|
|
627
695
|
const parts = args.trim().split(/\s+/).filter(Boolean);
|
|
696
|
+
const ref = parts.length > 0 && !parts[0].startsWith('--') ? parts[0] : undefined;
|
|
628
697
|
return {
|
|
629
698
|
full: parts.includes('--full'),
|
|
630
699
|
preview: !parts.includes('--no-preview'),
|
|
700
|
+
ref,
|
|
631
701
|
};
|
|
632
702
|
}
|
|
633
703
|
function printLastToolArtifactPreview(projectPath, label, artifactId, full) {
|
|
@@ -673,20 +743,72 @@ function handleLastTool(ctx, args = '') {
|
|
|
673
743
|
return { success: false };
|
|
674
744
|
}
|
|
675
745
|
const events = (0, session_storage_1.readSessionTraceEvents)(session.id);
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
746
|
+
// Resolve reference: latest (default), #N, or callId prefix
|
|
747
|
+
let trace = null;
|
|
748
|
+
let listMode = false;
|
|
749
|
+
if (!options.ref || options.ref === 'latest') {
|
|
750
|
+
trace = latestToolTrace(events);
|
|
751
|
+
}
|
|
752
|
+
else if (/^#?\d+$/.test(options.ref)) {
|
|
753
|
+
const seq = parseInt(options.ref.replace('#', ''), 10);
|
|
754
|
+
trace = toolTraceBySeq(events, seq);
|
|
755
|
+
if (!trace) {
|
|
756
|
+
console.log(ERROR(`Tool #${seq} not found in session trace.`));
|
|
757
|
+
// Fall back to listing available tools
|
|
758
|
+
listMode = true;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
else {
|
|
762
|
+
trace = toolTraceByCallId(events, options.ref);
|
|
763
|
+
if (!trace) {
|
|
764
|
+
console.log(ERROR(`Tool with callId prefix "${options.ref}" not found in session trace.`));
|
|
765
|
+
listMode = true;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (listMode || !trace) {
|
|
769
|
+
const pairs = collectToolTracePairs(events);
|
|
770
|
+
if (pairs.length === 0) {
|
|
771
|
+
console.log(DIM(`No tool trace events recorded for session ${session.id.slice(0, 8)} yet.`));
|
|
772
|
+
return { success: true };
|
|
773
|
+
}
|
|
774
|
+
console.log(HEADER(`Tools (${pairs.length})`));
|
|
775
|
+
console.log(DIM('─'.repeat(60)));
|
|
776
|
+
for (const pair of pairs.slice(-30)) {
|
|
777
|
+
const source = pair.result ?? pair.call;
|
|
778
|
+
const name = source?.name ?? 'tool';
|
|
779
|
+
const status = pair.result
|
|
780
|
+
? (pair.result.success === false ? '✗' : '✓')
|
|
781
|
+
: '…';
|
|
782
|
+
const duration = typeof pair.result?.duration === 'number'
|
|
783
|
+
? ` (${formatDurationMs(pair.result.duration)})`
|
|
784
|
+
: '';
|
|
785
|
+
const argsShort = (pair.call?.argsSummary ?? '').slice(0, 40);
|
|
786
|
+
console.log(` #${pair.seq} ${status} ${ACCENT(name)}${duration} ${DIM(argsShort)}`);
|
|
787
|
+
}
|
|
788
|
+
console.log();
|
|
789
|
+
console.log(DIM('Use /last-tool #N or /last-tool <callId> for details.'));
|
|
679
790
|
return { success: true };
|
|
680
791
|
}
|
|
681
|
-
const call =
|
|
682
|
-
const result =
|
|
792
|
+
const call = trace.call;
|
|
793
|
+
const result = trace.result;
|
|
683
794
|
const source = result ?? call;
|
|
684
795
|
const argsSource = call ?? result;
|
|
685
796
|
const name = source?.name ?? 'tool';
|
|
686
797
|
const inputLabel = lastToolInputLabel(name);
|
|
687
798
|
const callId = source?.callId ?? call?.callId;
|
|
688
799
|
const status = result ? (result.success === false ? ERROR('error') : SUCCESS('ok')) : WARN('running');
|
|
689
|
-
|
|
800
|
+
// Resolve sequence number from the trace events
|
|
801
|
+
let seqLabel = '';
|
|
802
|
+
if (options.ref && /^#?\d+$/.test(options.ref)) {
|
|
803
|
+
seqLabel = `#${parseInt(options.ref.replace('#', ''), 10)} `;
|
|
804
|
+
}
|
|
805
|
+
else if (result || call) {
|
|
806
|
+
const allPairs = collectToolTracePairs(events);
|
|
807
|
+
const matchingPair = allPairs.find(p => p.call?.callId === callId || p.result?.callId === callId);
|
|
808
|
+
if (matchingPair)
|
|
809
|
+
seqLabel = `#${matchingPair.seq} `;
|
|
810
|
+
}
|
|
811
|
+
console.log(HEADER(`Last Tool ${seqLabel}`.trimEnd()));
|
|
690
812
|
console.log(DIM('─'.repeat(40)));
|
|
691
813
|
console.log(` Tool ${ACCENT(name)}`);
|
|
692
814
|
console.log(` Turn ${DIM(source?.turnId ?? 'unknown')}`);
|