promptlineapp 1.10.2 → 1.10.4

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 (2) hide show
  1. package/bin/cli.js +146 -13
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -2380,9 +2380,11 @@ export default function DevAdmin() {
2380
2380
  const [endpoints, setEndpoints] = useState({})
2381
2381
  const [endpointStatus, setEndpointStatus] = useState({}) // { bindingName: { alive: bool, info: obj, loading: string } }
2382
2382
  const [testBinding, setTestBinding] = useState('')
2383
- const [testInput, setTestInput] = useState('Hello, test!')
2383
+ const [testVariables, setTestVariables] = useState({})
2384
+ const [testSchema, setTestSchema] = useState(null) // input_schema from endpoint info
2384
2385
  const [testResult, setTestResult] = useState('')
2385
2386
  const [testing, setTesting] = useState(false)
2387
+ const [loadingSchema, setLoadingSchema] = useState(false)
2386
2388
  const [saved, setSaved] = useState(false)
2387
2389
 
2388
2390
  useEffect(() => {
@@ -2490,6 +2492,57 @@ export default function DevAdmin() {
2490
2492
  }
2491
2493
  }
2492
2494
 
2495
+ // Load schema when test binding changes
2496
+ const loadTestSchema = async (bindingName) => {
2497
+ const epData = typeof endpoints[bindingName] === 'string'
2498
+ ? parseEndpointUrl(endpoints[bindingName])
2499
+ : endpoints[bindingName]
2500
+
2501
+ if (!apiKey) {
2502
+ setTestResult('Error: Set API Key first')
2503
+ setTestSchema(null)
2504
+ return
2505
+ }
2506
+ if (!epData?.id) {
2507
+ setTestResult('Error: Configure endpoint for "' + bindingName + '" first')
2508
+ setTestSchema(null)
2509
+ return
2510
+ }
2511
+
2512
+ setLoadingSchema(true)
2513
+ setTestResult('')
2514
+ try {
2515
+ const proxyPath = getProxyPath(epData.env)
2516
+ const res = await fetch(proxyPath + '/' + epData.id + '/info', {
2517
+ method: 'GET',
2518
+ headers: { 'X-API-Key': apiKey }
2519
+ })
2520
+ const data = await res.json()
2521
+ if (res.ok && data.inputSchema) {
2522
+ setTestSchema(data.inputSchema)
2523
+ const vars = {}
2524
+ Object.keys(data.inputSchema.properties || {}).forEach(key => {
2525
+ vars[key] = ''
2526
+ })
2527
+ setTestVariables(vars)
2528
+ } else {
2529
+ setTestResult('Error: ' + (data.detail || data.error || 'No inputSchema in response'))
2530
+ setTestSchema(null)
2531
+ }
2532
+ } catch (err) {
2533
+ setTestResult('Error: ' + err.message)
2534
+ setTestSchema(null)
2535
+ }
2536
+ setLoadingSchema(false)
2537
+ }
2538
+
2539
+ const handleBindingChange = (bindingName) => {
2540
+ setTestBinding(bindingName)
2541
+ setTestResult('')
2542
+ setTestVariables({})
2543
+ loadTestSchema(bindingName)
2544
+ }
2545
+
2493
2546
  const testEndpoint = async () => {
2494
2547
  const epData = typeof endpoints[testBinding] === 'string'
2495
2548
  ? parseEndpointUrl(endpoints[testBinding])
@@ -2514,7 +2567,10 @@ export default function DevAdmin() {
2514
2567
  'Content-Type': 'application/json',
2515
2568
  'X-API-Key': apiKey
2516
2569
  },
2517
- body: JSON.stringify({ input: { text: testInput } })
2570
+ body: JSON.stringify({
2571
+ input: testVariables,
2572
+ variables: testVariables
2573
+ })
2518
2574
  })
2519
2575
  const data = await res.json()
2520
2576
  if (!res.ok || data.error) {
@@ -2774,13 +2830,28 @@ export default function DevAdmin() {
2774
2830
  <div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
2775
2831
  <select
2776
2832
  value={testBinding}
2777
- onChange={e => setTestBinding(e.target.value)}
2833
+ onChange={e => handleBindingChange(e.target.value)}
2778
2834
  style={{ flex: 1, padding: 8, border: '1px solid #d1d5db', borderRadius: 4 }}
2779
2835
  >
2780
2836
  {availableBindings.map(b => (
2781
2837
  <option key={b.name} value={b.name}>{b.name}</option>
2782
2838
  ))}
2783
2839
  </select>
2840
+ <button
2841
+ onClick={() => loadTestSchema(testBinding)}
2842
+ disabled={loadingSchema}
2843
+ style={{
2844
+ padding: '8px 12px',
2845
+ background: '#fff',
2846
+ color: '#6366f1',
2847
+ border: '1px solid #6366f1',
2848
+ borderRadius: 4,
2849
+ cursor: loadingSchema ? 'wait' : 'pointer',
2850
+ fontSize: 12
2851
+ }}
2852
+ >
2853
+ {loadingSchema ? '...' : '↻ Load Schema'}
2854
+ </button>
2784
2855
  <button
2785
2856
  onClick={testEndpoint}
2786
2857
  disabled={testing}
@@ -2796,22 +2867,84 @@ export default function DevAdmin() {
2796
2867
  {testing ? '...' : 'Send'}
2797
2868
  </button>
2798
2869
  </div>
2799
- <textarea
2800
- value={testInput}
2801
- onChange={e => setTestInput(e.target.value)}
2802
- placeholder="Test input..."
2803
- rows={2}
2804
- style={{ width: '100%', padding: 8, border: '1px solid #d1d5db', borderRadius: 4, marginBottom: 12, resize: 'vertical' }}
2805
- />
2870
+
2871
+ {/* Variable Inputs */}
2872
+ {testSchema?.properties && Object.keys(testSchema.properties).length > 0 ? (
2873
+ <div style={{ marginBottom: 12 }}>
2874
+ <div style={{ fontSize: 12, color: '#6b7280', marginBottom: 8 }}>
2875
+ Variables ({Object.keys(testSchema.properties).length}):
2876
+ </div>
2877
+ <div style={{ display: 'grid', gap: 8 }}>
2878
+ {Object.entries(testSchema.properties).map(([key, prop]) => (
2879
+ <div key={key} style={{ display: 'flex', gap: 8, alignItems: 'flex-start' }}>
2880
+ <label style={{
2881
+ width: 140,
2882
+ fontSize: 12,
2883
+ fontWeight: 500,
2884
+ paddingTop: 8,
2885
+ color: testSchema.required?.includes(key) ? '#111' : '#6b7280'
2886
+ }}>
2887
+ {key}
2888
+ {testSchema.required?.includes(key) && <span style={{ color: '#ef4444' }}>*</span>}
2889
+ </label>
2890
+ {prop.type === 'object' || prop.type === 'array' ? (
2891
+ <textarea
2892
+ value={testVariables[key] || ''}
2893
+ onChange={e => setTestVariables(prev => ({ ...prev, [key]: e.target.value }))}
2894
+ placeholder={prop.description || \`Enter \${key} (JSON)\`}
2895
+ rows={2}
2896
+ style={{
2897
+ flex: 1,
2898
+ padding: 8,
2899
+ border: '1px solid #d1d5db',
2900
+ borderRadius: 4,
2901
+ fontSize: 12,
2902
+ resize: 'vertical'
2903
+ }}
2904
+ />
2905
+ ) : (
2906
+ <input
2907
+ type={prop.type === 'number' || prop.type === 'integer' ? 'number' : 'text'}
2908
+ value={testVariables[key] || ''}
2909
+ onChange={e => setTestVariables(prev => ({ ...prev, [key]: e.target.value }))}
2910
+ placeholder={prop.description || \`Enter \${key}\`}
2911
+ style={{
2912
+ flex: 1,
2913
+ padding: 8,
2914
+ border: '1px solid #d1d5db',
2915
+ borderRadius: 4,
2916
+ fontSize: 12
2917
+ }}
2918
+ />
2919
+ )}
2920
+ </div>
2921
+ ))}
2922
+ </div>
2923
+ </div>
2924
+ ) : (
2925
+ <div style={{
2926
+ padding: 12,
2927
+ background: '#f9fafb',
2928
+ borderRadius: 4,
2929
+ fontSize: 12,
2930
+ color: '#6b7280',
2931
+ marginBottom: 12,
2932
+ textAlign: 'center'
2933
+ }}>
2934
+ {loadingSchema ? 'Loading schema...' : 'Click "Load Schema" to see available variables'}
2935
+ </div>
2936
+ )}
2937
+
2806
2938
  {testResult && (
2807
2939
  <pre style={{
2808
- background: '#f9fafb',
2940
+ background: testResult.startsWith('Error') ? '#fef2f2' : '#f0fdf4',
2809
2941
  padding: 12,
2810
2942
  borderRadius: 4,
2811
2943
  fontSize: 13,
2812
2944
  overflow: 'auto',
2813
- maxHeight: 200,
2814
- whiteSpace: 'pre-wrap'
2945
+ maxHeight: 300,
2946
+ whiteSpace: 'pre-wrap',
2947
+ border: testResult.startsWith('Error') ? '1px solid #fecaca' : '1px solid #bbf7d0'
2815
2948
  }}>
2816
2949
  {testResult}
2817
2950
  </pre>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlineapp",
3
- "version": "1.10.2",
3
+ "version": "1.10.4",
4
4
  "description": "Create PromptLine applications with ease",
5
5
  "author": "PromptLine <support@promptlineops.com>",
6
6
  "license": "MIT",