@aiyiran/myclaw 1.1.202 → 1.1.203
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/assets/myclaw-artifacts.js +314 -8
- package/assets/myclaw-inject.js +110 -9
- package/create_agent.js +15 -11
- package/index.js +8 -0
- package/package.json +1 -1
- package/server/sync_workspace.py +12 -5
- package/skills/yiran-playground-template-use/SKILL.md +4 -4
- package/skills/yiran-playground-template-use/scripts/deploy_to_workspace.py +51 -5
- package/skills/yiran-playground-template-use/scripts/start_tui_handoff.py +22 -4
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
btn.id = 'myclaw-artifacts-btn';
|
|
106
106
|
btn.style.cssText = [
|
|
107
107
|
'position: fixed',
|
|
108
|
-
'top:
|
|
108
|
+
'top: 0',
|
|
109
109
|
'right: 0',
|
|
110
110
|
'padding: 3px 10px',
|
|
111
111
|
'background: rgba(100, 100, 100, 0.7)',
|
|
@@ -143,19 +143,19 @@
|
|
|
143
143
|
panelVisible = true;
|
|
144
144
|
|
|
145
145
|
var btn = document.querySelector('#myclaw-artifacts-btn');
|
|
146
|
-
if (btn) btn.style.
|
|
146
|
+
if (btn) btn.style.display = 'none';
|
|
147
147
|
|
|
148
148
|
// 面板
|
|
149
149
|
var panel = document.createElement('div');
|
|
150
150
|
panel.id = 'myclaw-artifacts-panel';
|
|
151
151
|
panel.style.cssText = [
|
|
152
152
|
'position: fixed',
|
|
153
|
-
'top:
|
|
153
|
+
'top: 0',
|
|
154
154
|
'right: 0',
|
|
155
155
|
'width: 380px',
|
|
156
|
-
'height:
|
|
156
|
+
'height: calc(100vh - 50px)',
|
|
157
157
|
'background: #1e1e2e',
|
|
158
|
-
'border-radius:
|
|
158
|
+
'border-radius: 0 0 0 8px',
|
|
159
159
|
'overflow: hidden',
|
|
160
160
|
'display: flex',
|
|
161
161
|
'flex-direction: column',
|
|
@@ -314,6 +314,7 @@
|
|
|
314
314
|
panel.appendChild(header);
|
|
315
315
|
panel.appendChild(content);
|
|
316
316
|
panel.appendChild(panelFooter);
|
|
317
|
+
panel.appendChild(createTrainingCard(null));
|
|
317
318
|
document.body.appendChild(panel);
|
|
318
319
|
|
|
319
320
|
// 立即拉一次,后续由轮询更新
|
|
@@ -323,11 +324,20 @@
|
|
|
323
324
|
// ═══ 关闭右侧面板 ═══
|
|
324
325
|
function closeArtifactsPanel() {
|
|
325
326
|
var panel = document.querySelector('#myclaw-artifacts-panel');
|
|
326
|
-
if (panel)
|
|
327
|
+
if (panel) {
|
|
328
|
+
var trainingCard = panel.querySelector('.myclaw-training-card');
|
|
329
|
+
if (trainingCard && typeof trainingCard._destroyVoiceInputs === 'function') {
|
|
330
|
+
try { trainingCard._destroyVoiceInputs(); } catch (e) {}
|
|
331
|
+
}
|
|
332
|
+
panel.remove();
|
|
333
|
+
}
|
|
327
334
|
panelVisible = false;
|
|
328
335
|
|
|
329
336
|
var btn = document.querySelector('#myclaw-artifacts-btn');
|
|
330
|
-
if (btn)
|
|
337
|
+
if (btn) {
|
|
338
|
+
btn.style.display = '';
|
|
339
|
+
btn.style.background = 'rgba(100, 100, 100, 0.7)';
|
|
340
|
+
}
|
|
331
341
|
}
|
|
332
342
|
|
|
333
343
|
// ═══ 请求数据 ═══
|
|
@@ -674,6 +684,246 @@
|
|
|
674
684
|
return asset.type && IMAGE_TYPES.indexOf(asset.type.toLowerCase()) !== -1;
|
|
675
685
|
}
|
|
676
686
|
|
|
687
|
+
var TRAINING_CARD_STORAGE_PREFIX = 'myclaw-training-card-records-v1:';
|
|
688
|
+
var TRAINING_CARD_STORAGE_LIMIT = 200;
|
|
689
|
+
|
|
690
|
+
function buildTrainingCardPrompt(values) {
|
|
691
|
+
return [
|
|
692
|
+
'我当前最想解决的问题是:',
|
|
693
|
+
values.problem,
|
|
694
|
+
'',
|
|
695
|
+
'我想达成的目标是:',
|
|
696
|
+
values.goal,
|
|
697
|
+
'',
|
|
698
|
+
'为了达到这个目标,我选择的方案是:',
|
|
699
|
+
values.plan,
|
|
700
|
+
'',
|
|
701
|
+
'请只围绕这个问题、目标和方案帮助我,不要顺便修改其他内容。'
|
|
702
|
+
].join('\n');
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function createTrainingRecord(asset, values) {
|
|
706
|
+
var now = new Date();
|
|
707
|
+
return {
|
|
708
|
+
version: 1,
|
|
709
|
+
recordId: 'training-' + now.getTime() + '-' + Math.random().toString(36).slice(2, 8),
|
|
710
|
+
submittedAt: now.toISOString(),
|
|
711
|
+
claw: lastKnownClawName || '',
|
|
712
|
+
workspace: getWorkspaceId(),
|
|
713
|
+
studentAgent: getAgentName(),
|
|
714
|
+
asset: asset ? {
|
|
715
|
+
name: asset.name || '',
|
|
716
|
+
path: asset.path || ''
|
|
717
|
+
} : null,
|
|
718
|
+
problem: values.problem,
|
|
719
|
+
goal: values.goal,
|
|
720
|
+
plan: values.plan
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
function archiveTrainingRecordLocally(record) {
|
|
725
|
+
var key = TRAINING_CARD_STORAGE_PREFIX + record.workspace;
|
|
726
|
+
var records = [];
|
|
727
|
+
try {
|
|
728
|
+
var stored = JSON.parse(localStorage.getItem(key) || '[]');
|
|
729
|
+
if (Array.isArray(stored)) records = stored;
|
|
730
|
+
} catch (e) {
|
|
731
|
+
records = [];
|
|
732
|
+
}
|
|
733
|
+
records.push(record);
|
|
734
|
+
if (records.length > TRAINING_CARD_STORAGE_LIMIT) {
|
|
735
|
+
records = records.slice(records.length - TRAINING_CARD_STORAGE_LIMIT);
|
|
736
|
+
}
|
|
737
|
+
localStorage.setItem(key, JSON.stringify(records));
|
|
738
|
+
return record;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function createTrainingCard(asset) {
|
|
742
|
+
var section = document.createElement('section');
|
|
743
|
+
section.className = 'myclaw-training-card';
|
|
744
|
+
var voiceDestroyers = [];
|
|
745
|
+
|
|
746
|
+
var heading = document.createElement('div');
|
|
747
|
+
heading.className = 'myclaw-training-card__heading';
|
|
748
|
+
var headingText = document.createElement('div');
|
|
749
|
+
var title = document.createElement('h2');
|
|
750
|
+
title.textContent = '这一轮想做什么?';
|
|
751
|
+
var intro = document.createElement('p');
|
|
752
|
+
intro.textContent = '三句话就够了,简单写。';
|
|
753
|
+
headingText.appendChild(title);
|
|
754
|
+
headingText.appendChild(intro);
|
|
755
|
+
|
|
756
|
+
var step = document.createElement('div');
|
|
757
|
+
step.className = 'myclaw-training-card__step';
|
|
758
|
+
step.textContent = '问题 → 目标 → 方案';
|
|
759
|
+
heading.appendChild(headingText);
|
|
760
|
+
heading.appendChild(step);
|
|
761
|
+
section.appendChild(heading);
|
|
762
|
+
|
|
763
|
+
var fields = document.createElement('div');
|
|
764
|
+
fields.className = 'myclaw-training-card__fields';
|
|
765
|
+
|
|
766
|
+
function makeField(number, label, prompt, placeholder) {
|
|
767
|
+
var field = document.createElement('label');
|
|
768
|
+
field.className = 'myclaw-training-card__field';
|
|
769
|
+
var fieldTitle = document.createElement('span');
|
|
770
|
+
fieldTitle.className = 'myclaw-training-card__field-title';
|
|
771
|
+
fieldTitle.textContent = number + '、' + label;
|
|
772
|
+
var fieldPrompt = document.createElement('span');
|
|
773
|
+
fieldPrompt.className = 'myclaw-training-card__field-prompt';
|
|
774
|
+
fieldPrompt.textContent = prompt;
|
|
775
|
+
var input = document.createElement('textarea');
|
|
776
|
+
input.rows = 2;
|
|
777
|
+
input.maxLength = 1000;
|
|
778
|
+
input.placeholder = placeholder;
|
|
779
|
+
input.setAttribute('aria-label', label);
|
|
780
|
+
|
|
781
|
+
var inputWrap = document.createElement('span');
|
|
782
|
+
inputWrap.className = 'myclaw-training-card__input-wrap';
|
|
783
|
+
var micBtn = document.createElement('button');
|
|
784
|
+
micBtn.type = 'button';
|
|
785
|
+
micBtn.className = 'myclaw-training-card__mic';
|
|
786
|
+
micBtn.title = '语音输入';
|
|
787
|
+
micBtn.setAttribute('aria-label', label + '语音输入');
|
|
788
|
+
micBtn.innerHTML = [
|
|
789
|
+
'<svg width="14" height="14" viewBox="0 0 24 24" fill="none"',
|
|
790
|
+
' stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">',
|
|
791
|
+
' <path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/>',
|
|
792
|
+
' <path d="M19 10v2a7 7 0 0 1-14 0v-2"/>',
|
|
793
|
+
' <line x1="12" x2="12" y1="19" y2="22"/>',
|
|
794
|
+
'</svg>'
|
|
795
|
+
].join('');
|
|
796
|
+
inputWrap.appendChild(input);
|
|
797
|
+
inputWrap.appendChild(micBtn);
|
|
798
|
+
field.appendChild(fieldTitle);
|
|
799
|
+
field.appendChild(fieldPrompt);
|
|
800
|
+
field.appendChild(inputWrap);
|
|
801
|
+
fields.appendChild(field);
|
|
802
|
+
|
|
803
|
+
if (typeof window.myclawBindVoiceInput === 'function') {
|
|
804
|
+
voiceDestroyers.push(window.myclawBindVoiceInput(input, micBtn));
|
|
805
|
+
} else {
|
|
806
|
+
micBtn.disabled = true;
|
|
807
|
+
micBtn.title = '语音输入暂不可用,请刷新页面';
|
|
808
|
+
}
|
|
809
|
+
return input;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
var problemInput = makeField(
|
|
813
|
+
'1', '问题',
|
|
814
|
+
'这一轮,我当前最想解决的问题是什么?',
|
|
815
|
+
'现在最想解决什么?'
|
|
816
|
+
);
|
|
817
|
+
var goalInput = makeField(
|
|
818
|
+
'2', '目标',
|
|
819
|
+
'我想让它变成什么样?做到什么样才算解决?',
|
|
820
|
+
'做到什么样就算解决?'
|
|
821
|
+
);
|
|
822
|
+
var planInput = makeField(
|
|
823
|
+
'3', '方案',
|
|
824
|
+
'为了达到这个目标,我选择哪个方案?',
|
|
825
|
+
'这一轮准备选哪个方案?'
|
|
826
|
+
);
|
|
827
|
+
section.appendChild(fields);
|
|
828
|
+
|
|
829
|
+
var footer = document.createElement('div');
|
|
830
|
+
footer.className = 'myclaw-training-card__footer';
|
|
831
|
+
var status = document.createElement('div');
|
|
832
|
+
status.className = 'myclaw-training-card__status';
|
|
833
|
+
status.setAttribute('role', 'status');
|
|
834
|
+
status.setAttribute('aria-live', 'polite');
|
|
835
|
+
var actions = document.createElement('div');
|
|
836
|
+
actions.className = 'myclaw-training-card__actions';
|
|
837
|
+
var aiBtn = document.createElement('button');
|
|
838
|
+
aiBtn.type = 'button';
|
|
839
|
+
aiBtn.className = 'myclaw-training-card__button myclaw-training-card__button--ai';
|
|
840
|
+
aiBtn.textContent = '提交 AI';
|
|
841
|
+
var teacherBtn = document.createElement('button');
|
|
842
|
+
teacherBtn.type = 'button';
|
|
843
|
+
teacherBtn.className = 'myclaw-training-card__button myclaw-training-card__button--teacher';
|
|
844
|
+
teacherBtn.textContent = '提交老师';
|
|
845
|
+
actions.appendChild(aiBtn);
|
|
846
|
+
actions.appendChild(teacherBtn);
|
|
847
|
+
footer.appendChild(status);
|
|
848
|
+
footer.appendChild(actions);
|
|
849
|
+
section.appendChild(footer);
|
|
850
|
+
|
|
851
|
+
var lastTeacherFingerprint = '';
|
|
852
|
+
|
|
853
|
+
function readValues() {
|
|
854
|
+
return {
|
|
855
|
+
problem: problemInput.value.trim(),
|
|
856
|
+
goal: goalInput.value.trim(),
|
|
857
|
+
plan: planInput.value.trim()
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function validate(values) {
|
|
862
|
+
var missing = [];
|
|
863
|
+
if (!values.problem) missing.push('问题');
|
|
864
|
+
if (!values.goal) missing.push('目标');
|
|
865
|
+
if (!values.plan) missing.push('方案');
|
|
866
|
+
if (missing.length) {
|
|
867
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
868
|
+
status.textContent = '请先填写:' + missing.join('、');
|
|
869
|
+
return false;
|
|
870
|
+
}
|
|
871
|
+
return true;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
aiBtn.addEventListener('click', function () {
|
|
875
|
+
var values = readValues();
|
|
876
|
+
if (!validate(values)) return;
|
|
877
|
+
if (typeof window.myclawSendPrompt !== 'function') {
|
|
878
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
879
|
+
status.textContent = 'AI 提交功能还没有准备好,请刷新页面后重试。';
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
aiBtn.disabled = true;
|
|
883
|
+
var sent = window.myclawSendPrompt(buildTrainingCardPrompt(values));
|
|
884
|
+
aiBtn.disabled = false;
|
|
885
|
+
if (sent) {
|
|
886
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
887
|
+
status.textContent = '已提交 AI。可以关闭作品窗口查看回复。';
|
|
888
|
+
} else {
|
|
889
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
890
|
+
status.textContent = '暂时无法发送。请确认 AI 没有正在回复,然后重试。';
|
|
891
|
+
}
|
|
892
|
+
});
|
|
893
|
+
|
|
894
|
+
teacherBtn.addEventListener('click', function () {
|
|
895
|
+
var values = readValues();
|
|
896
|
+
if (!validate(values)) return;
|
|
897
|
+
var fingerprint = [values.problem, values.goal, values.plan].join('\n---\n');
|
|
898
|
+
if (fingerprint === lastTeacherFingerprint) {
|
|
899
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
900
|
+
status.textContent = '这份内容已经提交老师。';
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
teacherBtn.disabled = true;
|
|
904
|
+
try {
|
|
905
|
+
var record = createTrainingRecord(asset, values);
|
|
906
|
+
archiveTrainingRecordLocally(record);
|
|
907
|
+
lastTeacherFingerprint = fingerprint;
|
|
908
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--success';
|
|
909
|
+
status.textContent = '已提交老师,并暂存在这台电脑。';
|
|
910
|
+
} catch (e) {
|
|
911
|
+
console.error('[myclaw-training-card] 本地归档失败:', e);
|
|
912
|
+
status.className = 'myclaw-training-card__status myclaw-training-card__status--error';
|
|
913
|
+
status.textContent = '提交失败,填写内容仍然保留,请重试。';
|
|
914
|
+
}
|
|
915
|
+
teacherBtn.disabled = false;
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
section._destroyVoiceInputs = function () {
|
|
919
|
+
voiceDestroyers.forEach(function (destroy) {
|
|
920
|
+
try { destroy(); } catch (e) {}
|
|
921
|
+
});
|
|
922
|
+
voiceDestroyers = [];
|
|
923
|
+
};
|
|
924
|
+
return section;
|
|
925
|
+
}
|
|
926
|
+
|
|
677
927
|
function openPreviewModal(data, asset) {
|
|
678
928
|
if (document.querySelector('#myclaw-artifacts-preview')) return;
|
|
679
929
|
|
|
@@ -3074,6 +3324,61 @@
|
|
|
3074
3324
|
' from { transform: rotate(0deg); }',
|
|
3075
3325
|
' to { transform: rotate(360deg); }',
|
|
3076
3326
|
'}',
|
|
3327
|
+
'.myclaw-training-card {',
|
|
3328
|
+
' box-sizing: border-box; width: 100%; padding: 10px 12px;',
|
|
3329
|
+
' color: #e5e7eb; background: #191927; border-top: 1px solid #35354d;',
|
|
3330
|
+
' font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;',
|
|
3331
|
+
'}',
|
|
3332
|
+
'#myclaw-artifacts-panel > .myclaw-training-card { flex-shrink: 0; }',
|
|
3333
|
+
'.myclaw-training-card__heading {',
|
|
3334
|
+
' margin: 0 0 8px; display: flex; align-items: baseline; gap: 9px;',
|
|
3335
|
+
'}',
|
|
3336
|
+
'.myclaw-training-card__heading h2 { margin: 0; font-size: 15px; line-height: 1.2; color: #f4f4f5; }',
|
|
3337
|
+
'.myclaw-training-card__heading p { margin: 0; font-size: 11px; color: #8f90a5; }',
|
|
3338
|
+
'.myclaw-training-card__step { display: none; }',
|
|
3339
|
+
'.myclaw-training-card__fields {',
|
|
3340
|
+
' display: grid; grid-template-columns: 1fr; gap: 6px;',
|
|
3341
|
+
'}',
|
|
3342
|
+
'.myclaw-training-card__field {',
|
|
3343
|
+
' min-width: 0; display: grid; grid-template-columns: 58px minmax(0, 1fr);',
|
|
3344
|
+
' align-items: center; gap: 8px;',
|
|
3345
|
+
'}',
|
|
3346
|
+
'.myclaw-training-card__field-title { font-size: 12px; font-weight: 700; color: #c9c9d7; }',
|
|
3347
|
+
'.myclaw-training-card__field-prompt { display: none; }',
|
|
3348
|
+
'.myclaw-training-card__input-wrap {',
|
|
3349
|
+
' min-width: 0; display: flex; align-items: center; gap: 6px;',
|
|
3350
|
+
'}',
|
|
3351
|
+
'.myclaw-training-card__field textarea {',
|
|
3352
|
+
' box-sizing: border-box; flex: 1; min-width: 0; width: auto; height: 52px; min-height: 52px; max-height: 76px;',
|
|
3353
|
+
' resize: vertical; padding: 7px 9px; border: 1px solid #3d3d55; border-radius: 7px;',
|
|
3354
|
+
' outline: none; color: #f4f4f5; background: #232334;',
|
|
3355
|
+
' font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;',
|
|
3356
|
+
'}',
|
|
3357
|
+
'.myclaw-training-card__field textarea::placeholder { color: #77788d; }',
|
|
3358
|
+
'.myclaw-training-card__field textarea:focus { border-color: #8b5cf6; background: #27273a; }',
|
|
3359
|
+
'.myclaw-training-card__mic {',
|
|
3360
|
+
' width: 32px; height: 32px; flex: 0 0 32px; padding: 0; border-radius: 50%;',
|
|
3361
|
+
' border: 1px solid #45455f; background: #232334; color: #9a9bad; cursor: pointer;',
|
|
3362
|
+
' display: inline-flex; align-items: center; justify-content: center; transition: all .15s ease;',
|
|
3363
|
+
'}',
|
|
3364
|
+
'.myclaw-training-card__mic:hover { color: #ddd6fe; border-color: #7c3aed; background: #292940; }',
|
|
3365
|
+
'.myclaw-training-card__mic:disabled { cursor: not-allowed; opacity: .4; }',
|
|
3366
|
+
'.myclaw-training-card__footer {',
|
|
3367
|
+
' margin: 8px 0 0; display: flex; flex-direction: column; gap: 5px;',
|
|
3368
|
+
'}',
|
|
3369
|
+
'.myclaw-training-card__status { min-height: 15px; color: #9ca3af; font-size: 11px; }',
|
|
3370
|
+
'.myclaw-training-card__status--success { color: #6ee7b7; }',
|
|
3371
|
+
'.myclaw-training-card__status--error { color: #fca5a5; }',
|
|
3372
|
+
'.myclaw-training-card__actions { display: flex; gap: 8px; width: 100%; }',
|
|
3373
|
+
'.myclaw-training-card__button {',
|
|
3374
|
+
' flex: 1; min-width: 0; padding: 7px 10px; border: 0; border-radius: 7px; cursor: pointer;',
|
|
3375
|
+
' color: #fff; font-size: 12px; font-weight: 700;',
|
|
3376
|
+
' transition: transform .15s ease, opacity .15s ease, filter .15s ease;',
|
|
3377
|
+
'}',
|
|
3378
|
+
'.myclaw-training-card__button:hover { transform: translateY(-1px); filter: brightness(1.08); }',
|
|
3379
|
+
'.myclaw-training-card__button:disabled { cursor: wait; opacity: .55; transform: none; }',
|
|
3380
|
+
'.myclaw-training-card__button--ai { background: #7c3aed; }',
|
|
3381
|
+
'.myclaw-training-card__button--teacher { background: #2563eb; }',
|
|
3077
3382
|
].join('\n');
|
|
3078
3383
|
document.head.appendChild(style);
|
|
3079
3384
|
}
|
|
@@ -3083,8 +3388,9 @@
|
|
|
3083
3388
|
injectStyles();
|
|
3084
3389
|
createArtifactsButton();
|
|
3085
3390
|
var templateFloatBtn = document.createElement('div');
|
|
3391
|
+
templateFloatBtn.id = 'myclaw-template-btn';
|
|
3086
3392
|
templateFloatBtn.textContent = '📋 模板';
|
|
3087
|
-
templateFloatBtn.style.cssText = 'position:fixed;right:
|
|
3393
|
+
templateFloatBtn.style.cssText = 'position:fixed;right:5px;bottom:8px;z-index:99999;cursor:pointer;padding:3px 10px;border-radius:4px;font-size:11px;font-weight:bold;font-family:monospace;color:#cdd6f4;background:rgba(37,37,54,0.92);border:1px solid #3d3d5c;text-align:center;transition:all 0.2s;letter-spacing:0.5px;';
|
|
3088
3394
|
templateFloatBtn.onmouseenter = function () { templateFloatBtn.style.background = 'rgba(255,255,255,0.14)'; };
|
|
3089
3395
|
templateFloatBtn.onmouseleave = function () { templateFloatBtn.style.background = 'rgba(37,37,54,0.92)'; };
|
|
3090
3396
|
templateFloatBtn.onclick = function () { openTemplateModal(); };
|
package/assets/myclaw-inject.js
CHANGED
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
var suppressNextClipboardCopy = false;
|
|
32
32
|
var VOICE_STOP_WAIT_MS = 1500;
|
|
33
33
|
var VOICE_STOP_WAIT_SECONDS = VOICE_STOP_WAIT_MS / 1000;
|
|
34
|
+
var activeBoundVoiceStop = null;
|
|
34
35
|
|
|
35
36
|
// ═══ 1. 右下角版本入口(打开快捷命令) ═══
|
|
36
37
|
function createVersionBar() {
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
bar.style.cssText = [
|
|
42
43
|
"position: fixed",
|
|
43
44
|
"bottom: 8px",
|
|
44
|
-
"right:
|
|
45
|
+
"right: 75px",
|
|
45
46
|
"padding: 3px 10px",
|
|
46
47
|
"background: rgba(59, 130, 246, 0.85)",
|
|
47
48
|
"color: #fff",
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
btn.style.cssText = [
|
|
86
87
|
"position: fixed",
|
|
87
88
|
"bottom: 8px",
|
|
88
|
-
"right:
|
|
89
|
+
"right: 175px",
|
|
89
90
|
"padding: 3px 10px",
|
|
90
91
|
"background: rgba(120, 120, 120, 0.18)",
|
|
91
92
|
"color: rgba(170, 170, 170, 0.9)",
|
|
@@ -235,24 +236,32 @@
|
|
|
235
236
|
*/
|
|
236
237
|
function setTextareaValue(fullText) {
|
|
237
238
|
var ta = document.querySelector(".agent-chat__input textarea");
|
|
238
|
-
if (!ta) return;
|
|
239
|
+
if (!ta) return false;
|
|
239
240
|
|
|
240
241
|
var setter = Object.getOwnPropertyDescriptor(
|
|
241
242
|
HTMLTextAreaElement.prototype, "value"
|
|
242
243
|
).set;
|
|
243
244
|
setter.call(ta, fullText);
|
|
244
245
|
ta.dispatchEvent(new Event("input", { bubbles: true }));
|
|
246
|
+
return true;
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
function sendGeneratedPrompt(text) {
|
|
250
|
+
if (!setTextareaValue(text)) {
|
|
251
|
+
console.warn("[myclaw-send] 找不到聊天输入框");
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
248
254
|
suppressNextClipboardCopy = true;
|
|
249
|
-
|
|
250
|
-
trySend();
|
|
255
|
+
var sent = trySend();
|
|
251
256
|
setTimeout(function () {
|
|
252
257
|
suppressNextClipboardCopy = false;
|
|
253
258
|
}, 3000);
|
|
259
|
+
return sent;
|
|
254
260
|
}
|
|
255
261
|
|
|
262
|
+
// 给其他 MyClaw 前端模块复用统一的聊天发送能力。
|
|
263
|
+
window.myclawSendPrompt = sendGeneratedPrompt;
|
|
264
|
+
|
|
256
265
|
/**
|
|
257
266
|
* 获取 textarea 当前值
|
|
258
267
|
*/
|
|
@@ -524,6 +533,97 @@
|
|
|
524
533
|
};
|
|
525
534
|
}
|
|
526
535
|
|
|
536
|
+
// 为其他 MyClaw 模块已有的 textarea 绑定一枚独立语音按钮。
|
|
537
|
+
function bindVoiceInput(input, micBtn) {
|
|
538
|
+
if (!input || !micBtn) return function () {};
|
|
539
|
+
|
|
540
|
+
var localVoice = null;
|
|
541
|
+
var localRecording = false;
|
|
542
|
+
var localStopping = false;
|
|
543
|
+
|
|
544
|
+
function setMicUI(isRecording) {
|
|
545
|
+
if (isRecording) {
|
|
546
|
+
micBtn.style.background = "#ef4444";
|
|
547
|
+
micBtn.style.borderColor = "#ef4444";
|
|
548
|
+
micBtn.style.color = "#fff";
|
|
549
|
+
micBtn.title = "停止录音";
|
|
550
|
+
input.style.borderColor = "#ef4444";
|
|
551
|
+
} else {
|
|
552
|
+
micBtn.style.background = "#232334";
|
|
553
|
+
micBtn.style.borderColor = "#45455f";
|
|
554
|
+
micBtn.style.color = "#9a9bad";
|
|
555
|
+
micBtn.title = "语音输入";
|
|
556
|
+
input.style.borderColor = "";
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
function initVoiceForField() {
|
|
561
|
+
if (typeof window.VoiceInput === "undefined") return false;
|
|
562
|
+
localVoice = new window.VoiceInput({
|
|
563
|
+
onResult: function (text) {
|
|
564
|
+
if (!localRecording && !localStopping) return;
|
|
565
|
+
input.value = String(text || "").slice(0, input.maxLength || 1000);
|
|
566
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
567
|
+
},
|
|
568
|
+
onStatusChange: function (oldStatus, newStatus) {
|
|
569
|
+
if (newStatus === "idle" && localRecording && !localStopping) {
|
|
570
|
+
setTimeout(function () {
|
|
571
|
+
if (localRecording && localVoice) localVoice.start();
|
|
572
|
+
}, 300);
|
|
573
|
+
}
|
|
574
|
+
},
|
|
575
|
+
onError: function (err) {
|
|
576
|
+
console.error("[myclaw-training-card] voice error:", err);
|
|
577
|
+
localRecording = false;
|
|
578
|
+
localStopping = false;
|
|
579
|
+
if (activeBoundVoiceStop === stopVoiceForField) activeBoundVoiceStop = null;
|
|
580
|
+
setMicUI(false);
|
|
581
|
+
},
|
|
582
|
+
});
|
|
583
|
+
return true;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function startVoiceForField() {
|
|
587
|
+
if (!localVoice && !initVoiceForField()) {
|
|
588
|
+
console.warn("[myclaw-training-card] VoiceInput SDK 未加载");
|
|
589
|
+
micBtn.title = "语音输入暂不可用";
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
if (activeBoundVoiceStop && activeBoundVoiceStop !== stopVoiceForField) {
|
|
593
|
+
activeBoundVoiceStop();
|
|
594
|
+
}
|
|
595
|
+
activeBoundVoiceStop = stopVoiceForField;
|
|
596
|
+
localStopping = false;
|
|
597
|
+
localRecording = true;
|
|
598
|
+
setMicUI(true);
|
|
599
|
+
localVoice.start();
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function stopVoiceForField() {
|
|
603
|
+
if (!localRecording && !localStopping) return;
|
|
604
|
+
localStopping = true;
|
|
605
|
+
localRecording = false;
|
|
606
|
+
setMicUI(false);
|
|
607
|
+
setTimeout(function () {
|
|
608
|
+
localStopping = false;
|
|
609
|
+
if (localVoice) localVoice.stop();
|
|
610
|
+
if (activeBoundVoiceStop === stopVoiceForField) activeBoundVoiceStop = null;
|
|
611
|
+
}, VOICE_STOP_WAIT_MS);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
micBtn.addEventListener("click", function () {
|
|
615
|
+
if (localRecording) stopVoiceForField();
|
|
616
|
+
else if (!localStopping) startVoiceForField();
|
|
617
|
+
});
|
|
618
|
+
setMicUI(false);
|
|
619
|
+
|
|
620
|
+
return function destroyVoiceBinding() {
|
|
621
|
+
stopVoiceForField();
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
window.myclawBindVoiceInput = bindVoiceInput;
|
|
626
|
+
|
|
527
627
|
function showDebugModal() {
|
|
528
628
|
if (document.getElementById("myclaw-debug-modal")) return;
|
|
529
629
|
|
|
@@ -1207,13 +1307,14 @@ btn.addEventListener("click", function () {
|
|
|
1207
1307
|
var btn = document.querySelector("button.chat-send-btn");
|
|
1208
1308
|
if (!btn) {
|
|
1209
1309
|
console.log("[myclaw-send] 找不到发送按钮");
|
|
1210
|
-
return;
|
|
1310
|
+
return false;
|
|
1211
1311
|
}
|
|
1212
1312
|
if (btn.classList.contains("chat-send-btn--stop")) {
|
|
1213
1313
|
console.log("[myclaw-send] AI 生成中,禁止发送");
|
|
1214
|
-
return;
|
|
1314
|
+
return false;
|
|
1215
1315
|
}
|
|
1216
1316
|
btn.click();
|
|
1317
|
+
return true;
|
|
1217
1318
|
}
|
|
1218
1319
|
|
|
1219
1320
|
/**
|
|
@@ -1769,7 +1870,7 @@ btn.addEventListener("click", function () {
|
|
|
1769
1870
|
btn.style.cssText = [
|
|
1770
1871
|
"position: fixed",
|
|
1771
1872
|
"bottom: 8px",
|
|
1772
|
-
"right:
|
|
1873
|
+
"right: 260px",
|
|
1773
1874
|
"padding: 3px 10px",
|
|
1774
1875
|
"background: rgba(139, 92, 246, 0.85)",
|
|
1775
1876
|
"color: #fff",
|
|
@@ -1804,7 +1905,7 @@ btn.addEventListener("click", function () {
|
|
|
1804
1905
|
btn.style.cssText = [
|
|
1805
1906
|
"position: fixed",
|
|
1806
1907
|
"bottom: 8px",
|
|
1807
|
-
"right:
|
|
1908
|
+
"right: 355px",
|
|
1808
1909
|
"padding: 3px 10px",
|
|
1809
1910
|
"background: rgba(59, 130, 246, 0.85)",
|
|
1810
1911
|
"color: #fff",
|
package/create_agent.js
CHANGED
|
@@ -278,20 +278,23 @@ function createAgent(rawName, opts) {
|
|
|
278
278
|
fail('配置文件写入失败: ' + err.message + '\n备份文件: ' + normalizePath(backupPath));
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
//
|
|
281
|
+
// 发送首条消息:普通 mc new 保持生日初始化逻辑;
|
|
282
|
+
// 模板部署可传 skipFirstMessage,等文件就绪后再发模板提示词。
|
|
282
283
|
const birthMessage = opts.firstMessage || buildBirthMessage();
|
|
283
284
|
let firstMessageSent = false;
|
|
284
285
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
286
|
+
if (!opts.skipFirstMessage) {
|
|
287
|
+
try {
|
|
288
|
+
const { spawn } = require('child_process');
|
|
289
|
+
spawn('openclaw', ['agent', '--agent', agentId, '--message', birthMessage, '--json'], {
|
|
290
|
+
detached: true,
|
|
291
|
+
stdio: 'ignore',
|
|
292
|
+
shell: true,
|
|
293
|
+
}).unref();
|
|
294
|
+
firstMessageSent = true;
|
|
295
|
+
} catch (err) {
|
|
296
|
+
firstMessageSent = false;
|
|
297
|
+
}
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
// 返回结果
|
|
@@ -305,6 +308,7 @@ function createAgent(rawName, opts) {
|
|
|
305
308
|
configBackup: normalizePath(backupPath),
|
|
306
309
|
birthMessage: birthMessage,
|
|
307
310
|
firstMessageSent: firstMessageSent,
|
|
311
|
+
firstMessageSkipped: !!opts.skipFirstMessage,
|
|
308
312
|
};
|
|
309
313
|
}
|
|
310
314
|
|
package/index.js
CHANGED
|
@@ -319,9 +319,16 @@ function runNew() {
|
|
|
319
319
|
// mc new → 交互输入名字
|
|
320
320
|
// mc new <name> → 直接使用传入的名字
|
|
321
321
|
// mc new <name> --first-message "..." → 自定义首条消息
|
|
322
|
+
// mc new <name> --no-first-message → 仅创建,不发送首条消息(供模板部署使用)
|
|
322
323
|
const rawName = args[1];
|
|
323
324
|
const firstMessageIdx = args.indexOf('--first-message');
|
|
324
325
|
const customFirstMessage = firstMessageIdx !== -1 ? args[firstMessageIdx + 1] : null;
|
|
326
|
+
const skipFirstMessage = args.includes('--no-first-message');
|
|
327
|
+
|
|
328
|
+
if (customFirstMessage && skipFirstMessage) {
|
|
329
|
+
console.error(R + '--first-message 和 --no-first-message 不能同时使用。' + NC);
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
325
332
|
|
|
326
333
|
if (rawName) {
|
|
327
334
|
doCreate(rawName);
|
|
@@ -402,6 +409,7 @@ function runNew() {
|
|
|
402
409
|
var result;
|
|
403
410
|
try {
|
|
404
411
|
const createOpts = customFirstMessage ? { firstMessage: customFirstMessage } : {};
|
|
412
|
+
createOpts.skipFirstMessage = skipFirstMessage;
|
|
405
413
|
createOpts.agentId = agentId;
|
|
406
414
|
createOpts.displayName = displayName;
|
|
407
415
|
result = require('./create_agent').createAgent(input, createOpts);
|
package/package.json
CHANGED
package/server/sync_workspace.py
CHANGED
|
@@ -1425,7 +1425,8 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
|
|
|
1425
1425
|
def _handle_template_deploy(self):
|
|
1426
1426
|
"""POST /api/template/deploy Body: {"folder": "a100_...", "agent": "playgrounds"}
|
|
1427
1427
|
agent 默认 "playgrounds";不传则自动生成唯一名 tpl-MMDDHHMM。
|
|
1428
|
-
流程:mc new {agent}
|
|
1428
|
+
流程:mc new {agent} --no-first-message(已存在忽略)
|
|
1429
|
+
→ 复制模板 → 同步发送模板提示词
|
|
1429
1430
|
"""
|
|
1430
1431
|
try:
|
|
1431
1432
|
length = int(self.headers.get('Content-Length', 0))
|
|
@@ -1448,9 +1449,15 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
|
|
|
1448
1449
|
version_str = os.path.basename(template_path) # template_path 末段就是 v1/v2...
|
|
1449
1450
|
agent_name = '{}-{}-{}'.format(series_num, version_str, datetime.now().strftime('%H%M'))
|
|
1450
1451
|
|
|
1451
|
-
#
|
|
1452
|
+
# 模板流程不发送生日初始化消息;文件复制完成后再发模板提示词。
|
|
1453
|
+
# 普通的 `mc new <name>` 行为不受影响。
|
|
1452
1454
|
try:
|
|
1453
|
-
ret = subprocess.run(
|
|
1455
|
+
ret = subprocess.run(
|
|
1456
|
+
['mc', 'new', agent_name, '--no-first-message'],
|
|
1457
|
+
capture_output=True,
|
|
1458
|
+
text=True,
|
|
1459
|
+
timeout=30,
|
|
1460
|
+
)
|
|
1454
1461
|
output = (ret.stdout or '') + (ret.stderr or '')
|
|
1455
1462
|
if ret.returncode != 0 and '已存在' not in output and 'exists' not in output.lower():
|
|
1456
1463
|
self._send_json({'ok': False, 'error': 'mc new 失败: ' + output.strip()}, 500)
|
|
@@ -1464,7 +1471,7 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
|
|
|
1464
1471
|
|
|
1465
1472
|
data, err = self._run_skill_script(
|
|
1466
1473
|
[sys.executable, script, template_path, workspace_path, '--with-tui'],
|
|
1467
|
-
timeout=
|
|
1474
|
+
timeout=90
|
|
1468
1475
|
)
|
|
1469
1476
|
if err:
|
|
1470
1477
|
self._send_json({'ok': False, 'error': err}, 500)
|
|
@@ -1731,4 +1738,4 @@ if __name__ == "__main__":
|
|
|
1731
1738
|
try:
|
|
1732
1739
|
reconcile_loop()
|
|
1733
1740
|
except KeyboardInterrupt:
|
|
1734
|
-
print("\n[exit] 收到中断,退出")
|
|
1741
|
+
print("\n[exit] 收到中断,退出")
|
|
@@ -46,9 +46,9 @@ python3 scripts/run_playgrounds_flow.py <template_path>
|
|
|
46
46
|
- 只收 1 个参数:模板路径
|
|
47
47
|
- 内部自动执行 A + B + C
|
|
48
48
|
- 固定使用 `playgrounds`
|
|
49
|
-
-
|
|
49
|
+
- 自动准备 `playgrounds` Agent
|
|
50
50
|
- 自动复制到 `workspace-playgrounds/remix/实例名`
|
|
51
|
-
-
|
|
51
|
+
- 自动通过 `openclaw agent --session-key ... --json` 发送提示词,并校验发送结果
|
|
52
52
|
|
|
53
53
|
### 入口 2,指定 workspace 投放
|
|
54
54
|
```bash
|
|
@@ -58,14 +58,14 @@ python3 scripts/deploy_to_workspace.py <template_path> <workspace_path> --with-t
|
|
|
58
58
|
|
|
59
59
|
特点:
|
|
60
60
|
- 只 deploy 时,不进入 tui
|
|
61
|
-
- 加 `--with-tui` 时,deploy
|
|
61
|
+
- 加 `--with-tui` 时,deploy 后继续发送模板提示词(参数名为了兼容保留)
|
|
62
62
|
- 不暴露 `--agent`
|
|
63
63
|
- 不暴露 `--session`
|
|
64
64
|
- agent 从 `workspace-xxx` 自动推导
|
|
65
65
|
|
|
66
66
|
## 统一规则
|
|
67
67
|
|
|
68
|
-
- `实例名 =
|
|
68
|
+
- `实例名 = 目标文件夹名`;session 名在 ASCII 场景下按 OpenClaw 规则转为小写
|
|
69
69
|
- 实例名在 deploy 阶段生成
|
|
70
70
|
- 命名规则默认是:`月日_原模板名_时分`
|
|
71
71
|
- 如果同一分钟同名冲突,会自动加 `_2`、`_3`
|
|
@@ -130,8 +130,8 @@ def parse_args(argv):
|
|
|
130
130
|
return source_dir, workspace, agent, do_tui
|
|
131
131
|
|
|
132
132
|
|
|
133
|
-
def run(cmd):
|
|
134
|
-
return subprocess.run(cmd, capture_output=True, text=True)
|
|
133
|
+
def run(cmd, timeout=None):
|
|
134
|
+
return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
def choose_entry_file(target_dir: Path):
|
|
@@ -197,9 +197,54 @@ def main():
|
|
|
197
197
|
if not agent:
|
|
198
198
|
fail({'ok': False, 'error': 'workspace_agent_not_inferable', 'message': 'workspace 路径必须形如 workspace-xxx,才能启用 --with-tui'})
|
|
199
199
|
message = build_message(folder_rel_path, entry_rel_path, target_dir)
|
|
200
|
-
|
|
200
|
+
# OpenClaw 会将 ASCII session key 标准化为小写;返回同样的值,
|
|
201
|
+
# 避免前端跳转到一个大小写不一致的空会话。
|
|
202
|
+
session_name = instance_name.lower()
|
|
203
|
+
session_key = f'agent:{agent}:{session_name}'
|
|
204
|
+
try:
|
|
205
|
+
result = run([
|
|
206
|
+
'openclaw', 'agent',
|
|
207
|
+
'--agent', agent,
|
|
208
|
+
'--session-key', session_key,
|
|
209
|
+
'--message', message,
|
|
210
|
+
'--thinking', 'off',
|
|
211
|
+
'--timeout', '60',
|
|
212
|
+
'--json',
|
|
213
|
+
], timeout=75)
|
|
214
|
+
except subprocess.TimeoutExpired as exc:
|
|
215
|
+
fail({
|
|
216
|
+
'ok': False,
|
|
217
|
+
'error': 'template_prompt_timeout',
|
|
218
|
+
'agent': agent,
|
|
219
|
+
'session': session_name,
|
|
220
|
+
'details': str(exc),
|
|
221
|
+
})
|
|
201
222
|
if result.returncode != 0:
|
|
202
|
-
fail({
|
|
223
|
+
fail({
|
|
224
|
+
'ok': False,
|
|
225
|
+
'error': 'template_prompt_failed',
|
|
226
|
+
'agent': agent,
|
|
227
|
+
'session': session_name,
|
|
228
|
+
'details': result.stderr or result.stdout,
|
|
229
|
+
})
|
|
230
|
+
try:
|
|
231
|
+
response = json.loads(result.stdout)
|
|
232
|
+
except Exception:
|
|
233
|
+
fail({
|
|
234
|
+
'ok': False,
|
|
235
|
+
'error': 'template_prompt_invalid_response',
|
|
236
|
+
'agent': agent,
|
|
237
|
+
'session': session_name,
|
|
238
|
+
'details': result.stdout or result.stderr,
|
|
239
|
+
})
|
|
240
|
+
if not isinstance(response, dict):
|
|
241
|
+
fail({
|
|
242
|
+
'ok': False,
|
|
243
|
+
'error': 'template_prompt_invalid_response',
|
|
244
|
+
'agent': agent,
|
|
245
|
+
'session': session_name,
|
|
246
|
+
'details': result.stdout,
|
|
247
|
+
})
|
|
203
248
|
tui_started = True
|
|
204
249
|
|
|
205
250
|
print(json.dumps({
|
|
@@ -212,7 +257,8 @@ def main():
|
|
|
212
257
|
'folder_rel_path': folder_rel_path,
|
|
213
258
|
'entry_rel_path': entry_rel_path,
|
|
214
259
|
'tui_started': tui_started,
|
|
215
|
-
'
|
|
260
|
+
'prompt_sent': tui_started,
|
|
261
|
+
'session': session_name if do_tui else instance_name,
|
|
216
262
|
'message': message,
|
|
217
263
|
}, ensure_ascii=False))
|
|
218
264
|
|
|
@@ -46,8 +46,8 @@ def parse_args(argv):
|
|
|
46
46
|
return agent, folder_rel_path, entry_rel_path, session_name
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def run(cmd):
|
|
50
|
-
return subprocess.run(cmd, capture_output=True, text=True)
|
|
49
|
+
def run(cmd, timeout=None):
|
|
50
|
+
return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
def main():
|
|
@@ -59,9 +59,27 @@ def main():
|
|
|
59
59
|
prompt_template = PROMPT_TEMPLATE_PATH.read_text(encoding='utf-8')
|
|
60
60
|
message = prompt_template.replace('{{FOLDER_REL_PATH}}', folder_rel_path).replace('{{ENTRY_REL_PATH}}', entry_rel_path)
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
session_name = session_name.lower()
|
|
63
|
+
try:
|
|
64
|
+
result = run([
|
|
65
|
+
'openclaw', 'agent',
|
|
66
|
+
'--agent', agent,
|
|
67
|
+
'--session-key', f'agent:{agent}:{session_name}',
|
|
68
|
+
'--message', message,
|
|
69
|
+
'--thinking', 'off',
|
|
70
|
+
'--timeout', '60',
|
|
71
|
+
'--json',
|
|
72
|
+
], timeout=75)
|
|
73
|
+
except subprocess.TimeoutExpired as exc:
|
|
74
|
+
fail({'started': False, 'error': 'template_prompt_timeout', 'agent': agent, 'session': session_name, 'details': str(exc)})
|
|
63
75
|
if result.returncode != 0:
|
|
64
|
-
fail({'started': False, 'error': '
|
|
76
|
+
fail({'started': False, 'error': 'template_prompt_failed', 'agent': agent, 'session': session_name, 'details': result.stderr or result.stdout})
|
|
77
|
+
try:
|
|
78
|
+
response = json.loads(result.stdout)
|
|
79
|
+
except Exception:
|
|
80
|
+
fail({'started': False, 'error': 'template_prompt_invalid_response', 'agent': agent, 'session': session_name, 'details': result.stdout or result.stderr})
|
|
81
|
+
if not isinstance(response, dict):
|
|
82
|
+
fail({'started': False, 'error': 'template_prompt_invalid_response', 'agent': agent, 'session': session_name, 'details': result.stdout})
|
|
65
83
|
|
|
66
84
|
print(json.dumps({
|
|
67
85
|
'started': True,
|