yaml-flow 8.2.0 → 8.2.2

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 (107) hide show
  1. package/browser/asset-integrity.json +3 -3
  2. package/browser/board-livecards-client.js +1 -1
  3. package/browser/board-livecards-localstorage.js +4 -6
  4. package/cli/{board-live-cards-lib-tjYsPt5U.d.ts → board-live-cards-lib-Iq_XAC09.d.ts} +1 -1
  5. package/cli/browser-api/board-live-cards-browser-adapter.d.ts +4 -3
  6. package/cli/browser-api/board-live-cards-browser-adapter.js +2 -2
  7. package/cli/browser-api/card-store-browser-api.d.ts +1 -1
  8. package/cli/node/artifacts-store-cli.js +8 -8
  9. package/cli/node/board-live-cards-cli.js +8 -8
  10. package/cli/node/fs-board-adapter.d.ts +6 -33
  11. package/cli/node/fs-board-adapter.js +10 -8
  12. package/cli/node/step-machine-cli.js +2 -2
  13. package/cli/{types-CSiGbY__.d.ts → types--rXGWbSR.d.ts} +76 -4
  14. package/examples/board/.board-ws/cards/store/_index.json +17 -0
  15. package/examples/board/.board-ws/cards/store/card-market-prices.json +80 -0
  16. package/examples/board/.board-ws/cards/store/card-portfolio-value.json +90 -0
  17. package/examples/board/.board-ws/cards/store/card-portfolio.json +78 -0
  18. package/examples/board/cards/cardT-market-prices.json +6 -4
  19. package/examples/board/cards/cardT-portfolio-value.json +10 -38
  20. package/examples/board/cards/cardT-portfolio.json +9 -4
  21. package/examples/board/demo-shell-with-server.html +3 -3
  22. package/examples/board/server/board-server.js +593 -0
  23. package/examples/board/server/board-worker/source-def-flows/mock-handler/mock-db.js +13 -0
  24. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/.retain/compliance.db +0 -0
  25. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/.retain/optimus.db +0 -0
  26. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/query.cjs +51 -0
  27. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/seed-cpm.cjs +197 -0
  28. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/seed-cpmV2.cjs +128 -0
  29. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/seed-optimus.cjs +352 -0
  30. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/sqlite-config.json +3 -0
  31. package/examples/board/server/board-worker/source-def-flows/sqlite-handler/sqlite-handler.js +84 -0
  32. package/examples/board/{source-def-flows/url.flow.json → server/board-worker/source-def-flows/sqlite.flow.json} +7 -7
  33. package/examples/board/{source-def-handlers → server/board-worker/source-def-flows/url-handler}/http-source-handler.js +29 -21
  34. package/examples/board/server/board-worker/source-def-flows/url.flow.json +73 -0
  35. package/examples/board/{source_def_flows.json → server/board-worker/source_def_flows.json} +61 -115
  36. package/examples/board/server/board-worker/task-executor.js +475 -0
  37. package/examples/board/server/chat-flow/chat-clear-processing.js +41 -0
  38. package/examples/board/server/chat-flow/chat-open-turn.js +144 -0
  39. package/examples/board/server/chat-flow/chat-write-assistant.js +44 -0
  40. package/examples/board/server/chat-flow/copilot-chat/assistant.js +253 -0
  41. package/examples/board/server/chat-flow/echo-probe/assistant.js +28 -0
  42. package/examples/board/server/chat-flow/flow-steps.json +167 -0
  43. package/examples/board/server-config.json +22 -0
  44. package/examples/board/test/server-http-test.js +707 -0
  45. package/examples/board/test/{portfolio-tracker-sse-worker.js → sse-worker.js} +9 -8
  46. package/examples/board-local/demo-shell-localstorage.html +3 -3
  47. package/lib/{artifacts-store-lib-public-DfU9t5-S.d.cts → artifacts-store-lib-public-C5UL5tyG.d.cts} +3 -31
  48. package/lib/{artifacts-store-lib-public-BPW_C15z.d.ts → artifacts-store-lib-public-GD4H-fFp.d.ts} +3 -31
  49. package/lib/artifacts-store-public.d.cts +3 -3
  50. package/lib/artifacts-store-public.d.ts +3 -3
  51. package/lib/board-live-cards-node.cjs +10 -8
  52. package/lib/board-live-cards-node.d.cts +9 -8
  53. package/lib/board-live-cards-node.d.ts +9 -8
  54. package/lib/board-live-cards-node.js +10 -8
  55. package/lib/{board-live-cards-public-W2zK59m0.d.cts → board-live-cards-public-BLXbcBNk.d.cts} +1 -1
  56. package/lib/{board-live-cards-public-B8b_0k_j.d.ts → board-live-cards-public-BZaNb2mi.d.ts} +1 -1
  57. package/lib/board-live-cards-public.d.cts +2 -2
  58. package/lib/board-live-cards-public.d.ts +2 -2
  59. package/lib/board-live-cards-server-runtime.cjs +4 -6
  60. package/lib/board-live-cards-server-runtime.d.cts +3 -3
  61. package/lib/board-live-cards-server-runtime.d.ts +3 -3
  62. package/lib/board-live-cards-server-runtime.js +4 -6
  63. package/lib/board-livegraph-runtime/index.cjs +2 -2
  64. package/lib/board-livegraph-runtime/index.js +2 -2
  65. package/lib/card-store-public.d.cts +2 -2
  66. package/lib/card-store-public.d.ts +2 -2
  67. package/lib/execution-refs.cjs +1 -1
  68. package/lib/execution-refs.js +1 -1
  69. package/lib/index.cjs +1 -1
  70. package/lib/index.d.cts +1 -1
  71. package/lib/index.d.ts +1 -1
  72. package/lib/index.js +1 -1
  73. package/lib/server-runtime/index.cjs +4 -6
  74. package/lib/server-runtime/index.d.cts +4 -4
  75. package/lib/server-runtime/index.d.ts +4 -4
  76. package/lib/server-runtime/index.js +4 -6
  77. package/lib/step-machine-public/index.d.cts +1 -1
  78. package/lib/step-machine-public/index.d.ts +1 -1
  79. package/lib/{storage-interface-BhAON-gW.d.cts → storage-interface-B6ecOulj.d.cts} +25 -3
  80. package/lib/{storage-interface-BhAON-gW.d.ts → storage-interface-B6ecOulj.d.ts} +25 -3
  81. package/lib/stores/index.d.cts +1 -1
  82. package/lib/stores/index.d.ts +1 -1
  83. package/lib/stores/kv.d.cts +1 -1
  84. package/lib/stores/kv.d.ts +1 -1
  85. package/lib/{types-seTI8zta.d.cts → types-Bztd1KoK.d.cts} +55 -3
  86. package/lib/{types-Bm7IFD7r.d.ts → types-D-xVWPdY.d.ts} +55 -3
  87. package/package.json +1 -1
  88. package/examples/board/demo-chat-copilot.flow.json +0 -38
  89. package/examples/board/demo-chat-copilot.js +0 -185
  90. package/examples/board/demo-chat-echo.flow.json +0 -38
  91. package/examples/board/demo-chat-echo.js +0 -92
  92. package/examples/board/demo-server-config.copilot-chat.json +0 -10
  93. package/examples/board/demo-server-config.json +0 -10
  94. package/examples/board/demo-server.js +0 -629
  95. package/examples/board/demo-task-executor.js +0 -721
  96. package/examples/board/gandalf-cards/card-source-kinds.json +0 -36
  97. package/examples/board/gandalf-cards/cards/_index.json +0 -7
  98. package/examples/board/gandalf-cards/cards/card-source-kinds.json +0 -64
  99. package/examples/board/scripts/copilot_wrapper.bat +0 -157
  100. package/examples/board/scripts/copilot_wrapper_helper.ps1 +0 -190
  101. package/examples/board/scripts/workiq_wrapper.mjs +0 -66
  102. package/examples/board/source-def-flows/copilot.flow.json +0 -33
  103. package/examples/board/source-def-flows/url-list.flow.json +0 -33
  104. package/examples/board/source-def-flows/workiq.flow.json +0 -34
  105. package/examples/board/source-def-handlers/copilot-source-handler.js +0 -141
  106. package/examples/board/test/demo-http-test.js +0 -362
  107. /package/examples/board/{source-def-flows → server/board-worker/source-def-flows}/mock.flow.json +0 -0
