@dotdrelle/wiki-manager 0.6.34 → 0.7.3

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 (42) hide show
  1. package/bin/wiki-manager.js +2 -2
  2. package/docker-compose.yml +25 -1
  3. package/package.json +2 -2
  4. package/src/agent/graph.js +2 -19
  5. package/src/cli/wiki-manager.js +236 -129
  6. package/src/commands/slash.js +17 -1
  7. package/src/commands/slash.test.js +78 -0
  8. package/src/core/activity.js +14 -0
  9. package/src/core/agentEvents.js +24 -2
  10. package/src/core/agentLoop.js +164 -0
  11. package/src/core/agentLoop.test.js +85 -0
  12. package/src/core/cacert.js +4 -3
  13. package/src/core/compose.js +4 -3
  14. package/src/core/dockerCompose.test.js +14 -0
  15. package/src/core/documentIntake.test.js +7 -7
  16. package/src/core/env.js +6 -0
  17. package/src/core/jobQueue.js +18 -4
  18. package/src/core/mcp.js +1 -1
  19. package/src/core/queueStore.js +27 -0
  20. package/src/core/queueStore.test.js +31 -0
  21. package/src/core/startupCheck.js +1 -1
  22. package/src/core/startupCheck.test.js +66 -0
  23. package/src/core/wikirc.js +2 -2
  24. package/src/core/workspaces.js +8 -1
  25. package/src/runtime/auth.js +35 -0
  26. package/src/runtime/auth.test.js +21 -0
  27. package/src/runtime/client.js +108 -0
  28. package/src/runtime/lifecycle.js +60 -0
  29. package/src/runtime/queueStore.js +6 -0
  30. package/src/runtime/runner.js +73 -0
  31. package/src/runtime/server.js +160 -0
  32. package/src/runtime/server.test.js +53 -0
  33. package/src/runtime/store.js +292 -0
  34. package/src/runtime/store.test.js +103 -0
  35. package/src/runtime/supervisor.js +98 -0
  36. package/src/runtime/supervisor.test.js +99 -0
  37. package/src/shell/repl.js +132 -17
  38. package/src/shell/repl.test.js +38 -0
  39. package/src/shell/tui.tsx +4 -1
  40. package/src/shell/useAgent.ts +20 -2
  41. package/src/shell/useSession.ts +146 -11
  42. package/wiki-workspace +39 -30
