office-core 0.1.0

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 (40) hide show
  1. package/.runtime-dist/scripts/bundle-host-package.js +46 -0
  2. package/.runtime-dist/scripts/demo-multi-agent.js +130 -0
  3. package/.runtime-dist/scripts/home-agent-host.js +1403 -0
  4. package/.runtime-dist/scripts/host-doctor.js +28 -0
  5. package/.runtime-dist/scripts/host-login.js +32 -0
  6. package/.runtime-dist/scripts/host-menu.js +227 -0
  7. package/.runtime-dist/scripts/host-open.js +20 -0
  8. package/.runtime-dist/scripts/install-host.js +108 -0
  9. package/.runtime-dist/scripts/lib/host-config.js +171 -0
  10. package/.runtime-dist/scripts/lib/local-runner.js +287 -0
  11. package/.runtime-dist/scripts/office-cli.js +698 -0
  12. package/.runtime-dist/scripts/run-local-project.js +277 -0
  13. package/.runtime-dist/src/auth/session-token.js +62 -0
  14. package/.runtime-dist/src/discord/outbox-ledger.js +56 -0
  15. package/.runtime-dist/src/do/AgentDO.js +205 -0
  16. package/.runtime-dist/src/do/GatewayShardDO.js +9 -0
  17. package/.runtime-dist/src/do/ProjectDO.js +829 -0
  18. package/.runtime-dist/src/do/TaskDO.js +356 -0
  19. package/.runtime-dist/src/index.js +123 -0
  20. package/.runtime-dist/src/project/office-view.js +405 -0
  21. package/.runtime-dist/src/project/read-model.js +79 -0
  22. package/.runtime-dist/src/routes/agents-bootstrap.js +9 -0
  23. package/.runtime-dist/src/routes/agents-descriptor.js +12 -0
  24. package/.runtime-dist/src/routes/agents-events.js +17 -0
  25. package/.runtime-dist/src/routes/agents-heartbeat.js +21 -0
  26. package/.runtime-dist/src/routes/agents-task-context.js +17 -0
  27. package/.runtime-dist/src/routes/bundles.js +198 -0
  28. package/.runtime-dist/src/routes/local-host.js +49 -0
  29. package/.runtime-dist/src/routes/projects.js +119 -0
  30. package/.runtime-dist/src/routes/tasks.js +67 -0
  31. package/.runtime-dist/src/task/reducer.js +464 -0
  32. package/.runtime-dist/src/types/project.js +1 -0
  33. package/.runtime-dist/src/types/protocol.js +3 -0
  34. package/.runtime-dist/src/types/runtime.js +1 -0
  35. package/README.md +148 -0
  36. package/bin/double-penetration-host.mjs +83 -0
  37. package/package.json +48 -0
  38. package/public/index.html +1581 -0
  39. package/public/install-host.ps1 +64 -0
  40. package/scripts/run-runtime-script.mjs +43 -0
@@ -0,0 +1,64 @@
1
+ param(
2
+ [string]$BaseUrl = "https://office-core.reif-ianson94.workers.dev",
3
+ [string]$ProjectId = "prj_local",
4
+ [string]$Workdir = (Get-Location).Path,
5
+ [string]$EnrollmentSecret = "office-host-enroll-secret",
6
+ [switch]$StartHost,
7
+ [switch]$OpenUi
8
+ )
9
+
10
+ $ErrorActionPreference = "Stop"
11
+
12
+ function Require-Command($Name) {
13
+ if (-not (Get-Command $Name -ErrorAction SilentlyContinue)) {
14
+ throw "Required command not found: $Name"
15
+ }
16
+ }
17
+
18
+ $BaseUrl = $BaseUrl.TrimEnd("/")
19
+ Require-Command npm
20
+
21
+ $tempDir = Join-Path $env:TEMP ("office-core-install-" + [guid]::NewGuid().ToString("N"))
22
+ New-Item -ItemType Directory -Force -Path $tempDir | Out-Null
23
+
24
+ try {
25
+ $packageUrl = "$BaseUrl/downloads/office-core.tgz"
26
+ $packagePath = Join-Path $tempDir "office-core.tgz"
27
+
28
+ Write-Host "Downloading Office Core package from $packageUrl" -ForegroundColor Cyan
29
+ Invoke-WebRequest -Uri $packageUrl -OutFile $packagePath
30
+
31
+ Write-Host "Installing Office Core CLI globally..." -ForegroundColor Cyan
32
+ npm install -g $packagePath
33
+ if ($LASTEXITCODE -ne 0) {
34
+ throw "npm install -g failed"
35
+ }
36
+
37
+ Write-Host "Registering this machine with $BaseUrl ..." -ForegroundColor Cyan
38
+ office-core install --baseUrl $BaseUrl --project $ProjectId --workdir $Workdir --enrollSecret $EnrollmentSecret
39
+ if ($LASTEXITCODE -ne 0) {
40
+ throw "office-core install failed"
41
+ }
42
+
43
+ if ($StartHost) {
44
+ Write-Host "Starting configured office core host..." -ForegroundColor Cyan
45
+ Start-Process -FilePath "office-core" -ArgumentList "start"
46
+ }
47
+
48
+ if ($OpenUi) {
49
+ Write-Host "Opening office in browser..." -ForegroundColor Cyan
50
+ Start-Process "$BaseUrl/?projectId=$ProjectId"
51
+ }
52
+
53
+ Write-Host ""
54
+ Write-Host "Machine installed." -ForegroundColor Green
55
+ Write-Host "Next commands:" -ForegroundColor Green
56
+ Write-Host " office-core"
57
+ Write-Host " office-core doctor"
58
+ Write-Host " office-core start"
59
+ Write-Host ""
60
+ Write-Host "Aliases also work: office-host, dp-host" -ForegroundColor DarkGray
61
+ }
62
+ finally {
63
+ Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
64
+ }
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { existsSync } from 'node:fs';
4
+ import path from 'node:path';
5
+ import process from 'node:process';
6
+ import { spawnSync } from 'node:child_process';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
10
+ const [relativeScript, ...args] = process.argv.slice(2);
11
+
12
+ if (!relativeScript) {
13
+ console.error('Usage: node scripts/run-runtime-script.mjs <relative-script.ts> [...args]');
14
+ process.exit(1);
15
+ }
16
+
17
+ const tscCli = path.join(rootDir, 'node_modules', 'typescript', 'bin', 'tsc');
18
+ const compiledScript = path.join(rootDir, '.runtime-dist', relativeScript).replace(/\.ts$/, '.js');
19
+ const sourceScript = path.join(rootDir, relativeScript);
20
+
21
+ if (existsSync(tscCli) && existsSync(sourceScript)) {
22
+ const compile = spawnSync(process.execPath, [tscCli, '-p', path.join(rootDir, 'tsconfig.runtime.build.json')], {
23
+ cwd: rootDir,
24
+ stdio: 'inherit',
25
+ env: process.env,
26
+ });
27
+
28
+ if ((compile.status ?? 1) !== 0) {
29
+ process.exit(compile.status ?? 1);
30
+ }
31
+ } else if (!existsSync(compiledScript)) {
32
+ console.error(`Missing compiled runtime: ${compiledScript}`);
33
+ console.error('This install does not include a prebuilt runtime and TypeScript is not available to build one.');
34
+ process.exit(1);
35
+ }
36
+
37
+ const run = spawnSync(process.execPath, [compiledScript, ...args], {
38
+ cwd: rootDir,
39
+ stdio: 'inherit',
40
+ env: process.env,
41
+ });
42
+
43
+ process.exit(run.status ?? 1);