crewcode-plugin-cli 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "crewcode-plugin-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Command-line tool for scaffolding, developing, and packaging CrewCode plugins.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,3 +1,7 @@
1
+ // Official CrewCode plugin API. GENERATED from crewcode-plugin-api/src — do not edit by hand.
2
+ // Vendored so this template builds with no external dependency.
3
+ // If you prefer a managed dependency: npm install crewcode-plugin-api
4
+
1
5
  export const CREWCODE_PLUGIN_API_VERSION = '0.1' as const
2
6
 
3
7
  export type CrewCodePluginApiVersion = typeof CREWCODE_PLUGIN_API_VERSION
@@ -18,6 +22,12 @@ export interface CrewCodePluginOpenContext {
18
22
 
19
23
  export interface CrewCodePluginContext {
20
24
  type: 'crewcode:context'
25
+ /**
26
+ * The plugin API version of the running CrewCode host. Use it to feature-detect
27
+ * at runtime, e.g. `if (ctx.hostApiVersion !== crewcode.apiVersion) { ... }`.
28
+ * Optional for backward compatibility with hosts that predate this field.
29
+ */
30
+ hostApiVersion?: string
21
31
  pluginId: string
22
32
  registrationId: string
23
33
  workspace: CrewCodeWorkspaceContext | null
@@ -69,10 +79,20 @@ interface PendingRequest<T = unknown> {
69
79
  }
70
80
 
71
81
  export interface CreateCrewCodeApiOptions {
82
+ /** Milliseconds before an unanswered request rejects. Default 10000. */
72
83
  timeoutMs?: number
84
+ /** postMessage targetOrigin. Default '*'. */
73
85
  targetOrigin?: string
74
86
  }
75
87
 
88
+ // Reserved v0 namespaces: these are declared for forward-compat but the host
89
+ // gate denies them from iframes today. Reject early with an actionable message
90
+ // instead of round-tripping to the host only to fail there.
91
+ const RESERVED_NETWORK_MESSAGE =
92
+ 'crewcode.network.fetch is reserved in plugin API v0. Use an agentProvider runtime (http/sse-http/openai-compatible/websocket) for network access.'
93
+ const RESERVED_SECRETS_MESSAGE =
94
+ 'crewcode.secrets.get is reserved in plugin API v0. Use a provider apiKeyEnv or local CLI auth instead.'
95
+
76
96
  export function createCrewCodeApi(options: CreateCrewCodeApiOptions = {}): CrewCodePluginApi {
77
97
  const timeoutMs = options.timeoutMs ?? 10_000
78
98
  const targetOrigin = options.targetOrigin ?? '*'
@@ -103,6 +123,10 @@ export function createCrewCodeApi(options: CreateCrewCodeApiOptions = {}): CrewC
103
123
  }
104
124
 
105
125
  window.addEventListener('message', event => {
126
+ // Only trust messages from the embedding CrewCode renderer, never sibling
127
+ // frames or nested content injected into the panel.
128
+ if (event.source !== window.parent) return
129
+
106
130
  const msg = event.data as Record<string, unknown> | null
107
131
  if (!msg || typeof msg !== 'object') return
108
132
 
@@ -135,10 +159,10 @@ export function createCrewCodeApi(options: CreateCrewCodeApiOptions = {}): CrewC
135
159
  writeFile: (sub, text) => request<WorkspaceWriteFileResult>('workspace:writeFile', { sub, text }),
136
160
  },
137
161
  network: {
138
- fetch: (input, init) => request<never>('network:fetch', { input, init }),
162
+ fetch: () => Promise.reject(new Error(RESERVED_NETWORK_MESSAGE)),
139
163
  },
140
164
  secrets: {
141
- get: key => request<never>('secrets:get', { key }),
165
+ get: () => Promise.reject(new Error(RESERVED_SECRETS_MESSAGE)),
142
166
  },
143
167
  }
144
168
  }
@@ -1,10 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
- import { crewcode, type CrewCodeContext } from './crewcode-api'
3
+ import { crewcode, type CrewCodePluginContext } from './crewcode-api'
4
4
  import './style.css'
5
5
 
6
6
  function App() {
7
- const [ctx, setCtx] = useState<CrewCodeContext | null>(null)
7
+ const [ctx, setCtx] = useState<CrewCodePluginContext | null>(null)
8
8
  const [files, setFiles] = useState<string[]>([])
9
9
  const [status, setStatus] = useState('waiting for CrewCode context…')
10
10