package/wiki-workspace CHANGED
@@ -225,9 +225,14 @@ agents_compose() {
225
225
  mkdir -p "$agents_data_dir/cme" "$agents_data_dir/documents/input" "$agents_data_dir/documents/output" "$agents_data_dir/documents/uploads"
226
226
  mkdir -p "$workspaces_root"
227
227
  $do_pull && _agents_dc pull
228
- _agents_dc up -d
228
+ local up_args=(up -d)
229
+ if [[ -n "$CACERT_PATH" ]]; then
230
+ up_args+=(--force-recreate)
231
+ fi
232
+ _agents_dc "${up_args[@]}"
229
233
  printf 'Workspaces root: %s\n' "$workspaces_root"
230
234
  printf 'Agents data: %s\n' "$agents_data_dir"
235
+ [[ -z "$CACERT_PATH" ]] || printf 'CA cert: %s -> /wiki-manager-ca.pem\n' "$CACERT_PATH"
231
236
  printf 'Agents: cme=:%s documents=:%s mailer=:%s\n' \
232
237
  "${CME_MCP_PORT:-3336}" "${DOCUMENTS_MCP_PORT:-3337}" "${MAILER_MCP_PORT:-3335}"
233
238
  ;;
@@ -473,13 +478,14 @@ compose_for_workspace() {
473
478
  local workspace="$1"
474
479
  shift
475
480
  need_workspace_env "$workspace"
476
- local workspace_env ws_path serve_port mcp_port prod_port project
481
+ local workspace_env ws_path serve_port mcp_port prod_port project agents_data_dir
477
482
  workspace_env="$(workspace_env_file "$workspace")"
478
483
  ws_path="$(normalize_path "$(workspace_value "$workspace" WIKI_WORKSPACE_PATH)")"
479
484
  serve_port="$(workspace_value "$workspace" WIKI_SERVE_PORT 3100)"
480
485
  mcp_port="$(workspace_value "$workspace" WIKI_MCP_PORT 3101)"
481
486
  prod_port="$(workspace_value "$workspace" PRODUCTION_MCP_PORT 3102)"
482
487
  project="$(compose_project "$workspace")"
488
+ agents_data_dir="$(absolute_path "${AGENTS_DATA_DIR:-.agents-data}" "$DEFAULT_MANAGER_DIR")"
483
489
 
484
490
  local compose_env_args=()
485
491
  [[ -f "$MANAGER_ENV_FILE" ]] && compose_env_args+=(--env-file "$MANAGER_ENV_FILE")
@@ -495,6 +501,7 @@ compose_for_workspace() {
495
501
  WIKI_SERVE_PORT="$serve_port" \
496
502
  WIKI_MCP_PORT="$mcp_port" \
497
503
  PRODUCTION_MCP_PORT="$prod_port" \
504
+ AGENTS_DATA_DIR="$agents_data_dir" \
498
505
  docker compose --project-directory "$DEFAULT_MANAGER_DIR" \
499
506
  ${compose_env_args[@]+"${compose_env_args[@]}"} -f "$ROOT_DIR/docker-compose.yml" ${cacert_args[@]+"${cacert_args[@]}"} -p "$project" "$@"
500
507
  }
@@ -524,41 +531,41 @@ cacert_compose_args() {
524
531
  local compose_file="$1"
525
532
  local override_name="$2"
526
533
  [[ -n "$CACERT_PATH" ]] || return 0
527
- command -v node >/dev/null 2>&1 || die "--cacert requires node to generate Docker Compose overrides"
528
534
 
529
535
  local services
530
536
  services="$(
531
- ROOT_DIR="$ROOT_DIR" _WIKI_COMPOSE_FILE_PATH="$compose_file" node <<'NODE'
532
- const { createRequire } = require('node:module');
533
- const fs = require('node:fs');
534
- const requireFromPackage = createRequire(`${process.env.ROOT_DIR}/package.json`);
535
- const YAML = requireFromPackage('yaml');
536
- const parsed = YAML.parse(fs.readFileSync(process.env._WIKI_COMPOSE_FILE_PATH, 'utf8')) ?? {};
537
- for (const service of Object.keys(parsed.services ?? {})) {
538
- console.log(service);
539
- }
540
- NODE
537
+ awk '
538
+ /^[[:space:]]*services:[[:space:]]*$/ { in_services=1; next }
539
+ in_services && /^[^[:space:]#]/ { exit }
540
+ in_services && /^ [A-Za-z0-9_.-]+:[[:space:]]*$/ {
541
+ line=$0
542
+ sub(/^ /, "", line)
543
+ sub(/:[[:space:]]*$/, "", line)
544
+ print line
545
+ }
546
+ ' "$compose_file"
541
547
  )"
542
548
  [[ -n "$services" ]] || return 0
543
549
 
544
550
  mkdir -p "$MANAGER_RUNTIME_DIR"
545
551
  local override_path="$MANAGER_RUNTIME_DIR/$override_name"
546
- {
547
- printf '# Generated by wiki-manager. Safe to delete.\n'
548
- printf '# Rewritten when --cacert is used with a Docker Compose command.\n'
549
- printf 'services:\n'
550
- while IFS= read -r service || [[ -n "$service" ]]; do
551
- [[ -n "$service" ]] || continue
552
- printf ' %s:\n' "$service"
553
- printf ' volumes:\n'
554
- printf ' - %s:/wiki-manager-ca.pem:ro\n' "$CACERT_PATH"
555
- printf ' environment:\n'
556
- printf ' NODE_EXTRA_CA_CERTS: /wiki-manager-ca.pem\n'
557
- printf ' SSL_CERT_FILE: /wiki-manager-ca.pem\n'
558
- printf ' REQUESTS_CA_BUNDLE: /wiki-manager-ca.pem\n'
559
- printf ' CURL_CA_BUNDLE: /wiki-manager-ca.pem\n'
560
- done <<< "$services"
561
- } > "$override_path"
552
+ if [[ ! -f "$override_path" ]]; then
553
+ {
554
+ printf '# Generated by wiki-manager. Edit freely; delete to regenerate.\n'
555
+ printf 'services:\n'
556
+ while IFS= read -r service || [[ -n "$service" ]]; do
557
+ [[ -n "$service" ]] || continue
558
+ printf ' %s:\n' "$service"
559
+ printf ' volumes:\n'
560
+ printf ' - %s:/wiki-manager-ca.pem:ro\n' "$CACERT_PATH"
561
+ printf ' environment:\n'
562
+ printf ' NODE_EXTRA_CA_CERTS: /wiki-manager-ca.pem\n'
563
+ printf ' SSL_CERT_FILE: /wiki-manager-ca.pem\n'
564
+ printf ' REQUESTS_CA_BUNDLE: /wiki-manager-ca.pem\n'
565
+ printf ' CURL_CA_BUNDLE: /wiki-manager-ca.pem\n'
566
+ done <<< "$services"
567
+ } > "$override_path"
568
+ fi
562
569
  printf '%s\n' -f "$override_path"
563
570
  }
564
571
 
@@ -685,7 +692,8 @@ config_workspace() {
685
692
  local env_file="$target_path/.env"
686
693
  [[ -f "$env_file" ]] && die "workspace already configured: $env_file"
687
694
 
688
- local port_base serve_port mcp_port prod_port wiki_token prod_token
695
+ local port_base serve_port mcp_port prod_port wiki_token prod_token agents_data_dir
696
+ agents_data_dir="$(absolute_path "${AGENTS_DATA_DIR:-.agents-data}" "$DEFAULT_MANAGER_DIR")"
689
697
  port_base="$(find_free_workspace_port_base 3100)"
690
698
  serve_port="$port_base"
691
699
  mcp_port=$((port_base + 1))
@@ -720,6 +728,7 @@ config_workspace() {
720
728
  WIKI_WORKSPACE_PATH="$target_path" \
721
729
  WIKI_SERVE_PORT="$serve_port" \
722
730
  WIKI_MCP_PORT="$mcp_port" \
731
+ AGENTS_DATA_DIR="$agents_data_dir" \
723
732
  docker compose --project-directory "$DEFAULT_MANAGER_DIR" \
724
733
  ${compose_env_args[@]+"${compose_env_args[@]}"} -f "$ROOT_DIR/docker-compose.yml" ${cacert_args[@]+"${cacert_args[@]}"} run --rm wiki init
725
734