@@ -1,36 +0,0 @@
1
- {
2
- "id": "card-source-kinds",
3
- "meta": {
4
- "title": "Source Connection Types",
5
- "tags": ["admin"],
6
- "desc": "Reference card listing the source def kinds supported by the demo task executor.",
7
- "_gandalfCard": true
8
- },
9
- "provides": [],
10
- "compute": [],
11
- "view": {
12
- "elements": [
13
- {
14
- "kind": "table",
15
- "label": "Supported connection types",
16
- "data": {
17
- "bind": "card_data.kinds",
18
- "columns": ["kind", "description"]
19
- }
20
- }
21
- ],
22
- "layout": {
23
- "board": { "col": 4, "order": 99 },
24
- "canvas": { "x": 900, "y": 50, "w": 480, "h": 240 }
25
- }
26
- },
27
- "card_data": {
28
- "kinds": [
29
- { "kind": "mock", "description": "Look up a key in the built-in MOCK_DB dictionary and return static JSON." },
30
- { "kind": "copilot", "description": "Invoke GitHub Copilot CLI using copilot.prompt_template (or top-level prompt_template shorthand) with {{key}} interpolation from _projections and args." },
31
- { "kind": "workiq", "description": "Invoke WorkIQ (Microsoft 365 Copilot) using workiq.query_template with {{key}} interpolation. Requires workiq CLI + az login." },
32
- { "kind": "url", "description": "Single URL fetch via curl with {{key}} interpolation from _projections. Supports method, headers, args, tickersFrom, and cacheTimeout (seconds)." },
33
- { "kind": "url-list", "description": "Fan-out fetch over _projections.url_list (string[]), returning an array of raw JSON responses. Supports method, headers, and cacheTimeout." }
34
- ]
35
- }
36
- }
@@ -1,7 +0,0 @@
1
- {
2
- "card-source-kinds": {
3
- "key": "card-source-kinds",
4
- "checksum": "",
5
- "updatedAt": "2026-05-07T19:32:58.245Z"
6
- }
7
- }
@@ -1,64 +0,0 @@
1
- {
2
- "id": "card-source-kinds",
3
- "meta": {
4
- "title": "Source Connection Types",
5
- "tags": [
6
- "admin"
7
- ],
8
- "desc": "Reference card listing the source def kinds supported by the demo task executor.",
9
- "_gandalfCard": true
10
- },
11
- "provides": [],
12
- "compute": [],
13
- "view": {
14
- "elements": [
15
- {
16
- "kind": "table",
17
- "label": "Supported connection types",
18
- "data": {
19
- "bind": "card_data.kinds",
20
- "columns": [
21
- "kind",
22
- "description"
23
- ]
24
- }
25
- }
26
- ],
27
- "layout": {
28
- "board": {
29
- "col": 4,
30
- "order": 99
31
- },
32
- "canvas": {
33
- "x": 900,
34
- "y": 50,
35
- "w": 480,
36
- "h": 240
37
- }
38
- }
39
- },
40
- "card_data": {
41
- "kinds": [
42
- {
43
- "kind": "mock",
44
- "description": "Look up a key in the built-in MOCK_DB dictionary and return static JSON."
45
- },
46
- {
47
- "kind": "copilot",
48
- "description": "Invoke GitHub Copilot CLI using copilot.prompt_template (or top-level prompt_template shorthand) with {{key}} interpolation from _projections and args."
49
- },
50
- {
51
- "kind": "workiq",
52
- "description": "Invoke WorkIQ (Microsoft 365 Copilot) using workiq.query_template with {{key}} interpolation. Requires workiq CLI + az login."
53
- },
54
- {
55
- "kind": "url",
56
- "description": "Single URL fetch via curl with {{key}} interpolation from _projections. Supports method, headers, args, tickersFrom, and cacheTimeout (seconds)."
57
- },
58
- {
59
- "kind": "url-list",
60
- "description": "Fan-out fetch over _projections.url_list (string[]), returning an array of raw JSON responses. Supports method, headers, and cacheTimeout."
61
- }
62
- ]
63
- }
64
- }
@@ -1,157 +0,0 @@
1
- @echo off
2
- setlocal enabledelayedexpansion
3
-
4
- REM Copilot Wrapper - Manages session isolation for GitHub Copilot CLI
5
- REM Usage: copilot_wrapper.bat <output_file> <session_dir> <working_dir> <request_or_file> <result_type> [agent_name] [model] [result_shape_file]
6
- REM
7
- REM If request_or_file starts with @, it's treated as a file path containing the prompt.
8
- REM Otherwise, it's treated as the prompt string directly.
9
- REM result_type: "raw" to return plain text, "json" to extract JSON (passed to clean_copilot_output.ps1)
10
- REM agent_name: name of the agent for log files (optional)
11
- REM model: passed to copilot with --model flag (optional)
12
-
13
- SET "OUTPUT_FILE=%~1"
14
- SET "SESSION_DIR=%~2"
15
- SET "WORKING_DIR=%~3"
16
- SET "REQUEST_OR_FILE=%~4"
17
- SET "RESULT_TYPE=%~5"
18
- SET "AGENT_NAME=%~6"
19
- SET "MODEL=%~7"
20
- SET "RESULT_SHAPE_FILE=%~8"
21
-
22
- if not defined RESULT_TYPE SET "RESULT_TYPE=raw"
23
-
24
- SET "PROMPT_FILE="
25
- SET "REQUEST="
26
- echo !REQUEST_OR_FILE! | findstr /b "@" >nul
27
- if !errorlevel! equ 0 (
28
- SET "PROMPT_FILE=!REQUEST_OR_FILE:~1!"
29
- ) else (
30
- SET "REQUEST=!REQUEST_OR_FILE!"
31
- )
32
-
33
- SET "_WD_HASH=!WORKING_DIR:\=!"
34
- SET "_WD_HASH=!_WD_HASH:/=!"
35
- SET "_WD_HASH=!_WD_HASH::=!"
36
- SET "_WD_HASH=!_WD_HASH:.=!"
37
- SET "_WD_HASH=!_WD_HASH: =!"
38
- SET "COPILOT_BASE=%TEMP%\copilot-sessions\!_WD_HASH!"
39
- SET "COPILOT_CACHE=%COPILOT_BASE%\session-state"
40
- SET "LOCK_FILE=%COPILOT_BASE%\copilot.lock"
41
- SET "UUID_FILE=%SESSION_DIR%\session.uuid"
42
-
43
- if not exist "%COPILOT_BASE%" mkdir "%COPILOT_BASE%"
44
- if not exist "%COPILOT_CACHE%" mkdir "%COPILOT_CACHE%"
45
- if not exist "%SESSION_DIR%" mkdir "%SESSION_DIR%"
46
-
47
- if exist "%LOCK_FILE%" (
48
- for /f "tokens=*" %%a in ('powershell -NoProfile -Command "if ((Get-Item '%LOCK_FILE%').LastWriteTime -lt (Get-Date).AddMinutes(-20)) { Write-Output 'STALE' }"') do (
49
- if "%%a"=="STALE" (
50
- del "%LOCK_FILE%" 2>nul
51
- )
52
- )
53
- )
54
- :acquire_lock
55
- 2>nul (
56
- >"%LOCK_FILE%" (
57
- echo %DATE% %TIME%
58
- )
59
- ) || (
60
- timeout /t 1 /nobreak >nul
61
- goto acquire_lock
62
- )
63
-
64
- SET "SESSION_UUID="
65
- if exist "%UUID_FILE%" (
66
- set /p SESSION_UUID=<"%UUID_FILE%"
67
- ) else (
68
- for /f "tokens=*" %%a in ('powershell -NoProfile -Command "[guid]::NewGuid().ToString()"') do (
69
- SET "SESSION_UUID=%%a"
70
- )
71
- echo !SESSION_UUID!>"%UUID_FILE%"
72
- )
73
-
74
- SET "CACHE_SESSION_PATH=%COPILOT_CACHE%\!SESSION_UUID!"
75
-
76
- if exist "%SESSION_DIR%\workspace.yaml" (
77
- if exist "!CACHE_SESSION_PATH!" rmdir /s /q "!CACHE_SESSION_PATH!" 2>nul
78
- mkdir "!CACHE_SESSION_PATH!" 2>nul
79
- for %%f in ("%SESSION_DIR%\*") do (
80
- if /i not "%%~nxf"=="session.uuid" (
81
- move /y "%%f" "!CACHE_SESSION_PATH!\" >nul 2>&1
82
- )
83
- )
84
- for /d %%d in ("%SESSION_DIR%\*") do (
85
- robocopy "%%d" "!CACHE_SESSION_PATH!\%%~nxd" /E /MOVE /NFL /NDL /NJH /NJS >nul 2>&1
86
- )
87
- )
88
-
89
- cd /d "%WORKING_DIR%"
90
-
91
- SET "MODEL_FLAG="
92
- if defined MODEL (
93
- SET "MODEL_FLAG=--model !MODEL!"
94
- )
95
-
96
- if defined PROMPT_FILE (
97
- type "!PROMPT_FILE!" | call copilot --allow-all --resume !SESSION_UUID! !MODEL_FLAG! > "%OUTPUT_FILE%" 2>&1
98
- ) else (
99
- call copilot -p "%REQUEST%" --allow-all --resume !SESSION_UUID! !MODEL_FLAG! > "%OUTPUT_FILE%" 2>&1
100
- )
101
-
102
- SET "LOG_DIR=%COPILOT_BASE%\copilot-logs"
103
- if not exist "!LOG_DIR!" mkdir "!LOG_DIR!"
104
- SET "LOG_AGENT=unknown"
105
- if defined AGENT_NAME SET "LOG_AGENT=!AGENT_NAME!"
106
- for /f "tokens=*" %%t in ('powershell -NoProfile -Command "Get-Date -Format 'yyyyMMdd-HHmmss'"') do SET "LOG_TS=%%t"
107
- SET "LOG_FILE=!LOG_DIR!\!LOG_AGENT!_!LOG_TS!.log"
108
- echo === PROMPT (!LOG_TS!) === > "!LOG_FILE!"
109
- echo Agent: !LOG_AGENT! >> "!LOG_FILE!"
110
- echo ResultType: !RESULT_TYPE! >> "!LOG_FILE!"
111
- echo Working Dir: %WORKING_DIR% >> "!LOG_FILE!"
112
- echo --- >> "!LOG_FILE!"
113
- if defined PROMPT_FILE (
114
- type "!PROMPT_FILE!" >> "!LOG_FILE!" 2>nul
115
- ) else (
116
- echo %REQUEST% >> "!LOG_FILE!"
117
- )
118
- echo. >> "!LOG_FILE!"
119
- echo === RESPONSE === >> "!LOG_FILE!"
120
- type "%OUTPUT_FILE%" >> "!LOG_FILE!" 2>nul
121
- echo. >> "!LOG_FILE!"
122
- echo === END === >> "!LOG_FILE!"
123
- for /f "skip=50 tokens=*" %%f in ('dir /b /o-d "!LOG_DIR!\!LOG_AGENT!_*.log" 2^>nul') do (
124
- del "!LOG_DIR!\%%f" 2>nul
125
- )
126
-
127
- powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0copilot_wrapper_helper.ps1" "%OUTPUT_FILE%" "!RESULT_TYPE!" "!RESULT_SHAPE_FILE!"
128
-
129
- REM If JSON extraction failed (exit 2) and result_type is json, retry once with a
130
- REM correction prompt in the same session (--resume SESSION_UUID continues the conversation).
131
- SET "PS1_EXIT=!ERRORLEVEL!"
132
- if "!PS1_EXIT!"=="2" (
133
- SET "RETRY_PROMPT_FILE=%TEMP%\copilot-retry-!RANDOM!.txt"
134
- (
135
- echo Your previous response did not contain a valid JSON object.
136
- echo Please respond with ONLY the JSON object — no markdown, no explanation, no preamble.
137
- echo Start your response with { and end with }.
138
- ) > "!RETRY_PROMPT_FILE!"
139
- type "!RETRY_PROMPT_FILE!" | call copilot --allow-all --resume !SESSION_UUID! !MODEL_FLAG! > "%OUTPUT_FILE%" 2>&1
140
- del "!RETRY_PROMPT_FILE!" 2>nul
141
- REM Re-run PS1 with -IsRetry so it writes skeleton on second failure rather than exit 2
142
- powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0copilot_wrapper_helper.ps1" "%OUTPUT_FILE%" "!RESULT_TYPE!" "!RESULT_SHAPE_FILE!" "-IsRetry"
143
- )
144
-
145
- if exist "!CACHE_SESSION_PATH!" (
146
- for %%f in ("!CACHE_SESSION_PATH!\*") do (
147
- move /y "%%f" "%SESSION_DIR%\" >nul 2>&1
148
- )
149
- for /d %%d in ("!CACHE_SESSION_PATH!\*") do (
150
- robocopy "%%d" "%SESSION_DIR%\%%~nxd" /E /MOVE /NFL /NDL /NJH /NJS >nul 2>&1
151
- )
152
- rmdir "!CACHE_SESSION_PATH!" 2>nul
153
- )
154
-
155
- del "%LOCK_FILE%" 2>nul
156
-
157
- endlocal
@@ -1,190 +0,0 @@
1
- # clean_copilot_output.ps1
2
- # Cleans copilot CLI output: filters noise lines and stats footer.
3
- # Called by copilot_wrapper.bat after copilot runs and after logging (raw log preserved).
4
- #
5
- # Usage: clean_copilot_output.ps1 <output_file> <result_type> [result_shape_file]
6
- # output_file - file containing raw copilot output; overwritten with cleaned result
7
- # result_type=raw - strip noise + stats, write plain text back to output_file
8
- # result_type=json - extract first JSON object whose keys match result_shape;
9
- # if result_shape_file is absent, accepts any valid JSON object
10
- # result_shape_file - (json result_type only) JSON file whose top-level keys are required in output
11
- #
12
- # raw result_type: right for chat responses and task executor source_defs.
13
- # json result_type: right for structured calls where the input contained {prompt, result_shape}.
14
-
15
- param(
16
- [Parameter(Mandatory)][string]$OutputFile,
17
- [Parameter(Mandatory)][string]$ResultType,
18
- [string]$ResultShapeFile = '',
19
- # When $true (retry pass), write shape-skeleton fallback instead of exiting with code 2.
20
- # On first pass, exit 2 signals the caller (.bat) to retry with a correction prompt.
21
- [switch]$IsRetry
22
- )
23
-
24
- if (-not (Test-Path $OutputFile)) { exit 0 }
25
-
26
- $raw = [IO.File]::ReadAllText($OutputFile, [Text.Encoding]::UTF8)
27
- if ([string]::IsNullOrWhiteSpace($raw)) { exit 0 }
28
-
29
- # --- Step 1: Filter noise lines ---
30
- $lines = $raw -split "`r?`n" | Where-Object {
31
- $_ -notmatch "^error: unknown option '--no-warnings'" -and
32
- $_ -notmatch "^Try 'copilot --help' for more information"
33
- }
34
- $cleaned = ($lines -join "`n").Trim()
35
-
36
- # --- Step 1b: Strip copilot-cli tool operation lines ---
37
- # These are internal tool invocations that leak into output:
38
- # ● Create/Read/Edit/List directory/Glob/Check ...
39
- # X Read ... (failed tool ops)
40
- # $ Get-Content/Set-Content ... (PowerShell invocations)
41
- # └ N lines/files found
42
- # ├ ... (tree lines)
43
- # "The agent decision has been simulated and saved to ..."
44
- # session-state file paths
45
- $noiseLines = New-Object System.Collections.Generic.List[string]
46
- $contentLines2 = New-Object System.Collections.Generic.List[string]
47
- foreach ($line in ($cleaned -split "`n")) {
48
- $t = $line.TrimStart()
49
- if ($t -match '^[\u25cf\u2022] ' -or # ● bullet tool ops
50
- $t -match '^X ' -or # X failed tool ops
51
- $t -match '^\$ ' -or # $ shell commands
52
- $t -match '^[\u2514\u251c]' -or # └ ├ tree lines
53
- $t -match 'session-state.*\.json' -or # session-state file projections
54
- $t -match 'agent.decision has been simulated' -or
55
- $t -match 'has been simulated and saved' -or
56
- $t -match '^\d+ (files?|lines?|matches?) found$' -or # "3 files found"
57
- $t -match '^No matches found$' -or
58
- $t -match '^Path does not exist$' -or
59
- $t -match '^\d+ lines?( read)?$') { # "1 line read"
60
- $noiseLines.Add($line)
61
- } else {
62
- $contentLines2.Add($line)
63
- }
64
- }
65
- $cleaned = ($contentLines2 -join "`n").Trim()
66
-
67
- # Write noise to sidecar file for upstream visibility
68
- $NoiseFile = $OutputFile + '.noise'
69
- if ($noiseLines.Count -gt 0) {
70
- $noiseContent = "STRIPPED_LINES=$($noiseLines.Count)`n" + ($noiseLines -join "`n")
71
- [IO.File]::WriteAllText($NoiseFile, $noiseContent, [Text.Encoding]::UTF8)
72
- } elseif (Test-Path $NoiseFile) {
73
- Remove-Item $NoiseFile -Force
74
- }
75
-
76
- # --- Step 2: Strip trailing usage stats ---
77
- $statsPrefixes = @('Total usage est:', 'API time spent:', 'Total session time:',
78
- 'Total code changes:', 'Breakdown by AI model:', 'Session:',
79
- 'Changes', 'Requests', 'Tokens')
80
- $resultLines = New-Object System.Collections.Generic.List[string]
81
- $hitStats = $false
82
- foreach ($line in $cleaned -split "`n") {
83
- if (-not $hitStats) {
84
- foreach ($sp in $statsPrefixes) {
85
- if ($line.TrimStart().StartsWith($sp)) { $hitStats = $true; break }
86
- }
87
- }
88
- if (-not $hitStats) { $resultLines.Add($line) }
89
- }
90
- $cleaned = ($resultLines -join "`n").Trim()
91
-
92
- # --- raw result_type: write cleaned plain text and exit ---
93
- if ($ResultType -eq 'raw') {
94
- if ([string]::IsNullOrWhiteSpace($cleaned)) {
95
- [IO.File]::WriteAllText($OutputFile, '', [Text.Encoding]::UTF8)
96
- } else {
97
- [IO.File]::WriteAllText($OutputFile, $cleaned, [Text.Encoding]::UTF8)
98
- }
99
- exit 0
100
- }
101
-
102
- # --- json result_type: extract JSON object matching result_shape ---
103
-
104
- # Load result_shape keys (if provided) to use as required-key filter
105
- $shapeKeys = @()
106
- if ($ResultShapeFile -and (Test-Path $ResultShapeFile)) {
107
- try {
108
- $shape = [IO.File]::ReadAllText($ResultShapeFile, [Text.Encoding]::UTF8) | ConvertFrom-Json -ErrorAction Stop
109
- $shapeKeys = @($shape.PSObject.Properties.Name)
110
- } catch {}
111
- }
112
-
113
- if ([string]::IsNullOrWhiteSpace($cleaned)) {
114
- $fallback = if ($shapeKeys.Count -gt 0) {
115
- $obj = [ordered]@{}
116
- foreach ($k in $shapeKeys) { $obj[$k] = $null }
117
- $obj | ConvertTo-Json -Depth 2 -Compress
118
- } else { '{}' }
119
- [IO.File]::WriteAllText($OutputFile, $fallback, [Text.Encoding]::UTF8)
120
- exit 0
121
- }
122
-
123
- # Helper: check if a parsed object has all required shape keys
124
- function Test-ShapeMatch($obj) {
125
- if ($shapeKeys.Count -eq 0) { return $true } # no shape constraint — accept any JSON object
126
- foreach ($k in $shapeKeys) {
127
- if (-not $obj.PSObject.Properties[$k]) { return $false }
128
- }
129
- return $true
130
- }
131
-
132
- $foundJson = $null
133
-
134
- # 1: Look in ```json fenced blocks first
135
- if ($cleaned -match '(?s)```json\s*(.*?)```') {
136
- try {
137
- $obj = $Matches[1].Trim() | ConvertFrom-Json -ErrorAction Stop
138
- if (Test-ShapeMatch $obj) { $foundJson = $Matches[1].Trim() }
139
- } catch {}
140
- }
141
-
142
- # 2: Scan for bare JSON objects
143
- if (-not $foundJson) {
144
- $depth = 0; $start = -1
145
- for ($i = 0; $i -lt $cleaned.Length; $i++) {
146
- if ($cleaned[$i] -eq '{') {
147
- if ($depth -eq 0) { $start = $i }
148
- $depth++
149
- } elseif ($cleaned[$i] -eq '}') {
150
- $depth--
151
- if ($depth -eq 0 -and $start -ge 0) {
152
- $candidate = $cleaned.Substring($start, $i - $start + 1)
153
- try {
154
- $obj = $candidate | ConvertFrom-Json -ErrorAction Stop
155
- if (Test-ShapeMatch $obj) {
156
- $foundJson = $candidate
157
- break
158
- }
159
- } catch {}
160
- $start = -1
161
- }
162
- }
163
- }
164
- }
165
-
166
- if ($foundJson) {
167
- [IO.File]::WriteAllText($OutputFile, $foundJson, [Text.Encoding]::UTF8)
168
- } else {
169
- # No matching JSON found — record raw in noise file for upstream visibility
170
- $NoiseFile = $OutputFile + '.noise'
171
- $fallbackNoise = "FALLBACK=no_json_match`nSHAPE_KEYS=$($shapeKeys -join ',')`nRAW_LENGTH=$($cleaned.Length)`n---`n$cleaned"
172
- if (Test-Path $NoiseFile) {
173
- $existing = [IO.File]::ReadAllText($NoiseFile, [Text.Encoding]::UTF8)
174
- [IO.File]::WriteAllText($NoiseFile, "$existing`n$fallbackNoise", [Text.Encoding]::UTF8)
175
- } else {
176
- [IO.File]::WriteAllText($NoiseFile, $fallbackNoise, [Text.Encoding]::UTF8)
177
- }
178
- if ($IsRetry) {
179
- # Second pass — write shape-skeleton so the card gets a structured (empty) result
180
- $fallback = if ($shapeKeys.Count -gt 0) {
181
- $obj = [ordered]@{}
182
- foreach ($k in $shapeKeys) { $obj[$k] = $null }
183
- $obj | ConvertTo-Json -Depth 2 -Compress
184
- } else { '{}' }
185
- [IO.File]::WriteAllText($OutputFile, $fallback, [Text.Encoding]::UTF8)
186
- } else {
187
- # First pass — exit 2 to signal the caller (.bat) to retry with a correction prompt
188
- exit 2
189
- }
190
- }
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * workiq_wrapper.mjs — Calls the demo-server /api/workiq/ask proxy endpoint.
4
- *
5
- * Usage: node workiq_wrapper.mjs <out_file>
6
- * WORKIQ_QUERY env var: the interpolated query string
7
- * WORKIQ_SERVER_URL env var: base URL of demo-server (default: http://127.0.0.1:7799)
8
- *
9
- * The demo-server has a TTY so workiq can produce output there.
10
- * Writes raw WorkIQ response text to <out_file>.
11
- */
12
-
13
- import http from 'node:http';
14
- import fs from 'node:fs';
15
-
16
- const outFile = process.argv[2];
17
- const query = process.env.WORKIQ_QUERY;
18
- const serverBase = (process.env.WORKIQ_SERVER_URL || 'http://127.0.0.1:7799').replace(/\/$/, '');
19
-
20
- if (!outFile) { console.error('workiq_wrapper: missing <out_file> argument'); process.exit(1); }
21
- if (!query) { console.error('workiq_wrapper: WORKIQ_QUERY env var not set'); process.exit(1); }
22
-
23
- const body = JSON.stringify({ query });
24
- const url = new URL('/api/workiq/ask', serverBase);
25
-
26
- const reqOptions = {
27
- hostname: url.hostname,
28
- port: url.port || 80,
29
- path: url.pathname,
30
- method: 'POST',
31
- headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) },
32
- };
33
-
34
- const req = http.request(reqOptions, (res) => {
35
- let data = '';
36
- res.on('data', chunk => { data += chunk; });
37
- res.on('end', () => {
38
- try {
39
- const json = JSON.parse(data);
40
- if (json.error) {
41
- fs.writeFileSync(outFile, `workiq error: ${json.error}`, 'utf8');
42
- process.exit(1);
43
- }
44
- fs.writeFileSync(outFile, json.response || '', 'utf8');
45
- process.exit(0);
46
- } catch {
47
- fs.writeFileSync(outFile, data, 'utf8');
48
- process.exit(0);
49
- }
50
- });
51
- });
52
-
53
- req.on('error', (err) => {
54
- fs.writeFileSync(outFile, `workiq proxy error: ${err.message}\nIs demo-server running at ${serverBase}?`, 'utf8');
55
- process.exit(1);
56
- });
57
-
58
- req.setTimeout(60_000, () => {
59
- req.destroy();
60
- fs.writeFileSync(outFile, 'workiq proxy timeout after 60s', 'utf8');
61
- process.exit(1);
62
- });
63
-
64
- req.write(body);
65
- req.end();
66
-
@@ -1,33 +0,0 @@
1
- {
2
- "id": "demo-source-copilot",
3
- "settings": {
4
- "start_step": "execute",
5
- "max_total_steps": 8,
6
- "timeout_ms": 180000
7
- },
8
- "steps": {
9
- "execute": {
10
- "description": "Execute copilot source def",
11
- "handler": {
12
- "type": "ref",
13
- "howToRun": "demo-local-module",
14
- "whatToRun": { "kind": "fs-path", "value": "./source-def-handlers/copilot-source-handler.js" }
15
- },
16
- "transitions": {
17
- "success": "completed",
18
- "failure": "failed"
19
- }
20
- }
21
- },
22
- "terminal_states": {
23
- "completed": {
24
- "description": "Copilot source succeeded",
25
- "return_intent": "success",
26
- "return_artifacts": ["resultValue", "wroteOutputDirectly"]
27
- },
28
- "failed": {
29
- "description": "Copilot source failed",
30
- "return_intent": "failure"
31
- }
32
- }
33
- }
@@ -1,33 +0,0 @@
1
- {
2
- "id": "demo-source-url-list",
3
- "settings": {
4
- "start_step": "execute",
5
- "max_total_steps": 10,
6
- "timeout_ms": 60000
7
- },
8
- "steps": {
9
- "execute": {
10
- "description": "Execute URL list source def",
11
- "handler": {
12
- "type": "ref",
13
- "howToRun": "demo-local-module",
14
- "whatToRun": { "kind": "fs-path", "value": "./source-def-handlers/http-source-handler.js" }
15
- },
16
- "transitions": {
17
- "success": "completed",
18
- "failure": "failed"
19
- }
20
- }
21
- },
22
- "terminal_states": {
23
- "completed": {
24
- "description": "URL list fetch succeeded",
25
- "return_intent": "success",
26
- "return_artifacts": ["resultValue", "wroteOutputDirectly"]
27
- },
28
- "failed": {
29
- "description": "URL list fetch failed",
30
- "return_intent": "failure"
31
- }
32
- }
33
- }
@@ -1,34 +0,0 @@
1
- {
2
- "id": "demo-source-workiq",
3
- "settings": {
4
- "start_step": "execute",
5
- "max_total_steps": 8,
6
- "timeout_ms": 120000
7
- },
8
- "steps": {
9
- "execute": {
10
- "description": "Execute workiq source def via demo-server HTTP proxy",
11
- "handler": {
12
- "type": "ref",
13
- "howToRun": "http:post",
14
- "whatToRun": { "kind": "http-url", "value": "/api/workiq/ask" }
15
- },
16
- "transitions": {
17
- "success": "completed",
18
- "failure": "failed"
19
- }
20
- }
21
- },
22
- "terminal_states": {
23
- "completed": {
24
- "description": "WorkIQ source succeeded",
25
- "return_intent": "success",
26
- "return_artifacts": ["resultValue", "wroteOutputDirectly"]
27
- },
28
- "failed": {
29
- "description": "WorkIQ source failed",
30
- "return_intent": "failure",
31
- "return_artifacts": ["error"]
32
- }
33
- }
34
- }